Author: DartPeng
Date: 2009-04-10 06:38:36 -0400 (Fri, 10 Apr 2009)
New Revision: 14660
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/uitls/SmooksUIUtils.java
Log:
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
10:34:30 UTC (rev 14659)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/SmooksMasterDetailBlock.java 2009-04-10
10:38:36 UTC (rev 14660)
@@ -286,8 +286,12 @@
EStructuralFeature sf = ((BasicFeatureMapEntry) obj).getEStructuralFeature();
if (sf.equals(XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__TEXT)
|| sf.equals(XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__CDATA)) {
-// return false;
+ return false;
}
+ }else{
+ if(obj.getClass() == String.class){
+ return false;
+ }
}
return true;
}
Modified:
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java
===================================================================
---
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-04-10
10:34:30 UTC (rev 14659)
+++
trunk/smooks/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/configuration/editors/uitls/SmooksUIUtils.java 2009-04-10
10:38:36 UTC (rev 14660)
@@ -10,26 +10,15 @@
******************************************************************************/
package org.jboss.tools.smooks.configuration.editors.uitls;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.util.FeatureMapUtil;
import org.eclipse.emf.ecore.xml.type.AnyType;
-import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
-import org.eclipse.emf.edit.command.AddCommand;
-import org.eclipse.emf.edit.command.RemoveCommand;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor.PropertyValueWrapper;
@@ -88,33 +77,7 @@
}
String text = SmooksModelUtils.getAnyTypeText((AnyType) fm);
if (!valueText.getText().equals(text)) {
- CompoundCommand ccommand = new CompoundCommand();
- List<String> listValue = new ArrayList<String>();
- listValue.add(valueText.getText());
- Command addCommand = AddCommand.create(fEditingDomain, fm,
- XMLTypePackage.Literals.ANY_TYPE__MIXED, FeatureMapUtil.createEntry(
- XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__TEXT, valueText
- .getText()));
- Object removeValue = ((AnyType) fm).getMixed().get(
- XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__TEXT, true);
- if (removeValue != null && removeValue instanceof Collection<?>) {
- List<Object> rList = new ArrayList<Object>();
- for (Iterator<?> iterator = ((Collection<?>) removeValue).iterator();
iterator
- .hasNext();) {
- Object string = (Object) iterator.next();
- rList.add(FeatureMapUtil.createEntry(
- XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__TEXT, string));
- }
- Command cc = RemoveCommand.create(fEditingDomain, fm, null, rList);
- if (cc != null && cc.canExecute()) {
- ccommand.append(cc);
- }
- }
- if (addCommand != null && addCommand.canExecute()) {
- ccommand.append(addCommand);
- }
- fEditingDomain.getCommandStack().execute(ccommand);
- return;
+ SmooksModelUtils.setTextToSmooksType(fEditingDomain, (AnyType) fm, text);
}
}
});
@@ -127,7 +90,7 @@
GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
label1.setLayoutData(gd);
gd = new GridData(GridData.FILL_HORIZONTAL);
- Text cdataText = toolkit.createText(parent, "", SWT.MULTI | SWT.V_SCROLL);
+ final Text cdataText = toolkit.createText(parent, "", SWT.MULTI |
SWT.V_SCROLL);
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.heightHint = 300;
cdataText.setLayoutData(gd);
@@ -138,11 +101,52 @@
cdataText.setText(cdata);
}
}
+ final Object fm = model;
+ final AdapterFactoryEditingDomain fEditingDomain = editingdomain;
+ cdataText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ if (!(fm instanceof AnyType)) {
+ return;
+ }
+ String text = SmooksModelUtils.getAnyTypeText((AnyType) fm);
+ if (!cdataText.getText().equals(text)) {
+ SmooksModelUtils.setCDATAToSmooksType(fEditingDomain, (AnyType) fm, text);
+ }
+ }
+ });
}
- public static void createCommentFieldEditor(String label, FormToolkit toolkit,
- Composite parent, Object model) {
-
+ public static void createCommentFieldEditor(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);
+// gd = new GridData(GridData.FILL_HORIZONTAL);
+// final Text cdataText = toolkit.createText(parent, "", SWT.MULTI |
SWT.V_SCROLL);
+// gd = new GridData(GridData.FILL_HORIZONTAL);
+// gd.heightHint = 300;
+// cdataText.setLayoutData(gd);
+//
+// if (model instanceof AnyType) {
+// String cdata = SmooksModelUtils.getAnyTypeCDATA((AnyType) model);
+// if (cdata != null) {
+// cdataText.setText(cdata);
+// }
+// }
+// final Object fm = model;
+// final AdapterFactoryEditingDomain fEditingDomain = editingdomain;
+// cdataText.addModifyListener(new ModifyListener() {
+// public void modifyText(ModifyEvent e) {
+// if (!(fm instanceof AnyType)) {
+// return;
+// }
+// String text = SmooksModelUtils.getAnyTypeText((AnyType) fm);
+// if (!cdataText.getText().equals(text)) {
+// SmooksModelUtils.set(fEditingDomain, (AnyType) fm, text);
+// }
+// }
+// });
}
public static Composite createJavaTypeSearchFieldEditor(Composite parent, FormToolkit
toolkit,
Show replies by date