Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Wizard to create EMF model file(based on editor.xxx.presentation.yyyWizard )
Wizard to create EMF model file [message #687977] Thu, 23 June 2011 11:34 Go to next message
nicolas h is currently offline nicolas h
Messages: 60
Registered: February 2011
Location: Grenoble, France
Member
Hi there,
I created an ecore model and a genmodel. Next, I generated "Model Code", "Edit Code" and "Editor Code".

The Editor plug-in generated proposes a wizard to create a new model file. I wish I created my own wizard based on the generated wizard.

Below is my own code :

WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
							
@Override
protected void execute(IProgressMonitor monitor) throws CoreException,
			InvocationTargetException, InterruptedException {
		
// EditingDomain Creation if necessary 
TransactionalEditingDomain editingDomain;
editingDomain = TransactionalEditingDomain.Registry.INSTANCE.getEditingDomain(SharedEditingDomainID);

if (editingDomain == null) {
	editingDomain = DiagramEditingDomainFactory.getInstance().createEditingDomain();
	editingDomain.setID(SharedEditingDomainID);
}		
			
ResourceSet resourceSet = editingDomain.getResourceSet();

Resource resource = resourceSet.createResource(domainModelFileURI);
EObject rootObject = xxxFactory.eINSTANCE.createRootModel();
if (rootObject != null) {
	resource.getContents().add(rootObject); // It Doesn't work
}
// Save the contents of the resource to the file system.
Map<Object, Object> options = new HashMap<Object, Object>();
options.put(XMLResource.OPTION_ENCODING, "UTF8");
try {
	resource.save(options);
} catch (Exception e) {
	e.printStackTrace();
}
finally {
	monitor.done();
}

}};

getContainer().run(false, false, op);



