Author: scabanovich
Date: 2009-11-12 11:01:44 -0500 (Thu, 12 Nov 2009)
New Revision: 18655
Added:
trunk/esb/plugins/org.jboss.tools.esb.ui/src/org/jboss/tools/esb/ui/editor/form/ESBActionForm.java
trunk/esb/plugins/org.jboss.tools.esb.ui/src/org/jboss/tools/esb/ui/wizard/AddGenericActionStep.java
Modified:
trunk/esb/plugins/org.jboss.tools.esb.ui/META-INF/MANIFEST.MF
trunk/esb/plugins/org.jboss.tools.esb.ui/plugin.xml
trunk/esb/plugins/org.jboss.tools.esb.ui/src/org/jboss/tools/esb/ui/editor/form/ESBXMLFormLayoutData.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-2024
Modified: trunk/esb/plugins/org.jboss.tools.esb.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.ui/META-INF/MANIFEST.MF 2009-11-12 15:59:38 UTC
(rev 18654)
+++ trunk/esb/plugins/org.jboss.tools.esb.ui/META-INF/MANIFEST.MF 2009-11-12 16:01:44 UTC
(rev 18655)
@@ -8,6 +8,7 @@
Export-Package: org.jboss.tools.esb.ui,
org.jboss.tools.esb.ui.editor.form,
org.jboss.tools.esb.ui.editor.attribute,
+ org.jboss.tools.esb.ui.wizard,
org.jboss.tools.esb.ui.wizard.newfile
Bundle-SymbolicName: org.jboss.tools.esb.ui; singleton:=true
Bundle-Localization: plugin
Modified: trunk/esb/plugins/org.jboss.tools.esb.ui/plugin.xml
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.ui/plugin.xml 2009-11-12 15:59:38 UTC (rev
18654)
+++ trunk/esb/plugins/org.jboss.tools.esb.ui/plugin.xml 2009-11-12 16:01:44 UTC (rev
18655)
@@ -37,6 +37,11 @@
class="org.jboss.tools.esb.ui.editor.form.ESBXMLFormLayoutData"/>
<xclass
id="org.jboss.tools.esb.ui.editor.attribute.ActionClassValueFilter"
class="org.jboss.tools.esb.ui.editor.attribute.ActionClassValueFilter"/>
+ <xclass id="org.jboss.tools.esb.ui.editor.form.ESBActionForm"
+ class="org.jboss.tools.esb.ui.editor.form.ESBActionForm"/>
+ <xclass id="org.jboss.tools.esb.ui.wizard.AddGenericActionStep"
+ class="org.jboss.tools.esb.ui.wizard.AddGenericActionStep"/>
+
</extension>
<extension point="org.jboss.tools.common.model.ui.attributeAdapter">
Added:
trunk/esb/plugins/org.jboss.tools.esb.ui/src/org/jboss/tools/esb/ui/editor/form/ESBActionForm.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.ui/src/org/jboss/tools/esb/ui/editor/form/ESBActionForm.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.ui/src/org/jboss/tools/esb/ui/editor/form/ESBActionForm.java 2009-11-12
16:01:44 UTC (rev 18655)
@@ -0,0 +1,113 @@
+package org.jboss.tools.esb.ui.editor.form;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jdt.core.Flags;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.jboss.tools.common.meta.XAttribute;
+import org.jboss.tools.common.meta.constraint.impl.XAttributeConstraintAList;
+import org.jboss.tools.common.meta.impl.XModelMetaDataImpl;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.ui.attribute.XAttributeSupport;
+import org.jboss.tools.common.model.ui.attribute.adapter.DefaultValueAdapter;
+import org.jboss.tools.common.model.ui.attribute.adapter.IModelPropertyEditorAdapter;
+import org.jboss.tools.common.model.ui.attribute.editor.StringButtonFieldEditorEx;
+import org.jboss.tools.common.model.ui.forms.Form;
+import org.jboss.tools.common.model.ui.forms.FormActionData;
+import org.jboss.tools.common.model.ui.forms.FormAttributeData;
+import org.jboss.tools.common.model.ui.forms.IFormData;
+import org.jboss.tools.common.model.ui.forms.ModelFormLayoutData;
+import org.jboss.tools.common.model.ui.widgets.IWidgetSettings;
+import org.jboss.tools.common.model.util.EclipseJavaUtil;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+
+public class ESBActionForm extends Form {
+ static IFormData formData = ModelFormLayoutData.createGeneralFormData(
+ XModelMetaDataImpl.getInstance().getEntity("ESBAction101")
+ );
+
+ static {
+ ((FormAttributeData)formData.getAttributes()[2]).setWrapperClassName(StringButtonFieldEditorEx.class.getName());
+ }
+
+ public ESBActionForm() {
+ super(formData);
+ }
+
+ protected Control createClientArea(Composite parent, IWidgetSettings settings) {
+ Control c = super.createClientArea(parent, settings);
+ XAttributeSupport support = getSupport();
+ setProcessMethods(getSupport(), getModelObject());
+ support.getPropertyEditorAdapterByName("class").addValueChangeListener(new
PCL());
+ return c;
+ }
+
+ public void dispose() {
+ DefaultValueAdapter a =
(DefaultValueAdapter)getSupport().getPropertyEditorAdapterByName("process");
+ XAttribute attr = a.getAttribute();
+ if(attr == null) attr = a.getAttributeData().getAttribute();
+ XAttributeConstraintAList c = (XAttributeConstraintAList)attr.getConstraint();
+ c.setValues(new String[0]);
+ super.dispose();
+ }
+
+ class PCL implements PropertyChangeListener {
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ setProcessMethods(getSupport(), getModelObject());
+ }
+
+ }
+
+ public static void setProcessMethods(XAttributeSupport support, XModelObject object) {
+ IProject p = EclipseResourceUtil.getProject(object);
+ IJavaProject jp = EclipseResourceUtil.getJavaProject(p);
+ String cls =
support.getPropertyEditorAdapterByName("class").getStringValue(true);
+ Set<String> list = new TreeSet<String>();
+ try {
+ collectMethods(jp, cls, list);
+ } catch (JavaModelException e) {
+ //ignore
+ }
+
+ DefaultValueAdapter a =
(DefaultValueAdapter)support.getPropertyEditorAdapterByName("process");
+ XAttribute attr = a.getAttribute();
+ if(attr == null) attr = a.getAttributeData().getAttribute();
+ XAttributeConstraintAList c = (XAttributeConstraintAList)attr.getConstraint();
+ c.setValues(list.toArray(new String[0]));
+ }
+
+ private static void collectMethods(IJavaProject jp, String typeName, Set<String>
list) throws JavaModelException {
+ IType type = EclipseJavaUtil.findType(jp, typeName);
+ if(type == null) return;
+ IMethod[] ms = type.getMethods();
+ for (int i = 0; i < ms.length; i++) {
+ if(ms[i].isConstructor()) continue;
+ if(!Flags.isPublic(ms[i].getFlags())) continue;
+ String[] ps = ms[i].getParameterTypes();
+ if(ps == null || ps.length != 1) continue;
+ String t = EclipseJavaUtil.resolveTypeAsString(type, ps[0]);
+ if(!t.endsWith("Message")) continue;
+ list.add(ms[i].getElementName());
+ }
+ String st = type.getSuperclassName();
+ if(st != null && st.length() > 0) {
+ st = EclipseJavaUtil.resolveType(type, st);
+ if(st != null && st.length() > 0) {
+ collectMethods(jp, st, list);
+ }
+ }
+
+ }
+}
Property changes on:
trunk/esb/plugins/org.jboss.tools.esb.ui/src/org/jboss/tools/esb/ui/editor/form/ESBActionForm.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/esb/plugins/org.jboss.tools.esb.ui/src/org/jboss/tools/esb/ui/editor/form/ESBXMLFormLayoutData.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.ui/src/org/jboss/tools/esb/ui/editor/form/ESBXMLFormLayoutData.java 2009-11-12
15:59:38 UTC (rev 18654)
+++
trunk/esb/plugins/org.jboss.tools.esb.ui/src/org/jboss/tools/esb/ui/editor/form/ESBXMLFormLayoutData.java 2009-11-12
16:01:44 UTC (rev 18655)
@@ -29,7 +29,6 @@
public static String EMPTY_DESCRIPTION = ""; //$NON-NLS-1$
private final static IFormData[] FORM_LAYOUT_DEFINITIONS = new IFormData[] {
-
};
@@ -63,10 +62,13 @@
return data;
}
- private IFormData generateDefaultFormData(XModelEntity entity) {
+ public IFormData generateDefaultFormData(XModelEntity entity) {
String entityName = entity.getName();
List<IFormData> list = new ArrayList<IFormData>();
IFormData g = ModelFormLayoutData.createGeneralFormData(entity);
+ if(entityName.equals(ENT_ESB_ACTION)) {
+ g = new FormData("org.jboss.tools.esb.ui.editor.form.ESBActionForm");
+ }
if(g != null) list.add(g);
if(entityName.startsWith(PREACTION_PREFIX)) {
if(entity.getChild(ENT_ESB_ROUTE_TO) != null) {
@@ -105,7 +107,7 @@
IFormData a = ModelFormLayoutData.createAdvancedFormData(entityName);
if(a != null) list.add(a);
IFormData[] ds = list.toArray(new IFormData[0]);
- IFormData data = new FormData(entityName, new String[]{null}, ds);
+ IFormData data = new FormData(entityName, (String[])(null), ds);
return data;
}
Added:
trunk/esb/plugins/org.jboss.tools.esb.ui/src/org/jboss/tools/esb/ui/wizard/AddGenericActionStep.java
===================================================================
---
trunk/esb/plugins/org.jboss.tools.esb.ui/src/org/jboss/tools/esb/ui/wizard/AddGenericActionStep.java
(rev 0)
+++
trunk/esb/plugins/org.jboss.tools.esb.ui/src/org/jboss/tools/esb/ui/wizard/AddGenericActionStep.java 2009-11-12
16:01:44 UTC (rev 18655)
@@ -0,0 +1,25 @@
+package org.jboss.tools.esb.ui.wizard;
+
+import java.beans.PropertyChangeEvent;
+
+import org.jboss.tools.common.model.ui.wizards.special.SpecialWizardStep;
+import org.jboss.tools.esb.ui.editor.form.ESBActionForm;
+
+public class AddGenericActionStep extends SpecialWizardStep {
+ boolean lock = false;
+
+ public AddGenericActionStep() {}
+
+ public void propertyChange(PropertyChangeEvent event) {
+ if(lock) return;
+ if(event.getSource() == attributes.getPropertyEditorAdapterByName("class")) {
//$NON-NLS-1$
+ lock = true;
+ try {
+ ESBActionForm.setProcessMethods(attributes, support.getTarget());
+ } finally {
+ lock = false;
+ }
+ }
+ super.propertyChange(event);
+ }
+}
Property changes on:
trunk/esb/plugins/org.jboss.tools.esb.ui/src/org/jboss/tools/esb/ui/wizard/AddGenericActionStep.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain