JBoss Tools SVN: r10022 - in trunk/common/plugins/org.jboss.tools.common.el: src/org/jboss/tools/common/el/global and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: estherbin
Date: 2008-09-02 07:22:12 -0400 (Tue, 02 Sep 2008)
New Revision: 10022
Modified:
trunk/common/plugins/org.jboss.tools.common.el/META-INF/MANIFEST.MF
trunk/common/plugins/org.jboss.tools.common.el/src/org/jboss/tools/common/el/global/GlobalELReferenceList.java
trunk/common/plugins/org.jboss.tools.common.el/src/org/jboss/tools/common/el/global/GlobalElVariablesComposite.java
trunk/common/plugins/org.jboss.tools.common.el/src/org/jboss/tools/common/el/vpe/ELReferenceList.java
trunk/common/plugins/org.jboss.tools.common.el/src/org/jboss/tools/common/el/vpe/ElVariablesComposite.java
Log:
Moved resources reference functionality to the separate bundle.
Modified: trunk/common/plugins/org.jboss.tools.common.el/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el/META-INF/MANIFEST.MF 2008-09-02 09:42:09 UTC (rev 10021)
+++ trunk/common/plugins/org.jboss.tools.common.el/META-INF/MANIFEST.MF 2008-09-02 11:22:12 UTC (rev 10022)
@@ -11,5 +11,5 @@
Bundle-Activator: org.jboss.tools.common.el.Activator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
- org.jboss.tools.common.rreferences;bundle-version="2.0.0",
+ org.jboss.tools.common.resref;bundle-version="2.0.0",
org.eclipse.core.resources;bundle-version="3.4.0"
Modified: trunk/common/plugins/org.jboss.tools.common.el/src/org/jboss/tools/common/el/global/GlobalELReferenceList.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el/src/org/jboss/tools/common/el/global/GlobalELReferenceList.java 2008-09-02 09:42:09 UTC (rev 10021)
+++ trunk/common/plugins/org.jboss.tools.common.el/src/org/jboss/tools/common/el/global/GlobalELReferenceList.java 2008-09-02 11:22:12 UTC (rev 10022)
@@ -12,7 +12,7 @@
package org.jboss.tools.common.el.global;
import org.eclipse.core.runtime.QualifiedName;
-import org.jboss.tools.common.rreferences.core.ResourceReferenceList;
+import org.jboss.tools.common.resref.core.ResourceReferenceList;
/**
* @author Evgenij Stherbin
Modified: trunk/common/plugins/org.jboss.tools.common.el/src/org/jboss/tools/common/el/global/GlobalElVariablesComposite.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el/src/org/jboss/tools/common/el/global/GlobalElVariablesComposite.java 2008-09-02 09:42:09 UTC (rev 10021)
+++ trunk/common/plugins/org.jboss.tools.common.el/src/org/jboss/tools/common/el/global/GlobalElVariablesComposite.java 2008-09-02 11:22:12 UTC (rev 10022)
@@ -13,10 +13,10 @@
import java.util.List;
-import org.jboss.tools.common.rreferences.core.ResourceReference;
-import org.jboss.tools.common.rreferences.core.ResourceReferenceList;
-import org.jboss.tools.common.rreferences.core.ResourceReferencesComposite;
-import org.jboss.tools.common.rreferences.core.ResourceReferencesTableProvider;
+import org.jboss.tools.common.resref.core.ResourceReference;
+import org.jboss.tools.common.resref.core.ResourceReferenceList;
+import org.jboss.tools.common.resref.core.ResourceReferencesComposite;
+import org.jboss.tools.common.resref.core.ResourceReferencesTableProvider;
/**
@@ -27,7 +27,7 @@
public class GlobalElVariablesComposite extends ResourceReferencesComposite {
/**
- * @see org.jboss.tools.common.rreferences.core.ResourceReferencesComposite#createGroupLabel()
+ * @see org.jboss.tools.common.resref.core.ResourceReferencesComposite#createGroupLabel()
*/
@Override
protected String createGroupLabel() {
@@ -35,7 +35,7 @@
}
/**
- * @see org.jboss.tools.common.rreferences.core.ResourceReferencesComposite#createTableProvider(java.util.List)
+ * @see org.jboss.tools.common.resref.core.ResourceReferencesComposite#createTableProvider(java.util.List)
*/
@Override
protected ResourceReferencesTableProvider createTableProvider(List dataList) {
@@ -43,7 +43,7 @@
}
/**
- * @see org.jboss.tools.common.rreferences.core.ResourceReferencesComposite#getEntity()
+ * @see org.jboss.tools.common.resref.core.ResourceReferencesComposite#getEntity()
*/
@Override
protected String getEntity() {
@@ -51,7 +51,7 @@
}
/**
- * @see org.jboss.tools.common.rreferences.core.ResourceReferencesComposite#getReferenceList()
+ * @see org.jboss.tools.common.resref.core.ResourceReferencesComposite#getReferenceList()
*/
@Override
protected ResourceReferenceList getReferenceList() {
Modified: trunk/common/plugins/org.jboss.tools.common.el/src/org/jboss/tools/common/el/vpe/ELReferenceList.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el/src/org/jboss/tools/common/el/vpe/ELReferenceList.java 2008-09-02 09:42:09 UTC (rev 10021)
+++ trunk/common/plugins/org.jboss.tools.common.el/src/org/jboss/tools/common/el/vpe/ELReferenceList.java 2008-09-02 11:22:12 UTC (rev 10022)
@@ -2,7 +2,7 @@
import org.eclipse.core.runtime.QualifiedName;
-import org.jboss.tools.common.rreferences.core.ResourceReferenceList;
+import org.jboss.tools.common.resref.core.ResourceReferenceList;
/**
Modified: trunk/common/plugins/org.jboss.tools.common.el/src/org/jboss/tools/common/el/vpe/ElVariablesComposite.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.el/src/org/jboss/tools/common/el/vpe/ElVariablesComposite.java 2008-09-02 09:42:09 UTC (rev 10021)
+++ trunk/common/plugins/org.jboss.tools.common.el/src/org/jboss/tools/common/el/vpe/ElVariablesComposite.java 2008-09-02 11:22:12 UTC (rev 10022)
@@ -2,10 +2,10 @@
import java.util.List;
-import org.jboss.tools.common.rreferences.core.ResourceReferenceList;
-import org.jboss.tools.common.rreferences.core.ResourceReferencesComposite;
-import org.jboss.tools.common.rreferences.core.ResourceReferencesTableProvider;
-import org.jboss.tools.common.rreferences.messages.Messages;
+import org.jboss.tools.common.resref.core.ResourceReferenceList;
+import org.jboss.tools.common.resref.core.ResourceReferencesComposite;
+import org.jboss.tools.common.resref.core.ResourceReferencesTableProvider;
+import org.jboss.tools.common.resref.messages.Messages;
/**
* The Class ElVariablesComposite.
15 years, 8 months
JBoss Tools SVN: r10021 - in workspace/dart/plugins: trunk/org.jboss.tools.smooks.javabean/src/org/jboss/tools/smooks/javabean/analyzer and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: DartPeng
Date: 2008-09-02 05:42:09 -0400 (Tue, 02 Sep 2008)
New Revision: 10021
Modified:
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java
workspace/dart/plugins/trunk/org.jboss.tools.smooks.javabean/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java
workspace/dart/plugins/trunk/org.jboss.tools.smooks.model/src/org/milyn/xsd/smooks/util/SmooksModelUtils.java
Log:
add some code for parse input target object model via smooks file
Modified: workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java
===================================================================
--- workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java 2008-09-02 09:11:03 UTC (rev 10020)
+++ workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/ui/editors/SmooksGraphicalFormPage.java 2008-09-02 09:42:09 UTC (rev 10021)
@@ -303,9 +303,9 @@
section1.setLayoutData(sgd1);
toolkit.paintBordersFor(rootMainControl);
-
+
form.pack();
-
+
this.hookGraphicalViewer();
this.initGraphicalViewer();
if (initSourceTreeViewerProviders()) {
@@ -623,12 +623,19 @@
resource.load(Collections.EMPTY_MAP);
IAnalyzer sourceModelAnalyzer = AnalyzerFactory.getInstance()
.getSmooksModelAnalyzer(sourceDataTypeID);
-
+ IAnalyzer targetModelAnalyzer = AnalyzerFactory.getInstance()
+ .getSmooksModelAnalyzer(targetDataTypeID);
SmooksResourceListType listType = ((DocumentRoot) resource
.getContents().get(0)).getSmooksResourceList();
+
sourceTreeViewerInputModel = sourceModelAnalyzer
.buildSourceInputObjects(graph, listType,
((IFileEditorInput) input).getFile());
+
+ targetTreeViewerInputModel = targetModelAnalyzer
+ .buildTargetInputObjects(graph, listType,
+ ((IFileEditorInput) input).getFile());
+
} catch (IOException e) {
e.printStackTrace();
} catch (CoreException e) {
Modified: workspace/dart/plugins/trunk/org.jboss.tools.smooks.javabean/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java
===================================================================
--- workspace/dart/plugins/trunk/org.jboss.tools.smooks.javabean/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java 2008-09-02 09:11:03 UTC (rev 10020)
+++ workspace/dart/plugins/trunk/org.jboss.tools.smooks.javabean/src/org/jboss/tools/smooks/javabean/analyzer/JavaBeanAnalyzer.java 2008-09-02 09:42:09 UTC (rev 10021)
@@ -22,6 +22,7 @@
import org.eclipse.emf.common.command.BasicCommandStack;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CommandStack;
+import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.util.ExtendedMetaData;
import org.eclipse.emf.ecore.xml.type.AnyType;
@@ -408,31 +409,150 @@
null);
}
+ public Object buildTargetInputObjects(GraphInformations graphInfo,
+ SmooksResourceListType listType, IFile sourceFile)
+ throws InvocationTargetException {
+ return this.buildTargetInputObjects(graphInfo, listType, sourceFile,
+ null);
+ }
+
+ public Object buildTargetInputObjects(GraphInformations graphInfo,
+ SmooksResourceListType listType, IFile sourceFile,
+ ClassLoader loader) throws InvocationTargetException {
+ if (loader == null) {
+ try {
+ loader = new ProjectClassLoader(JavaCore.create(sourceFile
+ .getProject()));
+ } catch (JavaModelException e) {
+ // ignore
+ }
+ }
+ List resourceConfigList = listType.getAbstractResourceConfig();
+ String rootClassName = null;
+ ResourceConfigType current = null;
+ for (Iterator iterator = resourceConfigList.iterator(); iterator
+ .hasNext();) {
+ AbstractResourceConfig ar = (AbstractResourceConfig) iterator
+ .next();
+ if (ar instanceof ResourceConfigType) {
+ ResourceConfigType rc = (ResourceConfigType) ar;
+ ResourceType resourceType = rc.getResource();
+ String resource = resourceType.getValue();
+ if (BEANPOPULATOR.equals(resource)) {
+ // create root beanmodel
+ current = rc;
+ break;
+ }
+ }
+ }
+ Class rootClass = null;
+ rootClassName = SmooksModelUtils.getParmaText("beanClass", current);
+ if (rootClassName != null && loader != null) {
+ try {
+ rootClass = loader.loadClass(rootClassName);
+ } catch (ClassNotFoundException e) {
+ // ignore
+ }
+ }
+ boolean rootIsError = false;
+ JavaBeanModel rootModel = null;
+ if (rootClass != null) {
+ rootModel = JavaBeanModelFactory
+ .getJavaBeanModelWithLazyLoad(rootClass);
+ rootIsError = true;
+ } else {
+ rootModel = new JavaBeanModel(null, rootClassName);
+ }
+ setSelectorIsUsed(rootClassName);
+ buildChildrenOfTargetInputModel(listType, rootModel, false,
+ rootIsError, current, loader);
+ return rootModel;
+ }
+
+ protected void buildChildrenOfTargetInputModel(
+ SmooksResourceListType listType, JavaBeanModel beanModel,
+ boolean rootIsWarning, boolean rootIsError,
+ ResourceConfigType currentResourceConfigType,
+ ClassLoader classLoader) {
+ if (currentResourceConfigType != null) {
+ List bindingList = getBindingListFromResourceConfigType(currentResourceConfigType);
+ for (Iterator iterator = bindingList.iterator(); iterator.hasNext();) {
+ AnyType binding = (AnyType) iterator.next();
+ String property = SmooksModelUtils
+ .getAttributeValueFromAnyType(binding,
+ SmooksModelUtils.ATTRIBUTE_PROPERTY);
+ String selector = SmooksModelUtils
+ .getAttributeValueFromAnyType(binding,
+ SmooksModelUtils.ATTRIBUTE_SELECTOR);
+ // if(property == null){
+ // continue;
+ // }
+ processBindingPropertyFromTargetModel(listType, property,
+ selector, beanModel,classLoader);
+ }
+ }
+
+ }
+
+ protected void processBindingPropertyFromTargetModel(
+ SmooksResourceListType listType, String property, String selector,
+ JavaBeanModel parentModel,ClassLoader classLoader) {
+ parentModel.getProperties();
+ JavaBeanModel model = this.findTheChildJavaBeanModel(property, parentModel);
+ if(model == null){
+ model = new JavaBeanModel(null,property);
+ parentModel.addProperty(model);
+ model.setError("don't exist");
+ }
+
+ if(selector.startsWith("${") && selector.endsWith("}")){
+ selector = selector.substring(2, selector.length() - 1);
+ List rList = listType.getAbstractResourceConfig();
+ for (Iterator iterator = rList.iterator(); iterator.hasNext();) {
+ ResourceConfigType configType = (ResourceConfigType) iterator.next();
+ if(isSelectorIsUsed(configType.getSelector())){
+ continue;
+ }
+ String beanId = this.getBeanIDFromParam(configType);
+ if(selector.equals(beanId)){
+ this.buildChildrenOfTargetInputModel(listType, model, false, false, configType, classLoader);
+ }
+ }
+ }
+ }
+
+ protected List getBindingListFromResourceConfigType(
+ ResourceConfigType resourceConfig) {
+ List paramList = resourceConfig.getParam();
+ for (Iterator iterator = paramList.iterator(); iterator.hasNext();) {
+ ParamType param = (ParamType) iterator.next();
+ if ("bindings".equals(param.getName())) {
+ if (param.eContents().isEmpty())
+ continue;
+ List bindingList = (List) param.getMixed().get(
+ SmooksModelUtils.ELEMENT_BINDING, false);
+ return bindingList;
+ }
+ }
+ return null;
+ }
+
protected void buildSourceInputProperties(SmooksResourceListType listType,
JavaBeanModel beanModel, boolean rootIsWarning,
boolean rootIsError, ResourceConfigType currentResourceConfigType,
ClassLoader classLoader) {
if (currentResourceConfigType != null) {
- List paramList = currentResourceConfigType.getParam();
- for (Iterator iterator = paramList.iterator(); iterator.hasNext();) {
- ParamType param = (ParamType) iterator.next();
- if ("bindings".equals(param.getName())) {
- if (param.eContents().isEmpty())
- continue;
- List bindingList = (List) param.getMixed().get(
- SmooksModelUtils.ELEMENT_BINDING, false);
- for (Iterator iterator2 = bindingList.iterator(); iterator2
- .hasNext();) {
- AnyType binding = (AnyType) iterator2.next();
- String selector = (String) binding
- .getAnyAttribute()
- .get(SmooksModelUtils.ATTRIBUTE_SELECTOR, false);
- setSelectorIsUsed(currentResourceConfigType
- .getSelector());
- analyzeBindingSelector(selector, beanModel, listType,
- classLoader);
- }
- }
+ List bindingList = this
+ .getBindingListFromResourceConfigType(currentResourceConfigType);
+ for (Iterator iterator2 = bindingList.iterator(); iterator2
+ .hasNext();) {
+ AnyType binding = (AnyType) iterator2.next();
+ String selector = SmooksModelUtils
+ .getAttributeValueFromAnyType(binding,
+ SmooksModelUtils.ATTRIBUTE_SELECTOR);
+ setSelectorIsUsed(currentResourceConfigType.getSelector());
+ analyzeBindingSelector(selector, beanModel, listType,
+ classLoader);
}
}
}
@@ -519,11 +639,7 @@
for (Iterator iterator = list.iterator(); iterator.hasNext();) {
ParamType p = (ParamType) iterator.next();
if ("beanId".equals(p.getName())) {
- Object obj = p.getMixed().get(
- XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__TEXT,
- true);
- if (obj != null && obj instanceof List)
- return ((List) obj).get(0).toString().trim();
+ return SmooksModelUtils.getAnyTypeText(p);
}
}
Modified: workspace/dart/plugins/trunk/org.jboss.tools.smooks.model/src/org/milyn/xsd/smooks/util/SmooksModelUtils.java
===================================================================
--- workspace/dart/plugins/trunk/org.jboss.tools.smooks.model/src/org/milyn/xsd/smooks/util/SmooksModelUtils.java 2008-09-02 09:11:03 UTC (rev 10020)
+++ workspace/dart/plugins/trunk/org.jboss.tools.smooks.model/src/org/milyn/xsd/smooks/util/SmooksModelUtils.java 2008-09-02 09:42:09 UTC (rev 10021)
@@ -10,12 +10,16 @@
******************************************************************************/
package org.milyn.xsd.smooks.util;
+import java.util.Iterator;
+import java.util.List;
+
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.ExtendedMetaData;
import org.eclipse.emf.ecore.xml.type.AnyType;
import org.eclipse.emf.ecore.xml.type.XMLTypePackage;
import org.milyn.xsd.smooks.ParamType;
+import org.milyn.xsd.smooks.ResourceConfigType;
import org.milyn.xsd.smooks.SmooksPackage;
/**
@@ -35,7 +39,8 @@
.demandFeature(null, "type", false);
public static EStructuralFeature ELEMENT_BINDING = ExtendedMetaData.INSTANCE
- .demandFeature("http://www.milyn.org/xsd/smooks-1.0.xsd", "binding", true);
+ .demandFeature("http://www.milyn.org/xsd/smooks-1.0.xsd",
+ "binding", true);
public static void addBindingTypeToParamType(ParamType param,
String property, String selector, String type, String uri) {
@@ -43,6 +48,36 @@
param.getMixed().add(ELEMENT_BINDING, binding);
}
+ public static String getParmaText(String paramName,
+ ResourceConfigType resourceConfigType) {
+ List plist = resourceConfigType.getParam();
+ for (Iterator iterator = plist.iterator(); iterator.hasNext();) {
+ ParamType p = (ParamType) iterator.next();
+ if (paramName.equals(p.getName())) {
+ return getAnyTypeText(p);
+ }
+ }
+ return null;
+ }
+
+ public static String getAttributeValueFromAnyType(AnyType anyType,EStructuralFeature attribute) {
+ String value = (String) anyType.getAnyAttribute().get(attribute, false);
+ return value;
+ }
+
+ public static String getAnyTypeText(AnyType anyType){
+ Object value = anyType.getMixed().get(
+ XMLTypePackage.Literals.XML_TYPE_DOCUMENT_ROOT__TEXT,
+ true);
+ if (value != null) {
+ if (value instanceof List) {
+ return ((List) value).get(0).toString().trim();
+ }
+ return value.toString();
+ }
+ return null;
+ }
+
public static AnyType createBindingType(String property, String selector,
String type, String uri) {
if (uri == null) {
15 years, 8 months
JBoss Tools SVN: r10020 - workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer.
by jbosstools-commits@lists.jboss.org
Author: DartPeng
Date: 2008-09-02 05:11:03 -0400 (Tue, 02 Sep 2008)
New Revision: 10020
Modified:
workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/IAnalyzer.java
Log:
Add a method to parse the target model via smooks file
Modified: workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/IAnalyzer.java
===================================================================
--- workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/IAnalyzer.java 2008-09-02 07:18:00 UTC (rev 10019)
+++ workspace/dart/plugins/org.jboss.tools.smooks.ui/src/org/jboss/tools/smooks/analyzer/IAnalyzer.java 2008-09-02 09:11:03 UTC (rev 10020)
@@ -32,5 +32,10 @@
SmooksResourceListType listType);
public Object buildSourceInputObjects(GraphInformations graphInfo,
- SmooksResourceListType listType, IFile sourceFile) throws InvocationTargetException;
+ SmooksResourceListType listType, IFile sourceFile)
+ throws InvocationTargetException;
+
+ public Object buildTargetInputObjects(GraphInformations graphInfo,
+ SmooksResourceListType listType, IFile sourceFile)
+ throws InvocationTargetException;
}
15 years, 8 months
JBoss Tools SVN: r10019 - in trunk/esb/plugins/org.jboss.tools.esb.project.ui: .settings and 16 other directories.
by jbosstools-commits@lists.jboss.org
Author: dennyxu
Date: 2008-09-02 03:18:00 -0400 (Tue, 02 Sep 2008)
New Revision: 10019
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/.classpath
trunk/esb/plugins/org.jboss.tools.esb.project.ui/.project
trunk/esb/plugins/org.jboss.tools.esb.project.ui/.settings/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/.settings/org.eclipse.jdt.core.prefs
trunk/esb/plugins/org.jboss.tools.esb.project.ui/META-INF/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/META-INF/MANIFEST.MF
trunk/esb/plugins/org.jboss.tools.esb.project.ui/build.properties
trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/obj16/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/obj16/jar_obj.gif
trunk/esb/plugins/org.jboss.tools.esb.project.ui/plugin.properties
trunk/esb/plugins/org.jboss.tools.esb.project.ui/plugin.xml
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/ESBProjectPlugin.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/JBossESBUIPlugin.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/BaseField.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/BaseFieldEditor.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/ButtonFieldEditor.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/CompositeEditor.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/IFieldEditor.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/INamedElement.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/JBossESBRuntimePreferencePage.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/JBossLibraryListFieldEditor.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/JBossRuntimeListFieldEditor.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/LabelFieldEditor.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/PushButtonField.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/TextField.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/TextFieldEditor.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/messages/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/messages/JBossESBUI.properties
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/messages/JBossESBUIMessages.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/utils/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/utils/UIUtils.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/ESBProjectWizard.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/JBossESBFacetProjectCreationDataModelProvider.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/pages/
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/pages/ESBFacetInstallationPage.java
trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/pages/ESBProjectFirstPage.java
Log:
Initial import. Add ESB project facet and wizard
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/.classpath
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/.classpath (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/.classpath 2008-09-02 07:18:00 UTC (rev 10019)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/.project
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/.project (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/.project 2008-09-02 07:18:00 UTC (rev 10019)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.esb.project.ui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/.settings/org.eclipse.jdt.core.prefs 2008-09-02 07:18:00 UTC (rev 10019)
@@ -0,0 +1,7 @@
+#Wed Aug 27 16:06:10 CST 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/META-INF/MANIFEST.MF (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/META-INF/MANIFEST.MF 2008-09-02 07:18:00 UTC (rev 10019)
@@ -0,0 +1,33 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Esbproject Plug-in
+Bundle-SymbolicName: org.jboss.tools.esb.project.ui;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Activator: org.jboss.tools.esb.project.ui.ESBProjectPlugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.pde.ui,
+ org.eclipse.pde.ui.templates,
+ org.eclipse.wst.common.project.facet.core,
+ org.eclipse.core.resources,
+ org.eclipse.ui.ide,
+ org.eclipse.wst.web.ui,
+ org.eclipse.wst.common.frameworks,
+ org.eclipse.wst.common.frameworks.ui,
+ org.eclipse.wst.common.core,
+ org.eclipse.wst.common.project.facet.ui,
+ org.eclipse.wst.server.ui,
+ org.eclipse.wst.web,
+ org.eclipse.wst.common.modulecore,
+ org.eclipse.wst.server.core,
+ org.eclipse.jst.server.core,
+ org.eclipse.jst.servlet.ui;bundle-version="1.1.200",
+ org.eclipse.jst.common.frameworks;bundle-version="1.1.200",
+ org.eclipse.jst.common.project.facet.core;bundle-version="1.3.0",
+ org.eclipse.jst.j2ee;bundle-version="1.1.200",
+ org.eclipse.jst.j2ee.web;bundle-version="1.1.200",
+ org.eclipse.jst.j2ee.core;bundle-version="1.1.200",
+ org.eclipse.jst.j2ee.ui;bundle-version="1.1.200",
+ org.eclipse.jdt.core;bundle-version="3.4.0",
+ org.jboss.tools.esb.project.core;bundle-version="1.0.0"
+Eclipse-LazyStart: true
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/build.properties
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/build.properties (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/build.properties 2008-09-02 07:18:00 UTC (rev 10019)
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/obj16/jar_obj.gif
===================================================================
(Binary files differ)
Property changes on: trunk/esb/plugins/org.jboss.tools.esb.project.ui/icons/obj16/jar_obj.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/plugin.properties
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/plugin.properties (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/plugin.properties 2008-09-02 07:18:00 UTC (rev 10019)
@@ -0,0 +1 @@
+JBOSS_ESB_PREFERENCE_PAGE=JBoss ESB Runtimes
\ No newline at end of file
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/plugin.xml
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/plugin.xml (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/plugin.xml 2008-09-02 07:18:00 UTC (rev 10019)
@@ -0,0 +1,39 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension-point id="org.jboss.tools.esb.project.ui.template" name="ESB Template" schema="schema/org.jboss.tools.esb.project.ui.template.exsd"/>
+ <extension
+ point="org.eclipse.ui.newWizards">
+ <wizard
+ category="org.jboss.tools.esb.category1"
+ class="org.jboss.tools.esb.project.ui.wizards.ESBProjectWizard"
+ id="JBoss.ESB.Project.Wizard"
+ name="ESB Project Wizard"
+ project="true">
+ </wizard>
+ <category
+ id="org.jboss.tools.esb.category1"
+ name="ESB Wizard">
+ </category>
+ </extension>
+
+ <extension
+ point="org.eclipse.wst.common.project.facet.ui.wizardPages">
+ <wizard-pages
+ action="jst.jboss.esb.install">
+ <page
+ class="org.jboss.tools.esb.project.ui.wizards.pages.ESBFacetInstallationPage">
+ </page>
+ </wizard-pages>
+ </extension>
+<extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ category="org.jboss.ide.eclipse.ui.MainPreferencePage"
+ class="org.jboss.tools.esb.project.ui.preference.controls.JBossESBRuntimePreferencePage"
+ id="org.jboss.tools.esb.project.runtime.preference"
+ name="JBoss ESB Runtimes">
+ </page>
+ </extension>
+
+</plugin>
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/ESBProjectPlugin.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/ESBProjectPlugin.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/ESBProjectPlugin.java 2008-09-02 07:18:00 UTC (rev 10019)
@@ -0,0 +1,50 @@
+package org.jboss.tools.esb.project.ui;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class ESBProjectPlugin extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.esb.project.ui";
+
+ // The shared instance
+ private static ESBProjectPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public ESBProjectPlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static ESBProjectPlugin getDefault() {
+ return plugin;
+ }
+
+}
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/JBossESBUIPlugin.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/JBossESBUIPlugin.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/JBossESBUIPlugin.java 2008-09-02 07:18:00 UTC (rev 10019)
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * 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.esb.project.ui.preference;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class JBossESBUIPlugin extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.esb.project.preference";
+
+ // The shared instance
+ private static JBossESBUIPlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public JBossESBUIPlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static JBossESBUIPlugin getDefault() {
+ return plugin;
+ }
+
+ public static ImageDescriptor getImageDescriptor(String path) {
+ path = "icons/" + path; //$NON-NLS-1$
+ return AbstractUIPlugin.imageDescriptorFromPlugin("org.jboss.tools.esb.project.ui", path); //$NON-NLS-1$
+ }
+}
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/BaseField.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/BaseField.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/BaseField.java 2008-09-02 07:18:00 UTC (rev 10019)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * 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.esb.project.ui.preference.controls;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * @author Grid Qian
+ */
+public abstract class BaseField {
+
+ public static final String PROPERTY_NAME = "value"; //$NON-NLS-1$
+
+ private PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ public void firePropertyChange(Object oldValue, Object newValue) {
+ pcs.firePropertyChange(PROPERTY_NAME, oldValue, newValue);
+ }
+
+ abstract public Control getControl();
+}
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/BaseFieldEditor.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/BaseFieldEditor.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/BaseFieldEditor.java 2008-09-02 07:18:00 UTC (rev 10019)
@@ -0,0 +1,251 @@
+/*******************************************************************************
+ * 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.esb.project.ui.preference.controls;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.jboss.tools.esb.project.ui.preference.messages.JBossESBUIMessages;
+
+/**
+ * @author Grid Qian
+ */
+public abstract class BaseFieldEditor implements IFieldEditor {
+
+ PropertyChangeSupport pcs = new PropertyChangeSupport(this);
+
+ Set<DisposeListener> disposeListeners = new HashSet<DisposeListener>();
+
+ private Object value = new Object();
+
+ private String labelText;
+
+ private String nameText = null;
+
+ Label labelControl = null;
+
+ protected Map<Object, Object> data = null;
+
+ private boolean enabled = true;
+
+ /**
+ *
+ * @param name
+ * @param label
+ * @param defaultValue
+ */
+ public BaseFieldEditor(String name, String label,Object defaultValue) {
+ this.value = defaultValue;
+ this.labelText = label;
+ this.nameText = name;
+ }
+
+ /**
+ *
+ * @param parent
+ */
+ public void doFillIntoGrid(Object parent) {
+ Assert.isTrue(parent instanceof Composite, JBossESBUIMessages.Error_JBossWS_Basic_Editor_Composite);
+ Assert.isTrue(((Composite)parent).getLayout() instanceof GridLayout,JBossESBUIMessages.Error_JBossWS_Basic_Editor_Support);
+ Composite aComposite = (Composite) parent;
+ final Control[] controls = (Control[])getEditorControls(aComposite);
+ GridLayout gl = (GridLayout)((Composite)parent).getLayout();
+
+ doFillIntoGrid(aComposite,gl.numColumns);
+ if(controls.length>0) {
+ controls[0].addDisposeListener(new DisposeListener(){
+ public void widgetDisposed(DisposeEvent e) {
+ dispose();
+ controls[0].removeDisposeListener(this);
+ }
+ });
+ }
+ }
+
+ /**
+ * @param composite
+ * @param numColumns
+ */
+ protected void doFillIntoGrid(Composite composite, int numColumns) {
+
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ /**
+ *
+ * @param parent
+ * @return
+ */
+ public Label createLabelControl(Composite parent) {
+ if(labelControl==null) {
+ labelControl = new Label(parent,SWT.NO_BACKGROUND);
+ labelControl.setText(this.labelText);
+ } else if(parent!=null) {
+ if(labelControl.getParent()!=parent)
+ throw new IllegalArgumentException(JBossESBUIMessages.Error_JBossWS_Basic_Editor_Different);
+ }
+ return labelControl;
+ }
+
+ public Label getLabelControl() {
+ return createLabelControl(null);
+ }
+
+ public abstract Object[] getEditorControls(Object composite);
+
+ public abstract Object[] getEditorControls();
+
+ public Control[] getSwtControls() {
+ return (Control[])getEditorControls();
+ }
+
+ public abstract int getNumberOfControls();
+
+ public Object getValue() {
+ return value;
+ }
+
+ public String getValueAsString() {
+ return getValue().toString();
+ }
+
+ public boolean isEnabled() {
+ return this.enabled ;
+ }
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ Control[] controls = getSwtControls();
+ if(controls==null) {
+ return;
+ }
+ for(int i=0;i<controls.length;i++) {
+ Control control = controls[i];
+ control.setEnabled(enabled);
+ if(control instanceof Composite) {
+ setEnabled((Composite)control, enabled);
+ }
+ }
+ }
+
+ private void setEnabled(Composite composite, boolean enabled) {
+ Control[] controls = composite.getChildren();
+ for(int i=0;i<controls.length;i++) {
+ Control control = controls[i];
+ control.setEnabled(enabled);
+ if(control instanceof Composite) {
+ setEnabled((Composite)control, enabled);
+ }
+ }
+ }
+
+ public boolean setFocus() {
+ return true;
+ }
+
+ /**
+ *
+ * @param newValue
+ */
+ public void setValue(Object newValue) {
+ Object oldValue = value;
+ value = newValue;
+ pcs.firePropertyChange(nameText,oldValue,newValue);
+ }
+
+ public void setValueAsString(String stringValue) {
+ value = stringValue;
+ }
+
+ public String getName() {
+ return nameText;
+ }
+
+ public void dispose() {
+ PropertyChangeListener[] listeners = pcs.getPropertyChangeListeners();
+ for (int i = 0; i < listeners.length; i++) {
+ PropertyChangeListener propertyChangeListener = listeners[i];
+ pcs.removePropertyChangeListener(propertyChangeListener);
+ }
+ }
+
+ public void dispose(DisposeEvent e) {
+ dispose();
+ for (DisposeListener disposeListener : disposeListeners) {
+ disposeListener.widgetDisposed(e);
+ }
+ disposeListeners.clear();
+ }
+
+ public void addDisposeListener(DisposeListener listener) {
+ disposeListeners.add(listener);
+ }
+
+ public void removeDisposeListener(DisposeListener listener) {
+ disposeListeners.remove(listener);
+ }
+
+ public String getLabelText() {
+ return labelText;
+ }
+
+ /**
+ *
+ * @param labelText
+ */
+ public void setLabelText(String labelText) {
+ this.labelText = labelText;
+ }
+
+ private boolean editable = true;
+
+ public boolean isEditable() {
+ return editable;
+ }
+
+ public void setEditable(boolean aEditable) {
+ this.editable = aEditable;
+ }
+
+ public Object getData(Object key) {
+ if(data==null) {
+ return null;
+ }
+ return data.get(key);
+ }
+
+ public void setData(Object key, Object value) {
+ if(data==null) {
+ data = new HashMap<Object, Object>();
+ }
+ data.put(key, value);
+ }
+}
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/ButtonFieldEditor.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/ButtonFieldEditor.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/ButtonFieldEditor.java 2008-09-02 07:18:00 UTC (rev 10019)
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * 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.esb.project.ui.preference.controls;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.jboss.tools.esb.project.ui.preference.messages.JBossESBUIMessages;
+
+/**
+ * @author Grid Qian
+ */
+public class ButtonFieldEditor extends BaseFieldEditor {
+
+ PushButtonField button= null;
+ int style;
+
+ private ButtonPressedAction buttonAction = new ButtonPressedAction(JBossESBUIMessages.JBossWS_Button_Field_Editor_Browse) {
+ @Override
+ public void run() {
+ throw new RuntimeException(JBossESBUIMessages.Error_JBossWS_Button_Field_Editor_Not_Implemented_Yet);
+ }
+ };
+
+ public ButtonFieldEditor(String name, String label, int style) {
+ super(name, label, new Object());
+ this.style = style;
+ }
+
+ public ButtonFieldEditor(String name, ButtonPressedAction action, Object defaultValue) {
+ super(name, action.getText(), defaultValue);
+ buttonAction = action;
+ buttonAction.setFieldEditor(this);
+ }
+
+ @Override
+ public void doFillIntoGrid(Object parent) {
+ }
+
+ @Override
+ public Object[] getEditorControls() {
+ if(button==null) {
+ return null;
+ }
+ return new Control[]{button.getControl()};
+ }
+
+ @Override
+ public boolean isEditable() {
+ return false;
+ }
+
+ public void save(Object object) {
+ }
+
+ @Override
+ public void setEditable(boolean ediatble) {
+ }
+
+ @Override
+ public Object[] getEditorControls(Object composite) {
+ if(button==null && composite!=null) {
+ button = new PushButtonField((Composite)composite, style, buttonAction);
+ setEnabled(isEnabled());
+ }
+ return new Control[]{button.getControl()};
+ }
+
+ public ButtonPressedAction getButtonaction() {
+ return buttonAction;
+ }
+
+ public static class ButtonPressedAction extends Action implements SelectionListener{
+
+ private IFieldEditor editor = null;
+
+ public ButtonPressedAction(String label) {
+ super(label);
+ }
+
+ public void setFieldEditor(IFieldEditor newEditor) {
+ editor = newEditor;
+ }
+
+ public IFieldEditor getFieldEditor() {
+ return editor;
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ run();
+ }
+ }
+
+ @Override
+ public int getNumberOfControls() {
+ return 1;
+ }
+}
\ No newline at end of file
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/CompositeEditor.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/CompositeEditor.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/CompositeEditor.java 2008-09-02 07:18:00 UTC (rev 10019)
@@ -0,0 +1,166 @@
+/*******************************************************************************
+ * 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.esb.project.ui.preference.controls;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.jboss.tools.esb.project.ui.preference.messages.JBossESBUIMessages;
+
+/**
+ * @author Grid Qian
+ */
+public class CompositeEditor extends BaseFieldEditor implements PropertyChangeListener {
+
+ public CompositeEditor(String name, String label, Object defaultValue) {
+ super(name, label, defaultValue);
+ }
+
+ @Override
+ public void doFillIntoGrid(Object parent) {
+ Assert.isTrue(parent instanceof Composite,
+ JBossESBUIMessages.Error_JBossWS_Basic_Editor_Composite);
+ Assert.isTrue(((Composite) parent).getLayout() instanceof GridLayout,
+ JBossESBUIMessages.Error_JBossWS_Basic_Editor_Support);
+
+ Composite aComposite = (Composite) parent;
+ final Control[] controls = (Control[]) getEditorControls(aComposite);
+ GridLayout gl = (GridLayout) ((Composite) parent).getLayout();
+
+ for (int i = 0; i < controls.length; i++) {
+ GridData gd = new GridData();
+ gd.horizontalSpan = i == 1 ? gl.numColumns - controls.length + 1 : 1;
+ if (controls[i] instanceof Combo && i == (controls.length - 1)) {
+ gd.horizontalAlignment = SWT.BEGINNING;
+ } else {
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = (i == 1);
+ }
+
+ controls[i].setLayoutData(gd);
+ controls[i].setEnabled(isEnabled());
+
+ if(i==0) {
+ controls[i].addDisposeListener(new DisposeListener(){
+ public void widgetDisposed(DisposeEvent e) {
+ dispose();
+ controls[0].removeDisposeListener(this);
+ }
+ });
+ }
+ }
+ }
+
+ List<Control> controls = new ArrayList<Control>();
+
+ @Override
+ public Object[] getEditorControls() {
+ if(controls.size()>0) return controls.toArray();
+ else throw new IllegalStateException(JBossESBUIMessages.JBossWS_Composite_Editor_This_Method_Can_Be_Invoked);
+ }
+
+ @Override
+ public Object[] getEditorControls(Object parent) {
+ for (IFieldEditor editor : editors) {
+ controls.addAll(Arrays.asList((Control[])editor.getEditorControls(parent)));
+ }
+ return controls.toArray(new Control[]{});
+ }
+
+ @Override
+ public int getNumberOfControls() {
+ return editors.size();
+ }
+
+ @Override
+ public boolean isEditable() {
+ return true;
+ }
+
+ public void save(Object object) {
+ }
+
+ @Override
+ public void setEditable(boolean ediatble) {
+ }
+
+ List<IFieldEditor> editors = new ArrayList<IFieldEditor>();
+
+ public CompositeEditor addFieldEditors(IFieldEditor[] editors) {
+ this.editors.addAll( Arrays.asList(editors));
+ for (IFieldEditor editor : Arrays.asList(editors)) {
+ editor.addPropertyChangeListener(this);
+ }
+ return this;
+ }
+
+ @Override
+ public void setValue(Object newValue) {
+ for (IFieldEditor editor : editors) {
+ editor.removePropertyChangeListener(this);
+ editor.setValue(newValue);
+ editor.addPropertyChangeListener(this);
+ }
+ super.setValue(newValue);
+ }
+
+ public void propertyChange(PropertyChangeEvent event) {
+ for (IFieldEditor editor : editors) {
+ if(event.getSource()!=editor) {
+ editor.removePropertyChangeListener(this);
+ editor.setValue(event.getNewValue());
+ editor.addPropertyChangeListener(this);
+ }
+ }
+ super.setValue(event.getNewValue());
+ }
+
+ @Override
+ public void setEnabled(boolean set) {
+ for (IFieldEditor editor : editors) {
+ editor.setEnabled(set);
+ }
+ }
+
+ public List<IFieldEditor> getEditors() {
+ return Collections.unmodifiableList(editors);
+ }
+
+ public IFieldEditor getEditorByName(String name) {
+ for (IFieldEditor editor : editors) {
+ if(name.equals(editor.getName())) {
+ return editor;
+ }
+ }
+ return null;
+ }
+
+ public void setData(Object key, Object value) {
+ super.setData(key, value);
+ for (IFieldEditor editor : editors) {
+ editor.setData(key, value);
+ }
+ }
+}
\ No newline at end of file
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/IFieldEditor.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/IFieldEditor.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/IFieldEditor.java 2008-09-02 07:18:00 UTC (rev 10019)
@@ -0,0 +1,106 @@
+/*******************************************************************************
+ * 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.esb.project.ui.preference.controls;
+
+import java.beans.PropertyChangeListener;
+
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+
+/**
+ * @author Grid Qian
+ */
+public interface IFieldEditor extends INamedElement {
+
+ /**
+ *
+ * @param composite
+ */
+ public Object[] getEditorControls(Object composite);
+
+ public Object[] getEditorControls();
+
+ public int getNumberOfControls();
+
+ /**
+ *
+ * @param parent
+ */
+ public void doFillIntoGrid(Object parent);
+
+ /**
+ *
+ * @param listener
+ */
+ public void addPropertyChangeListener(PropertyChangeListener listener);
+
+ /**
+ *
+ * @param listener
+ */
+ public void addDisposeListener(DisposeListener listener);
+
+ /**
+ *
+ * @param listener
+ */
+ public void removeDisposeListener(DisposeListener listener);
+
+ /**
+ *
+ * @param listener
+ */
+ public void removePropertyChangeListener(PropertyChangeListener listener);
+
+ public boolean isEditable();
+
+ /**
+ *
+ * @param aEdiatble
+ */
+ public void setEditable(boolean aEdiatble);
+
+ public boolean setFocus();
+
+ public boolean isEnabled();
+
+ /**
+ *
+ * @param enabled
+ */
+ public void setEnabled(boolean enabled);
+
+ public void dispose();
+
+ /**
+ *
+ * @param e
+ */
+ public void dispose(DisposeEvent e);
+
+ /**
+ * Sets the application defined property of this editor
+ *
+ * @param data
+ * @param key
+ */
+ public void setData(Object key, Object data);
+
+ /**
+ * Gets the application defined property of this editor
+ *
+ * @param key
+ * @return
+ */
+ public Object getData(Object key);
+
+}
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/INamedElement.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/INamedElement.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/INamedElement.java 2008-09-02 07:18:00 UTC (rev 10019)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * 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.esb.project.ui.preference.controls;
+
+/**
+ * @author Grid Qian
+ */
+public interface INamedElement {
+
+ public abstract String getName();
+
+ public abstract Object getValue();
+
+ public abstract void setValue(Object newValue);
+
+ public abstract String getValueAsString();
+
+ public abstract void setValueAsString(String aValue);
+
+}
\ No newline at end of file
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/JBossESBRuntimePreferencePage.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/JBossESBRuntimePreferencePage.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/JBossESBRuntimePreferencePage.java 2008-09-02 07:18:00 UTC (rev 10019)
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * 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.esb.project.ui.preference.controls;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Map;
+
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+import org.jboss.tools.esb.core.runtime.JBossRuntime;
+import org.jboss.tools.esb.core.runtime.JBossRuntimeManager;
+import org.jboss.tools.esb.project.ui.preference.messages.JBossESBUIMessages;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossESBRuntimePreferencePage extends PreferencePage implements
+ IWorkbenchPreferencePage {
+
+ public JBossESBRuntimePreferencePage() {
+ super();
+ noDefaultAndApplyButton();
+ }
+
+ private static final int COLUMNS = 3;
+
+ JBossRuntimeListFieldEditor jbossRuntimes = new JBossRuntimeListFieldEditor(
+ "rtlist", JBossESBUIMessages.JBossWS_Preference_Page_Runtimes, new ArrayList<JBossRuntime>(Arrays.asList(JBossRuntimeManager.getInstance().getRuntimes()))); //$NON-NLS-1$
+
+ /**
+ * Create contents of JBoss ESB preferences page. list editor
+ * is created
+ *
+ * @return Control
+ */
+ @Override
+ protected Control createContents(Composite parent) {
+ Composite root = new Composite(parent, SWT.NONE);
+ GridLayout gl = new GridLayout(COLUMNS, false);
+ root.setLayout(gl);
+ jbossRuntimes.doFillIntoGrid(root);
+
+ return root;
+ }
+
+ /**
+ * Inherited from IWorkbenchPreferencePage
+ *
+ * @param workbench
+ * {@link IWorkbench}
+ *
+ */
+ public void init(IWorkbench workbench) {
+ }
+
+ /**
+ * Save JBossRuntime list
+ */
+ @Override
+ protected void performApply() {
+ for (JBossRuntime rt : jbossRuntimes.getAddedJBossRuntimes()) {
+ JBossRuntimeManager.getInstance().addRuntime(rt);
+ }
+ jbossRuntimes.getAddedJBossRuntimes().clear();
+ for (JBossRuntime rt : jbossRuntimes.getRemoved()) {
+ JBossRuntimeManager.getInstance().removeRuntime(rt);
+ }
+ jbossRuntimes.getRemoved().clear();
+ JBossRuntime defaultRuntime = jbossRuntimes
+ .getDefaultJBossRuntime();
+ // reset default runtime
+ for (JBossRuntime jbossWSRuntime : JBossRuntimeManager
+ .getInstance().getRuntimes()) {
+ jbossWSRuntime.setDefault(false);
+ }
+ // set deafult runtime
+ if (defaultRuntime != null) {
+ defaultRuntime.setDefault(true);
+ }
+ jbossRuntimes.setDefaultJBossRuntime(null);
+ Map<JBossRuntime, JBossRuntime> changed = jbossRuntimes
+ .getChangedJBossRuntimes();
+ for (JBossRuntime c : changed.keySet()) {
+ JBossRuntime o = changed.get(c);
+ o.setHomeDir(c.getHomeDir());
+ o.setVersion(c.getVersion());
+ String oldName = o.getName();
+ String newName = c.getName();
+ if (!oldName.equals(newName)) {
+ JBossRuntimeManager.getInstance().changeRuntimeName(oldName,
+ newName);
+ }
+ o.setDefault(c.isDefault());
+ o.setUserConfigClasspath(c.isUserConfigClasspath());
+ o.setLibraries(c.getLibraries());
+ }
+ jbossRuntimes.getChangedJBossRuntimes().clear();
+
+ JBossRuntimeManager.getInstance().save();
+ }
+
+ /**
+ * Restore original preferences values
+ */
+ @Override
+ protected void performDefaults() {
+ setValid(true);
+ setMessage(null);
+ performApply();
+ }
+
+ /**
+ * See {@link PreferencePage} for details
+ *
+ * @return Boolean
+ */
+ @Override
+ public boolean performOk() {
+ performApply();
+ return super.performOk();
+ }
+
+ public JBossRuntimeListFieldEditor getJBossRuntimes() {
+ return jbossRuntimes;
+ }
+}
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/JBossLibraryListFieldEditor.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/JBossLibraryListFieldEditor.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/JBossLibraryListFieldEditor.java 2008-09-02 07:18:00 UTC (rev 10019)
@@ -0,0 +1,584 @@
+/*******************************************************************************
+ * 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.esb.project.ui.preference.controls;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+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.Display;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
+import org.jboss.tools.esb.core.runtime.JBossRuntime;
+import org.jboss.tools.esb.project.ui.preference.JBossESBUIPlugin;
+import org.jboss.tools.esb.project.ui.preference.messages.JBossESBUIMessages;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossLibraryListFieldEditor extends BaseFieldEditor {
+
+ // ------------------------------------------------------------------------
+ // Layout parameters
+ // ------------------------------------------------------------------------
+
+ static final int GL_COLUMNS = 2;
+ static final int GL_HINT_HEIGHT = 200;
+ static final int TC_DEFAULT_WIDTH = 21;
+ static final int TC_NAME_WIDTH = 100;
+ static final int TC_VERSION_WIDTH = 50;
+ static final int TC_PATH_WIDTH = 100;
+
+ // ------------------------------------------------------------------------
+ // Field declarations
+ // ------------------------------------------------------------------------
+
+ private TreeViewer listView = null;
+
+ private Composite root = null;
+
+ private ActionPanel actionPanel;
+
+ private JBossRuntime tempJbesb;
+
+
+
+
+ private Group jarGroup;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Control for editing JBossRuntime list
+ *
+ * @param name
+ * String
+ * @param label
+ * String
+ * @param defaultValue
+ * Object
+ */
+ public JBossLibraryListFieldEditor(String name, String label,
+ JBossRuntime jbws) {
+ super(name, label, jbws);
+ this.tempJbesb = new JBossRuntime();
+ if(jbws != null){
+ this.tempJbesb.setUserConfigClasspath(jbws.isUserConfigClasspath());
+ this.tempJbesb.getLibraries().addAll(jbws.getLibraries());
+ }
+
+ }
+
+
+ public Object getValue(){
+ return this.tempJbesb;
+ }
+ /**
+ * TBD
+ *
+ * @param composite
+ * Object - instance of Composite
+ * @return Object[]
+ */
+ @Override
+ public Object[] getEditorControls(Object composite) {
+
+ root = new Composite((Composite) composite, SWT.NONE);
+ GridData gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ root.setLayoutData(gd);
+
+ root.setLayout(new GridLayout());
+
+ createCheckButton(root);
+
+ jarGroup = new Group(root, SWT.BORDER);
+ jarGroup.setText("Library Jars");
+ gd = new GridData(GridData.FILL_BOTH);
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+
+
+ jarGroup.setLayoutData(gd);
+ jarGroup.setLayout(new FormLayout());
+
+ createListView(jarGroup);
+ createActionBar(jarGroup);
+
+ FormData listData = new FormData();
+ listData.left = new FormAttachment(0, 5);
+ listData.right = new FormAttachment(actionPanel, -5);
+ listData.top = new FormAttachment(0, 5);
+ listData.bottom = new FormAttachment(100, -5);
+ listView.getControl().setLayoutData(listData);
+
+ FormData actionsData = new FormData();
+ actionsData.top = new FormAttachment(0, 5);
+ actionsData.bottom = new FormAttachment(100, -5);
+ actionsData.right = new FormAttachment(100, -5);
+ actionPanel.setLayoutData(actionsData);
+
+ setJarGroupStatus();
+ return new Control[] { root };
+ }
+
+ protected void createCheckButton(Composite parent){
+ final Button btnDefault = new Button(parent, SWT.CHECK);
+ btnDefault.setText(JBossESBUIMessages.JBossWS_Runtime_Check_Field_Default_Classpath);
+ GridData gd = new GridData();
+ gd.horizontalSpan = 2;
+ btnDefault.setLayoutData(gd);
+
+ btnDefault.setSelection(tempJbesb.isUserConfigClasspath());
+ btnDefault.addSelectionListener(new SelectionAdapter(){
+ public void widgetSelected(SelectionEvent e) {
+ tempJbesb.setUserConfigClasspath(btnDefault.getSelection());
+ setJarGroupStatus();
+ setValue(null);
+ }
+ });
+
+
+ }
+
+ protected void setJarGroupStatus(){
+ boolean isUserConfig = tempJbesb.isUserConfigClasspath();
+ jarGroup.setEnabled(isUserConfig);
+ listView.getTree().setEnabled(isUserConfig);
+ actionPanel.setEnabled(isUserConfig);
+ }
+
+ protected void createListView(Composite parent) {
+ listView = new TreeViewer(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
+ listView.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ listView.setContentProvider(new ITreeContentProvider() {
+
+ public Object[] getElements(Object inputElement) {
+ if (inputElement instanceof JBossRuntime) {
+ return ((JBossRuntime) inputElement).getLibraries().toArray();
+ } else {
+ throw new IllegalArgumentException(
+ JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_Inputelement_Must_Be
+ + JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_An_Instance_Of_List);
+ }
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput,
+ Object newInput) {
+ viewer.refresh();
+ }
+
+ public Object[] getChildren(Object parentElement) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Object getParent(Object element) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+ });
+
+ listView.setLabelProvider(new ILabelProvider() {
+
+ Image jarImg;
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ public void dispose() {
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+ }
+
+ public Image getImage(Object element) {
+ if (jarImg == null){
+ ImageDescriptor jarImgDesc = JBossESBUIPlugin.getImageDescriptor("obj16/jar_obj.gif");
+ jarImg = jarImgDesc.createImage();
+ }
+ return jarImg;
+ }
+
+ public String getText(Object element) {
+ String fullName = (String)element;
+ File jarFile = new File(fullName);
+ return jarFile.getName() + " - " + jarFile.getParentFile().toString();
+ }
+ });
+
+
+ listView.setInput(getValue());
+
+ }
+
+ protected void createActionBar(Composite parent) {
+ actionPanel = new ActionPanel(parent, new BaseAction[] { new AddAction(),
+ new RemoveAction() });
+ listView.addSelectionChangedListener(actionPanel);
+ }
+
+
+
+ /**
+ * Return array of Controls that forms and editor
+ *
+ * @return Control[]
+ */
+ @Override
+ public Object[] getEditorControls() {
+ return new Control[] { root };
+ }
+
+ /**
+ * Return number of controls in editor
+ *
+ * @return int
+ */
+ @Override
+ public int getNumberOfControls() {
+ return 1;
+ }
+
+ /**
+ * Fill wizard page with editors
+ *
+ * @param parent
+ * Composite - parent composite
+ */
+ @Override
+ public void doFillIntoGrid(Object parent) {
+ Assert.isTrue(parent instanceof Composite,
+ JBossESBUIMessages.Error_JBossWS_Basic_Editor_Composite);
+ Assert.isTrue(((Composite) parent).getLayout() instanceof GridLayout,
+ JBossESBUIMessages.Error_JBossWS_Basic_Editor_Support);
+ Composite aComposite = (Composite) parent;
+ getEditorControls(aComposite);
+ GridLayout gl = (GridLayout) ((Composite) parent).getLayout();
+
+ GridData gd = new GridData();
+ gd.horizontalSpan = gl.numColumns;
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalAlignment = GridData.FILL;
+
+ ((Control) getEditorControls()[0]).setLayoutData(gd);
+ }
+
+
+
+ /**
+ * Composite that holds list of BaseActions and presents them as column of
+ * buttons
+ *
+ */
+ public static class ActionPanel extends Composite implements
+ ISelectionChangedListener {
+
+ private BaseAction[] actions = null;
+
+ /**
+ * Constructor creates panel with style, grid layout and buttons
+ * represented the actions
+ *
+ * @param parent
+ * Composite
+ * @param style
+ * int
+ * @param actions
+ * BaseAction[]
+ */
+ public ActionPanel(Composite parent, int style, BaseAction[] actions) {
+ super(parent, style);
+ this.actions = actions;
+ setLayout(new GridLayout(1, false));
+ for (BaseAction action : this.actions) {
+ new ActionButton(this, SWT.PUSH, action);
+ }
+ }
+
+ /**
+ * Constructor creates panel with default style, grid layout and buttons
+ * represented the actions
+ *
+ * @param parent
+ * Composite
+ * @param actions
+ * BaseAction[]
+ */
+ public ActionPanel(Composite parent, BaseAction[] actions) {
+ this(parent, SWT.NONE, actions);
+ }
+
+ /**
+ * Listen to the selection changes and update actions state
+ * (enable/disable)
+ *
+ * @param event
+ * SelectionChangeEvent
+ * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
+ */
+ public void selectionChanged(SelectionChangedEvent event) {
+ for (BaseAction action : actions) {
+ action.setSelection(event.getSelection());
+ }
+ }
+ }
+
+ /**
+ * Class represents an BaseAction as SWT button control and runs action when
+ * button is prtessed
+ *
+ */
+ public static class ActionButton implements IPropertyChangeListener {
+
+ private Button button;
+ private BaseAction action;
+
+ /**
+ * Create Button control with parent control and style that represents
+ * action
+ *
+ * @param parent
+ * Composite
+ * @param style
+ * int
+ * @param action
+ * BaseAction
+ */
+ public ActionButton(Composite parent, int style, BaseAction action) {
+ this.button = new Button(parent, style);
+ this.action = action;
+
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL,
+ GridData.CENTER, false, false);
+
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
+ this.button.setLayoutData(gd);
+ this.action.addPropertyChangeListener(this);
+ this.button.setText(action.getText());
+ this.button.setEnabled(action.isEnabled());
+ this.button.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ ActionButton.this.action.run();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+
+ }
+
+ /**
+ * Return SWT button control that calls provided action
+ *
+ * @return Control - button swt control
+ */
+ public Control getControl() {
+ return button;
+ }
+
+ /**
+ * Update enabled/disabled button state
+ *
+ * @param event
+ * PropertyChangeEvent
+ * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getProperty().equals(IAction.ENABLED)) {
+ button.setEnabled(((Boolean) event.getNewValue())
+ .booleanValue());
+ }
+ }
+ }
+
+ /**
+ * Action that changes state enable/disable based on current table selection
+ *
+ */
+ public abstract class BaseAction extends Action {
+
+ String[] jars = new String[0];
+
+ /**
+ * Constructor creates action with provided name
+ *
+ * @param name
+ * String - action name
+ */
+ public BaseAction(String name) {
+ super(name);
+ updateEnablement();
+ }
+
+ /**
+ * Set current selection
+ *
+ * @param selection
+ * ISelection - selected items
+ */
+ public void setSelection(ISelection selection) {
+ if (selection instanceof IStructuredSelection) {
+ List<String> rts = new ArrayList<String>();
+ for (Object jarfile : ((IStructuredSelection) selection).toArray()) {
+ rts.add((String) jarfile);
+ }
+ jars = rts.toArray(new String[] {});
+ } else {
+ jars = new String[0];
+ }
+ updateEnablement();
+ }
+
+ protected abstract void updateEnablement();
+ }
+
+ /**
+ * Action that invokes New JBossWS Runtime Dialog
+ *
+ */
+ public class AddAction extends BaseAction {
+
+ static final String ACTION_NAME = "&Add";
+
+ /**
+ * Constructor create Add action with default name
+ */
+ public AddAction() {
+ super(ACTION_NAME);
+ // This action is always available
+ setEnabled(true);
+ }
+
+ /**
+ * Do nothing, because Add action should be always available
+ */
+ @Override
+ protected void updateEnablement() {
+ // Add button is always available
+ }
+
+ /**
+ * Invoke New JBossWS Runtime Dialog
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ FileDialog dialog = new FileDialog(Display.getCurrent()
+ .getActiveShell(), SWT.MULTI);
+ dialog.setFilterExtensions(new String[] { "*.jar;*.zip" });
+ String fileName = dialog.open();
+ String[] fileNames = dialog.getFileNames();
+ if (fileName != null) {
+ File filePath = new File(fileName);
+ filePath = filePath.getParentFile();
+ for (int i = 0; i < fileNames.length; i++) {
+ IPath path = new Path(filePath.getAbsolutePath())
+ .append(fileNames[i]);
+ if (!tempJbesb.getLibraries().contains(path.toOSString())) {
+ tempJbesb.getLibraries().add(path.toOSString());
+ }
+ }
+
+ listView.refresh();
+ setValue(null);
+ }
+ }
+ }
+
+
+ /**
+ * Action deletes all selected JBossWS Runtimes. A warning message is shown
+ * for used JBossWS Runtimes
+ *
+ */
+ public class RemoveAction extends BaseAction {
+
+ static final String ACTION_NAME = "&Remove";
+
+ /**
+ * Create DeleteAction action with default name
+ */
+ public RemoveAction() {
+ super(ACTION_NAME);
+ }
+
+ @Override
+ protected void updateEnablement() {
+ setEnabled(jars.length > 0);
+ }
+
+ /**
+ * Remove all selected JBossWS Runtimes one by one
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ for (String jar : jars) {
+ tempJbesb.getLibraries().remove(jar);
+ }
+ listView.refresh();
+ // just try to fire property change listener
+ setValue(null);
+ }
+
+
+ }
+}
\ No newline at end of file
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/JBossRuntimeListFieldEditor.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/JBossRuntimeListFieldEditor.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/JBossRuntimeListFieldEditor.java 2008-09-02 07:18:00 UTC (rev 10019)
@@ -0,0 +1,1143 @@
+/*******************************************************************************
+ * 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.esb.project.ui.preference.controls;
+
+import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FormAttachment;
+import org.eclipse.swt.layout.FormData;
+import org.eclipse.swt.layout.FormLayout;
+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.DirectoryDialog;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.TableColumn;
+import org.jboss.tools.esb.core.runtime.JBossRuntime;
+import org.jboss.tools.esb.core.runtime.JBossRuntimeManager;
+import org.jboss.tools.esb.project.ui.preference.messages.JBossESBUIMessages;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossRuntimeListFieldEditor extends BaseFieldEditor {
+
+ // ------------------------------------------------------------------------
+ // Layout parameters
+ // ------------------------------------------------------------------------
+
+ static final int GL_COLUMNS = 2;
+ static final int GL_HINT_HEIGHT = 200;
+ static final int TC_DEFAULT_WIDTH = 21;
+ static final int TC_NAME_WIDTH = 100;
+ static final int TC_VERSION_WIDTH = 50;
+ static final int TC_PATH_WIDTH = 100;
+
+ // ------------------------------------------------------------------------
+ // Field declarations
+ // ------------------------------------------------------------------------
+
+ private CheckboxTableViewer tableView = null;
+
+ private Composite root = null;
+
+ private ActionPanel actionPanel;
+
+ private Map<JBossRuntime, JBossRuntime> changed = new HashMap<JBossRuntime, JBossRuntime>();
+
+ private JBossRuntime checkedElement = new JBossRuntime();
+
+ private List<JBossRuntime> added = new ArrayList<JBossRuntime>();
+
+ private List<JBossRuntime> removed = new ArrayList<JBossRuntime>();
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Control for editing JBossRuntime list
+ *
+ * @param name
+ * String
+ * @param label
+ * String
+ * @param defaultValue
+ * Object
+ */
+ public JBossRuntimeListFieldEditor(String name, String label,
+ Object defaultValue) {
+ super(name, label, defaultValue);
+ }
+
+ /**
+ * TBD
+ *
+ * @return JBossRuntime;
+ */
+ public JBossRuntime getDefaultJBossRuntime() {
+ return checkedElement;
+ }
+
+ public void setDefaultJBossRuntime(JBossRuntime rt) {
+ checkedElement = rt;
+ }
+
+ /**
+ * TBD
+ *
+ * @return List<JBossRuntime>
+ */
+ public List<JBossRuntime> getAddedJBossRuntimes() {
+ return added;
+ }
+
+ /**
+ * TBD
+ *
+ * @return List<JBossRuntime>
+ */
+ public Map<JBossRuntime, JBossRuntime> getChangedJBossRuntimes() {
+ return changed;
+ }
+
+ /**
+ * TBD
+ *
+ * @return List<JBossRuntime>
+ */
+ public List<JBossRuntime> getRemoved() {
+ return removed;
+ }
+
+ /**
+ * TBD
+ *
+ * @param composite
+ * Object - instance of Composite
+ * @return Object[]
+ */
+ @Override
+ public Object[] getEditorControls(Object composite) {
+
+ root = new Composite((Composite) composite, SWT.NONE);
+ GridData gd = new GridData();
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+ root.setLayoutData(gd);
+
+ root.setLayout(new FormLayout());
+ createTableView();
+ createActionBar();
+
+ FormData tableData = new FormData();
+ tableData.left = new FormAttachment(0, 5);
+ tableData.right = new FormAttachment(actionPanel, -5);
+ tableData.top = new FormAttachment(0, 5);
+ tableData.bottom = new FormAttachment(100, -5);
+ tableView.getControl().setLayoutData(tableData);
+
+ FormData actionsData = new FormData();
+ actionsData.top = new FormAttachment(0, 5);
+ actionsData.bottom = new FormAttachment(100, -5);
+ actionsData.right = new FormAttachment(100, -5);
+ actionPanel.setLayoutData(actionsData);
+ return new Control[] { root };
+ }
+
+ @SuppressWarnings("unchecked")
+ protected void createTableView() {
+ tableView = CheckboxTableViewer.newCheckList(root, SWT.V_SCROLL
+ | SWT.BORDER | SWT.FULL_SELECTION | SWT.SINGLE);
+
+ TableColumn tc1 = new TableColumn(tableView.getTable(), SWT.CENTER);
+ tc1.setWidth(TC_DEFAULT_WIDTH);
+ tc1.setResizable(false);
+
+ TableColumn tc2 = new TableColumn(tableView.getTable(), SWT.LEFT);
+ tc2.setWidth(TC_NAME_WIDTH);
+ tc2.setText(JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_Name);
+
+ TableColumn tc3 = new TableColumn(tableView.getTable(), SWT.LEFT);
+ tc3.setWidth(TC_VERSION_WIDTH);
+ tc3
+ .setText(JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_Version);
+
+ TableColumn tc4 = new TableColumn(tableView.getTable(), SWT.LEFT);
+ tc4.setWidth(TC_PATH_WIDTH);
+ tc4.setText(JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_Path);
+
+ tableView.setContentProvider(new IStructuredContentProvider() {
+
+ public Object[] getElements(Object inputElement) {
+ if (inputElement instanceof List) {
+ return ((List<JBossRuntime>) inputElement).toArray();
+ } else {
+ throw new IllegalArgumentException(
+ JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_Inputelement_Must_Be
+ + JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_An_Instance_Of_List);
+ }
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput,
+ Object newInput) {
+ viewer.refresh();
+ }
+ });
+
+ tableView.setLabelProvider(new ITableLabelProvider() {
+
+ private static final int TC_DEFAULT_NUMBER = 0;
+ private static final int TC_NAME_NUMBER = 1;
+ private static final int TC_VERSION_NUMBER = 2;
+ private static final int TC_PATH_NUMBER = 3;
+
+ public void addListener(ILabelProviderListener listener) {
+ }
+
+ public void dispose() {
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ return false;
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+ }
+
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ JBossRuntime rt = (JBossRuntime) element;
+ if (columnIndex == TC_DEFAULT_NUMBER) {
+ return ""; //$NON-NLS-1$
+ }
+ if (columnIndex == TC_NAME_NUMBER) {
+ return rt.getName();
+ }
+ if (columnIndex == TC_VERSION_NUMBER) {
+ return rt.getVersion().toString();
+ }
+ if (columnIndex == TC_PATH_NUMBER) {
+ return rt.getHomeDir();
+ }
+ return ""; //$NON-NLS-1$
+ }
+ });
+
+ tableView.setInput(getValue());
+ tableView.getTable().setLinesVisible(true);
+ tableView.getTable().setHeaderVisible(true);
+ tableView.addCheckStateListener(new ICheckStateListener() {
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ JBossRuntime selRt = (JBossRuntime) event.getElement();
+ if (event.getChecked()) {
+ JBossRuntime deselRt = null;
+ Object[] selRts = tableView.getCheckedElements();
+
+ for (int i = 0; i < selRts.length; i++) {
+ JBossRuntime rt = (JBossRuntime) selRts[i];
+ if (rt != selRt) {
+ deselRt = rt;
+ break;
+ }
+ }
+
+ if (deselRt != null) {
+ Object[] newChecked = new Object[selRts.length - 1];
+ checkedElement = null;
+ int i = 0;
+ for (Object object : selRts) {
+ JBossRuntime rt = (JBossRuntime) object;
+ if (rt == selRt) {
+ newChecked[i] = rt;
+ checkedElement = rt;
+ i++;
+ }
+ }
+ tableView.setCheckedElements(newChecked);
+ } else {
+ checkedElement = (JBossRuntime) event.getElement();
+ }
+ } else {
+ if (checkedElement == selRt) {
+ checkedElement = null;
+ }
+ }
+ pcs.firePropertyChange(getName(), null, getValue());
+ }
+ });
+
+ for (JBossRuntime rt : (List<JBossRuntime>) getValue()) {
+ if (rt.isDefault()) {
+ tableView.setChecked(rt, true);
+ checkedElement = rt;
+ }
+ }
+ }
+
+ protected void createActionBar() {
+ actionPanel = new ActionPanel(root, new BaseAction[] { new AddAction(),
+ new EditAction(), new RemoveAction() });
+ tableView.addSelectionChangedListener(actionPanel);
+ }
+
+ /**
+ * Checks all runtimes and set default one if user did not do it.
+ */
+ @SuppressWarnings("unchecked")
+ private void setDefaultRuntime() {
+ List<JBossRuntime> runtimes = (List<JBossRuntime>) getValue();
+ boolean checked = false;
+ for (JBossRuntime jbossRuntime : runtimes) {
+
+ if (checkedElement == jbossRuntime) {
+ checked = true;
+ tableView.setChecked(checkedElement, true);
+ break;
+ }
+ }
+ if (!checked && runtimes.size() > 0) {
+ if (tableView.getCheckedElements() == null
+ || tableView.getCheckedElements().length == 0) {
+ tableView.setChecked(runtimes.get(0), true);
+ checkedElement = runtimes.get(0);
+ }
+ }
+
+ }
+
+ /**
+ * Return array of Controls that forms and editor
+ *
+ * @return Control[]
+ */
+ @Override
+ public Object[] getEditorControls() {
+ return new Control[] { root };
+ }
+
+ /**
+ * Return number of controls in editor
+ *
+ * @return int
+ */
+ @Override
+ public int getNumberOfControls() {
+ return 1;
+ }
+
+ /**
+ * Fill wizard page with editors
+ *
+ * @param parent
+ * Composite - parent composite
+ */
+ @Override
+ public void doFillIntoGrid(Object parent) {
+ Assert.isTrue(parent instanceof Composite,
+ JBossESBUIMessages.Error_JBossWS_Basic_Editor_Composite);
+ Assert.isTrue(((Composite) parent).getLayout() instanceof GridLayout,
+ JBossESBUIMessages.Error_JBossWS_Basic_Editor_Support);
+ Composite aComposite = (Composite) parent;
+ getEditorControls(aComposite);
+ GridLayout gl = (GridLayout) ((Composite) parent).getLayout();
+
+ GridData gd = new GridData();
+ gd.horizontalSpan = gl.numColumns;
+ gd.grabExcessHorizontalSpace = true;
+ gd.horizontalAlignment = GridData.FILL;
+
+ ((Control) getEditorControls()[0]).setLayoutData(gd);
+ }
+
+ /**
+ * Wizard page for editing JBossWS Runtime parameters
+ *
+ */
+ public static class JBossWSRuntimeWizardPage extends WizardPage implements
+ PropertyChangeListener {
+
+ private static final String SRT_NAME = "name";
+ private static final String SRT_VERSION = "version";
+ private static final String SRT_HOMEDIR = "homeDir";
+
+ private static final int GL_PARENT_COLUMNS = 1;
+ private static final int GL_CONTENT_COLUMNS = 3;
+
+ List<JBossRuntime> value = null;
+
+ IFieldEditor name = createTextEditor(SRT_NAME,
+ JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_Name2, ""); //$NON-NLS-1$
+
+ IFieldEditor version = createTextEditor(SRT_VERSION,
+ JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_Version, ""); //$NON-NLS-1$
+
+ IFieldEditor homeDir = createBrowseFolderEditor(
+ SRT_HOMEDIR,
+ JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_Home_Folder,
+ ""); //$NON-NLS-1$
+
+ JBossRuntime current = null;
+
+ IFieldEditor jars = null;
+
+ public JBossWSRuntimeWizardPage(List<JBossRuntime> editedList) {
+ super(
+ JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_New_Runtime);
+
+ setMessage(JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_Create_A_Runtime);
+ setTitle(JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_Runtime);
+ value = editedList;
+ }
+
+ /**
+ * Create Wizard page content
+ *
+ * @param parent
+ * Composite - parent composite
+ */
+ public void createControl(Composite parent) {
+ parent.setLayout(new GridLayout(GL_PARENT_COLUMNS, false));
+ GridData dg = new GridData();
+ dg.horizontalAlignment = GridData.FILL;
+ dg.grabExcessHorizontalSpace = true;
+ Composite root = new Composite(parent, SWT.NONE);
+ root.setLayoutData(dg);
+ GridLayout gl = new GridLayout(GL_CONTENT_COLUMNS, false);
+ root.setLayout(gl);
+ name.doFillIntoGrid(root);
+ name.addPropertyChangeListener(this);
+ version.doFillIntoGrid(root);
+ version.addPropertyChangeListener(this);
+ homeDir.doFillIntoGrid(root);
+ homeDir.addPropertyChangeListener(this);
+
+ jars = new JBossLibraryListFieldEditor("", "", current);
+ jars.doFillIntoGrid(root);
+ jars.addPropertyChangeListener(this);
+ setPageComplete(false);
+ setControl(root);
+ }
+
+ /**
+ * Process evt: setup default values based on JBossWS Home folder and
+ * validate user input
+ *
+ * @param evt
+ * PropertyChangeEvent describes changes in wizard
+ */
+ public void propertyChange(java.beans.PropertyChangeEvent evt) {
+ if ("homeDir".equals(evt.getPropertyName())) {
+ if (name.getValueAsString() == null
+ || "".equals(name.getValueAsString().trim())
+ || this.getErrorMessage() != null) {
+ String homeDirName = homeDir.getValueAsString();
+ if (homeDirName != null && !"".equals(homeDirName.trim())) {
+ File folder = new File(homeDirName);
+ homeDirName = folder.getName();
+ }
+ name.setValue(homeDirName);
+ }
+ }
+
+ if (name.getValueAsString() == null || "".equals(//$NON-NLS-1$
+ name.getValueAsString().toString().trim())) {
+ setErrorMessage(JBossESBUIMessages.Error_JBossWS_Runtime_List_Field_Editor_Name_Cannot_Be_Empty);
+ setPageComplete(false);
+ return;
+ }
+
+ if (!name.getValueAsString().matches(
+ "[a-zA-Z_][a-zA-Z0-9_\\-\\. ]*")) { //$NON-NLS-1$
+ setErrorMessage(JBossESBUIMessages.Error_JBossWS_Runtime_List_Field_Editor_Runtime_Name_Is_Not_Correct);
+ setPageComplete(false);
+ return;
+ }
+ for (JBossRuntime rt : value) {
+ if (current != null && current.getName().equals(rt.getName())) {
+ continue;
+ }
+ if (rt.getName().equals(name.getValueAsString())) {
+ setErrorMessage(JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_Runtime
+ + name.getValueAsString()
+ + JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_Already_Exists);
+ setPageComplete(false);
+ return;
+ }
+ }
+
+ JBossRuntime jarJbws = (JBossRuntime) jars.getValue();
+ if (current != null
+ && current.getName().equals(name.getValueAsString())
+ && current.getHomeDir().equals(homeDir.getValueAsString())
+ && current.getVersion().equals(version.getValueAsString())
+ && current.isUserConfigClasspath() == jarJbws
+ .isUserConfigClasspath()
+ && (!jarJbws.isUserConfigClasspath() || hasSameLibraies(
+ current.getLibraries(), jarJbws.getLibraries()))) {
+
+ setErrorMessage(null);
+ setPageComplete(false);
+ return;
+ }
+
+ if (jarJbws.isUserConfigClasspath()
+ && jarJbws.getLibraries().size() == 0) {
+ setErrorMessage("The library must contian at least one jar.");
+ setPageComplete(false);
+ return;
+ }
+
+ if (homeDir.getValueAsString() == null
+ || "".equals(homeDir.getValueAsString().trim())) { //$NON-NLS-1$
+ setErrorMessage(JBossESBUIMessages.Error_JBossWS_Runtime_List_Field_Editor_Path_To_Home_Diretory_Cannot_Be_Empty);
+ setPageComplete(false);
+ return;
+ }
+
+ if (!runtimeExist(homeDir.getValueAsString())) {
+ setErrorMessage(JBossESBUIMessages.Label_JBossWS_Runtime_Load_Error);
+ setPageComplete(false);
+ return;
+ }
+
+ setErrorMessage(null);
+ setPageComplete(true);
+ }
+
+ private boolean hasSameLibraies(List<String> lib1, List<String> lib2) {
+ if (lib1.size() != lib2.size())
+ return false;
+ for (String jar : lib1) {
+ if (!lib2.contains(jar))
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Return JBossWS Runtime instance initialized by user input
+ *
+ * @return JBossRuntime instance
+ */
+ public JBossRuntime getRuntime() {
+ JBossRuntime newRt = new JBossRuntime();
+ newRt.setName(name.getValueAsString());
+ newRt.setVersion(version.getValueAsString());
+ newRt.setHomeDir(homeDir.getValueAsString());
+ JBossRuntime rt = (JBossRuntime) jars.getValue();
+ newRt.setLibraries(rt.getLibraries());
+ newRt.setUserConfigClasspath(rt.isUserConfigClasspath());
+ return newRt;
+ }
+
+ public IFieldEditor createTextEditor(String name, String label,
+ String defaultValue) {
+ CompositeEditor editor = new CompositeEditor(name, label,
+ defaultValue);
+ editor.addFieldEditors(new IFieldEditor[] {
+ new LabelFieldEditor(name, label),
+ new TextFieldEditor(name, label, defaultValue) });
+ return editor;
+ }
+
+ public IFieldEditor createBrowseFolderEditor(String name, String label,
+ String defaultValue) {
+ CompositeEditor editor = new CompositeEditor(name, label,
+ defaultValue);
+ editor
+ .addFieldEditors(new IFieldEditor[] {
+ new LabelFieldEditor(name, label),
+ new TextFieldEditor(name, label, defaultValue),
+ new ButtonFieldEditor(
+ name,
+ createSelectFolderAction(JBossESBUIMessages.JBossWS_SWT_Field_Editor_Factory_Browse),
+ defaultValue) });
+ return editor;
+ }
+
+ public ButtonFieldEditor.ButtonPressedAction createSelectFolderAction(
+ String buttonName) {
+ return new ButtonFieldEditor.ButtonPressedAction(buttonName) {
+ @Override
+ public void run() {
+ DirectoryDialog dialog = new DirectoryDialog(Display
+ .getCurrent().getActiveShell());
+ dialog.setFilterPath(getFieldEditor().getValueAsString());
+ dialog
+ .setMessage(JBossESBUIMessages.JBossWS_SWT_Field_Editor_Factory_Select_Home_Folder);
+ dialog.setFilterPath(getFieldEditor().getValueAsString());
+ String directory = dialog.open();
+ if (directory != null) {
+ getFieldEditor().setValue(directory);
+ }
+ }
+ };
+ }
+
+ private boolean runtimeExist(String path) {
+
+ File jbosswsHomeDir = new File(path);
+ if (!jbosswsHomeDir.isDirectory())
+ return false;
+
+ if(!isValidESBStandaloneRuntimeDir(path)
+ && !isValidESBServer(path)){
+ return false;
+ }
+
+
+ return true;
+ }
+
+ private boolean isValidESBStandaloneRuntimeDir(String path) {
+ IPath location = new Path(path);
+ IPath esblocation = location.append("lib").append("jbossesb.esb");
+ IPath sarLocation = location.append("lib").append("jbossesb.sar");
+ if (!esblocation.toFile().isDirectory()) {
+ return false;
+ }
+ if (!sarLocation.toFile().isDirectory()) {
+ return false;
+ }
+
+ return true;
+ }
+
+ private boolean isValidESBServer(String path){
+ IPath serverLocation = new Path(path);
+
+ String esbLcoationSeg = "server" + File.separator + "default"
+ + File.separator + "deploy" + File.separator
+ + "jbossesb.esb";
+ String sarLocationSeg = "server" + File.separator + "default"
+ + File.separator + "deploy" + File.separator
+ + "jbossesb.sar";
+ IPath esbLocation = serverLocation.append(esbLcoationSeg);
+ IPath sarLocation = serverLocation.append(sarLocationSeg);
+
+ if(!esbLocation.toFile().isDirectory()){
+ return false;
+ }
+ if(!sarLocation.toFile().isDirectory()){
+ return false;
+ }
+
+
+ return true;
+ }
+
+ }
+
+
+
+ /**
+ * Wizard collect information and creates new JBossRuntime instances.
+ *
+ */
+ public static class JBossRuntimeNewWizard extends Wizard {
+
+ JBossWSRuntimeWizardPage page1 = null;
+ List<JBossRuntime> added = null;
+ List<JBossRuntime> value = null;
+
+ public JBossRuntimeNewWizard(List<JBossRuntime> exist,
+ List<JBossRuntime> added) {
+ super();
+ setWindowTitle(JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_New_Runtime);
+ page1 = new JBossWSRuntimeWizardPage(exist);
+ addPage(page1);
+ this.value = exist;
+ this.added = added;
+ }
+
+ /**
+ * Do finish steps
+ *
+ * @return boolean
+ */
+ @Override
+ public boolean performFinish() {
+ JBossRuntime rt = page1.getRuntime();
+ added.add(rt);
+ value.add(rt);
+
+ return true;
+ }
+
+ protected JBossRuntime getRuntime() {
+ return page1.getRuntime();
+ }
+
+ }
+
+ /**
+ * Wizard for editing JBossWS Runtime parameters: name and path to home
+ * folder
+ *
+ */
+ public static class JBossWSRuntimeEditWizard extends Wizard {
+ JBossWSRuntimeWizardPage page1 = null;
+ List<JBossRuntime> added = null;
+ Map<JBossRuntime, JBossRuntime> changed = null;
+ List<JBossRuntime> value = null;
+ JBossRuntime source = null;
+
+ /**
+ * Constructor with almost all initialization parameters
+ *
+ * @param existing
+ * List<JBossRuntime> - edited list of JBossWS
+ * Runtimes
+ * @param source
+ * JBossRuntime - edited JBossWS Runtime
+ * @param added
+ * List<JBossRuntime> - TBD
+ * @param changed
+ * List<JBossRuntime> - TBD
+ */
+ public JBossWSRuntimeEditWizard(List<JBossRuntime> existing,
+ JBossRuntime source, List<JBossRuntime> added,
+ Map<JBossRuntime, JBossRuntime> changed) {
+ super();
+ setWindowTitle(JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_Edit_Runtime);
+ page1 = new JBossWSRuntimeWizardPage(existing);
+ page1
+ .setMessage(JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_Modify_Runtime);
+ page1
+ .setTitle(JBossESBUIMessages.JBossWS_Runtime_List_Field_Editor_Edit_Runtime);
+ addPage(page1);
+ this.value = existing;
+ this.added = added;
+ this.changed = changed;
+ this.source = source;
+ page1.name.setValue(source.getName());
+ page1.version.setValue(source.getVersion());
+ page1.homeDir.setValue(source.getHomeDir());
+ page1.current = source;
+ }
+
+ /**
+ * Perform operations to finish editing JBossWS Runtime parameters
+ *
+ * @return boolean - always true
+ */
+ @Override
+ public boolean performFinish() {
+ JBossRuntime rt = page1.getRuntime();
+
+ if (added.contains(source) || changed.containsKey(source)) {
+ source.setName(rt.getName());
+ source.setHomeDir(rt.getHomeDir());
+ source.setVersion(rt.getVersion());
+ source.setUserConfigClasspath(rt.isUserConfigClasspath());
+ source.setLibraries(rt.getLibraries());
+ } else {
+ changed.put(rt, source);
+ if (source.isDefault()) {
+ rt.setDefault(true);
+ }
+ int i = value.indexOf(source);
+ if (i >= 0) {
+ value.set(i, rt);
+
+ } else {
+ value.remove(source);
+ value.add(rt);
+ }
+ }
+ return true;
+ }
+ }
+
+ /**
+ * Composite that holds list of BaseActions and presents them as column of
+ * buttons
+ *
+ */
+ public static class ActionPanel extends Composite implements
+ ISelectionChangedListener {
+
+ private BaseAction[] actions = null;
+
+ /**
+ * Constructor creates panel with style, grid layout and buttons
+ * represented the actions
+ *
+ * @param parent
+ * Composite
+ * @param style
+ * int
+ * @param actions
+ * BaseAction[]
+ */
+ public ActionPanel(Composite parent, int style, BaseAction[] actions) {
+ super(parent, style);
+ this.actions = actions;
+ setLayout(new GridLayout(1, false));
+ for (BaseAction action : this.actions) {
+ new ActionButton(this, SWT.PUSH, action);
+ }
+ }
+
+ /**
+ * Constructor creates panel with default style, grid layout and buttons
+ * represented the actions
+ *
+ * @param parent
+ * Composite
+ * @param actions
+ * BaseAction[]
+ */
+ public ActionPanel(Composite parent, BaseAction[] actions) {
+ this(parent, SWT.NONE, actions);
+ }
+
+ /**
+ * Listen to the selection changes and update actions state
+ * (enable/disable)
+ *
+ * @param event
+ * SelectionChangeEvent
+ * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
+ */
+ public void selectionChanged(SelectionChangedEvent event) {
+ for (BaseAction action : actions) {
+ action.setSelection(event.getSelection());
+ }
+ }
+ }
+
+ /**
+ * Class represents an BaseAction as SWT button control and runs action when
+ * button is prtessed
+ *
+ */
+ public static class ActionButton implements IPropertyChangeListener {
+
+ private Button button;
+ private BaseAction action;
+
+ /**
+ * Create Button control with parent control and style that represents
+ * action
+ *
+ * @param parent
+ * Composite
+ * @param style
+ * int
+ * @param action
+ * BaseAction
+ */
+ public ActionButton(Composite parent, int style, BaseAction action) {
+ this.button = new Button(parent, style);
+ this.action = action;
+
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL,
+ GridData.CENTER, false, false);
+
+ gd.horizontalAlignment = GridData.FILL;
+ gd.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING;
+ this.button.setLayoutData(gd);
+ this.action.addPropertyChangeListener(this);
+ this.button.setText(action.getText());
+ this.button.setEnabled(action.isEnabled());
+ this.button.addSelectionListener(new SelectionListener() {
+ public void widgetSelected(SelectionEvent e) {
+ ActionButton.this.action.run();
+ }
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+
+ }
+
+ /**
+ * Return SWT button control that calls provided action
+ *
+ * @return Control - button swt control
+ */
+ public Control getControl() {
+ return button;
+ }
+
+ /**
+ * Update enabled/disabled button state
+ *
+ * @param event
+ * PropertyChangeEvent
+ * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+ */
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getProperty().equals(IAction.ENABLED)) {
+ button.setEnabled(((Boolean) event.getNewValue())
+ .booleanValue());
+ }
+ }
+ }
+
+ /**
+ * Action that changes state enable/disable based on current table selection
+ *
+ */
+ public abstract class BaseAction extends Action {
+
+ JBossRuntime[] runtimes = new JBossRuntime[0];
+
+ /**
+ * Constructor creates action with provided name
+ *
+ * @param name
+ * String - action name
+ */
+ public BaseAction(String name) {
+ super(name);
+ updateEnablement();
+ }
+
+ /**
+ * Set current selection
+ *
+ * @param selection
+ * ISelection - selected items
+ */
+ public void setSelection(ISelection selection) {
+ if (selection instanceof IStructuredSelection) {
+ List<JBossRuntime> rts = new ArrayList<JBossRuntime>();
+ for (Object rt : ((IStructuredSelection) selection).toArray()) {
+ rts.add((JBossRuntime) rt);
+ }
+ runtimes = rts.toArray(new JBossRuntime[] {});
+ } else {
+ runtimes = new JBossRuntime[0];
+ }
+ updateEnablement();
+ }
+
+ protected abstract void updateEnablement();
+ }
+
+ /**
+ * Action that invokes New JBossWS Runtime Dialog
+ *
+ */
+ public class AddAction extends BaseAction {
+
+ static final String ACTION_NAME = "&Add";
+
+ /**
+ * Constructor create Add action with default name
+ */
+ public AddAction() {
+ super(ACTION_NAME);
+ // This action is always available
+ setEnabled(true);
+ }
+
+ /**
+ * Do nothing, because Add action should be always available
+ */
+ @Override
+ protected void updateEnablement() {
+ // Add button is always available
+ }
+
+ /**
+ * Invoke New JBossWS Runtime Dialog
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public void run() {
+ Wizard wiz = new JBossRuntimeNewWizard(
+ (List<JBossRuntime>) getValue(), added);
+ WizardDialog dialog = new WizardDialog(Display.getCurrent()
+ .getActiveShell(), wiz);
+ dialog.open();
+ tableView.refresh();
+ setDefaultRuntime();
+ }
+ }
+
+ /**
+ * Action starts an editing selected JBossWS Runtime in Edit JBossWS Runtime
+ * dialog
+ *
+ */
+ public class EditAction extends BaseAction {
+
+ static final String ACTION_NAME = "&Edit";
+
+ /**
+ * Create EditAction with default name
+ *
+ * @param text
+ */
+ public EditAction() {
+ super(ACTION_NAME);
+ }
+
+ /**
+ * Edit action is enabled when the only JBossWS Runtime is selected
+ */
+ @Override
+ protected void updateEnablement() {
+ // available when the only JBossRuntime is selected
+ setEnabled(runtimes.length == 1);
+ }
+
+ /**
+ * Start editing selected JBossWS Runtime in Edit JBossWS Runtime Wizard
+ * Dialog
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public void run() {
+ JBossRuntime selected = runtimes[0];
+ Wizard wiz = new JBossWSRuntimeEditWizard(
+ (List<JBossRuntime>) getValue(), runtimes[0], added,
+ changed);
+ WizardDialog dialog = new WizardDialog(Display.getCurrent()
+ .getActiveShell(), wiz);
+ dialog.open();
+ tableView.refresh();
+ JBossRuntime c = null;
+ if (changed.containsValue(selected)) {
+ c = findChangedRuntime(selected);
+ if (c != null) {
+ tableView.setSelection(new StructuredSelection(c));
+ }
+ }
+ if (c != null && c.isDefault()) {
+ checkedElement = c;
+ }
+ setDefaultRuntime();
+ }
+
+ private JBossRuntime findChangedRuntime(JBossRuntime source) {
+ for (JBossRuntime r : changed.keySet()) {
+ if (source == changed.get(r)) {
+ return r;
+ }
+ }
+ return null;
+ }
+ }
+
+ /**
+ * Action deletes all selected JBossWS Runtimes. A warning message is shown
+ * for used JBossWS Runtimes
+ *
+ */
+ public class RemoveAction extends BaseAction {
+
+ static final String ACTION_NAME = "&Remove";
+
+ /**
+ * Create DeleteAction action with default name
+ */
+ public RemoveAction() {
+ super(ACTION_NAME);
+ }
+
+ @Override
+ protected void updateEnablement() {
+ setEnabled(runtimes.length > 0);
+ }
+
+ /**
+ * Remove all selected JBossWS Runtimes one by one
+ *
+ * @see org.eclipse.jface.action.Action#run()
+ */
+ @Override
+ public void run() {
+ for (JBossRuntime rt : runtimes) {
+ removeRuntime(rt);
+ }
+ tableView.refresh();
+ setDefaultRuntime();
+ }
+
+ @SuppressWarnings("unchecked")
+ private void removeRuntime(JBossRuntime r) {
+ boolean used = JBossRuntimeManager.isRuntimeUsed(r.getName());
+ String title = JBossESBUIMessages.JBossWS_Runtime_Delete_Confirm_Title;
+ String message = (used) ? NLS.bind(
+ JBossESBUIMessages.JBossWS_Runtime_Delete_Used_Confirm, r
+ .getName()) : NLS.bind(
+ JBossESBUIMessages.JBossWS_Runtime_Delete_Not_Used_Confirm,
+ r.getName());
+ boolean b = MessageDialog.openConfirm(tableView.getControl()
+ .getShell(), title, message);
+ if (b) {
+ if (changed.containsKey(r)) {
+ r = changed.remove(r);
+ }
+ removed.add(r);
+ if (added.contains(r)) {
+ added.remove(r);
+ }
+ ((List) getValue()).remove(r);
+ }
+ if (checkedElement == r) {
+ checkedElement = null;
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/LabelFieldEditor.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/LabelFieldEditor.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/LabelFieldEditor.java 2008-09-02 07:18:00 UTC (rev 10019)
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * 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.esb.project.ui.preference.controls;
+
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+
+/**
+ * @author Grid Qian
+ */
+public class LabelFieldEditor extends BaseFieldEditor {
+
+ public LabelFieldEditor(String name, String label) {
+ super(name, label, ""); //$NON-NLS-1$
+ }
+
+ @Override
+ public void doFillIntoGrid(Object parent) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Object[] getEditorControls(Object composite) {
+ // TODO Auto-generated method stub
+ return new Control[]{createLabelControl((Composite)composite)};
+ }
+
+ @Override
+ public Object[] getEditorControls() {
+ return getEditorControls(null);
+ }
+
+ @Override
+ public boolean isEditable() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void save(Object object) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setEditable(boolean ediatble) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public void setValue(Object value) {
+ }
+
+ @Override
+ public int getNumberOfControls() {
+ // TODO Auto-generated method stub
+ return 1;
+ }
+}
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/PushButtonField.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/PushButtonField.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/PushButtonField.java 2008-09-02 07:18:00 UTC (rev 10019)
@@ -0,0 +1,41 @@
+/*******************************************************************************
+ * 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.esb.project.ui.preference.controls;
+
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.jboss.tools.esb.project.ui.preference.controls.ButtonFieldEditor.ButtonPressedAction;
+
+/**
+ * @author Grid Qian
+ *
+ */
+public class PushButtonField extends BaseField {
+
+ Button button;
+
+ /**
+ *
+ */
+ @Override
+ public Control getControl() {
+ return button;
+ }
+
+
+ public PushButtonField(Composite composite, int style, ButtonPressedAction listener) {
+ button = new Button(composite, style);
+ button.setText(listener.getText());
+ button.addSelectionListener(listener);
+ }
+}
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/TextField.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/TextField.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/TextField.java 2008-09-02 07:18:00 UTC (rev 10019)
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * 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.esb.project.ui.preference.controls;
+
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * @author Grid Qian
+ */
+public class TextField extends BaseField implements ModifyListener{
+
+
+ Text textField = null;
+
+ public TextField(Composite parent, int style) {
+ textField = new Text(parent,style);
+ textField.addModifyListener(this);
+ }
+
+ public void modifyText(ModifyEvent e) {
+ firePropertyChange(new Object(),((Text)e.widget).getText().trim());
+ }
+
+ public Text getTextControl() {
+ return textField;
+ }
+
+ public Control getControl() {
+ return getTextControl();
+ }
+}
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/TextFieldEditor.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/TextFieldEditor.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/controls/TextFieldEditor.java 2008-09-02 07:18:00 UTC (rev 10019)
@@ -0,0 +1,210 @@
+/*******************************************************************************
+ * 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.esb.project.ui.preference.controls;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Collection;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Text;
+import org.jboss.tools.esb.project.ui.preference.messages.JBossESBUIMessages;
+
+/**
+ *
+ * @author Grid Qian
+ *
+ */
+public class TextFieldEditor extends BaseFieldEditor implements PropertyChangeListener{
+
+ public static final int UNLIMITED = -1;
+
+ protected int style = -1;
+
+ /**
+ *
+ * @param name
+ * @param aLabelText
+ * @param defaultvalue
+ */
+ public TextFieldEditor(String name,String aLabelText,String defaultvalue) {
+ super(name, aLabelText, defaultvalue);
+ }
+
+ /**
+ *
+ * @param name
+ * @param aLabelText
+ * @param defaultvalue
+ * @param editable
+ */
+ public TextFieldEditor(String name,String aLabelText,String defaultvalue,boolean editable) {
+ super(name, aLabelText, defaultvalue);
+ setEditable(editable);
+ }
+
+ protected TextField fTextField = null;
+
+ protected int fWidthInChars = 0;
+
+ @Override
+ public Object[] getEditorControls() {
+ return new Control[] {getTextControl()};
+ }
+
+ @Override
+ public void doFillIntoGrid(Object aParent) {
+ Assert.isTrue(aParent instanceof Composite, JBossESBUIMessages.Error_JBossWS_Basic_Editor_Composite);
+ Assert.isTrue(((Composite)aParent).getLayout() instanceof GridLayout,JBossESBUIMessages.Error_JBossWS_Basic_Editor_Support);
+ Composite aComposite = (Composite) aParent;
+ getEditorControls(aComposite);
+ GridLayout gl = (GridLayout)((Composite)aParent).getLayout();
+ getTextControl(aComposite);
+
+ GridData gd = new GridData();
+
+ gd.horizontalSpan = gl.numColumns - 1;
+ gd.horizontalAlignment = GridData.FILL;
+ gd.grabExcessHorizontalSpace = true;
+
+ fTextField.getTextControl().setLayoutData(gd);
+ }
+
+ /**
+ *
+ * @param parent
+ * @return
+ */
+ public Text getTextControl(Composite parent) {
+ if (fTextField == null) {
+ fTextField = new TextField(parent, getInitialStyle());
+ Text textField = fTextField.getTextControl();
+ textField.setFont(parent.getFont());
+ textField.setText(getValue().toString());
+ textField.setEditable(isEditable());
+ textField.setEnabled(isEnabled());
+ fTextField.addPropertyChangeListener(this);
+ } else if (parent!=null){
+ Assert.isTrue(parent==fTextField.getTextControl().getParent());
+ }
+ return fTextField.getTextControl();
+ }
+
+ protected void updateWidgetValues() {
+ setValueAsString(getValueAsString());
+ }
+
+ protected int getInitialStyle() {
+ if(this.style >= 0) return style;
+ return SWT.SINGLE | SWT.BORDER;
+ }
+
+ /*
+ * @param value
+ * @return
+ */
+ @SuppressWarnings({ "unchecked", "unused" })
+ private String checkCollection(Object value){
+
+ return value != null && (((Collection)value).size() > 0) ? prepareCollectionToString((Collection)value) : ""; //$NON-NLS-1$
+ }
+
+ /*
+ * @param collection
+ * @return
+ */
+ @SuppressWarnings("unchecked")
+ private String prepareCollectionToString(Collection collection)
+ {
+ String stringValue = ""; //$NON-NLS-1$
+ Object[] objects = collection.toArray();
+ for(int i = 0; i < objects.length; i++){
+ stringValue += objects[i];
+ if(i < objects.length - 1)
+ stringValue += " "; //$NON-NLS-1$
+ }
+ return stringValue;
+ }
+
+
+ /*
+ * @param value
+ * @return
+ */
+ @SuppressWarnings("unused")
+ private String checkSimple(Object value){
+ return (value != null) ? value.toString() : ""; //$NON-NLS-1$
+ }
+
+ @Override
+ public int getNumberOfControls() {
+ return 2;
+ }
+
+ /**
+ * Returns this field editor's text control.
+ *
+ * @return the text control, or <code>null</code> if no
+ * text field is created yet
+ */
+ protected Text getTextControl() {
+ return fTextField!=null?fTextField.getTextControl():null;
+ }
+
+ @Override
+ public boolean setFocus() {
+ boolean setfocus = false;
+ if(fTextField!=null && !fTextField.getTextControl().isDisposed())
+ setfocus = fTextField.getTextControl().setFocus();
+ return setfocus;
+ }
+
+ @Override
+ public Object[] getEditorControls(Object composite) {
+ return new Control[]{getTextControl((Composite)composite)};
+ }
+
+ /**
+ *
+ * @param object
+ */
+ public void save(Object object) {
+ }
+
+ /**
+ *
+ */
+ @Override
+ public void setValue(Object newValue) {
+ super.setValue(newValue);
+ if(fTextField!=null){
+ fTextField.removePropertyChangeListener(this);
+ fTextField.getTextControl().setText(newValue.toString());
+ fTextField.addPropertyChangeListener(this);
+ }
+ }
+
+ @Override
+ public void setEditable(boolean aEditable) {
+ super.setEditable(aEditable);
+ if(getTextControl()!=null) getTextControl().setEditable(aEditable);
+ }
+
+ public void propertyChange(PropertyChangeEvent evt) {
+ super.setValue(evt.getNewValue());
+ }
+}
\ No newline at end of file
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/messages/JBossESBUI.properties
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/messages/JBossESBUI.properties (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/messages/JBossESBUI.properties 2008-09-02 07:18:00 UTC (rev 10019)
@@ -0,0 +1,37 @@
+Label_JBossWS_Runtime_Load_Error=Error occurred while loading JBoss ESB runtime. Please select a correct ESB runtime or SOA-P location
+
+Command=wsconsume.sh
+Bin=bin
+Client=client
+Lib=lib
+Endorsed=endorsed
+
+Error_JBossWS_Basic_Editor_Composite=Parent control should be Composite
+Error_JBossWS_Basic_Editor_Support=Editor supports only grid layout
+Error_JBossWS_Basic_Editor_Different=Parent for label is different
+JBossWS_Runtime_List_Field_Editor_Name=Name
+JBossWS_Runtime_List_Field_Editor_Version=Version
+JBossWS_Runtime_List_Field_Editor_Path=Path
+JBossWS_Runtime_List_Field_Editor_Inputelement_Must_Be=inputElement must be
+JBossWS_Runtime_List_Field_Editor_An_Instance_Of_List=an instance of List<JBossRuntime>.
+JBossWS_Runtime_Delete_Confirm_Title=Confirm Runtime Delete
+JBossWS_Runtime_Delete_Used_Confirm=Runtime ''{0}'' is used by JBoss ESB projects. Are you sure you want to delete it?
+JBossWS_Runtime_Delete_Not_Used_Confirm=Are you sure you want to delete runtime ''{0}''?
+JBossWS_Runtime_List_Field_Editor_Edit_Runtime=Edit JBoss ESB Runtime
+JBossWS_Runtime_List_Field_Editor_Modify_Runtime=Input new values
+JBossWS_Runtime_List_Field_Editor_New_Runtime=New JBoss ESB Runtime
+Error_JBossWS_Runtime_List_Field_Editor_Path_To_Home_Diretory_Cannot_Be_Empty=Path to JBoss ESB runtime home directory cannot be empty
+JBossWS_Runtime_List_Field_Editor_Already_Exists=' already exists
+JBossWS_Runtime_List_Field_Editor_Runtime=JBoss ESB Runtime
+Error_JBossWS_Runtime_List_Field_Editor_Runtime_Name_Is_Not_Correct=Runtime name is not correct
+Error_JBossWS_Runtime_List_Field_Editor_Name_Cannot_Be_Empty=Name cannot be empty
+JBossWS_Runtime_List_Field_Editor_Create_A_Runtime=Create a JBoss ESB Runtime
+JBossWS_Runtime_List_Field_Editor_Home_Folder=Home Folder:
+JBossWS_Composite_Editor_This_Method_Can_Be_Invoked=This metod can be invoked after getEditorControls(parent) only
+JBossWS_Button_Field_Editor_Browse=Browse...
+Error_JBossWS_Button_Field_Editor_Not_Implemented_Yet=Not implemented yet. Please setup real acion for editor.
+JBossWS_SWT_Field_Editor_Factory_Browse=Browse...
+JBossWS_SWT_Field_Editor_Factory_Select_Home_Folder=Select JBoss ESB runtime Home Folder
+JBossWS_Runtime_List_Field_Editor_Name2=Name:
+JBossWS_Runtime_Check_Field_Default_Classpath=Customize JBoss ESB runtime jars
+JBossWS_Preference_Page_Runtimes=JBoss ESB Runtimes
\ No newline at end of file
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/messages/JBossESBUIMessages.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/messages/JBossESBUIMessages.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/preference/messages/JBossESBUIMessages.java 2008-09-02 07:18:00 UTC (rev 10019)
@@ -0,0 +1,70 @@
+/*******************************************************************************
+ * 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.esb.project.ui.preference.messages;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @author Grid Qian
+ */
+public final class JBossESBUIMessages extends NLS {
+
+ private static final String BUNDLE_NAME =
+ "org.jboss.tools.esb.project.ui.preference.messages.JBossESBUI"; //$NON-NLS-1$
+
+ private JBossESBUIMessages() {
+ // Do not instantiate
+ }
+
+ public static String Label_JBossWS_Runtime_Load_Error;
+
+ public static String Bin;
+ public static String Command;
+ public static String Client;
+ public static String Lib;
+ public static String Endorsed;
+
+ public static String Error_JBossWS_Basic_Editor_Composite;
+ public static String Error_JBossWS_Basic_Editor_Support;
+ public static String Error_JBossWS_Basic_Editor_Different;
+ public static String JBossWS_Runtime_List_Field_Editor_Name;
+ public static String JBossWS_Runtime_List_Field_Editor_Version;
+ public static String JBossWS_Runtime_List_Field_Editor_Path;
+ public static String JBossWS_Runtime_List_Field_Editor_Inputelement_Must_Be;
+ public static String JBossWS_Runtime_List_Field_Editor_An_Instance_Of_List;
+ public static String JBossWS_Runtime_Delete_Confirm_Title;
+ public static String JBossWS_Runtime_Delete_Used_Confirm;
+ public static String JBossWS_Runtime_Delete_Not_Used_Confirm;
+ public static String JBossWS_Runtime_List_Field_Editor_Edit_Runtime;
+ public static String JBossWS_Runtime_List_Field_Editor_Modify_Runtime;
+ public static String JBossWS_Runtime_List_Field_Editor_New_Runtime;
+ public static String Error_JBossWS_Runtime_List_Field_Editor_Path_To_Home_Diretory_Cannot_Be_Empty;
+ public static String JBossWS_Runtime_List_Field_Editor_Already_Exists;
+ public static String JBossWS_Runtime_List_Field_Editor_Runtime;
+ public static String Error_JBossWS_Runtime_List_Field_Editor_Runtime_Name_Is_Not_Correct;
+ public static String Error_JBossWS_Runtime_List_Field_Editor_Name_Cannot_Be_Empty;
+ public static String JBossWS_Runtime_List_Field_Editor_Create_A_Runtime;
+ public static String JBossWS_Runtime_List_Field_Editor_Home_Folder;
+ public static String JBossWS_Composite_Editor_This_Method_Can_Be_Invoked;
+ public static String JBossWS_Button_Field_Editor_Browse;
+ public static String Error_JBossWS_Button_Field_Editor_Not_Implemented_Yet;
+ public static String JBossWS_SWT_Field_Editor_Factory_Browse;
+ public static String JBossWS_SWT_Field_Editor_Factory_Select_Home_Folder;
+ public static String JBossWS_Runtime_List_Field_Editor_Name2;
+ public static String JBossWS_Runtime_Check_Field_Default_Classpath;
+ public static String JBossWS_Preference_Page_Runtimes;
+
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, JBossESBUIMessages.class);
+ }
+}
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/utils/UIUtils.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/utils/UIUtils.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/utils/UIUtils.java 2008-09-02 07:18:00 UTC (rev 10019)
@@ -0,0 +1,502 @@
+/*******************************************************************************
+ * 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.esb.project.ui.utils;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * @author Grid Qian
+ */
+public class UIUtils {
+ /**
+ * A default padding value for horizontalResize().
+ */
+ public final static int DEFAULT_PADDING = 35;
+
+ String infoPopid_;
+
+ public UIUtils(String infoPopid) {
+ infoPopid_ = infoPopid;
+ }
+
+ public Button createRadioButton(Composite parent, String labelName,
+ String tooltip, String infopop) {
+ return createButton(SWT.RADIO, parent, labelName, tooltip, infopop);
+ }
+
+ public Button createCheckbox(Composite parent, String labelName,
+ String tooltip, String infopop) {
+ return createButton(SWT.CHECK, parent, labelName, tooltip, infopop);
+ }
+
+ public Button createPushButton(Composite parent, String labelName,
+ String tooltip, String infopop) {
+ return createButton(SWT.NONE, parent, labelName, tooltip, infopop);
+ }
+
+ public Button createButton(int kind, Composite parent, String labelName,
+ String tooltip, String infopop) {
+ Button button = new Button(parent, kind);
+
+ tooltip = tooltip == null ? labelName : tooltip;
+ button.setText(labelName);
+ button.setToolTipText(tooltip);
+
+ if (infopop != null)
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(button,
+ infoPopid_ + "." + infopop);
+
+ return button;
+ }
+
+ public Combo createCombo(Composite parent, String labelName,
+ String tooltip, String infopop, int style) {
+ tooltip = tooltip == null ? labelName : tooltip;
+
+ if (labelName != null) {
+ Label label = new Label(parent, SWT.WRAP);
+ label.setText(labelName);
+ label.setToolTipText(tooltip);
+ }
+
+ Combo combo = new Combo(parent, style);
+ GridData griddata = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.GRAB_HORIZONTAL);
+
+ combo.setLayoutData(griddata);
+ combo.setToolTipText(tooltip);
+
+ if (infopop != null)
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(combo,
+ infoPopid_ + "." + infopop);
+
+ return combo;
+ }
+
+ public Text createText(Composite parent, String labelName, String tooltip,
+ String infopop, int style) {
+ tooltip = tooltip == null ? labelName : tooltip;
+
+ if (labelName != null) {
+ Label label = new Label(parent, SWT.WRAP);
+ label.setText(labelName);
+ label.setToolTipText(tooltip);
+ }
+
+ Text text = new Text(parent, style);
+ GridData griddata = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.GRAB_HORIZONTAL);
+
+ text.setLayoutData(griddata);
+ text.setToolTipText(tooltip);
+
+ if (infopop != null)
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(text,
+ infoPopid_ + "." + infopop);
+
+ return text;
+ }
+
+ public Composite createComposite(Composite parent, int columns) {
+ return createComposite(parent, columns, -1, -1);
+ }
+
+ public Composite createComposite(Composite parent, int columns,
+ int marginHeight, int marginWidth) {
+ Composite composite = new Composite(parent, SWT.NONE);
+
+ GridLayout gridlayout = new GridLayout();
+ gridlayout.numColumns = columns;
+
+ if (marginHeight >= 0)
+ gridlayout.marginHeight = marginHeight;
+ if (marginWidth >= 0)
+ gridlayout.marginWidth = marginWidth;
+
+ composite.setLayout(gridlayout);
+ GridData griddata = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.GRAB_HORIZONTAL);
+ composite.setLayoutData(griddata);
+
+ return composite;
+
+ }
+
+ public Group createGroup(Composite parent, String groupName,
+ String tooltip, String infopop) {
+ return createGroup(parent, groupName, tooltip, infopop, 1, -1, -1);
+ }
+
+ public Group createGroup(Composite parent, String groupName,
+ String tooltip, String infopop, int columns, int marginHeight,
+ int marginWidth) {
+ Group newGroup = new Group(parent, SWT.NONE);
+ GridData griddata = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.GRAB_HORIZONTAL);
+ GridLayout gridlayout = new GridLayout();
+
+ gridlayout.numColumns = columns;
+
+ if (marginHeight >= 0)
+ gridlayout.marginHeight = marginHeight;
+ if (marginWidth >= 0)
+ gridlayout.marginWidth = marginWidth;
+
+ tooltip = tooltip == null ? groupName : tooltip;
+ newGroup.setLayout(gridlayout);
+ newGroup.setText(groupName);
+ newGroup.setLayoutData(griddata);
+ newGroup.setToolTipText(tooltip);
+
+ if (infopop != null)
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(newGroup,
+ infoPopid_ + "." + infopop);
+
+ return newGroup;
+ }
+
+ public Tree createTree(Composite parent, String tooltip, String infopop,
+ int style) {
+
+ tooltip = tooltip == null ? "" : tooltip;
+
+ Tree tree = new Tree(parent, style);
+
+ tree.setLayoutData(createFillAll());
+ tree.setToolTipText(tooltip);
+
+ if (infopop != null)
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(tree,
+ infoPopid_ + "." + infopop);
+
+ return tree;
+
+ }
+
+ public Table createTable(Composite parent, String tooltip, String infopop,
+ int style) {
+
+ tooltip = tooltip == null ? "" : tooltip;
+
+ Table table = new Table(parent, style);
+
+ // table.setLayoutData( createFillAll() );
+ table.setToolTipText(tooltip);
+
+ if (infopop != null)
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(table,
+ infoPopid_ + "." + infopop);
+
+ return table;
+
+ }
+
+ public Label createHorizontalSeparator(Composite parent, int spacing) {
+ Composite composite = createComposite(parent, 1, spacing, -1);
+
+ Label separator = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL);
+
+ GridData griddata = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.GRAB_HORIZONTAL);
+ separator.setLayoutData(griddata);
+
+ return separator;
+ }
+
+ public GridData createFillAll() {
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL
+ | GridData.GRAB_HORIZONTAL | GridData.VERTICAL_ALIGN_FILL
+ | GridData.GRAB_VERTICAL);
+ return data;
+ }
+
+ public void createInfoPop(Control ctrl, String infopop) {
+ if (infopop != null)
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(ctrl,
+ infoPopid_ + "." + infopop);
+ }
+
+ /**
+ * Resizes the width of the target composite so that it is as wide as the
+ * reference composite plus a padding value.
+ *
+ * @param target
+ * The composite to resize.
+ * @param reference
+ * The reference composite
+ * @param padding
+ * The padding value
+ */
+ public void horizontalResize(Composite target, Composite reference,
+ int padding) {
+
+ Point originalSize = target.getSize();
+ Point referenceSize = reference.getSize();
+
+ padding = padding >= 0 ? padding : DEFAULT_PADDING;
+
+ if (referenceSize.x + padding > originalSize.x)
+ target.setSize(referenceSize.x + padding, originalSize.y);
+ }
+
+ public static void writePropertyToFile(File file,String key, String value) throws IOException {
+ Writer out = new BufferedWriter(new OutputStreamWriter(
+ new FileOutputStream(file), "8859_1"));
+ out.write(key+"="+value+"\n");
+ out.close();
+ }
+
+ // file util
+ public static void copyFile(String src, String dest) {
+ InputStream is = null;
+ FileOutputStream fos = null;
+
+ try
+ {
+ is = new FileInputStream(src);
+ fos = new FileOutputStream(dest);
+ int c = 0;
+ byte[] array = new byte[1024];
+ while ((c = is.read(array)) >= 0){
+ fos.write(array, 0, c);
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ finally {
+ try {
+ fos.close();
+ is.close();
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public static File createFileAndParentDirectories(String fileName) throws Exception {
+ File file = new File(fileName);
+ File parent = file.getParentFile();
+ if (!parent.exists()){
+ parent.mkdirs();
+ }
+ file.createNewFile();
+ return file;
+ }
+
+ public static boolean deleteDir(File dir) {
+ if (dir.isDirectory()) {
+ String[] children = dir.list();
+ for (int i=0; i<children.length; i++) {
+ boolean success = deleteDir(new File(dir, children[i]));
+ if (!success) {
+ return false;
+ }
+ }
+ }
+ return dir.delete();
+ }
+
+ public static void deleteDirectories(File dir) {
+ File[] children = dir.listFiles();
+ for (int i = 0; i < children.length; i++){
+ if (children[i].list() != null && children[i].list().length > 0){
+ deleteDirectories(children[i]);
+ }
+ else{
+ children[i].delete();
+ }
+ }
+ dir.delete();
+ }
+
+ public static void deleteDirectories(String dir) {
+ File directory = new File(dir);
+ deleteDirectories(directory);
+ }
+
+ public static void createTargetFile(String sourceFileName, String targetFileName)
+ throws Exception {
+ createTargetFile(sourceFileName, targetFileName, false);
+ }
+
+ public static void createTargetFile(String sourceFileName, String targetFileName,
+ boolean overwrite) throws Exception{
+ File idealResultFile = new File(targetFileName);
+ if (overwrite || !idealResultFile.exists())
+ {
+ createFileAndParentDirectories(targetFileName);
+ copyFile(sourceFileName, targetFileName);
+ }
+ }
+
+ public static boolean createDirectory(String directory){
+ // Create a directory; all ancestor directories must exist
+ boolean success = (new File(directory)).mkdir();
+ if (!success) {
+ // Directory creation failed
+ }
+ return success;
+ }
+
+ public static boolean createDirectorys(String directory){
+ // Create a directory; all ancestor directories must exist
+ boolean success = (new File(directory)).mkdirs();
+ if (!success) {
+ // Directory creation failed
+ }
+ return success;
+ }
+
+ //Copies all files under srcDir to dstDir.
+ // If dstDir does not exist, it will be created.
+ public static void copyDirectory(File srcDir, File dstDir) throws IOException {
+ if (srcDir.isDirectory()) {
+ if (!dstDir.exists()) {
+ dstDir.mkdir();
+ }
+
+ String[] children = srcDir.list();
+ for (int i=0; i<children.length; i++) {
+ copyDirectory(new File(srcDir, children[i]),
+ new File(dstDir, children[i]));
+ }
+ } else {
+ copy(srcDir, dstDir);
+ }
+ }
+
+ //Copies src file to dst file.
+ // If the dst file does not exist, it is created
+ public static void copy(File src, File dst) throws IOException {
+ InputStream in = new FileInputStream(src);
+ OutputStream out = new FileOutputStream(dst);
+
+ // Transfer bytes from in to out
+ byte[] buf = new byte[1024];
+ int len;
+ while ((len = in.read(buf)) > 0) {
+ out.write(buf, 0, len);
+ }
+ in.close();
+ out.close();
+ }
+
+ public static String addAnotherNodeToPath(String currentPath, String newNode) {
+ return currentPath + File.separator + newNode;
+ }
+
+ public static String addNodesToPath(String currentPath, String[] newNode) {
+ String returnPath=currentPath;
+ for (int i = 0; i < newNode.length; i++) {
+ returnPath = returnPath + File.separator + newNode[i];
+ }
+ return returnPath;
+ }
+
+ public static String addNodesToPath(StringBuffer currentPath, String[] pathNodes) {
+ for (int i = 0; i < pathNodes.length; i++){
+ currentPath.append(File.separator);
+ currentPath.append(pathNodes[i]);
+ }
+ return currentPath.toString();
+ }
+
+ public static String addNodesToURL(String currentPath, String[] newNode) {
+ String returnPath=currentPath;
+ for (int i = 0; i < newNode.length; i++) {
+ returnPath = returnPath + "/" + newNode[i];
+ }
+ return returnPath;
+ }
+
+ /**
+ * Get the list of file with a prefix of <code>fileNamePrefix</code> & an extension of
+ * <code>extension</code>
+ *
+ * @param sourceDir The directory in which to search the files
+ * @param fileNamePrefix The prefix to look for
+ * @param extension The extension to look for
+ * @return The list of file with a prefix of <code>fileNamePrefix</code> & an extension of
+ * <code>extension</code>
+ */
+ public static File[] getMatchingFiles(String sourceDir, String fileNamePrefix, String extension) {
+ List<File> fileList = new ArrayList<File>();
+ File libDir = new File(sourceDir);
+ String libDirPath = libDir.getAbsolutePath();
+ String[] items = libDir.list();
+ if (items != null) {
+ for (int i = 0; i < items.length; i++) {
+ String item = items[i];
+ if (fileNamePrefix != null && extension != null) {
+ if (item.startsWith(fileNamePrefix) && item.endsWith(extension)) {
+ fileList.add(new File(libDirPath + File.separator + item));
+ }
+ } else if (fileNamePrefix == null && extension != null) {
+ if (item.endsWith(extension)) {
+ fileList.add(new File(libDirPath + File.separator + item));
+ }
+ } else if (fileNamePrefix != null && extension == null) {
+ if (item.startsWith(fileNamePrefix)) {
+ fileList.add(new File(libDirPath + File.separator + item));
+ }
+ } else {
+ fileList.add(new File(libDirPath + File.separator + item));
+ }
+ }
+ return (File[]) fileList.toArray(new File[fileList.size()]);
+ }
+ return new File[0];
+ }
+
+ /**
+ * Filter out files inside a <code>sourceDir</code> with matching <codefileNamePrefix></code>
+ * and <code>extension</code>
+ * @param sourceDir The directory to filter the files
+ * @param fileNamePrefix The filtering filename prefix
+ * @param extension The filtering file extension
+ */
+ public static void filterOutRestrictedFiles(String sourceDir, String fileNamePrefix, String extension){
+ File[] resultedMatchingFiles = getMatchingFiles(sourceDir, fileNamePrefix, extension);
+ for (int i = 0; i < resultedMatchingFiles.length; i++) {
+ File matchingFilePath = new File(resultedMatchingFiles[i].getAbsolutePath());
+ matchingFilePath.delete();
+ }
+ }
+
+}
\ No newline at end of file
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/ESBProjectWizard.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/ESBProjectWizard.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/ESBProjectWizard.java 2008-09-02 07:18:00 UTC (rev 10019)
@@ -0,0 +1,54 @@
+package org.jboss.tools.esb.project.ui.wizards;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.wizard.IWizardPage;
+import org.eclipse.jst.common.project.facet.IJavaFacetInstallDataModelProperties;
+import org.eclipse.jst.common.project.facet.core.JavaFacet;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties.FacetDataModelMap;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.IFacetedProjectTemplate;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.eclipse.wst.web.ui.internal.wizards.NewProjectDataModelFacetWizard;
+import org.jboss.tools.esb.core.ESBProjectUtilities;
+import org.jboss.tools.esb.project.ui.wizards.pages.ESBProjectFirstPage;
+
+public class ESBProjectWizard extends NewProjectDataModelFacetWizard implements
+ INewWizard {
+
+ public ESBProjectWizard() {
+ setWindowTitle("New ESB Project Wizard");
+ }
+
+ public ESBProjectWizard(IDataModel model) {
+ super(model);
+ setWindowTitle("New ESB Project Wizard");
+
+ }
+
+ @Override
+ protected IDataModel createDataModel() {
+ return DataModelFactory.createDataModel(new JBossESBFacetProjectCreationDataModelProvider());
+ }
+
+ @Override
+ protected IWizardPage createFirstPage() {
+ return new ESBProjectFirstPage(model, "first.page");
+ }
+
+ @Override
+ protected ImageDescriptor getDefaultPageImageDescriptor() {
+ return null;
+ }
+
+ @Override
+ protected IFacetedProjectTemplate getTemplate() {
+ return ProjectFacetsManager.getTemplate(ESBProjectUtilities.ESB_PROJECT_FACET_TEMPLATE);
+ }
+
+
+
+}
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/JBossESBFacetProjectCreationDataModelProvider.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/JBossESBFacetProjectCreationDataModelProvider.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/JBossESBFacetProjectCreationDataModelProvider.java 2008-09-02 07:18:00 UTC (rev 10019)
@@ -0,0 +1,40 @@
+package org.jboss.tools.esb.project.ui.wizards;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jst.common.project.facet.IJavaFacetInstallDataModelProperties;
+import org.eclipse.jst.common.project.facet.JavaFacetInstallDataModelProvider;
+import org.eclipse.wst.common.componentcore.datamodel.FacetProjectCreationDataModelProvider;
+import org.eclipse.wst.common.frameworks.datamodel.DataModelFactory;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.jboss.tools.esb.core.facet.IJBossESBFacetDataModelProperties;
+import org.jboss.tools.esb.core.facet.JBossESBFacetDataModelProvider;
+
+public class JBossESBFacetProjectCreationDataModelProvider extends
+ FacetProjectCreationDataModelProvider {
+
+
+ public void init() {
+ super.init();
+
+ FacetDataModelMap map = (FacetDataModelMap) getProperty(FACET_DM_MAP);
+ IDataModel javaFacet = DataModelFactory.createDataModel(new JavaFacetInstallDataModelProvider());
+ map.add(javaFacet);
+
+ IDataModel esbFacet = DataModelFactory.createDataModel(new JBossESBFacetDataModelProvider());
+ map.add(esbFacet);
+ String esbSrc = esbFacet.getStringProperty(IJBossESBFacetDataModelProperties.ESB_SOURCE_FOLDER);
+ javaFacet.setProperty(IJavaFacetInstallDataModelProperties.SOURCE_FOLDER_NAME, esbSrc);
+
+ }
+
+
+
+ @Override
+ public IStatus validate(String propertyName) {
+
+ return super.validate(propertyName);
+ }
+
+
+
+}
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/pages/ESBFacetInstallationPage.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/pages/ESBFacetInstallationPage.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/pages/ESBFacetInstallationPage.java 2008-09-02 07:18:00 UTC (rev 10019)
@@ -0,0 +1,362 @@
+package org.jboss.tools.esb.project.ui.wizards.pages;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.jst.common.project.facet.JavaFacetUtils;
+import org.eclipse.jst.common.project.facet.core.JavaFacetInstallConfig;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy;
+import org.eclipse.wst.common.project.facet.ui.AbstractFacetWizardPage;
+import org.eclipse.wst.common.project.facet.ui.IFacetWizardPage;
+import org.jboss.tools.esb.core.ESBProjectUtilities;
+import org.jboss.tools.esb.core.facet.IJBossESBFacetDataModelProperties;
+import org.jboss.tools.esb.core.runtime.JBossRuntime;
+import org.jboss.tools.esb.core.runtime.JBossRuntimeManager;
+import org.jboss.tools.esb.project.ui.preference.controls.JBossRuntimeListFieldEditor;
+import org.jboss.tools.esb.project.ui.wizards.ESBProjectWizard;
+
+public class ESBFacetInstallationPage extends AbstractFacetWizardPage implements IFacetWizardPage, IJBossESBFacetDataModelProperties {
+
+ private Label configFolderLabel;
+ private Text configFolder;
+ private Label contextRootLabel;
+ private Text contentFolder;
+ private IDataModel model;
+ private boolean hasValidContentFolder = true;
+ private boolean hasValidSrc = true;
+ private boolean hasRuntime = true;
+ private Combo cmbRuntimes;
+
+ public ESBFacetInstallationPage() {
+ super( "esb.facet.install.page"); //$NON-NLS-1$
+ setTitle("Install ESB Facet");
+ setDescription("Configure project structure and classpath");
+
+ }
+
+ private void setDefaultOutputFolder(){
+ JavaFacetInstallConfig cfg = findJavaFacetInstallConfig();
+ cfg.setDefaultOutputFolder(new Path(ESBProjectUtilities.BUILD_CLASSES));
+ }
+
+ protected Composite createTopLevelComposite(Composite parent) {
+ //setInfopopID(IWstWebUIContextIds.NEW_STATIC_WEB_PROJECT_PAGE3);
+ final Composite composite = new Composite(parent, SWT.NONE);
+ composite.setLayout(new GridLayout(1, false));
+
+ createProjectGroup(composite);
+ createRuntimeGroup(composite);
+
+ setDefaultOutputFolder();
+
+ //synchHelper.synchText(configFolder, CONTENT_DIR, null);
+ Dialog.applyDialogFont(parent);
+
+
+ return composite;
+ }
+
+ private void createProjectGroup(Composite parent){
+
+ Group prjGroup = new Group(parent, SWT.BORDER);
+ prjGroup.setText("Project Folders");
+ prjGroup.setLayout(new GridLayout(1, false));
+ prjGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+
+ this.contextRootLabel = new Label(prjGroup, SWT.NONE);
+ this.contextRootLabel.setText("Content Directory");
+ this.contextRootLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ this.contentFolder = new Text(prjGroup, SWT.BORDER);
+ this.contentFolder.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ this.contentFolder.setData("label", this.contextRootLabel); //$NON-NLS-1$
+ this.contentFolder.setText(model.getStringProperty(ESB_CONTENT_FOLDER));
+ contentFolder.addModifyListener(new ModifyListener(){
+ public void modifyText(ModifyEvent e){
+ String content = contentFolder.getText();
+ if(content != null && !content.equals("")){
+ model.setProperty(ESB_CONTENT_FOLDER, content);
+ }
+ changePageStatus();
+ }
+ });
+
+ configFolderLabel = new Label(prjGroup, SWT.NONE);
+ configFolderLabel.setText("Java Source Directory");
+ configFolderLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ configFolder = new Text(prjGroup, SWT.BORDER);
+ configFolder.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ configFolder.setData("label", configFolderLabel); //$NON-NLS-1$
+ configFolder.setText("src");
+ configFolder.addModifyListener(new ModifyListener(){
+ public void modifyText(ModifyEvent e){
+ String srcFolder = configFolder.getText();
+ if(srcFolder != null && !srcFolder.equals("")){
+ model.setProperty(ESB_SOURCE_FOLDER, srcFolder);
+ setConfigFolder(srcFolder);
+ }
+ changePageStatus();
+ }
+
+ });
+ }
+
+ private void setConfigFolder(String folderName){
+ JavaFacetInstallConfig cfg = findJavaFacetInstallConfig();
+ cfg.setSourceFolder(new Path(folderName));
+ }
+
+
+ private JavaFacetInstallConfig findJavaFacetInstallConfig()
+ {
+ ESBProjectWizard wizard = (ESBProjectWizard)this.getWizard();
+ IDataModel wModel = wizard.getDataModel();
+ final IFacetedProjectWorkingCopy fpjwc
+ = (IFacetedProjectWorkingCopy) wModel.getProperty( FACETED_PROJECT_WORKING_COPY );
+
+ if( fpjwc != null )
+ {
+ final IFacetedProject.Action javaInstallAction
+ = fpjwc.getProjectFacetAction( JavaFacetUtils.JAVA_FACET );
+
+ final Object config = javaInstallAction.getConfig();
+
+ if( config instanceof JavaFacetInstallConfig )
+ {
+ return (JavaFacetInstallConfig) config;
+ }
+ else
+ {
+ return (JavaFacetInstallConfig) Platform.getAdapterManager().getAdapter( config, JavaFacetInstallConfig.class );
+ }
+ }
+
+ return null;
+ }
+
+ private void createRuntimeGroup(Composite parent){
+
+ Group runtimeGroup = new Group(parent, SWT.BORDER);
+ runtimeGroup.setText("JBoss ESB Runtime");
+ runtimeGroup.setLayout(new GridLayout(4, false));
+ runtimeGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ /* Button btnServerSupplied = new Button(runtimeGroup, SWT.RADIO);
+
+ GridData gd = new GridData();
+
+ gd.horizontalSpan = 1;
+ btnServerSupplied.setLayoutData(gd);*/
+
+ /*Label lblServerSupplied = new Label(runtimeGroup, SWT.NONE);
+
+ lblServerSupplied.setText("Server supplied ESB Runtime");
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = 3;
+ lblServerSupplied.setLayoutData(gd);
+
+ Button btnUserSupplied = new Button(runtimeGroup, SWT.RADIO);*/
+
+
+ cmbRuntimes = new Combo(runtimeGroup, SWT.READ_ONLY);
+ cmbRuntimes.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ cmbRuntimes.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ String runtimeName = cmbRuntimes.getText();
+ JBossRuntime jr = (JBossRuntime) cmbRuntimes
+ .getData(runtimeName);
+ saveJBosswsRuntimeToModel(jr);
+ }
+ });
+ initializeRuntimesCombo(cmbRuntimes, null);
+
+ Button btnNew = new Button(runtimeGroup, SWT.NONE);
+ btnNew.setText("New");
+ btnNew.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ newJBossWSRuntime();
+ changePageStatus();
+ }
+ });
+
+
+ }
+
+
+
+ /*
+ * create a new jbossws runtime and set user supplied runtime to the new one
+ */
+ protected void newJBossWSRuntime() {
+ List<JBossRuntime> exists = new ArrayList<JBossRuntime>(Arrays.asList(JBossRuntimeManager.getInstance().getRuntimes()));
+ List<JBossRuntime> added = new ArrayList<JBossRuntime>();
+
+ JBossRuntimeListFieldEditor.JBossRuntimeNewWizard newRtwizard = new JBossRuntimeListFieldEditor.JBossRuntimeNewWizard(
+ exists, added) {
+ public boolean performFinish() {
+ JBossRuntime rt = getRuntime();
+ rt.setDefault(true);
+ JBossRuntimeManager.getInstance().addRuntime(rt);
+ JBossRuntimeManager.getInstance().save();
+
+ return true;
+ }
+ };
+ WizardDialog dialog = new WizardDialog(Display.getCurrent()
+ .getActiveShell(), newRtwizard);
+ if (dialog.open() == WizardDialog.OK) {
+ initializeRuntimesCombo(cmbRuntimes, null);
+ //cmbRuntimes.select(0);
+ }
+ }
+
+ protected void initializeRuntimesCombo(Combo cmRuntime, String runtimeName) {
+ JBossRuntime selectedJbws = null;
+ JBossRuntime defaultJbws = null;
+ int selectIndex = 0;
+ int defaultIndex = 0;
+ cmRuntime.removeAll();
+ JBossRuntime[] runtimes = JBossRuntimeManager.getInstance()
+ .getRuntimes();
+ for (int i = 0; i < runtimes.length; i++) {
+ JBossRuntime jr = runtimes[i];
+ cmRuntime.add(jr.getName());
+ cmRuntime.setData(jr.getName(), jr);
+
+ if(jr.getName().equals(runtimeName)){
+ selectedJbws = jr;
+ selectIndex = i;
+ }
+ // get default jbossws runtime
+ if (jr.isDefault()) {
+ defaultJbws = jr;
+ defaultIndex = i;
+ }
+ }
+
+ if(selectedJbws != null){
+ cmRuntime.select(selectIndex);
+ saveJBosswsRuntimeToModel(selectedJbws);
+ }else if(defaultJbws != null){
+ cmRuntime.select(defaultIndex);
+ saveJBosswsRuntimeToModel(defaultJbws);
+ }
+ }
+
+ protected void saveJBosswsRuntimeToModel(JBossRuntime jbws) {
+ /* String duplicateMsg = "";
+ try {
+ duplicateMsg = ESBProjectUtil.getDuplicateJars(model, jbws.getName());
+ } catch (JavaModelException e1) {
+ JBossESBPlugin.getDefault().getLog().log(
+ StatusUtils.errorStatus(e1));
+ }*/
+ if (jbws != null) {
+ model.setStringProperty(
+ IJBossESBFacetDataModelProperties.RUNTIME_HOME,
+ jbws.getHomeDir());
+ model.setStringProperty(
+ IJBossESBFacetDataModelProperties.RUNTIME_ID, jbws
+ .getName());
+ hasRuntime = true;
+ }else{
+ model.setStringProperty(
+ IJBossESBFacetDataModelProperties.RUNTIME_ID, null);
+ model.setStringProperty(
+ IJBossESBFacetDataModelProperties.RUNTIME_HOME, null);
+ hasRuntime = false;
+ }
+ }
+
+
+
+ private void changePageStatus(){
+ //String duplicateMsg = "";
+ /*try {
+ duplicateMsg = ESBProjectUtil.getDuplicateJars(model, cmbRuntimes.getText());
+ } catch (JavaModelException e1) {
+ JBossESBPlugin.getDefault().getLog().log(
+ StatusUtils.errorStatus(e1));
+ }*/
+
+ if(contentFolder.getText().trim().equals("")){
+ setErrorMessage("Please specify a valid content folder.");
+ hasValidContentFolder = false;
+ setPageComplete(isPageComplete());
+ }
+ else if(configFolder.getText().trim().equals("")){
+ setErrorMessage("Please specify a valid source folder.");
+ hasValidSrc = false;
+ setPageComplete(isPageComplete());
+ }
+ /* else if (!duplicateMsg.equals("")) {
+ setErrorMessage("Duplicated jar on classpath:" + duplicateMsg);
+ }*/
+ else{
+ setErrorMessage(null);
+ hasValidSrc = true;
+ hasValidContentFolder = true;
+ setPageComplete(isPageComplete());
+
+ }
+ }
+
+ @Override
+ public boolean isPageComplete() {
+ return hasValidContentFolder
+ && hasValidSrc
+ && hasRuntime;
+ }
+
+
+ private void fillMessageGroup(Composite parent){
+ Group messageGroup = new Group(parent, SWT.BORDER);
+ messageGroup.setText("Target Message Product");
+ messageGroup.setLayout(new GridLayout(1, false));
+ messageGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ }
+
+
+ public void setConfig(Object config) {
+ this.model = (IDataModel)config;
+ }
+
+
+ public void createControl(Composite parent) {
+
+ setControl(createTopLevelComposite(parent));
+ }
+
+
+ public Object create() throws CoreException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+}
Added: trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/pages/ESBProjectFirstPage.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/pages/ESBProjectFirstPage.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.ui/src/org/jboss/tools/esb/project/ui/wizards/pages/ESBProjectFirstPage.java 2008-09-02 07:18:00 UTC (rev 10019)
@@ -0,0 +1,26 @@
+package org.jboss.tools.esb.project.ui.wizards.pages;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.web.ui.internal.wizards.DataModelFacetCreationWizardPage;
+import org.jboss.tools.esb.core.ESBProjectUtilities;
+
+public class ESBProjectFirstPage extends DataModelFacetCreationWizardPage {
+
+ public ESBProjectFirstPage(IDataModel dataModel, String pageName) {
+ super(dataModel, pageName);
+ setTitle("JBoss ESB Project");
+ setDescription("Create a new JBoss ESB project.");
+ }
+
+ protected String getModuleTypeID() {
+ return ESBProjectUtilities.ESB_PROJECT_FACET;
+ }
+
+ protected void createPresetPanel(Composite top) {
+ new Label(top, SWT.NONE);
+ }
+
+}
15 years, 8 months
JBoss Tools SVN: r10018 - trunk/esb/plugins.
by jbosstools-commits@lists.jboss.org
Author: dennyxu
Date: 2008-09-02 03:17:17 -0400 (Tue, 02 Sep 2008)
New Revision: 10018
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.ui/
Log:
Initial import. Add ESB project facet and wizard
15 years, 8 months
JBoss Tools SVN: r10017 - in trunk/esb/plugins/org.jboss.tools.esb.project.core: .settings and 11 other directories.
by jbosstools-commits@lists.jboss.org
Author: dennyxu
Date: 2008-09-02 03:14:58 -0400 (Tue, 02 Sep 2008)
New Revision: 10017
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.core/.classpath
trunk/esb/plugins/org.jboss.tools.esb.project.core/.project
trunk/esb/plugins/org.jboss.tools.esb.project.core/.settings/
trunk/esb/plugins/org.jboss.tools.esb.project.core/.settings/org.eclipse.jdt.core.prefs
trunk/esb/plugins/org.jboss.tools.esb.project.core/META-INF/
trunk/esb/plugins/org.jboss.tools.esb.project.core/META-INF/MANIFEST.MF
trunk/esb/plugins/org.jboss.tools.esb.project.core/build.properties
trunk/esb/plugins/org.jboss.tools.esb.project.core/plugin.xml
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/ESBCorePlugin.java
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/ESBProjectUtilities.java
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/StatusUtils.java
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/IJBossESBFacetDataModelProperties.java
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/JBossClassPathCommand.java
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/JBossESBFacetDataModelProvider.java
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/JBossESBFacetInstallationDelegate.java
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/UninstallJBossClassPathCommand.java
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/messages/
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/messages/JBossFacetCore.properties
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/messages/JBossFacetCoreMessages.java
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModule.java
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModuleDelegate.java
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModuleFactory.java
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntime.java
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeClassPathInitializer.java
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeListConverter.java
trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeManager.java
Log:
Initial import. Add ESB project facet and wizard
Added: trunk/esb/plugins/org.jboss.tools.esb.project.core/.classpath
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.core/.classpath (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.core/.classpath 2008-09-02 07:14:58 UTC (rev 10017)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/esb/plugins/org.jboss.tools.esb.project.core/.project
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.core/.project (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.core/.project 2008-09-02 07:14:58 UTC (rev 10017)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.esb.project.core</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: trunk/esb/plugins/org.jboss.tools.esb.project.core/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.core/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.core/.settings/org.eclipse.jdt.core.prefs 2008-09-02 07:14:58 UTC (rev 10017)
@@ -0,0 +1,7 @@
+#Wed Aug 27 16:17:18 CST 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
Added: trunk/esb/plugins/org.jboss.tools.esb.project.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.core/META-INF/MANIFEST.MF (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.core/META-INF/MANIFEST.MF 2008-09-02 07:14:58 UTC (rev 10017)
@@ -0,0 +1,34 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %PLUGIN_NAME
+Bundle-SymbolicName: org.jboss.tools.esb.project.core;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Localization: plugin
+Bundle-Activator: org.jboss.tools.esb.core.ESBCorePlugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.wst.common.project.facet.core,
+ org.eclipse.wst.common.frameworks,
+ org.eclipse.core.resources,
+ org.eclipse.jst.ws,
+ org.eclipse.jdt.core,
+ org.eclipse.jdt.launching,
+ org.eclipse.jst.jsf.core,
+ org.eclipse.jst.jsf.ui,
+ org.eclipse.wst.common.modulecore,
+ org.eclipse.jdt.launching,
+ org.eclipse.jst.jsf.core,
+ org.eclipse.jst.jsf.ui,
+ org.eclipse.jdt.launching,
+ org.eclipse.jst.j2ee,
+ org.eclipse.jst.ws.consumption.ui,
+ org.eclipse.jst.common.frameworks;bundle-version="1.1.200",
+ org.eclipse.wst.server.core,
+ org.eclipse.jst.common.project.facet.core;bundle-version="1.3.0"
+Bundle-ActivationPolicy: lazy
+Bundle-Vendor: %PLUGIN_PROVIDER
+Export-Package: org.jboss.tools.esb.core,
+ org.jboss.tools.esb.core.facet,
+ org.jboss.tools.esb.core.messages,
+ org.jboss.tools.esb.core.runtime
+
Added: trunk/esb/plugins/org.jboss.tools.esb.project.core/build.properties
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.core/build.properties (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.core/build.properties 2008-09-02 07:14:58 UTC (rev 10017)
@@ -0,0 +1,5 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
Added: trunk/esb/plugins/org.jboss.tools.esb.project.core/plugin.xml
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.core/plugin.xml (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.core/plugin.xml 2008-09-02 07:14:58 UTC (rev 10017)
@@ -0,0 +1,96 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension
+ point="org.eclipse.wst.common.project.facet.core.facets">
+ <project-facet
+ id="jst.jboss.esb">
+ <label>
+ JBoss ESB
+ </label>
+ </project-facet>
+ <project-facet-version
+ facet="jst.jboss.esb"
+ version="4.2">
+ </project-facet-version>
+ <action
+ facet="jst.jboss.esb"
+ id="jst.jboss.esb.install"
+ type="install">
+ <delegate
+ class="org.jboss.tools.esb.core.facet.JBossESBFacetInstallationDelegate">
+ </delegate>
+ <config-factory
+ class="org.jboss.tools.esb.core.facet.JBossESBFacetDataModelProvider">
+ </config-factory>
+ </action>
+ <project-facet-version
+ facet="jst.jboss.esb"
+ version="4.3">
+ </project-facet-version>
+ <template
+ id="template.jst.jboss.esb">
+ <label>
+ label body text
+ </label>
+ <fixed
+ facet="jst.java">
+ </fixed>
+ <fixed
+ facet="jst.jboss.esb">
+ </fixed>
+ </template>
+ </extension>
+ <extension
+ point="org.eclipse.wst.common.project.facet.core.runtimes">
+ <supported>
+ <facet
+ id="jst.jboss.esb"
+ version="4.2,4.3">
+ </facet>
+ <runtime-component
+ id="org.jboss.ide.eclipse.as.runtime.component"
+ version="4.2">
+ </runtime-component>
+ </supported>
+ </extension>
+ <extension
+ id="ESBNature"
+ name="JBoss ESB Nature"
+ point="org.eclipse.core.resources.natures">
+ <runtime>
+ <run
+ class="org.jboss.tools.esb.project.nature.JBossESBProjectNature">
+ </run>
+ </runtime>
+ <requires-nature
+ id="org.eclipse.wst.common.project.facet.core.nature">
+ </requires-nature>
+ </extension>
+ <extension
+ point="org.eclipse.jdt.core.classpathContainerInitializer">
+ <classpathContainerInitializer
+ class="org.jboss.tools.esb.core.runtime.JBossRuntimeClassPathInitializer"
+ id="org.jboss.esb.runtime.classpath">
+ </classpathContainerInitializer>
+ </extension>
+ <extension
+ point="org.eclipse.wst.server.core.moduleTypes">
+ <moduleType
+ id="jst.jboss.esb"
+ name="JBoss ESB Module">
+ </moduleType>
+ </extension>
+ <extension
+ point="org.eclipse.wst.server.core.moduleFactories">
+ <moduleFactory
+ class="org.jboss.tools.esb.core.module.JBossESBModuleFactory"
+ id="org.jboss.tools.esb.project.core.moduleFactory"
+ projects="true">
+ <moduleType
+ types="jst.jboss.esb"
+ versions="4.2,4.3,4.4">
+ </moduleType>
+ </moduleFactory>
+ </extension>
+</plugin>
Added: trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/ESBCorePlugin.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/ESBCorePlugin.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/ESBCorePlugin.java 2008-09-02 07:14:58 UTC (rev 10017)
@@ -0,0 +1,50 @@
+package org.jboss.tools.esb.core;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class ESBCorePlugin extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.esb.core";
+
+ // The shared instance
+ private static ESBCorePlugin plugin;
+
+ /**
+ * The constructor
+ */
+ public ESBCorePlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static ESBCorePlugin getDefault() {
+ return plugin;
+ }
+
+}
Added: trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/ESBProjectUtilities.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/ESBProjectUtilities.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/ESBProjectUtilities.java 2008-09-02 07:14:58 UTC (rev 10017)
@@ -0,0 +1,10 @@
+package org.jboss.tools.esb.core;
+
+public class ESBProjectUtilities {
+
+ public final static String ESB_PROJECT_FACET = "jst.jboss.esb";
+ public final static String ESB_PROJECT_FACET_TEMPLATE = "template.jst.jboss.esb";
+ public final static String BUILD_CLASSES = "build/classes";
+
+ public final static String ESB_PROJECT_NATURE = "org.jboss.tools.esb.project.ESBNature";
+}
Added: trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/StatusUtils.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/StatusUtils.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/StatusUtils.java 2008-09-02 07:14:58 UTC (rev 10017)
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.esb.core;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Status;
+
+public class StatusUtils
+{
+ public static IStatus errorStatus( String errorMessage )
+ {
+ return new Status( IStatus.ERROR, "id", 0, errorMessage, null );
+ }
+
+ public static IStatus errorStatus( Throwable exc )
+ {
+ String message = exc.getMessage();
+
+ return new Status( IStatus.ERROR, "id", 0, message == null ? "" : message, exc );
+ }
+
+ public static IStatus errorStatus( String message, Throwable exc )
+ {
+ return new Status( IStatus.ERROR, "id", 0, message, exc );
+ }
+
+ public static MultiStatus multiStatus( String message, IStatus[] children, Throwable exc )
+ {
+ return new MultiStatus( "id", 0, children, message, exc );
+ }
+
+ public static MultiStatus multiStatus( String message, IStatus[] children )
+ {
+ return new MultiStatus( "id", 0, children, message, null );
+ }
+
+ public static IStatus warningStatus( String warningMessage )
+ {
+ return new Status( IStatus.WARNING, "id", 0, warningMessage, null );
+ }
+
+ public static IStatus warningStatus( String warningMessage, Throwable exc )
+ {
+ return new Status( IStatus.WARNING, "id", 0, warningMessage, exc );
+ }
+
+ public static IStatus infoStatus( String infoMessage )
+ {
+ return new Status( IStatus.INFO, "id", 0, infoMessage, null );
+ }
+}
\ No newline at end of file
Added: trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/IJBossESBFacetDataModelProperties.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/IJBossESBFacetDataModelProperties.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/IJBossESBFacetDataModelProperties.java 2008-09-02 07:14:58 UTC (rev 10017)
@@ -0,0 +1,37 @@
+package org.jboss.tools.esb.core.facet;
+
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.wst.common.componentcore.datamodel.properties.IFacetProjectCreationDataModelProperties;
+
+public interface IJBossESBFacetDataModelProperties extends IFacetProjectCreationDataModelProperties {
+
+ public static final String USER_DEFINED_LOCATION = "IProjectCreationPropertiesNew.USER_DEFINED_LOCATION"; //$NON-NLS-1$
+ public static final String DEFAULT_LOCATION = "IProjectCreationPropertiesNew.DEFAULT_LOCATION"; //$NON-NLS-1$
+ public static final String USE_DEFAULT_LOCATION = "IProjectCreationPropertiesNew.USE_DEFAULT_LOCATION"; //$NON-NLS-1$
+ public static final String PROJECT_LOCATION = "IProjectCreationPropertiesNew.PROJECT_LOCATION";
+
+ public static final String ESB_CONTENT_FOLDER = "JBoss.Project.Content_Folder";
+ public static final String ESB_SOURCE_FOLDER = "JBoss.Project.Src_Folder";
+
+ public static final QualifiedName QNAME_ESB_CONTENT_FOLDER = new QualifiedName("jboss", ESB_CONTENT_FOLDER);
+ public static final QualifiedName QNAME_ESB_SRC_FOLDER = new QualifiedName("jboss", ESB_SOURCE_FOLDER);
+
+
+
+ public static final String JBOSS_ESB_FACET_ID = "jst.jboss.esb";
+ public static final String RUNTIME_DEPLOY = "jboss.deploy";
+ public static final String QUALIFIEDNAME_IDENTIFIER = "jboss.tools";
+ public static final String RUNTIME_IS_SERVER_SUPPLIED = "jboss.is.server.supplied";
+ public static final String RUNTIME_ID = "jboss.runtime_id";
+
+ public static final String PERSISTENT_PROPERTY_IS_SERVER_SUPPLIED_RUNTIME = "is.server.supplied.runtime";
+ public static final String RUNTIME_HOME = "jboss.runtime.home";
+ public static final String DEFAULT_VALUE_IS_SERVER_SUPPLIED = "1";
+ static QualifiedName PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME = new QualifiedName(QUALIFIEDNAME_IDENTIFIER,
+ RUNTIME_ID);
+ static QualifiedName PERSISTENCE_PROPERTY_RNTIME_LOCATION = new QualifiedName(QUALIFIEDNAME_IDENTIFIER,
+ RUNTIME_HOME);
+ static QualifiedName PERSISTENCE_PROPERTY_SERVER_SUPPLIED_RUNTIME = new QualifiedName(
+ QUALIFIEDNAME_IDENTIFIER,
+ PERSISTENT_PROPERTY_IS_SERVER_SUPPLIED_RUNTIME);
+}
Added: trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/JBossClassPathCommand.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/JBossClassPathCommand.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/JBossClassPathCommand.java 2008-09-02 07:14:58 UTC (rev 10017)
@@ -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.esb.core.facet;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+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.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.common.frameworks.datamodel.AbstractDataModelOperation;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.jboss.tools.esb.core.StatusUtils;
+import org.jboss.tools.esb.core.messages.JBossFacetCoreMessages;
+import org.jboss.tools.esb.core.runtime.JBossRuntimeClassPathInitializer;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossClassPathCommand extends AbstractDataModelOperation {
+
+ IProject project;
+ private IDataModel model;
+
+ public JBossClassPathCommand(IProject project, IDataModel model) {
+ this.project = project;
+ this.model = model;
+ }
+
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info)
+ throws ExecutionException {
+ return executeOverride(monitor);
+ }
+
+ public IStatus executeOverride(IProgressMonitor monitor) {
+ IStatus status = Status.OK_STATUS;
+ try {
+
+ // store runtime name and runtime location to the project
+
+ String runtimeName = model
+ .getStringProperty(IJBossESBFacetDataModelProperties.RUNTIME_ID);
+ String runtimeLocation = model
+ .getStringProperty(IJBossESBFacetDataModelProperties.RUNTIME_HOME);
+ String esbcontentFolder = model.getStringProperty(IJBossESBFacetDataModelProperties.ESB_CONTENT_FOLDER);
+ project
+ .setPersistentProperty(
+ IJBossESBFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME,
+ runtimeName);
+ project
+ .setPersistentProperty(
+ IJBossESBFacetDataModelProperties.PERSISTENCE_PROPERTY_RNTIME_LOCATION,
+ runtimeLocation);
+ project.setPersistentProperty(IJBossESBFacetDataModelProperties.QNAME_ESB_CONTENT_FOLDER, esbcontentFolder);
+ status = addClassPath(project, runtimeName);
+
+
+ } catch (CoreException e) {
+ status = StatusUtils.errorStatus(
+ JBossFacetCoreMessages.Error_Add_Facet_JBossWS, e);
+ }
+ return status;
+ }
+
+ public IStatus addClassPath(IProject project, String segment) {
+ IStatus status = Status.OK_STATUS;
+ try {
+
+ IClasspathEntry newClasspath;
+ IJavaProject javaProject = JavaCore.create(project);
+
+ newClasspath = JavaCore
+ .newContainerEntry(new Path(
+ JBossRuntimeClassPathInitializer.JBOSS_ESB_RUNTIME_CLASSPATH_CONTAINER_ID)
+ .append(segment));
+
+ IClasspathEntry[] oldClasspathEntries = javaProject
+ .readRawClasspath();
+
+ boolean isFolderInClassPathAlready = false;
+ for (int i = 0; i < oldClasspathEntries.length
+ && !isFolderInClassPathAlready; i++) {
+ if (oldClasspathEntries[i].getPath().equals(
+ newClasspath.getPath())) {
+ isFolderInClassPathAlready = true;
+ break;
+ }
+ }
+
+ if (!isFolderInClassPathAlready) {
+
+ IClasspathEntry[] newClasspathEntries = new IClasspathEntry[oldClasspathEntries.length + 1];
+ for (int i = 0; i < oldClasspathEntries.length; i++) {
+ newClasspathEntries[i] = oldClasspathEntries[i];
+ }
+ newClasspathEntries[oldClasspathEntries.length] = newClasspath;
+ javaProject.setRawClasspath(newClasspathEntries,
+ new NullProgressMonitor());
+ }
+ } catch (JavaModelException e) {
+ status = StatusUtils.errorStatus(NLS.bind(
+ JBossFacetCoreMessages.Error_Copy, new String[] { e
+ .getLocalizedMessage() }), e);
+ return status;
+ }
+
+ return status;
+ }
+
+}
\ No newline at end of file
Added: trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/JBossESBFacetDataModelProvider.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/JBossESBFacetDataModelProvider.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/JBossESBFacetDataModelProvider.java 2008-09-02 07:14:58 UTC (rev 10017)
@@ -0,0 +1,64 @@
+package org.jboss.tools.esb.core.facet;
+
+import java.util.Set;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jst.j2ee.internal.J2EEVersionConstants;
+import org.eclipse.jst.j2ee.project.facet.J2EEModuleFacetInstallDataModelProvider;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+
+public class JBossESBFacetDataModelProvider extends J2EEModuleFacetInstallDataModelProvider implements IJBossESBFacetDataModelProperties{
+
+ private static final String JBOSSESB_PROJECT_FACET = "jst.jboss.esb";
+
+ public Set getPropertyNames() {
+ Set names = super.getPropertyNames();
+ names.add(CONFIG_FOLDER);
+ names.add(IJBossESBFacetDataModelProperties.ESB_SOURCE_FOLDER);
+ names.add(IJBossESBFacetDataModelProperties.ESB_CONTENT_FOLDER);
+ names.add(IJBossESBFacetDataModelProperties.ESB_SOURCE_FOLDER);
+ names.add(RUNTIME_ID);
+ names.add(RUNTIME_HOME);
+ return names;
+ }
+
+ public Object getDefaultProperty(String propertyName) {
+ if (propertyName.equals(FACET_ID)) {
+ return JBOSSESB_PROJECT_FACET;
+ }
+ else if(IJBossESBFacetDataModelProperties.ESB_CONTENT_FOLDER.equals(propertyName)){
+ return "esbcontent";
+ }
+ else if(IJBossESBFacetDataModelProperties.ESB_SOURCE_FOLDER.equals(propertyName)){
+ return "src";
+ }
+ else if(propertyName.equals(RUNTIME_ID)){
+ return "";
+ }else if(propertyName.equals(FACET_ID)){
+ return IJBossESBFacetDataModelProperties.JBOSS_ESB_FACET_ID;
+ }
+ return super.getDefaultProperty(propertyName);
+ }
+
+ protected int convertFacetVersionToJ2EEVersion(IProjectFacetVersion version) {
+ return J2EEVersionConstants.J2EE_1_4_ID;
+ }
+
+ public boolean isPropertyEnabled(String propertyName) {
+ return super.isPropertyEnabled(propertyName);
+ }
+
+ public boolean propertySet(String propertyName, Object propertyValue) {
+ boolean status = false;
+ status = super.propertySet(propertyName, propertyValue);
+ return status;
+ }
+
+ public IStatus validate(String propertyName) {
+ return OK_STATUS;
+ }
+
+
+
+
+}
Added: trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/JBossESBFacetInstallationDelegate.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/JBossESBFacetInstallationDelegate.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/JBossESBFacetInstallationDelegate.java 2008-09-02 07:14:58 UTC (rev 10017)
@@ -0,0 +1,127 @@
+package org.jboss.tools.esb.core.facet;
+
+import java.io.ByteArrayInputStream;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jst.common.project.facet.WtpUtils;
+import org.eclipse.jst.common.project.facet.core.ClasspathHelper;
+import org.eclipse.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.IDelegate;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+
+public class JBossESBFacetInstallationDelegate implements IDelegate {
+
+
+ private IDataModel model;
+ public static final String ESB_NATURE = "org.jboss.tools.esb.project.core.ESBNature";
+
+ public void execute(IProject project, IProjectFacetVersion fv,
+ Object config, IProgressMonitor monitor) throws CoreException {
+ model = (IDataModel) config;
+
+ createProjectStructure(project);
+
+ final IJavaProject jproj = JavaCore.create(project);
+
+ // Add WTP natures.
+ WtpUtils.addNatures(project);
+
+ // Setup the flexible project structure.
+ final IVirtualComponent c = ComponentCore.createComponent(project);
+ c.create(0, null);
+ String esbContent = model.getStringProperty(IJBossESBFacetDataModelProperties.ESB_CONTENT_FOLDER);
+ c.setMetaProperty("java-output-path", "/" + esbContent + "/build/classes/");
+
+ final IVirtualFolder jbiRoot = c.getRootFolder();
+
+ // Create directory structure
+ String srcFolder = null;
+ srcFolder = model
+ .getStringProperty(IJBossESBFacetDataModelProperties.ESB_SOURCE_FOLDER);
+ jbiRoot.createLink(new Path("/" + srcFolder), 0, null);
+ String resourcesFolder = model
+ .getStringProperty(IJBossESBFacetDataModelProperties.ESB_CONTENT_FOLDER);
+ jbiRoot.createLink(new Path("/" + resourcesFolder), 0, null);
+
+
+
+ //addESBNature(project);
+
+ String runtimeId = model
+ .getStringProperty(IJBossESBFacetDataModelProperties.RUNTIME_ID);
+ if (runtimeId != null && !runtimeId.equals("")) {
+ JBossClassPathCommand command = new JBossClassPathCommand(project,
+ model);
+ IStatus status = command.executeOverride(monitor);
+ if (!status.equals(Status.OK_STATUS)) {
+ throw new CoreException(status);
+ }
+ }
+
+ ClasspathHelper.removeClasspathEntries(project, fv);
+ ClasspathHelper.addClasspathEntries(project, fv);
+
+ //String prjName = model.getStringProperty(IFacetDataModelProperties.FACET_PROJECT_NAME);
+ //IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(prjName);
+
+
+ }
+
+ private IFile createJBossESBXML(IFolder folder) throws CoreException{
+ StringBuffer emptyESB = new StringBuffer();
+ emptyESB.append("<?xml version = \"1.0\" encoding = \"UTF-8\"?>");
+ emptyESB.append("\n");
+ emptyESB.append("<jbossesb xmlns=\"http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml..." parameterReloadSecs=\"5\">");
+ emptyESB.append("\n");
+ emptyESB.append("</jbossesb>");
+ IFile esbfile = folder.getFile("jboss-esb.xml");
+ esbfile.create(new ByteArrayInputStream(emptyESB.toString().getBytes()), true, null);
+
+ return esbfile;
+ }
+
+
+
+
+ private void createProjectStructure(IProject project) throws CoreException{
+ IFile esbFile = null;
+ String strContentFolder = model.getStringProperty(IJBossESBFacetDataModelProperties.ESB_CONTENT_FOLDER);
+ project.setPersistentProperty(IJBossESBFacetDataModelProperties.QNAME_ESB_CONTENT_FOLDER, strContentFolder);
+ IFolder esbContent = project.getFolder(strContentFolder);
+ if(!esbContent.exists()) {
+ esbContent.create(true, true, null);
+ }
+
+ esbContent.getFolder("lib").create(true, true, null);
+ esbContent.getFolder("META-INF").create(true, true, null);
+ esbFile = createJBossESBXML(esbContent.getFolder("META-INF"));
+
+ project.refreshLocal(IResource.DEPTH_ZERO, null);
+ }
+
+ private static void addESBNature(IProject project) throws CoreException{
+ IProjectDescription desc = project.getDescription();
+ final String[] current = desc.getNatureIds();
+ final String[] replacement = new String[ current.length + 1 ];
+ System.arraycopy( current, 0, replacement, 1, current.length );
+ replacement[ 0 ] = ESB_NATURE;
+ desc.setNatureIds( replacement );
+ project.setDescription( desc, null );
+
+ }
+
+}
Added: trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/UninstallJBossClassPathCommand.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/UninstallJBossClassPathCommand.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/facet/UninstallJBossClassPathCommand.java 2008-09-02 07:14:58 UTC (rev 10017)
@@ -0,0 +1,102 @@
+package org.jboss.tools.esb.core.facet;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+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.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.jboss.tools.esb.core.StatusUtils;
+import org.jboss.tools.esb.core.messages.JBossFacetCoreMessages;
+import org.jboss.tools.esb.core.runtime.JBossRuntimeClassPathInitializer;
+
+public class UninstallJBossClassPathCommand {
+ IProject project;
+
+ public UninstallJBossClassPathCommand(IProject project, IDataModel model) {
+ this.project = project;
+ }
+
+ public IStatus execute(IProgressMonitor monitor, IAdaptable info)
+ throws ExecutionException {
+ return executeOverride(monitor);
+ }
+
+ public IStatus executeOverride(IProgressMonitor monitor) {
+ IStatus status = Status.OK_STATUS;
+ try {
+ boolean isServerSupplied = Boolean
+ .getBoolean(project
+ .getPersistentProperty(IJBossESBFacetDataModelProperties.PERSISTENCE_PROPERTY_SERVER_SUPPLIED_RUNTIME));
+ if (isServerSupplied) {
+// project
+// .getPersistentProperties()
+// .remove(
+// IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_SERVER_SUPPLIED_RUNTIME);
+ } else {
+// project
+// .getPersistentProperties()
+// .remove(
+// IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME);
+// project
+// .getPersistentProperties()
+// .remove(
+// IJBossWSFacetDataModelProperties.PERSISTENCE_PROPERTY_RNTIME_LOCATION);
+ String runtimeName = project
+ .getPersistentProperty(IJBossESBFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME);
+
+ status = removeClassPath(project, runtimeName);
+ }
+
+ } catch (CoreException e) {
+ status = StatusUtils.errorStatus(
+ JBossFacetCoreMessages.Error_Remove_Facet_JBossWS, e);
+ }
+ return status;
+ }
+
+ public IStatus removeClassPath(IProject project, String segment) {
+ IStatus status = Status.OK_STATUS;
+ try {
+ IJavaProject javaProject = JavaCore.create(project);
+ IClasspathEntry[] oldClasspathEntries = javaProject
+ .readRawClasspath();
+
+ boolean isFolderInClassPathAlready = false;
+ List<IClasspathEntry> classpathEntries = new ArrayList<IClasspathEntry>();
+ for (int i = 0; i < oldClasspathEntries.length
+ && !isFolderInClassPathAlready; i++) {
+ if (!oldClasspathEntries[i].getPath().equals(
+ new Path(JBossRuntimeClassPathInitializer.JBOSS_ESB_RUNTIME_CLASSPATH_CONTAINER_ID)
+ .append(segment))) {
+ classpathEntries.add(oldClasspathEntries[i]);
+ }
+ }
+ if (classpathEntries.size() < oldClasspathEntries.length) {
+ javaProject.setRawClasspath(classpathEntries
+ .toArray(new IClasspathEntry[classpathEntries.size()]),
+ new NullProgressMonitor());
+ }
+ } catch (JavaModelException e) {
+ status = StatusUtils.errorStatus(NLS.bind(
+ JBossFacetCoreMessages.Error_Remove_Facet_JBossWS,
+ new String[] { e.getLocalizedMessage() }), e);
+ return status;
+ }
+
+ return status;
+ }
+
+}
Added: trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/messages/JBossFacetCore.properties
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/messages/JBossFacetCore.properties (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/messages/JBossFacetCore.properties 2008-09-02 07:14:58 UTC (rev 10017)
@@ -0,0 +1,14 @@
+Progress_Install_JBossWS_Runtime=JBoss ESB Runtime
+Progress_UnInstall_JBossWS_Runtime=Uninstall JBoss ESB Runtime
+Dir_Lib=lib
+Dir_Client=client
+Dir_Web_Inf=WEB-INF
+Dir_Web_Content=WebContent
+Error_Copy=Exception while copy runtime jars
+ESB_Location=jbossesbruntimelocation
+JBossWS_Runtime=JBoss ESB Runtime
+JBossAS=JBOSS
+Error_WS_Location=The JBoss ESB Runtime Location is NULL
+Error_WS_Classpath=A error comes up when create JBoss ESB runtime Classpath
+Error_Add_Facet_JBossWS=Exception while install JBoss ESB facet
+Error_Remove_Facet_JBossWS=Exception while uninstall JBoss ESB facet
Added: trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/messages/JBossFacetCoreMessages.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/messages/JBossFacetCoreMessages.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/messages/JBossFacetCoreMessages.java 2008-09-02 07:14:58 UTC (rev 10017)
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * 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.esb.core.messages;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossFacetCoreMessages {
+
+ private static final String BUNDLE_NAME = "org.jboss.tools.esb.core.messages.JBossFacetCore"; //$NON-NLS-1$
+
+ private JBossFacetCoreMessages() {
+ // Do not instantiate
+ }
+
+ public static String Progress_Install_JBossWS_Runtime;
+ public static String Progress_UnInstall_JBossWS_Runtime;
+ public static String Dir_Lib;
+ public static String Dir_Client;
+ public static String Dir_Web_Inf;
+ public static String Dir_Web_Content;
+ public static String Error_Copy;
+ public static String ESB_Location;
+ public static String JBossWS_Runtime;
+ public static String JBossAS;
+ public static String Error_WS_Location;
+ public static String Error_WS_Classpath;
+ public static String Error_Add_Facet_JBossWS;
+ public static String Error_Remove_Facet_JBossWS;
+
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, JBossFacetCoreMessages.class);
+ }
+}
\ No newline at end of file
Added: trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModule.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModule.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModule.java 2008-09-02 07:14:58 UTC (rev 10017)
@@ -0,0 +1,73 @@
+package org.jboss.tools.esb.core.module;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.IModuleType;
+import org.eclipse.wst.server.core.ServerCore;
+import org.eclipse.wst.server.core.ServerUtil;
+import org.eclipse.wst.server.core.internal.ModuleFactory;
+import org.eclipse.wst.server.core.internal.ModuleType;
+import org.eclipse.wst.server.core.model.ModuleDelegate;
+import org.eclipse.wst.server.core.model.ModuleFactoryDelegate;
+import org.jboss.tools.esb.core.ESBProjectUtilities;
+
+public class JBossESBModule implements IModule{
+
+ private IProject project;
+ private ModuleFactoryDelegate factory;
+ private String factoryId;
+ public JBossESBModule(IProject project, ModuleFactoryDelegate factory, String factoryId){
+ this.project = project;
+ this.factory = factory;
+ this.factoryId = factoryId;
+
+ }
+ public Object getAdapter(Class adapter) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getId() {
+ return factoryId + ":" + project.getName();
+ }
+
+ public IModuleType getModuleType() {
+ IFacetedProject facetPrj;
+ try {
+ facetPrj = ProjectFacetsManager.create(project);
+ final IProjectFacet esbfacet = ProjectFacetsManager.getProjectFacet(ESBProjectUtilities.ESB_PROJECT_FACET);
+ final IProjectFacetVersion fv = facetPrj.getInstalledVersion(esbfacet);
+ return ModuleType.getModuleType(esbfacet.getId(), fv.getVersionString());
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+
+ public String getName() {
+ return project.getName();
+ }
+
+ public IProject getProject() {
+ return project;
+ }
+
+ public boolean isExternal() {
+ return false;
+ }
+
+ public Object loadAdapter(Class adapter, IProgressMonitor monitor) {
+ ModuleDelegate delegate = factory.getModuleDelegate(this);
+ if(adapter.isInstance(delegate))
+ return delegate;
+ return null;
+ }
+
+}
Added: trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModuleDelegate.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModuleDelegate.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModuleDelegate.java 2008-09-02 07:14:58 UTC (rev 10017)
@@ -0,0 +1,85 @@
+package org.jboss.tools.esb.core.module;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.internal.core.JavaProject;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.internal.ModuleResourceDelta;
+import org.eclipse.wst.server.core.model.IModuleResource;
+import org.eclipse.wst.server.core.model.ModuleDelegate;
+import org.eclipse.wst.server.core.util.ModuleFile;
+import org.eclipse.wst.server.core.util.ModuleFolder;
+import org.eclipse.wst.server.core.util.ProjectModule;
+import org.jboss.tools.esb.core.facet.IJBossESBFacetDataModelProperties;
+
+public class JBossESBModuleDelegate extends ProjectModule {
+
+ public JBossESBModuleDelegate(IProject project){
+ super(project);
+ }
+ @Override
+ public IModule[] getChildModules() {
+ return null;
+ }
+
+ public IModuleResource[] members() throws CoreException {
+ IProject project = getProject();
+ String esbFolder = (String)project.getPersistentProperty(IJBossESBFacetDataModelProperties.QNAME_ESB_CONTENT_FOLDER);
+ IFolder configFolder = project.getFolder(esbFolder);
+ IJavaProject javaPrj = JavaCore.create(project);
+ IPath output = javaPrj.getOutputLocation();
+ IModuleResource[] esbContent = getModuleResources(Path.EMPTY, configFolder);
+ IModuleResource[] classes = getModuleResources(Path.EMPTY, project.getWorkspace().getRoot().getFolder(output));
+ IModuleResource[] allResource = new IModuleResource[esbContent.length + classes.length];
+ System.arraycopy(esbContent, 0, allResource, 0, esbContent.length);
+ System.arraycopy(classes, 0, allResource, esbContent.length, classes.length);
+ return allResource;
+ }
+
+ @Override
+ public IStatus validate() {
+ return null;
+ }
+
+ @Override
+ protected IModuleResource[] getModuleResources(IPath path, IContainer container) throws CoreException {
+
+ IResource[] resources = container.members();
+ if (resources != null) {
+ int size = resources.length;
+ List<IModuleResource> list = new ArrayList<IModuleResource>(size);
+ for (int i = 0; i < size; i++) {
+ IResource resource = resources[i];
+ if (resource != null && resource.exists()) {
+ String name = resource.getName();
+ if (resource instanceof IContainer) {
+ IContainer container2 = (IContainer) resource;
+ ModuleFolder mf = new ModuleFolder(container2, name, path);
+ mf.setMembers(getModuleResources(path.append(name), container2));
+ list.add(mf);
+ } else if (resource instanceof IFile) {
+ list.add(new ModuleFile((IFile) resource, name, path));
+ }
+ }
+ }
+ IModuleResource[] moduleResources = new IModuleResource[list.size()];
+ list.toArray(moduleResources);
+ return moduleResources;
+ }
+ return new IModuleResource[0];
+ }
+
+
+}
Added: trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModuleFactory.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModuleFactory.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/module/JBossESBModuleFactory.java 2008-09-02 07:14:58 UTC (rev 10017)
@@ -0,0 +1,44 @@
+package org.jboss.tools.esb.core.module;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.eclipse.wst.server.core.IModule;
+import org.eclipse.wst.server.core.model.ModuleDelegate;
+import org.eclipse.wst.server.core.util.ProjectModule;
+import org.eclipse.wst.server.core.util.ProjectModuleFactoryDelegate;
+import org.jboss.tools.esb.core.ESBProjectUtilities;
+
+public class JBossESBModuleFactory extends ProjectModuleFactoryDelegate {
+
+ public JBossESBModuleFactory() {
+ }
+
+ @Override
+ public ModuleDelegate getModuleDelegate(IModule module) {
+ if(module instanceof JBossESBModule){
+ IProject project = module.getProject();
+ return new JBossESBModuleDelegate(project);
+ }
+ return null;
+ }
+
+ protected IModule[] createModules(IProject project) {
+ IFacetedProject facetProject;
+ try {
+ facetProject = ProjectFacetsManager.create(project);
+ IProjectFacet esbFacet = ProjectFacetsManager.getProjectFacet(ESBProjectUtilities.ESB_PROJECT_FACET);
+ if(facetProject.hasProjectFacet(esbFacet)){
+ JBossESBModule module = new JBossESBModule(project, this, this.getId());
+ return new IModule[]{ module };
+ }
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ return null;
+
+ }
+
+}
Added: trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntime.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntime.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntime.java 2008-09-02 07:14:58 UTC (rev 10017)
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * 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.esb.core.runtime;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossRuntime {
+
+ String name = null;
+
+ String homeDir = null;
+
+ String version = null;
+
+ boolean defaultRt = false;
+
+ List<String> libraries;
+
+ private boolean userConfigClasspath;
+
+ /**
+ * Default constructor
+ */
+ public JBossRuntime() {
+ libraries = new ArrayList<String>();
+ }
+
+ /**
+ * Get JBossWSRuntime name
+ *
+ * @return name
+ */
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Get path to home directory
+ *
+ * @return home directory path as string
+ */
+ public String getHomeDir() {
+ return homeDir;
+ }
+
+ /**
+ * Set JBossWSRuntime name
+ *
+ * @param name
+ * new JBossWSRuntime name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Set home directory
+ *
+ * @param homeDir
+ * new JBossWSRuntime's home directory
+ */
+ public void setHomeDir(String homeDir) {
+ this.homeDir = homeDir;
+ }
+
+ /**
+ * Mark runtime as default
+ *
+ * @param b
+ * new value for default property
+ */
+ public void setDefault(boolean b) {
+ this.defaultRt = b;
+ }
+
+ /**
+ * Get default flag
+ *
+ * @return default property
+ */
+ public boolean isDefault() {
+ return defaultRt;
+ }
+
+ public List<String> getLibraries(){
+
+ return this.libraries;
+ }
+
+ public void setLibraries(List<String> libraries){
+ this.libraries = libraries;
+ }
+
+ public boolean isUserConfigClasspath(){
+ return this.userConfigClasspath;
+ }
+
+ public void setUserConfigClasspath(boolean userConfigClasspath){
+ this.userConfigClasspath = userConfigClasspath;
+ }
+
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+}
Added: trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeClassPathInitializer.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeClassPathInitializer.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeClassPathInitializer.java 2008-09-02 07:14:58 UTC (rev 10017)
@@ -0,0 +1,129 @@
+/*******************************************************************************
+ * 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.esb.core.runtime;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.ClasspathContainerInitializer;
+import org.eclipse.jdt.core.IClasspathContainer;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.jboss.tools.esb.core.messages.JBossFacetCoreMessages;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossRuntimeClassPathInitializer extends
+ ClasspathContainerInitializer {
+
+ public final static String JBOSS_ESB_RUNTIME_CLASSPATH_CONTAINER_ID = "org.jboss.esb.runtime.classpath";
+ public JBossRuntimeClassPathInitializer() {
+ }
+
+ private String segment;
+
+ @Override
+ public void initialize(IPath containerPath, IJavaProject project)
+ throws CoreException {
+
+ if (containerPath.segment(0).equals(
+ JBOSS_ESB_RUNTIME_CLASSPATH_CONTAINER_ID)) {
+ JBossRuntimeClasspathContainer container = new JBossRuntimeClasspathContainer(
+ containerPath);
+ segment = containerPath.segment(1);
+ JavaCore.setClasspathContainer(containerPath,
+ new IJavaProject[] { project },
+ new IClasspathContainer[] { container }, null);
+ }
+ }
+
+ public IClasspathEntry[] getEntries(IPath path) {
+ return new JBossRuntimeClasspathContainer(path).getClasspathEntries();
+ }
+
+ public class JBossRuntimeClasspathContainer implements
+ IClasspathContainer {
+ private IPath path;
+ private IClasspathEntry[] entries = null;
+
+ public JBossRuntimeClasspathContainer(IPath path) {
+ this.path = path;
+ }
+
+ public String getDescription() {
+ return JBossFacetCoreMessages.JBossWS_Runtime;
+ }
+
+ public int getKind() {
+ return IClasspathContainer.K_APPLICATION;
+ }
+
+ public IPath getPath() {
+ return path;
+ }
+
+ public IClasspathEntry[] getClasspathEntries() {
+ if (entries == null) {
+ ArrayList<IClasspathEntry> entryList = new ArrayList<IClasspathEntry>();
+ JBossRuntime jbws = JBossRuntimeManager.getInstance()
+ .findRuntimeByName(segment);
+ if (jbws != null) {
+
+ List<String> jars = JBossRuntimeManager.getInstance().getAllRuntimeJars(jbws);
+ for (String jar : jars) {
+ entryList.add(getEntry(new Path(jar)));
+ }
+ entries = entryList.toArray(new IClasspathEntry[entryList.size()]);
+ if (entries == null)
+ return new IClasspathEntry[0];
+ }
+ }
+ return entries;
+ }
+
+ protected IClasspathEntry getEntry(IPath path) {
+ return JavaRuntime.newArchiveRuntimeClasspathEntry(path)
+ .getClasspathEntry();
+ }
+
+ public void removeEntry(String jarName) {
+ if (entries == null) {
+ return;
+ }
+ IClasspathEntry[] newEntries = new IClasspathEntry[entries.length - 1];
+ int i = 0;
+ for (IClasspathEntry entry : entries) {
+ if (!entry.toString().contains(jarName)) {
+ newEntries[i++] = entry;
+ }
+ }
+ entries = newEntries;
+ }
+
+ }
+
+ public boolean filterJars(String jarName, ArrayList<IClasspathEntry> list) {
+ for (IClasspathEntry entry : list) {
+ if (entry.getPath().lastSegment().equals(jarName)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+}
Added: trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeListConverter.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeListConverter.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeListConverter.java 2008-09-02 07:14:58 UTC (rev 10017)
@@ -0,0 +1,141 @@
+package org.jboss.tools.esb.core.runtime;
+
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.StringTokenizer;
+
+
+/**
+ *
+ * @author Grid Qian
+ *
+ */
+public class JBossRuntimeListConverter {
+
+ /*
+ * Constants definitions
+ */
+ private static final String REGEXP_ESCAPE = "\\";
+ private static final String COMMA = ",";
+ private static final String LIBRARY_SEPARATOR = ";";
+ private static final String EMPTY_STRING = "";
+ private static final String FIELD_SEPARATOR = "|";
+ private static final String DEFAULT = "default";
+ private static final String HOME_DIR = "homeDir";
+ private static final String VERSION = "version";
+ private static final String NAME = "name";
+ private static final String USER_CONFIG_CLASSPATH = "userConfig";
+ private static final String LIBRARY = "libraries";
+
+ /**
+ * Load String to JBossWSRuntime map from String
+ * @param input
+ * String representation of map
+ * @return
+ * Map<String, JBossWSRuntime> loaded from string
+ * TODO - switch to XML?
+ * TODO - write converter from old serialization format to XML?
+ * TODO - handle errors in string format
+ */
+ public Map<String, JBossRuntime> getMap(String input) {
+
+ Map<String, JBossRuntime> result = new HashMap<String, JBossRuntime>();
+ if (input == null || EMPTY_STRING.equals(input.trim())) {
+ return result;
+ }
+ StringTokenizer runtimes = new StringTokenizer(input, COMMA);
+ while (runtimes.hasMoreTokens()) {
+ String runtime = runtimes.nextToken();
+ String[] map = runtime.split(REGEXP_ESCAPE + FIELD_SEPARATOR);
+ JBossRuntime rt = new JBossRuntime();
+ final int step = 2;
+ for (int i = 0; i < map.length; i += step) {
+ String name = map[i];
+ String value = i + 1 < map.length ? map[i + 1] : EMPTY_STRING;
+ if (NAME.equals(name)) {
+ rt.setName(value);
+ } else if (HOME_DIR.equals(name)) {
+ rt.setHomeDir(value);
+ } else if (VERSION.equals(name)) {
+ rt.setVersion(value);
+ } else if (DEFAULT.equals(name)) {
+ rt.setDefault(Boolean.parseBoolean(value));
+ }else if(USER_CONFIG_CLASSPATH.equals(name)){
+ rt.setUserConfigClasspath(Boolean.parseBoolean(value));
+ }else if(LIBRARY.equals(name)){
+ if(value != null && !EMPTY_STRING.equals(value)){
+ rt.setLibraries(getLibrariesFromString(value));
+ }
+ }
+
+ }
+ result.put(rt.getName(), rt);
+ }
+
+ return result;
+ }
+
+ private List<String> getLibrariesFromString(String strLibraries){
+ List<String> libraries = new ArrayList<String>();
+ StringTokenizer st = new StringTokenizer(strLibraries, LIBRARY_SEPARATOR);
+ while(st.hasMoreTokens()){
+ String library = st.nextToken();
+ if(!libraries.contains(library)){
+ libraries.add(library);
+ }
+ }
+ return libraries;
+
+ }
+
+ private String convertListToString(List<String> libraries){
+ String strLib = "";
+ for(String library: libraries){
+ if("".equals(strLib)){
+ strLib = library;
+ }else{
+ strLib = strLib + LIBRARY_SEPARATOR + library;
+ }
+ }
+ return strLib;
+ }
+
+ /**
+ * Convert map String to JBossWSRUntime to string representation
+ * @param runtimeMap
+ * Map<String, JBossWSRuntime> - map of String to JBossWS Runtime to convert
+ * in String
+ * @return
+ * String representation of String to JBossWS Runtime map
+ */
+ public String getString(Map<String, JBossRuntime> runtimeMap) {
+ StringBuffer buffer = new StringBuffer();
+ JBossRuntime[] runtimes = runtimeMap.values().toArray(
+ new JBossRuntime[runtimeMap.size()]);
+ for (int i = 0; i < runtimes.length; i++) {
+ buffer.append(NAME).append(FIELD_SEPARATOR);
+ buffer.append(runtimes[i].getName());
+ buffer.append(FIELD_SEPARATOR).append(VERSION).append(
+ FIELD_SEPARATOR);
+ buffer.append(runtimes[i].getVersion());
+ buffer.append(FIELD_SEPARATOR).append(HOME_DIR).append(
+ FIELD_SEPARATOR);
+ buffer.append(runtimes[i].getHomeDir());
+ buffer.append(FIELD_SEPARATOR).append(DEFAULT).append(
+ FIELD_SEPARATOR);
+ buffer.append(runtimes[i].isDefault());
+ buffer.append(FIELD_SEPARATOR).append(USER_CONFIG_CLASSPATH).append(FIELD_SEPARATOR);
+ buffer.append(runtimes[i].isUserConfigClasspath());
+ buffer.append(FIELD_SEPARATOR).append(LIBRARY).append(FIELD_SEPARATOR);
+ buffer.append(convertListToString(runtimes[i].getLibraries()));
+ if (i != runtimes.length - 1) {
+ buffer.append(COMMA);
+ }
+ }
+ return buffer.toString();
+ }
+ }
+
Added: trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeManager.java
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeManager.java (rev 0)
+++ trunk/esb/plugins/org.jboss.tools.esb.project.core/src/org/jboss/tools/esb/core/runtime/JBossRuntimeManager.java 2008-09-02 07:14:58 UTC (rev 10017)
@@ -0,0 +1,393 @@
+/*******************************************************************************
+ * 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.esb.core.runtime;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.jface.preference.IPersistentPreferenceStore;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.jboss.tools.esb.core.ESBCorePlugin;
+import org.jboss.tools.esb.core.facet.IJBossESBFacetDataModelProperties;
+import org.jboss.tools.esb.core.messages.JBossFacetCoreMessages;
+
+/**
+ * @author Grid Qian
+ */
+public class JBossRuntimeManager {
+
+ private static JBossRuntimeListConverter converter = new JBossRuntimeListConverter();
+
+ private Map<String, JBossRuntime> runtimes = new HashMap<String, JBossRuntime>();
+
+ private final static String JBOSSESB_ESB = "jbossesb.esb";
+ private final static String JBOSSESB_SAR = "jbossesb.sar";
+
+ /**
+ * Private constructor
+ */
+ private JBossRuntimeManager() {
+ load();
+ }
+
+ /**
+ * This class make Java Runtime responsible for solving synchronization
+ * problems during initialization if there is any
+ *
+ */
+ static class JBossRuntimeManagerHolder {
+ private static final JBossRuntimeManager INSTANCE = new JBossRuntimeManager();
+ }
+
+ /**
+ * Return JBossWSRuntimeManaher instance
+ *
+ * @return JBossWSRuntimeManager instance
+ */
+ public static JBossRuntimeManager getInstance() {
+ return JBossRuntimeManagerHolder.INSTANCE;
+ }
+
+ /**
+ * Return Array of configured JBossWSRuntimes
+ *
+ * @return JBossWSRuntime[]
+ */
+ public JBossRuntime[] getRuntimes() {
+ Collection<JBossRuntime> c = runtimes.values();
+ return c.toArray(new JBossRuntime[runtimes.size()]);
+ }
+
+ /**
+ * Add new JBossWSRuntime
+ *
+ * @param runtime
+ * JBossWSRuntime
+ */
+ public void addRuntime(JBossRuntime runtime) {
+ if (runtimes.size() == 0) {
+ runtime.setDefault(true);
+ }
+
+ JBossRuntime oldDefaultRuntime = getDefaultRuntime();
+ if (oldDefaultRuntime != null && runtime.isDefault()) {
+ oldDefaultRuntime.setDefault(false);
+ }
+ runtimes.put(runtime.getName(), runtime);
+ save();
+ }
+
+ /**
+ * Add new JBossWSRuntime with given parameters
+ *
+ * @param name
+ * String - runtime name
+ * @param path
+ * String - runtime home folder
+ * @param version
+ * String - string representation of version number
+ * @param defaultRt
+ * boolean - default flag
+ */
+ public void addRuntime(String name, String path, String version,
+ boolean defaultRt) {
+ JBossRuntime jbossWSRt = new JBossRuntime();
+ jbossWSRt.setHomeDir(path);
+ jbossWSRt.setName(name);
+ jbossWSRt.setVersion(version);
+ jbossWSRt.setDefault(defaultRt);
+ addRuntime(jbossWSRt);
+ }
+
+ /**
+ * Return JBossWSRuntime by given name
+ *
+ * @param name
+ * String - JBossWSRuntime name
+ * @return JBossWSRuntime - found JBossWSRuntime instance or null
+ */
+ public JBossRuntime findRuntimeByName(String name) {
+ for (JBossRuntime jbossWSRuntime : runtimes.values()) {
+ if (jbossWSRuntime.getName().equals(name)) {
+ return jbossWSRuntime;
+ }
+ }
+ return null;
+ }
+
+ public List<String> getAllRuntimeJars(JBossRuntime rt){
+ List<String> jarList = new ArrayList<String>();
+ if (rt != null) {
+ if (rt.isUserConfigClasspath()) {
+ jarList.addAll(rt.getLibraries());
+
+ } else {
+
+ IPath rtHome = new Path(rt.getHomeDir());
+ IPath deployPath = rtHome.append("server").append("default").append("deploy");
+
+ IPath esbPath = deployPath.append(JBOSSESB_ESB);
+ IPath sarPath = deployPath.append(JBOSSESB_SAR);
+
+ IPath libPath = rtHome.append("lib");
+
+ if (!esbPath.toFile().exists() || !sarPath.toFile().exists()) {
+ esbPath = libPath.append(JBOSSESB_ESB);
+ sarPath = libPath.append(JBOSSESB_SAR);
+
+ }
+
+ List<File> esblibs = getJarsOfFolder(esbPath.toFile());
+ IPath sarLibPath = sarPath.append("lib");
+ List<File> sarJars = getJarsOfFolder(sarLibPath.toFile());
+ ///List<File> commonLibs = getJarsOfFolder(libPath.toFile());
+ //List<File> tmpLibs = mergeTwoFileList(esblibs, sarJars);
+ //libs.addAll(commonLibs);
+
+ jarList = mergeTwoList(esblibs, sarJars);
+
+ }
+
+ }
+ return jarList;
+ }
+
+
+
+ private List<File> getJarsOfFolder(File folder){
+ List<File> jars = new ArrayList<File>();
+ if(folder.isDirectory()){
+ for(File file: folder.listFiles()){
+ if(file.isFile() && (file.getName().endsWith(".jar") || file.getName().endsWith(".zip"))){
+ jars.add(file);
+ }else if (folder.isDirectory()){
+ jars.addAll(getJarsOfFolder(file));
+ }
+ }
+ }
+
+ return jars;
+ }
+
+ // if two folders have the same jar file, one of them will be ignored.
+ private List<String> mergeTwoList(List<File> jarList1, List<File> jarList2){
+ List<String> rtList = new ArrayList<String>();
+ List<String> distinctFileNames = new ArrayList<String>();
+
+ for(File jarFile: jarList1){
+ distinctFileNames.add(jarFile.getName());
+ rtList.add(jarFile.getAbsolutePath());
+ }
+ for(File jarFile: jarList2){
+ if(!distinctFileNames.contains(jarFile.getName())){
+ rtList.add(jarFile.getAbsolutePath());
+ }
+ }
+
+ return rtList;
+
+ }
+
+ private List<File> mergeTwoFileList(List<File> jarList1, List<File> jarList2){
+ List<File> rtList = new ArrayList<File>();
+ List<String> distinctFileNames = new ArrayList<String>();
+
+ for(File jarFile: jarList1){
+ distinctFileNames.add(jarFile.getName());
+ rtList.add(jarFile);
+ }
+ for(File jarFile: jarList2){
+ if(!distinctFileNames.contains(jarFile.getName())){
+ rtList.add(jarFile);
+ }
+ }
+
+ return rtList;
+
+ }
+
+ /**
+ * Remove given JBossWSRuntime from manager
+ *
+ * @param rt
+ * JBossWSRuntime
+ */
+ public void removeRuntime(JBossRuntime rt) {
+ runtimes.remove(rt.getName());
+ }
+
+ /**
+ * Save preference value and force save changes to disk
+ */
+ public void save() {
+ ESBCorePlugin.getDefault().getPreferenceStore().setValue(
+ JBossFacetCoreMessages.ESB_Location, converter.getString(runtimes));
+ IPreferenceStore store = ESBCorePlugin.getDefault()
+ .getPreferenceStore();
+ if (store instanceof IPersistentPreferenceStore) {
+ try {
+ ((IPersistentPreferenceStore) store).save();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * Marks this runtime as default. Marks other runtimes with the same version
+ * as not default.
+ *
+ * @param runtime
+ */
+ public void setDefaultRuntime(JBossRuntime runtime) {
+ JBossRuntime[] runtimes = getRuntimes();
+ for (int i = 0; i < runtimes.length; i++) {
+ runtimes[i].setDefault(false);
+ }
+ runtime.setDefault(true);
+ }
+
+ /**
+ * Return first default JBossWSRuntime
+ *
+ * @return JBossWSRuntime
+ */
+ public JBossRuntime getDefaultRuntime() {
+ for (JBossRuntime rt : runtimes.values()) {
+ if (rt.isDefault()) {
+ return rt;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Return list of available JBossWSRuntime names
+ *
+ * @return List<String>
+ */
+ public List<String> getRuntimeNames() {
+ JBossRuntime[] rts = getRuntimes();
+ List<String> result = new ArrayList<String>();
+ for (JBossRuntime jbossWSRuntime : rts) {
+ result.add(jbossWSRuntime.getName());
+ }
+ return result;
+ }
+
+ /**
+ * Return a list of all runtime names
+ *
+ * @return List of all runtime names
+ */
+ public List<String> getAllRuntimeNames() {
+ JBossRuntime[] rts = getRuntimes();
+ List<String> result = new ArrayList<String>();
+ for (JBossRuntime jbossWSRuntime : rts) {
+ result.add(jbossWSRuntime.getName());
+ }
+ return result;
+ }
+
+ /**
+ * TBD
+ *
+ * @param oldName
+ * old runtime name
+ * @param newName
+ * new runtime name
+ */
+ public void changeRuntimeName(String oldName, String newName) {
+ JBossRuntime o = findRuntimeByName(oldName);
+ if (o == null) {
+ return;
+ }
+ o.setName(newName);
+ onRuntimeNameChanged(oldName, newName);
+ }
+
+ private void onRuntimeNameChanged(String oldName, String newName) {
+ IProjectFacet facet = ProjectFacetsManager
+ .getProjectFacet(IJBossESBFacetDataModelProperties.JBOSS_ESB_FACET_ID);
+ Set<IFacetedProject> facetedProjects = null;
+ try {
+ facetedProjects = ProjectFacetsManager.getFacetedProjects(facet);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ for (IFacetedProject facetedProject : facetedProjects) {
+ QualifiedName qRuntimeName = IJBossESBFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME;
+ String name = null;
+ try {
+ name = facetedProject.getProject().getPersistentProperty(
+ qRuntimeName);
+ if (name != null && name.equals(oldName)) {
+ facetedProject.getProject().setPersistentProperty(
+ qRuntimeName, newName);
+ }
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+ }
+
+ public static boolean isRuntimeUsed(String name) {
+ IProjectFacet facet = ProjectFacetsManager
+ .getProjectFacet(IJBossESBFacetDataModelProperties.JBOSS_ESB_FACET_ID);
+ Set<IFacetedProject> facetedProjects = null;
+ try {
+ facetedProjects = ProjectFacetsManager.getFacetedProjects(facet);
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ for (IFacetedProject facetedProject : facetedProjects) {
+ QualifiedName qRuntimeName = IJBossESBFacetDataModelProperties.PERSISTENCE_PROPERTY_QNAME_RUNTIME_NAME;
+ try {
+ if (name.equals(facetedProject.getProject()
+ .getPersistentProperty(qRuntimeName))) {
+ return true;
+ }
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+ return false;
+ }
+
+ public void load() {
+ IPreferenceStore ps = ESBCorePlugin.getDefault()
+ .getPreferenceStore();
+
+ String runtimeListString = ps
+ .getString(JBossFacetCoreMessages.ESB_Location);
+
+ runtimes = converter.getMap(runtimeListString);
+ }
+
+}
\ No newline at end of file
15 years, 8 months
JBoss Tools SVN: r10016 - trunk/esb/plugins.
by jbosstools-commits@lists.jboss.org
Author: dennyxu
Date: 2008-09-02 03:14:15 -0400 (Tue, 02 Sep 2008)
New Revision: 10016
Added:
trunk/esb/plugins/org.jboss.tools.esb.project.core/
Log:
Initial import. Add ESB project facet and wizard
15 years, 8 months
JBoss Tools SVN: r10015 - workspace/dart/plugins/trunk/org.jboss.tools.smooks.javabean/src_test/test.
by jbosstools-commits@lists.jboss.org
Author: DartPeng
Date: 2008-09-02 02:59:31 -0400 (Tue, 02 Sep 2008)
New Revision: 10015
Added:
workspace/dart/plugins/trunk/org.jboss.tools.smooks.javabean/src_test/test/Test.smooks.graph
Log:
add new file for testing
Added: workspace/dart/plugins/trunk/org.jboss.tools.smooks.javabean/src_test/test/Test.smooks.graph
===================================================================
--- workspace/dart/plugins/trunk/org.jboss.tools.smooks.javabean/src_test/test/Test.smooks.graph (rev 0)
+++ workspace/dart/plugins/trunk/org.jboss.tools.smooks.javabean/src_test/test/Test.smooks.graph 2008-09-02 06:59:31 UTC (rev 10015)
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="ASCII"?>
+<GraphInformations xmlns="http://www.jboss.org/tools/smooks">
+ <mappingType targetTypeID="org.jboss.tools.smooks.ui.viewerInitor.javabean" sourceTypeID="org.jboss.tools.smooks.ui.viewerInitor.javabean"/>
+</GraphInformations>
15 years, 8 months
JBoss Tools SVN: r10014 - workspace/dart/plugins/trunk/org.jboss.tools.smooks.javabean/src_test/test.
by jbosstools-commits@lists.jboss.org
Author: DartPeng
Date: 2008-09-02 02:59:11 -0400 (Tue, 02 Sep 2008)
New Revision: 10014
Modified:
workspace/dart/plugins/trunk/org.jboss.tools.smooks.javabean/src_test/test/SmooksAnalyzerTester.java
workspace/dart/plugins/trunk/org.jboss.tools.smooks.javabean/src_test/test/Test.xml
Log:
change some test code and config file for testing
Modified: workspace/dart/plugins/trunk/org.jboss.tools.smooks.javabean/src_test/test/SmooksAnalyzerTester.java
===================================================================
--- workspace/dart/plugins/trunk/org.jboss.tools.smooks.javabean/src_test/test/SmooksAnalyzerTester.java 2008-09-02 06:58:44 UTC (rev 10013)
+++ workspace/dart/plugins/trunk/org.jboss.tools.smooks.javabean/src_test/test/SmooksAnalyzerTester.java 2008-09-02 06:59:11 UTC (rev 10014)
@@ -11,13 +11,12 @@
package test;
import java.io.IOException;
+import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.util.Collections;
import junit.framework.TestCase;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EPackage.Registry;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.xmi.impl.XMLResourceFactoryImpl;
@@ -38,23 +37,24 @@
GraphicalPackage.eINSTANCE);
Registry.INSTANCE.put(SmooksPackage.eNS_URI, SmooksPackage.eINSTANCE);
try {
- String path = "C:\\Users\\Dart\\Documents\\SmooksTest\\Test.smooks";
- String path1 = "C:\\Users\\Dart\\Documents\\SmooksTest\\Test.smooks.graph";
+ ClassLoader classLoader = SmooksAnalyzerTester.class.getClassLoader();
Resource resource = new SmooksResourceFactoryImpl()
- .createResource(URI.createFileURI(path));
- Resource gr = new XMLResourceFactoryImpl()
- .createResource(URI.createFileURI(path1));
- gr.load(Collections.EMPTY_MAP);
- GraphInformations graph = (GraphInformations) gr.getContents().get(0);;
+ .createResource(null);
+ Resource gr = new XMLResourceFactoryImpl().createResource(null);
+ InputStream stream1 = classLoader.getResourceAsStream("test/Test.xml");
+ InputStream stream2 = classLoader.getResourceAsStream("test/Test.smooks.graph");
+ gr.load(stream2,Collections.EMPTY_MAP);
+ GraphInformations graph = (GraphInformations) gr.getContents().get(
+ 0);
- resource.load(Collections.EMPTY_MAP);
+ resource.load(stream1,Collections.EMPTY_MAP);
JavaBeanAnalyzer sourceModelAnalyzer = new JavaBeanAnalyzer();
SmooksResourceListType listType = ((DocumentRoot) resource
.getContents().get(0)).getSmooksResourceList();
Object obj = sourceModelAnalyzer
- .buildSourceInputObjects(graph, listType, null,
- SmooksAnalyzerTester.class.getClassLoader());
+ .buildSourceInputObjects(graph, listType, null,classLoader);
+ System.out.println(obj);
} catch (IOException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
Modified: workspace/dart/plugins/trunk/org.jboss.tools.smooks.javabean/src_test/test/Test.xml
===================================================================
--- workspace/dart/plugins/trunk/org.jboss.tools.smooks.javabean/src_test/test/Test.xml 2008-09-02 06:58:44 UTC (rev 10013)
+++ workspace/dart/plugins/trunk/org.jboss.tools.smooks.javabean/src_test/test/Test.xml 2008-09-02 06:59:11 UTC (rev 10014)
@@ -1,36 +1,38 @@
-<?xml version="1.0" encoding="ASCII"?>
-<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.0.xsd">
- <resource-config selector="srcmodel.Order">
- <resource>org.milyn.javabean.BeanPopulator</resource>
- <param name="beanId">LineOrder</param>
- <param name="beanClass">targetmodel.LineOrder</param>
- <param name="bindings">
- <binding property="customerId"
- selector="header customerNumber" />
- <binding property="customerName"
- selector="header customerName" />
- <binding property="lineItems" selector="${lineItems}" />
- </param>
- </resource-config>
- <resource-config selector="orderItems">
- <resource>org.milyn.javabean.BeanPopulator</resource>
- <param name="beanId">lineItems</param>
- <param name="beanClass">targetmodel.LineItem[]</param>
- <param name="bindings">
- <binding property="LineItem" selector="${LineItem}" />
- </param>
- </resource-config>
- <resource-config selector="srcmodel.OrderItem">
- <resource>org.milyn.javabean.BeanPopulator</resource>
- <param name="beanId">LineItem</param>
- <param name="beanClass">targetmodel.LineItem</param>
- <param name="bindings">
- <binding property="productCode"
- selector="srcmodel.OrderItem productId" />
- <binding property="unitPrice"
- selector="srcmodel.OrderItem price" />
- <binding property="unitQuantity"
- selector="srcmodel.OrderItem quantity" />
- </param>
- </resource-config>
+<?xml version="1.0" encoding="ASCII"?>
+<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.0.xsd">
+ <resource-config selector="srcmodel.Order">
+ <resource>org.milyn.javabean.BeanPopulator</resource>
+ <param name="beanId">LineOrder</param>
+ <param name="beanClass">targetmodel.LineOrder</param>
+ <param name="bindings">
+ <binding property="customerId"
+ selector="header customerNumber" />
+ <binding property="customerName"
+ selector="header customerName" />
+ <binding property="lineItems" selector="${lineItems}" />
+ </param>
+ </resource-config>
+ <resource-config selector="orderItems">
+ <resource>org.milyn.javabean.BeanPopulator</resource>
+ <param name="beanId">lineItems</param>
+ <param name="beanClass">targetmodel.LineItem[]</param>
+ <param name="bindings">
+ <binding property="LineItem" selector="${LineItem}" />
+ </param>
+ </resource-config>
+ <resource-config selector="srcmodel.OrderItem">
+ <resource>org.milyn.javabean.BeanPopulator</resource>
+ <param name="beanId">LineItem</param>
+ <param name="beanClass">targetmodel.LineItem</param>
+ <param name="bindings">
+ <binding property="productCode"
+ selector="srcmodel.OrderItem productId" />
+ <binding property="unitPrice"
+ selector="srcmodel.OrderItem price" />
+ <binding property="unitPrice"
+ selector="srcmodel.OrderItem Ate" />
+ <binding property="unitQuantity"
+ selector="srcmodel.OrderItem quantity" />
+ </param>
+ </resource-config>
</smooks-resource-list>
\ No newline at end of file
15 years, 8 months
JBoss Tools SVN: r10013 - workspace/dart/plugins/trunk/org.jboss.tools.smooks.javabean/src/org/jboss/tools/smooks/javabean/ui.
by jbosstools-commits@lists.jboss.org
Author: DartPeng
Date: 2008-09-02 02:58:44 -0400 (Tue, 02 Sep 2008)
New Revision: 10013
Modified:
workspace/dart/plugins/trunk/org.jboss.tools.smooks.javabean/src/org/jboss/tools/smooks/javabean/ui/JavaBeanModelLoadComposite.java
Log:
remove the checkbox treeviewer
Modified: workspace/dart/plugins/trunk/org.jboss.tools.smooks.javabean/src/org/jboss/tools/smooks/javabean/ui/JavaBeanModelLoadComposite.java
===================================================================
--- workspace/dart/plugins/trunk/org.jboss.tools.smooks.javabean/src/org/jboss/tools/smooks/javabean/ui/JavaBeanModelLoadComposite.java 2008-09-02 06:58:19 UTC (rev 10012)
+++ workspace/dart/plugins/trunk/org.jboss.tools.smooks.javabean/src/org/jboss/tools/smooks/javabean/ui/JavaBeanModelLoadComposite.java 2008-09-02 06:58:44 UTC (rev 10013)
@@ -10,13 +10,10 @@
******************************************************************************/
package org.jboss.tools.smooks.javabean.ui;
-import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.Iterator;
import java.util.List;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.search.IJavaSearchScope;
@@ -25,7 +22,6 @@
import org.eclipse.jdt.ui.IJavaElementSearchConstants;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.viewers.CheckboxTreeViewer;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
@@ -33,8 +29,6 @@
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.events.TreeEvent;
-import org.eclipse.swt.events.TreeListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -43,10 +37,7 @@
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.ui.dialogs.SelectionDialog;
-import org.jboss.tools.smooks.javabean.model.BeanContentProvider;
-import org.jboss.tools.smooks.javabean.model.BeanlabelProvider;
import org.jboss.tools.smooks.javabean.model.JavaBeanModel;
import org.jboss.tools.smooks.javabean.model.JavaBeanModelFactory;
import org.jboss.tools.smooks.ui.SmooksUIActivator;
@@ -64,7 +55,6 @@
private Button classBrowseButton;
protected String classFullName;
protected boolean loadAtomic;
- private CheckboxTreeViewer treeViewer;
protected IJavaProject javaProject;
protected IRunnableContext runnableContext;
protected JavaBeanModel currentRootJavaBeanModel = null;
@@ -136,8 +126,6 @@
*/
public void modifyText(ModifyEvent arg0) {
classFullName = classText.getText();
- if (loadAtomic)
- loadModelPropertiesAndRefreshViewer(runnableContext);
}
});
@@ -146,88 +134,6 @@
classBrowseButton.addSelectionListener(this);
classBrowseButton.setText("Browse...");
}
-
- // final Button atomicLoadButton = new Button(com, SWT.RADIO);
- //
- // atomicLoadButton.setText("Atomicly load");
- // atomicLoadButton.setSelection(true);
- //
- // Button loadButton = new Button(com, SWT.RADIO);
- // loadButton.setText("Load by hand");
- //
- // final Button loadClassButton = new Button(com, SWT.NONE);
- // loadClassButton.setText("Load Class");
- // loadClassButton.addSelectionListener(new SelectionAdapter() {
- //
- // /*
- // * (non-Javadoc)
- // *
- // * @see
- // * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
- // * .swt.events.SelectionEvent)
- // */
- // @Override
- // public void widgetSelected(SelectionEvent e) {
- // super.widgetSelected(e);
- // if (!loadAtomic)
- // loadModelPropertiesAndRefreshViewer(runnableContext);
- // }
- // });
- // loadClassButton.setEnabled(false);
- //
- // SelectionAdapter radioButtonSelectionAdp = new SelectionAdapter() {
- // /*
- // * (non-Javadoc)
- // *
- // * @see
- // * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse
- // * .swt.events.SelectionEvent)
- // */
- // @Override
- // public void widgetSelected(SelectionEvent e) {
- // super.widgetSelected(e);
- // loadAtomic = atomicLoadButton.getSelection();
- // loadClassButton.setEnabled(!loadAtomic);
- // }
- //
- // };
- // atomicLoadButton.addSelectionListener(radioButtonSelectionAdp);
- // loadButton.addSelectionListener(radioButtonSelectionAdp);
-
- Label spliter = new Label(com, SWT.SEPARATOR | SWT.HORIZONTAL);
- spliter.setVisible(false);
- treeViewer = new CheckboxTreeViewer(com, SWT.BORDER);
- treeViewer.setContentProvider(new BeanContentProvider());
- treeViewer.setLabelProvider(new BeanlabelProvider());
- treeViewer.getTree().addTreeListener(new TreeListener(){
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.TreeListener#treeCollapsed(org.eclipse.swt.events.TreeEvent)
- */
- public void treeCollapsed(TreeEvent e) {
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.TreeListener#treeExpanded(org.eclipse.swt.events.TreeEvent)
- */
- public void treeExpanded(TreeEvent e) {
- TreeItem item = (TreeItem)e.item;
- if(item.getChecked()){
- TreeItem[] items = item.getItems();
- for (int i = 0; i < items.length; i++) {
- TreeItem ci = items[i];
- ci.setChecked(true);
- }
- }
- }
-
- });
- gd = new GridData(GridData.FILL_BOTH);
- gd.horizontalSpan = 2;
- gd.grabExcessHorizontalSpace = true;
- gd.grabExcessVerticalSpace = true;
- treeViewer.getTree().setLayoutData(gd);
return com;
}
@@ -267,12 +173,20 @@
*/
public JavaBeanModel fillCheckStateModel(JavaBeanModel rootJavaBean) {
if (rootJavaBean == null) {
- List list = (List) treeViewer.getInput();
- if (list != null)
- rootJavaBean = (JavaBeanModel) list.get(0);
+ // List list = (List) treeViewer.getInput();
+ // if (list != null)
+ // rootJavaBean = (JavaBeanModel) list.get(0);
+ try {
+ ProjectClassLoader loader = new ProjectClassLoader(javaProject);
+ Class clazz = loader.loadClass(this.classText.getText());
+ rootJavaBean = JavaBeanModelFactory
+ .getJavaBeanModelWithLazyLoad(clazz);
+ }catch(Exception e){
+
+ }
}
- if (rootJavaBean != null)
- this.fillTheModelWithCheckStatus(rootJavaBean, treeViewer);
+ // if (rootJavaBean != null)
+ // this.fillTheModelWithCheckStatus(rootJavaBean, treeViewer);
return rootJavaBean;
}
@@ -307,40 +221,6 @@
}
}
+
- protected void loadModelPropertiesAndRefreshViewer(
- IRunnableContext runnableContext) {
- Exception exp = null;
- try {
- runnableContext.run(false, false, new IRunnableWithProgress() {
-
- public void run(IProgressMonitor arg0)
- throws InvocationTargetException, InterruptedException {
- try {
- Class clazz = loader.loadClass(classFullName);
- currentRootJavaBeanModel = JavaBeanModelFactory
- .getJavaBeanModelWithLazyLoad(clazz);
- } catch (ClassNotFoundException e) {
- throw new InvocationTargetException(e);
- }
- }
-
- });
- } catch (InvocationTargetException e1) {
- exp = e1;
- } catch (InterruptedException e1) {
- exp = e1;
- }
- if (exp != null) {
- // TODO ignor????
- treeViewer.setInput(Collections.EMPTY_LIST);
- } else {
- if (currentRootJavaBeanModel != null) {
- treeViewer.setInput(currentRootJavaBeanModel.getProperties());
- treeViewer.setAllChecked(true);
- } else
- treeViewer.setInput(Collections.EMPTY_LIST);
- }
- }
-
}
15 years, 8 months