If I comment the line
resource.getContents().add(rootObject);
, the file is well created, however, it doesn't contain any rootModel. If I don't comment the line, my application enter into an infinite loop (into org.eclipse.jface.window#runEventLoop(Shell))

Though, my code is very similar to the generated wizard, the only fundamental difference I think is how ResourceSet is instantiated. I tried to replace this line with
ResourceSet resourceSet = new ResourceSetImpl();
, it doesn't change anything.

Does anyone have an idea to solve this issue, please ?

Best regards


--
Nicolas
Re: Wizard to create EMF model file [message #688008 is a reply to message #687977] Thu, 23 June 2011 13:07 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26000
Registered: July 2009
Senior Member
Nicolas,

Comments below.

nicolas wrote:
> Hi there,
> I created an ecore model and a genmodel. Next, I generated "Model
> Code", "Edit Code" and "Editor Code".
>
> The Editor plug-in generated proposes a wizard to create a new model
> file. I wish I created my own wizard based on the generated wizard.
>
> Below is my own code :
>
> WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
>
> @Override
> protected void execute(IProgressMonitor monitor) throws CoreException,
> InvocationTargetException, InterruptedException {
>
> // EditingDomain Creation if necessary TransactionalEditingDomain
> editingDomain;
> editingDomain =
> TransactionalEditingDomain.Registry.INSTANCE.getEditingDomain(SharedEditingDomainID);
>
>
> if (editingDomain == null) {
> editingDomain =
> DiagramEditingDomainFactory.getInstance().createEditingDomain();
> editingDomain.setID(SharedEditingDomainID);
> }
>
> ResourceSet resourceSet = editingDomain.getResourceSet();
>
> Resource resource = resourceSet.createResource(domainModelFileURI);
> EObject rootObject = xxxFactory.eINSTANCE.createRootModel();
> if (rootObject != null) {
> resource.getContents().add(rootObject); // It Doesn't work
In what way doesn't it work. If you're using transactions, you need to
make modifications as part of a transaction. Is that the problem?
> }
> // Save the contents of the resource to the file system.
> Map<Object, Object> options = new HashMap<Object, Object>();
> options.put(XMLResource.OPTION_ENCODING, "UTF8");
> try {
> resource.save(options);
> } catch (Exception e) {
> e.printStackTrace();
> }
> finally {
> monitor.done();
> }
>
> }};
>
> getContainer().run(false, false, op);
>
>
>
> If I comment the line resource.getContents().add(rootObject);, the
> file is well created, however, it doesn't contain any rootModel. If I
> don't comment the line, my application enter into an infinite loop
> (into org.eclipse.jface.window#runEventLoop(Shell))
Have you consulted with your best friend, the debugger?
>
> Though, my code is very similar to the generated wizard, the only
> fundamental difference I think is how ResourceSet is instantiated. I
> tried to replace this line with ResourceSet resourceSet = new
> ResourceSetImpl();, it doesn't change anything.
>
> Does anyone have an idea to solve this issue, please ?
You've not made it clear yet why it's failing. Perhaps an exception is
being thrown? What type?
>
> Best regards
>
>
Re: Wizard to create EMF model file [message #688225 is a reply to message #688008] Fri, 24 June 2011 03:54 Go to previous messageGo to next message
nicolas h is currently offline nicolas h
Messages: 60
Registered: February 2011
Location: Grenoble, France
Member
Hi, thanks for you reply.

You were right, an InvocationTargetException was thrown : "Cannot modify
resource set without a write transaction". I didn't have any error message since I didn't add the catch clause ...

I looked for a solution on the web by using transactionalEditingDomain. I found two ways, fist by using an AbstractTransactionalCommand, then by using RecordingCommand. None of them work.

My implementation of the two ways :

Using an AbstractTransactionalCommand :
if (rootObject != null) {
			
	AbstractTransactionalCommand com = new AbstractTransactionalCommand(editingDomain, "shared editing domain", null) {
			
		@Override
		protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
						IAdaptable info) throws ExecutionException {
			resource.getContents().add(rootObject);
			return null;
		}
	};
			
	if (com.canExecute()) {
		try {
			OperationHistoryFactory.getOperationHistory().execute(com, new NullProgressMonitor(), null);
		} catch (ExecutionException e) {
			e.printStackTrace();
		}
	}			
}


Quote:

org.eclipse.core.commands.ExecutionException: While executing the operation, an exception occurred
Caused by: java.lang.UnsupportedOperationException


Using RecordingCommand :

if (rootObject != null) {
	TransactionalCommandStack stack = (TransactionalCommandStack) editingDomain.getCommandStack();
	stack.execute(new RecordingCommand(editingDomain) {
				
		@Override
		protected void doExecute() {
			resource.getContents().add(rootObject);
		}
	});
}


Quote:

java.lang.reflect.InvocationTargetException
Caused by: java.lang.UnsupportedOperationException


Can you oriented me about the correct way to create my command please ?

Best regards,

--
Nicolas
Re: Wizard to create EMF model file [message #688398 is a reply to message #688225] Fri, 24 June 2011 11:44 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26000
Registered: July 2009
Senior Member
Nicolas,

Comments below.

nicolas wrote:
> Hi, thanks for you reply.
>
> You were right, an InvocationTargetException was thrown : "Cannot modify
> resource set without a write transaction". I didn't have any error
> message since I didn't add the catch clause ...
That's what I expected, yes. The normal generated wizard doesn't use a
transactional editing domain. Is there a particular reason why you're
using one?
>
> I looked for a solution on the web by using
> transactionalEditingDomain. I found two ways, fist by using an
> AbstractTransactionalCommand, then by using RecordingCommand. None of
> them work.
>
> My implementation of the two ways :
>
> Using an AbstractTransactionalCommand :
>
> if (rootObject != null) {
>
> AbstractTransactionalCommand com = new
> AbstractTransactionalCommand(editingDomain, "shared editing domain",
> null) {
>
> @Override
> protected CommandResult doExecuteWithResult(IProgressMonitor
> monitor,
> IAdaptable info) throws ExecutionException {
> resource.getContents().add(rootObject);
> return null;
> }
> };
>
> if (com.canExecute()) {
> try {
> OperationHistoryFactory.getOperationHistory().execute(com,
> new NullProgressMonitor(), null);
> } catch (ExecutionException e) {
> e.printStackTrace();
> }
> }
> }
>
>
> Quote:
>> org.eclipse.core.commands.ExecutionException: While executing the
>> operation, an exception occurred
>> Caused by: java.lang.UnsupportedOperationException
And you've used the debugger to figure out what's cause this? A stack
trace is always very helpful...
>
>
> Using RecordingCommand :
>
>
> if (rootObject != null) {
> TransactionalCommandStack stack = (TransactionalCommandStack)
> editingDomain.getCommandStack();
> stack.execute(new RecordingCommand(editingDomain) {
>
> @Override
> protected void doExecute() {
> resource.getContents().add(rootObject);
> }
> });
> }
>
>
> Quote:
>> java.lang.reflect.InvocationTargetException
>> Caused by: java.lang.UnsupportedOperationException
>
No stack trace for this one either.
>
> Can you oriented me about the correct way to create my command please ?
I'm not all that familiar with the transaction framework so I'm not sure
if you're using it correctly. I'm not sure why you're using it in a
wizard. It's not as if you're setting up the ability to undo the
creation of the resource...
>
> Best regards,
>
Re: Wizard to create EMF model file [message #692882 is a reply to message #688398] Tue, 05 July 2011 07:58 Go to previous messageGo to next message
nicolas h is currently offline nicolas h
Messages: 60
Registered: February 2011
Location: Grenoble, France
Member
Hi Ed, sorry for the late.

What I want to do is the following steps :

1. Ask a project name to the user :
- I used a wizard for this;
- This wizard contains one field;
- Let's call the project name "projectName"

2. Create a project named "projectName" into the workspace :

@Override
public boolean performFinish() {
	root = ResourcesPlugin.getWorkspace().getRoot();
		
	IRunnableWithProgress op = new IRunnableWithProgress() {

	public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
		final IProject project = root.getProject(systemName);
		if (!project.exists()) {
			WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
							
			@Override
			protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
				project.create (new NullProgressMonitor());
				project.open (new NullProgressMonitor ());
			}
		};
		getContainer().run(false, false, op);
		// Here, the code below to create and initialize a model file in step 3
	}};
	try {
		getContainer().run(false, true, op);
	} catch (InterruptedException e) {
		return false;
	} catch (InvocationTargetException e) {
		return false;
	}
	return true;
}


3. Create a model file systemName.model into my project;
- My code is based on the code generated in the wizard in the plug-in Editor generated,
- I added a peace of code to automatically initialize my model file width some elements :

WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
							
@Override
protected void execute(IProgressMonitor monitor) throws CoreException, InvocationTargetException, InterruptedException {
		
// EditingDomain Creation if necessary 
TransactionalEditingDomain editingDomain;
editingDomain = TransactionalEditingDomain.Registry.INSTANCE.getEditingDomain(SharedEditingDomainID);

if (editingDomain == null) {
	editingDomain = DiagramEditingDomainFactory.getInstance().createEditingDomain();
	editingDomain.setID(SharedEditingDomainID);
}		
			
ResourceSet resourceSet = editingDomain.getResourceSet();

Resource resource = resourceSet.createResource(domainModelFileURI);
EObject rootObject = xxxFactory.eINSTANCE.createRootModel();
if (rootObject != null) {
	resource.getContents().add(rootObject); // InvocationTargetException is thrown
	// I want to add some elements to my rootObject here
}
// Save the contents of the resource to the file system.
Map<Object, Object> options = new HashMap<Object, Object>();
options.put(XMLResource.OPTION_ENCODING, "UTF8");
try {
	resource.save(options);
} catch (Exception e) {
	e.printStackTrace();
}
finally {
	monitor.done();
}

}};

getContainer().run(false, false, op);



4. I want to initialize automatically new diagram file from this model file.

An InvocationTargetException caused by an IllegalStateException is thrown : "Cannot modify resource set without a write transaction" when I tried to add my RootModel to my Resource :

if (rootObject != null) {
	resource.getContents().add(rootObject);
}


I don't know why.

Do you have any idea to fix this ?

--
Nicolas

The stack trace below :

Quote:
InvocationTarget
java.lang.reflect.InvocationTargetException
at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:477)
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:372)
at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java:1008)
at org.test.wizard.NewHOE2ProjectWizard$1.run(NewProjectWizard.java:108)
at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:464)
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:372)
at org.eclipse.jface.wizard.WizardDialog.run(WizardDialog.java:1008)
at org.test.wizard.NewProjectWizard.performFinish(NewProjectWizard.java:120)
at org.eclipse.jface.wizard.WizardDialog.finishPressed(WizardDialog.java:811)
at org.eclipse.jface.wizard.WizardDialog.buttonPressed(WizardDialog.java:430)
at org.eclipse.jface.dialogs.Dialog$2.widgetSelected(Dialog.java:624)
at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:234)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:3783)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1375)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1398)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1383)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1195)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3629)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3284)
at org.eclipse.jface.window.Window.runEventLoop(Window.java:825)
at org.eclipse.jface.window.Window.open(Window.java:801)
at org.eclipse.ui.internal.handlers.WizardHandler$New.executeHandler(WizardHandler.java:254)
at org.eclipse.ui.internal.handlers.WizardHandler.execute(WizardHandler.java:274)
at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:293)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
at org.eclipse.ui.internal.handlers.SlaveHandlerService.executeCommand(SlaveHandlerService.java:241)
at org.eclipse.ui.internal.actions.CommandAction.runWithEvent(CommandAction.java:157)
at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:584)
at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:501)
at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:411)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:3783)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1375)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1398)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1383)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1195)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3629)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3284)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
at org.test.Application.start(Application.java:84)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.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(EclipseStarter.java:369)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:620)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:575)
at org.eclipse.equinox.launcher.Main.run(Main.java:1408)
at org.eclipse.equinox.launcher.Main.main(Main.java:1384)
Caused by: java.lang.IllegalStateException: Cannot modify resource set without a write transaction
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.assertWriting(TransactionChangeRecorder.java:348)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.appendNotification(TransactionChangeRecorder.java:302)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.processResourceNotification(TransactionChangeRecorder.java:272)
at org.eclipse.emf.transaction.impl.TransactionChangeRecorder.notifyChanged(TransactionChangeRecorder.java:238)
at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:380)
at org.eclipse.emf.common.notify.impl.NotifyingListImpl.dispatchNotification(NotifyingListImpl.java:267)
at org.eclipse.emf.common.notify.impl.NotifyingListImpl.addUnique(NotifyingListImpl.java:300)
at org.eclipse.emf.common.util.AbstractEList.add(AbstractEList.java:307)
at requirements.diagram.part.CreationNewDiagram$1.execute(CreationNewDiagram.java:63)
at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:106)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1975)
at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:118)
at requirements.diagram.part.CreationNewDiagram.execute(CreationNewDiagram.java:67)
at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:106)
at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1975)
at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:118)
at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:464)
... 61 more
Re: Wizard to create EMF model file [message #692974 is a reply to message #692882] Tue, 05 July 2011 11:06 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26000
Registered: July 2009
Senior Member
Comments below.

> Hi Ed, sorry for the late.
>
> What I want to do is the following steps :
>
> 1. Ask a project name to the user :
> - I used a wizard for this;
> - This wizard contains one field;
> - Let's call the project name "projectName"
>
> 2. Create a project named "projectName" into the workspace :
You're expecting to be able to undo project creation?
>
>
> @Override
> public boolean performFinish() {
> root = ResourcesPlugin.getWorkspace().getRoot();
>
> IRunnableWithProgress op = new IRunnableWithProgress() {
>
> public void run(IProgressMonitor monitor) throws
> InvocationTargetException, InterruptedException {
> final IProject project = root.getProject(systemName);
> if (!project.exists()) {
> WorkspaceModifyOperation op = new
> WorkspaceModifyOperation() {
>
> @Override
> protected void execute(IProgressMonitor monitor) throws
> CoreException, InvocationTargetException, InterruptedException {
> project.create (new NullProgressMonitor());
> project.open (new NullProgressMonitor ());
> }
> };
> getContainer().run(false, false, op);
> // Here, the code below to create and initialize a model file
> in step 3
> }};
> try {
> getContainer().run(false, true, op);
> } catch (InterruptedException e) {
> return false;
> } catch (InvocationTargetException e) {
> return false;
> }
> return true;
> }
>
>
> 3. Create a model file systemName.model into my project;
> - My code is based on the code generated in the wizard in the plug-in
> Editor generated,
> - I added a peace of code to automatically initialize my model file
> width some elements :
>
> WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
>
> @Override
> protected void execute(IProgressMonitor monitor) throws CoreException,
> InvocationTargetException, InterruptedException {
>
> // EditingDomain Creation if necessary TransactionalEditingDomain
> editingDomain;
> editingDomain =
> TransactionalEditingDomain.Registry.INSTANCE.getEditingDomain(SharedEditingDomainID);
>
> if (editingDomain == null) {
> editingDomain =
> DiagramEditingDomainFactory.getInstance().createEditingDomain();
> editingDomain.setID(SharedEditingDomainID);
> }
>
> ResourceSet resourceSet = editingDomain.getResourceSet();
>
> Resource resource = resourceSet.createResource(domainModelFileURI);
> EObject rootObject = xxxFactory.eINSTANCE.createRootModel();
> if (rootObject != null) {
> resource.getContents().add(rootObject); //
> InvocationTargetException is thrown
> // I want to add some elements to my rootObject here
> }
> // Save the contents of the resource to the file system.
> Map<Object, Object> options = new HashMap<Object, Object>();
> options.put(XMLResource.OPTION_ENCODING, "UTF8");
> try {
> resource.save(options);
> } catch (Exception e) {
> e.printStackTrace();
> }
> finally {
> monitor.done();
> }
This strikes me as another thing that can't be undone.
>
> }};
>
> getContainer().run(false, false, op);
>
>
> 4. I want to initialize automatically new diagram file from this model
> file.
>
> An InvocationTargetException caused by an IllegalStateException is
> thrown : "Cannot modify resource set without a write transaction" when
> I tried to add my RootModel to my Resource :
>
> if (rootObject != null) {
> resource.getContents().add(rootObject);
> }
>
> I don't know why.
>
> Do you have any idea to fix this ?
Again, I have to wonder why you're using commands at all. None of this
strikes me as stuff that needs to be undone.
Re: Wizard to create EMF model file [message #693266 is a reply to message #692974] Wed, 06 July 2011 02:56 Go to previous messageGo to next message
nicolas h is currently offline nicolas h
Messages: 60
Registered: February 2011
Location: Grenoble, France
Member
That's a good point, I don't need to use commands since I don't want to undone these actions.

If I tried to use AbstractTransactionalCommand or RecordingCommand, It's only because I found these class as a solution to solve the "Cannot modify resource set without a write transaction" issue.

Regarding the WorkspaceModifyOperation class, if I don't get its purpose wrong, we have to use it when the code makes changes to the workspace (project, folder, file, generally Resource creation into the workspace) right ?


--
Nicolas

[Updated on: Wed, 06 July 2011 02:57]

Report message to a moderator

Re: Wizard to create EMF model file [message #693287 is a reply to message #693266] Wed, 06 July 2011 03:44 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26000
Registered: July 2009
Senior Member
Yes, you should modify the workspace as part of an operation that groups
all the related changes into a single workspace delta.


On 05/07/2011 11:56 PM, nicolas wrote:
> That's a good point, I don't need to use commands since I don't want
> to undone these actions.
>
> If I tried to use AbstractTransactionalCommand or RecordingCommand,
> It's only because I found these class as a solution to solve the
> "Cannot modify resource set without a write transaction" issue.
>
> Regarding the WorkspaceModifyOperation class, if I don't get its
> purpose wrong, we have to use it when the code makes changes to the
> workspace (project, folder, file, generally Resource creation into the
> workspace) right ?
>
>
Re: Wizard to create EMF model file [message #693324 is a reply to message #693287] Wed, 06 July 2011 05:12 Go to previous message
nicolas h is currently offline nicolas h
Messages: 60
Registered: February 2011
Location: Grenoble, France
Member
I found where my error is located :

// EditingDomain Creation if necessary 
TransactionalEditingDomain editingDomain;
editingDomain = TransactionalEditingDomain.Registry.INSTANCE.getEditingDomain(SharedEditingDomainID);

if (editingDomain == null) {
	editingDomain = DiagramEditingDomainFactory.getInstance().createEditingDomain();
	editingDomain.setID(SharedEditingDomainID);
}		
			
ResourceSet resourceSet = editingDomain.getResourceSet();


I can't write into this resourceSet.

If I replace this by

ResourceSet resourceSet = new ResourceSetImpl();


It works. However, I'm pretty sure that I've already try this and it didn't work ...

Well, it works now, but it seems like I don't know how to use editing domains yet ...

Thanks for you help Ed Wink I've a lot of things to learn ...

--
Nicolas
Previous Topic:Code Generation Programatically
Next Topic:[CDO] Migrating to RC2 - driver not found
Goto Forum:
  


Current Time: Fri Aug 22 19:39:46 EDT 2014

Powered by FUDForum. Page generated in 0.01972 seconds