Author: DartPeng
Date: 2009-04-12 06:55:55 -0400 (Sun, 12 Apr 2009)
New Revision: 14692
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/CompoundStructuredDataContentProvider.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/CompoundStructuredDataLabelProvider.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ExtentionInputContentProvider.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ExtentionInputLabelProvider.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IXMLStructuredObject.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/InputStructuredDataSelectionDialog.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectorAttributes.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksResourceChangeListener.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksToolsStartup.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/StructuredDataSelectionWizardDailog.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/IJavaBeanSelectionListener.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanConfigWizardPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanList.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModel.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModelFactory.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModelLoadComposite.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanContentProvider.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanStrucutredDataWizard.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanlabelProvider.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/BaseViewerInitor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/IStructuredDataSelectionWizard.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/IViewerInitor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/StructuredDataSelectionWizard.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/TransformDataWizardSelectionPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/TransformSelectWizardNode.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/ViewerInitorStore.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xml/
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/SmooksConfigurationActivator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/SmooksConstants.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/Codegenerator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/GraphicsConstants.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IPropertyUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksConfigurationFormPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMasterDetailBlock.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMultiFormEditor.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffPropertyDetailPage.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/Template.txt
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanWiringUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/PropertiesAndSetterMethodSearchFieldEditorCreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ConditionTypeUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ImportTypeUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ParamTypeUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ResourceConfigTypeUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ResourceTypeUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xsl/BindToUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xsl/OutputToUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xsl/TemplateUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xsl/XslUICreator.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/wizards/SmooksConfigurationFileNewWizard.java
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/wizards/SmooksFileContainerSelectionPage.java
Log:
Add new feature for smooks-configuration-editor:
1.Add input data path
2.Show editor to select input data and transform the data to "selector"
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/SmooksConfigurationActivator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/SmooksConfigurationActivator.java 2009-04-10
16:56:24 UTC (rev 14691)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/SmooksConfigurationActivator.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -66,6 +66,37 @@
super.initializeImageRegistry(reg);
reg.put(GraphicsConstants.JAVA_PROPERTY_ICON,
getImageDescriptor(GraphicsConstants.JAVA_PROPERTY_ICON_PATH));
+
+ reg.put(GraphicsConstants.IMAGE_EMPTY,
getImageDescriptor(GraphicsConstants.IMAGE_PATH_BLANK));
+ reg.put(GraphicsConstants.IMAGE_ERROR,
getImageDescriptor(GraphicsConstants.IMAGE_PATH_ERROR));
+ reg.put(GraphicsConstants.IMAGE_WARNING,
getImageDescriptor(GraphicsConstants.IMAGE_PATH_WARNING));
+
+ // regist java images
+ reg.put(GraphicsConstants.IMAGE_JAVA_INTERFACE, imageDescriptorFromPlugin(PLUGIN_ID,
+ GraphicsConstants.IMAGE_JAVA_INTERFACE));
+ reg.put(GraphicsConstants.IMAGE_JAVA_ATTRIBUTE, imageDescriptorFromPlugin(PLUGIN_ID,
+ GraphicsConstants.IMAGE_JAVA_ATTRIBUTE));
+ reg.put(GraphicsConstants.IMAGE_CHECKBOX_CHECK, imageDescriptorFromPlugin(PLUGIN_ID,
+ GraphicsConstants.IMAGE_CHECKBOX_CHECK));
+ reg.put(GraphicsConstants.IMAGE_CHECKBOX_UNCHECK, imageDescriptorFromPlugin(PLUGIN_ID,
+ GraphicsConstants.IMAGE_CHECKBOX_UNCHECK));
+ reg.put(GraphicsConstants.IMAGE_JAVA_OBJECT, imageDescriptorFromPlugin(PLUGIN_ID,
+ "icons/full/obj16/class_obj.gif"));
+ reg.put(GraphicsConstants.IMAGE_JAVA_ARRAY, imageDescriptorFromPlugin(PLUGIN_ID,
+ GraphicsConstants.IMAGE_JAVA_ARRAY));
+ reg.put(GraphicsConstants.IMAGE_JAVA_COLLECTION, imageDescriptorFromPlugin(PLUGIN_ID,
+ GraphicsConstants.IMAGE_JAVA_COLLECTION));
+
+ // for the xml2xml line
+ reg.put(GraphicsConstants.IMAGE_BINDING_LINE, imageDescriptorFromPlugin(PLUGIN_ID,
+ GraphicsConstants.IMAGE_BINDING_LINE));
+
+ reg.put(GraphicsConstants.IMAGE_MAPPING_LINE, imageDescriptorFromPlugin(PLUGIN_ID,
+ GraphicsConstants.IMAGE_MAPPING_LINE));
+ reg.put(GraphicsConstants.IMAGE_XML_ATTRIBUTE, imageDescriptorFromPlugin(PLUGIN_ID,
+ "icons/full/obj16/attribute_obj.gif"));
+ reg.put(GraphicsConstants.IMAGE_XML_ELEMENT, imageDescriptorFromPlugin(PLUGIN_ID,
+ "icons/full/obj16/element_obj.gif"));
}
/**
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/SmooksConstants.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/SmooksConstants.java 2009-04-10
16:56:24 UTC (rev 14691)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/SmooksConstants.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -16,6 +16,17 @@
*/
public class SmooksConstants {
public static final String SMOOKS_EXTENTION_NAME = "xml";
+
+ public static final String SMOOKS_GRAPHICSEXT_EXTENTION_NAME = "ext";
+
+ public static final String SMOOKS_EXTENTION_NAME_WITHDOT = "." +
SMOOKS_EXTENTION_NAME;
+
+ public static final String SMOOKS_GRAPHICSEXT_EXTENTION_NAME_WITHDOT = "." +
SMOOKS_GRAPHICSEXT_EXTENTION_NAME;
+
+
public static final String VERSION_1_0 = "1.0";
- public static final String VERSION_1_1_1 = "1.1.1";
+
+ public static final String VERSION_1_1 = "1.1";
+
+ public static final String[] SMOOKS_VERSIONS = new String[]{VERSION_1_0,VERSION_1_1};
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/Codegenerator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/Codegenerator.java 2009-04-10
16:56:24 UTC (rev 14691)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/Codegenerator.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -13,7 +13,7 @@
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EPackage;
-import org.jboss.tools.smooks.model.xsl.XslPackage;
+import org.jboss.tools.smooks.model.smooks.SmooksPackage;
public class Codegenerator {
String basePath =
"/home/Dart/Works/eclipse_wtp.3.0.4/eclipse/workspace/jbosstools/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/temp/";
@@ -23,7 +23,7 @@
try {
FileReader reader = new FileReader(
new File(
- "/home/Dart/Works/eclipse_wtp.3.0.4/eclipse/workspace/jbosstools/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/Template.txt"));
+ "/home/DartPeng/Work/eclipse/new-smooks-editor/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/Template.txt"));
BufferedReader r = new BufferedReader(reader);
String line = r.readLine();
while (line != null) {
@@ -43,7 +43,7 @@
public static void main(String[] args) {
Codegenerator g = new Codegenerator();
try {
- g.generateCodes(XslPackage.eINSTANCE);
+ g.generateCodes(SmooksPackage.eINSTANCE);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
@@ -95,7 +95,7 @@
String allepName = epName + ".eINSTANCE.get" + eClass.getName();
List<EAttribute> alist = eClass.getEAllAttributes();
String attributeMethod = "";
- for (Iterator iterator = alist.iterator(); iterator.hasNext();) {
+ for (Iterator<?> iterator = alist.iterator(); iterator.hasNext();) {
EAttribute attribute = (EAttribute) iterator.next();
String atn = attribute.getName();
String firstC = new String(new char[]{ atn.toCharArray()[0] });
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/CompoundStructuredDataContentProvider.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/CompoundStructuredDataContentProvider.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/CompoundStructuredDataContentProvider.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -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:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/CompoundStructuredDataContentProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/CompoundStructuredDataLabelProvider.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/CompoundStructuredDataLabelProvider.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/CompoundStructuredDataLabelProvider.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -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:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/CompoundStructuredDataLabelProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ExtentionInputContentProvider.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ExtentionInputContentProvider.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ExtentionInputContentProvider.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * 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 org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.jboss.tools.smooks.model.graphics.ext.SmooksGraphicsExtType;
+
+/**
+ * @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 SmooksGraphicsExtType){
+ 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:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ExtentionInputContentProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ExtentionInputLabelProvider.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ExtentionInputLabelProvider.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ExtentionInputLabelProvider.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * 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 org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
+import org.jboss.tools.smooks.model.graphics.ext.InputType;
+import org.jboss.tools.smooks10.model.smooks.util.SmooksModelUtils;
+
+/**
+ * @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_OBJECT);
+ }
+ if (SmooksModelUtils.INPUT_TYPE_XML.equals(type)) {
+ return SmooksConfigurationActivator.getDefault().getImageRegistry().get(
+ GraphicsConstants.IMAGE_XML_ELEMENT);
+ }
+ }
+ }
+ 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 = SmooksModelUtils.getInputPath((InputType) element);
+ if (value == null)
+ value = "";
+ switch (columnIndex) {
+ case 0:
+ return ((InputType) element).getType();
+ case 1:
+ return value;
+ }
+ }
+ return "";
+ }
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/ExtentionInputLabelProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/GraphicsConstants.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/GraphicsConstants.java 2009-04-10
16:56:24 UTC (rev 14691)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/GraphicsConstants.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -1,6 +1,46 @@
package org.jboss.tools.smooks.configuration.editors;
+import org.eclipse.swt.graphics.Color;
+
public final class GraphicsConstants {
- public static final String JAVA_PROPERTY_ICON_PATH =
"icons/full/obj16/att_obj.gif";
+
+ public static final Color BORDER_CORLOER = new Color(null,128,128,128);
+
+ public static final String IMAGE_JAVA_ATTRIBUTE =
"icons/full/obj16/att_obj.gif";
+
+ public static final String IMAGE_JAVA_OBJECT = "java_object";
+
+ public static final String IMAGE_JAVA_INTERFACE =
"icons/full/obj16/int_obj.gif";
+
+ public static final String IMAGE_JAVA_COLLECTION =
"icons/full/obj16/javalistmodel.gif";
+
+ public static final String IMAGE_JAVA_ARRAY =
"icons/full/obj16/javaarraymodel.gif";
+
+ public static final String IMAGE_CHECKBOX_CHECK =
"icons/full/obj16/checkbox_checked.gif";
+
+ public static final String IMAGE_CHECKBOX_UNCHECK =
"icons/full/obj16/checkbox_uncheck.gif";
+
+ public static final String JAVA_PROPERTY_ICON_PATH = IMAGE_JAVA_ATTRIBUTE;
+
public static final String JAVA_PROPERTY_ICON = JAVA_PROPERTY_ICON_PATH;
+
+ public static final String IMAGE_PATH_ERROR =
"icons/full/obj16/error_obj.gif";
+
+ public static final String IMAGE_PATH_WARNING =
"icons/full/obj16/warning_obj.gif";
+
+ public static final String IMAGE_PATH_BLANK = "icons/full/obj16/blank.gif";
+
+ public static final String IMAGE_WARNING = IMAGE_PATH_WARNING;
+
+ public static final String IMAGE_ERROR = IMAGE_PATH_ERROR;
+
+ public static final String IMAGE_EMPTY = IMAGE_PATH_BLANK;
+
+ public static final String IMAGE_XML_ELEMENT = "xml_element";
+
+ public static final String IMAGE_XML_ATTRIBUTE = "xml_attribute";
+
+ public static final String IMAGE_MAPPING_LINE =
"icons/full/obj16/mapping_line.gif";
+
+ public static final String IMAGE_BINDING_LINE =
"icons/full/obj16/binding_line.gif";
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IPropertyUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IPropertyUICreator.java 2009-04-10
16:56:24 UTC (rev 14691)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IPropertyUICreator.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -23,7 +23,11 @@
*/
public interface IPropertyUICreator {
public Composite createPropertyUI(FormToolkit toolkit, Composite parent,
- IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature);
+ IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature,
+ SmooksMultiFormEditor formEditor);
+
+ public void createExtendUI(AdapterFactoryEditingDomain editingdomain, FormToolkit
toolkit,
+ Composite parent, Object model, SmooksMultiFormEditor formEditor);
- public void createExtendUI(AdapterFactoryEditingDomain editingdomain,FormToolkit
toolkit, Composite parent,Object model );
+ public boolean ignoreProperty(EAttribute feature);
}
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IXMLStructuredObject.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IXMLStructuredObject.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IXMLStructuredObject.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -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:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/IXMLStructuredObject.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/InputStructuredDataSelectionDialog.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/InputStructuredDataSelectionDialog.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/InputStructuredDataSelectionDialog.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * 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.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.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
+import org.jboss.tools.smooks.configuration.editors.javabean.JavaBeanModel;
+import org.jboss.tools.smooks.configuration.editors.javabean.JavaBeanModelFactory;
+import org.jboss.tools.smooks.configuration.editors.uitls.ProjectClassLoader;
+import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
+import org.jboss.tools.smooks.model.graphics.ext.InputType;
+import org.jboss.tools.smooks.model.graphics.ext.SmooksGraphicsExtType;
+import org.jboss.tools.smooks10.model.smooks.util.SmooksModelUtils;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ * <p>
+ * Apr 12, 2009
+ */
+public class InputStructuredDataSelectionDialog extends Dialog {
+
+ private SmooksGraphicsExtType graphicsExt;
+ private TreeViewer viewer;
+ private Object currentSelection;
+
+ public InputStructuredDataSelectionDialog(IShellProvider parentShell) {
+ super(parentShell);
+ // TODO Auto-generated constructor stub
+ }
+
+ public InputStructuredDataSelectionDialog(Shell parentShell, SmooksGraphicsExtType
graphicsExt) {
+ super(parentShell);
+ this.graphicsExt = graphicsExt;
+ }
+
+ /*
+ * (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 = 400;
+ gd.widthHint = 400;
+ composite.setLayoutData(gd);
+ composite.setLayout(new FillLayout());
+ viewer = new TreeViewer(composite, SWT.BORDER);
+ viewer.setContentProvider(new CompoundStructuredDataContentProvider());
+ viewer.setLabelProvider(new CompoundStructuredDataLabelProvider());
+ viewer.setInput(generateInputData());
+ viewer.addDoubleClickListener(new IDoubleClickListener() {
+ public void doubleClick(DoubleClickEvent event) {
+ okPressed();
+ }
+ });
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ currentSelection = ((IStructuredSelection) event.getSelection()).getFirstElement();
+ }
+ });
+ getShell().setText("Input Datas");
+ return composite;
+ }
+
+ protected List<?> generateInputData() {
+ List<Object> list = new ArrayList<Object>();
+ if (this.graphicsExt != null) {
+ IJavaProject project = SmooksUIUtils.getJavaProject(graphicsExt);
+ try {
+ ProjectClassLoader classLoader = new ProjectClassLoader(project);
+ List<InputType> inputLists = graphicsExt.getInput();
+ for (Iterator<?> iterator = inputLists.iterator(); iterator.hasNext();) {
+ InputType inputType = (InputType) iterator.next();
+ String type = inputType.getType();
+ String path = SmooksModelUtils.getInputPath(inputType);
+ if (type != null && path != null) {
+ path = path.trim();
+ if (SmooksModelUtils.INPUT_TYPE_JAVA.equals(type)) {
+ try {
+ JavaBeanModel model = JavaBeanModelFactory
+ .getJavaBeanModelWithLazyLoad(classLoader.loadClass(path));
+ if (model != null) {
+ list.add(model);
+ }
+ } finally {
+
+ }
+ }
+ if (SmooksModelUtils.INPUT_TYPE_XML.equals(type)) {
+
+ }
+ }
+ }
+ } catch (Exception e) {
+ SmooksConfigurationActivator.getDefault().log(e);
+ }
+ }
+ return list;
+ }
+
+ /**
+ * @return the currentSelection
+ */
+ public Object getCurrentSelection() {
+ return currentSelection;
+ }
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/InputStructuredDataSelectionDialog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreator.java 2009-04-10
16:56:24 UTC (rev 14691)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/PropertyUICreator.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -38,7 +38,7 @@
* org.eclipse.emf.ecore.EAttribute)
*/
public Composite createPropertyUI(FormToolkit toolkit, Composite parent,
- IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature) {
+ IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute
feature,SmooksMultiFormEditor formEditor) {
if(feature == SmooksPackage.eINSTANCE.getAbstractReader_TargetProfile()){
}
@@ -54,9 +54,13 @@
}
public void createExtendUI(AdapterFactoryEditingDomain editingdomain, FormToolkit
toolkit,
- Composite parent, Object model) {
+ Composite parent, Object model,SmooksMultiFormEditor formEditor) {
}
+ public boolean ignoreProperty(EAttribute feature) {
+ return false;
+ }
+
}
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectorAttributes.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectorAttributes.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectorAttributes.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -0,0 +1,35 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.configuration.editors;
+
+
+/**
+ * @author Dart
+ *
+ */
+public class SelectorAttributes {
+ public static final String ONLY_NAME = "only_name";
+
+ public static final String FULL_PATH = "full_path";
+
+ public static final String IGNORE_ROOT = "ignore_root";
+
+ public static final String INCLUDE_PARENT = "include_parent";
+ private String selectorSperator = " ";
+ 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:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SelectorAttributes.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksConfigurationFormPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksConfigurationFormPage.java 2009-04-10
16:56:24 UTC (rev 14691)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksConfigurationFormPage.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -10,17 +10,43 @@
******************************************************************************/
package org.jboss.tools.smooks.configuration.editors;
+import java.io.IOException;
+import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Properties;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
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.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.Composite;
+import org.eclipse.swt.widgets.TableColumn;
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.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.Section;
+import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
+import
org.jboss.tools.smooks.configuration.editors.wizard.IStructuredDataSelectionWizard;
+import
org.jboss.tools.smooks.configuration.editors.wizard.StructuredDataSelectionWizard;
+import org.jboss.tools.smooks.model.graphics.ext.InputType;
+import org.jboss.tools.smooks.model.graphics.ext.ParamType;
+import org.jboss.tools.smooks.model.graphics.ext.SmooksGraphicsExtFactory;
+import org.jboss.tools.smooks.model.graphics.ext.SmooksGraphicsExtType;
+import org.jboss.tools.smooks10.model.smooks.util.SmooksModelUtils;
/**
* @author Dart Peng (dpeng(a)redhat.com) Date Apr 1, 2009
@@ -28,6 +54,7 @@
public class SmooksConfigurationFormPage extends FormPage {
private SmooksMasterDetailBlock masterDetailBlock = null;
+ private TableViewer inputDataViewer;
public SmooksConfigurationFormPage(FormEditor editor, String id, String title) {
super(editor, id, title);
@@ -39,25 +66,182 @@
@Override
protected void createFormContent(IManagedForm managedForm) {
- masterDetailBlock = new SmooksMasterDetailBlock(getEditor(),
- (AdapterFactoryEditingDomain) ((SmooksMultiFormEditor)
getEditor()).getEditingDomain());
final ScrolledForm form = managedForm.getForm();
FormToolkit toolkit = managedForm.getToolkit();
toolkit.decorateFormHeading(form.getForm());
form.setText(getTitle());
- masterDetailBlock.createContent(managedForm);
-
+ // create master details UI
+ createMasterDetailBlock(managedForm);
GridLayout gridLayout = new GridLayout();
gridLayout.marginHeight = 13;
+ // gridLayout.numColumns = 2;
+ // gridLayout.makeColumnsEqualWidth = true;
form.getBody().setLayout(gridLayout);
+ // create extention UI for add/remove extention data
+ createExtentionArea(managedForm);
}
-
- public void setSmooksModel(Object model){
+
+ protected void createMasterDetailBlock(IManagedForm managedForm) {
+ masterDetailBlock = new SmooksMasterDetailBlock(getEditor(),
+ (AdapterFactoryEditingDomain) ((SmooksMultiFormEditor)
getEditor()).getEditingDomain());
+ masterDetailBlock.createContent(managedForm);
+ }
+
+ protected void createExtentionArea(IManagedForm managedForm) {
+ FormToolkit toolkit = managedForm.getToolkit();
+ final ScrolledForm form = managedForm.getForm();
+ Section section = toolkit.createSection(form.getBody(), Section.TITLE_BAR |
Section.TWISTIE);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ section.setLayoutData(gd);
+ section.setText("Input Data");
+ 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);
+ tableComposite.setLayoutData(gd);
+ tableComposite.setBackground(GraphicsConstants.BORDER_CORLOER);
+ tableComposite.setLayout(fillLayout);
+
+ inputDataViewer = new TableViewer(tableComposite, SWT.MULTI);
+ TableColumn header = new TableColumn(inputDataViewer.getTable(), SWT.NONE);
+ header.setText("Type");
+ header.setWidth(100);
+ TableColumn pathColumn = new TableColumn(inputDataViewer.getTable(), SWT.NONE);
+ pathColumn.setText("Path");
+ pathColumn.setWidth(300);
+ inputDataViewer.setContentProvider(new ExtentionInputContentProvider());
+ inputDataViewer.setLabelProvider(new ExtentionInputLabelProvider());
+ inputDataViewer.getTable().setHeaderVisible(true);
+ inputDataViewer.getTable().setLinesVisible(true);
+ SmooksGraphicsExtType extType = getSmooksGraphicsExtType();
+ if (extType != null) {
+ inputDataViewer.setInput(extType);
+ }
+ Composite buttonComposite = toolkit.createComposite(mainComposite, SWT.NONE);
+ gd = new GridData(GridData.FILL_VERTICAL);
+ buttonComposite.setLayoutData(gd);
+ GridLayout l = new GridLayout();
+ buttonComposite.setLayout(l);
+
+ Button addButton = toolkit.createButton(buttonComposite, "Add", SWT.FLAT);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ addButton.setLayoutData(gd);
+ addButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent e) {
+ showInputDataWizard();
+ }
+
+ });
+
+ Button removeButton = toolkit.createButton(buttonComposite, "Delete",
SWT.FLAT);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ removeButton.setLayoutData(gd);
+ removeButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent e) {
+ IStructuredSelection selection = (IStructuredSelection)
inputDataViewer.getSelection();
+ if (selection != null) {
+ SmooksGraphicsExtType extType = getSmooksGraphicsExtType();
+ if (extType != null) {
+ boolean canSave = false;
+ Object[] objs = selection.toArray();
+ for (int i = 0; i < objs.length; i++) {
+ Object obj = objs[i];
+ if (obj instanceof InputType) {
+ extType.getInput().remove(obj);
+ canSave = true;
+ }
+ }
+ if (!canSave)
+ return;
+ try {
+ extType.eResource().save(Collections.emptyMap());
+ inputDataViewer.refresh();
+ } catch (IOException t) {
+ SmooksConfigurationActivator.getDefault().log(t);
+ }
+ }
+ }
+ }
+ });
+ }
+
+ private SmooksGraphicsExtType getSmooksGraphicsExtType() {
+ SmooksGraphicsExtType extType = ((SmooksMultiFormEditor)
getEditor()).getSmooksGraphicsExt();
+ return extType;
+ }
+
+ public void setSmooksModel(Object model) {
masterDetailBlock.setSmooksModel(model);
}
-
- public void setSelectionToViewer(final Collection<?> collection){
- if(masterDetailBlock != null && masterDetailBlock.getSmooksTreeViewer() !=
null){
+
+ protected void showInputDataWizard() {
+ StructuredDataSelectionWizard wizard = new StructuredDataSelectionWizard();
+ wizard.setInput(getEditorInput());
+ wizard.setSite(getEditorSite());
+ wizard.setForcePreviousAndNextButtons(true);
+ StructuredDataSelectionWizardDailog dialog = new
StructuredDataSelectionWizardDailog(getEditorSite()
+ .getShell(), wizard);
+ if (dialog.open() == WizardDialog.OK) {
+ IStructuredDataSelectionWizard wizard1 = dialog.getCurrentCreationWizard();
+ String type = wizard1.getInputDataTypeID();
+ String path = wizard1.getStructuredDataSourcePath();
+ SmooksGraphicsExtType extType = getSmooksGraphicsExtType();
+ if (type != null && path != null && extType != null) {
+ String[] values = path.split(";");
+ for (int i = 0; i < values.length; i++) {
+ String value = values[i];
+ value = value.trim();
+ if (value.length() == 0)
+ continue;
+ InputType input = SmooksGraphicsExtFactory.eINSTANCE.createInputType();
+ input.setType(type);
+ ParamType param = SmooksGraphicsExtFactory.eINSTANCE.createParamType();
+ param.setValue(value);
+ param.setName(SmooksModelUtils.PARAM_NAME_PATH);
+ input.getParam().add(param);
+ List<ParamType> params = generateExtParams(type, path,
wizard1.getProperties());
+ input.getParam().addAll(params);
+ extType.getInput().add(input);
+ }
+ try {
+ extType.eResource().save(Collections.emptyMap());
+ inputDataViewer.refresh();
+ } catch (IOException e) {
+ SmooksConfigurationActivator.getDefault().log(e);
+ }
+ }
+ }
+ }
+
+ private List<ParamType> generateExtParams(String type, String path, Properties
properties) {
+ List<ParamType> lists = new ArrayList<ParamType>();
+ if (properties != null) {
+ Enumeration<?> enumerations = properties.keys();
+ while (enumerations.hasMoreElements()) {
+ Object key = (Object) enumerations.nextElement();
+ ParamType param = SmooksGraphicsExtFactory.eINSTANCE.createParamType();
+ param.setValue(properties.getProperty(key.toString()));
+ param.setName(key.toString());
+ lists.add(param);
+ }
+ }
+ return lists;
+ }
+
+ public void setSelectionToViewer(final Collection<?> collection) {
+ if (masterDetailBlock != null && masterDetailBlock.getSmooksTreeViewer() !=
null) {
// I don't know if this should be run this deferred
// because we might have to give the editor a chance to process the
// viewer update events
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMasterDetailBlock.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMasterDetailBlock.java 2009-04-10
16:56:24 UTC (rev 14691)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMasterDetailBlock.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -94,6 +94,16 @@
createSmooksTreeViewer(tool, managedForm, parent);
}
+
+
+ @Override
+ public void createContent(IManagedForm managedForm) {
+ super.createContent(managedForm);
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalSpan = 2;
+ sashForm.setLayoutData(gd);
+ }
+
/*
* (non-Javadoc)
*
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMultiFormEditor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMultiFormEditor.java 2009-04-10
16:56:24 UTC (rev 14691)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMultiFormEditor.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -24,9 +24,11 @@
import java.util.Timer;
import java.util.TimerTask;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.eclipse.emf.common.command.BasicCommandStack;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CommandStack;
@@ -56,16 +58,18 @@
import org.eclipse.ui.views.properties.PropertySheetPage;
import org.eclipse.wst.sse.ui.StructuredTextEditor;
import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
+import org.jboss.tools.smooks.configuration.SmooksConstants;
+import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
+import org.jboss.tools.smooks.configuration.wizards.SmooksConfigurationFileNewWizard;
import org.jboss.tools.smooks.edit.common.provider.CommonItemProviderAdapterFactory;
import org.jboss.tools.smooks.edit.edi.provider.EdiItemProviderAdapterFactory;
import
org.jboss.tools.smooks.edit.freemarker.provider.FreemarkerItemProviderAdapterFactory;
import org.jboss.tools.smooks.edit.javabean.provider.JavabeanItemProviderAdapterFactory;
import org.jboss.tools.smooks.edit.smooks.provider.SmooksItemProviderAdapterFactory;
import org.jboss.tools.smooks.edit.xsl.provider.XslItemProviderAdapterFactory;
+import org.jboss.tools.smooks.model.graphics.ext.SmooksGraphicsExtType;
import org.jboss.tools.smooks10.model.smooks.util.SmooksResourceFactoryImpl;
-
-
/**
*
* @author Dart Peng (dpeng(a)redhat.com) Date Apr 1, 2009
@@ -84,6 +88,8 @@
private PropertySheetPage propertySheetPage = null;
+ private SmooksGraphicsExtType smooksGraphicsExt = null;
+
private EObject smooksModel;
private boolean handleEMFModelChange;
@@ -149,7 +155,6 @@
return ((BasicCommandStack) editingDomain.getCommandStack()).isSaveNeeded() ||
super.isDirty();
}
-
public EObject getSmooksModel() {
return smooksModel;
}
@@ -181,8 +186,8 @@
List<Object> newList = new ArrayList<Object>();
for (Iterator<?> iterator = theSelection.iterator(); iterator.hasNext();) {
Object object = (Object) iterator.next();
- if(object instanceof IWrapperItemProvider){
- newList.add(((IWrapperItemProvider)object).getValue());
+ if (object instanceof IWrapperItemProvider) {
+ newList.add(((IWrapperItemProvider) object).getValue());
}
}
configurationPage.setSelectionToViewer(newList);
@@ -212,9 +217,18 @@
e.printStackTrace();
}
}
+
+
+ /**
+ * @return the smooksGraphicsExt
+ */
+ public SmooksGraphicsExtType getSmooksGraphicsExt() {
+ return smooksGraphicsExt;
+ }
+
protected StructuredTextEditor createTextEditor() {
- SmooksXMLEditor xmlEditor = new SmooksXMLEditor(){
+ SmooksXMLEditor xmlEditor = new SmooksXMLEditor() {
public void createPartControl(Composite parent) {
super.createPartControl(parent);
@@ -260,7 +274,7 @@
});
}
-
+
};
return xmlEditor;
}
@@ -297,7 +311,7 @@
@Override
public void doSave(IProgressMonitor monitor) {
IEditorPart activeEditor = getActiveEditor();
- if(activeEditor != null && activeEditor == textEditor){
+ if (activeEditor != null && activeEditor == textEditor) {
textEditor.doSave(monitor);
((BasicCommandStack) editingDomain.getCommandStack()).saveIsDone();
firePropertyChange(PROP_DIRTY);
@@ -339,11 +353,27 @@
}
editingDomain.getResourceSet().getResources().add(smooksResource);
super.init(site, input);
- // try {
- // file.move(getNewPath(file), true, true, null);
- // } catch (CoreException e) {
- // e.printStackTrace();
- // }
+ // if success to open editor , check if there isn't ext file and create
+ // a new one
+ String extFileName = file.getName() +
SmooksConstants.SMOOKS_GRAPHICSEXT_EXTENTION_NAME_WITHDOT;
+ IContainer container = file.getParent();
+ if (container != null && container.exists()) {
+ IFile extFile = container.getFile(new Path(extFileName));
+ if (extFile != null && !extFile.exists()) {
+ try {
+ SmooksConfigurationFileNewWizard.createExtentionFile(extFile, null);
+ } catch (Throwable t) {
+ // ignore
+ }
+ }
+ if (extFile != null && extFile.exists()) {
+ try {
+ smooksGraphicsExt = SmooksUIUtils.loadSmooksGraphicsExt(extFile);
+ } catch (IOException e) {
+ SmooksConfigurationActivator.getDefault().log(e);
+ }
+ }
+ }
}
public IPath getNewPath(IFile file) {
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksResourceChangeListener.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksResourceChangeListener.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksResourceChangeListener.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -0,0 +1,171 @@
+/*******************************************************************************
+ * 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 org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectNature;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.resources.WorkspaceJob;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.jboss.tools.smooks.configuration.SmooksConstants;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)
+ * <p>
+ * Apr 12, 2009
+ */
+public class SmooksResourceChangeListener implements IResourceChangeListener {
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org
+ * .eclipse.core.resources.IResourceChangeEvent)
+ */
+ public void resourceChanged(IResourceChangeEvent event) {
+ try {
+ switch (event.getType()) {
+ case IResourceChangeEvent.POST_CHANGE:
+ event.getDelta().accept(new DeltaPrinter());
+ break;
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ private void deleteFile(IPath path) {
+ final IPath path1 = path;
+ WorkspaceJob job = new WorkspaceJob("Delete file") { //$NON-NLS-1$
+
+ public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path1);
+ if (file.exists()) {
+ file.delete(true, monitor);
+ }
+ return Status.OK_STATUS;
+ }
+ };
+ job.schedule();
+ }
+
+ private void newFile(IPath path, IPath newPath) {
+ final IPath path1 = path;
+ final IPath newPath1 = newPath;
+ WorkspaceJob job = new WorkspaceJob("New file and delete old file") {
//$NON-NLS-1$
+ public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
+ IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path1);
+ if (file.exists()) {
+ IFile newFile = ResourcesPlugin.getWorkspace().getRoot().getFile(newPath1);
+ if (newFile.exists()) {
+ if (MessageDialog.openQuestion(new Shell(Display.getDefault()),
+ "Cover File?", "Do you want to cover " //$NON-NLS-1$
//$NON-NLS-2$
+ + newFile.getFullPath())) { //$NON-NLS-1$
+ newFile.setContents(file.getContents(), true, true, monitor);
+ }
+ } else {
+ newFile.create(file.getContents(), true, monitor);
+ }
+ file.delete(true, monitor);
+ }
+ return Status.OK_STATUS;
+ }
+
+ };
+ job.schedule();
+ }
+
+ class DeltaPrinter implements IResourceDeltaVisitor {
+
+ int count = 0;
+
+ public boolean visit(IResourceDelta delta) {
+ IResource res = delta.getResource();
+ String fileExtension = res.getFileExtension();
+ if (!SmooksConstants.SMOOKS_EXTENTION_NAME.equals(fileExtension)) { //$NON-NLS-1$
+ return true;
+ }
+ int flags = delta.getFlags();
+ switch (delta.getKind()) {
+ case IResourceDelta.ADDED:
+ if (flags == IResourceDelta.MOVED_FROM) {
+ IPath path = delta.getMovedFromPath();
+ String fileName = ""; //$NON-NLS-1$
+ if (path != null) {
+ fileName = path.lastSegment();
+ int dotIndex = fileName.lastIndexOf("."); //$NON-NLS-1$
+ if (dotIndex != -1) {
+ fileExtension = fileName.substring(dotIndex + 1, fileName.length());
+ }
+ if (!SmooksConstants.SMOOKS_EXTENTION_NAME.equals(fileExtension)) { //$NON-NLS-1$
+ return true;
+ }
+ fileName += SmooksConstants.SMOOKS_GRAPHICSEXT_EXTENTION_NAME_WITHDOT;
//$NON-NLS-1$
+ path = path.removeLastSegments(1);
+ path = path.append(fileName);
+ }
+
+ IPath newPath = res.getFullPath();
+ fileName = newPath.lastSegment();
+ fileName += SmooksConstants.SMOOKS_GRAPHICSEXT_EXTENTION_NAME_WITHDOT;
//$NON-NLS-1$
+ newPath = newPath.removeLastSegments(1).append(fileName);
+ newFile(path, newPath);
+ }
+ break;
+ case IResourceDelta.REMOVED:
+ if (flags == IResourceDelta.MOVED_TO) {
+ break;
+ }
+ IProject project = res.getProject();
+ try {
+ if (project.isOpen()) {
+ IProjectNature nature = project.getNature(JavaCore.NATURE_ID);
+ if (nature != null) {
+ IJavaProject javaProject = JavaCore.create(project);
+ IPath outPut = javaProject.getOutputLocation();
+ IPath removeRes = res.getFullPath();
+ if (outPut.isPrefixOf(removeRes)) {
+ break;
+ }
+ }
+ }
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ IPath path = res.getFullPath();
+ String fileName = path.lastSegment();
+ fileName += SmooksConstants.SMOOKS_GRAPHICSEXT_EXTENTION_NAME_WITHDOT; //$NON-NLS-1$
+ path = path.removeLastSegments(1).append(fileName);
+ deleteFile(path);
+ break;
+ }
+ return true; // visit the children
+ }
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksResourceChangeListener.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffPropertyDetailPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffPropertyDetailPage.java 2009-04-10
16:56:24 UTC (rev 14691)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksStuffPropertyDetailPage.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -103,19 +103,20 @@
GridLayout layout = new GridLayout();
layout.numColumns = 2;
detailsComposite.setLayout(layout);
- IPropertyUICreator creator = PropertyUICreatorManager.getInstance()
- .getPropertyUICreator(getModel());
- List<IItemPropertyDescriptor> propertyDes = itemPropertySource
- .getPropertyDescriptors(getModel());
- for (Iterator<IItemPropertyDescriptor> iterator = propertyDes.iterator();
iterator
- .hasNext();) {
+ IPropertyUICreator creator =
PropertyUICreatorManager.getInstance().getPropertyUICreator(
+ getModel());
+ List<IItemPropertyDescriptor> propertyDes =
itemPropertySource.getPropertyDescriptors(getModel());
+ for (Iterator<IItemPropertyDescriptor> iterator = propertyDes.iterator();
iterator.hasNext();) {
final IItemPropertyDescriptor itemPropertyDescriptor = (IItemPropertyDescriptor)
iterator
- .next();
+ .next();
EAttribute feature = (EAttribute) itemPropertyDescriptor.getFeature(getModel());
boolean createDefault = true;
if (creator != null) {
+ if(creator.ignoreProperty(feature)){
+ continue;
+ }
Composite composite = creator.createPropertyUI(formToolkit, detailsComposite,
- itemPropertyDescriptor, getModel(), feature);
+ itemPropertyDescriptor, getModel(), feature, getFormEditor());
if (composite != null) {
createDefault = false;
}
@@ -124,27 +125,24 @@
EClassifier typeClazz = feature.getEType();
if (typeClazz instanceof EEnum) {
createEnumFieldEditor(detailsComposite, (EEnum) typeClazz, formToolkit,
- itemPropertyDescriptor);
+ itemPropertyDescriptor);
}
if (typeClazz.getInstanceClass() == String.class) {
- createStringFieldEditor(detailsComposite, formToolkit,
- itemPropertyDescriptor);
+ createStringFieldEditor(detailsComposite, formToolkit, itemPropertyDescriptor);
}
if (typeClazz.getInstanceClass() == Boolean.class
- || typeClazz.getInstanceClass() == boolean.class) {
- createBooleanFieldEditor(detailsComposite, formToolkit,
- itemPropertyDescriptor);
+ || typeClazz.getInstanceClass() == boolean.class) {
+ createBooleanFieldEditor(detailsComposite, formToolkit, itemPropertyDescriptor);
}
if (typeClazz.getInstanceClass() == Integer.class
- || typeClazz.getInstanceClass() == int.class) {
- createIntegerFieldEditor(detailsComposite, formToolkit,
- itemPropertyDescriptor);
+ || typeClazz.getInstanceClass() == int.class) {
+ createIntegerFieldEditor(detailsComposite, formToolkit, itemPropertyDescriptor);
}
}
}
if (creator != null) {
creator.createExtendUI((AdapterFactoryEditingDomain) formEditor.getEditingDomain(),
- formToolkit, detailsComposite, getModel());
+ formToolkit, detailsComposite, getModel(), getFormEditor());
}
formToolkit.paintBordersFor(detailsComposite);
detailsComposite.pack();
@@ -155,7 +153,7 @@
}
protected void createEnumFieldEditor(Composite propertyComposite, final EEnum
typeClass,
- FormToolkit formToolKit, final IItemPropertyDescriptor itemPropertyDescriptor) {
+ FormToolkit formToolKit, final IItemPropertyDescriptor itemPropertyDescriptor) {
String displayName = itemPropertyDescriptor.getDisplayName(getModel());
formToolKit.createLabel(propertyComposite, displayName + " :");
final CCombo combo = new CCombo(propertyComposite, SWT.NONE);
@@ -183,12 +181,11 @@
try {
Object value = itemPropertyDescriptor.getPropertyValue(getModel());
Method method = typeClass.getInstanceClass().getMethod("get",
- new Class<?>[] { String.class });
+ new Class<?>[] { String.class });
// it's static method
Object v = method.invoke(null, combo.getText());
if (value != null && value instanceof PropertyValueWrapper) {
- Object editValue = ((PropertyValueWrapper) value)
- .getEditableValue(getModel());
+ Object editValue = ((PropertyValueWrapper) value).getEditableValue(getModel());
if (editValue != null) {
if (!editValue.equals(v)) {
@@ -209,20 +206,19 @@
combo.setLayoutData(gd);
}
- protected void createBooleanFieldEditor(final Composite propertyComposite,
- FormToolkit formToolkit, final IItemPropertyDescriptor itemPropertyDescriptor) {
+ protected void createBooleanFieldEditor(final Composite propertyComposite, FormToolkit
formToolkit,
+ final IItemPropertyDescriptor itemPropertyDescriptor) {
String displayName = itemPropertyDescriptor.getDisplayName(getModel());
Object value = itemPropertyDescriptor.getPropertyValue(getModel());
- final Button checkButton = formToolkit.createButton(propertyComposite, displayName,
- SWT.CHECK);
+ final Button checkButton = formToolkit.createButton(propertyComposite, displayName,
SWT.CHECK);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
checkButton.setLayoutData(gd);
Object editValue = null;
if (value != null && value instanceof PropertyValueWrapper) {
editValue = ((PropertyValueWrapper) value).getEditableValue(getModel());
- if (editValue != null && editValue instanceof Boolean) checkButton
- .setSelection((Boolean) editValue);
+ if (editValue != null && editValue instanceof Boolean)
+ checkButton.setSelection((Boolean) editValue);
}
checkButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
@@ -231,15 +227,16 @@
});
}
- protected void createStringFieldEditor(final Composite propertyComposite,
- FormToolkit formToolKit, final IItemPropertyDescriptor itemPropertyDescriptor) {
+ protected void createStringFieldEditor(final Composite propertyComposite, FormToolkit
formToolKit,
+ final IItemPropertyDescriptor itemPropertyDescriptor) {
String displayName = itemPropertyDescriptor.getDisplayName(getModel());
formToolKit.createLabel(propertyComposite, displayName + " :");
final Text text = formToolKit.createText(propertyComposite, "", SWT.NONE);
Object value = itemPropertyDescriptor.getPropertyValue(getModel());
if (value != null && value instanceof PropertyValueWrapper) {
Object editValue = ((PropertyValueWrapper) value).getEditableValue(getModel());
- if (editValue != null) text.setText(editValue.toString());
+ if (editValue != null)
+ text.setText(editValue.toString());
}
text.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
@@ -262,16 +259,16 @@
text.setLayoutData(gd);
}
- protected void createIntegerFieldEditor(final Composite propertyComposite,
- FormToolkit formToolKit, final IItemPropertyDescriptor itemPropertyDescriptor) {
+ protected void createIntegerFieldEditor(final Composite propertyComposite, FormToolkit
formToolKit,
+ final IItemPropertyDescriptor itemPropertyDescriptor) {
String displayName = itemPropertyDescriptor.getDisplayName(getModel());
formToolKit.createLabel(propertyComposite, displayName + " :");
final Spinner spinner = new Spinner(propertyComposite, SWT.BORDER);
Object value = itemPropertyDescriptor.getPropertyValue(getModel());
if (value != null && value instanceof PropertyValueWrapper) {
Object editValue = ((PropertyValueWrapper) value).getEditableValue(getModel());
- if (editValue != null && editValue instanceof Integer) spinner
- .setSelection((Integer) editValue);
+ if (editValue != null && editValue instanceof Integer)
+ spinner.setSelection((Integer) editValue);
}
spinner.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
@@ -280,8 +277,7 @@
Object editValue = ((PropertyValueWrapper) value).getEditableValue(getModel());
if (editValue != null) {
if (!editValue.equals(spinner.getSelection())) {
- itemPropertyDescriptor.setPropertyValue(getModel(), spinner
- .getSelection());
+ itemPropertyDescriptor.setPropertyValue(getModel(), spinner.getSelection());
}
} else {
itemPropertyDescriptor.setPropertyValue(getModel(), spinner.getSelection());
@@ -307,9 +303,10 @@
setOldModel(oldModel);
this.selection = selection;
this.formPart = part;
- this.itemPropertySource = (IItemPropertySource)
editingDomain.getAdapterFactory().adapt(
- getModel(), IItemPropertySource.class);
- if (getOldModel() == getModel()) return;
+ this.itemPropertySource = (IItemPropertySource)
editingDomain.getAdapterFactory().adapt(getModel(),
+ IItemPropertySource.class);
+ if (getOldModel() == getModel())
+ return;
if (getOldModel() != getModel()) {
if (propertyComposite != null) {
propertyComposite.dispose();
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksToolsStartup.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksToolsStartup.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksToolsStartup.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * 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 org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.ui.IStartup;
+
+/**
+ * @author Dart (dpeng(a)redhat.com)<p>
+ * Apr 12, 2009
+ */
+public class SmooksToolsStartup implements IStartup {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.IStartup#earlyStartup()
+ */
+ public void earlyStartup() {
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(new
SmooksResourceChangeListener());
+ }
+
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksToolsStartup.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/StructuredDataSelectionWizardDailog.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/StructuredDataSelectionWizardDailog.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/StructuredDataSelectionWizardDailog.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * 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 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 {
+
+ 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;
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/StructuredDataSelectionWizardDailog.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/Template.txt
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/Template.txt 2009-04-10
16:56:24 UTC (rev 14691)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/Template.txt 2009-04-12
10:55:55 UTC (rev 14692)
@@ -18,6 +18,7 @@
import org.jboss.tools.smooks.configuration.editors.PropertyUICreator;
import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
import org.jboss.tools.smooks.model.javabean.BindingsType;
+import org.jboss.tools.smooks.configuration.editors.SmooksMultiFormEditor;
/**
* @author Dart Peng (dpeng(a)redhat.com) Date Apr 10, 2009
@@ -34,7 +35,7 @@
* org.eclipse.emf.ecore.EAttribute)
*/
public Composite createPropertyUI(FormToolkit toolkit, Composite parent,
- IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature) {
+ IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature
,SmooksMultiFormEditor formEditor) {
${attributeMethod}
return null;
}
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/IJavaBeanSelectionListener.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/IJavaBeanSelectionListener.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/IJavaBeanSelectionListener.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -0,0 +1,12 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.configuration.editors.javabean;
+
+/**
+ * @author Dart
+ *
+ */
+public interface IJavaBeanSelectionListener {
+ public void exceptionOccur(Exception e);
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/IJavaBeanSelectionListener.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanConfigWizardPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanConfigWizardPage.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanConfigWizardPage.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * 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.javabean;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * @author Dart Peng
+ *
+ * @CreateTime Jul 21, 2008
+ */
+public class JavaBeanConfigWizardPage extends WizardPage implements
+ SelectionListener ,IJavaBeanSelectionListener {
+
+ TreeViewer treeViewer;
+
+ Text classText = null;
+
+ Button classBrowseButton = null;
+
+ IJavaProject project = null;
+
+ private JavaBeanModelLoadComposite javaPropertySelectComposite;
+
+
+ public List<JavaBeanModel> getJavaBeanModelList() {
+ if(javaPropertySelectComposite == null) return Collections.emptyList();
+ return javaPropertySelectComposite.getJavabeanList();
+ }
+
+ public JavaBeanConfigWizardPage(IJavaProject selection) {
+ super("beansearchwizardpage"); //$NON-NLS-1$
+ this.project = selection;
+ setPageComplete(true);
+ setTitle("Select Javabean"); //$NON-NLS-1$
+ setDescription("Select Javabean model"); //$NON-NLS-1$
+ }
+
+ protected void initilize() {
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.ecSclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt
+ * .widgets.Composite)
+ */
+ public void createControl(Composite parent) {
+ initilize();
+ try {
+ javaPropertySelectComposite = new JavaBeanModelLoadComposite(
+ parent, SWT.NONE, getContainer(), project);
+ javaPropertySelectComposite.addJavaBeanSelectionListener(this);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ this.setControl(javaPropertySelectComposite);
+ this.updatePage();
+ }
+
+ protected void updatePage() {
+ String error = null;
+ if (project == null) {
+ error = "Must select java project"; //$NON-NLS-1$
+ }
+ setPageComplete(error == null);
+ this.setErrorMessage(error);
+ }
+
+// public JavaBeanConfigWizardPage(String pageName, String title,
+// ImageDescriptor titleImage) {
+// super(pageName, title, titleImage);
+// }
+
+ public JavaBeanConfigWizardPage(String pageName) {
+ super(pageName);
+ }
+
+ public void widgetDefaultSelected(SelectionEvent arg0) {
+ widgetSelected(arg0);
+ }
+
+ public void widgetSelected(SelectionEvent arg0) {
+
+ }
+
+ public void exceptionOccur(Exception e) {
+ String error = null;
+ if(e != null) error = e.toString();
+ this.setErrorMessage(error);
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanConfigWizardPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanList.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanList.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanList.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -0,0 +1,117 @@
+/**
+ *
+ */
+package org.jboss.tools.smooks.configuration.editors.javabean;
+
+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:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanList.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModel.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModel.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModel.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -0,0 +1,549 @@
+/*******************************************************************************
+ * 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.javabean;
+
+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.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+
+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 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$
+ }
+
+ return clazz.getName();
+ }
+
+ public String getBeanClassStringWithList() {
+ String s = getBeanClassString();
+ if (this.isList()) {
+ Class genericType = getGenericType();
+ if (genericType != null)
+ s += "<" + genericType.getName() + ">";
+ }
+ 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];
+ Class beanType = (Class) gtype;
+ componentClass = beanType;
+ 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 = 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);
+ }
+
+ 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;
+
+ public List getProperties() {
+ 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);
+ 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() {
+ 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:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModel.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModelFactory.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModelFactory.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModelFactory.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * 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.javabean;
+
+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;
+ }
+
+ public synchronized static JavaBeanModel getJavaBeanModel(Class<?> beanClass ) {
+ JavaBeanModel m = new JavaBeanModel(beanClass,false);
+ m.setRootClassModel(true);
+ return m;
+ }
+
+ public static boolean isPrimitiveObject(Class<?> clazz) {
+ return (PRIMITIVE_CLASSES.indexOf(clazz) != -1);
+ }
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModelFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModelLoadComposite.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModelLoadComposite.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModelLoadComposite.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -0,0 +1,431 @@
+/*******************************************************************************
+ * 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.javabean;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IType;
+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.operation.IRunnableContext;
+import org.eclipse.jface.viewers.ICellModifier;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerCell;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+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.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.dialogs.SelectionDialog;
+import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
+import org.jboss.tools.smooks.configuration.editors.GraphicsConstants;
+import org.jboss.tools.smooks.configuration.editors.uitls.ProjectClassLoader;
+
+/**
+ * @author Dart Peng
+ *
+ * @CreateTime Jul 22, 2008
+ */
+public class JavaBeanModelLoadComposite extends Composite implements SelectionListener {
+
+ private List<JavaBeanModel> javabeanList = new ArrayList<JavaBeanModel>();
+ protected Text classText;
+// private Button classBrowseButton;
+ protected String classFullName;
+ protected boolean loadAtomic;
+ protected IJavaProject javaProject;
+ protected IRunnableContext runnableContext;
+ protected JavaBeanModel currentRootJavaBeanModel = null;
+ protected JavaBeanModel returnJavaBeanModel = null;
+
+ private List<IJavaBeanSelectionListener> selectionListenerList = new
ArrayList<IJavaBeanSelectionListener>();
+
+ protected ProjectClassLoader loader = null;
+ private TableViewer listViewer;
+
+ public JavaBeanModelLoadComposite(Composite parent, int style, IRunnableContext
runnableContext,
+ IJavaProject project, boolean loadJavapropertiesAtomic) throws Exception {
+ super(parent, style);
+ loadAtomic = loadJavapropertiesAtomic;
+ this.runnableContext = runnableContext;
+ if (this.runnableContext == null) {
+ this.runnableContext = SmooksConfigurationActivator.getDefault().getWorkbench()
+ .getActiveWorkbenchWindow();
+ // this.runnableContext = new
+ // ProgressMonitorDialog(parent.getShell());
+ if (this.runnableContext == null)
+ throw new Exception("Init error"); //$NON-NLS-1$
+ }
+
+ if (project != null) {
+ javaProject = project;
+ loader = new ProjectClassLoader(javaProject);
+ }
+
+ createCompositeContent();
+ }
+
+ public JavaBeanModelLoadComposite(Composite parent, int style, IRunnableContext
runnableContext,
+ IJavaProject project) throws Exception {
+ this(parent, style, runnableContext, project, true);
+ }
+
+ public List<JavaBeanModel> getJavabeanList() {
+ return javabeanList;
+ }
+
+ public void addJavaBeanSelectionListener(IJavaBeanSelectionListener listener) {
+ this.selectionListenerList.add(listener);
+ }
+
+ public void removeJavaBeanSelectionListener(IJavaBeanSelectionListener listener) {
+ this.selectionListenerList.remove(listener);
+ }
+
+ public void setJavabeanList(List<JavaBeanModel> javabeanList) {
+ this.javabeanList = javabeanList;
+ }
+
+ protected Control createCompositeContent() {
+ Composite parent = this;
+ parent.setLayout(new FillLayout());
+ Composite com = new Composite(parent, SWT.NULL);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ com.setLayout(layout);
+
+ Label classLabel = new Label(com, SWT.NULL);
+ classLabel.setText("Class : "); //$NON-NLS-1$
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ classLabel.setLayoutData(gd);
+
+ Composite listViewerComposite = new Composite(com, SWT.NONE);
+ GridLayout listLayout = new GridLayout();
+ listLayout.numColumns = 2;
+ listViewerComposite.setLayout(listLayout);
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalSpan = 2;
+ listViewerComposite.setLayoutData(gd);
+
+ listViewer = new TableViewer(listViewerComposite, SWT.BORDER);
+ TableColumn nameColumn = new TableColumn(listViewer.getTable(), SWT.NONE);
+ nameColumn.setText("Class");
+ TableColumn isArrayColumn = new TableColumn(listViewer.getTable(), SWT.NONE);
+ isArrayColumn.setText("Array");
+ TableColumn isListColumn = new TableColumn(listViewer.getTable(), SWT.NONE);
+ isListColumn.setText("List");
+
+ nameColumn.setWidth(400);
+ isArrayColumn.setWidth(60);
+ isListColumn.setWidth(60);
+
+ listViewer.getTable().setHeaderVisible(true);
+
+ gd = new GridData(GridData.FILL_BOTH);
+ listViewer.getTable().addMouseListener(new ColumnSelectionListener());
+ listViewer.getControl().setLayoutData(gd);
+ listViewer.setContentProvider(new IStructuredContentProvider() {
+
+ public Object[] getElements(Object inputElement) {
+ if (inputElement instanceof List) {
+ return ((List<?>) inputElement).toArray();
+ }
+ return new Object[] {};
+ }
+
+ public void dispose() {
+
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+
+ }
+
+ });
+ listViewer.setLabelProvider(new BeanViewerLabelProvider());
+ listViewer.setInput(javabeanList);
+
+ Composite buttonArea = new Composite(listViewerComposite, SWT.NONE);
+ gd = new GridData(GridData.FILL_VERTICAL);
+ buttonArea.setLayoutData(gd);
+
+ GridLayout buttonAreaLayout = new GridLayout();
+ buttonArea.setLayout(buttonAreaLayout);
+
+ Button addButton = new Button(buttonArea, SWT.NONE);
+ addButton.setText("Add");
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ addButton.setLayoutData(gd);
+ addButton.addSelectionListener(this);
+
+ Button removeButton = new Button(buttonArea, SWT.NONE);
+ removeButton.setText("Remove");
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ removeButton.setLayoutData(gd);
+ removeButton.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ IStructuredSelection selection = (IStructuredSelection) listViewer.getSelection();
+ if (selection.isEmpty())
+ return;
+ javabeanList.removeAll(selection.toList());
+ listViewer.refresh();
+ }
+
+ });
+ return com;
+ }
+
+ public ProjectClassLoader getProjectClassLoader() {
+ if (loader == null) {
+ try {
+ loader = new ProjectClassLoader(javaProject);
+ } catch (Exception e) {
+ }
+ }
+ return loader;
+ }
+
+ public void widgetDefaultSelected(SelectionEvent arg0) {
+ this.widgetSelected(arg0);
+
+ }
+
+ public void widgetSelected(SelectionEvent arg0) {
+
+ IJavaSearchScope scope = 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;
+ Throwable exception = null;
+ try {
+ dialog = JavaUI.createTypeDialog(this.getShell(), runnableContext, scope,
+ IJavaElementSearchConstants.CONSIDER_CLASSES_AND_INTERFACES, false);
+ dialog.setMessage("Search Java Class"); //$NON-NLS-1$
+ dialog.setTitle("Search"); //$NON-NLS-1$
+
+ if (dialog.open() == Window.OK) {
+ Object[] results = dialog.getResult();
+ if (results.length > 0) {
+ Object result = results[0];
+ String packageFullName = JavaModelUtil.getTypeContainerName((IType) result);
+ String className = null;
+ if (packageFullName == null || packageFullName.length() <= 0) {
+ className = ((IType) result).getElementName();
+ } else {
+ className = packageFullName + "." //$NON-NLS-1$
+ + ((IType) result).getElementName();
+ }
+ if (className != null) {
+ ClassLoader l = this.getProjectClassLoader();
+ if (l != null) {
+ Class clazz = l.loadClass(className);
+ if (clazz != null) {
+ JavaBeanModel model = JavaBeanModelFactory
+ .getJavaBeanModelWithLazyLoad(clazz);
+ javabeanList.add(model);
+ listViewer.refresh();
+ }
+ }
+
+ }
+ }
+ }
+ } catch (Throwable e) {
+ exception = e;
+ }
+
+ for (Iterator<IJavaBeanSelectionListener> iterator =
this.selectionListenerList.iterator(); iterator
+ .hasNext();) {
+ IJavaBeanSelectionListener l = (IJavaBeanSelectionListener) iterator.next();
+ if (exception != null) {
+ l.exceptionOccur(new Exception(exception));
+ } else {
+ l.exceptionOccur(null);
+ }
+ }
+
+ }
+
+ private class BeanViewerCellModifyer implements ICellModifier {
+
+ public boolean canModify(Object element, String property) {
+ if (property.equals("name"))
+ return false;
+ return true;
+ }
+
+ public Object getValue(Object element, String property) {
+ if (element instanceof JavaBeanModel) {
+ if (property.equals("array")) {
+ return ((JavaBeanModel) element).isArray();
+ }
+ if (property.equals("list")) {
+ return ((JavaBeanModel) element).isList();
+ }
+ }
+ return Boolean.TRUE;
+ }
+
+ public void modify(Object element, String property, Object value) {
+
+ }
+
+ }
+
+ private class BeanViewerLabelProvider extends LabelProvider implements
ITableLabelProvider {
+
+ public Image getColumnImage(Object element, int columnIndex) {
+
+ if (element instanceof JavaBeanModel) {
+ boolean isArray = "array".equals(((JavaBeanModel)
element).getExtendProperty("many"));
+ boolean isList = "list".equals(((JavaBeanModel)
element).getExtendProperty("many"));
+ switch (columnIndex) {
+ case 0:
+ if (isArray) {
+ return SmooksConfigurationActivator.getDefault().getImageRegistry().get(
+ GraphicsConstants.IMAGE_JAVA_ARRAY);
+ }
+ if (isList) {
+ return SmooksConfigurationActivator.getDefault().getImageRegistry().get(
+ GraphicsConstants.IMAGE_JAVA_COLLECTION);
+ }
+ return SmooksConfigurationActivator.getDefault().getImageRegistry().get(
+ GraphicsConstants.IMAGE_JAVA_OBJECT);
+ case 1:
+ if (isArray) {
+ return SmooksConfigurationActivator.getDefault().getImageRegistry().get(
+ GraphicsConstants.IMAGE_CHECKBOX_CHECK);
+ } else {
+ return SmooksConfigurationActivator.getDefault().getImageRegistry().get(
+ GraphicsConstants.IMAGE_CHECKBOX_UNCHECK);
+ }
+ case 2:
+ if (isList) {
+ return SmooksConfigurationActivator.getDefault().getImageRegistry().get(
+ GraphicsConstants.IMAGE_CHECKBOX_CHECK);
+ } else {
+ return SmooksConfigurationActivator.getDefault().getImageRegistry().get(
+ GraphicsConstants.IMAGE_CHECKBOX_UNCHECK);
+ }
+ }
+ }
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ if (element instanceof JavaBeanModel) {
+ switch (columnIndex) {
+ case 0:
+ return ((JavaBeanModel) element).getBeanClassString();
+ case 1:
+ return null;
+ case 2:
+ return null;
+ }
+ }
+ return null;
+ }
+
+ }
+
+ public class ColumnSelectionListener implements MouseListener {
+
+ public void widgetSelected(SelectionEvent e) {
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+
+ }
+
+ public void mouseDoubleClick(MouseEvent e) {
+
+ }
+
+ public void mouseDown(MouseEvent e) {
+ if (!(e.button == 1))
+ return;
+ ViewerCell cell = listViewer.getCell(new Point(e.x, e.y));
+ if (cell != null) {
+ Object element = cell.getElement();
+ if (element instanceof JavaBeanModel) {
+ if (cell.getColumnIndex() == 1) {
+ String many = ((JavaBeanModel) element).getExtendProperty("many");
+ if ("array".equals(many)) {
+ ((JavaBeanModel) element).addExtendProperty("many", "");
+ } else {
+ ((JavaBeanModel) element).addExtendProperty("many", "array");
+ }
+ }
+ if (cell.getColumnIndex() == 2) {
+ String many = ((JavaBeanModel) element).getExtendProperty("many");
+ if ("list".equals(many)) {
+ ((JavaBeanModel) element).addExtendProperty("many", "");
+ } else {
+ ((JavaBeanModel) element).addExtendProperty("many", "list");
+ }
+ }
+ try {
+ listViewer.refresh(element);
+ } catch (Exception e1) {
+ }
+ }
+ }
+ }
+
+ public void mouseUp(MouseEvent e) {
+
+ }
+ }
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavaBeanModelLoadComposite.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanContentProvider.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanContentProvider.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanContentProvider.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -0,0 +1,51 @@
+package org.jboss.tools.smooks.configuration.editors.javabean;
+
+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();
+ }
+ return new Object[]{};
+ }
+
+ public void dispose() {
+
+ }
+
+ public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
+
+ }
+
+}
\ No newline at end of file
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanContentProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanStrucutredDataWizard.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanStrucutredDataWizard.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanStrucutredDataWizard.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -0,0 +1,177 @@
+/*******************************************************************************
+ * 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.javabean;
+
+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.jdt.internal.core.JavaProject;
+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.editors.wizard.IStructuredDataSelectionWizard;
+import org.jboss.tools.smooks10.model.smooks.util.SmooksModelUtils;
+
+/**
+ * @author Dart Peng
+ * @Date Aug 5, 2008
+ */
+public class JavabeanStrucutredDataWizard extends Wizard implements
+ IStructuredDataSelectionWizard, INewWizard {
+ JavaBeanConfigWizardPage page = null;
+ IJavaProject project = null;
+ 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 JavaBeanConfigWizardPage(project);
+ 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
+ .getExtendProperty("many"));
+ boolean isList = "list".equals(javabean
+ .getExtendProperty("many"));
+ 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 JavaProject) {
+ this.project = (JavaProject) 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(";")) {
+ JavaBeanModel javaBeanModel = (JavaBeanModel) iterator.next();
+ Class<?> clazz = javaBeanModel.getBeanClass();
+ if (clazz != null) {
+ buffer.append(clazz.getName());
+ }
+ }
+ return buffer.toString();
+ }
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanStrucutredDataWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanWiringUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanWiringUICreator.java 2009-04-10
16:56:24 UTC (rev 14691)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanWiringUICreator.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -24,6 +24,7 @@
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.jboss.tools.smooks.configuration.editors.SmooksMultiFormEditor;
import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
import org.jboss.tools.smooks.model.javabean.BindingsType;
import org.jboss.tools.smooks.model.javabean.JavabeanPackage;
@@ -42,29 +43,26 @@
}
return false;
}
-
-
@Override
protected boolean canCreateMethodsSearchFieldEditor(EAttribute feature) {
- if(feature == JavabeanPackage.eINSTANCE.getWiringType_SetterMethod()){
+ if (feature == JavabeanPackage.eINSTANCE.getWiringType_SetterMethod()) {
return true;
}
return super.canCreateMethodsSearchFieldEditor(feature);
}
-
-
@Override
public Composite createPropertyUI(FormToolkit toolkit, Composite parent,
- IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature) {
+ IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature,
+ SmooksMultiFormEditor formEditor) {
if (feature == JavabeanPackage.eINSTANCE.getWiringType_BeanIdRef()) {
- if(model instanceof EObject){
- SmooksResourceListType smooksResourceList = getSmooksResourceList((EObject)model);
- if(smooksResourceList != null){
+ if (model instanceof EObject) {
+ SmooksResourceListType smooksResourceList = getSmooksResourceList((EObject) model);
+ if (smooksResourceList != null) {
String displayName = propertyDescriptor.getDisplayName(model);
toolkit.createLabel(parent, displayName + " :");
- final CCombo combo = new CCombo(parent,SWT.BORDER);
+ final CCombo combo = new CCombo(parent, SWT.BORDER);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
combo.setLayoutData(gd);
Object editValue = SmooksUIUtils.getEditValue(propertyDescriptor, model);
@@ -77,15 +75,15 @@
combo.add(beanId);
}
int selectIndex = list.indexOf(editValue);
- if(selectIndex != -1){
+ if (selectIndex != -1) {
combo.select(selectIndex);
}
final IItemPropertyDescriptor ip = propertyDescriptor;
final Object cmodel = model;
- combo.addModifyListener(new ModifyListener(){
+ combo.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
Object editValue = SmooksUIUtils.getEditValue(ip, cmodel);
- if(combo.getText().equals(editValue)){
+ if (combo.getText().equals(editValue)) {
return;
}
ip.setPropertyValue(cmodel, combo.getText());
@@ -95,18 +93,18 @@
}
}
}
- return super.createPropertyUI(toolkit, parent, propertyDescriptor, model, feature);
+ return super.createPropertyUI(toolkit, parent, propertyDescriptor, model,
feature,formEditor);
}
-
- protected List<String> getBeanIdList(SmooksResourceListType resourceList){
+
+ protected List<String> getBeanIdList(SmooksResourceListType resourceList) {
List<AbstractResourceConfig> rlist = resourceList.getAbstractResourceConfig();
List<String> beanIdList = new ArrayList<String>();
for (Iterator<?> iterator = rlist.iterator(); iterator.hasNext();) {
- AbstractResourceConfig abstractResourceConfig = (AbstractResourceConfig) iterator
- .next();
- if(abstractResourceConfig instanceof BindingsType){
- String beanId = ((BindingsType)abstractResourceConfig).getBeanId();
- if(beanId == null) continue;
+ AbstractResourceConfig abstractResourceConfig = (AbstractResourceConfig)
iterator.next();
+ if (abstractResourceConfig instanceof BindingsType) {
+ String beanId = ((BindingsType) abstractResourceConfig).getBeanId();
+ if (beanId == null)
+ continue;
beanIdList.add(beanId);
}
}
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanlabelProvider.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanlabelProvider.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanlabelProvider.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -0,0 +1,84 @@
+package org.jboss.tools.smooks.configuration.editors.javabean;
+
+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>";
+
+ Object error = ((JavaBeanModel) element).getError();
+ if (error != null) {
+ name = name + " " + "<" + error.toString() +
">";
+ return name;
+ }
+
+ Class<?> typeRef = ((JavaBeanModel) element).getBeanClass();
+ String typeStr = "";
+ if (typeRef != null) {
+ if (typeRef.isArray()) {
+ typeRef = typeRef.getComponentType();
+ typeStr = typeRef.getName() + "[]";
+ } else {
+ typeStr = typeRef.getName();
+ }
+ }
+ if (!typeStr.equals("")) {
+ name = name + " " + typeStr;
+ }
+
+ return name;
+ }
+ return super.getText(element);
+ }
+
+ @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:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/JavabeanlabelProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/PropertiesAndSetterMethodSearchFieldEditorCreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/PropertiesAndSetterMethodSearchFieldEditorCreator.java 2009-04-10
16:56:24 UTC (rev 14691)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/javabean/PropertiesAndSetterMethodSearchFieldEditorCreator.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -16,6 +16,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.jboss.tools.smooks.configuration.editors.PropertyUICreator;
+import org.jboss.tools.smooks.configuration.editors.SmooksMultiFormEditor;
import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
import org.jboss.tools.smooks.model.javabean.BindingsType;
@@ -26,7 +27,7 @@
@Override
public Composite createPropertyUI(FormToolkit toolkit, Composite parent,
- IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature) {
+ IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute
feature,SmooksMultiFormEditor formEditor) {
if(canCreatePropertiesSearchFieldEditor(feature)){
return createPropertiesSearchFieldEditor(toolkit, parent, propertyDescriptor, model);
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ConditionTypeUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ConditionTypeUICreator.java 2009-04-10
16:56:24 UTC (rev 14691)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ConditionTypeUICreator.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -16,6 +16,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.jboss.tools.smooks.configuration.editors.PropertyUICreator;
+import org.jboss.tools.smooks.configuration.editors.SmooksMultiFormEditor;
import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
import org.jboss.tools.smooks.model.smooks.SmooksPackage;
@@ -34,7 +35,7 @@
* org.eclipse.emf.ecore.EAttribute)
*/
public Composite createPropertyUI(FormToolkit toolkit, Composite parent,
- IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature) {
+ IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute
feature,SmooksMultiFormEditor formEditor) {
if (feature == SmooksPackage.eINSTANCE.getConditionType_Value()) {
}
if (feature == SmooksPackage.eINSTANCE.getConditionType_Evaluator()) {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ImportTypeUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ImportTypeUICreator.java 2009-04-10
16:56:24 UTC (rev 14691)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ImportTypeUICreator.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -15,6 +15,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.jboss.tools.smooks.configuration.editors.PropertyUICreator;
+import org.jboss.tools.smooks.configuration.editors.SmooksMultiFormEditor;
import org.jboss.tools.smooks.model.smooks.SmooksPackage;
/**
@@ -32,7 +33,7 @@
* org.eclipse.emf.ecore.EAttribute)
*/
public Composite createPropertyUI(FormToolkit toolkit, Composite parent,
- IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature) {
+ IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute
feature,SmooksMultiFormEditor formEditor) {
if (feature == SmooksPackage.eINSTANCE.getImportType_File()) {
}
return null;
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ParamTypeUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ParamTypeUICreator.java 2009-04-10
16:56:24 UTC (rev 14691)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ParamTypeUICreator.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -16,6 +16,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.jboss.tools.smooks.configuration.editors.PropertyUICreator;
+import org.jboss.tools.smooks.configuration.editors.SmooksMultiFormEditor;
import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
import org.jboss.tools.smooks.model.smooks.SmooksPackage;
@@ -34,7 +35,7 @@
* org.eclipse.emf.ecore.EAttribute)
*/
public Composite createPropertyUI(FormToolkit toolkit, Composite parent,
- IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature) {
+ IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute
feature,SmooksMultiFormEditor formEditor) {
if (feature == SmooksPackage.eINSTANCE.getParamType_Name()) {
}
if (feature == SmooksPackage.eINSTANCE.getParamType_Type()) {
@@ -44,7 +45,7 @@
@Override
public void createExtendUI(AdapterFactoryEditingDomain editingdomain, FormToolkit
toolkit,
- Composite parent, Object model) {
+ Composite parent, Object model, SmooksMultiFormEditor formEditor) {
SmooksUIUtils.createTextFieldEditor("Value", editingdomain, toolkit, parent,
model);
SmooksUIUtils.createCDATAFieldEditor("CDATA", editingdomain, toolkit, parent,
model);
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ResourceConfigTypeUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ResourceConfigTypeUICreator.java 2009-04-10
16:56:24 UTC (rev 14691)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ResourceConfigTypeUICreator.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -15,6 +15,9 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.jboss.tools.smooks.configuration.editors.PropertyUICreator;
+import org.jboss.tools.smooks.configuration.editors.SmooksMultiFormEditor;
+import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
+import org.jboss.tools.smooks.model.graphics.ext.SmooksGraphicsExtType;
import org.jboss.tools.smooks.model.smooks.SmooksPackage;
/**
@@ -32,15 +35,19 @@
* org.eclipse.emf.ecore.EAttribute)
*/
public Composite createPropertyUI(FormToolkit toolkit, Composite parent,
- IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature) {
-
+ IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature,
+ SmooksMultiFormEditor formEditor) {
if (feature == SmooksPackage.eINSTANCE.getResourceConfigType_Selector()) {
+ SmooksGraphicsExtType ext = formEditor.getSmooksGraphicsExt();
+ if (ext != null) {
+ return SmooksUIUtils.createSelectorFieldEditor(toolkit, parent, propertyDescriptor,
model,
+ ext);
+ }
}
if (feature == SmooksPackage.eINSTANCE.getResourceConfigType_SelectorNamespace()) {
}
if (feature == SmooksPackage.eINSTANCE.getResourceConfigType_TargetProfile()) {
}
-
return null;
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ResourceTypeUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ResourceTypeUICreator.java 2009-04-10
16:56:24 UTC (rev 14691)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/smooks/ResourceTypeUICreator.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -16,6 +16,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.jboss.tools.smooks.configuration.editors.PropertyUICreator;
+import org.jboss.tools.smooks.configuration.editors.SmooksMultiFormEditor;
import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
import org.jboss.tools.smooks.model.smooks.SmooksPackage;
@@ -34,14 +35,13 @@
* org.eclipse.emf.ecore.EAttribute)
*/
public Composite createPropertyUI(FormToolkit toolkit, Composite parent,
- IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature) {
+ IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute
feature,SmooksMultiFormEditor formEditor) {
if (feature == SmooksPackage.eINSTANCE.getResourceType_Value()) {
return SmooksUIUtils.createJavaTypeSearchFieldEditor(parent, toolkit,
propertyDescriptor, (EObject) model);
}
if (feature == SmooksPackage.eINSTANCE.getResourceType_Type()) {
}
-
return null;
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-04-10
16:56:24 UTC (rev 14691)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -10,6 +10,12 @@
******************************************************************************/
package org.jboss.tools.smooks.configuration.editors.uitls;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -27,6 +33,7 @@
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
@@ -36,6 +43,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.forms.events.HyperlinkEvent;
@@ -43,8 +51,14 @@
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Hyperlink;
import org.jboss.tools.smooks.configuration.SmooksConfigurationActivator;
+import org.jboss.tools.smooks.configuration.editors.IXMLStructuredObject;
+import org.jboss.tools.smooks.configuration.editors.InputStructuredDataSelectionDialog;
+import org.jboss.tools.smooks.configuration.editors.SelectorAttributes;
import org.jboss.tools.smooks.configuration.editors.javabean.JavaMethodsSelectionDialog;
import
org.jboss.tools.smooks.configuration.editors.javabean.JavaPropertiesSelectionDialog;
+import org.jboss.tools.smooks.model.graphics.ext.DocumentRoot;
+import org.jboss.tools.smooks.model.graphics.ext.SmooksGraphicsExtType;
+import
org.jboss.tools.smooks.model.graphics.ext.util.SmooksGraphicsExtResourceFactoryImpl;
import org.jboss.tools.smooks.model.javabean.BindingsType;
import org.jboss.tools.smooks10.model.smooks.util.SmooksModelUtils;
@@ -54,9 +68,8 @@
*/
public class SmooksUIUtils {
- public static void createTextFieldEditor(String label,
- AdapterFactoryEditingDomain editingdomain, FormToolkit toolkit, Composite parent,
- Object model) {
+ public static void createTextFieldEditor(String label, AdapterFactoryEditingDomain
editingdomain,
+ FormToolkit toolkit, Composite parent, Object model) {
toolkit.createLabel(parent, "Value :");
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
final Text valueText = toolkit.createText(parent, "", SWT.FLAT);
@@ -77,15 +90,48 @@
}
String text = SmooksModelUtils.getAnyTypeText((AnyType) fm);
if (!valueText.getText().equals(text)) {
- SmooksModelUtils.setTextToSmooksType(fEditingDomain,(AnyType) fm,
valueText.getText());
+ SmooksModelUtils.setTextToSmooksType(fEditingDomain, (AnyType) fm,
valueText.getText());
}
}
});
}
- public static void createCDATAFieldEditor(String label,
- AdapterFactoryEditingDomain editingdomain, FormToolkit toolkit, Composite parent,
- Object model) {
+ public static Composite createSelectorFieldEditor(FormToolkit toolkit, Composite
parent,
+ final IItemPropertyDescriptor propertyDescriptor, Object model,
+ final SmooksGraphicsExtType extType) {
+ return createDialogFieldEditor(parent, toolkit, propertyDescriptor, "Browse",
new IFieldDialog() {
+ public Object open(Shell shell) {
+ InputStructuredDataSelectionDialog dialog = new
InputStructuredDataSelectionDialog(shell,
+ extType);
+ if (dialog.open() == Dialog.OK) {
+ Object currentSelection = dialog.getCurrentSelection();
+ if (currentSelection instanceof IXMLStructuredObject) {
+ String s = SmooksUIUtils.generateFullPath((IXMLStructuredObject) currentSelection,
+ "/");
+ return s;
+ }
+ }
+ return null;
+ }
+
+ }, (EObject) model);
+ }
+
+ public static SmooksGraphicsExtType loadSmooksGraphicsExt(IFile file) throws IOException
{
+ Resource resource = new SmooksGraphicsExtResourceFactoryImpl().createResource(URI
+ .createPlatformResourceURI(file.getFullPath().toPortableString(), false));
+ resource.load(Collections.emptyMap());
+ if (resource.getContents().size() > 0) {
+ Object obj = resource.getContents().get(0);
+ if (obj instanceof DocumentRoot) {
+ return ((DocumentRoot) obj).getSmooksGraphicsExt();
+ }
+ }
+ return null;
+ }
+
+ public static void createCDATAFieldEditor(String label, AdapterFactoryEditingDomain
editingdomain,
+ FormToolkit toolkit, Composite parent, Object model) {
Label label1 = toolkit.createLabel(parent, label + " :");
GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
label1.setLayoutData(gd);
@@ -110,27 +156,26 @@
}
String text = SmooksModelUtils.getAnyTypeCDATA((AnyType) fm);
if (!cdataText.getText().equals(text)) {
- SmooksModelUtils.setCDATAToSmooksType(fEditingDomain,(AnyType) fm,
cdataText.getText());
+ SmooksModelUtils.setCDATAToSmooksType(fEditingDomain, (AnyType) fm,
cdataText.getText());
}
}
});
}
- public static void createCommentFieldEditor(String label, FormToolkit toolkit,
- Composite parent, Object model) {
+ public static void createCommentFieldEditor(String label, FormToolkit toolkit, Composite
parent,
+ Object model) {
}
public static Composite createJavaTypeSearchFieldEditor(Composite parent, FormToolkit
toolkit,
- final IItemPropertyDescriptor propertyDescriptor, final EObject model) {
+ final IItemPropertyDescriptor propertyDescriptor, final EObject model) {
if (model instanceof EObject) {
final Resource resource = ((EObject) model).eResource();
URI uri = resource.getURI();
IResource workspaceResource = null;
if (uri.isPlatformResource()) {
String path = uri.toPlatformString(true);
- workspaceResource = ResourcesPlugin.getWorkspace().getRoot().findMember(
- new Path(path));
+ workspaceResource = ResourcesPlugin.getWorkspace().getRoot().findMember(new
Path(path));
JavaTypeFieldDialog dialog = new JavaTypeFieldDialog(workspaceResource);
String displayName = propertyDescriptor.getDisplayName(model);
Hyperlink link = toolkit.createHyperlink(parent, displayName + " :",
SWT.NONE);
@@ -141,8 +186,8 @@
fillLayout.marginHeight = 0;
fillLayout.marginWidth = 0;
classTextComposite.setLayout(fillLayout);
- final SearchComposite searchComposite = new SearchComposite(classTextComposite,
- toolkit, "Search Class", dialog, SWT.NONE);
+ final SearchComposite searchComposite = new SearchComposite(classTextComposite,
toolkit,
+ "Search Class", dialog, SWT.NONE);
Object editValue = getEditValue(propertyDescriptor, model);
if (editValue != null) {
searchComposite.getText().setText(editValue.toString());
@@ -151,20 +196,18 @@
public void modifyText(ModifyEvent e) {
Object value = propertyDescriptor.getPropertyValue(model);
if (value != null && value instanceof PropertyValueWrapper) {
- Object editValue = ((PropertyValueWrapper) value)
- .getEditableValue(model);
+ Object editValue = ((PropertyValueWrapper) value).getEditableValue(model);
if (editValue != null) {
if (!editValue.equals(searchComposite.getText().getText())) {
- propertyDescriptor.setPropertyValue(model, searchComposite
- .getText().getText());
+ propertyDescriptor.setPropertyValue(model, searchComposite.getText()
+ .getText());
}
} else {
- propertyDescriptor.setPropertyValue(model, searchComposite
- .getText().getText());
+ propertyDescriptor.setPropertyValue(model, searchComposite.getText()
+ .getText());
}
} else {
- propertyDescriptor.setPropertyValue(model, searchComposite.getText()
- .getText());
+ propertyDescriptor.setPropertyValue(model, searchComposite.getText().getText());
}
}
});
@@ -173,17 +216,18 @@
public void linkActivated(HyperlinkEvent e) {
try {
- if (fresource == null) return;
+ if (fresource == null)
+ return;
if (fresource.getProject().hasNature(JavaCore.NATURE_ID)) {
IJavaProject javaProject = JavaCore.create(fresource.getProject());
String typeName = searchComposite.getText().getText();
IJavaElement result = javaProject.findType(typeName);
- if (result != null) JavaUI.openInEditor(result);
+ if (result != null)
+ JavaUI.openInEditor(result);
else {
MessageDialog.openInformation(classTextComposite.getShell(),
- "Can't find type", "Can't find type \"" +
typeName
- + "\" in \"" + javaProject.getProject().getName()
- + "\" project.");
+ "Can't find type", "Can't find type \"" +
typeName + "\" in \""
+ + javaProject.getProject().getName() + "\" project.");
}
}
} catch (PartInitException ex) {
@@ -232,9 +276,9 @@
return null;
}
- public static Composite createJavaMethodSearchFieldEditor(BindingsType container,
- Composite parent, FormToolkit toolkit, final IItemPropertyDescriptor
propertyDescriptor,
- String buttonName, final EObject model) {
+ public static Composite createJavaMethodSearchFieldEditor(BindingsType container,
Composite parent,
+ FormToolkit toolkit, final IItemPropertyDescriptor propertyDescriptor, String
buttonName,
+ final EObject model) {
String classString = ((BindingsType) container).getClass_();
IJavaProject project = getJavaProject(container);
try {
@@ -242,7 +286,7 @@
Class<?> clazz = classLoader.loadClass(classString);
JavaMethodsSelectionDialog dialog = new JavaMethodsSelectionDialog(project, clazz);
return SmooksUIUtils.createDialogFieldEditor(parent, toolkit, propertyDescriptor,
- "Select method", dialog, (EObject) model);
+ "Select method", dialog, (EObject) model);
} catch (JavaModelException e) {
// ignore
} catch (ClassNotFoundException e) {
@@ -251,9 +295,78 @@
return null;
}
- public static Composite createJavaPropertySearchFieldEditor(BindingsType container,
- Composite parent, FormToolkit toolkit, final IItemPropertyDescriptor
propertyDescriptor,
- String buttonName, final EObject model) {
+ public static String generateFullPath(IXMLStructuredObject node, final String sperator)
{
+ return generatePath(node, getRootParent(node), sperator, true);
+ }
+
+ public static IXMLStructuredObject getRootParent(IXMLStructuredObject child) {
+ IXMLStructuredObject parent = child.getParent();
+ if (child.isRootNode())
+ return child;
+ if (parent == null || parent.isRootNode())
+ return child;
+ IXMLStructuredObject temp = parent;
+ while (temp != null && !temp.isRootNode()) {
+ parent = temp;
+ temp = temp.getParent();
+ }
+ return parent;
+ }
+
+ public static String generatePath(IXMLStructuredObject node, SelectorAttributes
selectorAttributes) {
+ String sperator = selectorAttributes.getSelectorSperator();
+ String policy = selectorAttributes.getSelectorPolicy();
+ if (sperator == null)
+ sperator = " ";
+ if (policy == null)
+ policy = SelectorAttributes.FULL_PATH;
+ if (policy.equals(SelectorAttributes.FULL_PATH)) {
+ return generateFullPath(node, sperator);
+ }
+ if (policy.equals(SelectorAttributes.INCLUDE_PARENT)) {
+ return generatePath(node, node.getParent(), sperator, true);
+ }
+ if (policy.equals(SelectorAttributes.IGNORE_ROOT)) {
+
+ }
+ if (policy.equals(SelectorAttributes.ONLY_NAME)) {
+ return node.getNodeName();
+ }
+ return generateFullPath(node, sperator);
+ }
+
+ public static String generatePath(IXMLStructuredObject startNode, IXMLStructuredObject
stopNode,
+ final String sperator, boolean includeContext) {
+ String name = "";
+ if (startNode == stopNode) {
+ return startNode.getNodeName();
+ }
+ List<IXMLStructuredObject> nodeList = new
ArrayList<IXMLStructuredObject>();
+ IXMLStructuredObject temp = startNode;
+ if (stopNode != null) {
+ while (temp != stopNode.getParent() && temp != null) {
+ nodeList.add(temp);
+ temp = temp.getParent();
+ }
+ }
+ int length = nodeList.size();
+ if (!includeContext) {
+ length--;
+ }
+ for (int i = 0; i < length; i++) {
+ IXMLStructuredObject n = nodeList.get(i);
+ String nodeName = n.getNodeName();
+ if (n.isAttribute()) {
+ nodeName = "@" + nodeName;
+ }
+ name = sperator + nodeName + name;
+ }
+ return name.trim();
+ }
+
+ public static Composite createJavaPropertySearchFieldEditor(BindingsType container,
Composite parent,
+ FormToolkit toolkit, final IItemPropertyDescriptor propertyDescriptor, String
buttonName,
+ final EObject model) {
String classString = ((BindingsType) container).getClass_();
IJavaProject project = getJavaProject(container);
try {
@@ -261,7 +374,7 @@
Class<?> clazz = classLoader.loadClass(classString);
JavaPropertiesSelectionDialog dialog = new JavaPropertiesSelectionDialog(project,
clazz);
return SmooksUIUtils.createDialogFieldEditor(parent, toolkit, propertyDescriptor,
- "Select property", dialog, (EObject) model);
+ "Select property", dialog, (EObject) model);
} catch (JavaModelException e) {
// ignore
} catch (ClassNotFoundException e) {
@@ -280,8 +393,8 @@
}
public static Composite createDialogFieldEditor(Composite parent, FormToolkit toolkit,
- final IItemPropertyDescriptor propertyDescriptor, String buttonName, IFieldDialog
dialog,
- final EObject model) {
+ final IItemPropertyDescriptor propertyDescriptor, String buttonName, IFieldDialog
dialog,
+ final EObject model) {
String displayName = propertyDescriptor.getDisplayName(model);
toolkit.createLabel(parent, displayName + " :");
final Composite classTextComposite = toolkit.createComposite(parent);
@@ -291,8 +404,8 @@
fillLayout.marginHeight = 0;
fillLayout.marginWidth = 0;
classTextComposite.setLayout(fillLayout);
- final SearchComposite searchComposite = new SearchComposite(classTextComposite,
toolkit,
- buttonName, dialog, SWT.NONE);
+ final SearchComposite searchComposite = new SearchComposite(classTextComposite,
toolkit, buttonName,
+ dialog, SWT.NONE);
Object editValue = getEditValue(propertyDescriptor, model);
if (editValue != null) {
searchComposite.getText().setText(editValue.toString());
@@ -304,12 +417,10 @@
Object editValue = ((PropertyValueWrapper) value).getEditableValue(model);
if (editValue != null) {
if (!editValue.equals(searchComposite.getText().getText())) {
- propertyDescriptor.setPropertyValue(model, searchComposite.getText()
- .getText());
+ propertyDescriptor.setPropertyValue(model, searchComposite.getText().getText());
}
} else {
- propertyDescriptor.setPropertyValue(model, searchComposite.getText()
- .getText());
+ propertyDescriptor.setPropertyValue(model, searchComposite.getText().getText());
}
} else {
propertyDescriptor.setPropertyValue(model, searchComposite.getText().getText());
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/BaseViewerInitor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/BaseViewerInitor.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/BaseViewerInitor.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -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";
+ 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:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/BaseViewerInitor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/IStructuredDataSelectionWizard.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/IStructuredDataSelectionWizard.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/IStructuredDataSelectionWizard.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -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 java.util.Properties;
+
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+
+/**
+ * @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();
+
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/IStructuredDataSelectionWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/IViewerInitor.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/IViewerInitor.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/IViewerInitor.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -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:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/IViewerInitor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/StructuredDataSelectionWizard.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/StructuredDataSelectionWizard.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/StructuredDataSelectionWizard.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -0,0 +1,99 @@
+/*******************************************************************************
+ * 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;
+ /**
+ * @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");
+ 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:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/StructuredDataSelectionWizard.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/TransformDataWizardSelectionPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/TransformDataWizardSelectionPage.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/TransformDataWizardSelectionPage.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -0,0 +1,229 @@
+/*******************************************************************************
+ * 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;
+
+/**
+ * @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);
+
+ viewer = new TreeViewer(main, SWT.NONE);
+ viewer.setContentProvider(new WizardNodeContentProvider());
+ viewer.setLabelProvider(new WizardNodeLabelProvider());
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ viewer.getTree().setLayoutData(gd);
+ createAllExtentionWizard();
+
+ 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("Selection data type"); //$NON-NLS-1$
+ setTitle("Selection data type"); //$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 = (Image) map.get(path);
+ if (icon == null) {
+
+ }
+ }
+ }
+ 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() {
+ 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:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/TransformDataWizardSelectionPage.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/TransformSelectWizardNode.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/TransformSelectWizardNode.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/TransformSelectWizardNode.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -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 = "";
+ String iconPath = null;
+ String pluginID = null;
+ String description = "";
+ 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:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/TransformSelectWizardNode.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/ViewerInitorStore.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/ViewerInitorStore.java
(rev 0)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/ViewerInitorStore.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -0,0 +1,139 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.smooks.configuration.editors.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.editors.javabean.JavabeanContentProvider;
+import org.jboss.tools.smooks.configuration.editors.javabean.JavabeanlabelProvider;
+import
org.jboss.tools.smooks.configuration.editors.javabean.JavabeanStrucutredDataWizard;
+import org.jboss.tools.smooks10.model.smooks.util.SmooksModelUtils;
+
+/**
+ * @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;
+ return initor.getStructuredDataLoadWizard();
+ }
+
+ 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 (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>();
+ BaseViewerInitor javabeanViewerInitor = new BaseViewerInitor();
+ String name = "Java";
+ String description = "Java class";
+ String iconPath = null;
+ String 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());
+ map.put(typeID, javabeanViewerInitor);
+ return map;
+ }
+}
Property changes on:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/wizard/ViewerInitorStore.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xsl/BindToUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xsl/BindToUICreator.java 2009-04-10
16:56:24 UTC (rev 14691)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xsl/BindToUICreator.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -15,6 +15,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.jboss.tools.smooks.configuration.editors.PropertyUICreator;
+import org.jboss.tools.smooks.configuration.editors.SmooksMultiFormEditor;
import org.jboss.tools.smooks.model.xsl.XslPackage;
/**
@@ -32,7 +33,7 @@
* org.eclipse.emf.ecore.EAttribute)
*/
public Composite createPropertyUI(FormToolkit toolkit, Composite parent,
- IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature) {
+ IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute
feature,SmooksMultiFormEditor formEditor) {
if (feature == XslPackage.eINSTANCE.getBindTo_Id()) {
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xsl/OutputToUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xsl/OutputToUICreator.java 2009-04-10
16:56:24 UTC (rev 14691)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xsl/OutputToUICreator.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -15,6 +15,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.jboss.tools.smooks.configuration.editors.PropertyUICreator;
+import org.jboss.tools.smooks.configuration.editors.SmooksMultiFormEditor;
import org.jboss.tools.smooks.model.xsl.XslPackage;
/**
@@ -32,7 +33,7 @@
* org.eclipse.emf.ecore.EAttribute)
*/
public Composite createPropertyUI(FormToolkit toolkit, Composite parent,
- IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature) {
+ IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute
feature,SmooksMultiFormEditor formEditor) {
if (feature == XslPackage.eINSTANCE.getOutputTo_OutputStreamResource()) {
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xsl/TemplateUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xsl/TemplateUICreator.java 2009-04-10
16:56:24 UTC (rev 14691)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xsl/TemplateUICreator.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -16,6 +16,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.jboss.tools.smooks.configuration.editors.PropertyUICreator;
+import org.jboss.tools.smooks.configuration.editors.SmooksMultiFormEditor;
import org.jboss.tools.smooks.configuration.editors.uitls.SmooksUIUtils;
import org.jboss.tools.smooks.model.xsl.XslPackage;
@@ -34,7 +35,7 @@
* org.eclipse.emf.ecore.EAttribute)
*/
public Composite createPropertyUI(FormToolkit toolkit, Composite parent,
- IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature) {
+ IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute
feature,SmooksMultiFormEditor formEditor) {
if (feature == XslPackage.eINSTANCE.getTemplate_Value()) {
}
if (feature == XslPackage.eINSTANCE.getTemplate_Encoding()) {
@@ -42,14 +43,27 @@
return null;
}
+
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.smooks.configuration.editors.PropertyUICreator#ignoreProperty(org.eclipse.emf.ecore.EAttribute)
+ */
@Override
+ public boolean ignoreProperty(EAttribute feature) {
+ if (feature == XslPackage.eINSTANCE.getTemplate_Value()) {
+ return true;
+ }
+ return super.ignoreProperty(feature);
+ }
+
+
+
+ @Override
public void createExtendUI(AdapterFactoryEditingDomain editingdomain, FormToolkit
toolkit,
- Composite parent, Object model) {
+ Composite parent, Object model, SmooksMultiFormEditor formEditor) {
SmooksUIUtils.createTextFieldEditor("Value", editingdomain, toolkit, parent,
model);
SmooksUIUtils.createCDATAFieldEditor("Template Contents", editingdomain,
toolkit, parent, model);
}
-
-
}
\ No newline at end of file
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xsl/XslUICreator.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xsl/XslUICreator.java 2009-04-10
16:56:24 UTC (rev 14691)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/xsl/XslUICreator.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -15,6 +15,7 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.jboss.tools.smooks.configuration.editors.PropertyUICreator;
+import org.jboss.tools.smooks.configuration.editors.SmooksMultiFormEditor;
import org.jboss.tools.smooks.model.xsl.XslPackage;
/**
@@ -32,7 +33,7 @@
* org.eclipse.emf.ecore.EAttribute)
*/
public Composite createPropertyUI(FormToolkit toolkit, Composite parent,
- IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute feature) {
+ IItemPropertyDescriptor propertyDescriptor, Object model, EAttribute
feature,SmooksMultiFormEditor formEditor) {
if (feature == XslPackage.eINSTANCE.getXsl_ApplyBefore()) {
}
if (feature == XslPackage.eINSTANCE.getXsl_ApplyOnElement()) {
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/wizards/SmooksConfigurationFileNewWizard.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/wizards/SmooksConfigurationFileNewWizard.java 2009-04-10
16:56:24 UTC (rev 14691)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/wizards/SmooksConfigurationFileNewWizard.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -14,6 +14,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.MessageDialog;
@@ -46,6 +47,7 @@
public SmooksConfigurationFileNewWizard() {
super();
setNeedsProgressMonitor(true);
+ setDefaultPageImageDescriptor(SmooksConfigurationActivator.getImageDescriptor("icons/smooks-wiz.gif"));
}
/**
@@ -54,7 +56,7 @@
public void addPages() {
containerSelectionPage = new SmooksFileContainerSelectionPage("Smooks
Configuration File",
- (IStructuredSelection) selection);
+ (IStructuredSelection) selection);
addPage(containerSelectionPage);
}
@@ -95,8 +97,8 @@
* file.
*/
- private void doFinish(IPath containerPath, String fileName, IProgressMonitor monitor,
- String version) throws CoreException {
+ private void doFinish(IPath containerPath, String fileName, IProgressMonitor monitor,
String version)
+ throws CoreException {
// create a sample file
monitor.beginTask("Creating " + fileName, 2);
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
@@ -105,17 +107,22 @@
if (resource.exists() && resource instanceof IContainer) {
container = (IContainer) resource;
}
- if (container == null) throwCoreException("Container \"" +
containerPath.toPortableString()
- + "\" does not exist.");
- final IFile file = container.getFile(new Path(fileName));
+ if (container == null)
+ throwCoreException("Container \"" + containerPath.toPortableString() +
"\" does not exist.");
+ final IFile configFile = container.getFile(new Path(fileName));
+ String extFileName = fileName + ".ext";
+ final IFile extFile = container.getFile(new Path(extFileName));
try {
+ // create config file
InputStream stream = openContentStream(version);
- if (file.exists()) {
- file.setContents(stream, true, true, monitor);
+ if (configFile.exists()) {
+ configFile.setContents(stream, true, true, monitor);
} else {
- file.create(stream, true, monitor);
+ configFile.create(stream, true, monitor);
}
stream.close();
+ // create ext file:
+ createExtentionFile(extFile, monitor);
} catch (IOException e) {
SmooksConfigurationActivator.getDefault().log(e);
}
@@ -123,9 +130,8 @@
monitor.setTaskName("Opening file with Smooks Editor.");
getShell().getDisplay().asyncExec(new Runnable() {
public void run() {
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow()
- .getActivePage();
- FileEditorInput editorInput = new FileEditorInput(file);
+ IWorkbenchPage page =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ FileEditorInput editorInput = new FileEditorInput(configFile);
try {
page.openEditor(editorInput, SmooksMultiFormEditor.EDITOR_ID, true);
} catch (PartInitException e) {
@@ -135,7 +141,26 @@
});
monitor.worked(1);
}
+
+ public static void createExtentionFile(IFile file , IProgressMonitor monitor) throws
CoreException, IOException{
+ if(monitor == null){
+ monitor = new NullProgressMonitor();
+ }
+ InputStream stream1 = createExtContentStream();
+ if (file.exists()) {
+ file.setContents(stream1, true, true, monitor);
+ } else {
+ file.create(stream1, true, monitor);
+ }
+ stream1.close();
+ }
+ public static InputStream createExtContentStream() {
+ String contents = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n"
+ + " <smooks-graphics-ext
xmlns=\"http://www.jboss.org/jbosstools/smooks/smooks-graphics-ext.x...;
+ return new ByteArrayInputStream(contents.getBytes());
+ }
+
/**
* We will initialize file contents with different smooks config file
* version.
@@ -145,26 +170,26 @@
String contents = "";
if (SmooksConstants.VERSION_1_0.equals(version)) {
contents = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n" //$NON-NLS-1$
- + "<smooks-resource-list
xmlns=\"http://www.milyn.org/xsd/smooks-1.0.xsd\">\n"//...
- + " <resource-config
selector=\"global-parameters\">\n"//$NON-NLS-1$
- + " <param
name=\"stream.filter.type\">SAX</param>\n"//$NON-NLS-1$
- + " </resource-config>\n"//$NON-NLS-1$
- + "</smooks-resource-list>"; //$NON-NLS-1$
+ + "<smooks-resource-list
xmlns=\"http://www.milyn.org/xsd/smooks-1.0.xsd\">\n"//...
+ + " <resource-config
selector=\"global-parameters\">\n"//$NON-NLS-1$
+ + " <param
name=\"stream.filter.type\">SAX</param>\n"//$NON-NLS-1$
+ + " </resource-config>\n"//$NON-NLS-1$
+ + "</smooks-resource-list>"; //$NON-NLS-1$
}
- if (SmooksConstants.VERSION_1_1_1.equals(version)) {
+ if (SmooksConstants.VERSION_1_1.equals(version)) {
contents = "<?xml version=\"1.0\"
encoding=\"UTF-8\"?>\n" //$NON-NLS-1$
- + "<smooks-resource-list
xmlns=\"http://www.milyn.org/xsd/smooks-1.1.xsd\">\n"//...
- + " <resource-config
selector=\"global-parameters\">\n"//$NON-NLS-1$
- + " <param
name=\"stream.filter.type\">SAX</param>\n"//$NON-NLS-1$
- + " </resource-config>\n"//$NON-NLS-1$
- + "</smooks-resource-list>"; //$NON-NLS-1$
+ + "<smooks-resource-list
xmlns=\"http://www.milyn.org/xsd/smooks-1.1.xsd\">\n"//...
+ + " <resource-config
selector=\"global-parameters\">\n"//$NON-NLS-1$
+ + " <param
name=\"stream.filter.type\">SAX</param>\n"//$NON-NLS-1$
+ + " </resource-config>\n"//$NON-NLS-1$
+ + "</smooks-resource-list>"; //$NON-NLS-1$
}
return new ByteArrayInputStream(contents.getBytes());
}
private void throwCoreException(String message) throws CoreException {
- IStatus status = new Status(IStatus.ERROR,SmooksConfigurationActivator.PLUGIN_ID,
- IStatus.OK, message, null);
+ IStatus status = new Status(IStatus.ERROR, SmooksConfigurationActivator.PLUGIN_ID,
IStatus.OK,
+ message, null);
throw new CoreException(status);
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/wizards/SmooksFileContainerSelectionPage.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/wizards/SmooksFileContainerSelectionPage.java 2009-04-10
16:56:24 UTC (rev 14691)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/wizards/SmooksFileContainerSelectionPage.java 2009-04-12
10:55:55 UTC (rev 14692)
@@ -2,11 +2,11 @@
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.custom.CCombo;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
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.ui.dialogs.WizardNewFileCreationPage;
@@ -18,13 +18,12 @@
*/
public class SmooksFileContainerSelectionPage extends WizardNewFileCreationPage {
- String version = SmooksConstants.VERSION_1_0;
+ String version = SmooksConstants.VERSION_1_1;
- private Button smook10Button;
- private Button smook11Button;
-
public SmooksFileContainerSelectionPage(String pageName, IStructuredSelection selection)
{
super(pageName, selection);
+ setTitle("Smooks Configuration File Wizard Page");
+ setDescription("Create a new Smooks configuration file.");
}
@Override
@@ -38,20 +37,42 @@
buttonComposite.setLayout(layout);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
-// Label speator = new Label(buttonComposite, SWT.SEPARATOR | SWT.HORIZONTAL);
-// speator.setLayoutData(gd);
+ Label speator = new Label(buttonComposite, SWT.SEPARATOR|SWT.HORIZONTAL);
+ gd.widthHint = 10;
+ speator.setLayoutData(gd);
+
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
Label label = new Label(buttonComposite, SWT.NONE);
label.setText("Please select Smooks configuration file version");
- label.setLayoutData(gd);
- smook10Button = new Button(buttonComposite, SWT.RADIO);
- smook10Button.setText("Smooks 1.0");
- VersionButtonSelectionAdapter selectionAdapter = new VersionButtonSelectionAdapter();
- smook10Button.addSelectionListener(selectionAdapter);
- smook11Button = new Button(buttonComposite, SWT.RADIO);
- smook11Button.setText("Smooks 1.1.1");
- smook11Button.addSelectionListener(selectionAdapter);
- smook10Button.setSelection(true);
+
+ final CCombo combo = new CCombo(buttonComposite,SWT.BORDER);
+ combo.setEditable(false);
+
+ for(int i = 0 ; i < SmooksConstants.SMOOKS_VERSIONS.length ; i++){
+ combo.add(SmooksConstants.SMOOKS_VERSIONS[i]);
+ }
+
+ int defaultIndex = 0 ;
+ for(int i = 0 ; i < SmooksConstants.SMOOKS_VERSIONS.length ; i++){
+ if(SmooksConstants.SMOOKS_VERSIONS[i].equals(version)){
+ defaultIndex = i;
+ break;
+ }
+ }
+ combo.select(defaultIndex);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 2;
+ combo.setLayoutData(gd);
+
+ combo.addModifyListener(new ModifyListener(){
+
+ public void modifyText(ModifyEvent e) {
+ version = combo.getText();
+ }
+
+ });
}
public String getVersion() {
@@ -61,18 +82,4 @@
public void setVersion(String version) {
this.version = version;
}
-
- private class VersionButtonSelectionAdapter extends SelectionAdapter {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (smook10Button.getSelection()) {
- version = SmooksConstants.VERSION_1_0;
- return;
- }
- if (smook11Button.getSelection()) {
- version = SmooksConstants.VERSION_1_1_1;
- return;
- }
- }
- }
}
\ No newline at end of file