Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Serialize EMF objects in a XMI similar file with another file extension humanresourcemodel(file.humanresourcemodel instead of file.xmi)
Serialize EMF objects in a XMI similar file with another file extension humanresourcemodel [message #550821] Wed, 04 August 2010 12:53 Go to next message
Ugur Kocak is currently offline Ugur KocakFriend
Messages: 33
Registered: February 2010
Member
Hi,

I have an ecore model called humanresourcemodel.
My aim is to serialize normal some objects with their attributes and references. The generated file with the serialized file shouldn't have an extension like .xmi. It should have the extension file.humanresourcemodel because I want to open this file the plugin editor of this model humanresourcemodel.

I have built some lines of code but the problem is with the save() method. I think I have to use the methods from the humanresourcemodel.provider and humanresourcemodel.presentation packages. Please can somebody give me any hint or better a pattern source code.

Thank you in advance


public class SerializationUtility {

    public void serialize() throws IOException {

	HumanresourcemodelResourceFactoryImpl hrfi = new   HumanresourcemodelResourceFactoryImpl();

	URI fileURI = URI.createFileURI( "ResourcesHRM.humanresourcemodel");

	Resource resource = hrfi.createResource( fileURI);

	Map<Object, Object> options = new HashMap<Object, Object>();

	options.put( XMLResource.OPTION_ENCODING, new HumanresourcemodelResourceFactoryImpl());

        Collection<OrganizationalUnit> orgUnits =      OrganizationalUnitMapping.orgUnitMap.values();
	Iterator<OrganizationalUnit> itr11 = orgUnits.iterator();
	while ( itr11.hasNext()) {
	    OrganizationalUnit next = itr11.next();
	    resource.getContents().add( next);
	}

       //previously resource.save
       this.save();
       }
    
     protected void save(){ }
}

Re: Serialize EMF objects in a XMI similar file with another file extension humanresourcemodel [message #550840 is a reply to message #550821] Wed, 04 August 2010 13:36 Go to previous messageGo to next message
Bryan Hunt is currently offline Bryan HuntFriend
Messages: 366
Registered: July 2009
Senior Member
This should do what you want

ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("humanresourcemodel", new XMLResourceFactoryImpl());
Re: Serialize EMF objects in a XMI similar file with another file extension humanresourcemodel [message #550841 is a reply to message #550821] Wed, 04 August 2010 13:38 Go to previous messageGo to next message
Bryan Hunt is currently offline Bryan HuntFriend
Messages: 366
Registered: July 2009
Senior Member
This should do what you want

ResourceSet resourceSet = new ResourceSetImpl();
resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("humanresourcemodel", new XMIResourceFactoryImpl());


Oops, I gave you an XML factory in my previous response when you wanted XMI. The above code will give you an XMI resource.
Re: Serialize EMF objects in a XMI similar file with another file extension humanresourcemodel [message #550853 is a reply to message #550840] Wed, 04 August 2010 13:56 Go to previous messageGo to next message
Ugur Kocak is currently offline Ugur KocakFriend
Messages: 33
Registered: February 2010
Member
Hi Bryan,

Thank you for the hint.
It creates the file but I can't open it in an editor of the model.

Here is a terrible list of errors when I try to open the file in an editor of a new Eclipse App

org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri 'http://www.omg.org/XMI' not found. (platform:/resource/Humanresourcemodel/model/ResourcesHRM.hu manresourcemodel, 2, 120)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(X MLHandler.java:2591)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getFactoryForPrefi x(XMLHandler.java:2422)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:1299)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:1468)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:1019)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:1001)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:712)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator. startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm pl$ContentDriver.scanRootElementHook(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm pl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm pl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U nknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSA XParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1494)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1282)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)
at humanresourcemodel.presentation.HumanresourcemodelEditor.cre ateModel(HumanresourcemodelEditor.java:951)
at humanresourcemodel.presentation.HumanresourcemodelEditor.cre atePages(HumanresourcemodelEditor.java:1008)
at org.eclipse.ui.part.MultiPageEditorPart.createPartControl(Mu ltiPageEditorPart.java:348)
at org.eclipse.ui.internal.EditorReference.createPartHelper(Edi torReference.java:670)
at org.eclipse.ui.internal.EditorReference.createPart(EditorRef erence.java:465)
at org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:595)
at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:31 3)
at org.eclipse.ui.internal.presentations.PresentablePart.setVis ible(PresentablePart.java:180)
at org.eclipse.ui.internal.presentations.util.PresentablePartFo lder.select(PresentablePartFolder.java:270)
at org.eclipse.ui.internal.presentations.util.LeftToRightTabOrd er.select(LeftToRightTabOrder.java:65)
at org.eclipse.ui.internal.presentations.util.TabbedStackPresen tation.selectPart(TabbedStackPresentation.java:473)
at org.eclipse.ui.internal.PartStack.refreshPresentationSelecti on(PartStack.java:1254)
at org.eclipse.ui.internal.PartStack.setSelection(PartStack.jav a:1207)
at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:16 06)
at org.eclipse.ui.internal.PartStack.add(PartStack.java:497)
at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103 )
at org.eclipse.ui.internal.PartStack.add(PartStack.java:483)
at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112 )
at org.eclipse.ui.internal.EditorSashContainer.addEditor(Editor SashContainer.java:63)
at org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorA reaHelper.java:225)
at org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAre aHelper.java:213)
at org.eclipse.ui.internal.EditorManager.createEditorTab(Editor Manager.java:778)
at org.eclipse.ui.internal.EditorManager.openEditorFromDescript or(EditorManager.java:677)
at org.eclipse.ui.internal.EditorManager.openEditor(EditorManag er.java:638)
at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched( WorkbenchPage.java:2860)
at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(Workben chPage.java:2768)
at org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPag e.java:2760)
at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.j ava:2711)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:70)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2707)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2691)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2682)
at org.eclipse.ui.ide.IDE.openEditor(IDE.java:651)
at org.eclipse.ui.ide.IDE.openEditor(IDE.java:610)
at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInE ditor(EditorUtility.java:365)
at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInE ditor(EditorUtility.java:168)
at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:22 9)
at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:20 8)
at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchR un(SelectionDispatchAction.java:274)
at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(Selec tionDispatchAction.java:250)
at org.eclipse.jdt.internal.ui.packageview.PackageExplorerActio nGroup.handleOpen(PackageExplorerActionGroup.java:373)
at org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$ 4.open(PackageExplorerPart.java:526)
at org.eclipse.ui.OpenAndLinkWithEditorHelper$InternalListener. open(OpenAndLinkWithEditorHelper.java:48)
at org.eclipse.jface.viewers.StructuredViewer$2.run(StructuredV iewer.java:845)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:17 5)
at org.eclipse.jface.viewers.StructuredViewer.fireOpen(Structur edViewer.java:843)
at org.eclipse.jface.viewers.StructuredViewer.handleOpen(Struct uredViewer.java:1131)
at org.eclipse.jface.viewers.StructuredViewer$6.handleOpen(Stru cturedViewer.java:1235)
at org.eclipse.jface.util.OpenStrategy.fireOpenEvent(OpenStrate gy.java:264)
at org.eclipse.jface.util.OpenStrategy.access$2(OpenStrategy.ja va:258)
at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrate gy.java:298)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:4066)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3657)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2629)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:24 27)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
at org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:663)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:115)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
at org.eclipse.equinox.launcher.Main.main(Main.java:1383)

