Author: bbrodt
Date: 2010-04-20 11:12:10 -0400 (Tue, 20 Apr 2010)
New Revision: 21557
Modified:
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/editors/ODEDeployMultiPageEditor.java
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/pages/ProcessPage.java
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/util/DeployUtils.java
trunk/bpel/plugins/org.eclipse.bpel.common.ui/plugin.xml
trunk/bpel/plugins/org.eclipse.bpel.model/build.properties
trunk/bpel/plugins/org.eclipse.bpel.model/plugin.xml
trunk/bpel/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/resource/BPELResourceSetImpl.java
trunk/bpel/plugins/org.eclipse.bpel.ui/plugin.xml
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/IBPELUIConstants.java
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/Templates.java
trunk/bpel/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/Builder.java
Log:
https://jira.jboss.org/jira/browse/JBIDE-6006
Added content type checking to BPEL editor and deployment editor.
Also fixed deployment editor crash if BPEL resources are deleted.
Modified:
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/editors/ODEDeployMultiPageEditor.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/editors/ODEDeployMultiPageEditor.java 2010-04-20
14:37:39 UTC (rev 21556)
+++
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/editors/ODEDeployMultiPageEditor.java 2010-04-20
15:12:10 UTC (rev 21557)
@@ -22,6 +22,7 @@
import org.eclipse.bpel.apache.ode.deploy.model.dd.util.ddResourceFactoryImpl;
import org.eclipse.bpel.apache.ode.deploy.ui.pages.ProcessPage;
import org.eclipse.bpel.apache.ode.deploy.ui.util.DeployUtils;
+import org.eclipse.bpel.model.BPELFactory;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceVisitor;
@@ -52,14 +53,17 @@
* @author Tammo van Lessen (IAAS)
* @author Simon Moser (IBM)
*/
-public class ODEDeployMultiPageEditor extends FormEditor implements
IEditingDomainProvider {
-
- protected TDeployment deployDescriptor = null;
-
+public class ODEDeployMultiPageEditor extends FormEditor implements
+ IEditingDomainProvider {
+
+ // Display this in title if no BPEL process files are found in current directory
+ private final static String NO_PROCESSES_FOUND = " *** No Processes Found ***
";
+ private boolean readOnly = false;
+ protected TDeployment deployDescriptor = null;
+
protected AdapterFactoryEditingDomain editingDomain;
protected ComposedAdapterFactory adapterFactory;
-
/**
* Creates a multi-page editor example.
*/
@@ -67,36 +71,38 @@
super();
initializeEditingDomain();
}
-
+
/**
* Saves the deployment descriptor
*/
public void doSave(IProgressMonitor monitor) {
commitPages(true);
saveDeploymentDescriptor();
- ((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone();
+ ((BasicCommandStack) editingDomain.getCommandStack()).saveIsDone();
firePropertyChange(IEditorPart.PROP_DIRTY);
}
-
+
/**
* SaveAs is not supported.
*/
public void doSaveAs() {
throw new UnsupportedOperationException("SaveAs is not allowed.");
//$NON-NLS-1$
}
-
+
/**
- * The implementation of this method checks that the input is an
- * instance of <code>IFileEditorInput</code> and creates the data model.
+ * The implementation of this method checks that the input is an instance of
+ * <code>IFileEditorInput</code> and creates the data model.
*/
- public void init(IEditorSite site, IEditorInput editorInput) throws PartInitException {
+ public void init(IEditorSite site, IEditorInput editorInput)
+ throws PartInitException {
super.init(site, editorInput);
setPartName(editorInput.getName());
-
+
if (!(editorInput instanceof IFileEditorInput)) {
- throw new PartInitException("Invalid Input: Must be IFileEditorInput");
//$NON-NLS-1$
+ throw new PartInitException(
+ "Invalid Input: Must be IFileEditorInput"); //$NON-NLS-1$
}
-
+
createModel();
}
@@ -105,14 +111,16 @@
}
public void saveDeploymentDescriptor() {
- try {
- deployDescriptor.eResource().save(null);
- }
- catch (IOException e1) {
+ try {
+ //
https://jira.jboss.org/jira/browse/JBIDE-6006
+ // editor will be "read only" if there are no BPEL resources to process
+ if (!readOnly)
+ deployDescriptor.eResource().save(null);
+ } catch (IOException e1) {
e1.printStackTrace();
}
}
-
+
protected org.eclipse.bpel.model.Process loadBPEL(IFile bpelFile) {
IPath fullProcessPath = bpelFile.getFullPath();
URI uri = URI.createPlatformResourceURI(fullProcessPath.toString(), false);
@@ -133,42 +141,43 @@
}
@Override
- protected void addPages() {
+ protected void addPages() {
try {
for (ProcessType pt : deployDescriptor.getProcess()) {
addPage(new ProcessPage(this, pt));
}
- }
- catch (PartInitException e) {
+ } catch (PartInitException e) {
// ~
}
}
-
- public TDeployment getDeploymentModel(){
+
+ public TDeployment getDeploymentModel() {
return deployDescriptor;
}
protected void initializeEditingDomain() {
- adapterFactory = new
ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+ adapterFactory = new ComposedAdapterFactory(
+ ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
- // Create the command stack that will notify this editor as commands are executed.
+ // Create the command stack that will notify this editor as commands are
+ // executed.
BasicCommandStack commandStack = new BasicCommandStack();
- // Add a listener to set the most recent command's affected objects to be the
selection of the viewer with focus.
- commandStack.addCommandStackListener
- (new CommandStackListener() {
- public void commandStackChanged(final EventObject event) {
- getContainer().getDisplay().asyncExec
- (new Runnable() {
- public void run() {
- editorDirtyStateChanged();
- }
- });
- }
- });
+ // Add a listener to set the most recent command's affected objects to
+ // be the selection of the viewer with focus.
+ commandStack.addCommandStackListener(new CommandStackListener() {
+ public void commandStackChanged(final EventObject event) {
+ getContainer().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ editorDirtyStateChanged();
+ }
+ });
+ }
+ });
// Create the editing domain with a special command stack.
- editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new
HashMap<Resource, Boolean>());
+ editingDomain = new AdapterFactoryEditingDomain(adapterFactory,
+ commandStack, new HashMap<Resource, Boolean>());
}
public EditingDomain getEditingDomain() {
@@ -177,16 +186,18 @@
@Override
public boolean isDirty() {
- return ((BasicCommandStack)editingDomain.getCommandStack()).isSaveNeeded();
+ return !readOnly
+ && ((BasicCommandStack) editingDomain.getCommandStack())
+ .isSaveNeeded();
}
-
+
@Override
public void setFocus() {
if (getActivePage() != -1 && getControl(getActivePage()) != null) {
getControl(getActivePage()).setFocus();
}
}
-
+
protected void createModel() throws PartInitException {
URI resourceURI = EditUIUtil.getURI(getEditorInput());
Resource resource = null;
@@ -196,43 +207,51 @@
editingDomain.getResourceSet().getResources().add(resource);
try {
resource.load(Collections.EMPTY_MAP);
-
+
EList<EObject> contents = resource.getContents();
if (!contents.isEmpty() && contents.get(0) instanceof DocumentRoot) {
deployDescriptor = ((DocumentRoot) contents.get(0)).getDeploy();
-
+
populateModel();
-
- //TODO: what to do with processtypes in DD without a corresponding BPEL file
available?
}
} catch (CoreException e) {
throw new PartInitException(e.getStatus());
} catch (IOException e) {
throw new PartInitException(e.getMessage(), e);
}
+ if (deployDescriptor.getProcess().isEmpty()) {
+ //
https://jira.jboss.org/jira/browse/JBIDE-6006
+ // add a process stub to DD so the editor doesn't crash
+ org.eclipse.bpel.model.Process p = BPELFactory.eINSTANCE.createProcess();
+ p.setName(NO_PROCESSES_FOUND);
+ ProcessType pt = DeployUtils.createProcessStub(p);
+ deployDescriptor.getProcess().add(pt);
+ // set model
+ pt.setModel(p);
+ readOnly = true; // can't save editor
+ }
}
public void populateModel() throws CoreException {
- ((IFileEditorInput)getEditorInput()).getFile().getProject().accept(new
IResourceVisitor() {
+ ((IFileEditorInput) getEditorInput()).getFile().getProject().accept(new
IResourceVisitor() {
public boolean visit(IResource bpelfile) throws CoreException {
- if (bpelfile.getType() == IResource.FILE
- && bpelfile.getFileExtension().equalsIgnoreCase("bpel")) {
//$NON-NLS-1$
- org.eclipse.bpel.model.Process p = DeployUtils.loadBPEL((IFile)bpelfile,
editingDomain.getResourceSet());
+ //
https://jira.jboss.org/jira/browse/JBIDE-6006
+ if (DeployUtils.isBPELFile(bpelfile)) {
+ org.eclipse.bpel.model.Process p = DeployUtils.loadBPEL((IFile) bpelfile,
editingDomain.getResourceSet());
if (p != null) {
- // add process to DD unless it it not already there.
- ProcessType pt = DeployUtils.findProcessTypeInDD(p, deployDescriptor);
+ // add process to DD unless it is not already there.
+ ProcessType pt = DeployUtils.findProcessTypeInDD(p, deployDescriptor);
if (pt == null) {
pt = DeployUtils.createProcessStub(p);
deployDescriptor.getProcess().add(pt);
}
// set model
pt.setModel(p);
-
+
}
- }
+ }
return true;
}
});
}
-
}
Modified:
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/pages/ProcessPage.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/pages/ProcessPage.java 2010-04-20
14:37:39 UTC (rev 21556)
+++
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/pages/ProcessPage.java 2010-04-20
15:12:10 UTC (rev 21557)
@@ -34,6 +34,7 @@
import org.eclipse.bpel.apache.ode.deploy.ui.Activator;
import org.eclipse.bpel.apache.ode.deploy.ui.editors.ODEDeployMultiPageEditor;
import org.eclipse.bpel.apache.ode.deploy.ui.util.DeployUtils;
+import org.eclipse.bpel.model.BPELFactory;
import org.eclipse.bpel.model.PartnerLink;
import org.eclipse.bpel.model.PartnerLinks;
import org.eclipse.bpel.model.Process;
@@ -55,6 +56,8 @@
import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.edit.command.AddCommand;
import org.eclipse.emf.edit.command.RemoveCommand;
@@ -714,56 +717,62 @@
public Object[] getElements(Object inputElement) {
- if (inputElement instanceof ProcessType){
- ProcessType type = (ProcessType) inputElement;
- if (forInbound){
- EList<TProvide> provide = type.getProvide();
-
- if (provide.isEmpty()){
- Process process = type.getModel();
- PartnerLinks pls = process.getPartnerLinks();
- EList<PartnerLink> plList = pls.getChildren();
- for (Iterator<PartnerLink> iterator = plList.iterator(); iterator.hasNext();)
{
- PartnerLink current = (PartnerLink) iterator.next();
- if (current.getMyRole() != null){
- TProvide currentProvide = ddFactory.eINSTANCE.createTProvide();
- currentProvide.setPartnerLink(current.getName());
- provide.add(currentProvide);
- }
+ try
+ {
+ if (inputElement instanceof ProcessType){
+ ProcessType type = (ProcessType) inputElement;
+ if (forInbound){
+ EList<TProvide> provide = type.getProvide();
+
+ if (provide.isEmpty()){
+ Process process = type.getModel();
+ PartnerLinks pls = process.getPartnerLinks();
+ EList<PartnerLink> plList = pls.getChildren();
+ for (Iterator<PartnerLink> iterator = plList.iterator();
iterator.hasNext();) {
+ PartnerLink current = (PartnerLink) iterator.next();
+ if (current.getMyRole() != null){
+ TProvide currentProvide = ddFactory.eINSTANCE.createTProvide();
+ currentProvide.setPartnerLink(current.getName());
+ provide.add(currentProvide);
+ }
+ }
}
+
+ return provide.toArray();
}
-
- return provide.toArray();
- }
- else {
- EList<TInvoke> invoke = type.getInvoke();
-
- if (invoke.isEmpty()){
- Process process = type.getModel();
- PartnerLinks pls = process.getPartnerLinks();
- if (pls != null) {
- EList<PartnerLink> plList = pls.getChildren();
- for (Iterator<PartnerLink> iterator = plList.iterator(); iterator
- .hasNext();) {
- PartnerLink current = (PartnerLink) iterator
- .next();
- if (current.getPartnerRole() != null) {
- TInvoke currentInvoke = ddFactory.eINSTANCE
- .createTInvoke();
- currentInvoke.setPartnerLink(current
- .getName());
- invoke.add(currentInvoke);
+ else {
+ EList<TInvoke> invoke = type.getInvoke();
+
+ if (invoke.isEmpty()){
+ Process process = type.getModel();
+ PartnerLinks pls = process.getPartnerLinks();
+ if (pls != null) {
+ EList<PartnerLink> plList = pls.getChildren();
+ for (Iterator<PartnerLink> iterator = plList.iterator(); iterator
+ .hasNext();) {
+ PartnerLink current = (PartnerLink) iterator
+ .next();
+ if (current.getPartnerRole() != null) {
+ TInvoke currentInvoke = ddFactory.eINSTANCE
+ .createTInvoke();
+ currentInvoke.setPartnerLink(current
+ .getName());
+ invoke.add(currentInvoke);
+ }
}
}
}
+
+ return invoke.toArray();
}
-
- return invoke.toArray();
}
}
- else {
- return new String[1];
+ catch(NullPointerException ex)
+ {
}
+ //
https://jira.jboss.org/jira/browse/JBIDE-6006
+ // create a stub invoke so the editor doesn't crash
+ return new TInvoke[] { ddFactory.eINSTANCE.createTInvoke() };
}
public void dispose() {
@@ -812,7 +821,8 @@
IResourceDeltaVisitor rdv = new IResourceDeltaVisitor() {
public boolean visit(IResourceDelta delta) {
IResource res = delta.getResource();
- if ("bpel".equalsIgnoreCase(res.getFileExtension())) { //$NON-NLS-1$
+ //
https://jira.jboss.org/jira/browse/JBIDE-6006
+ if (DeployUtils.isBPELFile(res)) {
Display.getDefault().syncExec(new Runnable() {
public void run() {
mainform.setMessage("Associated BPEL and/or WSDL has been changed, click to
update!", IMessageProvider.WARNING);
Modified:
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/util/DeployUtils.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/util/DeployUtils.java 2010-04-20
14:37:39 UTC (rev 21556)
+++
trunk/bpel/plugins/org.eclipse.bpel.apache.ode.deploy.ui/src/org/eclipse/bpel/apache/ode/deploy/ui/util/DeployUtils.java 2010-04-20
15:12:10 UTC (rev 21557)
@@ -32,6 +32,8 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.content.IContentDescription;
+import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.EObject;
@@ -56,7 +58,8 @@
public static final String URL_PREFIX_PLATFORM = "platform"; //$NON-NLS-1$
public static final String URL_PREFIX_RESOURCE = "resource"; //$NON-NLS-1$
public static final String NONE_STRING = "-- none -- "; //$NON-NLS-1$
-
+ public static final String BPEL_CONTENT_TYPE = "org.eclipse.bpel.contenttype";
//$NON-NLS-1$
+
public static ProcessType findProcessTypeInDD(
org.eclipse.bpel.model.Process process, TDeployment dd) {
for (ProcessType pt : dd.getProcess()) {
@@ -210,8 +213,9 @@
for (IFile file : allFiles) {
- if (file.getFileExtension().equalsIgnoreCase("bpel")) { //$NON-NLS-1$
- // load it
+ //
https://jira.jboss.org/jira/browse/JBIDE-6006
+ if (DeployUtils.isBPELFile(file)) {
+ // load it
Process currentProcess = loadBPEL(file, resourceSet);
// stuff it in bpelFiles
bpelFiles.add(currentProcess);
@@ -316,4 +320,28 @@
return file;
}
+ //
https://jira.jboss.org/jira/browse/JBIDE-6006
+ public static boolean isBPELFile(IResource res)
+ {
+ try
+ {
+ if (res.getType() == IResource.FILE) {
+ // check if file was recognized by eclipse BPEL editor
+ IContentDescription desc = ((IFile) res).getContentDescription();
+ if (desc != null) {
+ IContentType type = desc.getContentType();
+ if (type.getId().equals(BPEL_CONTENT_TYPE))
+ return true;
+ }
+ // maybe the eclipse BPEL editor is not installed?
+ // fall back to using '.bpel' file extension
+ if ("bpel".equals(((IFile)res).getFileExtension()))
+ return true;
+ }
+ }
+ catch(Exception ex)
+ {
+ }
+ return false;
+ }
}
Modified: trunk/bpel/plugins/org.eclipse.bpel.common.ui/plugin.xml
===================================================================
--- trunk/bpel/plugins/org.eclipse.bpel.common.ui/plugin.xml 2010-04-20 14:37:39 UTC (rev
21556)
+++ trunk/bpel/plugins/org.eclipse.bpel.common.ui/plugin.xml 2010-04-20 15:12:10 UTC (rev
21557)
@@ -44,15 +44,4 @@
name="org.eclipse.bpel.common.ui.lineNumInObject">
</attribute>
</extension>
- <extension
- point="org.eclipse.core.runtime.contentTypes">
- <content-type
- base-type="org.eclipse.core.runtime.xml"
- default-charset="UTF-8"
- file-extensions="bpel,bpel2"
- id="org.eclipse.bpel.common.ui.bpel.content-type"
- name="BPEL Process"
- priority="normal"/>
- </extension>
-
</plugin>
Modified: trunk/bpel/plugins/org.eclipse.bpel.model/build.properties
===================================================================
--- trunk/bpel/plugins/org.eclipse.bpel.model/build.properties 2010-04-20 14:37:39 UTC
(rev 21556)
+++ trunk/bpel/plugins/org.eclipse.bpel.model/build.properties 2010-04-20 15:12:10 UTC
(rev 21557)
@@ -10,8 +10,7 @@
# JBoss by Red Hat - subsequent contributions and maintenance
###############################################################################
bin.includes = META-INF/,\
- plugin.*,\
- .
+ plugin.*
src.includes = .classpath,\
.cvsignore,\
.project,\
@@ -19,4 +18,3 @@
src/,\
META-INF/,\
plugin.*
-source.. = src/
Modified: trunk/bpel/plugins/org.eclipse.bpel.model/plugin.xml
===================================================================
--- trunk/bpel/plugins/org.eclipse.bpel.model/plugin.xml 2010-04-20 14:37:39 UTC (rev
21556)
+++ trunk/bpel/plugins/org.eclipse.bpel.model/plugin.xml 2010-04-20 15:12:10 UTC (rev
21557)
@@ -78,6 +78,12 @@
<provider
class="org.eclipse.bpel.model.resource.ResourceSetProvider"/>
</extension>
-
+ <!--
https://jira.jboss.org/jira/browse/JBIDE-6006 -->
+ <extension point="org.eclipse.emf.ecore.content_parser">
+ <parser
+ class="org.eclipse.bpel.model.resource.BPELResourceFactoryImpl"
+ contentTypeIdentifier="org.eclipse.bpel.contenttype">
+ </parser>
+ </extension>
</plugin>
Modified:
trunk/bpel/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/resource/BPELResourceSetImpl.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/resource/BPELResourceSetImpl.java 2010-04-20
14:37:39 UTC (rev 21556)
+++
trunk/bpel/plugins/org.eclipse.bpel.model/src/org/eclipse/bpel/model/resource/BPELResourceSetImpl.java 2010-04-20
15:12:10 UTC (rev 21557)
@@ -21,6 +21,8 @@
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.content.IContentDescription;
+import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.URIConverter;
@@ -39,6 +41,8 @@
public class BPELResourceSetImpl extends ResourceSetImpl implements
IResourceChangeListener {
+ public static final String BPEL_CONTENT_TYPE = "org.eclipse.bpel.contenttype";
//$NON-NLS-1$
+
public BPELResourceSetImpl() {
super();
// FIX ME: This should not have dependency on running eclipse.
@@ -243,7 +247,8 @@
// TODO: Temporary hack
// Actually we should remove all resources from the resourceSet,
// but for some reasons bpel files can't be removed now
- if ("bpel".equals(((IFile) resource).getFileExtension())){
+ //
https://jira.jboss.org/jira/browse/JBIDE-6006
+ if (isBPELFile(resource)){
continue;
}
@@ -286,4 +291,22 @@
}
}
+ public static boolean isBPELFile(IResource res)
+ {
+ try
+ {
+ if (res.getType() == IResource.FILE) {
+ IContentDescription desc = ((IFile) res).getContentDescription();
+ if (desc != null) {
+ IContentType type = desc.getContentType();
+ if (type.getId().equals(BPEL_CONTENT_TYPE))
+ return true;
+ }
+ }
+ }
+ catch(Exception ex)
+ {
+ }
+ return false;
+ }
}
Modified: trunk/bpel/plugins/org.eclipse.bpel.ui/plugin.xml
===================================================================
--- trunk/bpel/plugins/org.eclipse.bpel.ui/plugin.xml 2010-04-20 14:37:39 UTC (rev 21556)
+++ trunk/bpel/plugins/org.eclipse.bpel.ui/plugin.xml 2010-04-20 15:12:10 UTC (rev 21557)
@@ -6,7 +6,7 @@
<extension-point id="expressionEditors" name="Expression Language
Editors" schema="schemas/expressionEditors.exsd"/>
<extension-point id="actions" name="Actions"
schema="schemas/actions.exsd"/>
<extension-point id="modelListener" name="Model Listener"
schema="schemas/modelListener.exsd"/>
- <extension-point id="uiObjectFactories"
name="UIObjectFactories" schema="schema/uiObjectFactories.exsd"/>
+ <extension-point id="uiObjectFactories"
name="UIObjectFactories" schema="schemas/uiObjectFactories.exsd"/>
<extension
@@ -15,10 +15,12 @@
class="org.eclipse.bpel.ui.BPELMultipageEditorPart"
contributorClass="org.eclipse.bpel.ui.BPELMultiPageEditorActionBarContributor"
default="true"
- extensions="bpel"
- icon="icons/obj16/bpel.gif"
id="org.eclipse.bpel.ui.bpeleditor"
name="%BPEL_EDITOR_NAME">
+ <!-- use content type to identify BPEL files
https://jira.jboss.org/jira/browse/JBIDE-6006 -->
+ <contentTypeBinding
+ contentTypeId="org.eclipse.bpel.contenttype">
+ </contentTypeBinding>
</editor>
</extension>
<extension
@@ -640,4 +642,50 @@
uri="platform:/plugin/org.eclipse.bpel.ui/templates/fn.xml">
</registry>
</extension>
+
+ <!--
+
https://jira.jboss.org/jira/browse/JBIDE-6006
+ Content Type recognition for BPEL files
+ NOTE: eclipse does not support recognition of file types for files without extensions
+ See eclipse bugzilla
https://bugs.eclipse.org/bugs/show_bug.cgi?id=46297
+ -->
+ <extension
+ point="org.eclipse.core.contenttype.contentTypes">
+ <content-type
+ base-type="org.eclipse.core.runtime.xml"
+ id="org.eclipse.bpel.contenttype"
+ name="BPEL Editor File"
+ file-extensions="bpel,bpel2,xml"
+ priority="normal">
+ <describer
+
class="org.eclipse.core.runtime.content.XMLRootElementContentDescriber2">
+ <parameter
+ name="element"
+
value="{http://docs.oasis-open.org/wsbpel/2.0/process/executable}pro...
+ </describer>
+ </content-type>
+ </extension>
+ <extension
+ point="org.eclipse.ui.decorators">
+ <decorator
+ adaptable="true"
+ icon="icons/obj16/bpel.gif"
+ id="org.eclipse.bpel.ui.icondecorator"
+ label="BPEL Resource Decorator"
+ lightweight="true"
+ location="TOP_LEFT"
+ state="true">
+ <enablement>
+ <and>
+ <objectClass
+ name="org.eclipse.core.resources.IFile">
+ </objectClass>
+ <objectState
+ name="contentTypeId"
+ value="org.eclipse.bpel.contenttype">
+ </objectState>
+ </and>
+ </enablement>
+ </decorator>
+ </extension>
</plugin>
Modified:
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/IBPELUIConstants.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/IBPELUIConstants.java 2010-04-20
14:37:39 UTC (rev 21556)
+++
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/IBPELUIConstants.java 2010-04-20
15:12:10 UTC (rev 21557)
@@ -17,6 +17,7 @@
public interface IBPELUIConstants {
// File extensions
+ @Deprecated // use content type instead of bpel file extensions
public final String EXTENSION_BPEL = "bpel"; //$NON-NLS-1$
public final String EXTENSION_WSDL = "wsdl"; //$NON-NLS-1$
public final String EXTENSION_WSIL = "wsil"; //$NON-NLS-1$
Modified: trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/Templates.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/Templates.java 2010-04-20
14:37:39 UTC (rev 21556)
+++
trunk/bpel/plugins/org.eclipse.bpel.ui/src/org/eclipse/bpel/ui/Templates.java 2010-04-20
15:12:10 UTC (rev 21557)
@@ -55,6 +55,7 @@
static final String DEFAULT_ENCODING = "UTF-8"; //$NON-NLS-1$
/** the main bpel file has this extension */
+ @Deprecated // use content type instead of bpel file extensions
static final String BPEL_FILE_EXTENSION = ".bpel"; //$NON-NLS-1$
/** Entries which are directories of the bundle */
Modified:
trunk/bpel/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/Builder.java
===================================================================
---
trunk/bpel/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/Builder.java 2010-04-20
14:37:39 UTC (rev 21556)
+++
trunk/bpel/plugins/org.eclipse.bpel.validator/src/org/eclipse/bpel/validator/Builder.java 2010-04-20
15:12:10 UTC (rev 21557)
@@ -34,6 +34,8 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.content.IContentDescription;
+import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.wst.wsdl.WSDLElement;
@@ -52,6 +54,10 @@
@SuppressWarnings("nls")
public class Builder extends IncrementalProjectBuilder {
+ //
https://jira.jboss.org/jira/browse/JBIDE-6006
+ // Content Type ID for org.eclipse.bpel editor files
+ public static final String BPEL_CONTENT_TYPE = "org.eclipse.bpel.contenttype";
//$NON-NLS-1$
+
Date created = new Date();
boolean bDebug = false;
@@ -196,9 +202,9 @@
IFile file = (IFile) resource;
p("File Resource : " + file.getName() );
-
- // TODO: This should be a better check
- if ( file.getName().endsWith(".bpel") ||
file.getName().endsWith(".wsdl")) {
+ //
https://jira.jboss.org/jira/browse/JBIDE-6006
+ // use content type to check for BPEL files
+ if ( isBPELFile(file) || file.getName().endsWith(".wsdl")) {
IProject project = file.getProject();
validate(project, monitor);
// file.deleteMarkers(IBPELMarker.ID, true, IResource.DEPTH_INFINITE);
@@ -227,7 +233,8 @@
public boolean visit(IResource resource) throws CoreException {
if( resource.getType() == IResource.FILE){
- if("bpel".equals(resource.getFileExtension())){
+ //
https://jira.jboss.org/jira/browse/JBIDE-6006
+ if(isBPELFile(resource)){
bpelFolders.add((IFile)resource);
return false;
}
@@ -375,5 +382,24 @@
}
}
+ //
https://jira.jboss.org/jira/browse/JBIDE-6006
+ public static boolean isBPELFile(IResource res)
+ {
+ try
+ {
+ if (res.getType() == IResource.FILE) {
+ IContentDescription desc = ((IFile) res).getContentDescription();
+ if (desc != null) {
+ IContentType type = desc.getContentType();
+ if (type.getId().equals(BPEL_CONTENT_TYPE))
+ return true;
+ }
+ }
+ }
+ catch(Exception ex)
+ {
+ }
+ return false;
+ }
}