Author: DartPeng
Date: 2010-08-09 04:49:06 -0400 (Mon, 09 Aug 2010)
New Revision: 23990
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/CompoundStructuredDataContentProvider.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/CompoundStructuredDataLabelProvider.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ExtentionInputContentProvider.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ExtentionInputLabelProvider.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IFilePathProcessor.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IXMLStructuredObject.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectorAttributes.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectorCreationDialog.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksReaderFormPage.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/StructuredDataSelectionWizardDailog.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/input/
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/input/InputParameter.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/input/InputType.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavaBeanList.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavaBeanModel.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavaBeanModelFactory.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavaBeanSelectionWizardPage.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavabeanContentProvider.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavabeanStrucutredDataWizard.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavabeanlabelProvider.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/Messages.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/messages.properties
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/IFieldDialog.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/IModelProcsser.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JavaPropertyUtils.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JavaTypeFieldDialog.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/Messages.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/ProjectClassLoader.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/messages.properties
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/BaseViewerInitor.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/IStructuredDataSelectionWizard.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/IViewerInitor.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/Messages.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/StructuredDataSelectionWizard.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/TransformDataWizardSelectionPage.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/TransformSelectWizardNode.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/ViewerInitorStore.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/messages.properties
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractFileSelectionWizardPage.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractStructuredDdataWizard.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractXMLObject.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/Messages.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagList.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagObject.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagPropertyObject.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/WSDLObjectAnalyzer.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLObjectAnalyzer.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataContentProvider.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataLabelProvider.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataWizard.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataWizardPage.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLTemplateCreationWizardPage.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLUtils.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDListContentProvider.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDListLabelProvider.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDObjectAnalyzer.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDStructuredDataWizard.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/messages.properties
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/ISmooksModelValidateListener.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/Messages.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/messages.properties
Modified:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.model/.classpath
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/AbstractSmooksFormEditor.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/ISmooksModelProvider.java
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksProcessGraphicalEditor.java
Log:
JBIDE-6776
regenerate EMF model
Modified: branches/smooks-dmb/plugins/org.jboss.tools.smooks.model/.classpath
===================================================================
--- branches/smooks-dmb/plugins/org.jboss.tools.smooks.model/.classpath 2010-08-09
05:55:07 UTC (rev 23989)
+++ branches/smooks-dmb/plugins/org.jboss.tools.smooks.model/.classpath 2010-08-09
08:49:06 UTC (rev 23990)
@@ -1,11 +1,11 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry exported="true" kind="lib"
path="libs/commons-logging-1.1.1.jar"/>
- <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
- <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="lib"
path="libs/commons-beanutils-1.8.3.jar"/>
- <classpathentry kind="lib"
path="libs/commons-beanutils-bean-collections-1.8.3.jar"/>
- <classpathentry kind="lib"
path="libs/commons-beanutils-core-1.8.3.jar"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry exported="true" kind="lib"
path="libs/commons-logging-1.1.1.jar"/>
+ <classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con"
path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="lib"
path="libs/commons-beanutils-1.8.3.jar"/>
+ <classpathentry kind="lib"
path="libs/commons-beanutils-bean-collections-1.8.3.jar"/>
+ <classpathentry kind="lib"
path="libs/commons-beanutils-core-1.8.3.jar"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Modified: branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF
===================================================================
--- branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF 2010-08-09
05:55:07 UTC (rev 23989)
+++ branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/META-INF/MANIFEST.MF 2010-08-09
08:49:06 UTC (rev 23990)
@@ -18,7 +18,16 @@
org.jboss.tools.smooks.runtime,
org.eclipse.emf.edit,
org.eclipse.zest.core;bundle-version="1.2.0",
- org.eclipse.zest.layouts;bundle-version="1.1.0"
+ org.eclipse.zest.layouts;bundle-version="1.1.0",
+ org.eclipse.jdt;bundle-version="3.6.0",
+ org.eclipse.jdt.core;bundle-version="3.6.0",
+ org.eclipse.jdt.ui;bundle-version="3.6.0",
+ org.eclipse.emf.edit.ui;bundle-version="2.6.0",
+ org.eclipse.xsd;bundle-version="2.6.0",
+ org.eclipse.core.filesystem;bundle-version="1.3.0",
+ org.eclipse.wst.wsdl;bundle-version="1.2.101",
+ javax.wsdl;bundle-version="1.4.0",
+ org.jboss.tools.smooks.templating;bundle-version="1.1.0"
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/CompoundStructuredDataContentProvider.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/CompoundStructuredDataContentProvider.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/CompoundStructuredDataContentProvider.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.jboss.tools.smooks.configuration.editors.wizard.IViewerInitor;
+import org.jboss.tools.smooks.configuration.editors.wizard.ViewerInitorStore;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ * <p>
+ * Apr 12, 2009
+ */
+public class CompoundStructuredDataContentProvider implements ITreeContentProvider {
+
+ private List<ITreeContentProvider> contentProviderList = new
ArrayList<ITreeContentProvider>();
+
+ public CompoundStructuredDataContentProvider() {
+ Collection<IViewerInitor> lists =
ViewerInitorStore.getInstance().getViewerInitorCollection();
+ for (Iterator<IViewerInitor> iterator = lists.iterator(); iterator.hasNext();) {
+ IViewerInitor viewerInitor = (IViewerInitor) iterator.next();
+ contentProviderList.add(viewerInitor.getTreeContentProvider());
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.
+ * Object)
+ */
+ public Object[] getChildren(Object parentElement) {
+ for (Iterator<?> iterator = contentProviderList.iterator(); iterator.hasNext();)
{
+ ITreeContentProvider provider = (ITreeContentProvider) iterator.next();
+ Object[] objs = provider.getChildren(parentElement);
+ if (objs == null || objs.length == 0) {
+ continue;
+ }
+ return objs;
+ }
+ return new Object[] {};
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object
+ * )
+ */
+ public Object getParent(Object element) {
+ for (Iterator<?> iterator = contentProviderList.iterator(); iterator.hasNext();)
{
+ ITreeContentProvider provider = (ITreeContentProvider) iterator.next();
+ Object parent = provider.getParent(element);
+ if (parent == null) {
+ continue;
+ }
+ return parent;
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.
+ * Object)
+ */
+ public boolean hasChildren(Object element) {
+ for (Iterator<?> iterator = contentProviderList.iterator(); iterator.hasNext();)
{
+ ITreeContentProvider provider = (ITreeContentProvider) iterator.next();
+ boolean parent = provider.hasChildren(element);
+ if (!parent) {
+ continue;
+ }
+ return parent;
+ }
+ return false;
+ }
+
+ /*
+ * (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();
+ }
+ for (Iterator<?> iterator = contentProviderList.iterator(); iterator.hasNext();)
{
+ ITreeContentProvider provider = (ITreeContentProvider) iterator.next();
+ Object[] objs = provider.getElements(inputElement);
+ if (objs == null || objs.length == 0) {
+ continue;
+ }
+ return objs;
+ }
+ return new Object[] {};
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.IContentProvider#dispose()
+ */
+ public void dispose() {
+ for (Iterator<?> iterator = contentProviderList.iterator(); iterator.hasNext();)
{
+ ITreeContentProvider provider = (ITreeContentProvider) iterator.next();
+ provider.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:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/CompoundStructuredDataContentProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/CompoundStructuredDataLabelProvider.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/CompoundStructuredDataLabelProvider.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/CompoundStructuredDataLabelProvider.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.smooks.configuration.editors.wizard.IViewerInitor;
+import org.jboss.tools.smooks.configuration.editors.wizard.ViewerInitorStore;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)<p>
+ * Apr 12, 2009
+ */
+public class CompoundStructuredDataLabelProvider extends LabelProvider {
+ private List<ILabelProvider> labelProviderList = new
ArrayList<ILabelProvider>();
+
+ public CompoundStructuredDataLabelProvider() {
+ Collection<IViewerInitor> lists =
ViewerInitorStore.getInstance().getViewerInitorCollection();
+ for (Iterator<IViewerInitor> iterator = lists.iterator(); iterator.hasNext();) {
+ IViewerInitor viewerInitor = (IViewerInitor) iterator.next();
+ labelProviderList.add(viewerInitor.getLabelProvider());
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
+ */
+ @Override
+ public Image getImage(Object element) {
+ for (Iterator<?> iterator = labelProviderList.iterator(); iterator.hasNext();) {
+ ILabelProvider provider = (ILabelProvider) iterator.next();
+ Image img = provider.getImage(element);
+ if (img == null) {
+ continue;
+ }
+ return img;
+ }
+ return super.getImage(element);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
+ */
+ @Override
+ public String getText(Object element) {
+ for (Iterator<?> iterator = labelProviderList.iterator(); iterator.hasNext();) {
+ ILabelProvider provider = (ILabelProvider) iterator.next();
+ String text = provider.getText(element);
+ if (text == null || text.length() == 0) {
+ continue;
+ }
+ return text;
+ }
+ return super.getText(element);
+ }
+
+
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/CompoundStructuredDataLabelProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ExtentionInputContentProvider.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ExtentionInputContentProvider.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ExtentionInputContentProvider.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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;
+
+import java.util.List;
+
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ * <p>
+ * Apr 12, 2009
+ */
+public class ExtentionInputContentProvider 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
+ // ((SmooksGraphicsExtType)inputElement).getInput().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) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ExtentionInputContentProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ExtentionInputLabelProvider.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ExtentionInputLabelProvider.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ExtentionInputLabelProvider.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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;
+
+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.configuration.SmooksModelUtils;
+import org.jboss.tools.smooks.configuration.editors.input.InputParameter;
+import org.jboss.tools.smooks.configuration.editors.input.InputType;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ * <p>
+ * Apr 12, 2009
+ */
+public class ExtentionInputLabelProvider extends LabelProvider implements
ITableLabelProvider {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang
+ * .Object, int)
+ */
+ public Image getColumnImage(Object element, int columnIndex) {
+ if (element instanceof InputType) {
+ String type = ((InputType) element).getType();
+ switch (columnIndex) {
+ case 0:
+ if (SmooksModelUtils.INPUT_TYPE_JAVA.equals(type)) {
+ return SmooksConfigurationActivator.getDefault().getImageRegistry().get(
+ GraphicsConstants.IMAGE_JAVA_FILE);
+ }
+ if (SmooksModelUtils.INPUT_TYPE_XML.equals(type)) {
+ return SmooksConfigurationActivator.getDefault().getImageRegistry().get(
+ 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;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang
+ * .Object, int)
+ */
+ public String getColumnText(Object element, int columnIndex) {
+ if (element instanceof InputType) {
+ String value = ((InputType) element).getPath();
+ if (value == null)
+ value = ""; //$NON-NLS-1$
+ String extValue = ""; //$NON-NLS-1$
+ List<InputParameter> paramers = ((InputType) element).getParameters();
+ for (Iterator<?> iterator = paramers.iterator(); iterator.hasNext();) {
+ InputParameter paramType = (InputParameter) iterator.next();
+// if ("path".equalsIgnoreCase(paramType.getName())) {
+// continue;
+// }
+ extValue += paramType.getName() + "=" + paramType.getValue() +
","; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ 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 ""; //$NON-NLS-1$
+ }
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ExtentionInputLabelProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IFilePathProcessor.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IFilePathProcessor.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IFilePathProcessor.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,16 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.configuration.editors;
+
+import org.eclipse.core.resources.IFile;
+
+/**
+ * @author DartPeng
+ *
+ */
+public interface IFilePathProcessor {
+ String processWorkBenchPath(IFile file);
+
+ String processFileSystemPath(String filePath);
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IFilePathProcessor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IXMLStructuredObject.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IXMLStructuredObject.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IXMLStructuredObject.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,25 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.configuration.editors;
+
+import java.util.List;
+
+/**
+ * @author Dart
+ *
+ */
+public interface IXMLStructuredObject {
+
+ public String getNodeName();
+
+ public List<IXMLStructuredObject> getChildren();
+
+ public IXMLStructuredObject getParent();
+
+ public Object getID();
+
+ public boolean isRootNode();
+
+ public boolean isAttribute();
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IXMLStructuredObject.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectorAttributes.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectorAttributes.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectorAttributes.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,35 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.configuration.editors;
+
+
+/**
+ * @author Dart
+ *
+ */
+public class SelectorAttributes {
+ public static final String ONLY_NAME = "only_name"; //$NON-NLS-1$
+
+ public static final String FULL_PATH = "full_path"; //$NON-NLS-1$
+
+ public static final String IGNORE_ROOT = "ignore_root"; //$NON-NLS-1$
+
+ public static final String INCLUDE_PARENT = "include_parent"; //$NON-NLS-1$
+ private String selectorSperator = "/"; //$NON-NLS-1$
+ private String selectorPolicy = SelectorAttributes.FULL_PATH;
+ public String getSelectorSperator() {
+ return selectorSperator;
+ }
+ public void setSelectorSperator(String selectorSperator) {
+ this.selectorSperator = selectorSperator;
+ }
+ public String getSelectorPolicy() {
+ return selectorPolicy;
+ }
+ public void setSelectorPolicy(String selectorPolicy) {
+ this.selectorPolicy = selectorPolicy;
+ }
+
+
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectorAttributes.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectorCreationDialog.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectorCreationDialog.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectorCreationDialog.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,515 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.window.IShellProvider;
+import org.eclipse.jface.wizard.WizardDialog;
+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.Combo;
+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.eclipse.ui.IEditorPart;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.events.IHyperlinkListener;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Hyperlink;
+import org.jboss.tools.smooks.configuration.SmooksModelUtils;
+import org.jboss.tools.smooks.configuration.editors.input.InputParameter;
+import org.jboss.tools.smooks.configuration.editors.input.InputType;
+import org.jboss.tools.smooks.configuration.editors.java.JavaBeanModel;
+import org.jboss.tools.smooks.configuration.editors.java.JavaBeanModelFactory;
+import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
+import
org.jboss.tools.smooks.configuration.editors.wizard.StructuredDataSelectionWizard;
+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.editor.ISmooksModelProvider;
+import org.jboss.tools.smooks.model.SmooksModel;
+import org.milyn.javabean.dynamic.Model;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ * <p>
+ * Apr 12, 2009
+ */
+public class SelectorCreationDialog extends Dialog {
+
+ private TreeViewer viewer;
+ private Object currentSelection;
+ private Button onlyNameButton;
+ private Button fullPathButton;
+ private SelectorAttributes selectorAttributes = null;
+ private IEditorPart editorPart = null;
+
+ private static Throwable currentException = null;
+
+ private FormToolkit toolkit;
+
+ private IJavaProject currentProject = null;
+
+ public SelectorCreationDialog(IShellProvider parentShell , IJavaProject project) {
+ super(parentShell);
+ currentProject = project;
+ }
+
+ /**
+ * @return the currentException
+ */
+ public static Throwable getCurrentException() {
+ return currentException;
+ }
+
+ public SelectorCreationDialog(Shell parentShell, IEditorPart editorPart , IJavaProject
project) {
+ super(parentShell);
+ selectorAttributes = new SelectorAttributes();
+ this.editorPart = editorPart;
+ currentProject = project;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets
+ * .Composite)
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.heightHint = 500;
+ gd.widthHint = 450;
+ composite.setLayoutData(gd);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ layout.marginHeight = 10;
+ layout.marginWidth = 10;
+ layout.makeColumnsEqualWidth = false;
+ composite.setLayout(layout);
+
+ Label viewerLabel = new Label(composite, SWT.NONE);
+ viewerLabel.setText(Messages.SelectorCreationDialog_InputViewerlabel);
+
+ toolkit = new FormToolkit(getShell().getDisplay());
+
+ Hyperlink link = toolkit
+ .createHyperlink(composite, Messages.SelectorCreationDialog_AddInputLinkLabel,
SWT.NONE);// new
+ // Hyperlink(composite,SWT.NONE);
+ link.setBackground(composite.getBackground());
+ link.addHyperlinkListener(new IHyperlinkListener() {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.forms.events.IHyperlinkListener#linkActivated(
+ * org.eclipse.ui.forms.events.HyperlinkEvent)
+ */
+ public void linkActivated(HyperlinkEvent e) {
+ showInputDataWizard(currentProject);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.forms.events.IHyperlinkListener#linkEntered(org
+ * .eclipse.ui.forms.events.HyperlinkEvent)
+ */
+ public void linkEntered(HyperlinkEvent e) {
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.ui.forms.events.IHyperlinkListener#linkExited(org
+ * .eclipse.ui.forms.events.HyperlinkEvent)
+ */
+ public void linkExited(HyperlinkEvent e) {
+
+ }
+
+ });
+ gd = new GridData();
+ gd.horizontalAlignment = GridData.END;
+ link.setLayoutData(gd);
+
+ viewer = new TreeViewer(composite, SWT.BORDER);
+ viewer.setContentProvider(new CompoundStructuredDataContentProvider());
+ viewer.setLabelProvider(new CompoundStructuredDataLabelProvider());
+ List<Object> inputList = generateInputData(currentProject);
+ viewer.setInput(inputList);
+ viewer.addDoubleClickListener(new IDoubleClickListener() {
+ public void doubleClick(DoubleClickEvent event) {
+ okPressed();
+ }
+ });
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ currentSelection = ((IStructuredSelection) event.getSelection()).getFirstElement();
+ }
+ });
+
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalSpan = 2;
+ viewer.getTree().setLayoutData(gd);
+
+ Label label = new Label(composite, SWT.NONE);
+ label.setText(Messages.SelectorCreationDialog_SperatorCharlabel);
+ final Combo speratorCombo = new Combo(composite, SWT.BORDER | SWT.READ_ONLY);
+ speratorCombo.add(" "); //$NON-NLS-1$
+ speratorCombo.add("/"); //$NON-NLS-1$
+ speratorCombo.select(1);
+ // speratorCombo.setEditable(false);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ speratorCombo.setLayoutData(gd);
+ speratorCombo.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ selectorAttributes.setSelectorSperator(speratorCombo.getText());
+ }
+
+ });
+
+ Label l = new Label(composite, SWT.NONE);
+ l.setText(Messages.SelectorCreationDialog_PolicyLabel);
+ 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 = 2;
+ com.setLayout(gl);
+ fullPathButton = new Button(com, SWT.RADIO);
+ fullPathButton.setText(Messages.SelectorCreationDialog_FullPathPolicy);
+ onlyNameButton = new Button(com, SWT.RADIO);
+ onlyNameButton.setText(Messages.SelectorCreationDialog_OnlyNamePolicy);
+ // Button containtParentButton = new Button(com,SWT.RADIO);
+ // containtParentButton.setText("Containt Parent Name");
+ fullPathButton.setSelection(true);
+
+ handleButtons();
+
+ getShell().setText(Messages.SelectorCreationDialog_DialogTitle);
+
+ SmooksUIUtils.expandSelectorViewer(inputList, viewer);
+
+ return composite;
+ }
+
+ private void handleButtons() {
+ fullPathButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ selectorAttributes.setSelectorPolicy(SelectorAttributes.FULL_PATH);
+ }
+ });
+
+ onlyNameButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ selectorAttributes.setSelectorPolicy(SelectorAttributes.ONLY_NAME);
+ }
+ });
+ }
+
+ public static List<Object> generateInputData(SmooksModel smooksResourceListType ,
IJavaProject project) {
+ currentException = null;
+ List<Object> list = new ArrayList<Object>();
+ if (smooksResourceListType != null) {
+// IJavaProject project = SmooksUIUtils.getJavaProject(smooksResourceListType.get);
+ try {
+ List<InputType> inputLists =
SmooksUIUtils.getInputTypeList(smooksResourceListType);
+ for (Iterator<?> iterator = inputLists.iterator(); iterator.hasNext();) {
+ InputType inputType = (InputType) iterator.next();
+ if (!inputType.isActived())
+ continue;
+ String type = inputType.getType();
+ String path = inputType.getPath();
+ if (type != null && path != null) {
+ path = path.trim();
+// if (SmooksModelUtils.INPUT_TYPE_EDI_1_1.equals(type)
+// || SmooksModelUtils.INPUT_TYPE_EDI_1_2.equals(type)) {
+// EDIDataParser parser = new EDIDataParser();
+// try {
+// TagList tl = parser.parseEDIFile(path, smooksResourceListType);
+// if (tl != null) {
+// list.addAll(((TagList) tl).getChildren());
+// }
+// } catch (Throwable t) {
+// currentException = t;
+// }
+// }
+// if (SmooksModelUtils.INPUT_TYPE_CSV.equals(type)
+// || SmooksModelUtils.INPUT_TYPE_CSV_1_2.equals(type)) {
+// CSVDataParser parser = new CSVDataParser();
+// try {
+// TagList tl = parser.parseCSV(path, smooksResourceListType);
+// if (tl != null) {
+// list.addAll(((TagList) tl).getChildren());
+// }
+// } catch (Throwable t) {
+// currentException = t;
+// }
+// }
+// if (SmooksModelUtils.INPUT_TYPE_JSON_1_1.equals(type)
+// || SmooksModelUtils.INPUT_TYPE_JSON_1_2.equals(type)) {
+// try {
+// JsonInputDataParser parser = new JsonInputDataParser();
+// IXMLStructuredObject tagList =
parser.parseJsonFile(SmooksUIUtils.parseFilePath(path),
+// smooksResourceListType);
+// if (tagList instanceof TagList) {
+// list.addAll(((TagList) tagList).getChildren());
+// } else {
+// list.add(tagList);
+// }
+// } catch (Throwable tt) {
+// currentException = tt;
+// }
+// }
+ if (SmooksModelUtils.INPUT_TYPE_JAVA.equals(type)) {
+ try {
+ Class<?> clazz = SmooksUIUtils.loadClass(path, project);
+ JavaBeanModel model = JavaBeanModelFactory.getJavaBeanModelWithLazyLoad(clazz);
+ if (model != null) {
+ list.add(model);
+ }
+ } catch (Throwable t) {
+ currentException = t;
+ }
+ }
+ if (SmooksModelUtils.INPUT_TYPE_XSD.equals(type)) {
+ try {
+ path = SmooksUIUtils.parseFilePath(path);
+ String rootElementName = null;
+ List<InputParameter> paramers = inputType.getParameters();
+ for (Iterator<?> iterator2 = paramers.iterator(); iterator2.hasNext();) {
+ InputParameter paramType = (InputParameter) iterator2.next();
+ String pn = paramType.getName();
+ if ("rootElement".equals(pn)) { //$NON-NLS-1$
+ rootElementName = paramType.getValue();
+ break;
+ }
+ }
+ if (rootElementName != null) {
+ rootElementName = rootElementName.trim();
+ list.add(new XSDObjectAnalyzer().loadElement(path, rootElementName));
+ }
+ } catch (Throwable tt) {
+ currentException = tt;
+ }
+ }
+ 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 , null);
+ if (model != null) {
+ if (model instanceof TagList) {
+ list.addAll(((TagList) model).getChildren());
+ } else {
+ list.add(model);
+ }
+ }
+ } catch (Throwable e) {
+ currentException = e;
+ }
+ }
+ }
+ }
+ } catch (Exception e) {
+ currentException = e;
+ // SmooksConfigurationActivator.getDefault().log(e);
+ }
+ }
+ return list;
+ }
+
+ public static List<Object> generateInputDataForSmooks10() {
+ List<Object> list = new ArrayList<Object>();
+ // if (extType != null) {
+ // IJavaProject project = SmooksUIUtils.getJavaProject(extType);
+ // try {
+ // List<InputType> inputLists = extType.getInput();
+ // for (Iterator<?> iterator = inputLists.iterator();
+ // iterator.hasNext();) {
+ // InputType inputType = (InputType) iterator.next();
+ // if (!SmooksUIUtils.isActivedInput(inputType))
+ // continue;
+ // String type = inputType.getType();
+ // String path = SmooksModelUtils.getInputPath(inputType);
+ // if (type != null && path != null) {
+ // path = path.trim();
+ // if (SmooksModelUtils.INPUT_TYPE_EDI_1_1.equals(type)
+ // || SmooksModelUtils.INPUT_TYPE_EDI_1_2.equals(type)) {
+ // }
+ // if (SmooksModelUtils.INPUT_TYPE_CSV.equals(type)
+ // || SmooksModelUtils.INPUT_TYPE_CSV_1_2.equals(type)) {
+ // }
+ // if (SmooksModelUtils.INPUT_TYPE_JSON_1_1.equals(type)
+ // || SmooksModelUtils.INPUT_TYPE_JSON_1_2.equals(type)) {
+ // }
+ // if (SmooksModelUtils.INPUT_TYPE_JAVA.equals(type)) {
+ // try {
+ // Class<?> clazz = SmooksUIUtils.loadClass(path, project);
+ // JavaBeanModel model =
+ // JavaBeanModelFactory.getJavaBeanModelWithLazyLoad(clazz);
+ // if (model != null) {
+ // list.add(model);
+ // }
+ // } 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) {
+ // list.addAll(((TagList) model).getChildren());
+ // } else {
+ // list.add(model);
+ // }
+ // }
+ // } catch (Throwable e) {
+ //
+ // }
+ // }
+ // }
+ // }
+ // } catch (Exception e) {
+ // // SmooksConfigurationActivator.getDefault().log(e);
+ // }
+ // }
+ return list;
+ }
+
+ protected List<Object> generateInputData(IJavaProject project) {
+ Model<SmooksModel> obj = null;
+ if (editorPart instanceof ISmooksModelProvider) {
+ obj = ((ISmooksModelProvider) editorPart).getSmooksModel();
+ } else {
+ ISmooksModelProvider provider = (ISmooksModelProvider)
editorPart.getAdapter(ISmooksModelProvider.class);
+ if (provider != null) {
+ obj = provider.getSmooksModel();
+ }
+ }
+ if (obj == null) {
+ List<Object> ll = Collections.emptyList();
+ return ll;
+ }
+ SmooksModel resourceList = obj.getModelRoot();
+ return generateInputData(resourceList,project);
+ }
+
+ protected void showInputDataWizard(IJavaProject project) {
+ StructuredDataSelectionWizard wizard = new StructuredDataSelectionWizard();
+ if (this.editorPart != null) {
+ wizard.setInput(editorPart.getEditorInput());
+ wizard.setSite(editorPart.getEditorSite());
+ }
+
+ wizard.setForcePreviousAndNextButtons(true);
+ StructuredDataSelectionWizardDailog dialog = new
StructuredDataSelectionWizardDailog(this.getShell(), wizard);
+ if (dialog.show() == WizardDialog.OK) {
+ List<Object> input = this.generateInputData(project);
+ this.viewer.setInput(input);
+ SmooksUIUtils.expandSelectorViewer(input, viewer);
+ }
+ }
+
+ /**
+ * @return the currentSelection
+ */
+ public Object getCurrentSelection() {
+ return currentSelection;
+ }
+
+ public SelectorAttributes getSelectorAttributes() {
+ return selectorAttributes;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.dialogs.Dialog#close()
+ */
+ @Override
+ public boolean close() {
+ if (toolkit != null) {
+ toolkit.dispose();
+ }
+ return super.close();
+ }
+
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectorCreationDialog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksReaderFormPage.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksReaderFormPage.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksReaderFormPage.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,1131 @@
+/*******************************************************************************
+ * 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;
+
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.EventObject;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import org.eclipse.core.filesystem.EFS;
+import org.eclipse.core.filesystem.IFileInfo;
+import org.eclipse.core.filesystem.IFileStore;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.common.command.CommandStackListener;
+import org.eclipse.emf.common.command.CommandWrapper;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.command.AddCommand;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.emf.edit.command.RemoveCommand;
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ICheckStateProvider;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableColorProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.events.IHyperlinkListener;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Hyperlink;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.ScrolledPageBook;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.ide.IDE;
+import org.jboss.tools.smooks.configuration.SmooksModelUtils;
+import org.jboss.tools.smooks.configuration.editors.input.InputType;
+import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
+import
org.jboss.tools.smooks.configuration.editors.wizard.IStructuredDataSelectionWizard;
+import
org.jboss.tools.smooks.configuration.editors.wizard.StructuredDataSelectionWizard;
+import org.jboss.tools.smooks.configuration.editors.wizard.ViewerInitorStore;
+import org.jboss.tools.smooks.editor.ISmooksModelProvider;
+import org.jboss.tools.smooks.editor.ISourceSynchronizeListener;
+import org.jboss.tools.smooks.model.SmooksModel;
+import org.jboss.tools.smooks.model.core.ICoreFactory;
+import org.jboss.tools.smooks.model.core.ICorePackage;
+import org.jboss.tools.smooks.model.core.IGlobalParams;
+import org.jboss.tools.smooks.model.core.IParam;
+import org.milyn.SmooksException;
+import org.milyn.javabean.dynamic.Model;
+
+
+
+/**
+ * @author Dart
+ *
+ */
+public class SmooksReaderFormPage extends FormPage implements
ISourceSynchronizeListener,
+ CommandStackListener {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.emf.common.command.CommandStackListener#commandStackChanged
+ * (java.util.EventObject)
+ */
+ public void commandStackChanged(EventObject event) {
+ final Command mostRecentCommand = ((org.eclipse.emf.common.command.CommandStack)
event.getSource())
+ .getMostRecentCommand();
+ getEditorSite().getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ if (mostRecentCommand != null) {
+ Command rawCommand = mostRecentCommand;
+ while (rawCommand instanceof CommandWrapper) {
+ rawCommand = ((CommandWrapper) rawCommand).getCommand();
+ }
+ if (rawCommand instanceof CompoundCommand) {
+ List<Command> command = ((CompoundCommand) rawCommand).getCommandList();
+ for (Iterator<?> iterator = command.iterator(); iterator.hasNext();) {
+ Command command2 = (Command) iterator.next();
+ while (command2 instanceof CommandWrapper) {
+ command2 = ((CommandWrapper) command2).getCommand();
+ }
+ if (handleInputParamChange(command2)) {
+ break;
+ }
+ }
+ } else {
+ handleInputParamChange(rawCommand);
+ }
+ }
+ }
+ });
+ }
+
+ private CheckboxTableViewer inputDataViewer;
+ private TreeViewer inputModelViewer;
+ private Combo readerCombo;
+ private List<Object> readerTypeList = new ArrayList<Object>();
+ private Composite readerConfigComposite;
+// private ModelPanelCreator modelPanelCreator;
+ protected boolean lockCheck = false;
+ private Button removeInputDataButton;
+ private Button addInputDataButton;
+ private ScrolledPageBook scrolledPageBook;
+
+ public SmooksReaderFormPage(FormEditor editor, String id, String title) {
+ super(editor, id, title);
+ }
+
+ public SmooksReaderFormPage(String id, String title) {
+ super(id, title);
+ }
+
+ public ISmooksModelProvider getSmooksModelProvider(){
+ return (ISmooksModelProvider)getEditor();
+ }
+
+
+ private void handleCommandStack(CommandStack commandStack) {
+ commandStack.addCommandStackListener(this);
+ }
+
+ @Override
+ public void init(IEditorSite site, IEditorInput input) {
+ super.init(site, input);
+ if (getEditor() != null && getEditor() instanceof ISmooksModelProvider) {
+ this.handleCommandStack(((ISmooksModelProvider)
getEditor()).getEditingDomain().getCommandStack());
+ }
+ }
+
+ @Override
+ protected void createFormContent(IManagedForm managedForm) {
+ final ScrolledForm form = managedForm.getForm();
+ FormToolkit toolkit = managedForm.getToolkit();
+ form.setText(""); //$NON-NLS-1$
+ // toolkit.decorateFormHeading(form.getForm());
+ // // create master details UI
+ // createMasterDetailBlock(managedForm);
+ Composite leftComposite = toolkit.createComposite(form.getBody());
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.widthHint = 300;
+ leftComposite.setLayoutData(gd);
+
+ Composite rightComposite = toolkit.createComposite(form.getBody());
+ gd = new GridData(GridData.FILL_BOTH);
+ rightComposite.setLayoutData(gd);
+
+ GridLayout lgl = new GridLayout();
+ lgl.marginWidth = 0;
+ lgl.marginHeight = 0;
+ leftComposite.setLayout(lgl);
+
+ GridLayout rgl = new GridLayout();
+ rgl.marginWidth = 0;
+ rgl.marginHeight = 0;
+ rightComposite.setLayout(rgl);
+
+ createReaderSection(toolkit, leftComposite);
+ createInputDataSection(toolkit, rightComposite);
+ createReaderConfigSection(toolkit, leftComposite);
+ createInputModelViewerSection(toolkit, rightComposite);
+
+ handleReaderCombo(readerCombo);
+
+ GridLayout gridLayout = new GridLayout();
+ gridLayout.marginHeight = 13;
+ gridLayout.numColumns = 2;
+ gridLayout.horizontalSpacing = 20;
+ gridLayout.makeColumnsEqualWidth = true;
+ form.getBody().setLayout(gridLayout);
+
+ refreshInputDataButtons();
+ }
+
+ private void refreshInputDataButtons() {
+ this.addInputDataButton.setEnabled(true);
+ this.removeInputDataButton.setEnabled(true);
+
+ String inputType = getSmooksModelProvider().getInputType();
+ if (inputType == null || inputType.trim().equals("")) { //$NON-NLS-1$
+ this.addInputDataButton.setEnabled(false);
+ this.removeInputDataButton.setEnabled(false);
+ }
+ }
+
+ private void createInputModelViewerSection(FormToolkit toolkit, Composite parent) {
+ Section section = toolkit.createSection(parent, Section.TITLE_BAR | Section.TWISTIE |
Section.EXPANDED);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ // gd.verticalAlignment = GridData.BEGINNING;
+ section.setLayoutData(gd);
+ section.setText(Messages.SmooksReaderFormPage_InputSectionTitle);
+ // section.setDescription("View the XML structure model of the input data");
+ FillLayout flayout = new FillLayout();
+ section.setLayout(flayout);
+
+ Composite mainContainer = toolkit.createComposite(section);
+ GridLayout gl = new GridLayout();
+ mainContainer.setLayout(gl);
+ section.setClient(mainContainer);
+
+ Hyperlink refreshLink = toolkit.createHyperlink(mainContainer,
Messages.SmooksReaderFormPage_RefreshLinkLabel,
+ SWT.NONE);
+ refreshLink.addHyperlinkListener(new IHyperlinkListener() {
+
+ public void linkExited(HyperlinkEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void linkEntered(HyperlinkEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void linkActivated(HyperlinkEvent e) {
+ refreshInputModelView();
+ }
+ });
+
+ Composite viewerContainer = toolkit.createComposite(mainContainer);
+ gd = new GridData(GridData.FILL_BOTH);
+ viewerContainer.setLayoutData(gd);
+
+ FillLayout fillLayout = new FillLayout();
+ fillLayout.marginHeight = 1;
+ fillLayout.marginWidth = 1;
+ viewerContainer.setBackground(GraphicsConstants.BORDER_CORLOR);
+ viewerContainer.setLayout(fillLayout);
+ inputModelViewer = new TreeViewer(viewerContainer, SWT.NONE);
+ inputModelViewer.setContentProvider(new CompoundStructuredDataContentProvider());
+ inputModelViewer.setLabelProvider(new CompoundStructuredDataLabelProvider());
+ inputModelViewer.addDoubleClickListener(new IDoubleClickListener() {
+ public void doubleClick(DoubleClickEvent event) {
+ }
+ });
+ inputModelViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ // currentSelection = ((IStructuredSelection)
+ // event.getSelection()).getFirstElement();
+ }
+ });
+
+ refreshInputModelView();
+
+ }
+
+ private void refreshInputModelView() {
+ if (this.getManagedForm() != null) {
+ this.getManagedForm().getMessageManager().removeAllMessages();
+ }
+ if (inputModelViewer != null) {
+ List<Object> input = generateInputData();
+ try {
+ inputModelViewer.setInput(input);
+ SmooksUIUtils.expandSelectorViewer(input, inputModelViewer);
+ } catch (Throwable e) {
+
+ }
+
+ if (input == null || input.isEmpty()) {
+ Throwable t = SelectorCreationDialog.getCurrentException();
+ if (t != null) {
+ if (this.getManagedForm() != null) {
+ if (t instanceof SmooksException && t.getCause() != null) {
+ t = t.getCause();
+ }
+ this.getManagedForm().getMessageManager()
+ .addMessage(
+ Messages.SmooksReaderFormPage_Input_Error,
+ Messages.SmooksReaderFormPage_Error_Creating_Input_Model + t.getMessage()
+ + "\"", null, IMessageProvider.ERROR); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ }
+
+ protected List<Object> generateInputData() {
+ Model<SmooksModel> obj = ((SmooksMultiFormEditor) getEditor()).getSmooksModel();
+ SmooksModel resourceList = obj.getModelRoot();
+ IJavaProject javaProject =
JavaCore.create(((IFileEditorInput)getEditorInput()).getFile().getProject());
+ return SelectorCreationDialog.generateInputData(resourceList,javaProject);
+ }
+
+ private void createReaderConfigSection(FormToolkit toolkit, Composite parent) {
+ Section section = toolkit.createSection(parent, Section.TITLE_BAR | Section.TWISTIE |
Section.EXPANDED);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ section.setLayoutData(gd);
+ section.setText(Messages.SmooksReaderFormPage_InputConfigurationSectionTitle);
+ section.setDescription(Messages.SmooksReaderFormPage_InputConfigurationSectionDes);
+ FillLayout flayout = new FillLayout();
+ section.setLayout(flayout);
+
+ scrolledPageBook = new ScrolledPageBook(section);
+ scrolledPageBook.setBackground(toolkit.getColors().getBackground());
+ section.setClient(scrolledPageBook);
+
+ readerConfigComposite = scrolledPageBook.createPage(scrolledPageBook);
+ scrolledPageBook.showPage(scrolledPageBook);
+
+ GridLayout gl = new GridLayout();
+ gl.numColumns = 2;
+ readerConfigComposite.setLayout(gl);
+
+ initReaderConfigSection();
+ }
+
+ private void initReaderConfigSection() {
+ Object reader = getCurrentReaderModel();
+ ISmooksModelProvider provider = getSmooksModelProvider();
+ if (provider == null)
+ return;
+ String type = provider.getInputType();
+ if (reader instanceof EObject && type != null) {
+// SmooksResourceListType list = getSmooksConfigResourceList();
+// createReaderPanel((EObject) list.getAbstractReader().get(0));
+ } else {
+ disposeCompositeControls(readerConfigComposite, null);
+ createSimpleReaderPanel(reader);
+ }
+ }
+
+ private void createSimpleReaderPanel(Object reader){
+ Label formText = this.getManagedForm().getToolkit().createLabel(readerConfigComposite,
""); //$NON-NLS-1$
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.heightHint = 50;
+ gd.horizontalSpan = 2;
+ formText.setLayoutData(gd);
+ if (reader instanceof XMLReader || reader instanceof JavaReader || reader instanceof
XSDReader) {
+ formText.setText(Messages.SmooksReaderFormPage_Warning_Specify_Sample_Data);
+ }
+
+ if (reader instanceof NullReader) {
+ formText.setText(Messages.SmooksReaderFormPage_Warning_Specify_Input_Type);
+ }
+ readerConfigComposite.layout();
+ scrolledPageBook.reflow(false);
+ }
+
+ protected void disposeCompositeControls(Composite composite, Control[] ignoreControl) {
+ if (composite != null) {
+ Control[] children = composite.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ Control child = children[i];
+ if (ignoreControl != null) {
+ for (int j = 0; j < ignoreControl.length; j++) {
+ if (child == ignoreControl[j]) {
+ continue;
+ }
+ }
+ }
+ child.dispose();
+ child = null;
+ }
+ }
+ }
+
+ private Object getCurrentReaderModel() {
+ if (readerCombo == null || readerCombo.isDisposed())
+ return null;
+ int index = readerCombo.getSelectionIndex();
+ if (index < 0)
+ return null;
+ return readerTypeList.get(index);
+ }
+
+ protected void createInputDataSection(FormToolkit toolkit, Composite parent) {
+ Section section = toolkit.createSection(parent, Section.TITLE_BAR | Section.DESCRIPTION
| Section.TWISTIE
+ | Section.EXPANDED);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ section.setLayoutData(gd);
+ section.setText(Messages.SmooksReaderFormPage_InputDataSectionTitle);
+ section.setDescription(Messages.SmooksReaderFormPage_InputDataSectionDes);
+ FillLayout flayout = new FillLayout();
+ section.setLayout(flayout);
+
+ Composite mainComposite = toolkit.createComposite(section, SWT.NONE);
+ GridLayout gl = new GridLayout();
+ gl.numColumns = 2;
+ mainComposite.setLayout(gl);
+ section.setClient(mainComposite);
+
+ Composite tableComposite = toolkit.createComposite(mainComposite, SWT.NONE);
+ FillLayout fillLayout = new FillLayout();
+ fillLayout.marginHeight = 1;
+ fillLayout.marginWidth = 1;
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.heightHint = 70;
+ tableComposite.setLayoutData(gd);
+ tableComposite.setBackground(GraphicsConstants.BORDER_CORLOR);
+ tableComposite.setLayout(fillLayout);
+
+ inputDataViewer = CheckboxTableViewer.newCheckList(tableComposite, SWT.MULTI |
SWT.FULL_SELECTION);
+ // inputDataViewer.set
+ inputDataViewer.setCheckStateProvider(new ICheckStateProvider() {
+
+ public boolean isGrayed(Object element) {
+ return isIncorrectInputType((InputType) element);
+ }
+
+ public boolean isChecked(Object element) {
+ if (element instanceof InputType) {
+ return ((InputType) element).isActived();
+ }
+ return false;
+ }
+ });
+ inputDataViewer.addCheckStateListener(new ICheckStateListener() {
+
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ if (lockCheck)
+ return;
+ boolean checked = event.getChecked();
+ InputType inputType = (InputType) event.getElement();
+ if (isIncorrectInputType(inputType)) {
+ lockCheck = true;
+ inputDataViewer.setChecked(inputType, false);
+ lockCheck = false;
+ return;
+ }
+ CompoundCommand compoundCommand = new CompoundCommand();
+ if (checked) {
+ IParam param = SmooksUIUtils.getInputTypeAssociatedParamType(inputType,
+ getSmooksConfigResourceList());
+ if (param != null) {
+ inputType.setActived(checked);
+ String value = SmooksModelUtils.INPUT_ACTIVE_TYPE;
+ Command c = SetCommand.create(getEditingDomain(), param,
+ ICorePackage.Literals.PARAM__TYPE, value);
+ if (c.canExecute())
+ compoundCommand.append(c);
+ }
+
+ Object[] checkedObjects = inputDataViewer.getCheckedElements();
+ for (int i = 0; i < checkedObjects.length; i++) {
+ InputType type = (InputType) checkedObjects[i];
+ if (type == inputType) {
+ continue;
+ }
+ type.setActived(!checked);
+ IParam param1 = SmooksUIUtils.getInputTypeAssociatedParamType(type,
+ getSmooksConfigResourceList());
+ if (param1 != null) {
+ String value1 = SmooksModelUtils.INPUT_DEACTIVE_TYPE;
+ Command c1 = SetCommand.create(getEditingDomain(), param1,
+ ICorePackage.Literals.PARAM__TYPE, value1);
+ compoundCommand.append(c1);
+ }
+
+ lockCheck = true;
+ inputDataViewer.setChecked(type, false);
+ lockCheck = false;
+ }
+
+ } else {
+ IParam param = SmooksUIUtils.getInputTypeAssociatedParamType(inputType,
+ getSmooksConfigResourceList());
+ if (param != null) {
+ String value = SmooksModelUtils.INPUT_DEACTIVE_TYPE;
+ Command c = SetCommand.create(getEditingDomain(), param,
+ ICorePackage.Literals.PARAM__TYPE, value);
+ compoundCommand.append(c);
+ }
+ }
+ try {
+ getEditingDomain().getCommandStack().execute(compoundCommand);
+ } catch (Exception e) {
+ // e.printStackTrace();
+ }
+
+ // refreshInputModelView();
+ }
+ });
+ inputDataViewer.addDoubleClickListener(new IDoubleClickListener() {
+
+ public void doubleClick(DoubleClickEvent event) {
+ IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+ Object element = selection.getFirstElement();
+ if (element instanceof InputType) {
+ String type = ((InputType) element).getType();
+ String filePath = ((InputType) element).getPath();
+ if (type != null && filePath != null) {
+ if (SmooksModelUtils.INPUT_TYPE_JAVA.equals(type)) {
+ IFile file = ((IFileEditorInput) getEditorInput()).getFile();
+ IJavaProject javaProject = JavaCore.create(file.getProject());
+ if (javaProject != null) {
+ try {
+ if (filePath.endsWith("[]")) { //$NON-NLS-1$
+ filePath = filePath.substring(0, filePath.length() - 2);
+ }
+ IJavaElement result = javaProject.findType(filePath);
+ if (result != null)
+ JavaUI.openInEditor(result);
+ else {
+ MessageDialog.openError(getSite().getWorkbenchWindow().getShell(),
+ Messages.SmooksReaderFormPage_CantFindTypeErrorTitle,
+ "Can't find type \"" + filePath + "\" in
\"" //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+ + javaProject.getProject().getName() + "\" project.");
//$NON-NLS-1$
+ }
+ } catch (Exception e) {
+
+ }
+ }
+ } else {
+ try {
+ filePath = SmooksUIUtils.parseFilePath(filePath);
+ if (filePath != null) {
+ IFileStore fileStore = EFS.getLocalFileSystem().getStore(new Path(filePath));
+ IFileInfo fetchInfo = fileStore.fetchInfo();
+ if (!fetchInfo.isDirectory() && fetchInfo.exists()) {
+ IWorkbenchWindow window = getSite().getWorkbenchWindow();
+ IWorkbenchPage page = window.getActivePage();
+ try {
+ IDE.openEditorOnFileStore(page, fileStore);
+ } catch (PartInitException e) {
+ MessageDialog.open(MessageDialog.ERROR, window.getShell(),
+ Messages.SmooksReaderFormPage_OpenFileErrorTitle,
+ "Can't open the file : '" + filePath + "'",
SWT.SHEET); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ } else {
+ }
+ }
+ } catch (Exception e) {
+ MessageDialog.open(MessageDialog.ERROR,
getSite().getWorkbenchWindow().getShell(),
+ Messages.SmooksReaderFormPage_OpenFileErrorTitle,
+ "Can't open the file : '" + filePath + "'",
SWT.SHEET); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
+ }
+ }
+ }
+ }
+ }
+ });
+ TableColumn header = new TableColumn(inputDataViewer.getTable(), SWT.NONE);
+ header.setText(Messages.SmooksReaderFormPage_TypeColumnText);
+ header.setWidth(100);
+ TableColumn pathColumn = new TableColumn(inputDataViewer.getTable(), SWT.NONE);
+ pathColumn.setText(Messages.SmooksReaderFormPage_PathColumnText);
+ 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 InputDataViewerLabelProvider());
+ inputDataViewer.getTable().setHeaderVisible(true);
+ inputDataViewer.getTable().setLinesVisible(true);
+ ISmooksModelProvider provider = getSmooksModelProvider();
+ if (provider != null) {
+ inputDataViewer.setInput(SmooksUIUtils.getInputTypeList(getSmooksConfigResourceList().getModelRoot()));
+ }
+ Composite buttonComposite = toolkit.createComposite(mainComposite, SWT.NONE);
+ gd = new GridData(GridData.FILL_VERTICAL);
+ buttonComposite.setLayoutData(gd);
+ GridLayout l = new GridLayout();
+ buttonComposite.setLayout(l);
+
+ addInputDataButton = toolkit.createButton(buttonComposite,
Messages.SmooksReaderFormPage_AddButtonLabel,
+ SWT.FLAT);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ addInputDataButton.setLayoutData(gd);
+ addInputDataButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent e) {
+ showInputDataWizard();
+ }
+
+ });
+
+ removeInputDataButton = toolkit.createButton(buttonComposite,
Messages.SmooksReaderFormPage_DeleteButtonLabel,
+ SWT.FLAT);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ removeInputDataButton.setLayoutData(gd);
+ removeInputDataButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent e) {
+ IStructuredSelection selection = (IStructuredSelection)
inputDataViewer.getSelection();
+ if (selection != null) {
+ List<?> inputs = selection.toList();
+ ISmooksModelProvider smooksModelProvider = getSmooksModelProvider();
+ for (Iterator<?> iterator = inputs.iterator(); iterator.hasNext();) {
+ InputType input = (InputType) iterator.next();
+ SmooksUIUtils.removeInputType(input, smooksModelProvider);
+ }
+ if (!inputs.isEmpty()) {
+ List<?> viewerInput = (List<?>) inputDataViewer.getInput();
+ viewerInput.removeAll(inputs);
+ // inputTypeChanged();
+ if (inputDataViewer != null) {
+ inputDataViewer.refresh();
+ }
+ }
+ }
+ }
+ });
+ }
+
+
+ protected boolean handleInputParamChange(Command command) {
+ Collection<?> affectedObjects = command.getAffectedObjects();
+ boolean refreshInputModel = false;
+ for (Iterator<?> iterator2 = affectedObjects.iterator(); iterator2.hasNext();) {
+ Object object = (Object) iterator2.next();
+// if (object instanceof AbstractReader) {
+// refreshInputModel = true;
+// break;
+// }
+ if (object instanceof IParam) {
+ if (SmooksUIUtils.isInputParamType((IParam) object)) {
+ refreshInputModel = true;
+ break;
+ }
+ }
+ Collection<?> deletedObjs = null;
+ if (command instanceof DeleteCommand) {
+ deletedObjs = ((DeleteCommand) command).getCollection();
+ }
+ if (command instanceof RemoveCommand) {
+ deletedObjs = ((RemoveCommand) command).getCollection();
+ }
+ if (deletedObjs != null) {
+ for (Iterator<?> iterator = deletedObjs.iterator(); iterator.hasNext();) {
+ Object object2 = (Object) iterator.next();
+// if (object2 instanceof AbstractReader) {
+// refreshInputModel = true;
+// break;
+// }
+ if (object2 instanceof IParam) {
+ if (SmooksUIUtils.isInputParamType((IParam) object2)) {
+ refreshInputModel = true;
+ break;
+ }
+ }
+ }
+ }
+ if (refreshInputModel)
+ break;
+ }
+
+ if (refreshInputModel) {
+ refreshInputModelView();
+ }
+
+ return refreshInputModel;
+ }
+
+ protected EditingDomain getEditingDomain() {
+ return getSmooksModelProvider().getEditingDomain();
+ }
+
+ protected Model<SmooksModel> getSmooksConfigResourceList() {
+ return getSmooksModelProvider().getSmooksModel();
+ }
+
+ protected boolean isIncorrectInputType(InputType element) {
+ if (element == null)
+ return false;
+ if (element instanceof InputType) {
+ String type = ((InputType) element).getType();
+ int index = readerCombo.getSelectionIndex();
+ if (index == -1)
+ return true;
+
+ Object reader = readerTypeList.get(index);
+ if (reader instanceof NullReader) {
+ return true;
+ }
+ if (reader instanceof XMLReader || reader instanceof XSDReader || reader instanceof
JavaReader) {
+
+ }
+
+ if (reader instanceof XMLReader) {
+ if (!SmooksModelUtils.INPUT_TYPE_XML.equals(type)) {
+ return true;
+ }
+ }
+ if (reader instanceof XSDReader) {
+ if (!SmooksModelUtils.INPUT_TYPE_XSD.equals(type)) {
+ return true;
+ }
+ }
+ if (reader instanceof JavaReader) {
+ if (!SmooksModelUtils.INPUT_TYPE_JAVA.equals(type)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+
+ private void createReaderSection(FormToolkit toolkit, Composite parent) {
+ Section section = toolkit.createSection(parent, Section.TITLE_BAR | Section.TWISTIE |
Section.EXPANDED);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.verticalAlignment = GridData.BEGINNING;
+ section.setLayoutData(gd);
+ section.setText(Messages.SmooksReaderFormPage_InputTypeSectionTitle);
+ // section.setDescription("Select the input type");
+ FillLayout flayout = new FillLayout();
+ section.setLayout(flayout);
+
+ Composite mainComposite = toolkit.createComposite(section);
+ section.setClient(mainComposite);
+ GridLayout gl = new GridLayout();
+ gl.numColumns = 2;
+ mainComposite.setLayout(gl);
+
+ toolkit.createLabel(mainComposite, Messages.SmooksReaderFormPage_InputTypeLabel);
+
+ readerCombo = new Combo(mainComposite, SWT.NONE | SWT.READ_ONLY);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ readerCombo.setLayoutData(gd);
+
+ toolkit.createLabel(mainComposite, " "); //$NON-NLS-1$
+
+ bindingReaderCombo();
+
+ initReaderCombo();
+
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ readerCombo.setLayoutData(gd);
+
+ toolkit.paintBordersFor(mainComposite);
+ }
+
+ private void bindingReaderCombo() {
+ if (readerCombo == null)
+ return;
+
+ readerCombo.removeAll();
+ readerTypeList.clear();
+
+ readerCombo.add(Messages.SmooksReaderFormPage_NoInputComboText);
+ readerTypeList.add(new NullReader());
+ readerCombo.add(Messages.SmooksReaderFormPage_XMLReaderComboText);
+ readerTypeList.add(new XMLReader());
+ readerCombo.add(Messages.SmooksReaderFormPage_JavaReaderComboText);
+ readerTypeList.add(new JavaReader());
+ readerCombo.add(Messages.SmooksReaderFormPage_XSDReaderComboText);
+ readerTypeList.add(new XSDReader());
+ }
+
+ private void initReaderCombo() {
+ if (readerCombo == null)
+ return;
+ Model<SmooksModel> model = getSmooksModelProvider().getSmooksModel();
+ if (model == null) {
+ readerCombo.select(-1);
+ return;
+ }
+
+ ISmooksModelProvider modelProvider = getSmooksModelProvider();
+
+ String inputType = modelProvider.getInputType();
+
+ if (inputType == null) {
+ readerCombo.select(0);
+ return;
+// // for the first time to open the file.
+// List<IComponent> compoenents = model.getModelRoot().getComponents();
+// for (Iterator<?> iterator = compoenents.iterator(); iterator.hasNext();) {
+// IComponent component = (IComponent) iterator.next();
+// }
+// if (rlist.getAbstractReader().isEmpty()) {
+// readerCombo.select(0);
+// return;
+// } else {
+// }
+ }
+ if (SmooksModelUtils.INPUT_TYPE_XML.equals(inputType)) {
+ readerCombo.select(1);
+ }
+ if (SmooksModelUtils.INPUT_TYPE_JAVA.equals(inputType)) {
+ readerCombo.select(2);
+ }
+ if (SmooksModelUtils.INPUT_TYPE_XSD.equals(inputType)) {
+ readerCombo.select(3);
+ }
+ return;
+ }
+
+ private void handleReaderCombo(final Combo combo) {
+ combo.addSelectionListener(new SelectionListener() {
+
+ public void widgetSelected(SelectionEvent e) {
+ Object newreader = getCurrentReaderModel();
+ if (newreader == null)
+ return;
+ // String type = getCurrentReaderType();
+ // if (type == null) {
+ //
getSmooksGraphicsExtType().eUnset(GraphPackage.Literals.SMOOKS_GRAPHICS_EXT_TYPE__INPUT_TYPE);
+ // } else {
+ // getSmooksGraphicsExtType().setInputType(type);
+ // }
+ readerChanged(newreader);
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+ });
+ }
+
+ private String getCurrentReaderType() {
+ Object reader = getCurrentReaderModel();
+ return getReaderType(reader);
+ }
+
+ private String getReaderType(Object reader) {
+ if (reader instanceof XMLReader) {
+ return SmooksModelUtils.INPUT_TYPE_XML;
+ }
+ if (reader instanceof JavaReader) {
+ return SmooksModelUtils.INPUT_TYPE_JAVA;
+ }
+ if (reader instanceof XSDReader) {
+ return SmooksModelUtils.INPUT_TYPE_XSD;
+ }
+ if (reader instanceof EObject) {
+ Object obj = ((EObject) reader);
+
+// if (obj instanceof CSV12Reader) {
+// return SmooksModelUtils.INPUT_TYPE_CSV;
+// }
+// if (obj instanceof EDI12Reader) {
+// return SmooksModelUtils.INPUT_TYPE_EDI_1_1;
+// }
+// if (obj instanceof Json12Reader) {
+// return SmooksModelUtils.INPUT_TYPE_JSON_1_1;
+// }
+// if (obj instanceof ReaderType) {
+// return SmooksModelUtils.INPUT_TYPE_CUSTOME;
+// }
+ }
+ return null;
+ }
+
+ private void readerChanged(Object reader) {
+
+ String type = getCurrentReaderType();
+ String oldType = this.getSmooksModelProvider().getInputType();
+
+ if (type == null && oldType == null) {
+ return;
+ }
+ if (type != null && type.equals(oldType)) {
+ return;
+ }
+ if (oldType != null && oldType.equals(type)) {
+ return;
+ }
+
+ CompoundCommand compoundCommand = new CompoundCommand();
+
+ IGlobalParams params = getSmooksConfigResourceList().getModelRoot().getParams();
+ if (params == null) {
+ params = ICoreFactory.eINSTANCE.createGlobalParams();
+ Command addparamsCommand = SetCommand.create(getEditingDomain(),
getSmooksConfigResourceList().getModelRoot(),
+ ICorePackage.Literals.PARAMS, params);
+ if (addparamsCommand.canExecute())
+ compoundCommand.append(addparamsCommand);
+ }
+
+ IParam param = SmooksUIUtils
+ .getInputTypeParam(getSmooksConfigResourceList().getModelRoot());
+ if (param == null) {
+ // add new one
+ param = ICoreFactory.eINSTANCE.createParam();
+ param.setName(SmooksModelUtils.INPUT_TYPE);
+ param.setValue(type);
+ Command addparamc = AddCommand.create(getEditingDomain(), params,
+ ICorePackage.Literals.PARAMS__PARAMS, param);
+ if (addparamc.canExecute())
+ compoundCommand.append(addparamc);
+ } else {
+
+ Command setCommand = null;
+ if (type != null) {
+ setCommand = SetCommand.create(getEditingDomain(),
param,ICorePackage.Literals.PARAM__VALUE, type);
+ }
+
+ if (setCommand != null && setCommand.canExecute()) {
+ compoundCommand.append(setCommand);
+ }else{
+ throw new RuntimeException("Can't set the value to Param element");
+ }
+
+ }
+ Command removeCommand = createRemoveReaderCommand();
+ if (removeCommand != null && removeCommand.canExecute()) {
+ compoundCommand.append(removeCommand);
+ }
+ if (readerConfigComposite != null) {
+ disposeCompositeControls(readerConfigComposite, null);
+ scrolledPageBook.reflow(true);
+ }
+ if (reader instanceof EObject) {
+// Object obj = ((EObject) reader);
+// obj = AdapterFactoryEditingDomain.unwrap(obj);
+// Command command = AddCommand.create(getEditingDomain(),
getSmooksConfigResourceList(),
+// SmooksPackage.Literals.SMOOKS_RESOURCE_LIST_TYPE__ABSTRACT_READER_GROUP,
createReaderEntry(obj,
+// false));
+// if (command.canExecute()) {
+// compoundCommand.append(command);
+// }
+
+ } else {
+ createSimpleReaderPanel(reader);
+ }
+ deactiveAllInputFile(compoundCommand);
+ if (!compoundCommand.isEmpty() && compoundCommand.canExecute()) {
+ getEditingDomain().getCommandStack().execute(compoundCommand);
+ if (reader != null && reader instanceof EObject) {
+// createReaderPanel(((EObject) reader));
+ }
+ }
+
+ if (inputDataViewer != null) {
+ inputDataViewer.refresh();
+ }
+ refreshInputModelView();
+ refreshInputDataButtons();
+ }
+
+ private Command createRemoveReaderCommand() {
+ Model<SmooksModel> rlist = getSmooksConfigResourceList();
+// List<AbstractReader> readerList = rlist.getAbstractReader();
+ CompoundCommand compoundCommand = new CompoundCommand();
+// for (Iterator<?> iterator = readerList.iterator(); iterator.hasNext();) {
+// AbstractReader abstractReader = (AbstractReader) iterator.next();
+// Object readerEntry = createReaderEntry(abstractReader, false);
+// if (readerEntry == null)
+// continue;
+// Command removeCommand = RemoveCommand.create(getEditingDomain(), rlist,
+// SmooksPackage.Literals.SMOOKS_RESOURCE_LIST_TYPE__ABSTRACT_READER_GROUP,
readerEntry);
+// if (removeCommand.canExecute()) {
+// compoundCommand.append(removeCommand);
+// }
+// }
+// if (compoundCommand.isEmpty()) {
+// return null;
+// }
+ return compoundCommand;
+ }
+
+ protected void showInputDataWizard() {
+ CompoundCommand compoundCommand = new CompoundCommand();
+ // SmooksGraphicsExtType extType = getSmooksGraphicsExtType();
+ String inputType = getSmooksModelProvider().getInputType();
+ List<InputType> inputTypes = null;
+ Model<SmooksModel> smooksModel = getSmooksConfigResourceList();
+ SmooksModel rootModel = smooksModel.getModelRoot();
+ if (inputType == null || SmooksModelUtils.INPUT_TYPE_CUSTOME.equals(inputType) ||
inputType.trim().equals("")) { //$NON-NLS-1$
+ StructuredDataSelectionWizard wizard = new StructuredDataSelectionWizard();
+ wizard.setInput(getEditorInput());
+ wizard.setSite(getEditorSite());
+ wizard.setForcePreviousAndNextButtons(true);
+ StructuredDataSelectionWizardDailog dialog = new
StructuredDataSelectionWizardDailog(getEditorSite()
+ .getShell(), wizard);
+
+ if (dialog.show() == Dialog.OK) {
+ String type = dialog.getType();
+ String path = dialog.getPath();
+ Properties pros = dialog.getProperties();
+ inputTypes =
SmooksUIUtils.recordInputDataInfomation(getEditingDomain(),rootModel.getParams() , type,
path, pros, compoundCommand);
+ }
+ } else {
+ IStructuredDataSelectionWizard wizard =
ViewerInitorStore.getInstance().getStructuredDataCreationWizard(
+ inputType);
+ WizardDialog dialog = new WizardDialog(getEditorSite().getShell(), wizard);
+ wizard.init(getEditorSite(), getEditorInput());
+ if (dialog.open() == Dialog.OK) {
+ String path = wizard.getStructuredDataSourcePath();
+ Properties pros = wizard.getProperties();
+ inputTypes = SmooksUIUtils.recordInputDataInfomation(getEditingDomain(),
rootModel.getParams(), inputType, path, pros, compoundCommand);
+ }
+ }
+
+ if (inputTypes != null && !inputTypes.isEmpty()) {
+ InputType addedInputType = inputTypes.get(0);
+ Object obj = this.inputDataViewer.getInput();
+ if (obj != null && obj instanceof List) {
+ ((List) obj).add(addedInputType);
+ }
+
+ deactiveAllInputFile(compoundCommand);
+ if (inputType.equals(SmooksModelUtils.INPUT_TYPE_CUSTOME)) {
+ // don't active the input file
+ } else {
+ addedInputType.setActived(true);
+ IParam param = addedInputType.getRelatedParameter();
+ if (param != null) {
+ String value = SmooksModelUtils.INPUT_ACTIVE_TYPE;
+ Command c = SetCommand.create(this.getEditingDomain(), param,
+ ICorePackage.Literals.PARAM__TYPE, value);
+ if (c.canExecute()) {
+ compoundCommand.append(c);
+ }
+ }
+ }
+ if (!compoundCommand.isEmpty()) {
+ getSmooksModelProvider().getEditingDomain().getCommandStack().execute(compoundCommand);
+ }
+ if (inputDataViewer != null)
+ inputDataViewer.refresh();
+ }
+ }
+
+ private void deactiveAllInputFile(CompoundCommand command) {
+ Object viewerInput = this.inputDataViewer.getInput();
+ if (viewerInput != null && viewerInput instanceof List<?>) {
+ List<InputType> inputList = (List) viewerInput;
+ for (Iterator<?> iterator = inputList.iterator(); iterator.hasNext();) {
+ InputType inputType = (InputType) iterator.next();
+ setInputDataActiveStatus(false, inputType, command);
+ }
+ }
+ }
+
+ private void setInputDataActiveStatus(boolean active, InputType inputType, final
CompoundCommand command) {
+ inputType.setActived(active);
+ IParam param = SmooksUIUtils.getInputTypeAssociatedParamType(inputType,
getSmooksConfigResourceList());
+ if (param != null) {
+ String value = SmooksModelUtils.INPUT_ACTIVE_TYPE;
+ if (!active) {
+ value = SmooksModelUtils.INPUT_DEACTIVE_TYPE;
+ }
+ Command c = SetCommand.create(this.getEditingDomain(), param,
ICorePackage.Literals.PARAM__TYPE,
+ value);
+ if (command != null) {
+ command.append(c);
+ } else {
+ getEditingDomain().getCommandStack().execute(c);
+ }
+ }
+ }
+
+
+ public void sourceChange(Object model) {
+
+ }
+
+ private class NullReader {
+
+ }
+
+ private class XMLReader {
+
+ }
+
+ private class XSDReader {
+
+ }
+
+ private class JavaReader {
+
+ }
+
+ private class InputDataViewerLabelProvider extends ExtentionInputLabelProvider
implements ITableColorProvider {
+
+ public Color getBackground(Object element, int columnIndex) {
+ if (isIncorrectInputType((InputType) element)) {
+ // return ColorConstants.darkGray;
+ }
+ return null;
+ }
+
+ public Color getForeground(Object element, int columnIndex) {
+ if (isIncorrectInputType((InputType) element)) {
+ return ColorConstants.lightGray;
+ }
+ return null;
+ }
+ }
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksReaderFormPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/StructuredDataSelectionWizardDailog.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/StructuredDataSelectionWizardDailog.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/StructuredDataSelectionWizardDailog.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * 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;
+
+import java.util.Properties;
+
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+import
org.jboss.tools.smooks.configuration.editors.wizard.IStructuredDataSelectionWizard;
+
+/**
+ * @author Dart Peng
+ * @Date Aug 6, 2008
+ */
+public class StructuredDataSelectionWizardDailog extends WizardDialog {
+
+ private String type = null;
+
+ private String path = null;
+
+ private Properties properties = null;
+
+ public StructuredDataSelectionWizardDailog(Shell parentShell, IWizard newWizard) {
+ super(parentShell, newWizard);
+ }
+
+ public IStructuredDataSelectionWizard getCurrentCreationWizard() {
+ IWizard w = getWizard();
+ if (w != null && w instanceof IStructuredDataSelectionWizard) {
+ return (IStructuredDataSelectionWizard) w;
+ }
+ return null;
+ }
+
+ // public SmooksMultiFormEditor getFormEditor() {
+ // return formEditor;
+ // }
+ //
+ // public void setFormEditor(SmooksMultiFormEditor formEditor) {
+ // this.formEditor = formEditor;
+ // }
+
+ public int show() {
+ int openResult = this.open();
+ if (openResult == WizardDialog.OK) {
+ IStructuredDataSelectionWizard wizard1 = this.getCurrentCreationWizard();
+ type = wizard1.getInputDataTypeID();
+ path = wizard1.getStructuredDataSourcePath();
+ properties = wizard1.getProperties();
+ }
+ return openResult;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ public Properties getProperties() {
+ return properties;
+ }
+
+ public void setProperties(Properties properties) {
+ this.properties = properties;
+ }
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/StructuredDataSelectionWizardDailog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/input/InputParameter.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/input/InputParameter.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/input/InputParameter.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * 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.input;
+
+/**
+ * @author Dart
+ *
+ */
+public class InputParameter {
+ private String name;
+
+ private String value;
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * @return the value
+ */
+ public String getValue() {
+ return value;
+ }
+
+ /**
+ * @param value the value to set
+ */
+ public void setValue(String value) {
+ this.value = value;
+ }
+
+
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/input/InputParameter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/input/InputType.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/input/InputType.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/input/InputType.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,90 @@
+package org.jboss.tools.smooks.configuration.editors.input;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jboss.tools.smooks.model.core.IParam;
+
+public class InputType {
+ private String path;
+ private String type;
+ private boolean actived = false;
+
+ private IParam relatedParameter = null;
+
+ private List<InputParameter> parameters = null;
+
+ /**
+ * @return the parameters
+ */
+ public List<InputParameter> getParameters() {
+ if (parameters == null) {
+ parameters = new ArrayList<InputParameter>();
+ }
+ return parameters;
+ }
+
+
+ /**
+ * @return the relatedParameter
+ */
+ public IParam getRelatedParameter() {
+ return relatedParameter;
+ }
+
+
+ /**
+ * @param relatedParameter the relatedParameter to set
+ */
+ public void setRelatedParameter(IParam relatedParameter) {
+ this.relatedParameter = relatedParameter;
+ }
+
+
+
+ /**
+ * @return the path
+ */
+ public String getPath() {
+ return path;
+ }
+
+ /**
+ * @param path
+ * the path to set
+ */
+ public void setPath(String path) {
+ this.path = path;
+ }
+
+ /**
+ * @return the type
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * @param type
+ * the type to set
+ */
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ /**
+ * @return the actived
+ */
+ public boolean isActived() {
+ return actived;
+ }
+
+ /**
+ * @param actived
+ * the actived to set
+ */
+ public void setActived(boolean actived) {
+ this.actived = actived;
+ }
+
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/input/InputType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavaBeanList.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavaBeanList.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavaBeanList.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,117 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.configuration.editors.java;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.jboss.tools.smooks.configuration.editors.IXMLStructuredObject;
+
+
+/**
+ * @author Dart
+ *
+ */
+public class JavaBeanList extends JavaBeanModel implements IXMLStructuredObject{
+
+
+ private List<IXMLStructuredObject> children = null;
+
+ public List<IXMLStructuredObject> getChildren() {
+ if(children == null){
+ children = new ArrayList<IXMLStructuredObject>();
+ }
+ return children;
+ }
+
+ public JavaBeanList(){
+ super(null);
+ }
+
+ @Override
+ public boolean isPrimitive() {
+ return false;
+ }
+
+ public String getJavaBeanName(JavaBeanModel javaBean){
+ List<?> children = getChildren();
+ int sameNameBean = 0;
+ for (Iterator<?> iterator = children.iterator(); iterator.hasNext();) {
+ JavaBeanModel child = (JavaBeanModel) iterator.next();
+ if(child.getBeanClass().getName().equals(javaBean.getBeanClass().getName())){
+ sameNameBean++;
+ }
+ }
+ if(sameNameBean > 0){
+ String name = javaBean.getName() + String.valueOf(sameNameBean);
+ while(hasSameNameBean(name,javaBean.getBeanClass())){
+ sameNameBean++;
+ name = javaBean.getName() + String.valueOf(sameNameBean);
+ }
+ return name;
+ }
+ return javaBean.getName();
+ }
+
+ private boolean hasSameNameBean(String name , Class<?> clazz){
+ for (Iterator<?> iterator = children.iterator(); iterator.hasNext();) {
+ JavaBeanModel child = (JavaBeanModel) iterator.next();
+ if(child.getBeanClass().getName().equals(clazz.getName())){
+ if(name.equals(child.getName())){
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+
+ public void addJavaBean(JavaBeanModel javaBean){
+ if(javaBean == null) return;
+ String name = javaBean.getName();
+ String n1 = getJavaBeanName(javaBean);
+ if(!name.equals(n1)){
+ javaBean.setName(n1);
+ }
+ javaBean.setParent(this);
+ this.getChildren().add(javaBean);
+ }
+
+ public void removeJavaBean(JavaBeanModel javaBean){
+ this.getChildren().remove(javaBean);
+ javaBean.setParent(null);
+ }
+
+ @Override
+ public List<?> getProperties() {
+ return Collections.EMPTY_LIST;
+ }
+
+ public Object getID() {
+ return this;
+ }
+
+ public String getNodeName() {
+ return null;
+ }
+
+ public JavaBeanModel getParent() {
+ return null;
+ }
+
+ public boolean isAttribute() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ public boolean isRootNode() {
+ return true;
+ }
+
+
+
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavaBeanList.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavaBeanModel.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavaBeanModel.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavaBeanModel.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,608 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.java;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.WildcardType;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import org.jboss.tools.smooks.configuration.editors.IXMLStructuredObject;
+import org.jboss.tools.smooks.configuration.editors.uitls.JavaPropertyUtils;
+
+/**
+ * @author Dart Peng
+ *
+ */
+public class JavaBeanModel implements IXMLStructuredObject, Cloneable {
+
+ private boolean flat = false;
+
+ private boolean expaned = false;
+
+ private Properties extendProperties = new Properties();
+
+ protected PropertyChangeSupport support = new PropertyChangeSupport(this);
+
+ private String beanClassString = null;
+
+ public void setBeanClassString(String beanClassString) {
+ this.beanClassString = beanClassString;
+ }
+
+ private Object waring = null;
+
+ private Object error = null;
+
+ private String name = ""; //$NON-NLS-1$
+
+ private Class typeRef = null;
+
+ private boolean many = false;
+
+ private boolean collection = false;
+
+ private boolean isPrimitive = false;
+
+ private boolean hasGenericType = false;
+
+ private Class<? extends Object> beanClass = null;
+
+ private JavaBeanModel parent = null;
+
+ public Class getBeanClass() {
+ return beanClass;
+ }
+
+ private Class parentClass = null;
+
+ // private boolean isRoot = false;
+
+ private boolean isRootClassModel = false;
+
+ /**
+ * @return the isRootClassModel
+ */
+ public boolean isRootClassModel() {
+ return isRootClassModel || getParent() == null;
+ }
+
+ public boolean isFlat() {
+ return flat;
+ }
+
+ public void setFlat(boolean flat) {
+ this.flat = flat;
+ }
+
+ /**
+ * @param isRootClassModel
+ * the isRootClassModel to set
+ */
+ public void setRootClassModel(boolean isRootClassModel) {
+ this.isRootClassModel = isRootClassModel;
+ }
+
+ public void addNodePropetyChangeListener(PropertyChangeListener listener) {
+ PropertyChangeListener[] array = support.getPropertyChangeListeners();
+ for (int i = 0; i < array.length; i++) {
+ if (listener == array[i])
+ return;
+ }
+ 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);
+ }
+ }
+
+ // /**
+ // * @return the isRoot
+ // */
+ // public boolean isRoot() {
+ // return isRoot;
+ // }
+
+ public String getBeanClassString() {
+ if (beanClassString != null && beanClassString.length() != 0) {
+ return this.beanClassString;
+ }
+ Class clazz = this.getBeanClass();
+ if (clazz == null)
+ return "<null>"; //$NON-NLS-1$
+
+ if (clazz.isArray()) {
+ String s = clazz.getComponentType().getName();
+ return s + "[]"; //$NON-NLS-1$
+ }
+// if(this.isList()){
+// String cs = "<"+System.currentTimeMillis()+">";
+// Class componentClazz = this.getComponentClass();
+// if(componentClazz != null){
+// cs = "<" + componentClazz.getName() +">";
+// }
+// return clazz.getName() + cs;
+// }
+
+ return clazz.getName();
+ }
+
+ public String getBeanClassStringWithList() {
+ String s = getBeanClassString();
+ if (this.isList()) {
+ Class genericType = getGenericType();
+ if (genericType != null)
+ s += "<" + genericType.getName() + ">"; //$NON-NLS-1$
//$NON-NLS-2$
+ }
+ return s;
+ }
+
+ /**
+ * @param isRoot
+ * the isRoot to set
+ */
+ // public void setRoot(boolean isRoot) {ois
+ private boolean isList = false;
+
+ private Class componentClass = null;
+
+ private boolean lazyLoadProperties = true;
+
+ public boolean isList() {
+ if (beanClass == null)
+ return false;
+ if (Collection.class.isAssignableFrom(beanClass)) {
+ if (this.propertyDescriptor != null) {
+ Method rmethod = propertyDescriptor.getReadMethod();
+ if (rmethod != null) {
+ Type returnType = rmethod.getGenericReturnType();
+ if (returnType instanceof ParameterizedType) {
+ Type gtype = ((ParameterizedType) returnType).getActualTypeArguments()[0];
+ if(gtype instanceof Class){
+ Class beanType = (Class) gtype;
+ componentClass = beanType;
+ setGenericType(true);
+ }
+ if(gtype instanceof WildcardType){
+ Type[] upperBounds = ((WildcardType)gtype).getUpperBounds();
+ Type[] lowerBounds = ((WildcardType)gtype).getLowerBounds();
+ if(upperBounds.length != 0){
+ componentClass = (Class<?>) upperBounds[0];
+ setGenericType(true);
+ }
+ if(lowerBounds.length != 0){
+ componentClass = (Class<?>) lowerBounds[0];
+ setGenericType(true);
+ }
+ }
+ }
+ }
+ }
+ setList(true);
+ }
+ return isList;
+ }
+
+ public void setList(boolean isList) {
+ this.isList = isList;
+ }
+
+ private PropertyDescriptor propertyDescriptor;
+
+ public PropertyDescriptor getPropertyDescriptor() {
+ return propertyDescriptor;
+ }
+
+ public void setPropertyDescriptor(PropertyDescriptor propertyDescriptor) {
+ this.propertyDescriptor = propertyDescriptor;
+ }
+
+ JavaBeanModel(Class beanClass, String beanName, PropertyDescriptor propertyDescriptor,
Class parentClass,
+ boolean lazyLoadProperties) {
+ this.lazyLoadProperties = lazyLoadProperties;
+ this.beanClass = toConcreteImpl(beanClass);
+ this.name = beanName;
+ if (beanClass == null)
+ return;
+ if (this.name == null) {
+ this.name = beanClass.getSimpleName();
+ }
+ if (propertyDescriptor == null)
+ setRootClassModel(true);
+ this.propertyDescriptor = propertyDescriptor;
+ Class beanType = beanClass;
+ if (beanClass.isArray()) {
+ beanType = beanClass.getComponentType();
+ setMany(true);
+ componentClass = beanType;
+ }
+
+ if (Collection.class.isAssignableFrom(beanClass)) {
+ if (this.propertyDescriptor != null) {
+ Method rmethod = propertyDescriptor.getReadMethod();
+ if (rmethod != null) {
+ Type returnType = rmethod.getGenericReturnType();
+ if (returnType instanceof ParameterizedType) {
+ Type gtype = ((ParameterizedType) returnType).getActualTypeArguments()[0];
+ if (gtype instanceof Class) {
+ beanType = (Class) gtype;
+ componentClass = beanType;
+ }
+ }
+ }
+ }
+ setList(true);
+ }
+
+ if (beanType.isPrimitive() || JavaBeanModelFactory.isPrimitiveObject(beanType)) {
+ this.parentClass = parentClass;
+ if (!isArray() && !isList())
+ setPrimitive(true);
+ return;
+ }
+ this.parentClass = parentClass;
+
+ if (!lazyLoadProperties)
+ this.getProperties();
+ }
+
+ JavaBeanModel(Class beanClass, String beanName, PropertyDescriptor propertyDescriptor)
{
+ this(beanClass, beanName, propertyDescriptor, null, true);
+ }
+
+ public JavaBeanModel(Class beanClass) {
+ this(beanClass, null, null, null, true);
+ }
+
+ public JavaBeanModel(Class beanClass, String name) {
+ this(beanClass, name, null, null, true);
+ }
+
+ JavaBeanModel(Class<?> beanClass, boolean lazyLoadProperties) {
+ this(beanClass, null, null, null, lazyLoadProperties);
+ }
+
+ private Class<? extends Object> toConcreteImpl(Class declaredType) {
+
+ // Intentionally not doing an isAssignableFrom test... want to know is it the
+ // the exact class...
+ if(declaredType == List.class) {
+ return ArrayList.class;
+ } else if(declaredType == Set.class) {
+ return LinkedHashSet.class;
+ } else if(declaredType == Collection.class) {
+ return ArrayList.class;
+ } else if(declaredType == Map.class) {
+ return LinkedHashMap.class;
+ }
+
+ return declaredType;
+ }
+
+ public boolean isPrimitive() {
+ Class<?> beanType = getBeanClass();
+ if (beanType == null)
+ return false;
+ if (beanType.isPrimitive() || JavaBeanModelFactory.isPrimitiveObject(beanType)) {
+ if (!isArray() && !isList())
+ setPrimitive(true);
+ }
+ return isPrimitive;
+ }
+
+ public void setPrimitive(boolean isPrimitive) {
+ this.isPrimitive = isPrimitive;
+ }
+
+ public boolean isArray() {
+ if (beanClass == null)
+ return false;
+ if (beanClass.isArray()) {
+ Class beanType = beanClass.getComponentType();
+ setMany(true);
+ componentClass = beanType;
+ setGenericType(true);
+ }
+ return many;
+ }
+
+ public Class getGenericType() {
+ return componentClass;
+ }
+
+ public void setMany(boolean many) {
+ this.many = many;
+ }
+
+ // public boolean isCollection() {
+ // return collection;
+ // }
+ //
+ // public void setCollection(boolean collection) {
+ // this.collection = collection;
+ // }
+
+ // public Class getTypeRef() {
+ // return typeRef;
+ // }
+ //
+ // public void setTypeRef(Class typeRef) {
+ // this.typeRef = typeRef;
+ // }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void addProperty(JavaBeanModel property) {
+ if (properties != null) {
+ properties.add(property);
+ property.setParent(this);
+ }
+ }
+
+ protected void createArrayChildren(Class<Object> clazz, String name,
PropertyDescriptor pd,
+ Class<? extends Object> parentClass, boolean lazyLoad) {
+ JavaBeanModel proxyModel = newChildJavaBean(clazz, name, pd, parentClass, lazyLoad);
+ addProperty(proxyModel);
+ }
+
+ protected void createListChildren(Class<Object> clazz, String name,
PropertyDescriptor pd,
+ Class<? extends Object> parentClass, boolean lazyLoad) {
+ JavaBeanModel proxyModel = newChildJavaBean(clazz, name, pd, parentClass, lazyLoad);
+ addProperty(proxyModel);
+ }
+
+ private List properties;
+
+
+ /**
+ * @return the expaned
+ */
+ public boolean isExpaned() {
+ return expaned;
+ }
+
+ public List getProperties() {
+ expaned = true;
+ JavaBeanModel parent = this.getParent();
+ if (parent != null) {
+ if (parent.isFlat())
+ return Collections.emptyList();
+ }
+ if (properties == null) {
+ properties = new ArrayList();
+ if (isPrimitive())
+ return properties;
+
+ Class beanType = beanClass;
+ if (isArray() || isList()) {
+ if (componentClass != null) {
+ createArrayChildren(componentClass, componentClass.getSimpleName(), null,
beanClass,
+ this.lazyLoadProperties);
+ beanType = componentClass;
+ } else {
+ createListChildren(Object.class, "object", null, beanClass,
this.lazyLoadProperties); //$NON-NLS-1$
+ beanType = componentClass;
+ }
+ return properties;
+ }
+ if (beanType == null)
+ return Collections.EMPTY_LIST;
+ PropertyDescriptor[] pds = JavaPropertyUtils.getPropertyDescriptor(beanType);
+ for (int i = 0; i < pds.length; i++) {
+ PropertyDescriptor pd = pds[i];
+ if ("class".equals(pd.getName())) //$NON-NLS-1$
+ continue;
+ if (pd.getPropertyType() == null)
+ continue;
+ if (Collection.class.isAssignableFrom(pd.getPropertyType())) {
+ Method rmethod = pd.getReadMethod();
+ if (rmethod != null) {
+ Type returnType = rmethod.getGenericReturnType();
+ if (returnType instanceof ParameterizedType) {
+ Type[] types = ((ParameterizedType) returnType).getActualTypeArguments();
+ if (types == null || types.length == 0) {
+ continue;
+ }
+ } else {
+ continue;
+ }
+ }
+ }
+ JavaBeanModel jbm = newChildJavaBean(pd.getPropertyType(), pd.getName(), pd,
beanClass,
+ this.lazyLoadProperties);
+ addProperty(jbm);
+ }
+ }
+ return properties;
+ }
+
+ protected JavaBeanModel newChildJavaBean(Class clazz, String name, PropertyDescriptor
pd,
+ Class parentClass, boolean lazyLoading) {
+ return new JavaBeanModel(clazz, name, pd, parentClass, lazyLoading);
+ }
+
+ public void setProperties(List properties) {
+ this.properties = properties;
+ }
+
+ public boolean propertiesHasBeenLoaded() {
+ return properties != null;
+ }
+
+ /**
+ * @return the parent
+ */
+ public JavaBeanModel getParent() {
+ return parent;
+ }
+
+ /**
+ * @param parent
+ * the parent to set
+ */
+ public void setParent(JavaBeanModel parent) {
+ this.parent = parent;
+ }
+
+ public Object getWarning() {
+ return waring;
+ }
+
+ public void setWarning(Object waring) {
+ this.waring = waring;
+ }
+
+ public Object getError() {
+ return error;
+ }
+
+ public void setError(Object error) {
+ this.error = error;
+ }
+
+ public JavaBeanModel getRootParent() {
+ JavaBeanModel parent = this.getParent();
+ if (parent == null)
+ return this;
+ JavaBeanModel temp = parent;
+ while (temp != null) {
+ parent = temp;
+ temp = temp.getParent();
+ }
+ return parent;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ StringBuffer buffer = new StringBuffer("JavaName : " + name); //$NON-NLS-1$
+ if (beanClass != null)
+ buffer.append("BeanClass : " + this.beanClass.getName()); //$NON-NLS-1$
+ if (this.properties != null) {
+ buffer.append("\n"); //$NON-NLS-1$
+ for (Iterator<?> iterator = properties.iterator(); iterator.hasNext();) {
+ JavaBeanModel child = (JavaBeanModel) iterator.next();
+ buffer.append("\t"); //$NON-NLS-1$
+ buffer.append(child.toString());
+ buffer.append("\n"); //$NON-NLS-1$
+ }
+ }
+ return buffer.toString();
+ }
+
+ public String getSelectorString() {
+ if (parent == null) {
+ return getBeanClassString();
+ }
+ if (parent.getClass() == JavaBeanList.class) {
+ return getBeanClassString();
+ }
+
+ if (parent.isArray() || parent.isList()) {
+ return getBeanClassString();
+ }
+ return getName();
+
+ }
+
+ public boolean hasGenericType() {
+ return hasGenericType;
+ }
+
+ public void setGenericType(boolean hasGenericType) {
+ this.hasGenericType = hasGenericType;
+ }
+
+ public boolean isAttribute() {
+ return false;
+ }
+
+ public List<IXMLStructuredObject> getChildren() {
+ List ps = getProperties();
+ if (ps != null) {
+ return ps;
+ }
+ return null;
+ }
+
+ public Object getID() {
+ Class<?> clazz = getBeanClass();
+ if(Collection.class.isAssignableFrom(clazz)){
+ return getBeanClassString() + getName();
+ }
+ return getBeanClass();
+ }
+
+ public String getNodeName() {
+ return getSelectorString();
+ }
+
+ public boolean isRootNode() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void setComponentClass(Class clazz) {
+ componentClass = clazz;
+ }
+
+ public Class getComponentClass() {
+ return componentClass;
+ }
+
+ public void addExtendProperty(String name, String value) {
+ extendProperties.setProperty(name, value);
+ }
+
+ public String getExtendProperty(String name) {
+ return extendProperties.getProperty(name);
+ }
+
+ public Object clone() {
+ if (isList()) {
+ JavaBeanModel model =
JavaBeanModelFactory.getJavaBeanModelWithLazyLoad(ArrayList.class);
+ model.setComponentClass(componentClass);
+ return model;
+ }
+ return JavaBeanModelFactory.getJavaBeanModelWithLazyLoad(this.getBeanClass());
+ }
+
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavaBeanModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavaBeanModelFactory.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavaBeanModelFactory.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavaBeanModelFactory.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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.java;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Dart Peng
+ *
+ */
+public class JavaBeanModelFactory {
+
+ private static final List<Object> PRIMITIVE_CLASSES = new
ArrayList<Object>();
+ static {
+ PRIMITIVE_CLASSES.add(Integer.class);
+ PRIMITIVE_CLASSES.add(Double.class);
+ PRIMITIVE_CLASSES.add(Float.class);
+ PRIMITIVE_CLASSES.add(String.class);
+ PRIMITIVE_CLASSES.add(Long.class);
+ PRIMITIVE_CLASSES.add(java.util.Date.class);
+ PRIMITIVE_CLASSES.add(Character.class);
+ PRIMITIVE_CLASSES.add(BigInteger.class);
+ PRIMITIVE_CLASSES.add(BigDecimal.class);
+ PRIMITIVE_CLASSES.add(Boolean.class);
+ PRIMITIVE_CLASSES.add(Byte.class);
+ PRIMITIVE_CLASSES.add(java.util.Calendar.class);
+ }
+
+ /**
+ * @param beanClass
+ * @param modelName
+ * @return
+ */
+ public synchronized static JavaBeanModel getJavaBeanModelWithLazyLoad(Class<?>
beanClass) {
+ JavaBeanModel m = new JavaBeanModel(beanClass, true);
+ m.setRootClassModel(true);
+ return m;
+ }
+
+ /**
+ * @deprecated
+ * @param beanClass
+ * @return
+ */
+ public synchronized static JavaBeanModel getJavaBeanModel(Class<?> beanClass) {
+ JavaBeanModel m = new JavaBeanModel(beanClass, false);
+ m.setRootClassModel(true);
+ return m;
+ }
+
+ public static boolean isPrimitiveObject(Class<?> clazz) {
+ if(clazz.isEnum()) return true;
+ return (PRIMITIVE_CLASSES.indexOf(clazz) != -1);
+ }
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavaBeanModelFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavaBeanSelectionWizardPage.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavaBeanSelectionWizardPage.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavaBeanSelectionWizardPage.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,427 @@
+/*******************************************************************************
+ * 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.java;
+
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.resource.ImageDescriptor;
+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.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.jboss.tools.smooks.configuration.editors.uitls.JavaTypeFieldDialog;
+import org.jboss.tools.smooks.configuration.editors.uitls.ProjectClassLoader;
+
+/**
+ * @author Dart
+ *
+ */
+public class JavaBeanSelectionWizardPage extends WizardPage {
+
+ private String beanID = null;
+
+ private String beanClass = null;
+
+ private IJavaProject project;
+
+ private String collectionClass = null;
+
+ private boolean isArray = false;
+
+ private boolean isCollection = false;
+
+ private JavaBeanModel javaBeanModel = null;
+
+ private Button arrayButton;
+
+ private Button collectionClassBrowseButton;
+
+ private Text colllectionClassText;
+
+ public JavaBeanSelectionWizardPage(String pageName, String title, ImageDescriptor
titleImage, IJavaProject project) {
+ super(pageName, title, titleImage);
+ this.project = project;
+ this.setTitle(Messages.JavaBeanSelectionWizardPage_WizardTitle);
+ this.setDescription(Messages.JavaBeanSelectionWizardPage_WizardDes);
+ }
+
+ public JavaBeanSelectionWizardPage(String pageName, IJavaProject project) {
+ super(pageName);
+ this.project = project;
+ this.setTitle(Messages.JavaBeanSelectionWizardPage_WizardTitle);
+ this.setDescription(Messages.JavaBeanSelectionWizardPage_WizardDes);
+ }
+
+ public List<JavaBeanModel> getJavaBeanModelList() {
+ if (getJavaBeanModel() != null) {
+ List<JavaBeanModel> list = new ArrayList<JavaBeanModel>();
+ list.add(javaBeanModel);
+ return list;
+ }
+ return Collections.emptyList();
+ }
+
+ /**
+ * @return the javaBeanModel
+ */
+ public JavaBeanModel getJavaBeanModel() {
+ return javaBeanModel;
+ }
+
+ /*
+ * (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);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+
+ GridLayout gl = new GridLayout();
+ gl.numColumns = 2;
+ mainComposite.setLayout(gl);
+ mainComposite.setLayoutData(gd);
+
+ // createBeanIDControls(mainComposite);
+
+ createBeanClassControls(mainComposite);
+
+ createBeanTypeControls(mainComposite);
+
+ Label seperator = new Label(mainComposite, SWT.HORIZONTAL | SWT.SEPARATOR);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ gd.heightHint = 18;
+ seperator.setLayoutData(gd);
+
+ setControl(mainComposite);
+
+ this.setPageComplete(false);
+
+ }
+
+ private void createBeanTypeControls(Composite mainComposite) {
+
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+
+ Label beanTypeLabel = new Label(mainComposite, SWT.NONE);
+ beanTypeLabel.setText(Messages.JavaBeanSelectionWizardPage_BeanTypeLabel);
+
+ Composite composite = new Composite(mainComposite, SWT.NONE);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ composite.setLayoutData(gd);
+
+ GridLayout gl = new GridLayout();
+ gl.numColumns = 2;
+ gl.marginHeight = 0;
+ gl.marginWidth = 0;
+ gl.makeColumnsEqualWidth = false;
+ composite.setLayout(gl);
+
+ arrayButton = new Button(composite, SWT.CHECK);
+ arrayButton.setText(Messages.JavaBeanSelectionWizardPage_ArrayCheckBoxLabel);
+
+ final Button collectionButton = new Button(composite, SWT.CHECK);
+ collectionButton.setText(Messages.JavaBeanSelectionWizardPage_CollectionLabel);
+
+ Label beanClassLabel = new Label(mainComposite, SWT.NONE);
+ beanClassLabel.setText(Messages.JavaBeanSelectionWizardPage_CollectionClassLabel);
+
+ Composite beanClassComposite = new Composite(mainComposite, SWT.NONE);
+ GridLayout gl1 = new GridLayout();
+ gl1.numColumns = 2;
+ gl1.marginHeight = 0;
+ gl1.marginWidth = 0;
+
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ beanClassComposite.setLayoutData(gd);
+
+ beanClassComposite.setLayout(gl);
+
+ colllectionClassText = new Text(beanClassComposite, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ colllectionClassText.setLayoutData(gd);
+ colllectionClassText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ Text t = (Text) e.getSource();
+ collectionClass = t.getText();
+ refreshJavaBeanModel();
+ updateWizardPageStatus();
+ }
+
+ });
+ colllectionClassText.setEnabled(false);
+
+ beanClassComposite.setLayoutData(gd);
+
+ collectionClassBrowseButton = new Button(beanClassComposite, SWT.NONE);
+ collectionClassBrowseButton.setText(Messages.JavaBeanSelectionWizardPage_BrowseButtonLabel);
+ collectionClassBrowseButton.addSelectionListener(new SelectionAdapter() {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
+ * .swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ String classString = JavaTypeFieldDialog.openJavaTypeDialog(getShell(), project);
+ colllectionClassText.setText(classString);
+ }
+
+ });
+ collectionClassBrowseButton.setEnabled(false);
+
+ arrayButton.addSelectionListener(new SelectionAdapter() {
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
+ * .swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ Button button = (Button) e.getSource();
+ if (button.getSelection()) {
+ isArray = true;
+ collectionButton.setSelection(false);
+ isCollection = false;
+ collectionClassBrowseButton.setEnabled(false);
+ colllectionClassText.setEnabled(false);
+ } else {
+ isArray = false;
+ }
+ refreshJavaBeanModel();
+ updateWizardPageStatus();
+ }
+ });
+
+ collectionButton.addSelectionListener(new SelectionAdapter() {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
+ * .swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ Button button = (Button) e.getSource();
+ if (button.getSelection()) {
+ isCollection = true;
+ arrayButton.setSelection(false);
+ isArray = false;
+ collectionClassBrowseButton.setEnabled(true);
+ colllectionClassText.setEnabled(true);
+ } else {
+ isCollection = false;
+ collectionClassBrowseButton.setEnabled(false);
+ colllectionClassText.setEnabled(false);
+ }
+ updateWizardPageStatus();
+ }
+
+ });
+ collectionButton.setVisible(false);
+ beanClassComposite.setVisible(false);
+ beanClassLabel.setVisible(false);
+ }
+
+ protected void refreshJavaBeanModel() {
+ if (beanClass == null || "".equals(beanClass.trim())) { //$NON-NLS-1$
+ } else {
+ try {
+ ProjectClassLoader loader = new ProjectClassLoader(project);
+ javaBeanModel = null;
+ isCollection = isCollectionClass(beanClass);
+ isCollection = false;
+ if (isCollection) {
+ if (collectionClass != null) {
+ Class<?> clazz = loader.loadClass(beanClass);
+ Class<?> cclazz = loader.loadClass(collectionClass);
+ javaBeanModel = JavaBeanModelFactory.getJavaBeanModelWithLazyLoad(clazz);
+ javaBeanModel.setComponentClass(cclazz);
+ } else {
+ }
+ } else {
+ Class<?> clazz = loader.loadClass(beanClass);
+ if (isArray) {
+ Object arrayInstance = Array.newInstance(clazz, 0);
+ clazz = arrayInstance.getClass();
+ }
+ javaBeanModel = JavaBeanModelFactory.getJavaBeanModelWithLazyLoad(clazz);
+ }
+ if (javaBeanModel != null) {
+ if (beanID != null) {
+ javaBeanModel.setName(beanID);
+ }
+ } else {
+ }
+ } catch (JavaModelException e1) {
+ } catch (ClassNotFoundException e1) {
+ }
+ }
+ }
+
+ private void createBeanClassControls(Composite mainComposite) {
+ Label beanClassLabel = new Label(mainComposite, SWT.NONE);
+ beanClassLabel.setText(Messages.JavaBeanSelectionWizardPage_BeanClassLabel);
+
+ Composite beanClassComposite = new Composite(mainComposite, SWT.NONE);
+ GridLayout gl = new GridLayout();
+ gl.numColumns = 2;
+ gl.marginHeight = 0;
+ gl.marginWidth = 0;
+
+ beanClassComposite.setLayout(gl);
+
+ final Text beanClassText = new Text(beanClassComposite, SWT.BORDER);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ beanClassText.setLayoutData(gd);
+ beanClassText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ Text t = (Text) e.getSource();
+ arrayButton.setEnabled(true);
+ beanClass = t.getText();
+ if (beanClass != null) {
+ beanClass = beanClass.trim();
+ }
+ isCollection = isCollectionClass(beanClass);
+// if (isCollection) {
+// isArray = false;
+// arrayButton.setSelection(false);
+// arrayButton.setEnabled(false);
+// collectionClassBrowseButton.setEnabled(true);
+// colllectionClassText.setEnabled(true);
+// } else {
+// collectionClassBrowseButton.setEnabled(false);
+// colllectionClassText.setEnabled(false);
+// colllectionClassText.setText("");
+// }
+ refreshJavaBeanModel();
+ updateWizardPageStatus();
+ }
+ });
+
+ beanClassComposite.setLayoutData(gd);
+
+ Button javaTypeBrowseButton = new Button(beanClassComposite, SWT.NONE);
+ javaTypeBrowseButton.setText(Messages.JavaBeanSelectionWizardPage_BrowseButtonLabel);
+ javaTypeBrowseButton.addSelectionListener(new SelectionAdapter() {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
+ * .swt.events.SelectionEvent)
+ */
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ String classString = JavaTypeFieldDialog.openJavaTypeDialog(getShell(), project);
+ beanClassText.setText(classString);
+ }
+
+ });
+ }
+
+ private boolean isCollectionClass(String classString) {
+ if (project != null) {
+ try {
+ ProjectClassLoader loader = new ProjectClassLoader(project);
+ Class<?> clazz = loader.loadClass(classString);
+ if (Collection.class.isAssignableFrom(clazz)) {
+ return true;
+ }
+ } catch (Throwable t) {
+
+ }
+ }
+ return false;
+ }
+
+ // private void createBeanIDControls(Composite mainComposite) {
+ // Label beanIDLabel = new Label(mainComposite, SWT.NONE);
+ // beanIDLabel.setText("Bean ID :");
+ //
+ // Text beanIDText = new Text(mainComposite, SWT.BORDER);
+ // GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ // beanIDText.setLayoutData(gd);
+ // beanIDText.addModifyListener(new ModifyListener() {
+ //
+ // public void modifyText(ModifyEvent e) {
+ // Text t = (Text) e.getSource();
+ // beanID = t.getText();
+ // updateWizardPageStatus();
+ // }
+ //
+ // });
+ // }
+
+ protected void updateWizardPageStatus() {
+ String error = null;
+ if (beanClass == null || "".equals(beanClass.trim())) { //$NON-NLS-1$
+ error = Messages.JavaBeanSelectionWizardPage_BeanClassEmptyErrorMessage;
+ } else {
+ try {
+ beanClass = beanClass.trim();
+ ProjectClassLoader loader = new ProjectClassLoader(project);
+ loader.loadClass(beanClass);
+ } catch (JavaModelException e) {
+ e.printStackTrace();
+ } catch (ClassNotFoundException e) {
+ error = Messages.JavaBeanSelectionWizardPage_CantFindClass1 + beanClass +
Messages.JavaBeanSelectionWizardPage_QuoteChar; //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-1$
//$NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-1$
+ }
+ }
+
+ if (isCollection) {
+ if (collectionClass == null || "".equals(collectionClass.trim())) {
//$NON-NLS-1$
+ error =
Messages.JavaBeanSelectionWizardPage_CollectionComponentClassEmptyErrorMessage;
+ } else {
+ try {
+ ProjectClassLoader loader = new ProjectClassLoader(project);
+ loader.loadClass(collectionClass);
+ } catch (JavaModelException e) {
+ e.printStackTrace();
+ } catch (ClassNotFoundException e) {
+ error = Messages.JavaBeanSelectionWizardPage_CantFindClass1 + beanClass;
+ }
+ }
+ }
+
+ this.setErrorMessage(error);
+ this.setPageComplete(error == null);
+ }
+
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavaBeanSelectionWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavabeanContentProvider.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavabeanContentProvider.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavabeanContentProvider.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,57 @@
+package org.jboss.tools.smooks.configuration.editors.java;
+
+import java.util.Collection;
+
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.jboss.tools.smooks.configuration.editors.IXMLStructuredObject;
+/**
+ *
+ * @author Dart Peng
+ *
+ */
+public class JavabeanContentProvider implements ITreeContentProvider,
+ IStructuredContentProvider {
+
+ public Object[] getChildren(Object arg0) {
+ if (arg0 instanceof IXMLStructuredObject) {
+ return ((IXMLStructuredObject) arg0).getChildren().toArray();
+ }
+ return new Object[] {};
+ }
+
+ public Object getParent(Object arg0) {
+ if(arg0 instanceof JavaBeanModel){
+ return ((JavaBeanModel)arg0).getParent();
+ }
+ return null;
+ }
+
+ public boolean hasChildren(Object bean) {
+ if (bean instanceof JavaBeanModel) {
+ return !((JavaBeanModel) bean).isPrimitive();
+ }
+ return false;
+ }
+
+ public Object[] getElements(Object arg0) {
+ if (arg0 instanceof JavaBeanList) {
+ return ((JavaBeanList) arg0).getChildren().toArray();
+ }
+
+ if (arg0 instanceof Collection<?>) {
+ return ((Collection<?>) arg0).toArray();
+ }
+ return new Object[]{};
+ }
+
+ public void dispose() {
+
+ }
+
+ public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
+
+ }
+
+}
\ No newline at end of file
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavabeanContentProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavabeanStrucutredDataWizard.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavabeanStrucutredDataWizard.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavabeanStrucutredDataWizard.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,200 @@
+/*******************************************************************************
+ * 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.java;
+
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.jboss.tools.smooks.configuration.SmooksModelUtils;
+import org.jboss.tools.smooks.configuration.editors.SmooksMultiFormEditor;
+import
org.jboss.tools.smooks.configuration.editors.wizard.IStructuredDataSelectionWizard;
+
+/**
+ * @author Dart Peng
+ * @Date Aug 5, 2008
+ */
+public class JavabeanStrucutredDataWizard extends Wizard implements
+ IStructuredDataSelectionWizard, INewWizard {
+ JavaBeanSelectionWizardPage page = null;
+ IJavaProject project = null;
+
+
+ public JavabeanStrucutredDataWizard() {
+ super();
+ this.setWindowTitle(Messages.JavabeanStrucutredDataWizard_WizardTitle);
+ }
+
+ public IJavaProject getProject() {
+ return project;
+ }
+
+ public void setProject(IJavaProject project) {
+ this.project = project;
+ }
+
+ Object result = null;
+ Properties properties = new Properties();
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.wizard.Wizard#addPages()
+ */
+ @Override
+ public void addPages() {
+ super.addPages();
+ if (page == null) {
+ page = new JavaBeanSelectionWizardPage("javaclass",project); //$NON-NLS-1$
+ this.addPage(page);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ @Override
+ public boolean performFinish() {
+ result = page.getJavaBeanModelList();
+ return true;
+ }
+
+ public JavaBeanList getJavaBeanList() {
+ JavaBeanList list = new JavaBeanList();
+ if (result != null && result instanceof List<?>) {
+ for (Iterator<?> iterator = ((List<?>) result).iterator(); iterator
+ .hasNext();) {
+ JavaBeanModel javabean = (JavaBeanModel) iterator.next();
+ boolean isArray = "array".equals(javabean //$NON-NLS-1$
+ .getExtendProperty("many")); //$NON-NLS-1$
+ boolean isList = "list".equals(javabean //$NON-NLS-1$
+ .getExtendProperty("many")); //$NON-NLS-1$
+ if (isArray) {
+ Object arrayInstance = Array.newInstance(javabean
+ .getBeanClass(), 0);
+ JavaBeanModel model = JavaBeanModelFactory
+ .getJavaBeanModelWithLazyLoad(arrayInstance
+ .getClass());
+ list.addJavaBean(model);
+ continue;
+ }
+ if(isList){
+ JavaBeanModel model = JavaBeanModelFactory
+ .getJavaBeanModelWithLazyLoad(ArrayList.class);
+ model.setComponentClass(javabean.getBeanClass());
+ list.addJavaBean(model);
+ continue;
+ }
+ list.addJavaBean(javabean);
+ }
+ }
+ if (list.getChildren().size() <= 0) {
+ return null;
+ }
+ return list;
+ }
+
+ public Object getResult() {
+ return result;
+ }
+
+ public Object getReturnData() {
+ return getJavaBeanList();
+ }
+
+ public void init(IEditorSite site, IEditorInput input) {
+ if (input != null && input instanceof IFileEditorInput) {
+ IFileEditorInput fi = (IFileEditorInput) input;
+ IProject project = fi.getFile().getProject();
+ if (project instanceof IJavaProject) {
+ this.project = (IJavaProject) project;
+ } else {
+ this.project = JavaCore.create(project);
+ }
+ }
+ }
+
+ public String getInputDataTypeID() {
+ return SmooksModelUtils.INPUT_TYPE_JAVA;
+ }
+
+ public Properties getProperties() {
+ return this.properties;
+ }
+
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ if (selection != null) {
+ Object obj = selection.getFirstElement();
+ if (obj instanceof IJavaProject) {
+ this.project = (IJavaProject) obj;
+ }
+ if (obj instanceof IResource) {
+ IProject project = ((IResource) obj).getProject();
+ this.project = JavaCore.create(project);
+ }
+
+ if (project == null) {
+ if (obj instanceof IAdaptable) {
+ IResource relateResource = (IResource) ((IAdaptable) obj)
+ .getAdapter(IResource.class);
+ IProject project = relateResource.getProject();
+ this.project = JavaCore.create(project);
+ }
+ }
+ }
+ }
+
+ public String getStructuredDataSourcePath() {
+ List<JavaBeanModel> list = page.getJavaBeanModelList();
+ StringBuffer buffer = new StringBuffer();
+ for (Iterator<JavaBeanModel> iterator = list.iterator(); iterator
+ .hasNext(); buffer.append(";")) { //$NON-NLS-1$
+ JavaBeanModel javaBeanModel = (JavaBeanModel) iterator.next();
+ Class<?> clazz = javaBeanModel.getBeanClass();
+ if (clazz != null) {
+ boolean isArray = clazz.isArray();
+// boolean isList = "list".equals(javaBeanModel
+// .getExtendProperty("many"));
+ String cname = clazz.getName();
+ if(isArray){
+ cname = clazz.getComponentType().getName();
+ cname = cname+ "[]"; //$NON-NLS-1$
+ }
+ buffer.append(cname);
+ }
+ }
+ if(buffer.toString().endsWith(";")){ //$NON-NLS-1$
+ return buffer.substring(0, buffer.length() - 1);
+ }
+ return buffer.toString();
+ }
+
+ public void complate(SmooksMultiFormEditor formEditor) {
+ // TODO Auto-generated method stub
+
+ }
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavabeanStrucutredDataWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavabeanlabelProvider.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavabeanlabelProvider.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavabeanlabelProvider.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,84 @@
+package org.jboss.tools.smooks.configuration.editors.java;
+
+import java.util.Collection;
+
+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;
+
+public class JavabeanlabelProvider extends LabelProvider {
+
+ public Image getJavaObjectImage() {
+ return SmooksConfigurationActivator.getDefault().getImageRegistry().get(
+ GraphicsConstants.IMAGE_JAVA_OBJECT);
+ }
+
+ public Image getJavaAttributeImage() {
+ return SmooksConfigurationActivator.getDefault().getImageRegistry().get(
+ GraphicsConstants.IMAGE_JAVA_ATTRIBUTE);
+ }
+
+ public String getText(Object element) {
+ if (element instanceof JavaBeanModel) {
+ String name = ((JavaBeanModel) element).getName();
+ if (name == null)
+ name = "<nonamed>"; //$NON-NLS-1$
+
+ Object error = ((JavaBeanModel) element).getError();
+ if (error != null) {
+ name = name + " " + "<" + error.toString() +
">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ return name;
+ }
+
+ Class<?> typeRef = ((JavaBeanModel) element).getBeanClass();
+ String typeStr = ""; //$NON-NLS-1$
+ if (typeRef != null) {
+ if (typeRef.isArray()) {
+ typeRef = typeRef.getComponentType();
+ typeStr = typeRef.getName() + "[]"; //$NON-NLS-1$
+ } else {
+ typeStr = typeRef.getName();
+ }
+ }
+ if (!typeStr.equals("")) { //$NON-NLS-1$
+ name = name + " " + typeStr; //$NON-NLS-1$
+ }
+
+ return name;
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ if (element instanceof JavaBeanModel) {
+ Object error = ((JavaBeanModel) element).getError();
+ if (error != null) {
+ return SmooksConfigurationActivator.getDefault().getImageRegistry().get(
+ GraphicsConstants.IMAGE_ERROR);
+ }
+ if (((JavaBeanModel) element).isPrimitive()) {
+ return this.getJavaAttributeImage();
+ } else {
+ Class<?> typeRef = ((JavaBeanModel) element).getBeanClass();
+ if (typeRef != null) {
+ if (typeRef.isArray()) {
+ return SmooksConfigurationActivator.getDefault().getImageRegistry().get(
+ GraphicsConstants.IMAGE_JAVA_ARRAY);
+ }
+ if (Collection.class.isAssignableFrom(typeRef)) {
+ return SmooksConfigurationActivator.getDefault().getImageRegistry().get(
+ GraphicsConstants.IMAGE_JAVA_COLLECTION);
+ }
+ if (typeRef.isInterface()) {
+ return SmooksConfigurationActivator.getDefault().getImageRegistry().get(
+ GraphicsConstants.IMAGE_JAVA_INTERFACE);
+ }
+ }
+ return this.getJavaObjectImage();
+ }
+ }
+ return super.getImage(element);
+ }
+}
\ No newline at end of file
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/JavabeanlabelProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/Messages.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/Messages.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/Messages.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,52 @@
+package org.jboss.tools.smooks.configuration.editors.java;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME =
"org.jboss.tools.smooks.configuration.editors.java.messages"; //$NON-NLS-1$
+ public static String Javabean12ExpressionUICreator_ExecuteOnGroupText;
+ public static String Javabean12ExpressionUICreator_ExpressionLabel;
+ public static String JavaBean12PropertyUICreator_CantGetClassValueErrorMessage;
+ public static String JavaBean12PropertyUICreator_ClassValueEmptyErrorMessage;
+ public static String JavaBean12PropertyUICreator_CreateOnElementGroupText;
+ public static String JavaBean12PropertyUICreator_ErrorDialogTitle;
+ public static String JavabeanValueBinding12UICreator_DataGroupText;
+ public static String JavabeanWiringBiding12UICreator_WiringOnGroupText;
+
+ public static String JavaBeanSelectionWizardPage_ArrayCheckBoxLabel;
+ public static String JavaBeanSelectionWizardPage_BeanClassEmptyErrorMessage;
+ public static String JavaBeanSelectionWizardPage_BeanClassLabel;
+ public static String JavaBeanSelectionWizardPage_BeanTypeLabel;
+ public static String JavaBeanSelectionWizardPage_BrowseButtonLabel;
+ public static String JavaBeanSelectionWizardPage_CantFindClass1;
+ public static String JavaBeanSelectionWizardPage_CollectionClassLabel;
+ public static String
JavaBeanSelectionWizardPage_CollectionComponentClassEmptyErrorMessage;
+ public static String JavaBeanSelectionWizardPage_CollectionLabel;
+ public static String JavaBeanSelectionWizardPage_QuoteChar;
+ public static String JavaBeanSelectionWizardPage_WizardDes;
+ public static String JavaBeanSelectionWizardPage_WizardTitle;
+ public static String JavabeanStrucutredDataWizard_WizardTitle;
+ public static String JavaMethodsSelectionDialog_ErrorDialogTitle;
+ public static String JavaMethodsSelectionDialog_ErrorMessage;
+ public static String JavaMethodsSelectionDialog_MethodNameColumnText;
+ public static String JavaMethodsSelectionDialog_MethodParamsColumnText;
+ public static String JavaMethodsSelectionDialog_SetterDialogTitle;
+ public static String JavaPropertiesSelectionDialog_CantOpenDialogErrorMessage1;
+ public static String JavaPropertiesSelectionDialog_CantOpenDialogTitle;
+ public static String JavaPropertiesSelectionDialog_DialogTitle;
+ public static String JavaPropertiesSelectionDialog_NameColumnText;
+ public static String JavaPropertiesSelectionDialog_ProjectisJavaProjectErrorMessage;
+ public static String JavaPropertiesSelectionDialog_TypeColumnText;
+ public static String
PropertiesAndSetterMethodSearchFieldEditorCreator_BrowseButtonLabel;
+ public static String ValueWiringBindingSelectionDialog_AddBindingLabel;
+ public static String ValueWiringBindingSelectionDialog_DeselectAllLink;
+ public static String ValueWiringBindingSelectionDialog_SelectAllLink;
+ public static String ValueWiringBindingSelectionDialog_SelectJavaLabel;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/Messages.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/messages.properties
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/messages.properties
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/messages.properties 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,38 @@
+Javabean12ExpressionUICreator_ExecuteOnGroupText=Execute On Element
+Javabean12ExpressionUICreator_ExpressionLabel=Expression
+JavaBean12PropertyUICreator_CantGetClassValueErrorMessage=Can't get the
'class' value.
+JavaBean12PropertyUICreator_ClassValueEmptyErrorMessage=The 'class' value
shouldn't be empty.
+JavaBean12PropertyUICreator_CreateOnElementGroupText=Create On Element
+JavaBean12PropertyUICreator_ErrorDialogTitle=Error
+JavabeanValueBinding12UICreator_DataGroupText=Data
+JavabeanWiringBiding12UICreator_WiringOnGroupText=Wrie On Element
+
+JavaBeanSelectionWizardPage_ArrayCheckBoxLabel=Array
+JavaBeanSelectionWizardPage_BeanClassEmptyErrorMessage=Bean Class is empty
+JavaBeanSelectionWizardPage_BeanClassLabel=Java Class \:
+JavaBeanSelectionWizardPage_BeanTypeLabel=Bean Type :
+JavaBeanSelectionWizardPage_BrowseButtonLabel=Browse...
+JavaBeanSelectionWizardPage_CantFindClass1=Can't find the class "
+JavaBeanSelectionWizardPage_CollectionClassLabel=Collection Class :
+JavaBeanSelectionWizardPage_CollectionComponentClassEmptyErrorMessage=Colletion component
class is empty
+JavaBeanSelectionWizardPage_CollectionLabel=Collection
+JavaBeanSelectionWizardPage_QuoteChar="
+JavaBeanSelectionWizardPage_WizardDes=Specify the incoming Java Class sample for this
configuration.
+JavaBeanSelectionWizardPage_WizardTitle=Input Java Class
+JavabeanStrucutredDataWizard_WizardTitle=Java Class Model Wizard
+JavaMethodsSelectionDialog_ErrorDialogTitle=Can't open dialog
+JavaMethodsSelectionDialog_ErrorMessage=Can't open java methods selection
dialog.Please check the 'class' value of Java Object.
+JavaMethodsSelectionDialog_MethodNameColumnText=Method Name
+JavaMethodsSelectionDialog_MethodParamsColumnText=Paramters Type
+JavaMethodsSelectionDialog_SetterDialogTitle='s Setter Methods
+JavaPropertiesSelectionDialog_CantOpenDialogErrorMessage1=Can't get properties of
'
+JavaPropertiesSelectionDialog_CantOpenDialogTitle=Can't open dialog
+JavaPropertiesSelectionDialog_DialogTitle='s Properties
+JavaPropertiesSelectionDialog_NameColumnText=Name
+JavaPropertiesSelectionDialog_ProjectisJavaProjectErrorMessage=Please make sure the
project is the 'Java Project'
+JavaPropertiesSelectionDialog_TypeColumnText=Type
+PropertiesAndSetterMethodSearchFieldEditorCreator_BrowseButtonLabel=Browse
+ValueWiringBindingSelectionDialog_AddBindingLabel=Add Binding
+ValueWiringBindingSelectionDialog_DeselectAllLink=Deselect All
+ValueWiringBindingSelectionDialog_SelectAllLink=Select All
+ValueWiringBindingSelectionDialog_SelectJavaLabel=Choose Java bean property
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/java/messages.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/IFieldDialog.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/IFieldDialog.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/IFieldDialog.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.uitls;
+
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)<p>
+ * Apr 8, 2009
+ */
+public interface IFieldDialog {
+ Object open(Shell shell);
+ IModelProcsser getModelProcesser();
+ void setModelProcesser(IModelProcsser processer);
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/IFieldDialog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/IModelProcsser.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/IModelProcsser.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/IModelProcsser.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,13 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.configuration.editors.uitls;
+
+/**
+ * @author DartPeng
+ *
+ */
+public interface IModelProcsser {
+ Object unwrapValue(Object model);
+ Object wrapValue(Object model);
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/IModelProcsser.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JavaPropertyUtils.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JavaPropertyUtils.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JavaPropertyUtils.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,64 @@
+package org.jboss.tools.smooks.configuration.editors.uitls;
+
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ *
+ * @author Dart Peng<br>
+ * Date : Sep 10, 2008
+ */
+public class JavaPropertyUtils {
+
+ private static JavaPropertyUtils instace = null;
+
+ public static PropertyDescriptor[] getPropertyDescriptor(Class clazz) {
+ try {
+ return getInstace().getPropertyDescriptorArray(clazz);
+ } catch (Exception e) {
+ // ignore
+ return new PropertyDescriptor[]{};
+ }
+ }
+
+ public static Method[] getSetterMethods(Class<?> clazz){
+ if(clazz == null){
+ return new Method[]{};
+ }
+ Method[] methods = clazz.getMethods();
+ List<Method> mlist = new ArrayList<Method>();
+ for (int i = 0; i < methods.length; i++) {
+ Method method = methods[i];
+ String methodName = method.getName();
+ if(methodName.startsWith("set")){ //$NON-NLS-1$
+ mlist.add(method);
+ }
+ }
+ return mlist.toArray(new Method[]{});
+ }
+
+ /**
+ *
+ * @param clazz
+ * @return
+ * @throws IntrospectionException
+ */
+ public PropertyDescriptor[] getPropertyDescriptorArray(Class clazz)
+ throws IntrospectionException {
+ // TODO should improve (use some catch to store the BeanInfo , right?)
+ return Introspector
+ .getBeanInfo(clazz, Introspector.IGNORE_ALL_BEANINFO)
+ .getPropertyDescriptors();
+ }
+
+ public static JavaPropertyUtils getInstace() {
+ if (instace == null) {
+ instace = new JavaPropertyUtils();
+ }
+ return instace;
+ }
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JavaPropertyUtils.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JavaTypeFieldDialog.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JavaTypeFieldDialog.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JavaTypeFieldDialog.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,121 @@
+/*******************************************************************************
+ * Copyright (c) 2009 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.uitls;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.search.IJavaSearchScope;
+import org.eclipse.jdt.internal.corext.util.JavaModelUtil;
+import org.eclipse.jdt.internal.ui.search.JavaSearchScopeFactory;
+import org.eclipse.jdt.ui.IJavaElementSearchConstants;
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.SelectionDialog;
+import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)<p>
+ * Apr 8, 2009
+ */
+public class JavaTypeFieldDialog implements IFieldDialog {
+
+ IResource workspaceResource = null;
+
+ public JavaTypeFieldDialog(IResource resource) {
+ super();
+ workspaceResource = resource;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.smooks.configuration.editors.uitls.IFieldDialog#open()
+ */
+ public Object open(Shell shell) {
+ if (workspaceResource != null && workspaceResource instanceof IFile) {
+ IProject project = ((IFile) workspaceResource).getProject();
+ IJavaProject jp = JavaCore.create(project);
+ if (jp != null) {
+ return openJavaTypeDialog(shell, jp);
+ }
+ }
+ MessageDialog.openInformation(shell, Messages.JavaTypeFieldDialog_CantOpenErrorTitle,
+ Messages.JavaTypeFieldDialog_CantOpenErrorMessage);
+ return null;
+ }
+
+ public static String openJavaTypeDialog(Shell shell, IJavaProject javaProject ) {
+ return openJavaTypeDialog(shell, javaProject,
IJavaElementSearchConstants.CONSIDER_CLASSES);
+ }
+
+ public static String openJavaTypeDialog(Shell shell, IJavaProject javaProject , int
javaType) {
+ IJavaSearchScope scope = null;
+ String className = null;
+ if (javaProject == null) {
+ scope = JavaSearchScopeFactory.getInstance().createWorkspaceScope(true);
+ } else {
+ String[] requiredProjects = null;
+ try {
+ requiredProjects = javaProject.getRequiredProjectNames();
+ } catch (Exception e) {
+ }
+ if (requiredProjects == null) {
+ requiredProjects = new String[] { javaProject.getElementName() };
+ } else {
+ String[] temp = new String[requiredProjects.length + 1];
+ temp[0] = javaProject.getElementName();
+ System.arraycopy(requiredProjects, 0, temp, 1, requiredProjects.length);
+ requiredProjects = temp;
+ }
+ scope =
JavaSearchScopeFactory.getInstance().createJavaProjectSearchScope(requiredProjects,
true);
+ }
+ SelectionDialog dialog;
+ try {
+ dialog = JavaUI.createTypeDialog(shell,
SmooksConfigurationActivator.getDefault().getWorkbench()
+ .getActiveWorkbenchWindow(), scope,javaType, false);
+ dialog.setMessage(Messages.JavaTypeFieldDialog_SearchDialogTitle);
+ dialog.setTitle(Messages.JavaTypeFieldDialog_SearchDialogTitle);
+ if (dialog.open() == Window.OK) {
+ Object[] results = dialog.getResult();
+ if (results.length > 0) {
+ Object result = results[0];
+ String packageFullName = JavaModelUtil.getTypeContainerName((IType) result);
+ if (packageFullName == null || packageFullName.length() <= 0) {
+ className = ((IType) result).getElementName();
+ } else {
+ className = packageFullName + "." //$NON-NLS-1$
+ + ((IType) result).getElementName();
+ }
+ return className;
+ }
+ }
+ } catch (Throwable t) {
+ SmooksConfigurationActivator.getDefault().log(t);
+ }
+ return className;
+ }
+
+ public IModelProcsser getModelProcesser() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setModelProcesser(IModelProcsser processer) {
+ // TODO Auto-generated method stub
+
+ }
+
+
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/JavaTypeFieldDialog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/Messages.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/Messages.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/Messages.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,41 @@
+package org.jboss.tools.smooks.configuration.editors.uitls;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME =
"org.jboss.tools.smooks.configuration.editors.uitls.messages"; //$NON-NLS-1$
+ public static String JavaTypeFieldDialog_CantOpenErrorMessage;
+ public static String JavaTypeFieldDialog_CantOpenErrorTitle;
+ public static String JavaTypeFieldDialog_SearchDialogTitle;
+ public static String SelectorContentProposalProvider_3;
+ public static String SmooksUIUtils_AltTooltip;
+ public static String SmooksUIUtils_BigDecimal;
+ public static String SmooksUIUtils_BigInteger;
+ public static String SmooksUIUtils_Boolean;
+ public static String SmooksUIUtils_BrowseButtonLabel;
+ public static String SmooksUIUtils_Byte;
+ public static String SmooksUIUtils_Calendar;
+ public static String SmooksUIUtils_CantFindTypeErrorDialogTitle;
+ public static String SmooksUIUtils_Char;
+ public static String SmooksUIUtils_Charset;
+ public static String SmooksUIUtils_Class;
+ public static String SmooksUIUtils_CtrlSpaceTooltip;
+ public static String SmooksUIUtils_Date;
+ public static String SmooksUIUtils_Double;
+ public static String SmooksUIUtils_Enum;
+ public static String SmooksUIUtils_Float;
+ public static String SmooksUIUtils_Integer;
+ public static String SmooksUIUtils_Long;
+ public static String SmooksUIUtils_Short;
+ public static String SmooksUIUtils_SqlDate;
+ public static String SmooksUIUtils_SqlTiem;
+ public static String SmooksUIUtils_URI;
+ public static String SmooksUIUtils_URL;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/Messages.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/ProjectClassLoader.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/ProjectClassLoader.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/ProjectClassLoader.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,126 @@
+package org.jboss.tools.smooks.configuration.editors.uitls;
+
+import java.io.File;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+
+/**
+ * This class code comes from HibernateSynchronizer
+ *
+ * @author Dart Peng
+ *
+ * @CreateTime Jul 21, 2008
+ */
+public class ProjectClassLoader extends URLClassLoader {
+
+ public ProjectClassLoader(IJavaProject project) throws JavaModelException {
+ super(getURLSFromProject(project, null, true), Thread.currentThread()
+ .getContextClassLoader());
+ }
+
+ public ProjectClassLoader(IJavaProject project, URL[] extraUrls)
+ throws JavaModelException {
+ super(getURLSFromProject(project, extraUrls, true), Thread
+ .currentThread().getContextClassLoader());
+ }
+
+ private static URL[] getURLSFromProject(IJavaProject project,
+ URL[] extraUrls, boolean cludeRequiredProject)
+ throws JavaModelException {
+ if(project == null || !project.exists()){
+ return new URL[]{};
+ }
+ List<URL> list = new ArrayList<URL>();
+ if (null != extraUrls) {
+ for (int i = 0; i < extraUrls.length; i++) {
+ list.add(extraUrls[i]);
+ }
+ }
+
+ IPackageFragmentRoot[] roots = project.getAllPackageFragmentRoots();
+ if (cludeRequiredProject) {
+ String[] requiredProjectNames = project.getRequiredProjectNames();
+ for (int i = 0; i < requiredProjectNames.length; i++) {
+ String requiredProjectName = requiredProjectNames[i];
+ IProject requiredProject = ResourcesPlugin.getWorkspace()
+ .getRoot().getProject(requiredProjectName);
+ if (requiredProject != null && requiredProject.isOpen()) {
+ IJavaProject jp = JavaCore.create(requiredProject);
+ if (jp == null)
+ continue;
+ URL[] requeiredURL = getURLSFromProject(jp, extraUrls,
+ false);
+ if (requeiredURL == null)
+ continue;
+ for (int j = 0; j < requeiredURL.length; j++) {
+ list.add(requeiredURL[j]);
+ }
+ }
+ }
+ }
+ IPath installPath = ResourcesPlugin.getWorkspace().getRoot()
+ .getLocation();
+ for (int i = 0; i < roots.length; i++) {
+ try {
+ if (roots[i].isArchive()) {
+ File f = new File(FileLocator.resolve(
+ installPath.append(roots[i].getPath()).toFile()
+ .toURL()).getFile());
+ if (!f.exists()) {
+ f = new File(FileLocator.resolve(
+ roots[i].getPath().makeAbsolute().toFile()
+ .toURL()).getFile());
+ }
+ if (!f.exists()) {
+ IJavaElement javaElement = roots[i].getPrimaryElement();
+ String jarName = javaElement.getElementName();
+ IResource jarResource = project.getProject().findMember(jarName);
+
+ if(jarResource != null) {
+ f = jarResource.getRawLocation().toFile();
+ }
+ }
+
+ list.add(f.toURL());
+ } else {
+ IPath path = roots[i].getJavaProject().getOutputLocation();
+ if (path.segmentCount() > 1) {
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace()
+ .getRoot();
+ path = root.getFolder(path).getLocation();
+ list.add(path.toFile().toURL());
+ } else {
+ path = roots[i].getJavaProject().getProject()
+ .getLocation();
+ list.add(path.toFile().toURL());
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ URL[] urls = new URL[list.size()];
+ int index = 0;
+ for (Iterator<?> i = list.iterator(); i.hasNext(); index++) {
+ urls[index] = (URL) i.next();
+ }
+ return urls;
+ }
+}
\ No newline at end of file
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/ProjectClassLoader.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2010-08-09
05:55:07 UTC (rev 23989)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -11,11 +11,47 @@
package org.jboss.tools.smooks.configuration.editors.uitls;
import java.io.File;
+import java.lang.reflect.Array;
import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.edit.command.AddCommand;
+import org.eclipse.emf.edit.command.RemoveCommand;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.widgets.Shell;
+import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
+import org.jboss.tools.smooks.configuration.SmooksModelUtils;
+import org.jboss.tools.smooks.configuration.editors.IXMLStructuredObject;
+import org.jboss.tools.smooks.configuration.editors.input.InputParameter;
+import org.jboss.tools.smooks.configuration.editors.input.InputType;
+import org.jboss.tools.smooks.editor.ISmooksModelProvider;
+import org.jboss.tools.smooks.model.SmooksModel;
+import org.jboss.tools.smooks.model.core.GlobalParams;
+import org.jboss.tools.smooks.model.core.ICoreFactory;
+import org.jboss.tools.smooks.model.core.ICorePackage;
+import org.jboss.tools.smooks.model.core.IParam;
+import org.milyn.javabean.dynamic.Model;
/**
*
@@ -45,7 +81,8 @@
public static final String[] SELECTOR_SPERATORS = new String[] { " ",
"/" }; //$NON-NLS-1$ //$NON-NLS-2$
- public static String parseFilePath(String path) throws InvocationTargetException {
+ public static String parseFilePath(String path)
+ throws InvocationTargetException {
if (path == null)
return null;
if (new File(path).exists()) {
@@ -57,18 +94,368 @@
} else {
index = path.indexOf(WORKSPACE_PRIX);
if (index != -1) {
- path = path.substring(index + WORKSPACE_PRIX.length(), path.length());
+ path = path.substring(index + WORKSPACE_PRIX.length(),
+ path.length());
Path wpath = new Path(path);
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(wpath);
+ 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$
+ 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$
+ throw new InvocationTargetException(new Exception(
+ "This path is un-support" + path + ".")); //$NON-NLS-1$
//$NON-NLS-2$
}
}
return path;
}
+
+ 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$
+ }
+
+ public static IParam getInputTypeAssociatedParamType(InputType inputType,
+ Model<SmooksModel> resourceList) {
+ SmooksModel rootModel = resourceList.getModelRoot();
+ GlobalParams params = rootModel.getParams();
+ if (params != null) {
+ EList<IParam> paramList = params.getParams();
+
+ for (Iterator<?> iterator = paramList.iterator(); iterator
+ .hasNext();) {
+ IParam paramType = (IParam) iterator.next();
+ String name = paramType.getName();
+ String value = paramType.getValue();
+ if (inputType.getType().equals(name)
+ && inputType.getPath().equals(value)) {
+ // find the associated param
+ return paramType;
+ }
+ }
+ }
+ return null;
+ }
+
+ public static IParam getInputTypeParam(SmooksModel resourceList) {
+ GlobalParams params = resourceList.getParams();
+ if (params != null) {
+ List<IParam> paramList = params.getParams();
+ for (Iterator<?> iterator = paramList.iterator(); iterator
+ .hasNext();) {
+ IParam paramType = (IParam) iterator.next();
+ if (SmooksModelUtils.INPUT_TYPE.equals(paramType.getName())) {
+ return paramType;
+ }
+ }
+ }
+ return null;
+ }
+
+ public static List<InputType> recordInputDataInfomation(
+ EditingDomain domain, GlobalParams paramsType, String type,
+ String path, Properties properties, CompoundCommand compoundCommand) {
+ List<InputType> inputTypeList = new ArrayList<InputType>();
+ if (type != null && path != null && domain != null) {
+ String[] values = path.split(";"); //$NON-NLS-1$
+ if (values == null || values.length == 0) {
+ values = new String[] { path };
+ }
+ for (int i = 0; i < values.length; i++) {
+ String value = values[i];
+ value = value.trim();
+ if (value.length() == 0)
+ continue;
+ IParam inputParam = ICoreFactory.eINSTANCE.createParam();
+ InputType input = new InputType();
+ input.setPath(path);
+ input.setType(type);
+ input.setActived(false);
+
+ inputParam.setName(type);
+ inputParam.setValue(path);
+ input.setRelatedParameter(inputParam);
+ List<IParam> params = generateExtParams(type, path, properties);
+ for (Iterator<?> iterator = params.iterator(); iterator
+ .hasNext();) {
+ IParam paramType2 = (IParam) iterator.next();
+ InputParameter p = new InputParameter();
+ p.setName(getInputParameterName(input.getType(),
+ paramType2.getName()));
+ p.setValue(paramType2.getValue());
+ input.getParameters().add(p);
+ // input.setRelatedParameter(paramType2);
+ }
+ params.add(inputParam);
+ Command command = null;
+ try {
+ command = AddCommand.create(domain, paramsType,
+ ICorePackage.Literals.PARAMS__PARAMS, params);
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ if (command.canExecute()) {
+ if (compoundCommand != null) {
+ compoundCommand.append(command);
+ } else {
+ domain.getCommandStack().execute(command);
+ }
+ input.setRelatedParameter(inputParam);
+ inputTypeList.add(input);
+ }
+ }
+ }
+ return inputTypeList;
+ }
+
+ public static void removeInputType(InputType inputType,
+ ISmooksModelProvider smooksModelProvider) {
+ SmooksModel resourceList = smooksModelProvider.getSmooksModel()
+ .getModelRoot();
+ if (resourceList != null) {
+ GlobalParams params = resourceList.getParams();
+ if (params != null) {
+ List<IParam> paramList = params.getParams();
+ List<IParam> removingList = new ArrayList<IParam>();
+ for (Iterator<?> iterator = paramList.iterator(); iterator
+ .hasNext();) {
+ IParam paramType = (IParam) iterator.next();
+ String name = paramType.getName();
+ String value = paramType.getValue();
+ if (inputType.getType().equals(name)
+ && inputType.getPath().equals(value)) {
+ // find the associated param
+ removingList.add(paramType);
+ continue;
+ }
+ if (isInputAssociatedParameter(paramType, inputType)) {
+ removingList.add(paramType);
+ }
+ }
+ if (!removingList.isEmpty()) {
+ Command removeCommand = RemoveCommand.create(
+ smooksModelProvider.getEditingDomain(),
+ removingList);
+ if (removeCommand.canExecute()) {
+ smooksModelProvider.getEditingDomain()
+ .getCommandStack().execute(removeCommand);
+ }
+ }
+ }
+ }
+ }
+
+ public static IJavaProject getJavaProject(EObject model) {
+ IResource r = getResource(model);
+ if (r != null) {
+ IProject p = r.getProject();
+ return JavaCore.create(p);
+ }
+ return null;
+ }
+
+ public static Class<?> loadClass(String className, Object resource)
+ throws JavaModelException, ClassNotFoundException {
+ if (resource == null)
+ return null;
+ IJavaProject jp = null;
+ if (resource instanceof IJavaProject) {
+ jp = (IJavaProject) resource;
+ }
+ if (resource instanceof IResource) {
+ IProject project = ((IResource) resource).getProject();
+ if (project != null) {
+ jp = JavaCore.create(project);
+ }
+ }
+ if (jp != null) {
+ ProjectClassLoader loader = new ProjectClassLoader(jp);
+ if (className.endsWith("[]")) { //$NON-NLS-1$
+ className = className.substring(0, className.length() - 2);
+ Class<?> clazz = loader.loadClass(className);
+ Object arrayInstance = Array.newInstance(clazz, 0);
+ clazz = arrayInstance.getClass();
+ arrayInstance = null;
+ return clazz;
+ }
+ if (className.endsWith("]") && !className.endsWith("[]"))
{ //$NON-NLS-1$ //$NON-NLS-2$
+ // int index = className.indexOf("[");
+ // String collectionName = className.substring(0,index);
+ // String componentName = className.substring(index + 1 ,
+ // className.length() - 1);
+ // Class<?> clazz = loader.loadClass(className);
+ // Object arrayInstance = Array.newInstance(clazz, 0);
+ // clazz = arrayInstance.getClass();
+ // arrayInstance = null;
+ // return clazz;
+ }
+ return loader.loadClass(className);
+ }
+
+ return null;
+ }
+
+ public static IResource getResource(EObject model) {
+ if (model == null)
+ return null;
+ final Resource resource = ((EObject) model).eResource();
+ return getResource(resource);
+ }
+
+ public static IResource getResource(Resource resource) {
+ if (resource == null)
+ return null;
+ URI uri = resource.getURI();
+
+ if (uri == null)
+ return null;
+ IResource workspaceResource = null;
+ if (uri.isPlatformResource()) {
+ String path = uri.toPlatformString(true);
+ workspaceResource = ResourcesPlugin.getWorkspace().getRoot()
+ .findMember(new Path(path));
+ }
+ return workspaceResource;
+ }
+
+ public static String getInputParameterName(String type, String name) {
+ int index = name.indexOf(type);
+ return name.substring(index + type.length() + 1, name.length());
+ }
+
+ public static List<IParam> generateExtParams(String type, String path,
+ Properties properties) {
+ List<IParam> lists = new ArrayList<IParam>();
+ if (properties != null) {
+ Enumeration<?> enumerations = properties.keys();
+ while (enumerations.hasMoreElements()) {
+ Object key = (Object) enumerations.nextElement();
+ IParam param = ICoreFactory.eINSTANCE.createParam();
+ param.setValue(properties.getProperty(key.toString()));
+ param.setName(generateInputParameterName(type, key.toString()));
+ lists.add(param);
+ }
+ }
+ return lists;
+ }
+
+ public static String generateInputParameterName(String type, String name) {
+ return type + "." + name; //$NON-NLS-1$
+ }
+
+ public static List<InputType> recordInputDataInfomation(
+ EditingDomain domain, GlobalParams paramsType, String type,
+ String path, Properties properties) {
+ return recordInputDataInfomation(domain, paramsType, type, path,
+ properties, null);
+ }
+
+ public static List<InputType> getInputTypeList(SmooksModel resourceList) {
+ List<InputType> inputList = new
ArrayList<org.jboss.tools.smooks.configuration.editors.input.InputType>();
+ GlobalParams params = resourceList.getParams();
+ if (params != null) {
+ List<IParam> paramList = params.getParams();
+ for (Iterator<?> iterator = paramList.iterator(); iterator
+ .hasNext();) {
+ IParam paramType = (IParam) iterator.next();
+ String type = paramType.getType();
+ if (isInputParamType(paramType)) {
+ org.jboss.tools.smooks.configuration.editors.input.InputType input = new
org.jboss.tools.smooks.configuration.editors.input.InputType();
+ input.setType(paramType.getName());
+ input.setActived(SmooksModelUtils.INPUT_ACTIVE_TYPE
+ .equals(type));
+ String path = paramType.getValue();
+ if (path != null) {
+ path = path.trim();
+ }
+ input.setPath(path);
+ inputList.add(input);
+ }
+ }
+
+ for (Iterator<?> iterator = inputList.iterator(); iterator
+ .hasNext();) {
+ org.jboss.tools.smooks.configuration.editors.input.InputType input =
(org.jboss.tools.smooks.configuration.editors.input.InputType) iterator
+ .next();
+ for (Iterator<?> iterator2 = paramList.iterator(); iterator2
+ .hasNext();) {
+ IParam paramType = (IParam) iterator2.next();
+ if (isInputAssociatedParameter(paramType, input)) {
+ InputParameter p = new InputParameter();
+ p.setName(getInputParameterName(input.getType(),
+ paramType.getName()));
+ p.setValue(paramType.getValue());
+ input.getParameters().add(p);
+ }
+ }
+ }
+ }
+ return inputList;
+ }
+
+ public static boolean isInputParamType(IParam param) {
+ String type = param.getType();
+ if (SmooksModelUtils.INPUT_ACTIVE_TYPE.equals(type)
+ || SmooksModelUtils.INPUT_DEACTIVE_TYPE.equals(type)) {
+ return true;
+ }
+ return false;
+ }
+
+ public static boolean isInputAssociatedParameter(IParam param,
+ org.jboss.tools.smooks.configuration.editors.input.InputType input) {
+ String type = input.getType();
+ String pn = param.getName();
+ if (pn != null && pn.startsWith(type) && !pn.equals(type)) {
+ return true;
+ }
+ return false;
+ }
+
+ private static void expandSelectorViewer(IXMLStructuredObject model,
+ TreeViewer viewer, List<String> expandedModel, int level) {
+ if (level >= SELECTOR_EXPAND_MAX_LEVEL)
+ return;
+ level++;
+ if (expandedModel.contains(model.getNodeName())) {
+ return;
+ } else {
+ expandedModel.add(model.getNodeName());
+ viewer.expandToLevel(model, 0);
+ List<IXMLStructuredObject> children = model.getChildren();
+ for (Iterator<?> iterator = children.iterator(); iterator.hasNext();) {
+ IXMLStructuredObject structuredObject = (IXMLStructuredObject) iterator
+ .next();
+ expandSelectorViewer(structuredObject, viewer, expandedModel,
+ level);
+ }
+ }
+ }
+
+ public static void expandSelectorViewer(List<Object> models,
+ TreeViewer viewer) {
+ for (Iterator<?> iterator = models.iterator(); iterator.hasNext();) {
+ Object model = (Object) iterator.next();
+ if (model instanceof IXMLStructuredObject) {
+ expandSelectorViewer((IXMLStructuredObject) model, viewer,
+ new ArrayList<String>(), 0);
+ }
+ }
+ }
}
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/messages.properties
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/messages.properties
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/messages.properties 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,27 @@
+JavaTypeFieldDialog_CantOpenErrorMessage=Can't open java type search dialog.
+JavaTypeFieldDialog_CantOpenErrorTitle=Can't open dialog
+JavaTypeFieldDialog_SearchDialogTitle=Search Java Type
+SelectorContentProposalProvider_3=/
+SmooksUIUtils_AltTooltip=Content Assist Available (Alt + /)
+SmooksUIUtils_BigDecimal=BigDecimal
+SmooksUIUtils_BigInteger=BigInteger
+SmooksUIUtils_Boolean=Boolean
+SmooksUIUtils_BrowseButtonLabel=Browse
+SmooksUIUtils_Byte=Byte
+SmooksUIUtils_Calendar=Calendar
+SmooksUIUtils_CantFindTypeErrorDialogTitle=Can't find type
+SmooksUIUtils_Char=Character
+SmooksUIUtils_Charset=Charset
+SmooksUIUtils_Class=Class
+SmooksUIUtils_CtrlSpaceTooltip=Content Assist Available (Ctrl + space)
+SmooksUIUtils_Date=Date
+SmooksUIUtils_Double=Double
+SmooksUIUtils_Enum=Enum
+SmooksUIUtils_Float=Float
+SmooksUIUtils_Integer=Integer
+SmooksUIUtils_Long=Long
+SmooksUIUtils_Short=Short
+SmooksUIUtils_SqlDate=SqlDate
+SmooksUIUtils_SqlTiem=SqlTime
+SmooksUIUtils_URI=URI
+SmooksUIUtils_URL=URL
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/messages.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/BaseViewerInitor.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/BaseViewerInitor.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/BaseViewerInitor.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * 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.wizard;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+
+/**
+ * @author Dart Peng
+ * @Date Aug 6, 2008
+ */
+public class BaseViewerInitor implements IViewerInitor {
+ protected String typeID = null;
+ protected String name = "nonamed"; //$NON-NLS-1$
+ protected String wizardIconPath = null;
+ protected String description;
+ protected ITreeContentProvider treeContentProvider;
+ protected IStructuredDataSelectionWizard structuredDataLoadWizard;
+ protected ILabelProvider labelProvider;
+
+ /**
+ * @return the name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * @param name
+ * the name to set
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+
+ /**
+ * @return the typeID
+ */
+ public String getTypeID() {
+ return typeID;
+ }
+
+ /**
+ * @param typeID
+ * the typeID to set
+ */
+ public void setTypeID(String typeID) {
+ this.typeID = typeID;
+ }
+
+
+ /**
+ * @return the wizardIconPath
+ */
+ public String getWizardIconPath() {
+ return wizardIconPath;
+ }
+
+ /**
+ * @param wizardIconPath
+ * the wizardIconPath to set
+ */
+ public void setWizardIconPath(String wizardIconPath) {
+ this.wizardIconPath = wizardIconPath;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * @return the treeContentProvider
+ */
+ public ITreeContentProvider getTreeContentProvider() {
+ return treeContentProvider;
+ }
+
+ /**
+ * @param treeContentProvider the treeContentProvider to set
+ */
+ public void setTreeContentProvider(ITreeContentProvider treeContentProvider) {
+ this.treeContentProvider = treeContentProvider;
+ }
+
+ /**
+ * @return the structuredDataLoadWizard
+ */
+ public IStructuredDataSelectionWizard getStructuredDataLoadWizard() {
+ return structuredDataLoadWizard;
+ }
+
+ /**
+ * @param structuredDataLoadWizard the structuredDataLoadWizard to set
+ */
+ public void setStructuredDataLoadWizard(IStructuredDataSelectionWizard
structuredDataLoadWizard) {
+ this.structuredDataLoadWizard = structuredDataLoadWizard;
+ }
+
+ /**
+ * @return the labelProvider
+ */
+ public ILabelProvider getLabelProvider() {
+ return labelProvider;
+ }
+
+ /**
+ * @param labelProvider the labelProvider to set
+ */
+ public void setLabelProvider(ILabelProvider labelProvider) {
+ this.labelProvider = labelProvider;
+ }
+
+
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/BaseViewerInitor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/IStructuredDataSelectionWizard.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/IStructuredDataSelectionWizard.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/IStructuredDataSelectionWizard.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * 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.wizard;
+
+import java.util.Properties;
+
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.jboss.tools.smooks.configuration.editors.SmooksMultiFormEditor;
+
+/**
+ * @author Dart Peng
+ * @Date Aug 5, 2008
+ */
+public interface IStructuredDataSelectionWizard extends IWizard {
+
+ public Object getReturnData();
+
+ public void init(IEditorSite site, IEditorInput input);
+
+ public String getInputDataTypeID();
+
+ public Properties getProperties();
+
+ public String getStructuredDataSourcePath();
+
+ /**
+ * @deprecated
+ * @param formEditor
+ */
+ public void complate(SmooksMultiFormEditor formEditor);
+
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/IStructuredDataSelectionWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/IViewerInitor.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/IViewerInitor.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/IViewerInitor.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * 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.wizard;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+
+/**
+ * @author Dart Peng
+ * @Date Aug 5, 2008
+ */
+public interface IViewerInitor {
+
+ ILabelProvider getLabelProvider();
+
+ ITreeContentProvider getTreeContentProvider();
+
+ String getTypeID();
+
+ IStructuredDataSelectionWizard getStructuredDataLoadWizard();
+
+ String getName();
+
+ String getWizardIconPath();
+
+ String getDescription();
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/IViewerInitor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/Messages.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/Messages.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/Messages.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,16 @@
+package org.jboss.tools.smooks.configuration.editors.wizard;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME =
"org.jboss.tools.smooks.configuration.editors.wizard.messages"; //$NON-NLS-1$
+ public static String StructuredDataSelectionWizard_WizardTitle;
+ public static String TransformDataWizardSelectionPage_InputTypeLabel;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/Messages.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/StructuredDataSelectionWizard.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/StructuredDataSelectionWizard.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/StructuredDataSelectionWizard.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,107 @@
+/*******************************************************************************
+ * 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.wizard;
+
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+
+/**
+ * @author Dart Peng
+ * @Date Jul 29, 2008
+ */
+public class StructuredDataSelectionWizard extends Wizard {
+
+ TransformDataWizardSelectionPage selectTypePage;
+
+ String activeTransformID= null;
+
+ IEditorSite site;
+
+ IEditorInput input;
+
+
+
+ public StructuredDataSelectionWizard() {
+ super();
+ setWindowTitle(Messages.StructuredDataSelectionWizard_WizardTitle);
+ }
+
+ /**
+ * @return the site
+ */
+ public IEditorSite getSite() {
+ return site;
+ }
+
+
+
+ /**
+ * @param site the site to set
+ */
+ public void setSite(IEditorSite site) {
+ this.site = site;
+ }
+
+
+
+ /**
+ * @return the input
+ */
+ public IEditorInput getInput() {
+ return input;
+ }
+
+
+
+ /**
+ * @param input the input to set
+ */
+ public void setInput(IEditorInput input) {
+ this.input = input;
+ }
+
+
+
+ @Override
+ public void addPages() {
+// super.addPages();
+ selectTypePage = new TransformDataWizardSelectionPage("Select type");
//$NON-NLS-1$
+ this.addPage(selectTypePage);
+ }
+
+
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.wizard.Wizard#performFinish()
+ */
+ @Override
+ public boolean performFinish() {
+ return false;
+ }
+
+ public Object getResultObject(){
+ return null;
+ }
+
+
+ public String getActiveTransformID() {
+ return activeTransformID;
+ }
+
+
+
+ public void setActiveTransformID(String activeTransformID) {
+ this.activeTransformID = activeTransformID;
+ }
+
+
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/StructuredDataSelectionWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/TransformDataWizardSelectionPage.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/TransformDataWizardSelectionPage.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/TransformDataWizardSelectionPage.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,248 @@
+/*******************************************************************************
+ * 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.wizard;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.IWizardNode;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jface.wizard.WizardSelectionPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+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;
+import org.jboss.tools.smooks.configuration.editors.GraphicsConstants;
+
+/**
+ * @author Dart Peng
+ * @Date Jul 30, 2008
+ */
+public class TransformDataWizardSelectionPage extends WizardSelectionPage {
+
+ List<Object> registedWizard = new ArrayList<Object>();
+ TreeViewer viewer = null;
+ private Label desLabel;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets
+ * .Composite)
+ */
+ public void createControl(Composite parent) {
+ // parent.setLayout(new FillLayout());
+ Composite main = new Composite(parent, SWT.NONE);
+
+ GridLayout gridLayout = new GridLayout();
+ main.setLayout(gridLayout);
+
+ Label label = new Label(main, SWT.NONE);
+ label.setText(Messages.TransformDataWizardSelectionPage_InputTypeLabel);
+
+ 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);
+
+ viewer.setInput(registedWizard);
+ if (!registedWizard.isEmpty()) {
+ this.setSelectedNode((IWizardNode) registedWizard.get(0));
+ }
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+ IWizardNode node = (IWizardNode) selection.getFirstElement();
+ desLabel.setText(""); //$NON-NLS-1$
+ if (node != null) {
+ setSelectedNode(node);
+ if (node instanceof TransformSelectWizardNode) {
+ String des = ((TransformSelectWizardNode) node).getDescription();
+ desLabel.setText(des);
+ }
+ IStructuredDataSelectionWizard wizard = (IStructuredDataSelectionWizard)
node.getWizard();
+ StructuredDataSelectionWizard pw = (StructuredDataSelectionWizard) getWizard();
+ wizard.init(pw.getSite(), pw.getInput());
+ }
+
+ }
+
+ });
+ viewer.addDoubleClickListener(new IDoubleClickListener() {
+
+ public void doubleClick(DoubleClickEvent event) {
+ getContainer().showPage(getNextPage());
+ }
+
+ });
+
+ // for (Iterator iterator = registedWizard.iterator();
+ // iterator.hasNext();) {
+ // IWizardNode node = (IWizardNode) iterator.next();
+ // node.
+ // }
+ this.setControl(main);
+ }
+
+ public IWizardPage getNextPage() {
+ if (this.getSelectedNode() == null) {
+ return null;
+ }
+
+ boolean isCreated = getSelectedNode().isContentCreated();
+
+ IWizard wizard = getSelectedNode().getWizard();
+
+ if (wizard == null) {
+ setSelectedNode(null);
+ return null;
+ }
+ if (!isCreated) {
+ wizard.addPages();
+ }
+ return wizard.getStartingPage();
+ }
+
+ protected void createAllExtentionWizard() {
+ Collection<IViewerInitor> viewers =
ViewerInitorStore.getInstance().getViewerInitorCollection();
+ if (viewer == null)
+ return;
+ for (Iterator<IViewerInitor> iterator = viewers.iterator(); iterator.hasNext();)
{
+ IViewerInitor viewerInitor = (IViewerInitor) iterator.next();
+ TransformSelectWizardNode wn = new TransformSelectWizardNode();
+ IStructuredDataSelectionWizard wizard = viewerInitor.getStructuredDataLoadWizard();
+ if (wizard == null)
+ continue;
+ wn.setWizard(wizard);
+ wn.setName(viewerInitor.getName());
+ wn.setIconPath(viewerInitor.getWizardIconPath());
+ wn.setDescription(viewerInitor.getDescription());
+ this.registedWizard.add(wn);
+ }
+ }
+
+ public TransformDataWizardSelectionPage(String pageName) {
+ super(pageName);
+ setDescription("Choose \"Input Data Type\" to open wizard dialog to
select the input data."); //$NON-NLS-1$
+ setTitle("Input Data Selection"); //$NON-NLS-1$
+
+ }
+
+ public void activeSelectionWizard() {
+
+ }
+
+ private class WizardNodeLabelProvider extends LabelProvider {
+
+ 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 =
SmooksConfigurationActivator.getDefault().getImageRegistry().get(path);
+ if (icon == null) {
+ }else{
+ return icon;
+ }
+ }
+ return SmooksConfigurationActivator.getDefault().getImageRegistry().get(
+ GraphicsConstants.IMAGE_UNKNOWN_OBJ);
+ }
+ return super.getImage(element);
+ }
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof TransformSelectWizardNode) {
+ return ((TransformSelectWizardNode) element).getName();
+ }
+ return super.getText(element);
+ }
+
+ @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();
+ }
+ }
+
+ private class WizardNodeContentProvider implements ITreeContentProvider {
+
+ public Object[] getChildren(Object parentElement) {
+ // TODO Auto-generated method stub
+ return new Object[] {};
+ }
+
+ public Object getParent(Object element) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public Object[] getElements(Object inputElement) {
+ if (inputElement instanceof List<?>) {
+ return ((List<?>) inputElement).toArray();
+ }
+ return new Object[] {};
+ }
+
+ public void dispose() {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+
+ }
+
+ }
+
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/TransformDataWizardSelectionPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/TransformSelectWizardNode.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/TransformSelectWizardNode.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/TransformSelectWizardNode.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,100 @@
+/*******************************************************************************
+ * 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.wizard;
+
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.jface.wizard.IWizardNode;
+import org.eclipse.swt.graphics.Point;
+
+/**
+ * @author Dart Peng
+ * @Date Jul 30, 2008
+ */
+public class TransformSelectWizardNode implements IWizardNode {
+ IWizard wizard = null;
+ String name = ""; //$NON-NLS-1$
+ String iconPath = null;
+ String pluginID = null;
+ String description = ""; //$NON-NLS-1$
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public String getPluginID() {
+ return pluginID;
+ }
+
+ public void setPluginID(String pluginID) {
+ this.pluginID = pluginID;
+ }
+
+ public String getIconPath() {
+ return iconPath;
+ }
+
+ public void setIconPath(String iconPath) {
+ this.iconPath = iconPath;
+ }
+
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setWizard(IWizard wizard) {
+ this.wizard = wizard;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.wizard.IWizardNode#dispose()
+ */
+ public void dispose() {
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.wizard.IWizardNode#getExtent()
+ */
+ public Point getExtent() {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.wizard.IWizardNode#getWizard()
+ */
+ public IWizard getWizard() {
+ return wizard;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.wizard.IWizardNode#isContentCreated()
+ */
+ public boolean isContentCreated() {
+ return wizard.getPageCount() > 0;
+ }
+
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/TransformSelectWizardNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/ViewerInitorStore.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/ViewerInitorStore.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/ViewerInitorStore.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,280 @@
+/*******************************************************************************
+ * 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.wizard;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.jboss.tools.smooks.configuration.SmooksModelUtils;
+import org.jboss.tools.smooks.configuration.editors.GraphicsConstants;
+import org.jboss.tools.smooks.configuration.editors.java.JavabeanContentProvider;
+import org.jboss.tools.smooks.configuration.editors.java.JavabeanStrucutredDataWizard;
+import org.jboss.tools.smooks.configuration.editors.java.JavabeanlabelProvider;
+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;
+
+/**
+ * @author Dart Peng
+ * @Date Aug 5, 2008
+ */
+public class ViewerInitorStore {
+ protected static ViewerInitorStore instance = null;
+
+ protected HashMap<String, IViewerInitor> initorMap = null;
+
+ protected ViewerInitorStore() {
+
+ }
+
+ public Collection<IViewerInitor> getViewerInitorCollection() {
+ Map<String, IViewerInitor> map = this.getInitorMap();
+ if (map != null) {
+ return map.values();
+ }
+ return null;
+ }
+
+ public IStructuredDataSelectionWizard getStructuredDataCreationWizard(String typeID) {
+ if (this.getInitorMap() == null)
+ return null;
+ IViewerInitor initor = this.getInitorMap().get(typeID);
+ if (initor == null)
+ return null;
+ IStructuredDataSelectionWizard wizard = initor.getStructuredDataLoadWizard();
+ return wizard;
+ // if(wizard != null){
+ // try {
+ // return wizard.getClass().newInstance();
+ // } catch (Throwable t){
+ // t.printStackTrace();
+ // return wizard;
+ // }
+ // }
+ // return null;
+ }
+
+ public ILabelProvider getLabelProvider(String typeID) {
+ if (this.getInitorMap() == null)
+ return null;
+ IViewerInitor initor = this.getInitorMap().get(typeID);
+ if (initor == null)
+ return null;
+ return initor.getLabelProvider();
+ }
+
+ public ITreeContentProvider getTreeCotentProvider(String typeID) {
+ if (this.getInitorMap() == null)
+ return null;
+ IViewerInitor initor = this.getInitorMap().get(typeID);
+ if (initor == null)
+ return null;
+ return initor.getTreeContentProvider();
+ }
+
+ public synchronized static ViewerInitorStore getInstance() {
+ if (true) {
+ return new ViewerInitorStore();
+ }
+ if (instance == null) {
+ instance = new ViewerInitorStore();
+ }
+ return instance;
+ }
+
+ /**
+ * @return the initorMap
+ */
+ protected HashMap<String, IViewerInitor> getInitorMap() {
+ if (initorMap == null) {
+ initorMap = createNewInitorMap();
+ }
+ return initorMap;
+ }
+
+ // protected ILabelProvider createLabelProvider(BaseViewerInitor initor,
+ // IConfigurationElement element) {
+ // try {
+ // initor
+ // .setLabelProvider();
+ // } catch (CoreException e) {
+ // // ignore
+ // }
+ // return initor.getLabelProvider();
+ // }
+ //
+ // protected ILabelProvider createTreeContentProvider(BaseViewerInitor
+ // initor,
+ // IConfigurationElement element) {
+ // try {
+ // initor
+ // .setTreeContentProvider();
+ // } catch (CoreException e) {// ignore
+ // }
+ // return initor.getLabelProvider();
+ // }
+ //
+ // protected ILabelProvider createCreationWizard(BaseViewerInitor initor,
+ // IConfigurationElement element) {
+ // try {
+ // initor
+ // .setStructuredDataLoadWizard);
+ // } catch (CoreException e) {// ignore
+ // }
+ // return initor.getLabelProvider();
+ // }
+
+ protected HashMap<String, IViewerInitor> createNewInitorMap() {
+ HashMap<String, IViewerInitor> map = new HashMap<String, IViewerInitor>();
+
+ // for json 1.1
+// BaseViewerInitor jsonViewerInitor = new BaseViewerInitor();
+ String name = "JSON"; //$NON-NLS-1$
+ String description = "Select Json data file as the input data.";
//$NON-NLS-1$
+ String iconPath = null;
+ String typeID = SmooksModelUtils.INPUT_TYPE_JSON_1_1;
+//
+// jsonViewerInitor.setName(name);
+// jsonViewerInitor.setDescription(description);
+// jsonViewerInitor.setWizardIconPath(iconPath);
+// jsonViewerInitor.setTypeID(typeID);
+// jsonViewerInitor.setLabelProvider(new XMLStructuredDataLabelProvider());
+// jsonViewerInitor.setTreeContentProvider(new XMLStructuredDataContentProvider());
+// jsonViewerInitor.setStructuredDataLoadWizard(new JsonDataWizard());
+ // jsonViewerInitor.setWizardIconPath(GraphicsConstants.IMAGE_JAVA_FILE);
+// map.put(typeID, jsonViewerInitor);
+
+ // for json 1.2
+// BaseViewerInitor json12ViewerInitor = new BaseViewerInitor();
+// name = "Json 1.2"; //$NON-NLS-1$
+// description = "Select Json data file as the input data.(version 1.2)";
//$NON-NLS-1$
+// iconPath = null;
+// typeID = SmooksModelUtils.INPUT_TYPE_JSON_1_2;
+//
+// json12ViewerInitor.setName(name);
+// json12ViewerInitor.setDescription(description);
+// json12ViewerInitor.setWizardIconPath(iconPath);
+// json12ViewerInitor.setTypeID(typeID);
+// json12ViewerInitor.setLabelProvider(new XMLStructuredDataLabelProvider());
+// json12ViewerInitor.setTreeContentProvider(new XMLStructuredDataContentProvider());
+// json12ViewerInitor.setStructuredDataLoadWizard(new Json12DataWizard());
+// json12ViewerInitor.setWizardIconPath(GraphicsConstants.IMAGE_JAVA_FILE);
+ // don't add this
+ // map.put(typeID, json12ViewerInitor);
+
+ // for java
+ BaseViewerInitor javabeanViewerInitor = new BaseViewerInitor();
+ name = "Java"; //$NON-NLS-1$
+ description = "Select a Java type(class,interface) as the input data.";
//$NON-NLS-1$
+ iconPath = null;
+ typeID = SmooksModelUtils.INPUT_TYPE_JAVA;
+
+ javabeanViewerInitor.setName(name);
+ javabeanViewerInitor.setDescription(description);
+ javabeanViewerInitor.setWizardIconPath(iconPath);
+ javabeanViewerInitor.setTypeID(typeID);
+ 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"; //$NON-NLS-1$
+ description = "Select a XML file to be the input data. "; //$NON-NLS-1$
+ 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());
+ xmlViewerInitor.setWizardIconPath(GraphicsConstants.IMAGE_XML_FILE);
+ map.put(typeID, xmlViewerInitor);
+
+ // for XSD
+
+// BaseViewerInitor xsdViewerInitor = new BaseViewerInitor();
+// name = "XSD/WSDL"; //$NON-NLS-1$
+// description = "Select a XSD file to be the input data. Need to figure out a Root
Element. "; //$NON-NLS-1$
+// 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);
+
+ // for Csv 1.1
+// BaseViewerInitor csvViewerInitor = new BaseViewerInitor();
+// name = "CSV"; //$NON-NLS-1$
+// description = "Select CSV data file as the input data."; //$NON-NLS-1$
+// iconPath = null;
+// typeID = SmooksModelUtils.INPUT_TYPE_CSV;
+//
+// csvViewerInitor.setName(name);
+// csvViewerInitor.setDescription(description);
+// csvViewerInitor.setWizardIconPath(iconPath);
+// csvViewerInitor.setTypeID(typeID);
+// csvViewerInitor.setLabelProvider(new XMLStructuredDataLabelProvider());
+// csvViewerInitor.setTreeContentProvider(new XMLStructuredDataContentProvider());
+// csvViewerInitor.setStructuredDataLoadWizard(new CSVInputDataWizard());
+// csvViewerInitor.setWizardIconPath(GraphicsConstants.IMAGE_CSV_FILE);
+// map.put(typeID, csvViewerInitor);
+
+ // for Csv 1.2
+// BaseViewerInitor csv12ViewerInitor = new BaseViewerInitor();
+// name = "CSV 1.2"; //$NON-NLS-1$
+// description = "Select CSV data file as the input data (version 1.2).";
//$NON-NLS-1$
+// iconPath = null;
+// typeID = SmooksModelUtils.INPUT_TYPE_CSV_1_2;
+//
+// csv12ViewerInitor.setName(name);
+// csv12ViewerInitor.setDescription(description);
+// csv12ViewerInitor.setWizardIconPath(iconPath);
+// csv12ViewerInitor.setTypeID(typeID);
+// csv12ViewerInitor.setLabelProvider(new XMLStructuredDataLabelProvider());
+// csv12ViewerInitor.setTreeContentProvider(new XMLStructuredDataContentProvider());
+// csv12ViewerInitor.setStructuredDataLoadWizard(new CSV12InputDataWizard());
+ // map.put(typeID, csv12ViewerInitor);
+
+ // for EDI 1.1
+// BaseViewerInitor ediViewerInitor = new BaseViewerInitor();
+// name = "EDI"; //$NON-NLS-1$
+// description = "Select EDI data file as the input data."; //$NON-NLS-1$
+// iconPath = null;
+// typeID = SmooksModelUtils.INPUT_TYPE_EDI_1_1;
+//
+// ediViewerInitor.setName(name);
+// ediViewerInitor.setDescription(description);
+// ediViewerInitor.setWizardIconPath(iconPath);
+// ediViewerInitor.setTypeID(typeID);
+// ediViewerInitor.setLabelProvider(new XMLStructuredDataLabelProvider());
+// ediViewerInitor.setTreeContentProvider(new XMLStructuredDataContentProvider());
+// ediViewerInitor.setStructuredDataLoadWizard(new EDIDataWizard());
+// // jsonViewerInitor.setWizardIconPath(GraphicsConstants.IMAGE_JAVA_FILE);
+// map.put(typeID, ediViewerInitor);
+ return map;
+ }
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/ViewerInitorStore.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/messages.properties
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/messages.properties
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/messages.properties 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,2 @@
+StructuredDataSelectionWizard_WizardTitle=Smooks Input Data Selection Wizard
+TransformDataWizardSelectionPage_InputTypeLabel=Input Data Type
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/messages.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractFileSelectionWizardPage.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractFileSelectionWizardPage.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractFileSelectionWizardPage.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,501 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.configuration.editors.xml;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+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.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+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.IFilePathProcessor;
+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;
+ protected Button workspaceBrowseButton;
+ private String filePath = null;
+ protected Object[] initSelections;
+ protected List<ViewerFilter> filters = new ArrayList<ViewerFilter>();
+ protected boolean multiSelect = false;
+
+ private IFilePathProcessor filePathProcessor = null;
+
+ protected String[] fileExtensionNames;
+
+ public AbstractFileSelectionWizardPage(String pageName, boolean multiSelect, Object[]
initSelections,
+ List<ViewerFilter> filters,String[] fileExtensionNames) {
+ this(pageName, false, initSelections, Collections.EMPTY_LIST);
+ this.fileExtensionNames = fileExtensionNames;
+ createFileExtensionNameFilter();
+ }
+
+ /**
+ * @return the fileExtensionNames
+ */
+ public String[] getFileExtensionNames() {
+ return fileExtensionNames;
+ }
+
+
+
+ /**
+ * @param fileExtensionNames the fileExtensionNames to set
+ */
+ public void setFileExtensionNames(String[] fileExtensionNames) {
+ this.fileExtensionNames = fileExtensionNames;
+ }
+
+
+
+ public void createFileExtensionNameFilter(){
+ if (this.fileExtensionNames != null && this.fileExtensionNames.length != 0) {
+ 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 AbstractFileSelectionWizardPage(String pageName, boolean multiSelect, Object[]
initSelections,
+ List<ViewerFilter> filters) {
+ super(pageName);
+ this.initSelections = initSelections;
+ if (filters != null) {
+ this.filters.addAll(filters);
+ }
+ this.multiSelect = multiSelect;
+ }
+
+ public AbstractFileSelectionWizardPage(String pageName, String[] fileExtensionNames) {
+ this(pageName, false, null, Collections.EMPTY_LIST);
+ this.fileExtensionNames = fileExtensionNames;
+ createFileExtensionNameFilter();
+ }
+
+ 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;
+ }
+
+ public IFilePathProcessor getFilePathProcessor() {
+ return filePathProcessor;
+ }
+
+ public void setFilePathProcessor(IFilePathProcessor filePathProcessor) {
+ this.filePathProcessor = filePathProcessor;
+ }
+
+ /*
+ * (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");
+
+ 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);
+
+ changeWizardPageStatus();
+ // don't show the error message when first open the dialog
+ this.setErrorMessage(null);
+ parent.getShell().setText(Messages.AbstractFileSelectionWizardPage_WizardTitle);
+ }
+
+ 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, initSelections, filters);
//$NON-NLS-1$ //$NON-NLS-2$
+ // dialog.setInitialSelections(selectedResources);
+ if (files.length > 0) {
+ IFile file = files[0];
+ String s = processWorkSpaceFilePath(file);
+ relationT.setText(s);
+ }
+ }
+
+ protected String processFileSystemFilePath(String path) {
+ if (filePathProcessor != null) {
+ String s = filePathProcessor.processFileSystemPath(path);
+ 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) {
+ return s;
+ }
+ }
+ String s = file.getFullPath().toPortableString();
+ s = SmooksUIUtils.WORKSPACE_PRIX + s;
+ return s;
+ }
+
+ 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 = 1;
+ fileTextComposite.setLayout(xsdtgl);
+
+ Text fileText = new Text(fileTextComposite, SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ fileText.setLayoutData(gd);
+ gd.grabExcessHorizontalSpace = true;
+
+ 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);
+ createExtensionGUIFirst(xsdComposite);
+ 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;
+ 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("Browse File System"); //$NON-NLS-1$
+
+ workspaceBrowseButton = new Button(browseButtonComposite, SWT.NONE);
+ workspaceBrowseButton.setText("Browse WorkSpace"); //$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;
+ }
+
+ protected void createExtensionGUIFirst(Composite parent) {
+ // do nothing
+ }
+
+ 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());
+ if (fileExtensionNames != null) {
+ String s = ""; //$NON-NLS-1$
+ for (int i = 0; i < fileExtensionNames.length; i++) {
+ String exname = fileExtensionNames[i];
+ s += "*." + exname + ";"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ if (s.length() != 0) {
+ s = s.substring(0, s.length() - 1);
+ dialog.setFilterExtensions(new String[]{s,"*.*"}); //$NON-NLS-1$
+ }
+ }
+ String path = dialog.open();
+ if (path != null) {
+ path = processFileSystemFilePath(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 name cannot 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;
+ }
+
+ public Object[] getInitSelections() {
+ return initSelections;
+ }
+
+ public void setInitSelections(Object[] initSelections) {
+ this.initSelections = initSelections;
+ }
+
+ public List<ViewerFilter> getFilters() {
+ return filters;
+ }
+
+ public void setFilters(List<ViewerFilter> filters) {
+ this.filters = filters;
+ }
+
+ public boolean isMultiSelect() {
+ return multiSelect;
+ }
+
+ public void setMultiSelect(boolean multiSelect) {
+ this.multiSelect = multiSelect;
+ }
+
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractFileSelectionWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractStructuredDdataWizard.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractStructuredDdataWizard.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractStructuredDdataWizard.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,88 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.configuration.editors.xml;
+
+import org.eclipse.core.resources.IContainer;
+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.IFileEditorInput;
+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;
+
+ private IContainer folder = null;
+
+ public AbstractStructuredDdataWizard() {
+ // TODO Auto-generated constructor stub
+ }
+
+ @Override
+ public void addPages() {
+ if (page == null) {
+ page = createAbstractFileSelectionWizardPage();
+ page.setSelection(this.selection);
+ if (folder != null) {
+ page.setInitSelections(new Object[] { folder });
+ }
+ }
+ 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) {
+ this.folder = ((IFileEditorInput) input).getFile().getParent();
+ if (page != null && folder != null) {
+ page.setInitSelections(new Object[] { folder });
+ }
+ }
+
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ this.workbench = workbench;
+ this.selection = selection;
+ }
+
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractStructuredDdataWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractXMLObject.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractXMLObject.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractXMLObject.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,186 @@
+/*******************************************************************************
+ * 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.jboss.tools.smooks.configuration.editors.IXMLStructuredObject;
+import org.w3c.dom.Element;
+
+/**
+ * @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;
+
+ private String namespaceURI = null;
+
+ private String namespacePrefix = null;
+
+ 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 getNamespaceURI() {
+ Element element = this.getReferenceElement();
+ if (element != null) {
+ return element.getNamespaceURI();
+ }
+ return namespaceURI;
+ }
+
+ public void setNamespaceURI(String namespaceURL) {
+ Element element = this.getReferenceElement();
+ if (element != null) {
+ // Namespace ns = element.getNamespace();
+ // Namespace nns = new Namespace(ns.getPrefix(), namespaceURL);
+ // element.setQName(new QName(name, nns));
+ }
+ this.namespaceURI = namespaceURL;
+ }
+
+ /**
+ * @return the nameSpacePrefix
+ */
+ public String getNameSpacePrefix() {
+ Element element = this.getReferenceElement();
+ if (element != null) {
+ return element.getPrefix();
+ }
+ return namespacePrefix;
+ }
+
+ /**
+ * @param nameSpacePrefix
+ * the nameSpacePrefix to set
+ */
+ public void setNameSpacePrefix(String nameSpacePrefix) {
+ Element element = this.getReferenceElement();
+ if (element != null) {
+ // Namespace ns = element.getNamespace();
+ // Namespace nns = new Namespace(nameSpacePrefix, ns.getURI());
+ // element.setQName(new QName(name, nns));
+ }
+ this.namespacePrefix = nameSpacePrefix;
+ }
+
+ 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 void setQName(QName name) {
+ // this.name = name.getName();
+ // Element element = this.getReferenceElement();
+ // if (element != null) {
+ // element.setQName(name);
+ // }
+ // }
+
+ 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:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/AbstractXMLObject.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/Messages.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/Messages.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/Messages.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,28 @@
+package org.jboss.tools.smooks.configuration.editors.xml;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME =
"org.jboss.tools.smooks.configuration.editors.xml.messages"; //$NON-NLS-1$
+ public static String AbstractFileSelectionWizardPage_WizardTitle;
+ public static String XMLStructuredDataWizard_Window_Title;
+ public static String XSDStructuredDataWizard_WizardTitle;
+ public static String XMLTemplateCreationWizardPage_Button_Load;
+ public static String XMLTemplateCreationWizardPage_Error_Must_Click_Load;
+ public static String XMLTemplateCreationWizardPage_Error_Must_Select_Root;
+ public static String XMLTemplateCreationWizardPage_FileLabel;
+ public static String XMLTemplateCreationWizardPage_Label_Select_Root;
+ public static String XMLTemplateCreationWizardPage_page_description;
+ public static String XMLTemplateCreationWizardPage_Page_Title;
+ public static String XMLTemplateCreationWizardPage_XMLSampleType;
+ public static String XMLTemplateCreationWizardPage_XMLTemplateLoadError;
+ public static String XMLTemplateCreationWizardPage_XSDParsingError1;
+ public static String XMLTemplateCreationWizardPage_XSDType;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/Messages.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagList.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagList.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagList.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -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 ""; //$NON-NLS-1$
+ }
+
+
+
+ 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-NLS-1$
+ }
+
+ /* (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:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagList.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagObject.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagObject.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagObject.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * 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;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+
+/**
+ * @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);
+ Attr attribute = pro.getReferenceAttibute();
+ Element parentElement = getReferenceElement();
+ if (attribute != null && parentElement != null) {
+ if (attribute.getParentNode() == parentElement) {
+ return;
+ }
+ parentElement.appendChild(attribute);
+ }
+ }
+
+ public void removeProperty(TagPropertyObject pro) {
+ this.getProperties().remove(pro);
+ if (pro != null)
+ pro.setParent(null);
+
+ Attr attribute = pro.getReferenceAttibute();
+ Element parentElement = getReferenceElement();
+ if (attribute != null && parentElement != null) {
+ parentElement.removeAttributeNode(attribute);
+ }
+ }
+
+ public void addChildTag(TagObject tag) {
+ this.getXMLNodeChildren().add(tag);
+ if (tag != null)
+ tag.setParent(this);
+ Element childElement = tag.getReferenceElement();
+ Element parentElement = getReferenceElement();
+ if (childElement != null && parentElement != null) {
+ if (childElement.getParentNode() == parentElement) {
+ return;
+ }
+ parentElement.appendChild(childElement);
+ }
+ }
+
+ public void removeChildTag(TagObject tag) {
+ this.getXMLNodeChildren().remove(tag);
+ if (tag != null)
+ tag.setParent(null);
+
+ Element childElement = tag.getReferenceElement();
+ Element parentElement = getReferenceElement();
+ if (childElement != null && parentElement != null) {
+ parentElement.removeChild(childElement);
+ }
+
+ }
+
+ @Override
+ public List<IXMLStructuredObject> getChildren() {
+ List<IXMLStructuredObject> all = new ArrayList<IXMLStructuredObject>();
+ List<AbstractXMLObject> tags = this.getXMLNodeChildren();
+ List<TagPropertyObject> properties = this.getProperties();
+ all.addAll(properties);
+ all.addAll(tags);
+ return all;
+ }
+
+ public String toString() {
+ String blankString = ""; //$NON-NLS-1$
+ int deep = -1;
+ AbstractXMLObject parent = this;
+ while (parent != null && !(parent instanceof TagList)) {
+ deep++;
+ parent = parent.getParent();
+ }
+
+ for (int i = 0; i < deep; i++) {
+ blankString = blankString + "\t"; //$NON-NLS-1$
+ }
+
+ StringBuffer propertyesBuffer = new StringBuffer();
+ for (Iterator<?> iterator = properties.iterator(); iterator.hasNext();) {
+ TagPropertyObject pro = (TagPropertyObject) iterator.next();
+ propertyesBuffer.append(" " + pro.getName() + "=\"\"");
//$NON-NLS-1$ //$NON-NLS-2$
+ }
+ StringBuffer buffer = null;
+ if (propertyesBuffer.length() == 0) {
+ buffer = new StringBuffer(blankString + "<" + getName() +
">"); //$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ buffer = new StringBuffer(blankString + "<" + getName() +
propertyesBuffer.toString() + ">"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ List<?> l = getXMLNodeChildren();
+ if (!l.isEmpty()) {
+ buffer.append("\n"); //$NON-NLS-1$
+ }
+ for (Iterator<?> iterator = l.iterator(); iterator.hasNext();) {
+ TagObject tag = (TagObject) iterator.next();
+ buffer.append(tag.toString());
+ if (iterator.hasNext())
+ buffer.append("\n"); //$NON-NLS-1$
+ }
+
+ if (l.isEmpty()) {
+ buffer.append("</" + getName() + ">"); //$NON-NLS-1$
//$NON-NLS-2$
+ } else {
+ buffer.append("\n" + blankString + "</" + getName() +
">"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ return buffer.toString();
+ }
+
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagObject.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagPropertyObject.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagPropertyObject.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagPropertyObject.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,190 @@
+/*******************************************************************************
+ * 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;
+
+import org.w3c.dom.Attr;
+
+
+/**
+ * @author Dart Peng
+ * @Date Jul 25, 2008
+ */
+public class TagPropertyObject extends AbstractXMLObject {
+
+ protected String type = "string"; //$NON-NLS-1$
+
+ protected String value = null;
+
+ protected Attr referenceAttibute;
+
+ public String getValue() {
+ Attr attribute = getReferenceAttibute();
+ if (attribute != null) {
+ return attribute.getValue();
+ }
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ Attr attribute = getReferenceAttibute();
+ if (attribute != null) {
+ attribute.setValue(value);
+ }
+ }
+
+ /**
+ * @return the referenceAttibute
+ */
+ public Attr getReferenceAttibute() {
+ return referenceAttibute;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.jboss.tools.smooks.configuration.editors.xml.AbstractXMLObject#getName
+ * ()
+ */
+ @Override
+ public String getName() {
+ Attr attribute = getReferenceAttibute();
+ if (attribute != null) {
+ return attribute.getName();
+ } else {
+ return super.getName();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.configuration.editors.xml.AbstractXMLObject#
+ * getNameSpacePrefix()
+ */
+ @Override
+ public String getNameSpacePrefix() {
+ Attr attribute = getReferenceAttibute();
+ if (attribute != null) {
+ return attribute.getPrefix();
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.configuration.editors.xml.AbstractXMLObject#
+ * getNamespaceURI()
+ */
+ @Override
+ public String getNamespaceURI() {
+ Attr attribute = getReferenceAttibute();
+ if (attribute != null) {
+ return attribute.getNamespaceURI();
+ }
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.jboss.tools.smooks.configuration.editors.xml.AbstractXMLObject#setName
+ * (java.lang.String)
+ */
+ @Override
+ public void setName(String name) {
+ if(name != null && name.equals(getName())){
+ return;
+ }
+ super.setName(name);
+ Attr attribute = getReferenceAttibute();
+ if (attribute != null) {
+// String namespace = attribute.getNamespaceURI();
+// String namespacePrefix = attribute.getNamespacePrefix();
+// Element container = attribute.getParent();
+// String value = attribute.getValue();
+// container.remove(attribute);
+// Attr newAttribute = DOMDocumentFactory.getInstance().createAttribute(container,
+// new QName(name, new Namespace(namespacePrefix, namespace)), value);
+// container.add(newAttribute);
+// this.setReferenceAttibute(newAttribute);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.configuration.editors.xml.AbstractXMLObject#
+ * setNameSpacePrefix(java.lang.String)
+ */
+ @Override
+ public void setNameSpacePrefix(String nameSpacePrefix) {
+ Attr attribute = getReferenceAttibute();
+ if (attribute != null) {
+ attribute.setPrefix(nameSpacePrefix);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.configuration.editors.xml.AbstractXMLObject#
+ * setNamespaceURI(java.lang.String)
+ */
+ @Override
+ public void setNamespaceURI(String namespaceURI) {
+ Attr attribute = getReferenceAttibute();
+ if (attribute != null) {
+// attribute.setNamespace(new Namespace(attribute.getNamespacePrefix(),
namespaceURI));
+ }
+ }
+
+ /**
+ * @param referenceAttibute
+ * the referenceAttibute to set
+ */
+ public void setReferenceAttibute(Attr referenceAttibute) {
+ this.referenceAttibute = referenceAttibute;
+ }
+
+ @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(); //$NON-NLS-1$
+ }
+
+ @Override
+ public List<AbstractXMLObject> getXMLNodeChildren() {
+ return Collections.emptyList();
+ }
+
+ @Override
+ public void setChildren(List<AbstractXMLObject> children) {
+ }
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/TagPropertyObject.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/WSDLObjectAnalyzer.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/WSDLObjectAnalyzer.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/WSDLObjectAnalyzer.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -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:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/WSDLObjectAnalyzer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLObjectAnalyzer.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLObjectAnalyzer.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLObjectAnalyzer.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,198 @@
+/*******************************************************************************
+ * 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.io.InputStream;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.Attr;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.SAXException;
+
+/**
+ * @author Dart Peng
+ * @Date Jul 25, 2008
+ */
+public class XMLObjectAnalyzer {
+ public TagList analyze(String xmlFilePath, String[] ignoreNodeNames,
+ Class<? extends AbstractXMLObject> tagObjectClass) throws
ParserConfigurationException, SAXException,
+ IOException {
+ FileInputStream stream = new FileInputStream(xmlFilePath);
+ TagList list = this.analyze(stream, ignoreNodeNames, tagObjectClass);
+ try {
+ stream.close();
+ } catch (IOException e) {
+ }
+ return list;
+ }
+
+ public TagList analyze(Document doc, String[] ignoreNodeNames, Class<? extends
AbstractXMLObject> tagObjectClass) {
+ if (doc == null)
+ return null;
+ Element rootElement = doc.getDocumentElement();
+ TagList dco = new TagList();
+ dco.setName("Docuement"); //$NON-NLS-1$
+ dco.addRootTag(parseElement(rootElement, null, ignoreNodeNames, tagObjectClass));
+ return dco;
+ }
+
+ public TagList analyze(InputStream stream, String[] ignoreNodeNames,
+ Class<? extends AbstractXMLObject> tagObjectClass) throws
ParserConfigurationException, SAXException,
+ IOException {
+ DocumentBuilder builder = createDocumentBuildingFactory();
+ Document doc = builder.parse(stream);
+ return analyze(doc, ignoreNodeNames, tagObjectClass);
+ }
+
+ public DocumentBuilder createDocumentBuildingFactory() throws
ParserConfigurationException {
+ return XMLUtils.getDOMBuilder();
+ }
+
+ public TagObject analyzeFregment(InputStream stream, String[] ignoreNodeNames,
+ Class<? extends AbstractXMLObject> tagObjectClass) throws
ParserConfigurationException, SAXException,
+ IOException {
+ DocumentBuilder builder = createDocumentBuildingFactory();
+ org.w3c.dom.Document doc = builder.parse(stream);
+ Element rootElement = doc.getDocumentElement();
+ return parseElement(rootElement, null, ignoreNodeNames, tagObjectClass);
+ }
+
+ 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.getNodeName(), 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,
+ Class<? extends AbstractXMLObject> tagObjectClass) {
+ if (isIgnoreNode(element, ignoreNodeNames))
+ return null;
+ boolean canAdd = false;
+ TagObject tag = getChildTagByName(element.getNodeName(), parentTag, ignoreNodeNames);
+ if (tag == null) {
+ if (tagObjectClass != null) {
+ try {
+ tag = (TagObject) tagObjectClass.newInstance();
+ } catch (InstantiationException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ }
+ } else {
+ tag = new TagObject();
+ }
+ canAdd = true;
+ }
+ if (tag == null)
+ return null;
+
+ tag.setReferenceElement(element);
+ String localName = element.getLocalName();
+ String nodeName = element.getNodeName();
+ if (localName == null) {
+ localName = nodeName;
+ }
+ tag.setName(localName);
+ fillProperties(element, tag, ignoreNodeNames);
+ tag.setNamespaceURI(element.getNamespaceURI());
+ NodeList nodeList = element.getChildNodes();
+ for (int i = 0; i < nodeList.getLength(); i++) {
+ Node node = nodeList.item(i);
+ if (node instanceof Element) {
+ Element childElement = (Element) node;
+ TagObject t = parseElement(childElement, tag, ignoreNodeNames, tagObjectClass);
+ if (t != null) {
+ tag.addChildTag(t);
+ t.setReferenceElement(childElement);
+ }
+ }
+ }
+ 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)
{
+ NamedNodeMap attrMap = element.getAttributes();
+ for (int i = 0; i < attrMap.getLength(); i++) {
+ Node node = attrMap.item(i);
+ if (node instanceof Attr) {
+ Attr attr = (Attr) node;
+ String attrName = attr.getName();
+ String value = attr.getValue();
+ if (isIgnoreNode(attrName, ignoreNodeNames))
+ continue;
+ if (hasSameNameProperty(attrName, tag)) {
+ continue;
+ }
+ TagPropertyObject pro = new TagPropertyObject();
+ String localName = attr.getLocalName();
+ String name = attr.getNodeName();
+ if (localName == null) {
+ localName = name;
+ }
+ pro.setName(localName);
+ pro.setValue(value);
+ pro.setNamespaceURI(attr.getNamespaceURI());
+ tag.addProperty(pro);
+ }
+ }
+ }
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLObjectAnalyzer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataContentProvider.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataContentProvider.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataContentProvider.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * 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;
+import org.jboss.tools.smooks.configuration.editors.IXMLStructuredObject;
+
+/**
+ * @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();
+ }
+
+ if(obj instanceof IXMLStructuredObject){
+ return ((IXMLStructuredObject)obj).getChildren().toArray();
+ }
+ return new Object[] {};
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object )
+ */
+ public Object getParent(Object arg0) {
+ if(arg0 instanceof IXMLStructuredObject){
+ return ((IXMLStructuredObject)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();
+ }
+ if(arg0 instanceof IXMLStructuredObject){
+ return ((IXMLStructuredObject)arg0).getChildren().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:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataContentProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataLabelProvider.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataLabelProvider.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataLabelProvider.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -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"; //$NON-NLS-1$
+ }
+ if (element instanceof AbstractXMLObject) {
+ return ((AbstractXMLObject) element).getName();
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataLabelProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataWizard.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataWizard.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataWizard.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * 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.smooks.configuration.SmooksModelUtils;
+import org.jboss.tools.smooks.configuration.editors.SmooksMultiFormEditor;
+
+/**
+ * @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"; //$NON-NLS-1$
+
+
+
+ public XMLStructuredDataWizard() {
+ super();
+ setWindowTitle(Messages.XMLStructuredDataWizard_Window_Title);
+ }
+
+ @Override
+ protected AbstractFileSelectionWizardPage createAbstractFileSelectionWizardPage() {
+ return new XMLStructuredDataWizardPage("XML"); //$NON-NLS-1$
+ }
+
+ 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;
+ }
+
+ public void complate(SmooksMultiFormEditor formEditor) {
+ // TODO Auto-generated method stub
+
+ }
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataWizardPage.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataWizardPage.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataWizardPage.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,36 @@
+/**
+ *
+ */
+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,new
String[]{"xml","xsd","wsdl","xsl"}); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ 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 {
+ return null;
+// XMLObjectAnalyzer analyzer = new XMLObjectAnalyzer();
+// TagList doc = analyzer.analyze(path, null);
+// return doc;
+ }
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLStructuredDataWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLTemplateCreationWizardPage.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLTemplateCreationWizardPage.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLTemplateCreationWizardPage.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,361 @@
+/*******************************************************************************
+ * 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.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+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.Combo;
+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.jboss.tools.smooks.configuration.SmooksModelUtils;
+import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
+import org.jboss.tools.smooks.templating.model.ModelBuilderException;
+import org.jboss.tools.smooks.templating.model.xml.XSDModelBuilder;
+import org.xml.sax.SAXException;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ *
+ */
+public class XMLTemplateCreationWizardPage extends AbstractFileSelectionWizardPage {
+
+ private Throwable parsingError = null;
+
+ protected Combo createFromDropdown = null;
+
+ protected CheckboxTableViewer tableViewer = null;
+ protected Label tableViewerLabel;
+
+ private boolean fireEvent = true;
+
+ private String rootElementName = null;
+
+ protected Button loadXSDButton;
+
+ private TemplateSourceType templateSourceType = TemplateSourceType.xsd;
+
+ public static enum TemplateSourceType {
+ // Template from XML Schema
+ xsd,
+ // Template from an XML Sample
+ xml
+ }
+
+ /*
+ * (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 XMLTemplateCreationWizardPage(String pageName) {
+ super(pageName, new String[] { "xsd" }); //$NON-NLS-1$
+ this.setTitle(Messages.XMLTemplateCreationWizardPage_Page_Title);
+ this.setDescription(Messages.XMLTemplateCreationWizardPage_page_description);
+
+ this.templateSourceType = TemplateSourceType.xsd;
+ }
+
+ public TemplateSourceType getTemplateSourceType() {
+ return templateSourceType;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @seeorg.jboss.tools.smooks.configuration.editors.xml.
+ * AbstractFileSelectionWizardPage#changeWizardPageStatus()
+ */
+ @Override
+ protected void changeWizardPageStatus() {
+ super.changeWizardPageStatus();
+ String errorMessage = this.getErrorMessage();
+ if (errorMessage == null && templateSourceType == TemplateSourceType.xsd) {
+
+ if (reasourceLoaded) {
+ if (tableViewer.getCheckedElements() == null ||
tableViewer.getCheckedElements().length == 0) {
+ errorMessage = Messages.XMLTemplateCreationWizardPage_Error_Must_Select_Root;
+ }
+ } else {
+ errorMessage = Messages.XMLTemplateCreationWizardPage_Error_Must_Click_Load;
+ }
+ if(parsingError != null){
+ errorMessage = parsingError.getLocalizedMessage();
+ }
+ 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;
+
+ loadXSDButton = new Button(fileTextComposite, SWT.NONE);
+ loadXSDButton.setText(Messages.XMLTemplateCreationWizardPage_Button_Load);
+ loadXSDButton.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ super.widgetSelected(e);
+ parsingError = null;
+ reasourceLoaded = false;
+ if (fileText.getText() == null || fileText.getText().length() == 0) {
+ changeWizardPageStatus();
+ return;
+ }
+
+ List<String> list;
+ try {
+ list = loadElement(fileText.getText());
+ if (list == null || list.isEmpty()) {
+ setErrorMessage(Messages.XMLTemplateCreationWizardPage_XSDParsingError1);
+ } else {
+ tableViewer.setInput(list);
+ reasourceLoaded = true;
+ }
+ } catch (InvocationTargetException e1) {
+ parsingError = e1.getTargetException();
+ while(parsingError instanceof InvocationTargetException){
+ parsingError = ((InvocationTargetException)parsingError).getTargetException();
+ }
+ } catch (IOException e1) {
+ parsingError = e1;
+ } catch (ModelBuilderException e1) {
+ parsingError = e1;
+ }
+ changeWizardPageStatus();
+ }
+
+ });
+ return fileText;
+ }
+
+ private List<String> loadElement(String path) throws InvocationTargetException,
IOException, ModelBuilderException {
+ List<String> elements = new ArrayList<String>();
+ if (path == null)
+ return null;
+ String pp = path.toLowerCase();
+ if (pp.endsWith(".wsdl")) { //$NON-NLS-1$
+ try {
+ List<XSDElementDeclaration> xsdDec = WSDLObjectAnalyzer.loadAllElement(path);
+ for (Iterator<?> iterator = xsdDec.iterator(); iterator.hasNext();) {
+ XSDElementDeclaration xsdElementDeclaration = (XSDElementDeclaration)
iterator.next();
+ elements.add(xsdElementDeclaration.getAliasName());
+ }
+ } catch (ParserConfigurationException e) {
+ throw new InvocationTargetException(e);
+ } catch (SAXException e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+ String file = null;
+ file = SmooksUIUtils.parseFilePath(path);
+ XSDModelBuilder xsdModelBuilder = new XSDModelBuilder(URI.createFileURI(file));
+ Set<String> elementNames = xsdModelBuilder.getRootElementNames();
+ Iterator<String> it = elementNames.iterator();
+ while (it.hasNext()) {
+ String name = it.next();
+ elements.add(name);
+ }
+ return elements;
+ }
+
+ public void createControl(Composite parent) {
+ Composite mainComposite = new Composite(parent, SWT.NONE);
+ GridLayout gl = new GridLayout();
+ mainComposite.setLayout(gl);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ mainComposite.setLayoutData(gd);
+
+ Label fileTypeLabel = new Label(mainComposite, SWT.NONE);
+ fileTypeLabel.setText(Messages.XMLTemplateCreationWizardPage_FileLabel);
+
+ createFromDropdown = new Combo(mainComposite, SWT.READ_ONLY | SWT.BORDER);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ initCombo(createFromDropdown);
+ createFromDropdown.setLayoutData(gd);
+ createFromDropdown.select(0);
+
+ createFromDropdown.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ updateTemplateSourceType();
+ }
+ });
+
+ Label separator = new Label(mainComposite, SWT.SEPARATOR | SWT.HORIZONTAL);
+ separator.setLayoutData(gd);
+
+ super.createControl(mainComposite);
+
+ mainComposite = (Composite) getControl();
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ tableViewerLabel = new Label(mainComposite, SWT.NONE);
+ tableViewerLabel.setLayoutData(gd);
+ tableViewerLabel.setText(Messages.XMLTemplateCreationWizardPage_Label_Select_Root);
+ 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);
+ Object checkElement = event.getElement();
+ if (checkElement instanceof String) {
+ rootElementName = (String) checkElement;
+ }
+ }
+ fireEvent = true;
+ changeWizardPageStatus();
+ }
+
+ });
+
+ this.setControl(mainComposite);
+ }
+
+ public Combo getCombo() {
+ return createFromDropdown;
+ }
+
+ protected void updateTemplateSourceType() {
+ switch (createFromDropdown.getSelectionIndex()) {
+ case 0 :
+ templateSourceType = TemplateSourceType.xsd;
+ break;
+ case 1 :
+ templateSourceType = TemplateSourceType.xml;
+ break;
+ default :
+ throw new
IllegalStateException(Messages.XMLTemplateCreationWizardPage_XMLTemplateLoadError);
+ }
+
+ // Table should only be visible for XSD template sources...
+ tableViewer.getTable().setVisible(templateSourceType == TemplateSourceType.xsd);
+ tableViewerLabel.setVisible(templateSourceType == TemplateSourceType.xsd);
+ loadXSDButton.setEnabled(templateSourceType == TemplateSourceType.xsd);
+
+ // Reset the file browse filter...
+ setFileExtensionNames(new String[] {templateSourceType.toString()});
+ }
+
+ private void initCombo(Combo combo2) {
+ combo2.add(Messages.XMLTemplateCreationWizardPage_XSDType);
+ combo2.add(Messages.XMLTemplateCreationWizardPage_XMLSampleType);
+ }
+
+ public String getInputType(){
+ if(createFromDropdown.getSelectionIndex() == 0){
+ return SmooksModelUtils.KEY_XML_FILE_TYPE_XSD;
+ }
+ if(createFromDropdown.getSelectionIndex() == 1){
+ return SmooksModelUtils.KEY_XML_FILE_TYPE_XML;
+ }
+ return null;
+ }
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLTemplateCreationWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLUtils.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLUtils.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLUtils.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,183 @@
+/*******************************************************************************
+ * 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.OutputStream;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.w3c.dom.DOMConfiguration;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.ls.DOMImplementationLS;
+import org.w3c.dom.ls.LSOutput;
+import org.w3c.dom.ls.LSSerializer;
+
+/**
+ * @author Dart
+ *
+ */
+public class XMLUtils {
+
+ public static DocumentBuilder getDOMBuilder() throws ParserConfigurationException {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ dbf.setValidating(false);
+ DocumentBuilder builder = dbf.newDocumentBuilder();
+ return builder;
+ }
+
+ public static Transformer getTransformer() throws TransformerConfigurationException {
+ TransformerFactory tf = TransformerFactory.newInstance();
+ return tf.newTransformer();
+ }
+
+ public static Document createDocument() throws ParserConfigurationException {
+ return XMLUtils.getDOMBuilder().newDocument();
+ }
+
+ public static Element firstChildElement(Node node) {
+ for (Node tempNode = node.getFirstChild(); tempNode != null; tempNode =
tempNode.getNextSibling()) {
+ if (tempNode.getNodeType() == Node.ELEMENT_NODE) {
+ return (Element) tempNode;
+ }
+ }
+ return null;
+ }
+
+ public static Element nextSiblingElement(Node node) {
+ for (Node tempNode = node.getNextSibling(); tempNode != null; tempNode =
tempNode.getNextSibling()) {
+ if (tempNode.getNodeType() == Node.ELEMENT_NODE) {
+ return (Element) tempNode;
+ }
+ }
+ return null;
+ }
+
+ public static Element lastChildElement(Node node) {
+ for (Node tempNode = node.getLastChild(); tempNode != null; tempNode =
tempNode.getPreviousSibling()) {
+ if (tempNode.getNodeType() == Node.ELEMENT_NODE) {
+ return (Element) tempNode;
+ }
+ }
+ return null;
+ }
+
+ public static Element previousSiblingElement(Node node) {
+ for (Node tempNode = node.getPreviousSibling(); tempNode != null; tempNode =
tempNode.getPreviousSibling()) {
+ if (tempNode.getNodeType() == Node.ELEMENT_NODE) {
+ return (Element) tempNode;
+ }
+ }
+ return null;
+ }
+
+ public static List<Element> getAllChildElements(Node node) {
+ List<Element> v = new ArrayList<Element>();
+ Node child = XMLUtils.firstChildElement(node);
+ while (child != null) {
+ v.add((Element) child);
+ child = XMLUtils.nextSiblingElement(child);
+ }
+ return v;
+ }
+
+ public static List<Element> getChildElementsByNS(Node node, String uri, String
localName) {
+ List<Element> childElements = XMLUtils.getAllChildElements(node);
+ List<Element> v = new ArrayList<Element>();
+ for (int i = 0; i < childElements.size(); i++) {
+ Element child = (Element) childElements.get(i);
+ String ln = child.getLocalName();
+ String u = child.getNamespaceURI();
+ if (uri == null) {
+ if (ln.equals(localName)) {
+ v.add(child);
+ }
+ } else {
+ if (ln.equals(localName) && u.equals(uri)) {
+ v.add(child);
+ }
+ }
+ }
+ return v;
+ }
+
+ public static String getLocalName(String nodeName) {
+ int index = nodeName.lastIndexOf(58);
+ if (index == -1) {
+ return nodeName;
+ } else {
+ return nodeName.substring(index + 1, nodeName.length());
+ }
+ }
+
+ public static String getPrefix(String nodeName) {
+ int index = nodeName.lastIndexOf(58);
+ if (index == -1) {
+ return null;
+ } else {
+ return nodeName.substring(0, index);
+ }
+ }
+
+ public static void outDOMNode(Node node, Writer writer) throws
TransformerConfigurationException,
+ TransformerException {
+ Transformer transformer = XMLUtils.getTransformer();
+ Source source = new DOMSource(node);
+ Result result = new StreamResult(writer);
+ transformer.transform(source, result);
+ }
+
+ public static void outDOMNode(Node node, OutputStream os) throws
TransformerConfigurationException,
+ TransformerException {
+
+ Document document = null;
+ if (node instanceof Document) {
+ document = (Document) node;
+ } else {
+ document = node.getOwnerDocument();
+ }
+ Object ls = null;
+ if (document != null) {
+ ls = document.getImplementation().getFeature("LS", "3.0");
//$NON-NLS-1$ //$NON-NLS-2$
+ }
+ if (ls != null && ls instanceof DOMImplementationLS) {
+ LSSerializer lss = ((DOMImplementationLS) ls).createLSSerializer();
+ DOMConfiguration domConfiguration = lss.getDomConfig();
+ if (domConfiguration.canSetParameter("format-pretty-print", Boolean.TRUE)) {
//$NON-NLS-1$
+ lss.getDomConfig().setParameter("format-pretty-print", Boolean.TRUE);
//$NON-NLS-1$
+ }
+ LSOutput lsoutput = ((DOMImplementationLS) ls).createLSOutput();
+ lsoutput.setByteStream(os);
+ lss.write(node, lsoutput);
+ } else {
+ Transformer transformer = XMLUtils.getTransformer();
+ Source source = new DOMSource(node);
+ Result result = new StreamResult(os);
+ transformer.transform(source, result);
+ }
+
+ }
+}
\ No newline at end of file
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XMLUtils.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDListContentProvider.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDListContentProvider.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDListContentProvider.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * 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.List;
+
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+/**
+ * @author Dart
+ *
+ */
+public 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:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDListContentProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDListLabelProvider.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDListLabelProvider.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDListLabelProvider.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * 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.xsd.XSDElementDeclaration;
+
+/**
+ * @author Dart
+ *
+ */
+public 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();
+ }
+ if(element instanceof String) return (String)element;
+ return super.getText(element);
+ }
+
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDListLabelProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDObjectAnalyzer.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDObjectAnalyzer.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDObjectAnalyzer.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,293 @@
+/*******************************************************************************
+ * 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.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 = null;
+ try {
+ file = SmooksUIUtils.parseFilePath(filePath);
+ } catch (Exception e) {
+ return nl;
+ }
+ 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.setNamespaceURI(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.setNamespaceURI(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"));
//$NON-NLS-1$
+ resource.load(Collections.EMPTY_MAP);
+ XSDSchema schema = (XSDSchema) resource.getContents().get(0);
+ TagObject rootTag = new XSDObjectAnalyzer().loadElement(schema,
"smooks-resource-list"); //$NON-NLS-1$
+ 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();
+ // }
+ }
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDObjectAnalyzer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDStructuredDataWizard.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDStructuredDataWizard.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDStructuredDataWizard.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * 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.smooks.configuration.SmooksModelUtils;
+import org.jboss.tools.smooks.configuration.editors.SmooksMultiFormEditor;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ *
+ */
+public class XSDStructuredDataWizard extends AbstractStructuredDdataWizard {
+
+
+ public XSDStructuredDataWizard() {
+ super();
+ setWindowTitle(Messages.XSDStructuredDataWizard_WizardTitle);
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.smooks.configuration.editors.xml.AbstractStructuredDdataWizard#createAbstractFileSelectionWizardPage()
+ */
+ @Override
+ protected AbstractFileSelectionWizardPage createAbstractFileSelectionWizardPage() {
+ // TODO Auto-generated method stub
+ return new XMLTemplateCreationWizardPage("XSD"); //$NON-NLS-1$
+ }
+
+ /* (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",
((XMLTemplateCreationWizardPage)page).getRootElementName()); //$NON-NLS-1$
+ return pro;
+ }
+
+ public void complate(SmooksMultiFormEditor formEditor) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/XSDStructuredDataWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/messages.properties
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/messages.properties
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/messages.properties 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,14 @@
+AbstractFileSelectionWizardPage_WizardTitle=Select File
+XMLStructuredDataWizard_Window_Title=XML File Input Data Wizard
+XSDStructuredDataWizard_WizardTitle=Apply XML Template
+XMLTemplateCreationWizardPage_Button_Load=Load
+XMLTemplateCreationWizardPage_Error_Must_Click_Load=Press 'Load' button to load
XSD root element names.
+XMLTemplateCreationWizardPage_Error_Must_Select_Root=Must select a root element.
+XMLTemplateCreationWizardPage_FileLabel=Create Template From:
+XMLTemplateCreationWizardPage_Label_Select_Root=Select root element
+XMLTemplateCreationWizardPage_page_description=Select template generation source
+XMLTemplateCreationWizardPage_Page_Title=Apply XML Template
+XMLTemplateCreationWizardPage_XMLSampleType=Sample XML
+XMLTemplateCreationWizardPage_XMLTemplateLoadError=Unexpected XML Template source
selection. Code must be updated to accomodate new source type.
+XMLTemplateCreationWizardPage_XSDParsingError1=Can't get the elements in the XSD
file.
+XMLTemplateCreationWizardPage_XSDType=XSD
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/messages.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/ISmooksModelValidateListener.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/ISmooksModelValidateListener.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/ISmooksModelValidateListener.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,10 @@
+package org.jboss.tools.smooks.configuration.validate;
+
+import java.util.List;
+
+import org.eclipse.emf.common.util.Diagnostic;
+
+public interface ISmooksModelValidateListener {
+ void validateStart();
+ void validateEnd(List<Diagnostic> diagnosticResult);
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/ISmooksModelValidateListener.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/Messages.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/Messages.java
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/Messages.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,31 @@
+package org.jboss.tools.smooks.configuration.validate;
+
+import org.eclipse.osgi.util.NLS;
+
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME =
"org.jboss.tools.smooks.configuration.validate.messages"; //$NON-NLS-1$
+ public static String BeanIdRefValidator_Warning_Does_Not_Exist;
+ public static String BeanIdRefValidator_Warning_Java_Bean;
+ public static String ClassFieldEditorValidator_Warning_Abstract_Class;
+ public static String ClassFieldEditorValidator_Warning_Cannot_Find_Class;
+ public static String ClassFieldEditorValidator_Warning_Class_Cannot_Be_Instanced;
+ public static String ClassFieldEditorValidator_Warning_Class_Cannot_Be_Instanced2;
+ public static String DuplicatedBeanIDValidator_Warning_Duplicate_Bean_ID;
+ public static String PropertyValidator_Warning_Property_Cannot_Be_Found;
+ public static String PropertyValidator_Warning_Property_Cannot_Be_Found2;
+ public static String SelectorValidator_Warning_Cannot_Find_Input_Source;
+ public static String SelectorValidator_Warning_Is_Not_Available;
+ public static String SelectorValidator_Warning_Must_Be_Linked_to_Source;
+ public static String SelectorValidator_Warning_Selector;
+ public static String SetterMethodValidator_Warning_Cannot_Be_Found;
+ public static String SetterMethodValidator_Warning_Setter_Method;
+ public static String SmooksModelValidator_Task_Validating;
+ public static String SmooksModelValidator_Task_Validating_Smooks_Model;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/Messages.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/messages.properties
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/messages.properties
(rev 0)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/messages.properties 2010-08-09
08:49:06 UTC (rev 23990)
@@ -0,0 +1,17 @@
+BeanIdRefValidator_Warning_Does_Not_Exist=' dosen't exist.
+BeanIdRefValidator_Warning_Java_Bean=The Java Bean '
+ClassFieldEditorValidator_Warning_Abstract_Class=The class can't be abstract
+ClassFieldEditorValidator_Warning_Cannot_Find_Class=Can't find class : "
+ClassFieldEditorValidator_Warning_Class_Cannot_Be_Instanced=The class '
+ClassFieldEditorValidator_Warning_Class_Cannot_Be_Instanced2='can't be instanced
+DuplicatedBeanIDValidator_Warning_Duplicate_Bean_ID=Duplicated Bean ID:
+PropertyValidator_Warning_Property_Cannot_Be_Found=Property '
+PropertyValidator_Warning_Property_Cannot_Be_Found2=' can't be found in class.
+SelectorValidator_Warning_Cannot_Find_Input_Source=Can't find the input source node :
'
+SelectorValidator_Warning_Is_Not_Available=' isn't available
+SelectorValidator_Warning_Must_Be_Linked_to_Source=Must be linked with source input node
+SelectorValidator_Warning_Selector=Selector '
+SetterMethodValidator_Warning_Cannot_Be_Found=' can't be found in class.
+SetterMethodValidator_Warning_Setter_Method=Setter method '
+SmooksModelValidator_Task_Validating=Validating...
+SmooksModelValidator_Task_Validating_Smooks_Model=Validate Smooks Model
Property changes on:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/validate/messages.properties
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/AbstractSmooksFormEditor.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/AbstractSmooksFormEditor.java 2010-08-09
05:55:07 UTC (rev 23989)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/AbstractSmooksFormEditor.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -56,9 +56,11 @@
import org.jboss.tools.smooks.configuration.RuntimeMetadata;
import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
import org.jboss.tools.smooks.configuration.editors.SmooksXMLEditor;
+import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
import org.jboss.tools.smooks.graphical.editors.ISmooksEditorInitListener;
import org.jboss.tools.smooks.model.SmooksEditorModelBuilder;
import org.jboss.tools.smooks.model.SmooksModel;
+import org.jboss.tools.smooks.model.core.IParam;
import org.milyn.javabean.dynamic.Model;
/**
@@ -638,4 +640,12 @@
return editingDomain;
}
+ public String getInputType() {
+ IParam inputParam = SmooksUIUtils.getInputTypeParam(smooksModel.getModelRoot());
+ if (inputParam != null) {
+ return inputParam.getValue();
+ }
+ return "";
+ }
+
}
Modified:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/ISmooksModelProvider.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/ISmooksModelProvider.java 2010-08-09
05:55:07 UTC (rev 23989)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/editor/ISmooksModelProvider.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -13,4 +13,6 @@
*/
public interface ISmooksModelProvider extends IEditingDomainProvider{
Model<SmooksModel> getSmooksModel();
+
+ String getInputType();
}
Modified:
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksProcessGraphicalEditor.java
===================================================================
---
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksProcessGraphicalEditor.java 2010-08-09
05:55:07 UTC (rev 23989)
+++
branches/smooks-dmb/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/graphical/editors/SmooksProcessGraphicalEditor.java 2010-08-09
08:49:06 UTC (rev 23990)
@@ -7,6 +7,7 @@
import java.beans.PropertyChangeListener;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.EventObject;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -14,6 +15,15 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.draw2d.IFigure;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.command.CommandWrapper;
+import org.eclipse.emf.common.command.CompoundCommand;
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.edit.command.AddCommand;
+import org.eclipse.emf.edit.command.DeleteCommand;
+import org.eclipse.emf.edit.command.RemoveCommand;
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
@@ -21,6 +31,7 @@
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.swt.SWT;
@@ -35,6 +46,7 @@
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.ui.IEditorActionBarContributor;
+import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorSite;
import org.eclipse.ui.IPropertyListener;
@@ -58,6 +70,8 @@
import org.eclipse.zest.layouts.LayoutStyles;
import org.eclipse.zest.layouts.algorithms.HorizontalTreeLayoutAlgorithm;
import org.jboss.tools.smooks.configuration.editors.GraphicsConstants;
+import org.jboss.tools.smooks.configuration.editors.SmooksReaderFormPage;
+import org.jboss.tools.smooks.configuration.validate.ISmooksModelValidateListener;
import org.jboss.tools.smooks.editor.AbstractSmooksFormEditor;
import org.jboss.tools.smooks.editor.ISmooksModelProvider;
import org.jboss.tools.smooks.graphical.actions.AbstractProcessGraphAction;
@@ -77,7 +91,7 @@
* @author Dart
*
*/
-public class SmooksProcessGraphicalEditor extends FormPage implements IProcessProvider ,
PropertyChangeListener , IPropertyListener{
+public class SmooksProcessGraphicalEditor extends FormPage implements IProcessProvider ,
PropertyChangeListener , IPropertyListener , ISelectionChangedListener{
private boolean processMapActived = false;
@@ -277,6 +291,115 @@
}
+ public void init(IEditorSite site, IEditorInput input) {
+ super.init(site, input);
+ if (smooksModelProvider != null) {
+ this.handleCommandStack(smooksModelProvider.getEditingDomain().getCommandStack());
+ }
+
+ List<TaskTypeDescriptor> tasks = TaskTypeManager.getAllTaskList();
+ for (Iterator<?> iterator = tasks.iterator(); iterator.hasNext();) {
+ TaskTypeDescriptor taskTypeDescriptor = (TaskTypeDescriptor) iterator.next();
+ IEditorPart part = createEditorPart(taskTypeDescriptor.getId());
+ if (part != null && isSingltonEditor(taskTypeDescriptor.getId())) {
+ this.registeTaskDetailsPage(part, taskTypeDescriptor.getId());
+ }
+ }
+ }
+
+ private void handleCommandStack(org.eclipse.emf.common.command.CommandStack
commandStack) {
+ commandStack.addCommandStackListener(new
org.eclipse.emf.common.command.CommandStackListener() {
+ public void commandStackChanged(EventObject event) {
+ final Command mostRecentCommand = ((org.eclipse.emf.common.command.CommandStack)
event.getSource())
+ .getMostRecentCommand();
+ getEditorSite().getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ if (mostRecentCommand != null) {
+ Command rawCommand = mostRecentCommand;
+ while (rawCommand instanceof CommandWrapper) {
+ rawCommand = ((CommandWrapper) rawCommand).getCommand();
+ }
+ Collection<?> activeModel = rawCommand.getAffectedObjects();
+ for (Iterator<?> iterator = activeModel.iterator(); iterator.hasNext();) {
+ Object object = (Object) iterator.next();
+ if (object instanceof TaskType || object instanceof ProcessType) {
+ validateEnd(null);
+ if (getProcessGraphViewer() != null) {
+ getProcessGraphViewer().refresh();
+ getProcessGraphViewer().applyLayout();
+ break;
+ }
+ }
+ }
+ if (rawCommand instanceof CompoundCommand) {
+ List<Command> command = ((CompoundCommand) rawCommand).getCommandList();
+ for (Iterator<?> iterator = command.iterator(); iterator.hasNext();) {
+ Command command2 = (Command) iterator.next();
+ while (command2 instanceof CommandWrapper) {
+ command2 = ((CommandWrapper) command2).getCommand();
+ }
+ if (command2 instanceof DeleteCommand || command2 instanceof RemoveCommand) {
+ Collection<?> objs = ((Command) command2).getAffectedObjects();
+ for (Iterator<?> iterator2 = objs.iterator(); iterator2.hasNext();) {
+ Object object = (Object) iterator2.next();
+ object = AdapterFactoryEditingDomain.unwrap(object);
+ if (object instanceof TaskType || object instanceof ProcessType) {
+ validateEnd(null);
+ showTaskControl(null);
+ break;
+ }
+ }
+ }
+
+ if (command2 instanceof AddCommand || command2 instanceof SetCommand) {
+ Collection<?> objs = ((Command) command2).getAffectedObjects();
+ for (Iterator<?> iterator2 = objs.iterator(); iterator2.hasNext();) {
+ Object object = (Object) iterator2.next();
+ object = AdapterFactoryEditingDomain.unwrap(object);
+ if (object instanceof TaskType) {
+ validateEnd(null);
+ showTaskControl((TaskType) object);
+ break;
+ }
+ }
+ }
+ }
+ } else {
+ if (rawCommand instanceof DeleteCommand || rawCommand instanceof RemoveCommand)
{
+ activeModel = rawCommand.getAffectedObjects();
+ for (Iterator<?> iterator = activeModel.iterator(); iterator.hasNext();)
{
+ Object object = (Object) iterator.next();
+ object = AdapterFactoryEditingDomain.unwrap(object);
+ if (object instanceof TaskType || object instanceof ProcessType) {
+ if (getProcessGraphViewer() != null) {
+ validateEnd(null);
+ showTaskControl(null);
+ break;
+ }
+ }
+ }
+ }
+ if (rawCommand instanceof AddCommand || rawCommand instanceof SetCommand) {
+ Collection<?> objs = ((Command) rawCommand).getAffectedObjects();
+ for (Iterator<?> iterator2 = objs.iterator(); iterator2.hasNext();) {
+ Object object = (Object) iterator2.next();
+ object = AdapterFactoryEditingDomain.unwrap(object);
+ if (object instanceof TaskType) {
+ validateEnd(null);
+ showTaskControl((TaskType) object);
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ });
+ }
+ });
+ }
+
private void generateNextTaskActions(MenuManager addNextTaskMenuManager) {
List<TaskTypeDescriptor> list = TaskTypeManager.getAllTaskList();
for (Iterator<?> iterator = list.iterator(); iterator.hasNext();) {
@@ -375,8 +498,8 @@
unhighlightGraphNodes();
highlightGraphNode(item);
}
-// showTaskControl(firstElement);
-// SmooksProcessGraphicalEditor.this.selectionChanged(event);
+ showTaskControl(firstElement);
+ SmooksProcessGraphicalEditor.this.selectionChanged(event);
updateGlobalActions();
}
});
@@ -547,10 +670,10 @@
// SmooksJavaMappingGraphicalEditor javaMappingPart = new
SmooksJavaMappingGraphicalEditor(smooksModelProvider);
// return javaMappingPart;
// }
-// if (taskID.equals(TaskTypeManager.TASK_ID_INPUT)) {
-// SmooksReaderFormPage readerPage = new SmooksReaderFormPage(getEditor(),
"input", "input"); //$NON-NLS-1$ //$NON-NLS-2$
-// return readerPage;
-// }
+ if (taskID.equals(TaskTypeManager.TASK_ID_INPUT)) {
+ SmooksReaderFormPage readerPage = new SmooksReaderFormPage(getEditor(),
"input", "input"); //$NON-NLS-1$ //$NON-NLS-2$
+ return readerPage;
+ }
return null;
}
@@ -706,6 +829,7 @@
}
} else {
Object page = getRegisteTaskPage(id);
+ try{
ITaskNodeProvider nodeProvider = (ITaskNodeProvider) ((IEditorPart) page)
.getAdapter(ITaskNodeProvider.class);
if (nodeProvider != null) {
@@ -727,6 +851,9 @@
GridData gd = new GridData(GridData.FILL_BOTH);
contentParent.setLayoutData(gd);
detailsContentsComposite.layout(false);
+ }catch(Throwable t){
+ t.printStackTrace();
+ }
}
}
} else {
@@ -820,6 +947,7 @@
}
}
+
/**
* @return the needupdatewhenshow
*/
@@ -834,11 +962,55 @@
public void setNeedupdatewhenshow(boolean needupdatewhenshow) {
this.needupdatewhenshow = needupdatewhenshow;
}
+
+ public void validateEnd(List<Diagnostic> diagnosticResult) {
+ Collection<Object> editors = registedTaskPages.values();
+ for (Iterator<?> iterator = editors.iterator(); iterator.hasNext();) {
+ Object object = (Object) iterator.next();
+ if (object instanceof ISmooksModelValidateListener) {
+ ((ISmooksModelValidateListener) object).validateEnd(diagnosticResult);
+ }
+ }
+ ProcessType process = this.getProcess();
+ validateProcess(process);
+ }
+
+ protected void validateProcess(ProcessType process) {
+ if (process != null) {
+ validateTasks(process.getTask());
+ GraphViewer viewer = this.getProcessGraphViewer();
+ if (viewer != null)
+ viewer.refresh();
+ }
+ }
+
+ protected void validateTasks(List<TaskType> tasks) {
+ if (tasks == null)
+ return;
+ for (Iterator<?> iterator = tasks.iterator(); iterator.hasNext();) {
+ TaskType taskType = (TaskType) iterator.next();
+ validateTask(taskType);
+ validateTasks(taskType.getTask());
+ }
+ }
+
+ protected void validateTask(TaskType t) {
+
+ }
+
+
public ProcessType getProcess() {
return this.process;
}
+ public void selectionChanged(SelectionChangedEvent event) {
+ ISelectionProvider provider = getEditor().getSite().getSelectionProvider();
+ if (provider != null) {
+ provider.setSelection(event.getSelection());
+ }
+ }
+
public void propertyChanged(Object source, int propId) {
this.firePropertyChange(propId);
if (propId == PROP_DIRTY) {