Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » A question about write transactions
A question about write transactions [message #88846] Tue, 02 January 2007 18:49 Go to next message
Eclipse UserFriend
Originally posted by: awm_abu.yahoo.com

Hello,

I am trying to add EditParts to my model programmatically.

I had a look at the documentation but I can't seem to see how to create a
write transaction.

I get the exception which you can see below

Sorry if this is a simple question but this is proving very frustrating for
me at the moment
Any help greatly appreciated.

Thanks:

java.lang.IllegalStateException: Cannot modify resource set without a write
transaction
Re: A question about write transactions [message #88923 is a reply to message #88846] Tue, 02 January 2007 21:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: vcciubot.uwaterloo.ca

How do you plan to add the EditParts? By creating views or model elements?

To write to your model you must use an AbstractTransactionalCommand and
execute it on the operation history. If returned from an editPolicy wrap
it around an ICommandProxy.

Explore the type hierarchy of AbstractTransactionalCommand to see example
commands.

Many edit policies contain examples: SemanticEditPolicy,
CreationEditPolicy etc.

hope this helps,
-Vlad


On Tue, 02 Jan 2007 18:49:14 +0000, Alan wrote:

> Hello,
>
> I am trying to add EditParts to my model programmatically.
>
> I had a look at the documentation but I can't seem to see how to create a
> write transaction.
>
> I get the exception which you can see below
>
> Sorry if this is a simple question but this is proving very frustrating for
> me at the moment
> Any help greatly appreciated.
>
> Thanks:
>
> java.lang.IllegalStateException: Cannot modify resource set without a write
> transaction
Re: A question about write transactions [message #88936 is a reply to message #88846] Tue, 02 January 2007 22:42 Go to previous messageGo to next message
Wiktor is currently offline WiktorFriend
Messages: 55
Registered: July 2009
Member
Hi,

If you do not need to have notification model for these parts persistent
as me, I would recommend modifing XXXCanonicalEditPolicies (methods
like refreshSemanticChildren, refreshChildren, refreshConnections, etc.)
so my temporary edit parts are created on the fly and it works realy
nice for me.

I hope I could help

Wiktor

Alan:
> Hello,
>
> I am trying to add EditParts to my model programmatically.
>
> I had a look at the documentation but I can't seem to see how to create a
> write transaction.
>
> I get the exception which you can see below
>
> Sorry if this is a simple question but this is proving very frustrating for
> me at the moment
> Any help greatly appreciated.
>
> Thanks:
>
> java.lang.IllegalStateException: Cannot modify resource set without a write
> transaction
>
>
>
>
>
>
Re: A question about write transactions [message #89042 is a reply to message #88923] Wed, 03 January 2007 10:55 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: awm_abu.yahoo.com

Thanks for the reply.

I created a subclass of AbstractTransactionalCommand and used that to create
my model elements
But I still got the same error. I am obviously missing something.

Perhaps if I tell you a bit more about what I am trying to do it might make
more sense.

My diagram contains a number of containers in a grid-like layout.
To start with I have, say, 3 rows and 5 columns. So that is 15 objects.
In my DiagramEditorUtil class in the createInitialRoot method I create these
15 objects in my model.
This works fine...the objects appear on the diagram on startup.

Now later the user decides to add another row.
This means I need another 5 objects in my model.
When I try to add objects to the model however I get the no write
transaction error.

Not sure if this extra info helps but maybe.
Anyway any pointers you could give me would be great.

"Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
news:pan.2007.01.02.21.02.10.619112@uwaterloo.ca...
> How do you plan to add the EditParts? By creating views or model elements?
>
> To write to your model you must use an AbstractTransactionalCommand and
> execute it on the operation history. If returned from an editPolicy wrap
> it around an ICommandProxy.
>
> Explore the type hierarchy of AbstractTransactionalCommand to see example
> commands.
>
> Many edit policies contain examples: SemanticEditPolicy,
> CreationEditPolicy etc.
>
> hope this helps,
> -Vlad
>
>
> On Tue, 02 Jan 2007 18:49:14 +0000, Alan wrote:
>
>> Hello,
>>
>> I am trying to add EditParts to my model programmatically.
>>
>> I had a look at the documentation but I can't seem to see how to create a
>> write transaction.
>>
>> I get the exception which you can see below
>>
>> Sorry if this is a simple question but this is proving very frustrating
>> for
>> me at the moment
>> Any help greatly appreciated.
>>
>> Thanks:
>>
>> java.lang.IllegalStateException: Cannot modify resource set without a
>> write
>> transaction
>
Re: A question about write transactions [message #89214 is a reply to message #89042] Wed, 03 January 2007 16:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: vcciubot.uwaterloo.ca

Where exactly are you trying to add the 5 new objects to your model? And,
is the row represented in your model?

If so, one easy way is to extend the edit helper of the row model element
so that upon creation it is configured with 5 children.

In that edit helper override


/**
* Gets the command to configure a new element of my kind. By default,
* returns <code>null</code>. Subclasses may override to provide their
* command.
*
* @param req
* the configure request
* @return the configure command
*/
protected ICommand getConfigureCommand(ConfigureRequest req) {
return null;
}

Here's an example of how to do this:

/**
* Returns a command that configures this block.
* <p>
* In subclasses override {@link BlockEditHelper#doConfiguration(EObject, IProgressMonitor)}
*/
protected ICommand getConfigureCommand(final ConfigureRequest req) {

return new ConfigureElementCommand(req) {

protected CommandResult doExecuteWithResult(
IProgressMonitor monitor, IAdaptable info)
throws ExecutionException {

EObject element = req.getElementToConfigure();
doConfiguration(element, monitor);

return CommandResult.newOKCommandResult(element);
}
};
}

/**
* Configures the block with a block interface.
* TODO: Could we add this directly to the ecore model?
* To configure the pipeline see {@link Bluenose2DiagramEditorUtil}.
*/
protected void doConfiguration(EObject element, IProgressMonitor monitor) {
Block block = (Block) element;
B2CreationCommandUtil.createBlkInterface(block, monitor);

//testing the vhdlid
Pipeline pipe = (Pipeline) EMFCoreUtil.getContainer(block, Bluenose2Package.eINSTANCE.getPipeline());
int id = Bluenose2SemanticUtil.getAndIncrementId(pipe, IDTypes.VHDL_ID);
block.setVhdlId("" + id);
}


Finally, element creation inside a command should be done this way:

EMFCoreUtil.create(element, containment, eClass)

-Vlad




On Wed, 03 Jan 2007 10:55:08 +0000, Alan wrote:

> Thanks for the reply.
>
> I created a subclass of AbstractTransactionalCommand and used that to create
> my model elements
> But I still got the same error. I am obviously missing something.
>
> Perhaps if I tell you a bit more about what I am trying to do it might make
> more sense.
>
> My diagram contains a number of containers in a grid-like layout.
> To start with I have, say, 3 rows and 5 columns. So that is 15 objects.
> In my DiagramEditorUtil class in the createInitialRoot method I create these
> 15 objects in my model.
> This works fine...the objects appear on the diagram on startup.
>
> Now later the user decides to add another row.
> This means I need another 5 objects in my model.
> When I try to add objects to the model however I get the no write
> transaction error.
>
> Not sure if this extra info helps but maybe.
> Anyway any pointers you could give me would be great.
>
> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
> news:pan.2007.01.02.21.02.10.619112@uwaterloo.ca...
>> How do you plan to add the EditParts? By creating views or model elements?
>>
>> To write to your model you must use an AbstractTransactionalCommand and
>> execute it on the operation history. If returned from an editPolicy wrap
>> it around an ICommandProxy.
>>
>> Explore the type hierarchy of AbstractTransactionalCommand to see example
>> commands.
>>
>> Many edit policies contain examples: SemanticEditPolicy,
>> CreationEditPolicy etc.
>>
>> hope this helps,
>> -Vlad
>>
>>
>> On Tue, 02 Jan 2007 18:49:14 +0000, Alan wrote:
>>
>>> Hello,
>>>
>>> I am trying to add EditParts to my model programmatically.
>>>
>>> I had a look at the documentation but I can't seem to see how to create a
>>> write transaction.
>>>
>>> I get the exception which you can see below
>>>
>>> Sorry if this is a simple question but this is proving very frustrating
>>> for
>>> me at the moment
>>> Any help greatly appreciated.
>>>
>>> Thanks:
>>>
>>> java.lang.IllegalStateException: Cannot modify resource set without a
>>> write
>>> transaction
>>
Re: A question about write transactions [message #89349 is a reply to message #89214] Thu, 04 January 2007 12:00 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: awm_abu.yahoo.com

No the row is not represented in my model.

In my model the Diagram itself contains the containers
The blocks then go in the containers
The containers are created programmatically.
I start with 15 (3 rows x 3 cols)
Then the user can change the row/column configuration which means adding
containers.
This is the problem I am currently dealing with.

As a row does not exist in model does this make the solution you proposed
below unsuitable ?

Any other thoughts ?

"Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
news:pan.2007.01.03.16.03.16.892127@uwaterloo.ca...
> Where exactly are you trying to add the 5 new objects to your model? And,
> is the row represented in your model?
>
> If so, one easy way is to extend the edit helper of the row model element
> so that upon creation it is configured with 5 children.
>
> In that edit helper override
>
>
> /**
> * Gets the command to configure a new element of my kind. By default,
> * returns <code>null</code>. Subclasses may override to provide their
> * command.
> *
> * @param req
> * the configure request
> * @return the configure command
> */
> protected ICommand getConfigureCommand(ConfigureRequest req) {
> return null;
> }
>
> Here's an example of how to do this:
>
> /**
> * Returns a command that configures this block.
> * <p>
> * In subclasses override {@link BlockEditHelper#doConfiguration(EObject,
> IProgressMonitor)}
> */
> protected ICommand getConfigureCommand(final ConfigureRequest req) {
>
> return new ConfigureElementCommand(req) {
>
> protected CommandResult doExecuteWithResult(
> IProgressMonitor monitor, IAdaptable info)
> throws ExecutionException {
>
> EObject element = req.getElementToConfigure();
> doConfiguration(element, monitor);
>
> return CommandResult.newOKCommandResult(element);
> }
> };
> }
>
> /**
> * Configures the block with a block interface.
> * TODO: Could we add this directly to the ecore model?
> * To configure the pipeline see {@link Bluenose2DiagramEditorUtil}.
> */
> protected void doConfiguration(EObject element, IProgressMonitor monitor)
> {
> Block block = (Block) element;
> B2CreationCommandUtil.createBlkInterface(block, monitor);
>
> //testing the vhdlid
> Pipeline pipe = (Pipeline) EMFCoreUtil.getContainer(block,
> Bluenose2Package.eINSTANCE.getPipeline());
> int id = Bluenose2SemanticUtil.getAndIncrementId(pipe, IDTypes.VHDL_ID);
> block.setVhdlId("" + id);
> }
>
>
> Finally, element creation inside a command should be done this way:
>
> EMFCoreUtil.create(element, containment, eClass)
>
> -Vlad
>
>
>
>
> On Wed, 03 Jan 2007 10:55:08 +0000, Alan wrote:
>
>> Thanks for the reply.
>>
>> I created a subclass of AbstractTransactionalCommand and used that to
>> create
>> my model elements
>> But I still got the same error. I am obviously missing something.
>>
>> Perhaps if I tell you a bit more about what I am trying to do it might
>> make
>> more sense.
>>
>> My diagram contains a number of containers in a grid-like layout.
>> To start with I have, say, 3 rows and 5 columns. So that is 15 objects.
>> In my DiagramEditorUtil class in the createInitialRoot method I create
>> these
>> 15 objects in my model.
>> This works fine...the objects appear on the diagram on startup.
>>
>> Now later the user decides to add another row.
>> This means I need another 5 objects in my model.
>> When I try to add objects to the model however I get the no write
>> transaction error.
>>
>> Not sure if this extra info helps but maybe.
>> Anyway any pointers you could give me would be great.
>>
>> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
>> news:pan.2007.01.02.21.02.10.619112@uwaterloo.ca...
>>> How do you plan to add the EditParts? By creating views or model
>>> elements?
>>>
>>> To write to your model you must use an AbstractTransactionalCommand and
>>> execute it on the operation history. If returned from an editPolicy wrap
>>> it around an ICommandProxy.
>>>
>>> Explore the type hierarchy of AbstractTransactionalCommand to see
>>> example
>>> commands.
>>>
>>> Many edit policies contain examples: SemanticEditPolicy,
>>> CreationEditPolicy etc.
>>>
>>> hope this helps,
>>> -Vlad
>>>
>>>
>>> On Tue, 02 Jan 2007 18:49:14 +0000, Alan wrote:
>>>
>>>> Hello,
>>>>
>>>> I am trying to add EditParts to my model programmatically.
>>>>
>>>> I had a look at the documentation but I can't seem to see how to create
>>>> a
>>>> write transaction.
>>>>
>>>> I get the exception which you can see below
>>>>
>>>> Sorry if this is a simple question but this is proving very frustrating
>>>> for
>>>> me at the moment
>>>> Any help greatly appreciated.
>>>>
>>>> Thanks:
>>>>
>>>> java.lang.IllegalStateException: Cannot modify resource set without a
>>>> write
>>>> transaction
>>>
>
Re: A question about write transactions [message #89718 is a reply to message #89349] Fri, 05 January 2007 15:32 Go to previous message
Eclipse UserFriend
Originally posted by: vcciubot.uwaterloo.ca

It should work the same way. As long you configure the newly created
containers or update the old ones.

You can send me some code to look at, no problem.

vlad

On Thu, 04 Jan 2007 12:00:18 +0000, Alan wrote:

> No the row is not represented in my model.
>
> In my model the Diagram itself contains the containers
> The blocks then go in the containers
> The containers are created programmatically.
> I start with 15 (3 rows x 3 cols)
> Then the user can change the row/column configuration which means adding
> containers.
> This is the problem I am currently dealing with.
>
> As a row does not exist in model does this make the solution you proposed
> below unsuitable ?
>
> Any other thoughts ?
>
> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
> news:pan.2007.01.03.16.03.16.892127@uwaterloo.ca...
>> Where exactly are you trying to add the 5 new objects to your model? And,
>> is the row represented in your model?
>>
>> If so, one easy way is to extend the edit helper of the row model element
>> so that upon creation it is configured with 5 children.
>>
>> In that edit helper override
>>
>>
>> /**
>> * Gets the command to configure a new element of my kind. By default,
>> * returns <code>null</code>. Subclasses may override to provide their
>> * command.
>> *
>> * @param req
>> * the configure request
>> * @return the configure command
>> */
>> protected ICommand getConfigureCommand(ConfigureRequest req) {
>> return null;
>> }
>>
>> Here's an example of how to do this:
>>
>> /**
>> * Returns a command that configures this block.
>> * <p>
>> * In subclasses override {@link BlockEditHelper#doConfiguration(EObject,
>> IProgressMonitor)}
>> */
>> protected ICommand getConfigureCommand(final ConfigureRequest req) {
>>
>> return new ConfigureElementCommand(req) {
>>
>> protected CommandResult doExecuteWithResult(
>> IProgressMonitor monitor, IAdaptable info)
>> throws ExecutionException {
>>
>> EObject element = req.getElementToConfigure();
>> doConfiguration(element, monitor);
>>
>> return CommandResult.newOKCommandResult(element);
>> }
>> };
>> }
>>
>> /**
>> * Configures the block with a block interface.
>> * TODO: Could we add this directly to the ecore model?
>> * To configure the pipeline see {@link Bluenose2DiagramEditorUtil}.
>> */
>> protected void doConfiguration(EObject element, IProgressMonitor monitor)
>> {
>> Block block = (Block) element;
>> B2CreationCommandUtil.createBlkInterface(block, monitor);
>>
>> //testing the vhdlid
>> Pipeline pipe = (Pipeline) EMFCoreUtil.getContainer(block,
>> Bluenose2Package.eINSTANCE.getPipeline());
>> int id = Bluenose2SemanticUtil.getAndIncrementId(pipe, IDTypes.VHDL_ID);
>> block.setVhdlId("" + id);
>> }
>>
>>
>> Finally, element creation inside a command should be done this way:
>>
>> EMFCoreUtil.create(element, containment, eClass)
>>
>> -Vlad
>>
>>
>>
>>
>> On Wed, 03 Jan 2007 10:55:08 +0000, Alan wrote:
>>
>>> Thanks for the reply.
>>>
>>> I created a subclass of AbstractTransactionalCommand and used that to
>>> create
>>> my model elements
>>> But I still got the same error. I am obviously missing something.
>>>
>>> Perhaps if I tell you a bit more about what I am trying to do it might
>>> make
>>> more sense.
>>>
>>> My diagram contains a number of containers in a grid-like layout.
>>> To start with I have, say, 3 rows and 5 columns. So that is 15 objects.
>>> In my DiagramEditorUtil class in the createInitialRoot method I create
>>> these
>>> 15 objects in my model.
>>> This works fine...the objects appear on the diagram on startup.
>>>
>>> Now later the user decides to add another row.
>>> This means I need another 5 objects in my model.
>>> When I try to add objects to the model however I get the no write
>>> transaction error.
>>>
>>> Not sure if this extra info helps but maybe.
>>> Anyway any pointers you could give me would be great.
>>>
>>> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
>>> news:pan.2007.01.02.21.02.10.619112@uwaterloo.ca...
>>>> How do you plan to add the EditParts? By creating views or model
>>>> elements?
>>>>
>>>> To write to your model you must use an AbstractTransactionalCommand and
>>>> execute it on the operation history. If returned from an editPolicy wrap
>>>> it around an ICommandProxy.
>>>>
>>>> Explore the type hierarchy of AbstractTransactionalCommand to see
>>>> example
>>>> commands.
>>>>
>>>> Many edit policies contain examples: SemanticEditPolicy,
>>>> CreationEditPolicy etc.
>>>>
>>>> hope this helps,
>>>> -Vlad
>>>>
>>>>
>>>> On Tue, 02 Jan 2007 18:49:14 +0000, Alan wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>> I am trying to add EditParts to my model programmatically.
>>>>>
>>>>> I had a look at the documentation but I can't seem to see how to create
>>>>> a
>>>>> write transaction.
>>>>>
>>>>> I get the exception which you can see below
>>>>>
>>>>> Sorry if this is a simple question but this is proving very frustrating
>>>>> for
>>>>> me at the moment
>>>>> Any help greatly appreciated.
>>>>>
>>>>> Thanks:
>>>>>
>>>>> java.lang.IllegalStateException: Cannot modify resource set without a
>>>>> write
>>>>> transaction
>>>>
>>
Previous Topic:Dynamically addition of new components to the pallete.
Next Topic:Adding EditParts programmatically
Goto Forum:
  


Current Time: Sun Nov 03 06:51:49 GMT 2024

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

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

Back to the top