Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 58645 Details for
Bug 172617
No Code generation menu when right clicking the dd file
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch for this issue
patch_172617.txt (text/plain), 13.87 KB, created by
Saurabh Dravid
on 2007-02-09 05:51:04 EST
(
hide
)
Description:
Patch for this issue
Filename:
MIME Type:
Creator:
Saurabh Dravid
Created:
2007-02-09 05:51:04 EST
Size:
13.87 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.tptp.wsdm.editor >Index: src/org/eclipse/tptp/wsdm/tooling/editor/dde/util/internal/DdeUtil.java >=================================================================== >RCS file: /cvsroot/ganges/org.eclipse.tptp.wsdm.editor/src/org/eclipse/tptp/wsdm/tooling/editor/dde/util/internal/DdeUtil.java,v >retrieving revision 1.1 >diff -u -r1.1 DdeUtil.java >--- src/org/eclipse/tptp/wsdm/tooling/editor/dde/util/internal/DdeUtil.java 8 Feb 2007 19:40:13 -0000 1.1 >+++ src/org/eclipse/tptp/wsdm/tooling/editor/dde/util/internal/DdeUtil.java 9 Feb 2007 10:47:30 -0000 >@@ -356,25 +356,14 @@ > */ > public static MuseType loadDecriptorFile(IFile file) > { >- URI uri = URI.createPlatformResourceURI(file.getFullPath().toString()); >- if (uri == null) >- return null; >- MuseType mt = loadMuseType(uri); >+ MuseType mt = loadMuseType(file); > return mt; > } > > // Return MuseType at URI. >- private static MuseType loadMuseType(URI uri) >+ private static MuseType loadMuseType(IFile file) > { >- ensureMusePackagePresent(); >- ResourceSet resourceSet = new ResourceSetImpl(); >- resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap() >- .put(Resource.Factory.Registry.DEFAULT_EXTENSION, >- new MyDescriptorResourceFactoryImpl()); >- resourceSet.getPackageRegistry().put(DescriptorPackage.eNS_URI, >- DescriptorPackage.eINSTANCE); >- Resource resource = resourceSet.getResource(uri, true); >- DocumentRoot root = (DocumentRoot) resource.getContents().get(0); >+ DocumentRoot root = getDocRoot(file); > RootType rt = root.getRoot(); > return rt.getMuse(); > } >@@ -932,4 +921,26 @@ > muse.getCustomSerializer().add(serializers[serializersIndex]); > } > } >+ >+ /** >+ * This method takes a dd file and returns the document root of the file >+ * @param file - IFile which is a dd file >+ * @return DocumentRoot of the file. >+ */ >+ public static DocumentRoot getDocRoot(IFile file) >+ { >+ URI uri = URI.createPlatformResourceURI(file.getFullPath().toString()); >+ if (uri == null) >+ return null; >+ ensureMusePackagePresent(); >+ ResourceSet resourceSet = new ResourceSetImpl(); >+ resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap() >+ .put(Resource.Factory.Registry.DEFAULT_EXTENSION, >+ new MyDescriptorResourceFactoryImpl()); >+ resourceSet.getPackageRegistry().put(DescriptorPackage.eNS_URI, >+ DescriptorPackage.eINSTANCE); >+ Resource resource = resourceSet.getResource(uri, true); >+ DocumentRoot root = (DocumentRoot) resource.getContents().get(0); >+ return root; >+ } > } >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/ganges/org.eclipse.tptp.wsdm.editor/plugin.xml,v >retrieving revision 1.1 >diff -u -r1.1 plugin.xml >--- plugin.xml 8 Feb 2007 19:40:11 -0000 1.1 >+++ plugin.xml 9 Feb 2007 10:47:30 -0000 >@@ -144,13 +144,26 @@ > adaptable="false" > objectClass="org.eclipse.core.resources.IResource" > nameFilter="*.mrt" >- id="org.eclipse.tptp.wsdm.tooling.objectContribution1"> >+ id="org.eclipse.tptp.wsdm.tooling.codegen.mrt"> > <action > enablesFor="1" > label="Generate Java Code" > icon="icons/obj16/mrt_obj.gif" > class="org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.Generation" >- id="org.eclipse.tptp.wsdm.tooling.action1"/> >+ id="org.eclipse.tptp.wsdm.tooling.codegen.mrt.action"/> >+ </objectContribution> >+ >+ <objectContribution >+ adaptable="false" >+ objectClass="org.eclipse.core.resources.IResource" >+ nameFilter="*.dd" >+ id="org.eclipse.tptp.wsdm.tooling.codegen.dd"> >+ <action >+ enablesFor="1" >+ label="Generate Java Code" >+ icon="icons/obj16/mrt_obj.gif" >+ class="org.eclipse.tptp.wsdm.tooling.codegen.dd.internal.Generation" >+ id="org.eclipse.tptp.wsdm.tooling.codegen.dd.action"/> > </objectContribution> > </extension> > >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/dd/internal/Generation.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/dd/internal/Generation.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/dd/internal/Generation.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/codegen/dd/internal/Generation.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,64 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are 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: >+ * Balan Subramanian (bsubram@us.ibm.com) >+ * Andrew Eberbach (aeberbac@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.codegen.dd.internal; >+ >+import org.eclipse.core.resources.IFile; >+import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.viewers.ISelection; >+import org.eclipse.jface.viewers.StructuredSelection; >+import org.eclipse.jface.wizard.WizardDialog; >+import org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.NewProjectWizard; >+import org.eclipse.ui.IObjectActionDelegate; >+import org.eclipse.ui.IWorkbenchPart; >+ >+/** >+ * This class provides the action to generate smashed WSDL and Java code from a >+ * Deployment Descriptore file. >+ */ >+public class Generation implements IObjectActionDelegate { >+ >+ private IWorkbenchPart _targetPart; >+ >+ private StructuredSelection _selection; >+ >+ /** >+ * Shows the <code>NewProjectWizards</code> after wrapping the selected >+ * Deployment Descriptor file in a <code>DescriptorHelper</code>. >+ */ >+ public void run(IAction action) { >+ //Get the file from the selected element >+ //It should be the first element in the selection >+ IFile ddFile = (IFile) _selection.getFirstElement(); >+ >+ //Create a code generation delegate which will >+ //some of the heavy-lifting during code generation so >+ //the UI thread can stay responsive >+ DDCodeGenerationDelegate delegate = new DDCodeGenerationDelegate(ddFile); >+ >+ //Open up the wizard dialog for code generation >+ NewProjectWizard npw = new NewProjectWizard(delegate); >+ WizardDialog wd = new WizardDialog(_targetPart.getSite().getShell(),npw); >+ wd.open(); >+ } >+ >+ public void setActivePart(IAction action, IWorkbenchPart targetPart) { >+ _targetPart = targetPart; >+ } >+ >+ public void selectionChanged(IAction action, ISelection selection) { >+ if (selection instanceof StructuredSelection) { >+ _selection = (StructuredSelection) selection; >+ } >+ } >+} >Index: src/org/eclipse/tptp/wsdm/tooling/codegen/dd/internal/DDCodeGenerationDelegate.java >=================================================================== >RCS file: src/org/eclipse/tptp/wsdm/tooling/codegen/dd/internal/DDCodeGenerationDelegate.java >diff -N src/org/eclipse/tptp/wsdm/tooling/codegen/dd/internal/DDCodeGenerationDelegate.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/tptp/wsdm/tooling/codegen/dd/internal/DDCodeGenerationDelegate.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,186 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are 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: >+ * Andrew Eberbach (aeberbac@us.ibm.com) >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.tptp.wsdm.tooling.codegen.dd.internal; >+ >+import java.io.IOException; >+import java.util.ArrayList; >+import java.util.Collections; >+import java.util.List; >+ >+import org.apache.ws.muse.descriptor.CapabilityType; >+import org.apache.ws.muse.descriptor.DescriptorPackage; >+import org.apache.ws.muse.descriptor.DocumentRoot; >+import org.apache.ws.muse.descriptor.MuseType; >+import org.apache.ws.muse.descriptor.ResourceTypeType; >+import org.apache.ws.muse.descriptor.RootType; >+import org.eclipse.core.resources.IFile; >+import org.eclipse.core.runtime.SubProgressMonitor; >+import org.eclipse.emf.common.util.URI; >+import org.eclipse.emf.ecore.resource.Resource; >+import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; >+import org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.CodeGenerationDelegate; >+import org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.DescriptorHelper; >+import org.eclipse.tptp.wsdm.tooling.codegen.mrt.internal.SubscriptionManagerInspector; >+import org.eclipse.tptp.wsdm.tooling.editor.dde.util.internal.DdeUtil; >+import org.eclipse.tptp.wsdm.tooling.model.capabilities.Capability; >+import org.eclipse.tptp.wsdm.tooling.model.manageableResourceType.ManageableResourceType; >+import org.eclipse.tptp.wsdm.tooling.nls.messages.dde.internal.Messages; >+import org.eclipse.tptp.wsdm.tooling.util.internal.MrtUtils; >+import org.eclipse.tptp.wsdm.tooling.util.internal.MyDescriptorResourceFactoryImpl; >+import org.eclipse.tptp.wsdm.tooling.util.internal.WsdmToolingLog; >+ >+/** >+ * A Deployment Descriptor-specifc resolver. This will go through the Deployment >+ * Descriptor and find all of the MCap files and resolve them and merge them >+ * into WSDL documents. >+ */ >+public class DDCodeGenerationDelegate implements CodeGenerationDelegate { >+ >+ /** >+ * The IFile of the unparsed descriptor file >+ */ >+ private IFile _descriptorFile; >+ >+ public DDCodeGenerationDelegate(IFile descriptorFile) { >+ _descriptorFile = descriptorFile; >+ } >+ >+ public DescriptorHelper run(SubProgressMonitor progressMonitor) throws Exception { >+ inspectForSubscriptionManager(); >+ return new DescriptorHelper(_descriptorFile); >+ } >+ >+ private void inspectForSubscriptionManager() >+ { >+ DocumentRoot docRoot = DdeUtil.getDocRoot(_descriptorFile); >+ SubscriptionManagerInspector inspector = new SubscriptionManagerInspector(docRoot); >+ inspector.setMrtParentDirectory(_descriptorFile.getParent().getFullPath() >+ .toString()); >+ RootType root = docRoot.getRoot(); >+ MuseType mt = root.getMuse(); >+ List rts = mt.getResourceType(); >+ if(rts == null || rts.size() == 0) >+ { >+ return; >+ } >+ List mrts = subManagerAdded(rts);// This method returns a list of mrts if subscriptionmanager is not already added. else null >+ if(mrts == null || mrts.size() == 0) >+ { >+ return; >+ } >+ for(int i = 0; i < mrts.size(); i++) >+ { >+ ManageableResourceType mrt = (ManageableResourceType) mrts.get(i); >+ Capability[] capDefs = getMrtCapabilities(mrt); >+ ResourceTypeType subMgr = inspector.inspect(capDefs); >+ if(subMgr == null) >+ { >+ continue; >+ } >+ else >+ { >+ mt.getResourceType().add(subMgr); >+ root.setMuse(mt); >+ docRoot.setRoot(root); >+ save(docRoot); >+ break; >+ } >+ } >+ } >+ >+ private Capability[] getMrtCapabilities(ManageableResourceType mrt) { >+ Capability[] capList = null; >+ try { >+ capList = MrtUtils.getCapabilities(mrt); >+ } catch (Exception e) { >+ WsdmToolingLog >+ .logError( >+ org.eclipse.tptp.wsdm.tooling.nls.messages.mrt.internal.Messages.MRT_ERROR_CANNOT_TRACE_CAPS, >+ e); >+ } >+ >+ if (capList != null) >+ return capList; >+ return new Capability[0]; >+ } >+ >+ private void save(DocumentRoot root) >+ { >+ ensureMusePackagePresent(); >+ URI ddFileURI = URI.createPlatformResourceURI(_descriptorFile.getFullPath().toString()); >+ ResourceSetImpl rsImpl = new ResourceSetImpl(); >+ rsImpl.getResourceFactoryRegistry().getExtensionToFactoryMap() >+ .put(Resource.Factory.Registry.DEFAULT_EXTENSION, >+ new MyDescriptorResourceFactoryImpl()); >+ rsImpl.getPackageRegistry().put(DescriptorPackage.eNS_URI, >+ DescriptorPackage.eINSTANCE); >+ Resource ddRes = rsImpl.getResource(ddFileURI, true); >+ ddRes.getContents().remove(0); >+ ddRes.getContents().add(root); >+ try { >+ ddRes.save(Collections.EMPTY_MAP); >+ } catch (IOException e) { >+ e.printStackTrace(); >+ } >+ } >+ >+ private void ensureMusePackagePresent() >+ { >+ // Ensure EMF knows about Muse descriptor >+ if (DescriptorPackage.eINSTANCE == null) >+ { >+ WsdmToolingLog.logError(Messages.FAILED_TO_INITIALIZE_MUSE_DESCRIPTOR_ERROR_, new Throwable()); >+ } >+ } >+ >+ /** >+ * This method takes alist of resourceTypes and checks whether subscriptionmanager is already present.<br> >+ * if so returns null. else converts the resourcetypes into mrts and returns the list. >+ * @param rts >+ * @return >+ */ >+ private List subManagerAdded(List rts) >+ { >+ List mrts = new ArrayList(); >+ if(rts == null || rts.size() == 0) >+ { >+ return null; >+ } >+ for(int i = 0; i < rts.size(); i++) >+ { >+ ResourceTypeType rt = (ResourceTypeType) rts.get(i); >+ IFile mrtFile = DdeUtil.getIFileFromName(DdeUtil >+ .getMrtFileName(rt.getWsdl().getWsdlFile()), "mrt"); >+ if(mrtFile == null) >+ { >+ continue; >+ } >+ ManageableResourceType mrt = DdeUtil.loadMrtFile(mrtFile); >+ mrts.add(mrt); >+ List capList = DdeUtil.getCapabilitiesFromMRT(mrt); >+ if(capList == null || capList.size() == 0) >+ { >+ continue; >+ } >+ for(int j = 0; j < capList.size(); j++) >+ { >+ CapabilityType ctype = (CapabilityType) capList.get(j); >+ if(ctype.getCapabilityUri().equals("http://docs.oasis-open.org/wsn/bw-2/SubscriptionManager")) >+ { >+ return null; >+ } >+ } >+ } >+ return mrts; >+ } >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 172617
: 58645