org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri 'http://www.omg.org/XMI' not found. (platform:/resource/Humanresourcemodel/model/ResourcesHRM.hu manresourcemodel, 2, 120)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(X MLHandler.java:2591)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getFactoryForPrefi x(XMLHandler.java:2422)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType (XMLHandler.java:1299)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM LHandler.java:1468)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML Handler.java:1019)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:1001)
at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa ndler.java:712)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator. startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm pl$ContentDriver.scanRootElementHook(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm pl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm pl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS cannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuratio n.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U nknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser .parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSA XParser.parse(Unknown Source)
at javax.xml.parsers.SAXParser.parse(Unknown Source)
at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl. java:181)
at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes ourceImpl.java:180)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1494)
at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour ceImpl.java:1282)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo ad(ResourceSetImpl.java:255)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo adHelper(ResourceSetImpl.java:270)
at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou rce(ResourceSetImpl.java:397)
at humanresourcemodel.presentation.HumanresourcemodelEditor.cre ateModel(HumanresourcemodelEditor.java:951)
at humanresourcemodel.presentation.HumanresourcemodelEditor.cre atePages(HumanresourcemodelEditor.java:1008)
at org.eclipse.ui.part.MultiPageEditorPart.createPartControl(Mu ltiPageEditorPart.java:348)
at org.eclipse.ui.internal.EditorReference.createPartHelper(Edi torReference.java:670)
at org.eclipse.ui.internal.EditorReference.createPart(EditorRef erence.java:465)
at org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb enchPartReference.java:595)
at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:31 3)
at org.eclipse.ui.internal.presentations.PresentablePart.setVis ible(PresentablePart.java:180)
at org.eclipse.ui.internal.presentations.util.PresentablePartFo lder.select(PresentablePartFolder.java:270)
at org.eclipse.ui.internal.presentations.util.LeftToRightTabOrd er.select(LeftToRightTabOrder.java:65)
at org.eclipse.ui.internal.presentations.util.TabbedStackPresen tation.selectPart(TabbedStackPresentation.java:473)
at org.eclipse.ui.internal.PartStack.refreshPresentationSelecti on(PartStack.java:1254)
at org.eclipse.ui.internal.PartStack.setSelection(PartStack.jav a:1207)
at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:16 06)
at org.eclipse.ui.internal.PartStack.add(PartStack.java:497)
at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103 )
at org.eclipse.ui.internal.PartStack.add(PartStack.java:483)
at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112 )
at org.eclipse.ui.internal.EditorSashContainer.addEditor(Editor SashContainer.java:63)
at org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorA reaHelper.java:225)
at org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAre aHelper.java:213)
at org.eclipse.ui.internal.EditorManager.createEditorTab(Editor Manager.java:778)
at org.eclipse.ui.internal.EditorManager.openEditorFromDescript or(EditorManager.java:677)
at org.eclipse.ui.internal.EditorManager.openEditor(EditorManag er.java:638)
at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched( WorkbenchPage.java:2860)
at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(Workben chPage.java:2768)
at org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPag e.java:2760)
at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.j ava:2711)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator .java:70)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2707)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2691)
at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa ge.java:2682)
at org.eclipse.ui.ide.IDE.openEditor(IDE.java:651)
at org.eclipse.ui.ide.IDE.openEditor(IDE.java:610)
at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInE ditor(EditorUtility.java:365)
at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInE ditor(EditorUtility.java:168)
at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:22 9)
at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:20 8)
at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchR un(SelectionDispatchAction.java:274)
at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(Selec tionDispatchAction.java:250)
at org.eclipse.jdt.internal.ui.packageview.PackageExplorerActio nGroup.handleOpen(PackageExplorerActionGroup.java:373)
at org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$ 4.open(PackageExplorerPart.java:526)
at org.eclipse.ui.OpenAndLinkWithEditorHelper$InternalListener. open(OpenAndLinkWithEditorHelper.java:48)
at org.eclipse.jface.viewers.StructuredViewer$2.run(StructuredV iewer.java:845)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:17 5)
at org.eclipse.jface.viewers.StructuredViewer.fireOpen(Structur edViewer.java:843)
at org.eclipse.jface.viewers.StructuredViewer.handleOpen(Struct uredViewer.java:1131)
at org.eclipse.jface.viewers.StructuredViewer$6.handleOpen(Stru cturedViewer.java:1235)
at org.eclipse.jface.util.OpenStrategy.fireOpenEvent(OpenStrate gy.java:264)
at org.eclipse.jface.util.OpenStrategy.access$2(OpenStrategy.ja va:258)
at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrate gy.java:298)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja va:4066)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java :3657)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav a:2629)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:24 27)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
at org.eclipse.core.databinding.observable.Realm.runWithDefault (Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work bench.java:663)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j ava:149)
at org.eclipse.ui.internal.ide.application.IDEApplication.start (IDEApplication.java:115)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips eAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher .start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS tarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 619)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
Re: Serialize EMF objects in a XMI similar file with another file extension humanresourcemodel [message #550854 is a reply to message #550821] Wed, 04 August 2010 14:01 Go to previous messageGo to next message
Bryan Hunt is currently offline Bryan HuntFriend
Messages: 366
Registered: July 2009
Senior Member
There's also an Eclipse extension point to register a file extension with a factory that would probably be a better solution for you.

<extension point="org.eclipse.emf.ecore.extension_parser"> 
  <parser type="humanresourcemodel" class="org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl"/> 
</extension>
Re: Serialize EMF objects in a XMI similar file with another file extension humanresourcemodel [message #550864 is a reply to message #550854] Wed, 04 August 2010 14:14 Go to previous messageGo to next message
Ugur Kocak is currently offline Ugur KocakFriend
Messages: 33
Registered: February 2010
Member
Thank you again.
Do you think I can do this with the HumanresourcemodelResourceFactoryImpl() instead of the XMIResourceFactoryImpl().
I hope then the edtior will open the file.

Br
Ugur
Re: Serialize EMF objects in a XMI similar file with another file extension humanresourcemodel [message #550867 is a reply to message #550864] Wed, 04 August 2010 14:18 Go to previous messageGo to next message
Bryan Hunt is currently offline Bryan HuntFriend
Messages: 366
Registered: July 2009
Senior Member
Ugur Kocak wrote on Wed, 04 August 2010 10:14

Do you think I can do this with the HumanresourcemodelResourceFactoryImpl() instead of the XMIResourceFactoryImpl().
I hope then the edtior will open the file.



You can register any resource factory and whenever EMF sees that file extension, it will use that factory to create the resource.
Re: Serialize EMF objects in a XMI similar file with another file extension humanresourcemodel [message #550869 is a reply to message #550867] Wed, 04 August 2010 14:28 Go to previous messageGo to next message
Ugur Kocak is currently offline Ugur KocakFriend
Messages: 33
Registered: February 2010
Member
should this registration be for the editor and edit project. I haven't any experiences with defining extension points

regards
Ugur
Re: Serialize EMF objects in a XMI similar file with another file extension humanresourcemodel [message #550877 is a reply to message #550821] Wed, 04 August 2010 13:49 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Ugur,

Try invoking "Generate Test Code" and then look at how the generated
HumanresourcemodelExample works. That's the approach you'd want to use
for a stand alone application. Within Eclipse, the resource factory
should already be registered by the entries in the plugin.xml for the model.


Ugur Kocak wrote:
> Hi,
>
> I have an ecore model called humanresourcemodel.
> My aim is to serialize normal some objects with their attributes and
> references. The generated file with the serialized file shouldn't have
> an extension like .xmi. It should have the extension
> file.humanresourcemodel because I want to open this file the plugin
> editor of this model humanresourcemodel.
>
> I have built some lines of code but the problem is with the save()
> method. I think I have to use the methods from the
> humanresourcemodel.provider and humanresourcemodel.presentation
> packages. Please can somebody give me any hint or better a pattern
> source code.
>
> Thank you in advance
>
>
>
> public class SerializationUtility {
>
> public void serialize() throws IOException {
>
> HumanresourcemodelResourceFactoryImpl hrfi = new
> HumanresourcemodelResourceFactoryImpl();
>
> URI fileURI = URI.createFileURI( "ResourcesHRM.humanresourcemodel");
>
> Resource resource = hrfi.createResource( fileURI);
>
> Map<Object, Object> options = new HashMap<Object, Object>();
>
> options.put( XMLResource.OPTION_ENCODING, new
> HumanresourcemodelResourceFactoryImpl());
>
> Collection<OrganizationalUnit> orgUnits =
> OrganizationalUnitMapping.orgUnitMap.values();
> Iterator<OrganizationalUnit> itr11 = orgUnits.iterator();
> while ( itr11.hasNext()) {
> OrganizationalUnit next = itr11.next();
> resource.getContents().add( next);
> }
>
> //previously resource.save
> this.save();
> }
> protected void save(){ }
> }
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Serialize EMF objects in a XMI similar file with another file extension humanresourcemodel [message #550878 is a reply to message #550853] Wed, 04 August 2010 14:09 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Ugar,

No doubt you aren't using XMIResourceFactoryImpl to load a resource
that's based on an XMI serialization. Pay attention to Byran's comments
about how to register a resource factory.


Ugur Kocak wrote:
> Hi Bryan,
>
> Thank you for the hint.
> It creates the file but I can't open it in an editor of the model.
>
> Here is a terrible list of errors when I try to open the file in an
> editor of a new Eclipse App
>
> org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri
> 'http://www.omg.org/XMI' not found.
> (platform:/resource/Humanresourcemodel/model/ResourcesHRM.hu
> manresourcemodel, 2, 120)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(X
> MLHandler.java:2591)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getFactoryForPrefi
> x(XMLHandler.java:2422)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType
> (XMLHandler.java:1299)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM
> LHandler.java:1468)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML
> Handler.java:1019)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa
> ndler.java:1001)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa
> ndler.java:712)
> at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser
> .startElement(Unknown Source)
> at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.
> startElement(Unknown Source)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS
> cannerImpl.scanStartElement(Unknown Source)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm
> pl$ContentDriver.scanRootElementHook(Unknown Source)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS
> cannerImpl$FragmentContentDriver.next(Unknown Source)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm
> pl$PrologDriver.next(Unknown Source)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm
> pl.next(Unknown Source)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS
> cannerImpl.scanDocument(Unknown Source)
> at com.sun.org.apache.xerces.internal.parsers.XML11Configuratio
> n.parse(Unknown Source)
> at com.sun.org.apache.xerces.internal.parsers.XML11Configuratio
> n.parse(Unknown Source)
> at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U
> nknown Source)
> at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser
> .parse(Unknown Source)
> at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSA
> XParser.parse(Unknown Source)
> at javax.xml.parsers.SAXParser.parse(Unknown Source)
> at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.
> java:181)
> at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes
> ourceImpl.java:180)
> at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour
> ceImpl.java:1494)
> at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour
> ceImpl.java:1282)
> at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo
> ad(ResourceSetImpl.java:255)
> at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo
> adHelper(ResourceSetImpl.java:270)
> at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou
> rce(ResourceSetImpl.java:397)
> at humanresourcemodel.presentation.HumanresourcemodelEditor.cre
> ateModel(HumanresourcemodelEditor.java:951)
> at humanresourcemodel.presentation.HumanresourcemodelEditor.cre
> atePages(HumanresourcemodelEditor.java:1008)
> at org.eclipse.ui.part.MultiPageEditorPart.createPartControl(Mu
> ltiPageEditorPart.java:348)
> at org.eclipse.ui.internal.EditorReference.createPartHelper(Edi
> torReference.java:670)
> at org.eclipse.ui.internal.EditorReference.createPart(EditorRef
> erence.java:465)
> at org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb
> enchPartReference.java:595)
> at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:31 3)
> at org.eclipse.ui.internal.presentations.PresentablePart.setVis
> ible(PresentablePart.java:180)
> at org.eclipse.ui.internal.presentations.util.PresentablePartFo
> lder.select(PresentablePartFolder.java:270)
> at org.eclipse.ui.internal.presentations.util.LeftToRightTabOrd
> er.select(LeftToRightTabOrder.java:65)
> at org.eclipse.ui.internal.presentations.util.TabbedStackPresen
> tation.selectPart(TabbedStackPresentation.java:473)
> at org.eclipse.ui.internal.PartStack.refreshPresentationSelecti
> on(PartStack.java:1254)
> at org.eclipse.ui.internal.PartStack.setSelection(PartStack.jav
> a:1207)
> at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:16 06)
> at org.eclipse.ui.internal.PartStack.add(PartStack.java:497)
> at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103 )
> at org.eclipse.ui.internal.PartStack.add(PartStack.java:483)
> at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112 )
> at org.eclipse.ui.internal.EditorSashContainer.addEditor(Editor
> SashContainer.java:63)
> at org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorA
> reaHelper.java:225)
> at org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAre
> aHelper.java:213)
> at org.eclipse.ui.internal.EditorManager.createEditorTab(Editor
> Manager.java:778)
> at org.eclipse.ui.internal.EditorManager.openEditorFromDescript
> or(EditorManager.java:677)
> at org.eclipse.ui.internal.EditorManager.openEditor(EditorManag
> er.java:638)
> at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(
> WorkbenchPage.java:2860)
> at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(Workben
> chPage.java:2768)
> at org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPag
> e.java:2760)
> at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.j
> ava:2711)
> at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator
> .java:70)
> at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa
> ge.java:2707)
> at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa
> ge.java:2691)
> at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa
> ge.java:2682)
> at org.eclipse.ui.ide.IDE.openEditor(IDE.java:651)
> at org.eclipse.ui.ide.IDE.openEditor(IDE.java:610)
> at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInE
> ditor(EditorUtility.java:365)
> at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInE
> ditor(EditorUtility.java:168)
> at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:22 9)
> at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:20 8)
> at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchR
> un(SelectionDispatchAction.java:274)
> at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(Selec
> tionDispatchAction.java:250)
> at org.eclipse.jdt.internal.ui.packageview.PackageExplorerActio
> nGroup.handleOpen(PackageExplorerActionGroup.java:373)
> at org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$
> 4.open(PackageExplorerPart.java:526)
> at org.eclipse.ui.OpenAndLinkWithEditorHelper$InternalListener.
> open(OpenAndLinkWithEditorHelper.java:48)
> at org.eclipse.jface.viewers.StructuredViewer$2.run(StructuredV
> iewer.java:845)
> at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
> at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
> at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:17 5)
> at org.eclipse.jface.viewers.StructuredViewer.fireOpen(Structur
> edViewer.java:843)
> at org.eclipse.jface.viewers.StructuredViewer.handleOpen(Struct
> uredViewer.java:1131)
> at org.eclipse.jface.viewers.StructuredViewer$6.handleOpen(Stru
> cturedViewer.java:1235)
> at org.eclipse.jface.util.OpenStrategy.fireOpenEvent(OpenStrate
> gy.java:264)
> at org.eclipse.jface.util.OpenStrategy.access$2(OpenStrategy.ja
> va:258)
> at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrate
> gy.java:298)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
> at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja
> va:4066)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java
> :3657)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav
> a:2629)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:24 27)
> at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
> at org.eclipse.core.databinding.observable.Realm.runWithDefault
> (Realm.java:332)
> at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work
> bench.java:663)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j
> ava:149)
> at org.eclipse.ui.internal.ide.application.IDEApplication.start
> (IDEApplication.java:115)
> at org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips
> eAppHandle.java:196)
> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher
> .runApplication(EclipseAppLauncher.java:110)
> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher
> .start(EclipseAppLauncher.java:79)
> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS
> tarter.java:369)
> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS
> tarter.java:179)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 619)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
>
> org.eclipse.emf.ecore.xmi.PackageNotFoundException: Package with uri
> 'http://www.omg.org/XMI' not found.
> (platform:/resource/Humanresourcemodel/model/ResourcesHRM.hu
> manresourcemodel, 2, 120)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getPackageForURI(X
> MLHandler.java:2591)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.getFactoryForPrefi
> x(XMLHandler.java:2422)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createObjectByType
> (XMLHandler.java:1299)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.createTopObject(XM
> LHandler.java:1468)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.processElement(XML
> Handler.java:1019)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa
> ndler.java:1001)
> at org.eclipse.emf.ecore.xmi.impl.XMLHandler.startElement(XMLHa
> ndler.java:712)
> at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser
> .startElement(Unknown Source)
> at com.sun.org.apache.xerces.internal.impl.dtd.XMLDTDValidator.
> startElement(Unknown Source)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS
> cannerImpl.scanStartElement(Unknown Source)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm
> pl$ContentDriver.scanRootElementHook(Unknown Source)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS
> cannerImpl$FragmentContentDriver.next(Unknown Source)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm
> pl$PrologDriver.next(Unknown Source)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerIm
> pl.next(Unknown Source)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentS
> cannerImpl.scanDocument(Unknown Source)
> at com.sun.org.apache.xerces.internal.parsers.XML11Configuratio
> n.parse(Unknown Source)
> at com.sun.org.apache.xerces.internal.parsers.XML11Configuratio
> n.parse(Unknown Source)
> at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(U
> nknown Source)
> at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser
> .parse(Unknown Source)
> at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSA
> XParser.parse(Unknown Source)
> at javax.xml.parsers.SAXParser.parse(Unknown Source)
> at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.load(XMLLoadImpl.
> java:181)
> at org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl.doLoad(XMLRes
> ourceImpl.java:180)
> at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour
> ceImpl.java:1494)
> at org.eclipse.emf.ecore.resource.impl.ResourceImpl.load(Resour
> ceImpl.java:1282)
> at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo
> ad(ResourceSetImpl.java:255)
> at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.demandLo
> adHelper(ResourceSetImpl.java:270)
> at org.eclipse.emf.ecore.resource.impl.ResourceSetImpl.getResou
> rce(ResourceSetImpl.java:397)
> at humanresourcemodel.presentation.HumanresourcemodelEditor.cre
> ateModel(HumanresourcemodelEditor.java:951)
> at humanresourcemodel.presentation.HumanresourcemodelEditor.cre
> atePages(HumanresourcemodelEditor.java:1008)
> at org.eclipse.ui.part.MultiPageEditorPart.createPartControl(Mu
> ltiPageEditorPart.java:348)
> at org.eclipse.ui.internal.EditorReference.createPartHelper(Edi
> torReference.java:670)
> at org.eclipse.ui.internal.EditorReference.createPart(EditorRef
> erence.java:465)
> at org.eclipse.ui.internal.WorkbenchPartReference.getPart(Workb
> enchPartReference.java:595)
> at org.eclipse.ui.internal.PartPane.setVisible(PartPane.java:31 3)
> at org.eclipse.ui.internal.presentations.PresentablePart.setVis
> ible(PresentablePart.java:180)
> at org.eclipse.ui.internal.presentations.util.PresentablePartFo
> lder.select(PresentablePartFolder.java:270)
> at org.eclipse.ui.internal.presentations.util.LeftToRightTabOrd
> er.select(LeftToRightTabOrder.java:65)
> at org.eclipse.ui.internal.presentations.util.TabbedStackPresen
> tation.selectPart(TabbedStackPresentation.java:473)
> at org.eclipse.ui.internal.PartStack.refreshPresentationSelecti
> on(PartStack.java:1254)
> at org.eclipse.ui.internal.PartStack.setSelection(PartStack.jav
> a:1207)
> at org.eclipse.ui.internal.PartStack.showPart(PartStack.java:16 06)
> at org.eclipse.ui.internal.PartStack.add(PartStack.java:497)
> at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:103 )
> at org.eclipse.ui.internal.PartStack.add(PartStack.java:483)
> at org.eclipse.ui.internal.EditorStack.add(EditorStack.java:112 )
> at org.eclipse.ui.internal.EditorSashContainer.addEditor(Editor
> SashContainer.java:63)
> at org.eclipse.ui.internal.EditorAreaHelper.addToLayout(EditorA
> reaHelper.java:225)
> at org.eclipse.ui.internal.EditorAreaHelper.addEditor(EditorAre
> aHelper.java:213)
> at org.eclipse.ui.internal.EditorManager.createEditorTab(Editor
> Manager.java:778)
> at org.eclipse.ui.internal.EditorManager.openEditorFromDescript
> or(EditorManager.java:677)
> at org.eclipse.ui.internal.EditorManager.openEditor(EditorManag
> er.java:638)
> at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(
> WorkbenchPage.java:2860)
> at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(Workben
> chPage.java:2768)
> at org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPag
> e.java:2760)
> at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.j
> ava:2711)
> at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator
> .java:70)
> at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa
> ge.java:2707)
> at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa
> ge.java:2691)
> at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPa
> ge.java:2682)
> at org.eclipse.ui.ide.IDE.openEditor(IDE.java:651)
> at org.eclipse.ui.ide.IDE.openEditor(IDE.java:610)
> at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInE
> ditor(EditorUtility.java:365)
> at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInE
> ditor(EditorUtility.java:168)
> at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:22 9)
> at org.eclipse.jdt.ui.actions.OpenAction.run(OpenAction.java:20 8)
> at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchR
> un(SelectionDispatchAction.java:274)
> at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(Selec
> tionDispatchAction.java:250)
> at org.eclipse.jdt.internal.ui.packageview.PackageExplorerActio
> nGroup.handleOpen(PackageExplorerActionGroup.java:373)
> at org.eclipse.jdt.internal.ui.packageview.PackageExplorerPart$
> 4.open(PackageExplorerPart.java:526)
> at org.eclipse.ui.OpenAndLinkWithEditorHelper$InternalListener.
> open(OpenAndLinkWithEditorHelper.java:48)
> at org.eclipse.jface.viewers.StructuredViewer$2.run(StructuredV
> iewer.java:845)
> at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
> at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
> at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:17 5)
> at org.eclipse.jface.viewers.StructuredViewer.fireOpen(Structur
> edViewer.java:843)
> at org.eclipse.jface.viewers.StructuredViewer.handleOpen(Struct
> uredViewer.java:1131)
> at org.eclipse.jface.viewers.StructuredViewer$6.handleOpen(Stru
> cturedViewer.java:1235)
> at org.eclipse.jface.util.OpenStrategy.fireOpenEvent(OpenStrate
> gy.java:264)
> at org.eclipse.jface.util.OpenStrategy.access$2(OpenStrategy.ja
> va:258)
> at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrate
> gy.java:298)
> at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java :84)
> at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1053)
> at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.ja
> va:4066)
> at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java
> :3657)
> at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.jav
> a:2629)
> at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
> at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:24 27)
> at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
> at org.eclipse.core.databinding.observable.Realm.runWithDefault
> (Realm.java:332)
> at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Work
> bench.java:663)
> at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.j
> ava:149)
> at org.eclipse.ui.internal.ide.application.IDEApplication.start
> (IDEApplication.java:115)
> at org.eclipse.equinox.internal.app.EclipseAppHandle.run(Eclips
> eAppHandle.java:196)
> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher
> .runApplication(EclipseAppLauncher.java:110)
> at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher
> .start(EclipseAppLauncher.java:79)
> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS
> tarter.java:369)
> at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseS
> tarter.java:179)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
> at java.lang.reflect.Method.invoke(Unknown Source)
> at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java: 619)
> at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
> at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
> at org.eclipse.equinox.launcher.Main.main(Main.java:1383)


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Serialize EMF objects in a XMI similar file with another file extension humanresourcemodel [message #550880 is a reply to message #550869] Wed, 04 August 2010 14:41 Go to previous messageGo to next message
Bryan Hunt is currently offline Bryan HuntFriend
Messages: 366
Registered: July 2009
Senior Member
Ugur Kocak wrote on Wed, 04 August 2010 10:28

should this registration be for the editor and edit project. I haven't any experiences with defining extension points



I would recommend adding the extension to the bundle (plugin / project) that defines your HumanresourcemodelResourceFactoryImpl. In Eclipse terms, you don't need to define an extension point, you need to provide an extension for an already existing extension point. Open the manifest of the project that defines your HumanresourcemodelResourceFactoryImpl, click on the Extensions tab, click Add..., choose org.eclipse.emf.ecore.extension_parser, click Finish. Set the type and class and you should be all set.
Re: Serialize EMF objects in a XMI similar file with another file extension humanresourcemodel [message #550898 is a reply to message #550880] Wed, 04 August 2010 15:19 Go to previous messageGo to next message
Ugur Kocak is currently offline Ugur KocakFriend
Messages: 33
Registered: February 2010
Member
Great. Thank you Bryan for the tutorial and Thank you Ed too
I did it. it's great I can open the file

But another problem occurs.
The following short program shows only one serialized element in my file.humanresourcemodel. I have more elements in my resource

Please could you tell me what's the problem.

public class SerializationUtility {

    public void serialize() throws IOException {

//	HumanresourcemodelResourceFactoryImpl hrfi = new     HumanresourcemodelResourceFactoryImpl();
	
	ResourceSet resourceSet = new ResourceSetImpl();
	resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("humanresourcemodel", new HumanresourcemodelResourceFactoryImpl());

	URI fileURI = URI.createFileURI( "ResourcesHRM.humanresourcemodel");

	Resource resource = resourceSet.createResource( fileURI);

	Map<Object, Object> options = new HashMap<Object, Object>();

	options.put( HumanresourcemodelFactory.eINSTANCE, new HumanresourcemodelResourceFactoryImpl());

        Collection<OrganizationalUnit> orgUnits =   OrganizationalUnitMapping.orgUnitMap.values();
	Iterator<OrganizationalUnit> itr11 = orgUnits.iterator();
	while ( itr11.hasNext()) {
	    OrganizationalUnit next = itr11.next();
	    resource.getContents().add( next);
	}

        resource.save(options);
	}
    }
Re: Serialize EMF objects in a XMI similar file with another file extension humanresourcemodel [message #550919 is a reply to message #550898] Wed, 04 August 2010 15:44 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Ugar,

Comments below.

Ugur Kocak wrote:
> Great. Thank you Bryan for the tutorial and Thank you Ed too
> I did it. it's great I can open the file
>
> But another problem occurs.
> The following short program shows only one serialized element in my
> file.humanresourcemodel. I have more elements in my resource
>
> Please could you tell me what's the problem.
>
>
> public class SerializationUtility {
>
> public void serialize() throws IOException {
>
> // HumanresourcemodelResourceFactoryImpl hrfi = new
> HumanresourcemodelResourceFactoryImpl();
>
> ResourceSet resourceSet = new ResourceSetImpl();
> resourceSet.getResourceFactoryRegistry().getExtensionToFacto ryMap().put( "humanresourcemodel",
> new HumanresourcemodelResourceFactoryImpl());
>
> URI fileURI = URI.createFileURI( "ResourcesHRM.humanresourcemodel");
Note that using a relative path for opening your resource is likely to
get you into problems with cross file references. If you look at the
generated example, you'll see how it ensures that an absolute URI is used.
>
> Resource resource = resourceSet.createResource( fileURI);
>
> Map<Object, Object> options = new HashMap<Object, Object>();
>
> options.put( HumanresourcemodelFactory.eINSTANCE, new
> HumanresourcemodelResourceFactoryImpl());
This option is useless.
>
> Collection<OrganizationalUnit> orgUnits =
> OrganizationalUnitMapping.orgUnitMap.values();
> Iterator<OrganizationalUnit> itr11 = orgUnits.iterator();
> while ( itr11.hasNext()) {
> OrganizationalUnit next = itr11.next();
> resource.getContents().add( next);
> }
>
> resource.save(options);
If HumanresourcemodelResourceFactoryImpl creates an XMLResourceImpl,
then it only supports a single root object. Only XMIResourceImpl
supports multiple roots.
> }
> }
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Serialize EMF objects in a XMI similar file with another file extension humanresourcemodel [message #550921 is a reply to message #550880] Wed, 04 August 2010 15:54 Go to previous messageGo to next message
Ugur Kocak is currently offline Ugur KocakFriend
Messages: 33
Registered: February 2010
Member
Hi Bryan,


Sad
Don't you know the problem or are you tired of me?

Best regards
Ugur
Re: Serialize EMF objects in a XMI similar file with another file extension humanresourcemodel [message #550925 is a reply to message #550919] Wed, 04 August 2010 15:57 Go to previous messageGo to next message
Ugur Kocak is currently offline Ugur KocakFriend
Messages: 33
Registered: February 2010
Member
Hi Ed,

Thank you for the hints.

Where are the generated Examples and where do I have to use
XMIResourceImpl.

Thanks in advance

Best regards
Ugur
Re: Serialize EMF objects in a XMI similar file with another file extension humanresourcemodel [message #550939 is a reply to message #550919] Wed, 04 August 2010 16:21 Go to previous messageGo to next message
Ugur Kocak is currently offline Ugur KocakFriend
Messages: 33
Registered: February 2010
Member
Hi Ed,

where and how can I use the XMIResourceImpl class for serializing in my code.

If I serialize this as a XMI file I can't open it in the editor as a humanresourcemodel file.

Please give me any hint. I have to finish this work.

Br
ugur
Re: Serialize EMF objects in a XMI similar file with another file extension humanresourcemodel [message #550943 is a reply to message #550925] Wed, 04 August 2010 16:02 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------040600070507080907010201
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

I already explained

Try invoking "Generate Test Code" and then look at how the generated
HumanresourcemodelExample works.

Have you looked at what HumanresourcemodelResourceFactoryImpl does yet?


Ugur Kocak wrote:
> Hi Ed,
>
> Thank you for the hints.
>
> Where are the generated Examples and where do I have to use
> XMIResourceImpl.
>
> Thanks in advance
>
> Best regards
> Ugur

--------------040600070507080907010201
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
I already explained<br>
<blockquote>Try invoking "Generate Test Code" and then look at how the
generated HumanresourcemodelExample works.   <br>
</blockquote>
Have you looked at what HumanresourcemodelResourceFactoryImpl does yet?<br>
<br>
<br>
Ugur Kocak wrote:
<blockquote cite="mid:i3c2lt$mik$1@build.eclipse.org" type="cite">Hi
Ed,
<br>
<br>
Thank you for the hints.
<br>
<br>
Where are the generated Examples and where do I have to use
<br>
XMIResourceImpl.
<br>
<br>
Thanks in advance
<br>
<br>
Best regards
<br>
Ugur
<br>
</blockquote>
</body>
</html>

--------------040600070507080907010201--


Ed Merks
Professional Support: https://www.macromodeling.com/
icon14.gif  Re: Serialize EMF objects in a XMI similar file with another file extension humanresourcemodel [message #550944 is a reply to message #550943] Wed, 04 August 2010 16:31 Go to previous messageGo to next message
Ugur Kocak is currently offline Ugur KocakFriend
Messages: 33
Registered: February 2010
Member
Hi Ed,

thank you, Now I understand you. I generated the test code I will analyze the code now.

HumanresourcemodelResourceFactoryImpl: Creates an instance of the resource factory.
Cool
Re: Serialize EMF objects in a XMI similar file with another file extension humanresourcemodel [message #550985 is a reply to message #550944] Wed, 04 August 2010 18:43 Go to previous messageGo to next message
Ugur Kocak is currently offline Ugur KocakFriend
Messages: 33
Registered: February 2010
Member
Hi Ed,

>Have you looked at what HumanresourcemodelResourceFactoryImpl does yet?

That's it

I modified XMLResource to XMIResource in the method createResource(URI uri) method of class HumanresourcemodelResourceFactoryImpl.java.

But not all attributes, specially Reference values, are shown in my serialized file, when I open this file in my editor.
Do you know what's the reason for this problem?
Transient is set to false for all attributes.

Thank you in Advance

Br
Ugur
Re: Serialize EMF objects in a XMI similar file with another file extension humanresourcemodel [message #551044 is a reply to message #550939] Thu, 05 August 2010 00:26 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Ugur,

I'm pretty sure you started your model with an XML Schema and I expect
you'd want the serialization to conform to that schema. Right? XML
generally allows only a single root element, so you should try to
restrict yourself to that.


Ugur Kocak wrote:
> Hi Ed,
>
> where and how can I use the XMIResourceImpl class for serializing in
> my code.
>
> If I serialize this as a XMI file I can't open it in the editor as a
> humanresourcemodel file.
>
> Please give me any hint. I have to finish this work.
>
> Br
> ugur


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[CDO](newbie question) how to retrieve the up to date CDO SDK
Next Topic:Model Importer Implementation
Goto Forum:
  


Current Time: Thu Apr 25 09:59:25 GMT 2024

Powered by FUDForum. Page generated in 0.05043 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top