Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » Problems with Command
Problems with Command [message #116390] Tue, 03 April 2007 05:22 Go to next message
Eclipse UserFriend
Originally posted by: fbanica.soluta.net

This is a multi-part message in MIME format.

------=_NextPart_000_0070_01C775EA.C6E17590
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

I have a problem with changing the model behind the diagram. What I am =
trying to do is inserting/populating a reference of the model. This has =
nothing to do with the diagram, since there will be no graphical element =
corresponding to this.

Here it is the code:

EditingDomain editDomain =3D protocolEditPart.getEditingDomain();
ResourceSet resSet =3D editDomain.getResourceSet();
EList resources =3D resSet.getResources();
Resource res =3D (Resource)resources.get(0);

if(res !=3D null) {
for(Iterator iter =3D res.getAllContents(); iter.hasNext(); ) {
Object o =3D iter.next();
=20
if(o instanceof ProtocolModel) {
ProtocolModel pm =3D (ProtocolModel)o;
=20
pm.setDataModel(mainPage.dataModel); // PROBLEM!
=20
break;
}
}

When I set the DataModel it gives me the error saying I have to use =
transactions... I read around some discussion on the commands subject, =
but I would need some straight/simple example (snippet) to see how to =
work with these commands.

Any help? Please!
------=_NextPart_000_0070_01C775EA.C6E17590
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.6000.16414" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT size=3D2>I have a problem with changing the model behind the =
diagram.=20
What I am trying to do is inserting/populating a reference of the model. =
This=20
has nothing to do with the diagram, since there will be no graphical =
element=20
corresponding to this.</FONT></DIV>
<DIV><FONT size=3D2><FONT size=3D2></FONT></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Here it&nbsp;is the code:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV align=3Dleft><FONT size=3D2>EditingDomain editDomain =3D=20
protocolEditPart.getEditingDomain();</FONT></DIV>
<DIV align=3Dleft><FONT size=3D2>ResourceSet resSet =3D=20
editDomain.getResourceSet();</FONT></DIV>
<DIV align=3Dleft><FONT size=3D2>EList resources =3D=20
resSet.getResources();</FONT></DIV>
<DIV align=3Dleft><FONT size=3D2>Resource res =3D=20
(Resource)resources.get(0);</FONT></DIV>
<DIV align=3Dleft><FONT size=3D2><FONT =
size=3D2></FONT></FONT>&nbsp;</DIV>
<DIV align=3Dleft><FONT size=3D2>if(res !=3D null) {</FONT></DIV>
<DIV align=3Dleft><FONT size=3D2>&nbsp;&nbsp;&nbsp; for(Iterator iter =
=3D=20
res.getAllContents(); iter.hasNext(); ) {</FONT></DIV>
<DIV align=3Dleft><FONT size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
Object o =3D=20
iter.next();</FONT></DIV>
<DIV align=3Dleft><FONT size=3D2><FONT size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
</FONT></FONT></DIV>
<DIV align=3Dleft><FONT size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; =
if(o=20
instanceof ProtocolModel) {</FONT></DIV>
<DIV align=3Dleft><FONT size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; ProtocolModel pm =3D (ProtocolModel)o;</FONT></DIV>
<DIV align=3Dleft><FONT size=3D2><FONT size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; </FONT></FONT></DIV>
<DIV align=3Dleft><FONT size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; pm.setDataModel(mainPage.dataModel); // =
PROBLEM!</FONT></DIV>
<DIV align=3Dleft><FONT size=3D2><FONT size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; </FONT></FONT></DIV>
<DIV align=3Dleft><FONT size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
&nbsp;&nbsp;&nbsp; break;</FONT></DIV>
<DIV align=3Dleft><FONT size=3D2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;=20
}</FONT></DIV>
<DIV align=3Dleft><FONT size=3D2>}</FONT></DIV>
<DIV align=3Dleft><FONT size=3D2><FONT =
size=3D2></FONT></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>When I set the DataModel it gives me the error =
saying I have=20
to use transactions... I read around some discussion on the commands =
subject,=20
but I would need some straight/simple example (snippet) to see how to =
work with=20
these commands.</FONT></DIV>
<DIV><FONT size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT size=3D2>Any help? Please!</FONT></DIV></BODY></HTML>

------=_NextPart_000_0070_01C775EA.C6E17590--
Re: Problems with Command [message #116784 is a reply to message #116390] Tue, 03 April 2007 11:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: vcciubot.uwaterloo.ca

Salut!

To read or write the model you must use commands. You don't need commands
if you read the model from an edit policy's getCommand().

To write to the model, you have to the wrap the code into an
AbstractTransactionalCommand, you'll find a full example below.

If you need to execute such a command from an action you will need a
ProgressMonitor. You can always use the NullProgressMonitor for this.

If you need to return such a command from an edit policy then you must
wrap it around an ICommandProxy.

Please note you cannot execute write commands from
GraphicalEditPart.getCommand() or from edit policies getCommand().

hope this helps!

vlad






public class ImportEntityCommand extends AbstractTransactionalCommand {

private static String label = "Import Block Interface Command";

private IFile file;

private Block block;
private Shell shell;

public ImportEntityCommand(Block block, IFile file, Shell shell) {
super(TransactionUtil.getEditingDomain(block), label,
getWorkspaceFiles(block));
this.block = block;
this.file = file;
this.shell = shell;
}

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

String filePath = file.getLocationURI().getPath().toString();

ArrayList<DesignUnit> dus = VHDLUtils.parse(filePath);
VHDLCompilationUnit compilationUnit = Bluenose2Factory.eINSTANCE.createVHDLCompilationUnit();


for (DesignUnit du : dus) {
if (du instanceof Entity) {
compilationUnit.getEntities().add( VHDLUtils.createEntity(
(Entity) du) );
}
}


ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell, new AdapterFactoryLabelProvider(
Bluenose2DiagramEditorPlugin.getInstance()
.getItemProvidersAdapterFactory()), new AdapterFactoryContentProvider(
Bluenose2DiagramEditorPlugin.getInstance()
.getItemProvidersAdapterFactory()) );

dialog.setTitle("Import Entity Dialog");
dialog.setMessage("Please select the toplevel entity to import.");
dialog.setInput(compilationUnit);
dialog.open();

if ( dialog.getReturnCode() == Dialog.OK) {
Object[] result = dialog.getResult();
if (result.length > 0 && result[0] instanceof VHDLEntity) {
VHDLEntity entity = (VHDLEntity) result[0];
block.setBlkInterface(entity.getInterface());
}
}

return CommandResult.newOKCommandResult();
}

}




On Tue, 03 Apr 2007 12:22:42 +0300, Florin Banica wrote:

> I have a problem with changing the model behind the diagram. What I am trying to do is inserting/populating a reference of the model. This has nothing to do with the diagram, since there will be no graphical element corresponding to this.
>
> Here it is the code:
>
> EditingDomain editDomain = protocolEditPart.getEditingDomain();
> ResourceSet resSet = editDomain.getResourceSet();
> EList resources = resSet.getResources();
> Resource res = (Resource)resources.get(0);
>
> if(res != null) {
> for(Iterator iter = res.getAllContents(); iter.hasNext(); ) {
> Object o = iter.next();
>
> if(o instanceof ProtocolModel) {
> ProtocolModel pm = (ProtocolModel)o;
>
> pm.setDataModel(mainPage.dataModel); // PROBLEM!
>
> break;
> }
> }
>
> When I set the DataModel it gives me the error saying I have to use transactions... I read around some discussion on the commands subject, but I would need some straight/simple example (snippet) to see how to work with these commands.
>
> Any help? Please!<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML><HEAD>
> <META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
> <META content="MSHTML 6.00.6000.16414" name=GENERATOR>
> <STYLE></STYLE>
> </HEAD>
> <BODY>
> <DIV><FONT size=2>I have a problem with changing the model behind the diagram.
> What I am trying to do is inserting/populating a reference of the model. This
> has nothing to do with the diagram, since there will be no graphical element
> corresponding to this.</FONT></DIV>
> <DIV><FONT size=2><FONT size=2></FONT></FONT>&nbsp;</DIV>
> <DIV><FONT size=2>Here it&nbsp;is the code:</FONT></DIV>
> <DIV>&nbsp;</DIV>
> <DIV align=left><FONT size=2>EditingDomain editDomain =
> protocolEditPart.getEditingDomain();</FONT></DIV>
> <DIV align=left><FONT size=2>ResourceSet resSet =
> editDomain.getResourceSet();</FONT></DIV>
> <DIV align=left><FONT size=2>EList resources =
> resSet.getResources();</FONT></DIV>
> <DIV align=left><FONT size=2>Resource res =
> (Resource)resources.get(0);</FONT></DIV>
> <DIV align=left><FONT size=2><FONT size=2></FONT></FONT>&nbsp;</DIV>
> <DIV align=left><FONT size=2>if(res != null) {</FONT></DIV>
> <DIV align=left><FONT size=2>&nbsp;&nbsp;&nbsp; for(Iterator iter =
> res.getAllContents(); iter.hasNext(); ) {</FONT></DIV>
> <DIV align=left><FONT size=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Object o =
> iter.next();</FONT></DIV>
> <DIV align=left><FONT size=2><FONT size=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
> </FONT></FONT></DIV>
> <DIV align=left><FONT size=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(o
> instanceof ProtocolModel) {</FONT></DIV>
> <DIV align=left><FONT size=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
> &nbsp;&nbsp;&nbsp; ProtocolModel pm = (ProtocolModel)o;</FONT></DIV>
> <DIV align=left><FONT size=2><FONT size=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
> &nbsp;&nbsp;&nbsp; </FONT></FONT></DIV>
> <DIV align=left><FONT size=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
> &nbsp;&nbsp;&nbsp; pm.setDataModel(mainPage.dataModel); // PROBLEM!</FONT></DIV>
> <DIV align=left><FONT size=2><FONT size=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
> &nbsp;&nbsp;&nbsp; </FONT></FONT></DIV>
> <DIV align=left><FONT size=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
> &nbsp;&nbsp;&nbsp; break;</FONT></DIV>
> <DIV align=left><FONT size=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
> }</FONT></DIV>
> <DIV align=left><FONT size=2>}</FONT></DIV>
> <DIV align=left><FONT size=2><FONT size=2></FONT></FONT>&nbsp;</DIV>
> <DIV><FONT size=2>When I set the DataModel it gives me the error saying I have
> to use transactions... I read around some discussion on the commands subject,
> but I would need some straight/simple example (snippet) to see how to work with
> these commands.</FONT></DIV>
> <DIV><FONT size=2></FONT>&nbsp;</DIV>
> <DIV><FONT size=2>Any help? Please!</FONT></DIV></BODY></HTML>
Re: Problems with Command [message #116821 is a reply to message #116784] Tue, 03 April 2007 12:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: fbanica.soluta.net

Salut, Vlad!

Everything looks fine, but i'm missing the call (execution) of this
command... How do I execute it from within my code?

Thanks.


"Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
news:pan.2007.04.03.15.17.32.707195@uwaterloo.ca...
> Salut!
>
> To read or write the model you must use commands. You don't need commands
> if you read the model from an edit policy's getCommand().
>
> To write to the model, you have to the wrap the code into an
> AbstractTransactionalCommand, you'll find a full example below.
>
> If you need to execute such a command from an action you will need a
> ProgressMonitor. You can always use the NullProgressMonitor for this.
>
> If you need to return such a command from an edit policy then you must
> wrap it around an ICommandProxy.
>
> Please note you cannot execute write commands from
> GraphicalEditPart.getCommand() or from edit policies getCommand().
>
> hope this helps!
>
> vlad
>
>
>
>
>
>
> public class ImportEntityCommand extends AbstractTransactionalCommand {
>
> private static String label = "Import Block Interface Command";
>
> private IFile file;
>
> private Block block;
> private Shell shell;
>
> public ImportEntityCommand(Block block, IFile file, Shell shell) {
> super(TransactionUtil.getEditingDomain(block), label,
> getWorkspaceFiles(block));
> this.block = block;
> this.file = file;
> this.shell = shell;
> }
>
> @Override
> protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
> IAdaptable info) throws ExecutionException {
>
> String filePath = file.getLocationURI().getPath().toString();
>
> ArrayList<DesignUnit> dus = VHDLUtils.parse(filePath);
> VHDLCompilationUnit compilationUnit =
> Bluenose2Factory.eINSTANCE.createVHDLCompilationUnit();
>
>
> for (DesignUnit du : dus) {
> if (du instanceof Entity) {
> compilationUnit.getEntities().add( VHDLUtils.createEntity(
> (Entity) du) );
> }
> }
>
>
> ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell,
> new AdapterFactoryLabelProvider(
> Bluenose2DiagramEditorPlugin.getInstance()
> .getItemProvidersAdapterFactory()), new AdapterFactoryContentProvider(
> Bluenose2DiagramEditorPlugin.getInstance()
> .getItemProvidersAdapterFactory()) );
>
> dialog.setTitle("Import Entity Dialog");
> dialog.setMessage("Please select the toplevel entity to import.");
> dialog.setInput(compilationUnit);
> dialog.open();
>
> if ( dialog.getReturnCode() == Dialog.OK) {
> Object[] result = dialog.getResult();
> if (result.length > 0 && result[0] instanceof VHDLEntity) {
> VHDLEntity entity = (VHDLEntity) result[0];
> block.setBlkInterface(entity.getInterface());
> }
> }
>
> return CommandResult.newOKCommandResult();
> }
>
> }
>
>
>
>
> On Tue, 03 Apr 2007 12:22:42 +0300, Florin Banica wrote:
>
>> I have a problem with changing the model behind the diagram. What I am
>> trying to do is inserting/populating a reference of the model. This has
>> nothing to do with the diagram, since there will be no graphical element
>> corresponding to this.
>>
>> Here it is the code:
>>
>> EditingDomain editDomain = protocolEditPart.getEditingDomain();
>> ResourceSet resSet = editDomain.getResourceSet();
>> EList resources = resSet.getResources();
>> Resource res = (Resource)resources.get(0);
>>
>> if(res != null) {
>> for(Iterator iter = res.getAllContents(); iter.hasNext(); ) {
>> Object o = iter.next();
>>
>> if(o instanceof ProtocolModel) {
>> ProtocolModel pm = (ProtocolModel)o;
>>
>> pm.setDataModel(mainPage.dataModel); // PROBLEM!
>>
>> break;
>> }
>> }
>>
>> When I set the DataModel it gives me the error saying I have to use
>> transactions... I read around some discussion on the commands subject,
>> but I would need some straight/simple example (snippet) to see how to
>> work with these commands.
>>
>> Any help? Please!<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
>> Transitional//EN">
>> <HTML><HEAD>
>> <META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
>> <META content="MSHTML 6.00.6000.16414" name=GENERATOR>
>> <STYLE></STYLE>
>> </HEAD>
>> <BODY>
>> <DIV><FONT size=2>I have a problem with changing the model behind the
>> diagram.
>> What I am trying to do is inserting/populating a reference of the model.
>> This
>> has nothing to do with the diagram, since there will be no graphical
>> element
>> corresponding to this.</FONT></DIV>
>> <DIV><FONT size=2><FONT size=2></FONT></FONT>&nbsp;</DIV>
>> <DIV><FONT size=2>Here it&nbsp;is the code:</FONT></DIV>
>> <DIV>&nbsp;</DIV>
>> <DIV align=left><FONT size=2>EditingDomain editDomain =
>> protocolEditPart.getEditingDomain();</FONT></DIV>
>> <DIV align=left><FONT size=2>ResourceSet resSet =
>> editDomain.getResourceSet();</FONT></DIV>
>> <DIV align=left><FONT size=2>EList resources =
>> resSet.getResources();</FONT></DIV>
>> <DIV align=left><FONT size=2>Resource res =
>> (Resource)resources.get(0);</FONT></DIV>
>> <DIV align=left><FONT size=2><FONT size=2></FONT></FONT>&nbsp;</DIV>
>> <DIV align=left><FONT size=2>if(res != null) {</FONT></DIV>
>> <DIV align=left><FONT size=2>&nbsp;&nbsp;&nbsp; for(Iterator iter =
>> res.getAllContents(); iter.hasNext(); ) {</FONT></DIV>
>> <DIV align=left><FONT size=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Object
>> o =
>> iter.next();</FONT></DIV>
>> <DIV align=left><FONT size=2><FONT size=2>&nbsp;&nbsp;&nbsp;
>> &nbsp;&nbsp;&nbsp;
>> </FONT></FONT></DIV>
>> <DIV align=left><FONT size=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(o
>> instanceof ProtocolModel) {</FONT></DIV>
>> <DIV align=left><FONT size=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
>> &nbsp;&nbsp;&nbsp; ProtocolModel pm = (ProtocolModel)o;</FONT></DIV>
>> <DIV align=left><FONT size=2><FONT size=2>&nbsp;&nbsp;&nbsp;
>> &nbsp;&nbsp;&nbsp;
>> &nbsp;&nbsp;&nbsp; </FONT></FONT></DIV>
>> <DIV align=left><FONT size=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
>> &nbsp;&nbsp;&nbsp; pm.setDataModel(mainPage.dataModel); //
>> PROBLEM!</FONT></DIV>
>> <DIV align=left><FONT size=2><FONT size=2>&nbsp;&nbsp;&nbsp;
>> &nbsp;&nbsp;&nbsp;
>> &nbsp;&nbsp;&nbsp; </FONT></FONT></DIV>
>> <DIV align=left><FONT size=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
>> &nbsp;&nbsp;&nbsp; break;</FONT></DIV>
>> <DIV align=left><FONT size=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
>> }</FONT></DIV>
>> <DIV align=left><FONT size=2>}</FONT></DIV>
>> <DIV align=left><FONT size=2><FONT size=2></FONT></FONT>&nbsp;</DIV>
>> <DIV><FONT size=2>When I set the DataModel it gives me the error saying I
>> have
>> to use transactions... I read around some discussion on the commands
>> subject,
>> but I would need some straight/simple example (snippet) to see how to
>> work with
>> these commands.</FONT></DIV>
>> <DIV><FONT size=2></FONT>&nbsp;</DIV>
>> <DIV><FONT size=2>Any help? Please!</FONT></DIV></BODY></HTML>
>
Re: Problems with Command [message #116834 is a reply to message #116821] Tue, 03 April 2007 13:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: vcciubot.uwaterloo.ca

command.execute(new NullProgressMonitor(), null)

or OperationHistoryFactory.getOperationHistory().execute(comman d)

vlad

On Tue, 03 Apr 2007 19:35:07 +0300, Florin Banica wrote:

> Salut, Vlad!
>
> Everything looks fine, but i'm missing the call (execution) of this
> command... How do I execute it from within my code?
>
> Thanks.
>
>
> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
> news:pan.2007.04.03.15.17.32.707195@uwaterloo.ca...
>> Salut!
>>
>> To read or write the model you must use commands. You don't need commands
>> if you read the model from an edit policy's getCommand().
>>
>> To write to the model, you have to the wrap the code into an
>> AbstractTransactionalCommand, you'll find a full example below.
>>
>> If you need to execute such a command from an action you will need a
>> ProgressMonitor. You can always use the NullProgressMonitor for this.
>>
>> If you need to return such a command from an edit policy then you must
>> wrap it around an ICommandProxy.
>>
>> Please note you cannot execute write commands from
>> GraphicalEditPart.getCommand() or from edit policies getCommand().
>>
>> hope this helps!
>>
>> vlad
>>
>>
>>
>>
>>
>>
>> public class ImportEntityCommand extends AbstractTransactionalCommand {
>>
>> private static String label = "Import Block Interface Command";
>>
>> private IFile file;
>>
>> private Block block;
>> private Shell shell;
>>
>> public ImportEntityCommand(Block block, IFile file, Shell shell) {
>> super(TransactionUtil.getEditingDomain(block), label,
>> getWorkspaceFiles(block));
>> this.block = block;
>> this.file = file;
>> this.shell = shell;
>> }
>>
>> @Override
>> protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
>> IAdaptable info) throws ExecutionException {
>>
>> String filePath = file.getLocationURI().getPath().toString();
>>
>> ArrayList<DesignUnit> dus = VHDLUtils.parse(filePath);
>> VHDLCompilationUnit compilationUnit =
>> Bluenose2Factory.eINSTANCE.createVHDLCompilationUnit();
>>
>>
>> for (DesignUnit du : dus) {
>> if (du instanceof Entity) {
>> compilationUnit.getEntities().add( VHDLUtils.createEntity(
>> (Entity) du) );
>> }
>> }
>>
>>
>> ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell,
>> new AdapterFactoryLabelProvider(
>> Bluenose2DiagramEditorPlugin.getInstance()
>> .getItemProvidersAdapterFactory()), new AdapterFactoryContentProvider(
>> Bluenose2DiagramEditorPlugin.getInstance()
>> .getItemProvidersAdapterFactory()) );
>>
>> dialog.setTitle("Import Entity Dialog");
>> dialog.setMessage("Please select the toplevel entity to import.");
>> dialog.setInput(compilationUnit);
>> dialog.open();
>>
>> if ( dialog.getReturnCode() == Dialog.OK) {
>> Object[] result = dialog.getResult();
>> if (result.length > 0 && result[0] instanceof VHDLEntity) {
>> VHDLEntity entity = (VHDLEntity) result[0];
>> block.setBlkInterface(entity.getInterface());
>> }
>> }
>>
>> return CommandResult.newOKCommandResult();
>> }
>>
>> }
>>
>>
>>
>>
>> On Tue, 03 Apr 2007 12:22:42 +0300, Florin Banica wrote:
>>
>>> I have a problem with changing the model behind the diagram. What I am
>>> trying to do is inserting/populating a reference of the model. This has
>>> nothing to do with the diagram, since there will be no graphical element
>>> corresponding to this.
>>>
>>> Here it is the code:
>>>
>>> EditingDomain editDomain = protocolEditPart.getEditingDomain();
>>> ResourceSet resSet = editDomain.getResourceSet();
>>> EList resources = resSet.getResources();
>>> Resource res = (Resource)resources.get(0);
>>>
>>> if(res != null) {
>>> for(Iterator iter = res.getAllContents(); iter.hasNext(); ) {
>>> Object o = iter.next();
>>>
>>> if(o instanceof ProtocolModel) {
>>> ProtocolModel pm = (ProtocolModel)o;
>>>
>>> pm.setDataModel(mainPage.dataModel); // PROBLEM!
>>>
>>> break;
>>> }
>>> }
>>>
>>> When I set the DataModel it gives me the error saying I have to use
>>> transactions... I read around some discussion on the commands subject,
>>> but I would need some straight/simple example (snippet) to see how to
>>> work with these commands.
>>>
>>> Any help? Please!<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
>>> Transitional//EN">
>>> <HTML><HEAD>
>>> <META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
>>> <META content="MSHTML 6.00.6000.16414" name=GENERATOR>
>>> <STYLE></STYLE>
>>> </HEAD>
>>> <BODY>
>>> <DIV><FONT size=2>I have a problem with changing the model behind the
>>> diagram.
>>> What I am trying to do is inserting/populating a reference of the model.
>>> This
>>> has nothing to do with the diagram, since there will be no graphical
>>> element
>>> corresponding to this.</FONT></DIV>
>>> <DIV><FONT size=2><FONT size=2></FONT></FONT>&nbsp;</DIV>
>>> <DIV><FONT size=2>Here it&nbsp;is the code:</FONT></DIV>
>>> <DIV>&nbsp;</DIV>
>>> <DIV align=left><FONT size=2>EditingDomain editDomain =
>>> protocolEditPart.getEditingDomain();</FONT></DIV>
>>> <DIV align=left><FONT size=2>ResourceSet resSet =
>>> editDomain.getResourceSet();</FONT></DIV>
>>> <DIV align=left><FONT size=2>EList resources =
>>> resSet.getResources();</FONT></DIV>
>>> <DIV align=left><FONT size=2>Resource res =
>>> (Resource)resources.get(0);</FONT></DIV>
>>> <DIV align=left><FONT size=2><FONT size=2></FONT></FONT>&nbsp;</DIV>
>>> <DIV align=left><FONT size=2>if(res != null) {</FONT></DIV>
>>> <DIV align=left><FONT size=2>&nbsp;&nbsp;&nbsp; for(Iterator iter =
>>> res.getAllContents(); iter.hasNext(); ) {</FONT></DIV>
>>> <DIV align=left><FONT size=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Object
>>> o =
>>> iter.next();</FONT></DIV>
>>> <DIV align=left><FONT size=2><FONT size=2>&nbsp;&nbsp;&nbsp;
>>> &nbsp;&nbsp;&nbsp;
>>> </FONT></FONT></DIV>
>>> <DIV align=left><FONT size=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(o
>>> instanceof ProtocolModel) {</FONT></DIV>
>>> <DIV align=left><FONT size=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
>>> &nbsp;&nbsp;&nbsp; ProtocolModel pm = (ProtocolModel)o;</FONT></DIV>
>>> <DIV align=left><FONT size=2><FONT size=2>&nbsp;&nbsp;&nbsp;
>>> &nbsp;&nbsp;&nbsp;
>>> &nbsp;&nbsp;&nbsp; </FONT></FONT></DIV>
>>> <DIV align=left><FONT size=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
>>> &nbsp;&nbsp;&nbsp; pm.setDataModel(mainPage.dataModel); //
>>> PROBLEM!</FONT></DIV>
>>> <DIV align=left><FONT size=2><FONT size=2>&nbsp;&nbsp;&nbsp;
>>> &nbsp;&nbsp;&nbsp;
>>> &nbsp;&nbsp;&nbsp; </FONT></FONT></DIV>
>>> <DIV align=left><FONT size=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
>>> &nbsp;&nbsp;&nbsp; break;</FONT></DIV>
>>> <DIV align=left><FONT size=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
>>> }</FONT></DIV>
>>> <DIV align=left><FONT size=2>}</FONT></DIV>
>>> <DIV align=left><FONT size=2><FONT size=2></FONT></FONT>&nbsp;</DIV>
>>> <DIV><FONT size=2>When I set the DataModel it gives me the error saying I
>>> have
>>> to use transactions... I read around some discussion on the commands
>>> subject,
>>> but I would need some straight/simple example (snippet) to see how to
>>> work with
>>> these commands.</FONT></DIV>
>>> <DIV><FONT size=2></FONT>&nbsp;</DIV>
>>> <DIV><FONT size=2>Any help? Please!</FONT></DIV></BODY></HTML>
>>
Re: Problems with Command [message #116860 is a reply to message #116834] Wed, 04 April 2007 05:50 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: fbanica.soluta.net

This is a multi-part message in MIME format.

------=_NextPart_000_0053_01C776B7.DA68EA30
Content-Type: text/plain;
charset="ISO-8859-15"
Content-Transfer-Encoding: quoted-printable

I tryed the first solution, but, unfortunately, there is no result in =
the model file. Although is says the file was modified (the little * =
appears near the name of the file in the editor), when I close the =
editor and choose YES when it askes for saving the file, it gives me 2 =
identical errors: "An internal error occurred during:

"An internal error occurred during: "children update". =
java.lang.ArrayIndexOutOfBoundsException"

Any ideea of what could it be worng?



"Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message =
news:pan.2007.04.03.17.34.23.269142@uwaterloo.ca...
> command.execute(new NullProgressMonitor(), null)
>=20
> or OperationHistoryFactory.getOperationHistory().execute(comman d)
>=20
> vlad
>=20
> On Tue, 03 Apr 2007 19:35:07 +0300, Florin Banica wrote:
>=20
>> Salut, Vlad!
>>=20
>> Everything looks fine, but i'm missing the call (execution) of this=20
>> command... How do I execute it from within my code?
>>=20
>> Thanks.
>>=20
>>=20
>> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message=20
>> news:pan.2007.04.03.15.17.32.707195@uwaterloo.ca...
>>> Salut!
>>>
>>> To read or write the model you must use commands. You don't need =
commands
>>> if you read the model from an edit policy's getCommand().
>>>
>>> To write to the model, you have to the wrap the code into an
>>> AbstractTransactionalCommand, you'll find a full example below.
>>>
>>> If you need to execute such a command from an action you will need a
>>> ProgressMonitor. You can always use the NullProgressMonitor for =
this.
>>>
>>> If you need to return such a command from an edit policy then you =
must
>>> wrap it around an ICommandProxy.
>>>
>>> Please note you cannot execute write commands from
>>> GraphicalEditPart.getCommand() or from edit policies getCommand().
>>>
>>> hope this helps!
>>>
>>> vlad
>>>
>>>
>>>
>>>
>>>
>>>
>>> public class ImportEntityCommand extends =
AbstractTransactionalCommand {
>>>
>>> private static String label =3D "Import Block Interface Command";
>>>
>>> private IFile file;
>>>
>>> private Block block;
>>> private Shell shell;
>>>
>>> public ImportEntityCommand(Block block, IFile file, Shell shell) {
>>> super(TransactionUtil.getEditingDomain(block), label,
>>> getWorkspaceFiles(block));
>>> this.block =3D block;
>>> this.file =3D file;
>>> this.shell =3D shell;
>>> }
>>>
>>> @Override
>>> protected CommandResult doExecuteWithResult(IProgressMonitor =
monitor,
>>> IAdaptable info) throws ExecutionException {
>>>
>>> String filePath =3D file.getLocationURI().getPath().toString();
>>>
>>> ArrayList<DesignUnit> dus =3D VHDLUtils.parse(filePath);
>>> VHDLCompilationUnit compilationUnit =3D=20
>>> Bluenose2Factory.eINSTANCE.createVHDLCompilationUnit();
>>>
>>>
>>> for (DesignUnit du : dus) {
>>> if (du instanceof Entity) {
>>> compilationUnit.getEntities().add( VHDLUtils.createEntity(
>>> (Entity) du) );
>>> }
>>> }
>>>
>>>
>>> ElementTreeSelectionDialog dialog =3D new =
ElementTreeSelectionDialog(shell,=20
>>> new AdapterFactoryLabelProvider(
>>> Bluenose2DiagramEditorPlugin.getInstance()
>>> .getItemProvidersAdapterFactory()), new =
AdapterFactoryContentProvider(
>>> Bluenose2DiagramEditorPlugin.getInstance()
>>> .getItemProvidersAdapterFactory()) );
>>>
>>> dialog.setTitle("Import Entity Dialog");
>>> dialog.setMessage("Please select the toplevel entity to import.");
>>> dialog.setInput(compilationUnit);
>>> dialog.open();
>>>
>>> if ( dialog.getReturnCode() =3D=3D Dialog.OK) {
>>> Object[] result =3D dialog.getResult();
>>> if (result.length > 0 && result[0] instanceof VHDLEntity) {
>>> VHDLEntity entity =3D (VHDLEntity) result[0];
>>> block.setBlkInterface(entity.getInterface());
>>> }
>>> }
>>>
>>> return CommandResult.newOKCommandResult();
>>> }
>>>
>>> }
>>>
>>>
>>>
>>>
>>> On Tue, 03 Apr 2007 12:22:42 +0300, Florin Banica wrote:
>>>
>>>> I have a problem with changing the model behind the diagram. What I =
am=20
>>>> trying to do is inserting/populating a reference of the model. This =
has=20
>>>> nothing to do with the diagram, since there will be no graphical =
element=20
>>>> corresponding to this.
>>>>
>>>> Here it is the code:
>>>>
>>>> EditingDomain editDomain =3D protocolEditPart.getEditingDomain();
>>>> ResourceSet resSet =3D editDomain.getResourceSet();
>>>> EList resources =3D resSet.getResources();
>>>> Resource res =3D (Resource)resources.get(0);
>>>>
>>>> if(res !=3D null) {
>>>> for(Iterator iter =3D res.getAllContents(); iter.hasNext(); ) {
>>>> Object o =3D iter.next();
>>>>
>>>> if(o instanceof ProtocolModel) {
>>>> ProtocolModel pm =3D (ProtocolModel)o;
>>>>
>>>> pm.setDataModel(mainPage.dataModel); // PROBLEM!
>>>>
>>>> break;
>>>> }
>>>> }
>>>>
>>>> When I set the DataModel it gives me the error saying I have to use =

>>>> transactions... I read around some discussion on the commands =
subject,=20
>>>> but I would need some straight/simple example (snippet) to see how =
to=20
>>>> work with these commands.
>>>>
>>>> Any help? Please!<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0=20
>>>> Transitional//EN">
>>>> <HTML><HEAD>
>>>> <META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
>>>> <META content=3D"MSHTML 6.00.6000.16414" name=3DGENERATOR>
>>>> <STYLE></STYLE>
>>>> </HEAD>
>>>> <BODY>
>>>> <DIV><FONT size=3D2>I have a problem with changing the model behind =
the=20
>>>> diagram.
>>>> What I am trying to do is inserting/populating a reference of the =
model.=20
>>>> This
>>>> has nothing to do with the diagram, since there will be no =
graphical=20
>>>> element
>>>> corresponding to this.</FONT></DIV>
>>>> <DIV><FONT size=3D2><FONT size=3D2></FONT></FONT>&nbsp;</DIV>
>>>> <DIV><FONT size=3D2>Here it&nbsp;is the code:</FONT></DIV>
>>>> <DIV>&nbsp;</DIV>
>>>> <DIV align=3Dleft><FONT size=3D2>EditingDomain editDomain =3D
>>>> protocolEditPart.getEditingDomain();</FONT></DIV>
>>>> <DIV align=3Dleft><FONT size=3D2>ResourceSet resSet =3D
>>>> editDomain.getResourceSet();</FONT></DIV>
>>>> <DIV align=3Dleft><FONT size=3D2>EList resources =3D
>>>> resSet.getResources();</FONT></DIV>
>>>> <DIV align=3Dleft><FONT size=3D2>Resource res =3D
>>>> (Resource)resources.get(0);</FONT></DIV>
>>>> <DIV align=3Dleft><FONT size=3D2><FONT =
size=3D2></FONT></FONT>&nbsp;</DIV>
>>>> <DIV align=3Dleft><FONT size=3D2>if(res !=3D null) {</FONT></DIV>
>>>> <DIV align=3Dleft><FONT size=3D2>&nbsp;&nbsp;&nbsp; for(Iterator =
iter =3D
>>>> res.getAllContents(); iter.hasNext(); ) {</FONT></DIV>
>>>> <DIV align=3Dleft><FONT size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp; Object=20
>>>> o =3D
>>>> iter.next();</FONT></DIV>
>>>> <DIV align=3Dleft><FONT size=3D2><FONT size=3D2>&nbsp;&nbsp;&nbsp;=20
>>>> &nbsp;&nbsp;&nbsp;
>>>> </FONT></FONT></DIV>
>>>> <DIV align=3Dleft><FONT size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp; if(o
>>>> instanceof ProtocolModel) {</FONT></DIV>
>>>> <DIV align=3Dleft><FONT size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;
>>>> &nbsp;&nbsp;&nbsp; ProtocolModel pm =3D =
(ProtocolModel)o;</FONT></DIV>
>>>> <DIV align=3Dleft><FONT size=3D2><FONT size=3D2>&nbsp;&nbsp;&nbsp;=20
>>>> &nbsp;&nbsp;&nbsp;
>>>> &nbsp;&nbsp;&nbsp; </FONT></FONT></DIV>
>>>> <DIV align=3Dleft><FONT size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;
>>>> &nbsp;&nbsp;&nbsp; pm.setDataModel(mainPage.dataModel); //=20
>>>> PROBLEM!</FONT></DIV>
>>>> <DIV align=3Dleft><FONT size=3D2><FONT size=3D2>&nbsp;&nbsp;&nbsp;=20
>>>> &nbsp;&nbsp;&nbsp;
>>>> &nbsp;&nbsp;&nbsp; </FONT></FONT></DIV>
>>>> <DIV align=3Dleft><FONT size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;
>>>> &nbsp;&nbsp;&nbsp; break;</FONT></DIV>
>>>> <DIV align=3Dleft><FONT size=3D2>&nbsp;&nbsp;&nbsp; =
&nbsp;&nbsp;&nbsp;
>>>> }</FONT></DIV>
>>>> <DIV align=3Dleft><FONT size=3D2>}</FONT></DIV>
>>>> <DIV align=3Dleft><FONT size=3D2><FONT =
size=3D2></FONT></FONT>&nbsp;</DIV>
>>>> <DIV><FONT size=3D2>When I set the DataModel it gives me the error =
saying I=20
>>>> have
>>>> to use transactions... I read around some discussion on the =
commands=20
>>>> subject,
>>>> but I would need some straight/simple example (snippet) to see how =
to=20
>>>> work with
>>>> these commands.</FONT></DIV>
>>>> <DIV><FONT size=3D2></FONT>&nbsp;</DIV>
>>>> <DIV><FONT size=3D2>Any help? Please!</FONT></DIV></BODY></HTML>
>>>
>
------=_NextPart_000_0053_01C776B7.DA68EA30
Content-Type: text/html;
charset="ISO-8859-15"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-15">
<META content=3D"MSHTML 6.00.6000.16414" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff background=3D"">
<DIV><FONT size=3D2>I tryed the first solution, but, unfortunately, =
there is no=20
result in the model file. Although is says the file was modified (the =
little *=20
appears near the name of the file in the editor), when I close the =
editor and=20
choose YES when it askes for saving the file, it gives me 2 identical =
errors:=20
"An internal error occurred during:<BR><BR>"<STRONG><EM>An internal =
error=20
occurred during: "children update".=20
java.lang.ArrayIndexOutOfBoundsException</EM></STRONG>"<BR ><BR>Any ideea =
of what=20
could it be worng?</FONT></DIV>
<DIV><FONT size=3D2><BR><BR><BR>"Vlad Ciubotariu" =
&lt;vcciubot@uwaterloo.ca&gt;=20
wrote in message =
news:pan.2007.04.03.17.34.23.269142@uwaterloo.ca...<BR>&gt;=20
command.execute(new NullProgressMonitor(), null)<BR>&gt; <BR>&gt; or=20
OperationHistoryFactory.getOperationHistory().execute(comman d) <BR>&gt; =
<BR>&gt;=20
vlad<BR>&gt; <BR>&gt; On Tue, 03 Apr 2007 19:35:07 +0300, Florin Banica=20
wrote:<BR>&gt; <BR>&gt;&gt; Salut, Vlad!<BR>&gt;&gt; <BR>&gt;&gt; =
Everything=20
looks fine, but i'm missing the call (execution) of this <BR>&gt;&gt; =
command...=20
How do I execute it from within my code?<BR>&gt;&gt; <BR>&gt;&gt;=20
Thanks.<BR>&gt;&gt; <BR>&gt;&gt; <BR>&gt;&gt; "Vlad Ciubotariu"=20
&lt;vcciubot@uwaterloo.ca&gt; wrote in message <BR>&gt;&gt;=20
news:pan.2007.04.03.15.17.32.707195@uwaterloo.ca...<BR>&gt;&gt;&gt;=20
Salut!<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; To read or write the model you =
must use=20
commands. You don't need commands<BR>&gt;&gt;&gt; if you read the model =
from an=20
edit policy's getCommand().<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; To write to =
the=20
model, you have to the wrap the code into an<BR>&gt;&gt;&gt;=20
AbstractTransactionalCommand, you'll find a full example=20
below.<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; If you need to execute such a =
command=20
from an action you will need a<BR>&gt;&gt;&gt; ProgressMonitor. You can =
always=20
use the NullProgressMonitor for this.<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; If =
you=20
need to return such a command from an edit policy then you =
must<BR>&gt;&gt;&gt;=20
wrap it around an ICommandProxy.<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; Please =
note you=20
cannot execute write commands from<BR>&gt;&gt;&gt;=20
GraphicalEditPart.getCommand() or from edit policies=20
getCommand().<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; hope this=20
helps!<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt;=20
vlad<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; <BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt;<BR >&=
gt;&gt;&gt;<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt;=20
public class ImportEntityCommand extends AbstractTransactionalCommand=20
{<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; private static String label =3D =
"Import Block=20
Interface Command";<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; private IFile=20
file;<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; private Block =
block;<BR>&gt;&gt;&gt;=20
private Shell shell;<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; public=20
ImportEntityCommand(Block block, IFile file, Shell shell) =
{<BR>&gt;&gt;&gt;=20
super(TransactionUtil.getEditingDomain(block), label,<BR>&gt;&gt;&gt;=20
getWorkspaceFiles(block));<BR>&gt;&gt;&gt; this.block =3D =
block;<BR>&gt;&gt;&gt;=20
this.file =3D file;<BR>&gt;&gt;&gt; this.shell =3D =
shell;<BR>&gt;&gt;&gt;=20
}<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; @Override<BR>&gt;&gt;&gt; protected=20
CommandResult doExecuteWithResult(IProgressMonitor =
monitor,<BR>&gt;&gt;&gt;=20
IAdaptable info) throws ExecutionException =
{<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt;=20
String filePath =3D=20
file.getLocationURI().getPath().toString();<BR>&gt;&gt;&gt; <BR>&gt;&gt;&g=
t;=20
ArrayList&lt;DesignUnit&gt; dus =3D =
VHDLUtils.parse(filePath);<BR>&gt;&gt;&gt;=20
VHDLCompilationUnit compilationUnit =3D <BR>&gt;&gt;&gt;=20
Bluenose2Factory.eINSTANCE.createVHDLCompilationUnit();<BR>&gt;&gt;&gt; <B=
R>&gt;&gt;&gt;<BR>&gt;&gt;&gt;=20
for (DesignUnit du : dus) {<BR>&gt;&gt;&gt; if (du instanceof Entity)=20
{<BR>&gt;&gt;&gt; compilationUnit.getEntities().add(=20
VHDLUtils.createEntity(<BR>&gt;&gt;&gt; (Entity) du) );<BR>&gt;&gt;&gt;=20
}<BR>&gt;&gt;&gt; }<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; <BR>&gt;&gt;&gt;=20
ElementTreeSelectionDialog dialog =3D new =
ElementTreeSelectionDialog(shell,=20
<BR>&gt;&gt;&gt; new AdapterFactoryLabelProvider(<BR>&gt;&gt;&gt;=20
Bluenose2DiagramEditorPlugin.getInstance()<BR>&gt;&gt;&gt;=20
..getItemProvidersAdapterFactory()), new=20
AdapterFactoryContentProvider(<BR>&gt;&gt;&gt;=20
Bluenose2DiagramEditorPlugin.getInstance()<BR>&gt;&gt;&gt;=20
..getItemProvidersAdapterFactory()) );<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt;=20
dialog.setTitle("Import Entity Dialog");<BR>&gt;&gt;&gt;=20
dialog.setMessage("Please select the toplevel entity to=20
import.");<BR>&gt;&gt;&gt; =
dialog.setInput(compilationUnit);<BR>&gt;&gt;&gt;=20
dialog.open();<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; if ( =
dialog.getReturnCode() =3D=3D=20
Dialog.OK) {<BR>&gt;&gt;&gt; Object[] result =3D=20
dialog.getResult();<BR>&gt;&gt;&gt; if (result.length &gt; 0 &amp;&amp;=20
result[0] instanceof VHDLEntity) {<BR>&gt;&gt;&gt; VHDLEntity entity =3D =

(VHDLEntity) result[0];<BR>&gt;&gt;&gt;=20
block.setBlkInterface(entity.getInterface());<BR>&gt;&gt;&gt; =
}<BR>&gt;&gt;&gt;=20
}<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; return=20
CommandResult.newOKCommandResult();<BR>&gt;&gt;&gt;=20
}<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt;=20
}<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; <BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt;<BR >&gt;=
&gt;&gt;=20
On Tue, 03 Apr 2007 12:22:42 +0300, Florin Banica=20
wrote:<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt;&gt; I have a problem with =
changing the=20
model behind the diagram. What I am <BR>&gt;&gt;&gt;&gt; trying to do is =

inserting/populating a reference of the model. This has =
<BR>&gt;&gt;&gt;&gt;=20
nothing to do with the diagram, since there will be no graphical element =

<BR>&gt;&gt;&gt;&gt; corresponding to=20
this.<BR>&gt;&gt;&gt;&gt;<BR>&gt;&gt;&gt;&gt; Here it is the=20
code:<BR>&gt;&gt;&gt;&gt;<BR>&gt;&gt;&gt;&gt; EditingDomain editDomain =
=3D=20
protocolEditPart.getEditingDomain();<BR>&gt;&gt;&gt;&gt; ResourceSet =
resSet =3D=20
editDomain.getResourceSet();<BR>&gt;&gt;&gt;&gt; EList resources =3D=20
resSet.getResources();<BR>&gt;&gt;&gt;&gt; Resource res =3D=20
(Resource)resources.get(0);<BR>&gt;&gt;&gt;&gt; <BR>&gt;&gt;&gt;&gt; =
if(res !=3D=20
null) {<BR> &gt;&gt;&gt;&gt;&nbsp;&nbsp;&nbs p;&nbsp; for(Iterator iter =
=3D=20
res.getAllContents(); iter.hasNext(); )=20
{<BR> &gt;&gt;&gt;&gt;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
Object o =3D=20
iter.next();<BR>&gt;&gt;&gt;&gt;<BR> &gt;&gt;&gt;&gt;&nbsp;&nbsp;&nbs p;&nb=
sp;&nbsp;&nbsp;&nbsp;&nbsp;=20
if(o instanceof ProtocolModel)=20
{<BR> &gt;&gt;&gt;&gt;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs =
p;&nbsp;&nbsp;&nbsp;=20
ProtocolModel pm =3D=20
(ProtocolModel)o;<BR>&gt;&gt;&gt;&gt;<BR> &gt;&gt;&gt;&gt;&nbsp;&nbsp;&nbs =
p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;=20
pm.setDataModel(mainPage.dataModel); //=20
PROBLEM!<BR>&gt;&gt;&gt;&gt;<BR> &gt;&gt;&gt;&gt;&nbsp;&nbsp;&nbs p;&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp;&nbsp;=20
break;<BR> &gt;&gt;&gt;&gt;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp=
;=20
}<BR>&gt;&gt;&gt;&gt; }<BR>&gt;&gt;&gt;&gt;<BR>&gt;&gt;&gt;&gt; When I =
set the=20
DataModel it gives me the error saying I have to use =
<BR>&gt;&gt;&gt;&gt;=20
transactions... I read around some discussion on the commands subject,=20
<BR>&gt;&gt;&gt;&gt; but I would need some straight/simple example =
(snippet) to=20
see how to <BR>&gt;&gt;&gt;&gt; work with these=20
commands.<BR>&gt;&gt;&gt;&gt;<BR>&gt;&gt;&gt;&gt; Any help? =
Please!&lt;!DOCTYPE=20
HTML PUBLIC "-//W3C//DTD HTML 4.0 <BR>&gt;&gt;&gt;&gt;=20
Transitional//EN"&gt;<BR>&gt;&gt;&gt;&gt;=20
&lt;HTML&gt;&lt;HEAD&gt;<BR>&gt;&gt;&gt;&gt; &lt;META =
http-equiv=3DContent-Type=20
content=3D"text/html; charset=3Diso-8859-1"&gt;<BR>&gt;&gt;&gt;&gt; =
&lt;META=20
content=3D"MSHTML 6.00.6000.16414" =
name=3DGENERATOR&gt;<BR>&gt;&gt;&gt;&gt;=20
&lt;STYLE&gt;&lt;/STYLE&gt;<BR>&gt;&gt;&gt;&gt;=20
&lt;/HEAD&gt;<BR>&gt;&gt;&gt;&gt; &lt;BODY&gt;<BR>&gt;&gt;&gt;&gt;=20
&lt;DIV&gt;&lt;FONT size=3D2&gt;I have a problem with changing the model =
behind=20
the <BR>&gt;&gt;&gt;&gt; diagram.<BR>&gt;&gt;&gt;&gt; What I am trying =
to do is=20
inserting/populating a reference of the model. <BR>&gt;&gt;&gt;&gt;=20
This<BR>&gt;&gt;&gt;&gt; has nothing to do with the diagram, since there =
will be=20
no graphical <BR>&gt;&gt;&gt;&gt; element<BR>&gt;&gt;&gt;&gt; =
corresponding to=20
this.&lt;/FONT&gt;&lt;/DIV&gt;<BR>&gt;&gt;&gt;&gt; &lt;DIV&gt;&lt;FONT=20
size=3D2&gt;&lt;FONT=20
size=3D2&gt;&lt;/FONT&gt;&lt;/FONT&gt;&a mp;amp;nbsp;&lt;/DIV&gt; <BR>&gt;&gt;&=
gt;&gt;=20
&lt;DIV&gt;&lt;FONT size=3D2&gt;Here it&amp;nbsp;is the=20
code:&lt;/FONT&gt;&lt;/DIV&gt;<BR>&gt;&gt;&gt;&gt;=20
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;<BR>&gt;&gt;&gt;&gt; &lt;DIV=20
align=3Dleft&gt;&lt;FONT size=3D2&gt;EditingDomain editDomain =
=3D<BR>&gt;&gt;&gt;&gt;=20
protocolEditPart.getEditingDomain();&lt;/FONT&gt;&am p;lt;/DIV&gt; <BR>&gt;&gt;=
&gt;&gt;=20
&lt;DIV align=3Dleft&gt;&lt;FONT size=3D2&gt;ResourceSet resSet=20
=3D<BR>&gt;&gt;&gt;&gt;=20
editDomain.getResourceSet();&lt;/FONT&gt;&lt;/DI V&gt; <BR>&gt;&gt;&gt;&gt;=
=20
&lt;DIV align=3Dleft&gt;&lt;FONT size=3D2&gt;EList resources =
=3D<BR>&gt;&gt;&gt;&gt;=20
resSet.getResources();&lt;/FONT&gt;&lt;/DIV& gt; <BR>&gt;&gt;&gt;&gt; =
&lt;DIV=20
align=3Dleft&gt;&lt;FONT size=3D2&gt;Resource res =
=3D<BR>&gt;&gt;&gt;&gt;=20
(Resource)resources.get(0);&lt;/FONT&gt;&lt;/DIV &gt; <BR>&gt;&gt;&gt;&gt; =
&lt;DIV=20
align=3Dleft&gt;&lt;FONT size=3D2&gt;&lt;FONT=20
size=3D2&gt;&lt;/FONT&gt;&lt;/FONT&gt;&a mp;amp;nbsp;&lt;/DIV&gt; <BR>&gt;&gt;&=
gt;&gt;=20
&lt;DIV align=3Dleft&gt;&lt;FONT size=3D2&gt;if(res !=3D null)=20
{&lt;/FONT&gt;&lt;/DIV&gt;<BR>&gt;&gt;&gt;&gt; &lt;DIV =
align=3Dleft&gt;&lt;FONT=20
size=3D2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(Iterator iter =
=3D<BR>&gt;&gt;&gt;&gt;=20
res.getAllContents(); iter.hasNext(); )=20
{&lt;/FONT&gt;&lt;/DIV&gt;<BR>&gt;&gt;&gt;&gt; &lt;DIV =
align=3Dleft&gt;&lt;FONT=20
size=3D2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; =
&amp;nbsp;&amp;nbsp;&amp;nbsp; Object=20
<BR>&gt;&gt;&gt;&gt; o =3D<BR>&gt;&gt;&gt;&gt;=20
iter.next();&lt;/FONT&gt;&lt;/DIV&gt;<BR>&gt;&gt;&gt;&gt; &lt;DIV=20
align=3Dleft&gt;&lt;FONT size=3D2&gt;&lt;FONT=20
size=3D2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; <BR>&gt;&gt;&gt;&gt;=20
&amp;nbsp;&amp;nbsp;&amp;nbsp;<BR>&gt;&gt;&gt;&gt;=20
&lt;/FONT&gt;&lt;/FONT&gt;&lt;/DIV&g t; <BR>&gt;&gt;&gt;&gt; &lt;DIV=20
align=3Dleft&gt;&lt;FONT size=3D2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;=2 0
&amp;nbsp;&amp;nbsp;&amp;nbsp; if(o<BR>&gt;&gt;&gt;&gt; instanceof=20
ProtocolModel) {&lt;/FONT&gt;&lt;/DIV&gt;<BR>&gt;&gt;&gt;&gt; &lt;DIV=20
align=3Dleft&gt;&lt;FONT size=3D2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;=2 0
&amp;nbsp;&amp;nbsp;&amp;nbsp;<BR>&gt;&gt;&gt;&gt;=20
&amp;nbsp;&amp;nbsp;&amp;nbsp; ProtocolModel pm =3D=20
(ProtocolModel)o;&lt;/FONT&gt;&lt;/DIV&gt;<BR >&gt;&gt;&gt;&gt; &lt;DIV=20
align=3Dleft&gt;&lt;FONT size=3D2&gt;&lt;FONT=20
size=3D2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; <BR>&gt;&gt;&gt;&gt;=20
&amp;nbsp;&amp;nbsp;&amp;nbsp;<BR>&gt;&gt;&gt;&gt;=20
&amp;nbsp;&amp;nbsp;&amp;nbsp;=20
&lt;/FONT&gt;&lt;/FONT&gt;&lt;/DIV&g t; <BR>&gt;&gt;&gt;&gt; &lt;DIV=20
align=3Dleft&gt;&lt;FONT size=3D2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;=2 0
&amp;nbsp;&amp;nbsp;&amp;nbsp;<BR>&gt;&gt;&gt;&gt;=20
&amp;nbsp;&amp;nbsp;&amp;nbsp; pm.setDataModel(mainPage.dataModel); //=20
<BR>&gt;&gt;&gt;&gt; =
PROBLEM!&lt;/FONT&gt;&lt;/DIV&gt;<BR>&gt;&gt;&gt;&gt;=20
&lt;DIV align=3Dleft&gt;&lt;FONT size=3D2&gt;&lt;FONT=20
size=3D2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; <BR>&gt;&gt;&gt;&gt;=20
&amp;nbsp;&amp;nbsp;&amp;nbsp;<BR>&gt;&gt;&gt;&gt;=20
&amp;nbsp;&amp;nbsp;&amp;nbsp;=20
&lt;/FONT&gt;&lt;/FONT&gt;&lt;/DIV&g t; <BR>&gt;&gt;&gt;&gt; &lt;DIV=20
align=3Dleft&gt;&lt;FONT size=3D2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;=2 0
&amp;nbsp;&amp;nbsp;&amp;nbsp;<BR>&gt;&gt;&gt;&gt;=20
&amp;nbsp;&amp;nbsp;&amp;nbsp;=20
break;&lt;/FONT&gt;&lt;/DIV&gt;<BR>&gt;&gt;&gt;&gt; &lt;DIV=20
align=3Dleft&gt;&lt;FONT size=3D2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;=2 0
&amp;nbsp;&amp;nbsp;&amp;nbsp;<BR>&gt;&gt;&gt;&gt;=20
}&lt;/FONT&gt;&lt;/DIV&gt;<BR>&gt;&gt;&gt;&gt; &lt;DIV =
align=3Dleft&gt;&lt;FONT=20
size=3D2&gt;}&lt;/FONT&gt;&lt;/DIV&gt;<BR >&gt;&gt;&gt;&gt; &lt;DIV=20
align=3Dleft&gt;&lt;FONT size=3D2&gt;&lt;FONT=20
size=3D2&gt;&lt;/FONT&gt;&lt;/FONT&gt;&a mp;amp;nbsp;&lt;/DIV&gt; <BR>&gt;&gt;&=
gt;&gt;=20
&lt;DIV&gt;&lt;FONT size=3D2&gt;When I set the DataModel it gives me the =
error=20
saying I <BR>&gt;&gt;&gt;&gt; have<BR>&gt;&gt;&gt;&gt; to use =
transactions... I=20
read around some discussion on the commands <BR>&gt;&gt;&gt;&gt;=20
subject,<BR>&gt;&gt;&gt;&gt; but I would need some straight/simple =
example=20
(snippet) to see how to <BR>&gt;&gt;&gt;&gt; work =
with<BR>&gt;&gt;&gt;&gt; these=20
commands.&lt;/FONT&gt;&lt;/DIV&gt;<BR>&gt;&gt;&gt;&gt; =
&lt;DIV&gt;&lt;FONT=20
size=3D2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/ DIV&gt; <BR>&gt;&gt;&gt;&gt;=20
&lt;DIV&gt;&lt;FONT size=3D2&gt;Any help?=20
Please!&lt;/FONT&gt;&lt;/DIV&gt;&lt;/BOD Y&gt;&lt;/HTML&gt; <BR>&gt;&gt;&gt=
;<BR>&gt;</FONT></DIV></BODY></HTML>

------=_NextPart_000_0053_01C776B7.DA68EA30--
Re: Problems with Command [message #116950 is a reply to message #116860] Wed, 04 April 2007 10:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: vcciubot.uwaterloo.ca

Could you post the code?

vlad


On Wed, 04 Apr 2007 12:50:41 +0300, Florin Banica wrote:

> I tryed the first solution, but, unfortunately, there is no result in the model file. Although is says the file was modified (the little * appears near the name of the file in the editor), when I close the editor and choose YES when it askes for saving the file, it gives me 2 identical errors: "An internal error occurred during:
>
> "An internal error occurred during: "children update". java.lang.ArrayIndexOutOfBoundsException"
>
> Any ideea of what could it be worng?
>
>
>
> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message news:pan.2007.04.03.17.34.23.269142@uwaterloo.ca...
>> command.execute(new NullProgressMonitor(), null)
>>
>> or OperationHistoryFactory.getOperationHistory().execute(comman d)
>>
>> vlad
>>
>> On Tue, 03 Apr 2007 19:35:07 +0300, Florin Banica wrote:
>>
>>> Salut, Vlad!
>>>
>>> Everything looks fine, but i'm missing the call (execution) of this
>>> command... How do I execute it from within my code?
>>>
>>> Thanks.
>>>
>>>
>>> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
>>> news:pan.2007.04.03.15.17.32.707195@uwaterloo.ca...
>>>> Salut!
>>>>
>>>> To read or write the model you must use commands. You don't need commands
>>>> if you read the model from an edit policy's getCommand().
>>>>
>>>> To write to the model, you have to the wrap the code into an
>>>> AbstractTransactionalCommand, you'll find a full example below.
>>>>
>>>> If you need to execute such a command from an action you will need a
>>>> ProgressMonitor. You can always use the NullProgressMonitor for this.
>>>>
>>>> If you need to return such a command from an edit policy then you must
>>>> wrap it around an ICommandProxy.
>>>>
>>>> Please note you cannot execute write commands from
>>>> GraphicalEditPart.getCommand() or from edit policies getCommand().
>>>>
>>>> hope this helps!
>>>>
>>>> vlad
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> public class ImportEntityCommand extends AbstractTransactionalCommand {
>>>>
>>>> private static String label = "Import Block Interface Command";
>>>>
>>>> private IFile file;
>>>>
>>>> private Block block;
>>>> private Shell shell;
>>>>
>>>> public ImportEntityCommand(Block block, IFile file, Shell shell) {
>>>> super(TransactionUtil.getEditingDomain(block), label,
>>>> getWorkspaceFiles(block));
>>>> this.block = block;
>>>> this.file = file;
>>>> this.shell = shell;
>>>> }
>>>>
>>>> @Override
>>>> protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
>>>> IAdaptable info) throws ExecutionException {
>>>>
>>>> String filePath = file.getLocationURI().getPath().toString();
>>>>
>>>> ArrayList<DesignUnit> dus = VHDLUtils.parse(filePath);
>>>> VHDLCompilationUnit compilationUnit =
>>>> Bluenose2Factory.eINSTANCE.createVHDLCompilationUnit();
>>>>
>>>>
>>>> for (DesignUnit du : dus) {
>>>> if (du instanceof Entity) {
>>>> compilationUnit.getEntities().add( VHDLUtils.createEntity(
>>>> (Entity) du) );
>>>> }
>>>> }
>>>>
>>>>
>>>> ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell,
>>>> new AdapterFactoryLabelProvider(
>>>> Bluenose2DiagramEditorPlugin.getInstance()
>>>> .getItemProvidersAdapterFactory()), new AdapterFactoryContentProvider(
>>>> Bluenose2DiagramEditorPlugin.getInstance()
>>>> .getItemProvidersAdapterFactory()) );
>>>>
>>>> dialog.setTitle("Import Entity Dialog");
>>>> dialog.setMessage("Please select the toplevel entity to import.");
>>>> dialog.setInput(compilationUnit);
>>>> dialog.open();
>>>>
>>>> if ( dialog.getReturnCode() == Dialog.OK) {
>>>> Object[] result = dialog.getResult();
>>>> if (result.length > 0 && result[0] instanceof VHDLEntity) {
>>>> VHDLEntity entity = (VHDLEntity) result[0];
>>>> block.setBlkInterface(entity.getInterface());
>>>> }
>>>> }
>>>>
>>>> return CommandResult.newOKCommandResult();
>>>> }
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>>
>>>> On Tue, 03 Apr 2007 12:22:42 +0300, Florin Banica wrote:
>>>>
>>>>> I have a problem with changing the model behind the diagram. What I am
>>>>> trying to do is inserting/populating a reference of the model. This has
>>>>> nothing to do with the diagram, since there will be no graphical element
>>>>> corresponding to this.
>>>>>
>>>>> Here it is the code:
>>>>>
>>>>> EditingDomain editDomain = protocolEditPart.getEditingDomain();
>>>>> ResourceSet resSet = editDomain.getResourceSet();
>>>>> EList resources = resSet.getResources();
>>>>> Resource res = (Resource)resources.get(0);
>>>>>
>>>>> if(res != null) {
>>>>> for(Iterator iter = res.getAllContents(); iter.hasNext(); ) {
>>>>> Object o = iter.next();
>>>>>
>>>>> if(o instanceof ProtocolModel) {
>>>>> ProtocolModel pm = (ProtocolModel)o;
>>>>>
>>>>> pm.setDataModel(mainPage.dataModel); // PROBLEM!
>>>>>
>>>>> break;
>>>>> }
>>>>> }
>>>>>
>>>>> When I set the DataModel it gives me the error saying I have to use
>>>>> transactions... I read around some discussion on the commands subject,
>>>>> but I would need some straight/simple example (snippet) to see how to
>>>>> work with these commands.
>>>>>
>>>>> Any help? Please!<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
>>>>> Transitional//EN">
>>>>> <HTML><HEAD>
>>>>> <META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
>>>>> <META content="MSHTML 6.00.6000.16414" name=GENERATOR>
>>>>> <STYLE></STYLE>
>>>>> </HEAD>
>>>>> <BODY>
>>>>> <DIV><FONT size=2>I have a problem with changing the model behind the
>>>>> diagram.
>>>>> What I am trying to do is inserting/populating a reference of the model.
>>>>> This
>>>>> has nothing to do with the diagram, since there will be no graphical
>>>>> element
>>>>> corresponding to this.</FONT></DIV>
>>>>> <DIV><FONT size=2><FONT size=2></FONT></FONT>&nbsp;</DIV>
>>>>> <DIV><FONT size=2>Here it&nbsp;is the code:</FONT></DIV>
>>>>> <DIV>&nbsp;</DIV>
>>>>> <DIV align=left><FONT size=2>EditingDomain editDomain =
>>>>> protocolEditPart.getEditingDomain();</FONT></DIV>
>>>>> <DIV align=left><FONT size=2>ResourceSet resSet =
>>>>> editDomain.getResourceSet();</FONT></DIV>
>>>>> <DIV align=left><FONT size=2>EList resources =
>>>>> resSet.getResources();</FONT></DIV>
>>>>> <DIV align=left><FONT size=2>Resource res =
>>>>> (Resource)resources.get(0);</FONT></DIV>
>>>>> <DIV align=left><FONT size=2><FONT size=2></FONT></FONT>&nbsp;</DIV>
>>>>> <DIV align=left><FONT size=2>if(res != null) {</FONT></DIV>
>>>>> <DIV align=left><FONT size=2>&nbsp;&nbsp;&nbsp; for(Iterator iter =
>>>>> res.getAllContents(); iter.hasNext(); ) {</FONT></DIV>
>>>>> <DIV align=left><FONT size=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Object
>>>>> o =
>>>>> iter.next();</FONT></DIV>
>>>>> <DIV align=left><FONT size=2><FONT size=2>&nbsp;&nbsp;&nbsp;
>>>>> &nbsp;&nbsp;&nbsp;
>>>>> </FONT></FONT></DIV>
>>>>> <DIV align=left><FONT size=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if(o
>>>>> instanceof ProtocolModel) {</FONT></DIV>
>>>>> <DIV align=left><FONT size=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
>>>>> &nbsp;&nbsp;&nbsp; ProtocolModel pm = (ProtocolModel)o;</FONT></DIV>
>>>>> <DIV align=left><FONT size=2><FONT size=2>&nbsp;&nbsp;&nbsp;
>>>>> &nbsp;&nbsp;&nbsp;
>>>>> &nbsp;&nbsp;&nbsp; </FONT></FONT></DIV>
>>>>> <DIV align=left><FONT size=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
>>>>> &nbsp;&nbsp;&nbsp; pm.setDataModel(mainPage.dataModel); //
>>>>> PROBLEM!</FONT></DIV>
>>>>> <DIV align=left><FONT size=2><FONT size=2>&nbsp;&nbsp;&nbsp;
>>>>> &nbsp;&nbsp;&nbsp;
>>>>> &nbsp;&nbsp;&nbsp; </FONT></FONT></DIV>
>>>>> <DIV align=left><FONT size=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
>>>>> &nbsp;&nbsp;&nbsp; break;</FONT></DIV>
>>>>> <DIV align=left><FONT size=2>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;
>>>>> }</FONT></DIV>
>>>>> <DIV align=left><FONT size=2>}</FONT></DIV>
>>>>> <DIV align=left><FONT size=2><FONT size=2></FONT></FONT>&nbsp;</DIV>
>>>>> <DIV><FONT size=2>When I set the DataModel it gives me the error saying I
>>>>> have
>>>>> to use transactions... I read around some discussion on the commands
>>>>> subject,
>>>>> but I would need some straight/simple example (snippet) to see how to
>>>>> work with
>>>>> these commands.</FONT></DIV>
>>>>> <DIV><FONT size=2></FONT>&nbsp;</DIV>
>>>>> <DIV><FONT size=2>Any help? Please!</FONT></DIV></BODY></HTML>
>>>>
>><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> <HTML><HEAD>
> <META http-equiv=Content-Type content="text/html; charset=iso-8859-15">
> <META content="MSHTML 6.00.6000.16414" name=GENERATOR>
> <STYLE></STYLE>
> </HEAD>
> <BODY bgColor=#ffffff background="">
> <DIV><FONT size=2>I tryed the first solution, but, unfortunately, there is no
> result in the model file. Although is says the file was modified (the little *
> appears near the name of the file in the editor), when I close the editor and
> choose YES when it askes for saving the file, it gives me 2 identical errors:
> "An internal error occurred during:<BR><BR>"<STRONG><EM>An internal error
> occurred during: "children update".
> java.lang.ArrayIndexOutOfBoundsException</EM></STRONG>"<BR ><BR>Any ideea of what
> could it be worng?</FONT></DIV>
> <DIV><FONT size=2><BR><BR><BR>"Vlad Ciubotariu" &lt;vcciubot@uwaterloo.ca&gt;
> wrote in message news:pan.2007.04.03.17.34.23.269142@uwaterloo.ca...<BR>&gt;
> command.execute(new NullProgressMonitor(), null)<BR>&gt; <BR>&gt; or
> OperationHistoryFactory.getOperationHistory().execute(comman d) <BR>&gt; <BR>&gt;
> vlad<BR>&gt; <BR>&gt; On Tue, 03 Apr 2007 19:35:07 +0300, Florin Banica
> wrote:<BR>&gt; <BR>&gt;&gt; Salut, Vlad!<BR>&gt;&gt; <BR>&gt;&gt; Everything
> looks fine, but i'm missing the call (execution) of this <BR>&gt;&gt; command...
> How do I execute it from within my code?<BR>&gt;&gt; <BR>&gt;&gt;
> Thanks.<BR>&gt;&gt; <BR>&gt;&gt; <BR>&gt;&gt; "Vlad Ciubotariu"
> &lt;vcciubot@uwaterloo.ca&gt; wrote in message <BR>&gt;&gt;
> news:pan.2007.04.03.15.17.32.707195@uwaterloo.ca...<BR>&gt;&gt;&gt;
> Salut!<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; To read or write the model you must use
> commands. You don't need commands<BR>&gt;&gt;&gt; if you read the model from an
> edit policy's getCommand().<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; To write to the
> model, you have to the wrap the code into an<BR>&gt;&gt;&gt;
> AbstractTransactionalCommand, you'll find a full example
> below.<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; If you need to execute such a command
> from an action you will need a<BR>&gt;&gt;&gt; ProgressMonitor. You can always
> use the NullProgressMonitor for this.<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; If you
> need to return such a command from an edit policy then you must<BR>&gt;&gt;&gt;
> wrap it around an ICommandProxy.<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; Please note you
> cannot execute write commands from<BR>&gt;&gt;&gt;
> GraphicalEditPart.getCommand() or from edit policies
> getCommand().<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; hope this
> helps!<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt;
> vlad<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; <BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt;<BR >&gt;&gt;&gt;<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt;
> public class ImportEntityCommand extends AbstractTransactionalCommand
> {<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; private static String label = "Import Block
> Interface Command";<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; private IFile
> file;<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; private Block block;<BR>&gt;&gt;&gt;
> private Shell shell;<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; public
> ImportEntityCommand(Block block, IFile file, Shell shell) {<BR>&gt;&gt;&gt;
> super(TransactionUtil.getEditingDomain(block), label,<BR>&gt;&gt;&gt;
> getWorkspaceFiles(block));<BR>&gt;&gt;&gt; this.block = block;<BR>&gt;&gt;&gt;
> this.file = file;<BR>&gt;&gt;&gt; this.shell = shell;<BR>&gt;&gt;&gt;
> }<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; @Override<BR>&gt;&gt;&gt; protected
> CommandResult doExecuteWithResult(IProgressMonitor monitor,<BR>&gt;&gt;&gt;
> IAdaptable info) throws ExecutionException {<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt;
> String filePath =
> file.getLocationURI().getPath().toString();<BR>&gt;&gt;&gt; <BR>&gt;&gt;&gt;
> ArrayList&lt;DesignUnit&gt; dus = VHDLUtils.parse(filePath);<BR>&gt;&gt;&gt;
> VHDLCompilationUnit compilationUnit = <BR>&gt;&gt;&gt;
> Bluenose2Factory.eINSTANCE.createVHDLCompilationUnit();<BR>&gt;&gt;&gt; <BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt;
> for (DesignUnit du : dus) {<BR>&gt;&gt;&gt; if (du instanceof Entity)
> {<BR>&gt;&gt;&gt; compilationUnit.getEntities().add(
> VHDLUtils.createEntity(<BR>&gt;&gt;&gt; (Entity) du) );<BR>&gt;&gt;&gt;
> }<BR>&gt;&gt;&gt; }<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; <BR>&gt;&gt;&gt;
> ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(shell,
> <BR>&gt;&gt;&gt; new AdapterFactoryLabelProvider(<BR>&gt;&gt;&gt;
> Bluenose2DiagramEditorPlugin.getInstance()<BR>&gt;&gt;&gt;
> .getItemProvidersAdapterFactory()), new
> AdapterFactoryContentProvider(<BR>&gt;&gt;&gt;
> Bluenose2DiagramEditorPlugin.getInstance()<BR>&gt;&gt;&gt;
> .getItemProvidersAdapterFactory()) );<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt;
> dialog.setTitle("Import Entity Dialog");<BR>&gt;&gt;&gt;
> dialog.setMessage("Please select the toplevel entity to
> import.");<BR>&gt;&gt;&gt; dialog.setInput(compilationUnit);<BR>&gt;&gt;&gt;
> dialog.open();<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; if ( dialog.getReturnCode() ==
> Dialog.OK) {<BR>&gt;&gt;&gt; Object[] result =
> dialog.getResult();<BR>&gt;&gt;&gt; if (result.length &gt; 0 &amp;&amp;
> result[0] instanceof VHDLEntity) {<BR>&gt;&gt;&gt; VHDLEntity entity =
> (VHDLEntity) result[0];<BR>&gt;&gt;&gt;
> block.setBlkInterface(entity.getInterface());<BR>&gt;&gt;&gt; }<BR>&gt;&gt;&gt;
> }<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; return
> CommandResult.newOKCommandResult();<BR>&gt;&gt;&gt;
> }<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt;
> }<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt; <BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt;<BR >&gt;&gt;&gt;
> On Tue, 03 Apr 2007 12:22:42 +0300, Florin Banica
> wrote:<BR>&gt;&gt;&gt;<BR>&gt;&gt;&gt;&gt; I have a problem with changing the
> model behind the diagram. What I am <BR>&gt;&gt;&gt;&gt; trying to do is
> inserting/populating a reference of the model. This has <BR>&gt;&gt;&gt;&gt;
> nothing to do with the diagram, since there will be no graphical element
> <BR>&gt;&gt;&gt;&gt; corresponding to
> this.<BR>&gt;&gt;&gt;&gt;<BR>&gt;&gt;&gt;&gt; Here it is the
> code:<BR>&gt;&gt;&gt;&gt;<BR>&gt;&gt;&gt;&gt; EditingDomain editDomain =
> protocolEditPart.getEditingDomain();<BR>&gt;&gt;&gt;&gt; ResourceSet resSet =
> editDomain.getResourceSet();<BR>&gt;&gt;&gt;&gt; EList resources =
> resSet.getResources();<BR>&gt;&gt;&gt;&gt; Resource res =
> (Resource)resources.get(0);<BR>&gt;&gt;&gt;&gt; <BR>&gt;&gt;&gt;&gt; if(res !=
> null) {<BR> &gt;&gt;&gt;&gt;&nbsp;&nbsp;&nbs p;&nbsp; for(Iterator iter =
> res.getAllContents(); iter.hasNext(); )
> {<BR> &gt;&gt;&gt;&gt;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Object o =
> iter.next();<BR>&gt;&gt;&gt;&gt;<BR> &gt;&gt;&gt;&gt;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> if(o instanceof ProtocolModel)
> {<BR> &gt;&gt;&gt;&gt;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;
> ProtocolModel pm =
> (ProtocolModel)o;<BR>&gt;&gt;&gt;&gt;<BR> &gt;&gt;&gt;&gt;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;
> pm.setDataModel(mainPage.dataModel); //
> PROBLEM!<BR>&gt;&gt;&gt;&gt;<BR> &gt;&gt;&gt;&gt;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;
> break;<BR> &gt;&gt;&gt;&gt;&nbsp;&nbsp;&nbs p;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
> }<BR>&gt;&gt;&gt;&gt; }<BR>&gt;&gt;&gt;&gt;<BR>&gt;&gt;&gt;&gt; When I set the
> DataModel it gives me the error saying I have to use <BR>&gt;&gt;&gt;&gt;
> transactions... I read around some discussion on the commands subject,
> <BR>&gt;&gt;&gt;&gt; but I would need some straight/simple example (snippet) to
> see how to <BR>&gt;&gt;&gt;&gt; work with these
> commands.<BR>&gt;&gt;&gt;&gt;<BR>&gt;&gt;&gt;&gt; Any help? Please!&lt;!DOCTYPE
> HTML PUBLIC "-//W3C//DTD HTML 4.0 <BR>&gt;&gt;&gt;&gt;
> Transitional//EN"&gt;<BR>&gt;&gt;&gt;&gt;
> &lt;HTML&gt;&lt;HEAD&gt;<BR>&gt;&gt;&gt;&gt; &lt;META http-equiv=Content-Type
> content="text/html; charset=iso-8859-1"&gt;<BR>&gt;&gt;&gt;&gt; &lt;META
> content="MSHTML 6.00.6000.16414" name=GENERATOR&gt;<BR>&gt;&gt;&gt;&gt;
> &lt;STYLE&gt;&lt;/STYLE&gt;<BR>&gt;&gt;&gt;&gt;
> &lt;/HEAD&gt;<BR>&gt;&gt;&gt;&gt; &lt;BODY&gt;<BR>&gt;&gt;&gt;&gt;
> &lt;DIV&gt;&lt;FONT size=2&gt;I have a problem with changing the model behind
> the <BR>&gt;&gt;&gt;&gt; diagram.<BR>&gt;&gt;&gt;&gt; What I am trying to do is
> inserting/populating a reference of the model. <BR>&gt;&gt;&gt;&gt;
> This<BR>&gt;&gt;&gt;&gt; has nothing to do with the diagram, since there will be
> no graphical <BR>&gt;&gt;&gt;&gt; element<BR>&gt;&gt;&gt;&gt; corresponding to
> this.&lt;/FONT&gt;&lt;/DIV&gt;<BR>&gt;&gt;&gt;&gt; &lt;DIV&gt;&lt;FONT
> size=2&gt;&lt;FONT
> size=2&gt;&lt;/FONT&gt;&lt;/FONT&gt;& ;amp;nbsp;&lt;/DIV&gt; <BR>&gt;&gt;&gt;&gt;
> &lt;DIV&gt;&lt;FONT size=2&gt;Here it&amp;nbsp;is the
> code:&lt;/FONT&gt;&lt;/DIV&gt;<BR>&gt;&gt;&gt;&gt;
> &lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;<BR>&gt;&gt;&gt;&gt; &lt;DIV
> align=left&gt;&lt;FONT size=2&gt;EditingDomain editDomain =<BR>&gt;&gt;&gt;&gt;
> protocolEditPart.getEditingDomain();&lt;/FONT&gt;&am p;lt;/DIV&gt; <BR>&gt;&gt;&gt;&gt;
> &lt;DIV align=left&gt;&lt;FONT size=2&gt;ResourceSet resSet
> =<BR>&gt;&gt;&gt;&gt;
> editDomain.getResourceSet();&lt;/FONT&gt;&lt;/DI V&gt; <BR>&gt;&gt;&gt;&gt;
> &lt;DIV align=left&gt;&lt;FONT size=2&gt;EList resources =<BR>&gt;&gt;&gt;&gt;
> resSet.getResources();&lt;/FONT&gt;&lt;/DIV& gt; <BR>&gt;&gt;&gt;&gt; &lt;DIV
> align=left&gt;&lt;FONT size=2&gt;Resource res =<BR>&gt;&gt;&gt;&gt;
> (Resource)resources.get(0);&lt;/FONT&gt;&lt;/DIV &gt; <BR>&gt;&gt;&gt;&gt; &lt;DIV
> align=left&gt;&lt;FONT size=2&gt;&lt;FONT
> size=2&gt;&lt;/FONT&gt;&lt;/FONT&gt;& ;amp;nbsp;&lt;/DIV&gt; <BR>&gt;&gt;&gt;&gt;
> &lt;DIV align=left&gt;&lt;FONT size=2&gt;if(res != null)
> {&lt;/FONT&gt;&lt;/DIV&gt;<BR>&gt;&gt;&gt;&gt; &lt;DIV align=left&gt;&lt;FONT
> size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for(Iterator iter =<BR>&gt;&gt;&gt;&gt;
> res.getAllContents(); iter.hasNext(); )
> {&lt;/FONT&gt;&lt;/DIV&gt;<BR>&gt;&gt;&gt;&gt; &lt;DIV align=left&gt;&lt;FONT
> size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Object
> <BR>&gt;&gt;&gt;&gt; o =<BR>&gt;&gt;&gt;&gt;
> iter.next();&lt;/FONT&gt;&lt;/DIV&gt;<BR>&gt;&gt;&gt;&gt; &lt;DIV
> align=left&gt;&lt;FONT size=2&gt;&lt;FONT
> size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; <BR>&gt;&gt;&gt;&gt;
> &amp;nbsp;&amp;nbsp;&amp;nbsp;<BR>&gt;&gt;&gt;&gt;
> &lt;/FONT&gt;&lt;/FONT&gt;&lt;/DIV&g t; <BR>&gt;&gt;&gt;&gt; &lt;DIV
> align=left&gt;&lt;FONT size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
> &amp;nbsp;&amp;nbsp;&amp;nbsp; if(o<BR>&gt;&gt;&gt;&gt; instanceof
> ProtocolModel) {&lt;/FONT&gt;&lt;/DIV&gt;<BR>&gt;&gt;&gt;&gt; &lt;DIV
> align=left&gt;&lt;FONT size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
> &amp;nbsp;&amp;nbsp;&amp;nbsp;<BR>&gt;&gt;&gt;&gt;
> &amp;nbsp;&amp;nbsp;&amp;nbsp; ProtocolModel pm =
> (ProtocolModel)o;&lt;/FONT&gt;&lt;/DIV&gt;<BR >&gt;&gt;&gt;&gt; &lt;DIV
> align=left&gt;&lt;FONT size=2&gt;&lt;FONT
> size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; <BR>&gt;&gt;&gt;&gt;
> &amp;nbsp;&amp;nbsp;&amp;nbsp;<BR>&gt;&gt;&gt;&gt;
> &amp;nbsp;&amp;nbsp;&amp;nbsp;
> &lt;/FONT&gt;&lt;/FONT&gt;&lt;/DIV&g t; <BR>&gt;&gt;&gt;&gt; &lt;DIV
> align=left&gt;&lt;FONT size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
> &amp;nbsp;&amp;nbsp;&amp;nbsp;<BR>&gt;&gt;&gt;&gt;
> &amp;nbsp;&amp;nbsp;&amp;nbsp; pm.setDataModel(mainPage.dataModel); //
> <BR>&gt;&gt;&gt;&gt; PROBLEM!&lt;/FONT&gt;&lt;/DIV&gt;<BR>&gt;&gt;&gt;&gt;
> &lt;DIV align=left&gt;&lt;FONT size=2&gt;&lt;FONT
> size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; <BR>&gt;&gt;&gt;&gt;
> &amp;nbsp;&amp;nbsp;&amp;nbsp;<BR>&gt;&gt;&gt;&gt;
> &amp;nbsp;&amp;nbsp;&amp;nbsp;
> &lt;/FONT&gt;&lt;/FONT&gt;&lt;/DIV&g t; <BR>&gt;&gt;&gt;&gt; &lt;DIV
> align=left&gt;&lt;FONT size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
> &amp;nbsp;&amp;nbsp;&amp;nbsp;<BR>&gt;&gt;&gt;&gt;
> &amp;nbsp;&amp;nbsp;&amp;nbsp;
> break;&lt;/FONT&gt;&lt;/DIV&gt;<BR>&gt;&gt;&gt;&gt; &lt;DIV
> align=left&gt;&lt;FONT size=2&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
> &amp;nbsp;&amp;nbsp;&amp;nbsp;<BR>&gt;&gt;&gt;&gt;
> }&lt;/FONT&gt;&lt;/DIV&gt;<BR>&gt;&gt;&gt;&gt; &lt;DIV align=left&gt;&lt;FONT
> size=2&gt;}&lt;/FONT&gt;&lt;/DIV&gt;<BR >&gt;&gt;&gt;&gt; &lt;DIV
> align=left&gt;&lt;FONT size=2&gt;&lt;FONT
> size=2&gt;&lt;/FONT&gt;&lt;/FONT&gt;& ;amp;nbsp;&lt;/DIV&gt; <BR>&gt;&gt;&gt;&gt;
> &lt;DIV&gt;&lt;FONT size=2&gt;When I set the DataModel it gives me the error
> saying I <BR>&gt;&gt;&gt;&gt; have<BR>&gt;&gt;&gt;&gt; to use transactions... I
> read around some discussion on the commands <BR>&gt;&gt;&gt;&gt;
> subject,<BR>&gt;&gt;&gt;&gt; but I would need some straight/simple example
> (snippet) to see how to <BR>&gt;&gt;&gt;&gt; work with<BR>&gt;&gt;&gt;&gt; these
> commands.&lt;/FONT&gt;&lt;/DIV&gt;<BR>&gt;&gt;&gt;&gt; &lt;DIV&gt;&lt;FONT
> size=2&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DI V&gt; <BR>&gt;&gt;&gt;&gt;
> &lt;DIV&gt;&lt;FONT size=2&gt;Any help?
> Please!&lt;/FONT&gt;&lt;/DIV&gt;&lt;/BOD Y&gt;&lt;/HTML&gt; <BR>&gt;&gt;&gt;<BR>&gt;</FONT></DIV></BODY ></HTML>
Re: Problems with Command [message #116989 is a reply to message #116950] Wed, 04 April 2007 10:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: fbanica.soluta.net

The command class:

public class AssignDataModelCommand extends AbstractTransactionalCommand {
private static String label = "Assign Data Model Command";
private ProtocolModel protMod;
private DataModel dtMod;

public AssignDataModelCommand(ProtocolModel protocolModel, DataModel
dataModel, ResourceSet resSet, List res) {
super(TransactionUtil.getEditingDomain(resSet), label, res);

this.protMod = protocolModel;
this.dtMod = dataModel;
}

@Override
protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
IAdaptable info) throws ExecutionException {
protMod.setDataModel(dtMod);

return CommandResult.newOKCommandResult();
}
}


and the execution:

....
AssignDataModelCommand cmd = new AssignDataModelCommand(pm,
mainPage.dataModel, resSet, resources);

try {
cmd.execute(new NullProgressMonitor(), null);
}
catch(ExecutionException e) {
System.out.println(e.getStackTrace());
}
....


"Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
news:pan.2007.04.04.14.02.52.966419@uwaterloo.ca...
> Could you post the code?
>
> vlad
>
>
Re: Problems with Command [message #117002 is a reply to message #116989] Wed, 04 April 2007 10:19 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: fbanica.soluta.net

Could it be the "res" parameter? Although it doesn't say anything when I
pass a ResourceSet... even if it expects a List<IFile> (at least this is
what I found in debug...). See also the recent message "RCP Application
opens files and Eclipse Application opens resurces from the workspace?"



"Florin Banica" <fbanica@soluta.net> wrote in message
news:ev0bsu$sgi$1@build.eclipse.org...
> The command class:
>
> public class AssignDataModelCommand extends AbstractTransactionalCommand {
> private static String label = "Assign Data Model Command";
> private ProtocolModel protMod;
> private DataModel dtMod;
>
> public AssignDataModelCommand(ProtocolModel protocolModel, DataModel
> dataModel, ResourceSet resSet, List res) {
> super(TransactionUtil.getEditingDomain(resSet), label, res);
>
> this.protMod = protocolModel;
> this.dtMod = dataModel;
> }
>
> @Override
> protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
> IAdaptable info) throws ExecutionException {
> protMod.setDataModel(dtMod);
>
> return CommandResult.newOKCommandResult();
> }
> }
>
>
> and the execution:
>
> ...
> AssignDataModelCommand cmd = new AssignDataModelCommand(pm,
> mainPage.dataModel, resSet, resources);
>
> try {
> cmd.execute(new NullProgressMonitor(), null);
> }
> catch(ExecutionException e) {
> System.out.println(e.getStackTrace());
> }
> ...
>
>
> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
> news:pan.2007.04.04.14.02.52.966419@uwaterloo.ca...
>> Could you post the code?
>>
>> vlad
>>
>>
>
>
Re: Problems with Command [message #117027 is a reply to message #117002] Wed, 04 April 2007 10:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: fbanica.soluta.net

Sorry, I meant "How to "convert" a Resource to a IFile?" message...


"Florin Banica" <fbanica@soluta.net> wrote in message
news:ev0c5g$tb4$1@build.eclipse.org...
> Could it be the "res" parameter? Although it doesn't say anything when I
> pass a ResourceSet... even if it expects a List<IFile> (at least this is
> what I found in debug...). See also the recent message "RCP Application
> opens files and Eclipse Application opens resurces from the workspace?"
>
>
>
> "Florin Banica" <fbanica@soluta.net> wrote in message
> news:ev0bsu$sgi$1@build.eclipse.org...
>> The command class:
>>
>> public class AssignDataModelCommand extends AbstractTransactionalCommand
>> {
>> private static String label = "Assign Data Model Command";
>> private ProtocolModel protMod;
>> private DataModel dtMod;
>>
>> public AssignDataModelCommand(ProtocolModel protocolModel, DataModel
>> dataModel, ResourceSet resSet, List res) {
>> super(TransactionUtil.getEditingDomain(resSet), label, res);
>>
>> this.protMod = protocolModel;
>> this.dtMod = dataModel;
>> }
>>
>> @Override
>> protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
>> IAdaptable info) throws ExecutionException {
>> protMod.setDataModel(dtMod);
>>
>> return CommandResult.newOKCommandResult();
>> }
>> }
>>
>>
>> and the execution:
>>
>> ...
>> AssignDataModelCommand cmd = new AssignDataModelCommand(pm,
>> mainPage.dataModel, resSet, resources);
>>
>> try {
>> cmd.execute(new NullProgressMonitor(), null);
>> }
>> catch(ExecutionException e) {
>> System.out.println(e.getStackTrace());
>> }
>> ...
>>
>>
>> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
>> news:pan.2007.04.04.14.02.52.966419@uwaterloo.ca...
>>> Could you post the code?
>>>
>>> vlad
>>>
>>>
>>
>>
>
>
Re: Problems with Command [message #117039 is a reply to message #117027] Wed, 04 April 2007 10:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: vcciubot.uwaterloo.ca

In my previous post containing the example command code you can see the
helpers used to figure out the IFiles for a list of EObjects.

I think that's the problem. Are you passing null or empty list?

vlad

On Wed, 04 Apr 2007 17:34:48 +0300, Florin Banica wrote:

> Sorry, I meant "How to "convert" a Resource to a IFile?" message...
>
>
> "Florin Banica" <fbanica@soluta.net> wrote in message
> news:ev0c5g$tb4$1@build.eclipse.org...
>> Could it be the "res" parameter? Although it doesn't say anything when I
>> pass a ResourceSet... even if it expects a List<IFile> (at least this is
>> what I found in debug...). See also the recent message "RCP Application
>> opens files and Eclipse Application opens resurces from the workspace?"
>>
>>
>>
>> "Florin Banica" <fbanica@soluta.net> wrote in message
>> news:ev0bsu$sgi$1@build.eclipse.org...
>>> The command class:
>>>
>>> public class AssignDataModelCommand extends AbstractTransactionalCommand
>>> {
>>> private static String label = "Assign Data Model Command";
>>> private ProtocolModel protMod;
>>> private DataModel dtMod;
>>>
>>> public AssignDataModelCommand(ProtocolModel protocolModel, DataModel
>>> dataModel, ResourceSet resSet, List res) {
>>> super(TransactionUtil.getEditingDomain(resSet), label, res);
>>>
>>> this.protMod = protocolModel;
>>> this.dtMod = dataModel;
>>> }
>>>
>>> @Override
>>> protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
>>> IAdaptable info) throws ExecutionException {
>>> protMod.setDataModel(dtMod);
>>>
>>> return CommandResult.newOKCommandResult();
>>> }
>>> }
>>>
>>>
>>> and the execution:
>>>
>>> ...
>>> AssignDataModelCommand cmd = new AssignDataModelCommand(pm,
>>> mainPage.dataModel, resSet, resources);
>>>
>>> try {
>>> cmd.execute(new NullProgressMonitor(), null);
>>> }
>>> catch(ExecutionException e) {
>>> System.out.println(e.getStackTrace());
>>> }
>>> ...
>>>
>>>
>>> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
>>> news:pan.2007.04.04.14.02.52.966419@uwaterloo.ca...
>>>> Could you post the code?
>>>>
>>>> vlad
>>>>
>>>>
>>>
>>>
>>
>>
Re: Problems with Command [message #117051 is a reply to message #117027] Wed, 04 April 2007 10:43 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: vcciubot.uwaterloo.ca

This is it: AbstractTransactionalCommand.getWorkspaceFiles(List/EObject)

vlad

On Wed, 04 Apr 2007 17:34:48 +0300, Florin Banica wrote:

> Sorry, I meant "How to "convert" a Resource to a IFile?" message...
>
>
> "Florin Banica" <fbanica@soluta.net> wrote in message
> news:ev0c5g$tb4$1@build.eclipse.org...
>> Could it be the "res" parameter? Although it doesn't say anything when I
>> pass a ResourceSet... even if it expects a List<IFile> (at least this is
>> what I found in debug...). See also the recent message "RCP Application
>> opens files and Eclipse Application opens resurces from the workspace?"
>>
>>
>>
>> "Florin Banica" <fbanica@soluta.net> wrote in message
>> news:ev0bsu$sgi$1@build.eclipse.org...
>>> The command class:
>>>
>>> public class AssignDataModelCommand extends AbstractTransactionalCommand
>>> {
>>> private static String label = "Assign Data Model Command";
>>> private ProtocolModel protMod;
>>> private DataModel dtMod;
>>>
>>> public AssignDataModelCommand(ProtocolModel protocolModel, DataModel
>>> dataModel, ResourceSet resSet, List res) {
>>> super(TransactionUtil.getEditingDomain(resSet), label, res);
>>>
>>> this.protMod = protocolModel;
>>> this.dtMod = dataModel;
>>> }
>>>
>>> @Override
>>> protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
>>> IAdaptable info) throws ExecutionException {
>>> protMod.setDataModel(dtMod);
>>>
>>> return CommandResult.newOKCommandResult();
>>> }
>>> }
>>>
>>>
>>> and the execution:
>>>
>>> ...
>>> AssignDataModelCommand cmd = new AssignDataModelCommand(pm,
>>> mainPage.dataModel, resSet, resources);
>>>
>>> try {
>>> cmd.execute(new NullProgressMonitor(), null);
>>> }
>>> catch(ExecutionException e) {
>>> System.out.println(e.getStackTrace());
>>> }
>>> ...
>>>
>>>
>>> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
>>> news:pan.2007.04.04.14.02.52.966419@uwaterloo.ca...
>>>> Could you post the code?
>>>>
>>>> vlad
>>>>
>>>>
>>>
>>>
>>
>>
Re: Problems with Command [message #117097 is a reply to message #117051] Wed, 04 April 2007 11:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: fbanica.soluta.net

This is the code of the method:

protected static List getWorkspaceFiles(List eObjects) {
List result = new ArrayList();

for (Iterator i = eObjects.iterator(); i.hasNext();) {
Object next = i.next();

if (next instanceof EObject) {
Resource resource = ((EObject) next).eResource();

if (resource != null) {
IFile file = WorkspaceSynchronizer.getFile(resource);

if (file != null) {
result.add(file);
}
}
}
}

return result;
}

As you can see, it checks "next" if it's instanceof EObject. My "affected"
(to be saved) resource is a GMFResource, which seems to be "NOT instanceof
EObject"...




"Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
news:pan.2007.04.04.14.43.02.606731@uwaterloo.ca...
> This is it: AbstractTransactionalCommand.getWorkspaceFiles(List/EObject)
>
> vlad
>
> On Wed, 04 Apr 2007 17:34:48 +0300, Florin Banica wrote:
>
>> Sorry, I meant "How to "convert" a Resource to a IFile?" message...
>>
>>
>> "Florin Banica" <fbanica@soluta.net> wrote in message
>> news:ev0c5g$tb4$1@build.eclipse.org...
>>> Could it be the "res" parameter? Although it doesn't say anything when I
>>> pass a ResourceSet... even if it expects a List<IFile> (at least this is
>>> what I found in debug...). See also the recent message "RCP Application
>>> opens files and Eclipse Application opens resurces from the workspace?"
>>>
>>>
>>>
>>> "Florin Banica" <fbanica@soluta.net> wrote in message
>>> news:ev0bsu$sgi$1@build.eclipse.org...
>>>> The command class:
>>>>
>>>> public class AssignDataModelCommand extends
>>>> AbstractTransactionalCommand
>>>> {
>>>> private static String label = "Assign Data Model Command";
>>>> private ProtocolModel protMod;
>>>> private DataModel dtMod;
>>>>
>>>> public AssignDataModelCommand(ProtocolModel protocolModel, DataModel
>>>> dataModel, ResourceSet resSet, List res) {
>>>> super(TransactionUtil.getEditingDomain(resSet), label, res);
>>>>
>>>> this.protMod = protocolModel;
>>>> this.dtMod = dataModel;
>>>> }
>>>>
>>>> @Override
>>>> protected CommandResult doExecuteWithResult(IProgressMonitor
>>>> monitor,
>>>> IAdaptable info) throws ExecutionException {
>>>> protMod.setDataModel(dtMod);
>>>>
>>>> return CommandResult.newOKCommandResult();
>>>> }
>>>> }
>>>>
>>>>
>>>> and the execution:
>>>>
>>>> ...
>>>> AssignDataModelCommand cmd = new AssignDataModelCommand(pm,
>>>> mainPage.dataModel, resSet, resources);
>>>>
>>>> try {
>>>> cmd.execute(new NullProgressMonitor(), null);
>>>> }
>>>> catch(ExecutionException e) {
>>>> System.out.println(e.getStackTrace());
>>>> }
>>>> ...
>>>>
>>>>
>>>> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
>>>> news:pan.2007.04.04.14.02.52.966419@uwaterloo.ca...
>>>>> Could you post the code?
>>>>>
>>>>> vlad
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>
Re: Problems with Command [message #117110 is a reply to message #117097] Wed, 04 April 2007 11:08 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: fbanica.soluta.net

In case you wonder, I have both the diagram and the model saved in the same
file. That's why I have a GMFResource...


"Florin Banica" <fbanica@soluta.net> wrote in message
news:ev0eqr$59v$1@build.eclipse.org...
> This is the code of the method:
>
> protected static List getWorkspaceFiles(List eObjects) {
> List result = new ArrayList();
>
> for (Iterator i = eObjects.iterator(); i.hasNext();) {
> Object next = i.next();
>
> if (next instanceof EObject) {
> Resource resource = ((EObject) next).eResource();
>
> if (resource != null) {
> IFile file = WorkspaceSynchronizer.getFile(resource);
>
> if (file != null) {
> result.add(file);
> }
> }
> }
> }
>
> return result;
> }
>
> As you can see, it checks "next" if it's instanceof EObject. My "affected"
> (to be saved) resource is a GMFResource, which seems to be "NOT instanceof
> EObject"...
>
>
>
>
> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
> news:pan.2007.04.04.14.43.02.606731@uwaterloo.ca...
>> This is it: AbstractTransactionalCommand.getWorkspaceFiles(List/EObject)
>>
>> vlad
>>
>> On Wed, 04 Apr 2007 17:34:48 +0300, Florin Banica wrote:
>>
>>> Sorry, I meant "How to "convert" a Resource to a IFile?" message...
>>>
>>>
>>> "Florin Banica" <fbanica@soluta.net> wrote in message
>>> news:ev0c5g$tb4$1@build.eclipse.org...
>>>> Could it be the "res" parameter? Although it doesn't say anything when
>>>> I
>>>> pass a ResourceSet... even if it expects a List<IFile> (at least this
>>>> is
>>>> what I found in debug...). See also the recent message "RCP Application
>>>> opens files and Eclipse Application opens resurces from the workspace?"
>>>>
>>>>
>>>>
>>>> "Florin Banica" <fbanica@soluta.net> wrote in message
>>>> news:ev0bsu$sgi$1@build.eclipse.org...
>>>>> The command class:
>>>>>
>>>>> public class AssignDataModelCommand extends
>>>>> AbstractTransactionalCommand
>>>>> {
>>>>> private static String label = "Assign Data Model Command";
>>>>> private ProtocolModel protMod;
>>>>> private DataModel dtMod;
>>>>>
>>>>> public AssignDataModelCommand(ProtocolModel protocolModel,
>>>>> DataModel
>>>>> dataModel, ResourceSet resSet, List res) {
>>>>> super(TransactionUtil.getEditingDomain(resSet), label, res);
>>>>>
>>>>> this.protMod = protocolModel;
>>>>> this.dtMod = dataModel;
>>>>> }
>>>>>
>>>>> @Override
>>>>> protected CommandResult doExecuteWithResult(IProgressMonitor
>>>>> monitor,
>>>>> IAdaptable info) throws ExecutionException {
>>>>> protMod.setDataModel(dtMod);
>>>>>
>>>>> return CommandResult.newOKCommandResult();
>>>>> }
>>>>> }
>>>>>
>>>>>
>>>>> and the execution:
>>>>>
>>>>> ...
>>>>> AssignDataModelCommand cmd = new AssignDataModelCommand(pm,
>>>>> mainPage.dataModel, resSet, resources);
>>>>>
>>>>> try {
>>>>> cmd.execute(new NullProgressMonitor(), null);
>>>>> }
>>>>> catch(ExecutionException e) {
>>>>> System.out.println(e.getStackTrace());
>>>>> }
>>>>> ...
>>>>>
>>>>>
>>>>> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
>>>>> news:pan.2007.04.04.14.02.52.966419@uwaterloo.ca...
>>>>>> Could you post the code?
>>>>>>
>>>>>> vlad
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>
>
>
Re: Problems with Command [message #117122 is a reply to message #117110] Wed, 04 April 2007 11:25 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: vcciubot.uwaterloo.ca

On Wed, 04 Apr 2007 18:08:02 +0300, Florin Banica wrote:

> In case you wonder, I have both the diagram and the model saved in the same
> file. That's why I have a GMFResource...
Don't pass the resource, pass one of the EObjects you're modifying.


>

>
> "Florin Banica" <fbanica@soluta.net> wrote in message
> news:ev0eqr$59v$1@build.eclipse.org...
>> This is the code of the method:
>>
>> protected static List getWorkspaceFiles(List eObjects) {
>> List result = new ArrayList();
>>
>> for (Iterator i = eObjects.iterator(); i.hasNext();) {
>> Object next = i.next();
>>
>> if (next instanceof EObject) {
>> Resource resource = ((EObject) next).eResource();
>>
>> if (resource != null) {
>> IFile file = WorkspaceSynchronizer.getFile(resource);
>>
>> if (file != null) {
>> result.add(file);
>> }
>> }
>> }
>> }
>>
>> return result;
>> }
>>
>> As you can see, it checks "next" if it's instanceof EObject. My "affected"
>> (to be saved) resource is a GMFResource, which seems to be "NOT instanceof
>> EObject"...
>>
>>
>>
>>
>> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
>> news:pan.2007.04.04.14.43.02.606731@uwaterloo.ca...
>>> This is it: AbstractTransactionalCommand.getWorkspaceFiles(List/EObject)
>>>
>>> vlad
>>>
>>> On Wed, 04 Apr 2007 17:34:48 +0300, Florin Banica wrote:
>>>
>>>> Sorry, I meant "How to "convert" a Resource to a IFile?" message...
>>>>
>>>>
>>>> "Florin Banica" <fbanica@soluta.net> wrote in message
>>>> news:ev0c5g$tb4$1@build.eclipse.org...
>>>>> Could it be the "res" parameter? Although it doesn't say anything when
>>>>> I
>>>>> pass a ResourceSet... even if it expects a List<IFile> (at least this
>>>>> is
>>>>> what I found in debug...). See also the recent message "RCP Application
>>>>> opens files and Eclipse Application opens resurces from the workspace?"
>>>>>
>>>>>
>>>>>
>>>>> "Florin Banica" <fbanica@soluta.net> wrote in message
>>>>> news:ev0bsu$sgi$1@build.eclipse.org...
>>>>>> The command class:
>>>>>>
>>>>>> public class AssignDataModelCommand extends
>>>>>> AbstractTransactionalCommand
>>>>>> {
>>>>>> private static String label = "Assign Data Model Command";
>>>>>> private ProtocolModel protMod;
>>>>>> private DataModel dtMod;
>>>>>>
>>>>>> public AssignDataModelCommand(ProtocolModel protocolModel,
>>>>>> DataModel
>>>>>> dataModel, ResourceSet resSet, List res) {
>>>>>> super(TransactionUtil.getEditingDomain(resSet), label, res);
>>>>>>
>>>>>> this.protMod = protocolModel;
>>>>>> this.dtMod = dataModel;
>>>>>> }
>>>>>>
>>>>>> @Override
>>>>>> protected CommandResult doExecuteWithResult(IProgressMonitor
>>>>>> monitor,
>>>>>> IAdaptable info) throws ExecutionException {
>>>>>> protMod.setDataModel(dtMod);
>>>>>>
>>>>>> return CommandResult.newOKCommandResult();
>>>>>> }
>>>>>> }
>>>>>>
>>>>>>
>>>>>> and the execution:
>>>>>>
>>>>>> ...
>>>>>> AssignDataModelCommand cmd = new AssignDataModelCommand(pm,
>>>>>> mainPage.dataModel, resSet, resources);
>>>>>>
>>>>>> try {
>>>>>> cmd.execute(new NullProgressMonitor(), null);
>>>>>> }
>>>>>> catch(ExecutionException e) {
>>>>>> System.out.println(e.getStackTrace());
>>>>>> }
>>>>>> ...
>>>>>>
>>>>>>
>>>>>> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
>>>>>> news:pan.2007.04.04.14.02.52.966419@uwaterloo.ca...
>>>>>>> Could you post the code?
>>>>>>>
>>>>>>> vlad
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>
>>
>>
Re: Problems with Command [message #117147 is a reply to message #117122] Wed, 04 April 2007 12:03 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: fbanica.soluta.net

Pretty much usless :-(

The method:

protected static List getWorkspaceFiles(EObject eObject) {
List result = new ArrayList();

if (eObject != null) {
Resource resource = eObject.eResource();

if (resource != null) {
IFile file = WorkspaceSynchronizer.getFile(resource);

if (file != null) {
result.add(file);
}
}
}

return result;
}

at the line Resource resource = eObject.eResource(); turns my EObject back
into a Resource (GMFResource). Then, the line IFile file =
WorkspaceSynchronizer.getFile(resource); gives no file (null), so nothing is
modified in the end.

So we're back at the starting point... :-(



"Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
news:pan.2007.04.04.15.25.35.323187@uwaterloo.ca...
> On Wed, 04 Apr 2007 18:08:02 +0300, Florin Banica wrote:
>
>> In case you wonder, I have both the diagram and the model saved in the
>> same
>> file. That's why I have a GMFResource...
> Don't pass the resource, pass one of the EObjects you're modifying.
>
>
>>
>
>>
>> "Florin Banica" <fbanica@soluta.net> wrote in message
>> news:ev0eqr$59v$1@build.eclipse.org...
>>> This is the code of the method:
>>>
>>> protected static List getWorkspaceFiles(List eObjects) {
>>> List result = new ArrayList();
>>>
>>> for (Iterator i = eObjects.iterator(); i.hasNext();) {
>>> Object next = i.next();
>>>
>>> if (next instanceof EObject) {
>>> Resource resource = ((EObject) next).eResource();
>>>
>>> if (resource != null) {
>>> IFile file = WorkspaceSynchronizer.getFile(resource);
>>>
>>> if (file != null) {
>>> result.add(file);
>>> }
>>> }
>>> }
>>> }
>>>
>>> return result;
>>> }
>>>
>>> As you can see, it checks "next" if it's instanceof EObject. My
>>> "affected"
>>> (to be saved) resource is a GMFResource, which seems to be "NOT
>>> instanceof
>>> EObject"...
>>>
>>>
>>>
>>>
>>> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
>>> news:pan.2007.04.04.14.43.02.606731@uwaterloo.ca...
>>>> This is it:
>>>> AbstractTransactionalCommand.getWorkspaceFiles(List/EObject)
>>>>
>>>> vlad
>>>>
>>>> On Wed, 04 Apr 2007 17:34:48 +0300, Florin Banica wrote:
>>>>
>>>>> Sorry, I meant "How to "convert" a Resource to a IFile?" message...
>>>>>
>>>>>
>>>>> "Florin Banica" <fbanica@soluta.net> wrote in message
>>>>> news:ev0c5g$tb4$1@build.eclipse.org...
>>>>>> Could it be the "res" parameter? Although it doesn't say anything
>>>>>> when
>>>>>> I
>>>>>> pass a ResourceSet... even if it expects a List<IFile> (at least this
>>>>>> is
>>>>>> what I found in debug...). See also the recent message "RCP
>>>>>> Application
>>>>>> opens files and Eclipse Application opens resurces from the
>>>>>> workspace?"
>>>>>>
>>>>>>
>>>>>>
>>>>>> "Florin Banica" <fbanica@soluta.net> wrote in message
>>>>>> news:ev0bsu$sgi$1@build.eclipse.org...
>>>>>>> The command class:
>>>>>>>
>>>>>>> public class AssignDataModelCommand extends
>>>>>>> AbstractTransactionalCommand
>>>>>>> {
>>>>>>> private static String label = "Assign Data Model Command";
>>>>>>> private ProtocolModel protMod;
>>>>>>> private DataModel dtMod;
>>>>>>>
>>>>>>> public AssignDataModelCommand(ProtocolModel protocolModel,
>>>>>>> DataModel
>>>>>>> dataModel, ResourceSet resSet, List res) {
>>>>>>> super(TransactionUtil.getEditingDomain(resSet), label, res);
>>>>>>>
>>>>>>> this.protMod = protocolModel;
>>>>>>> this.dtMod = dataModel;
>>>>>>> }
>>>>>>>
>>>>>>> @Override
>>>>>>> protected CommandResult doExecuteWithResult(IProgressMonitor
>>>>>>> monitor,
>>>>>>> IAdaptable info) throws ExecutionException {
>>>>>>> protMod.setDataModel(dtMod);
>>>>>>>
>>>>>>> return CommandResult.newOKCommandResult();
>>>>>>> }
>>>>>>> }
>>>>>>>
>>>>>>>
>>>>>>> and the execution:
>>>>>>>
>>>>>>> ...
>>>>>>> AssignDataModelCommand cmd = new AssignDataModelCommand(pm,
>>>>>>> mainPage.dataModel, resSet, resources);
>>>>>>>
>>>>>>> try {
>>>>>>> cmd.execute(new NullProgressMonitor(), null);
>>>>>>> }
>>>>>>> catch(ExecutionException e) {
>>>>>>> System.out.println(e.getStackTrace());
>>>>>>> }
>>>>>>> ...
>>>>>>>
>>>>>>>
>>>>>>> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
>>>>>>> news:pan.2007.04.04.14.02.52.966419@uwaterloo.ca...
>>>>>>>> Could you post the code?
>>>>>>>>
>>>>>>>> vlad
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>
>>>
>>>
>
Re: Problems with Command [message #117158 is a reply to message #117147] Wed, 04 April 2007 12:10 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: fbanica.soluta.net

I tried also to pass a List:

......
IFile affectedFile = ResourcesPlugin.getWorkspace().getRoot().getFile(new
Path(res.getURI().path()));
ArrayList<IFile> affectedFiles = new ArrayList<IFile>();
affectedFiles.add(affectedFile);
......
AssignDataModelCommand cmd = new AssignDataModelCommand(***, ***, ***,
affectedFiles);


in order not to call getWorkspaceFile() anymore. The same result. Nothing is
modified/saved :-(



"Florin Banica" <fbanica@soluta.net> wrote in message
news:ev0i90$883$1@build.eclipse.org...
> Pretty much usless :-(
>
> The method:
>
> protected static List getWorkspaceFiles(EObject eObject) {
> List result = new ArrayList();
>
> if (eObject != null) {
> Resource resource = eObject.eResource();
>
> if (resource != null) {
> IFile file = WorkspaceSynchronizer.getFile(resource);
>
> if (file != null) {
> result.add(file);
> }
> }
> }
>
> return result;
> }
>
> at the line Resource resource = eObject.eResource(); turns my EObject back
> into a Resource (GMFResource). Then, the line IFile file =
> WorkspaceSynchronizer.getFile(resource); gives no file (null), so nothing
> is modified in the end.
>
> So we're back at the starting point... :-(
>
>
>
> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
> news:pan.2007.04.04.15.25.35.323187@uwaterloo.ca...
>> On Wed, 04 Apr 2007 18:08:02 +0300, Florin Banica wrote:
>>
>>> In case you wonder, I have both the diagram and the model saved in the
>>> same
>>> file. That's why I have a GMFResource...
>> Don't pass the resource, pass one of the EObjects you're modifying.
>>
>>
>>>
>>
>>>
>>> "Florin Banica" <fbanica@soluta.net> wrote in message
>>> news:ev0eqr$59v$1@build.eclipse.org...
>>>> This is the code of the method:
>>>>
>>>> protected static List getWorkspaceFiles(List eObjects) {
>>>> List result = new ArrayList();
>>>>
>>>> for (Iterator i = eObjects.iterator(); i.hasNext();) {
>>>> Object next = i.next();
>>>>
>>>> if (next instanceof EObject) {
>>>> Resource resource = ((EObject) next).eResource();
>>>>
>>>> if (resource != null) {
>>>> IFile file = WorkspaceSynchronizer.getFile(resource);
>>>>
>>>> if (file != null) {
>>>> result.add(file);
>>>> }
>>>> }
>>>> }
>>>> }
>>>>
>>>> return result;
>>>> }
>>>>
>>>> As you can see, it checks "next" if it's instanceof EObject. My
>>>> "affected"
>>>> (to be saved) resource is a GMFResource, which seems to be "NOT
>>>> instanceof
>>>> EObject"...
>>>>
>>>>
>>>>
>>>>
>>>> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
>>>> news:pan.2007.04.04.14.43.02.606731@uwaterloo.ca...
>>>>> This is it:
>>>>> AbstractTransactionalCommand.getWorkspaceFiles(List/EObject)
>>>>>
>>>>> vlad
>>>>>
>>>>> On Wed, 04 Apr 2007 17:34:48 +0300, Florin Banica wrote:
>>>>>
>>>>>> Sorry, I meant "How to "convert" a Resource to a IFile?" message...
>>>>>>
>>>>>>
>>>>>> "Florin Banica" <fbanica@soluta.net> wrote in message
>>>>>> news:ev0c5g$tb4$1@build.eclipse.org...
>>>>>>> Could it be the "res" parameter? Although it doesn't say anything
>>>>>>> when
>>>>>>> I
>>>>>>> pass a ResourceSet... even if it expects a List<IFile> (at least
>>>>>>> this
>>>>>>> is
>>>>>>> what I found in debug...). See also the recent message "RCP
>>>>>>> Application
>>>>>>> opens files and Eclipse Application opens resurces from the
>>>>>>> workspace?"
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> "Florin Banica" <fbanica@soluta.net> wrote in message
>>>>>>> news:ev0bsu$sgi$1@build.eclipse.org...
>>>>>>>> The command class:
>>>>>>>>
>>>>>>>> public class AssignDataModelCommand extends
>>>>>>>> AbstractTransactionalCommand
>>>>>>>> {
>>>>>>>> private static String label = "Assign Data Model Command";
>>>>>>>> private ProtocolModel protMod;
>>>>>>>> private DataModel dtMod;
>>>>>>>>
>>>>>>>> public AssignDataModelCommand(ProtocolModel protocolModel,
>>>>>>>> DataModel
>>>>>>>> dataModel, ResourceSet resSet, List res) {
>>>>>>>> super(TransactionUtil.getEditingDomain(resSet), label, res);
>>>>>>>>
>>>>>>>> this.protMod = protocolModel;
>>>>>>>> this.dtMod = dataModel;
>>>>>>>> }
>>>>>>>>
>>>>>>>> @Override
>>>>>>>> protected CommandResult doExecuteWithResult(IProgressMonitor
>>>>>>>> monitor,
>>>>>>>> IAdaptable info) throws ExecutionException {
>>>>>>>> protMod.setDataModel(dtMod);
>>>>>>>>
>>>>>>>> return CommandResult.newOKCommandResult();
>>>>>>>> }
>>>>>>>> }
>>>>>>>>
>>>>>>>>
>>>>>>>> and the execution:
>>>>>>>>
>>>>>>>> ...
>>>>>>>> AssignDataModelCommand cmd = new AssignDataModelCommand(pm,
>>>>>>>> mainPage.dataModel, resSet, resources);
>>>>>>>>
>>>>>>>> try {
>>>>>>>> cmd.execute(new NullProgressMonitor(), null);
>>>>>>>> }
>>>>>>>> catch(ExecutionException e) {
>>>>>>>> System.out.println(e.getStackTrace());
>>>>>>>> }
>>>>>>>> ...
>>>>>>>>
>>>>>>>>
>>>>>>>> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
>>>>>>>> news:pan.2007.04.04.14.02.52.966419@uwaterloo.ca...
>>>>>>>>> Could you post the code?
>>>>>>>>>
>>>>>>>>> vlad
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>
>>>>
>>>>
>>
>
>
Re: Problems with Command [message #117171 is a reply to message #117147] Wed, 04 April 2007 12:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: vcciubot.uwaterloo.ca

Can you describe your scenario so I can give a more informed opinion?

Do you have a bootstrapped diagram to start with? If not, bootstrapping
code is contained in the generated XXXDiagramEditorUtil.

Another case I can think of is when you have a model and want to attach to
it some other model elements created outside the gmf framework. For
instance, if you create model elements through the
XXXFactory.eINSTANCE.createXXXX methods, you can attach them to the gmf
model in a command that calls the corresponding set reference method.

vlad




On Wed, 04 Apr 2007 19:03:08 +0300, Florin Banica wrote:

> Pretty much usless :-(
>
> The method:
>
> protected static List getWorkspaceFiles(EObject eObject) {
> List result = new ArrayList();
>
> if (eObject != null) {
> Resource resource = eObject.eResource();
>
> if (resource != null) {
> IFile file = WorkspaceSynchronizer.getFile(resource);
>
> if (file != null) {
> result.add(file);
> }
> }
> }
>
> return result;
> }
>
> at the line Resource resource = eObject.eResource(); turns my EObject back
> into a Resource (GMFResource). Then, the line IFile file =
> WorkspaceSynchronizer.getFile(resource); gives no file (null), so nothing is
> modified in the end.
>
> So we're back at the starting point... :-(
>
>
>
> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
> news:pan.2007.04.04.15.25.35.323187@uwaterloo.ca...
>> On Wed, 04 Apr 2007 18:08:02 +0300, Florin Banica wrote:
>>
>>> In case you wonder, I have both the diagram and the model saved in the
>>> same
>>> file. That's why I have a GMFResource...
>> Don't pass the resource, pass one of the EObjects you're modifying.
>>
>>
>>>
>>
>>>
>>> "Florin Banica" <fbanica@soluta.net> wrote in message
>>> news:ev0eqr$59v$1@build.eclipse.org...
>>>> This is the code of the method:
>>>>
>>>> protected static List getWorkspaceFiles(List eObjects) {
>>>> List result = new ArrayList();
>>>>
>>>> for (Iterator i = eObjects.iterator(); i.hasNext();) {
>>>> Object next = i.next();
>>>>
>>>> if (next instanceof EObject) {
>>>> Resource resource = ((EObject) next).eResource();
>>>>
>>>> if (resource != null) {
>>>> IFile file = WorkspaceSynchronizer.getFile(resource);
>>>>
>>>> if (file != null) {
>>>> result.add(file);
>>>> }
>>>> }
>>>> }
>>>> }
>>>>
>>>> return result;
>>>> }
>>>>
>>>> As you can see, it checks "next" if it's instanceof EObject. My
>>>> "affected"
>>>> (to be saved) resource is a GMFResource, which seems to be "NOT
>>>> instanceof
>>>> EObject"...
>>>>
>>>>
>>>>
>>>>
>>>> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
>>>> news:pan.2007.04.04.14.43.02.606731@uwaterloo.ca...
>>>>> This is it:
>>>>> AbstractTransactionalCommand.getWorkspaceFiles(List/EObject)
>>>>>
>>>>> vlad
>>>>>
>>>>> On Wed, 04 Apr 2007 17:34:48 +0300, Florin Banica wrote:
>>>>>
>>>>>> Sorry, I meant "How to "convert" a Resource to a IFile?" message...
>>>>>>
>>>>>>
>>>>>> "Florin Banica" <fbanica@soluta.net> wrote in message
>>>>>> news:ev0c5g$tb4$1@build.eclipse.org...
>>>>>>> Could it be the "res" parameter? Although it doesn't say anything
>>>>>>> when
>>>>>>> I
>>>>>>> pass a ResourceSet... even if it expects a List<IFile> (at least this
>>>>>>> is
>>>>>>> what I found in debug...). See also the recent message "RCP
>>>>>>> Application
>>>>>>> opens files and Eclipse Application opens resurces from the
>>>>>>> workspace?"
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> "Florin Banica" <fbanica@soluta.net> wrote in message
>>>>>>> news:ev0bsu$sgi$1@build.eclipse.org...
>>>>>>>> The command class:
>>>>>>>>
>>>>>>>> public class AssignDataModelCommand extends
>>>>>>>> AbstractTransactionalCommand
>>>>>>>> {
>>>>>>>> private static String label = "Assign Data Model Command";
>>>>>>>> private ProtocolModel protMod;
>>>>>>>> private DataModel dtMod;
>>>>>>>>
>>>>>>>> public AssignDataModelCommand(ProtocolModel protocolModel,
>>>>>>>> DataModel
>>>>>>>> dataModel, ResourceSet resSet, List res) {
>>>>>>>> super(TransactionUtil.getEditingDomain(resSet), label, res);
>>>>>>>>
>>>>>>>> this.protMod = protocolModel;
>>>>>>>> this.dtMod = dataModel;
>>>>>>>> }
>>>>>>>>
>>>>>>>> @Override
>>>>>>>> protected CommandResult doExecuteWithResult(IProgressMonitor
>>>>>>>> monitor,
>>>>>>>> IAdaptable info) throws ExecutionException {
>>>>>>>> protMod.setDataModel(dtMod);
>>>>>>>>
>>>>>>>> return CommandResult.newOKCommandResult();
>>>>>>>> }
>>>>>>>> }
>>>>>>>>
>>>>>>>>
>>>>>>>> and the execution:
>>>>>>>>
>>>>>>>> ...
>>>>>>>> AssignDataModelCommand cmd = new AssignDataModelCommand(pm,
>>>>>>>> mainPage.dataModel, resSet, resources);
>>>>>>>>
>>>>>>>> try {
>>>>>>>> cmd.execute(new NullProgressMonitor(), null);
>>>>>>>> }
>>>>>>>> catch(ExecutionException e) {
>>>>>>>> System.out.println(e.getStackTrace());
>>>>>>>> }
>>>>>>>> ...
>>>>>>>>
>>>>>>>>
>>>>>>>> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
>>>>>>>> news:pan.2007.04.04.14.02.52.966419@uwaterloo.ca...
>>>>>>>>> Could you post the code?
>>>>>>>>>
>>>>>>>>> vlad
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>
>>>>
>>>>
>>
Re: Problems with Command [message #117184 is a reply to message #117171] Wed, 04 April 2007 12:28 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: fbanica.soluta.net

So, I have a "ProtocolModel" and a "DataModel". I create a DataModel in a
GMF editor and the ProtocolModel in another one. (They both come from the
same meta-model)

What I am trying to do is "importing" the DataModel into the ProtocolModel.
The last one has a reference pointing the DataModel, so, from this point of
view there are no problems. If I make it "by hand" (meaning copying the text
in the XMI file) it's OK. The ProtocolModel editor has no problem with the
modified file.

The problem appears when I try to do it in the code. I made an Action
(IObjectActionDelegate) and inside this I made a wizard where the user can
choose the DataModel. From that I read the DataModel (dtMod) and then I want
to set the reference in the ProtocolModel:protMod.setDataModel(dtMod); This
is put in the doExecuteWithResult method of the AbstractTransactionalCommand
class, while the command and it's execution are in the performFinish()
method of the wizard.

Did you get the picture? Should I detail?

Thanks for spending a lot time with my problem...



"Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
news:pan.2007.04.04.16.17.48.447575@uwaterloo.ca...
> Can you describe your scenario so I can give a more informed opinion?
>
> Do you have a bootstrapped diagram to start with? If not, bootstrapping
> code is contained in the generated XXXDiagramEditorUtil.
>
> Another case I can think of is when you have a model and want to attach to
> it some other model elements created outside the gmf framework. For
> instance, if you create model elements through the
> XXXFactory.eINSTANCE.createXXXX methods, you can attach them to the gmf
> model in a command that calls the corresponding set reference method.
>
> vlad
>
>
>
>
> On Wed, 04 Apr 2007 19:03:08 +0300, Florin Banica wrote:
>
>> Pretty much usless :-(
>>
>> The method:
>>
>> protected static List getWorkspaceFiles(EObject eObject) {
>> List result = new ArrayList();
>>
>> if (eObject != null) {
>> Resource resource = eObject.eResource();
>>
>> if (resource != null) {
>> IFile file = WorkspaceSynchronizer.getFile(resource);
>>
>> if (file != null) {
>> result.add(file);
>> }
>> }
>> }
>>
>> return result;
>> }
>>
>> at the line Resource resource = eObject.eResource(); turns my EObject
>> back
>> into a Resource (GMFResource). Then, the line IFile file =
>> WorkspaceSynchronizer.getFile(resource); gives no file (null), so nothing
>> is
>> modified in the end.
>>
>> So we're back at the starting point... :-(
>>
>>
>>
>> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
>> news:pan.2007.04.04.15.25.35.323187@uwaterloo.ca...
>>> On Wed, 04 Apr 2007 18:08:02 +0300, Florin Banica wrote:
>>>
>>>> In case you wonder, I have both the diagram and the model saved in the
>>>> same
>>>> file. That's why I have a GMFResource...
>>> Don't pass the resource, pass one of the EObjects you're modifying.
>>>
>>>
>>>>
>>>
>>>>
>>>> "Florin Banica" <fbanica@soluta.net> wrote in message
>>>> news:ev0eqr$59v$1@build.eclipse.org...
>>>>> This is the code of the method:
>>>>>
>>>>> protected static List getWorkspaceFiles(List eObjects) {
>>>>> List result = new ArrayList();
>>>>>
>>>>> for (Iterator i = eObjects.iterator(); i.hasNext();) {
>>>>> Object next = i.next();
>>>>>
>>>>> if (next instanceof EObject) {
>>>>> Resource resource = ((EObject) next).eResource();
>>>>>
>>>>> if (resource != null) {
>>>>> IFile file = WorkspaceSynchronizer.getFile(resource);
>>>>>
>>>>> if (file != null) {
>>>>> result.add(file);
>>>>> }
>>>>> }
>>>>> }
>>>>> }
>>>>>
>>>>> return result;
>>>>> }
>>>>>
>>>>> As you can see, it checks "next" if it's instanceof EObject. My
>>>>> "affected"
>>>>> (to be saved) resource is a GMFResource, which seems to be "NOT
>>>>> instanceof
>>>>> EObject"...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
>>>>> news:pan.2007.04.04.14.43.02.606731@uwaterloo.ca...
>>>>>> This is it:
>>>>>> AbstractTransactionalCommand.getWorkspaceFiles(List/EObject)
>>>>>>
>>>>>> vlad
>>>>>>
>>>>>> On Wed, 04 Apr 2007 17:34:48 +0300, Florin Banica wrote:
>>>>>>
>>>>>>> Sorry, I meant "How to "convert" a Resource to a IFile?" message...
>>>>>>>
>>>>>>>
>>>>>>> "Florin Banica" <fbanica@soluta.net> wrote in message
>>>>>>> news:ev0c5g$tb4$1@build.eclipse.org...
>>>>>>>> Could it be the "res" parameter? Although it doesn't say anything
>>>>>>>> when
>>>>>>>> I
>>>>>>>> pass a ResourceSet... even if it expects a List<IFile> (at least
>>>>>>>> this
>>>>>>>> is
>>>>>>>> what I found in debug...). See also the recent message "RCP
>>>>>>>> Application
>>>>>>>> opens files and Eclipse Application opens resurces from the
>>>>>>>> workspace?"
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> "Florin Banica" <fbanica@soluta.net> wrote in message
>>>>>>>> news:ev0bsu$sgi$1@build.eclipse.org...
>>>>>>>>> The command class:
>>>>>>>>>
>>>>>>>>> public class AssignDataModelCommand extends
>>>>>>>>> AbstractTransactionalCommand
>>>>>>>>> {
>>>>>>>>> private static String label = "Assign Data Model Command";
>>>>>>>>> private ProtocolModel protMod;
>>>>>>>>> private DataModel dtMod;
>>>>>>>>>
>>>>>>>>> public AssignDataModelCommand(ProtocolModel protocolModel,
>>>>>>>>> DataModel
>>>>>>>>> dataModel, ResourceSet resSet, List res) {
>>>>>>>>> super(TransactionUtil.getEditingDomain(resSet), label,
>>>>>>>>> res);
>>>>>>>>>
>>>>>>>>> this.protMod = protocolModel;
>>>>>>>>> this.dtMod = dataModel;
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> @Override
>>>>>>>>> protected CommandResult doExecuteWithResult(IProgressMonitor
>>>>>>>>> monitor,
>>>>>>>>> IAdaptable info) throws ExecutionException {
>>>>>>>>> protMod.setDataModel(dtMod);
>>>>>>>>>
>>>>>>>>> return CommandResult.newOKCommandResult();
>>>>>>>>> }
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> and the execution:
>>>>>>>>>
>>>>>>>>> ...
>>>>>>>>> AssignDataModelCommand cmd = new AssignDataModelCommand(pm,
>>>>>>>>> mainPage.dataModel, resSet, resources);
>>>>>>>>>
>>>>>>>>> try {
>>>>>>>>> cmd.execute(new NullProgressMonitor(), null);
>>>>>>>>> }
>>>>>>>>> catch(ExecutionException e) {
>>>>>>>>> System.out.println(e.getStackTrace());
>>>>>>>>> }
>>>>>>>>> ...
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
>>>>>>>>> news:pan.2007.04.04.14.02.52.966419@uwaterloo.ca...
>>>>>>>>>> Could you post the code?
>>>>>>>>>>
>>>>>>>>>> vlad
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>
>
Re: Problems with Command [message #117209 is a reply to message #117171] Wed, 04 April 2007 12:47 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: fbanica.soluta.net

I was also wondering if the second parameter of the
doExecuteWithResult(IProgressMonitor monitor, IAdaptable info), the "info"
should be something "special", or it's OK to pass just "null"???


"Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
news:pan.2007.04.04.16.17.48.447575@uwaterloo.ca...
> Can you describe your scenario so I can give a more informed opinion?
>
> Do you have a bootstrapped diagram to start with? If not, bootstrapping
> code is contained in the generated XXXDiagramEditorUtil.
>
> Another case I can think of is when you have a model and want to attach to
> it some other model elements created outside the gmf framework. For
> instance, if you create model elements through the
> XXXFactory.eINSTANCE.createXXXX methods, you can attach them to the gmf
> model in a command that calls the corresponding set reference method.
>
> vlad
>
>
>
>
> On Wed, 04 Apr 2007 19:03:08 +0300, Florin Banica wrote:
>
>> Pretty much usless :-(
>>
>> The method:
>>
>> protected static List getWorkspaceFiles(EObject eObject) {
>> List result = new ArrayList();
>>
>> if (eObject != null) {
>> Resource resource = eObject.eResource();
>>
>> if (resource != null) {
>> IFile file = WorkspaceSynchronizer.getFile(resource);
>>
>> if (file != null) {
>> result.add(file);
>> }
>> }
>> }
>>
>> return result;
>> }
>>
>> at the line Resource resource = eObject.eResource(); turns my EObject
>> back
>> into a Resource (GMFResource). Then, the line IFile file =
>> WorkspaceSynchronizer.getFile(resource); gives no file (null), so nothing
>> is
>> modified in the end.
>>
>> So we're back at the starting point... :-(
>>
>>
>>
>> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
>> news:pan.2007.04.04.15.25.35.323187@uwaterloo.ca...
>>> On Wed, 04 Apr 2007 18:08:02 +0300, Florin Banica wrote:
>>>
>>>> In case you wonder, I have both the diagram and the model saved in the
>>>> same
>>>> file. That's why I have a GMFResource...
>>> Don't pass the resource, pass one of the EObjects you're modifying.
>>>
>>>
>>>>
>>>
>>>>
>>>> "Florin Banica" <fbanica@soluta.net> wrote in message
>>>> news:ev0eqr$59v$1@build.eclipse.org...
>>>>> This is the code of the method:
>>>>>
>>>>> protected static List getWorkspaceFiles(List eObjects) {
>>>>> List result = new ArrayList();
>>>>>
>>>>> for (Iterator i = eObjects.iterator(); i.hasNext();) {
>>>>> Object next = i.next();
>>>>>
>>>>> if (next instanceof EObject) {
>>>>> Resource resource = ((EObject) next).eResource();
>>>>>
>>>>> if (resource != null) {
>>>>> IFile file = WorkspaceSynchronizer.getFile(resource);
>>>>>
>>>>> if (file != null) {
>>>>> result.add(file);
>>>>> }
>>>>> }
>>>>> }
>>>>> }
>>>>>
>>>>> return result;
>>>>> }
>>>>>
>>>>> As you can see, it checks "next" if it's instanceof EObject. My
>>>>> "affected"
>>>>> (to be saved) resource is a GMFResource, which seems to be "NOT
>>>>> instanceof
>>>>> EObject"...
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
>>>>> news:pan.2007.04.04.14.43.02.606731@uwaterloo.ca...
>>>>>> This is it:
>>>>>> AbstractTransactionalCommand.getWorkspaceFiles(List/EObject)
>>>>>>
>>>>>> vlad
>>>>>>
>>>>>> On Wed, 04 Apr 2007 17:34:48 +0300, Florin Banica wrote:
>>>>>>
>>>>>>> Sorry, I meant "How to "convert" a Resource to a IFile?" message...
>>>>>>>
>>>>>>>
>>>>>>> "Florin Banica" <fbanica@soluta.net> wrote in message
>>>>>>> news:ev0c5g$tb4$1@build.eclipse.org...
>>>>>>>> Could it be the "res" parameter? Although it doesn't say anything
>>>>>>>> when
>>>>>>>> I
>>>>>>>> pass a ResourceSet... even if it expects a List<IFile> (at least
>>>>>>>> this
>>>>>>>> is
>>>>>>>> what I found in debug...). See also the recent message "RCP
>>>>>>>> Application
>>>>>>>> opens files and Eclipse Application opens resurces from the
>>>>>>>> workspace?"
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> "Florin Banica" <fbanica@soluta.net> wrote in message
>>>>>>>> news:ev0bsu$sgi$1@build.eclipse.org...
>>>>>>>>> The command class:
>>>>>>>>>
>>>>>>>>> public class AssignDataModelCommand extends
>>>>>>>>> AbstractTransactionalCommand
>>>>>>>>> {
>>>>>>>>> private static String label = "Assign Data Model Command";
>>>>>>>>> private ProtocolModel protMod;
>>>>>>>>> private DataModel dtMod;
>>>>>>>>>
>>>>>>>>> public AssignDataModelCommand(ProtocolModel protocolModel,
>>>>>>>>> DataModel
>>>>>>>>> dataModel, ResourceSet resSet, List res) {
>>>>>>>>> super(TransactionUtil.getEditingDomain(resSet), label,
>>>>>>>>> res);
>>>>>>>>>
>>>>>>>>> this.protMod = protocolModel;
>>>>>>>>> this.dtMod = dataModel;
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>> @Override
>>>>>>>>> protected CommandResult doExecuteWithResult(IProgressMonitor
>>>>>>>>> monitor,
>>>>>>>>> IAdaptable info) throws ExecutionException {
>>>>>>>>> protMod.setDataModel(dtMod);
>>>>>>>>>
>>>>>>>>> return CommandResult.newOKCommandResult();
>>>>>>>>> }
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> and the execution:
>>>>>>>>>
>>>>>>>>> ...
>>>>>>>>> AssignDataModelCommand cmd = new AssignDataModelCommand(pm,
>>>>>>>>> mainPage.dataModel, resSet, resources);
>>>>>>>>>
>>>>>>>>> try {
>>>>>>>>> cmd.execute(new NullProgressMonitor(), null);
>>>>>>>>> }
>>>>>>>>> catch(ExecutionException e) {
>>>>>>>>> System.out.println(e.getStackTrace());
>>>>>>>>> }
>>>>>>>>> ...
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
>>>>>>>>> news:pan.2007.04.04.14.02.52.966419@uwaterloo.ca...
>>>>>>>>>> Could you post the code?
>>>>>>>>>>
>>>>>>>>>> vlad
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>
>>>>>
>>>>>
>>>
>
Re: Problems with Command [message #117223 is a reply to message #117209] Wed, 04 April 2007 13:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: vcciubot.uwaterloo.ca

I pass null without problems.

The only problem I can think about is that if you have two editor windows
and they don't share the TransactionalEditingDomain.

Use protocolModelEditingDomain.getResourceSet().getResource(<<harcoded
data model uri>>, true);

And then call getContents() on the returned resource to get to the data
model which you pass to your command.

vlad


On Wed, 04 Apr 2007 19:47:15 +0300, Florin Banica wrote:

> I was also wondering if the second parameter of the
> doExecuteWithResult(IProgressMonitor monitor, IAdaptable info), the "info"
> should be something "special", or it's OK to pass just "null"???
>
>
> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
> news:pan.2007.04.04.16.17.48.447575@uwaterloo.ca...
>> Can you describe your scenario so I can give a more informed opinion?
>>
>> Do you have a bootstrapped diagram to start with? If not, bootstrapping
>> code is contained in the generated XXXDiagramEditorUtil.
>>
>> Another case I can think of is when you have a model and want to attach to
>> it some other model elements created outside the gmf framework. For
>> instance, if you create model elements through the
>> XXXFactory.eINSTANCE.createXXXX methods, you can attach them to the gmf
>> model in a command that calls the corresponding set reference method.
>>
>> vlad
>>
>>
>>
>>
>> On Wed, 04 Apr 2007 19:03:08 +0300, Florin Banica wrote:
>>
>>> Pretty much usless :-(
>>>
>>> The method:
>>>
>>> protected static List getWorkspaceFiles(EObject eObject) {
>>> List result = new ArrayList();
>>>
>>> if (eObject != null) {
>>> Resource resource = eObject.eResource();
>>>
>>> if (resource != null) {
>>> IFile file = WorkspaceSynchronizer.getFile(resource);
>>>
>>> if (file != null) {
>>> result.add(file);
>>> }
>>> }
>>> }
>>>
>>> return result;
>>> }
>>>
>>> at the line Resource resource = eObject.eResource(); turns my EObject
>>> back
>>> into a Resource (GMFResource). Then, the line IFile file =
>>> WorkspaceSynchronizer.getFile(resource); gives no file (null), so nothing
>>> is
>>> modified in the end.
>>>
>>> So we're back at the starting point... :-(
>>>
>>>
>>>
>>> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
>>> news:pan.2007.04.04.15.25.35.323187@uwaterloo.ca...
>>>> On Wed, 04 Apr 2007 18:08:02 +0300, Florin Banica wrote:
>>>>
>>>>> In case you wonder, I have both the diagram and the model saved in the
>>>>> same
>>>>> file. That's why I have a GMFResource...
>>>> Don't pass the resource, pass one of the EObjects you're modifying.
>>>>
>>>>
>>>>>
>>>>
>>>>>
>>>>> "Florin Banica" <fbanica@soluta.net> wrote in message
>>>>> news:ev0eqr$59v$1@build.eclipse.org...
>>>>>> This is the code of the method:
>>>>>>
>>>>>> protected static List getWorkspaceFiles(List eObjects) {
>>>>>> List result = new ArrayList();
>>>>>>
>>>>>> for (Iterator i = eObjects.iterator(); i.hasNext();) {
>>>>>> Object next = i.next();
>>>>>>
>>>>>> if (next instanceof EObject) {
>>>>>> Resource resource = ((EObject) next).eResource();
>>>>>>
>>>>>> if (resource != null) {
>>>>>> IFile file = WorkspaceSynchronizer.getFile(resource);
>>>>>>
>>>>>> if (file != null) {
>>>>>> result.add(file);
>>>>>> }
>>>>>> }
>>>>>> }
>>>>>> }
>>>>>>
>>>>>> return result;
>>>>>> }
>>>>>>
>>>>>> As you can see, it checks "next" if it's instanceof EObject. My
>>>>>> "affected"
>>>>>> (to be saved) resource is a GMFResource, which seems to be "NOT
>>>>>> instanceof
>>>>>> EObject"...
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
>>>>>> news:pan.2007.04.04.14.43.02.606731@uwaterloo.ca...
>>>>>>> This is it:
>>>>>>> AbstractTransactionalCommand.getWorkspaceFiles(List/EObject)
>>>>>>>
>>>>>>> vlad
>>>>>>>
>>>>>>> On Wed, 04 Apr 2007 17:34:48 +0300, Florin Banica wrote:
>>>>>>>
>>>>>>>> Sorry, I meant "How to "convert" a Resource to a IFile?" message...
>>>>>>>>
>>>>>>>>
>>>>>>>> "Florin Banica" <fbanica@soluta.net> wrote in message
>>>>>>>> news:ev0c5g$tb4$1@build.eclipse.org...
>>>>>>>>> Could it be the "res" parameter? Although it doesn't say anything
>>>>>>>>> when
>>>>>>>>> I
>>>>>>>>> pass a ResourceSet... even if it expects a List<IFile> (at least
>>>>>>>>> this
>>>>>>>>> is
>>>>>>>>> what I found in debug...). See also the recent message "RCP
>>>>>>>>> Application
>>>>>>>>> opens files and Eclipse Application opens resurces from the
>>>>>>>>> workspace?"
>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> "Florin Banica" <fbanica@soluta.net> wrote in message
>>>>>>>>> news:ev0bsu$sgi$1@build.eclipse.org...
>>>>>>>>>> The command class:
>>>>>>>>>>
>>>>>>>>>> public class AssignDataModelCommand extends
>>>>>>>>>> AbstractTransactionalCommand
>>>>>>>>>> {
>>>>>>>>>> private static String label = "Assign Data Model Command";
>>>>>>>>>> private ProtocolModel protMod;
>>>>>>>>>> private DataModel dtMod;
>>>>>>>>>>
>>>>>>>>>> public AssignDataModelCommand(ProtocolModel protocolModel,
>>>>>>>>>> DataModel
>>>>>>>>>> dataModel, ResourceSet resSet, List res) {
>>>>>>>>>> super(TransactionUtil.getEditingDomain(resSet), label,
>>>>>>>>>> res);
>>>>>>>>>>
>>>>>>>>>> this.protMod = protocolModel;
>>>>>>>>>> this.dtMod = dataModel;
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>> @Override
>>>>>>>>>> protected CommandResult doExecuteWithResult(IProgressMonitor
>>>>>>>>>> monitor,
>>>>>>>>>> IAdaptable info) throws ExecutionException {
>>>>>>>>>> protMod.setDataModel(dtMod);
>>>>>>>>>>
>>>>>>>>>> return CommandResult.newOKCommandResult();
>>>>>>>>>> }
>>>>>>>>>> }
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> and the execution:
>>>>>>>>>>
>>>>>>>>>> ...
>>>>>>>>>> AssignDataModelCommand cmd = new AssignDataModelCommand(pm,
>>>>>>>>>> mainPage.dataModel, resSet, resources);
>>>>>>>>>>
>>>>>>>>>> try {
>>>>>>>>>> cmd.execute(new NullProgressMonitor(), null);
>>>>>>>>>> }
>>>>>>>>>> catch(ExecutionException e) {
>>>>>>>>>> System.out.println(e.getStackTrace());
>>>>>>>>>> }
>>>>>>>>>> ...
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
>>>>>>>>>> news:pan.2007.04.04.14.02.52.966419@uwaterloo.ca...
>>>>>>>>>>> Could you post the code?
>>>>>>>>>>>
>>>>>>>>>>> vlad
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>
>>>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>
>>
Re: Problems with Command [message #118359 is a reply to message #117223] Wed, 11 April 2007 11:06 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: fbanica.soluta.net

Hi, I'm back.

I think the main problem comes from the fact that my application is RCP and,
in this case, the file in the editor is open "form the file system" while
parameter passed as IFile "is saw as a Resource" (see also the "RCP
Application opens files and Eclipse Application opens resurces from the
workspace?" message in the list above)... As far as I could see in debug,
this Resource is not seen as "changed" from the transaction's point of
view... So, it doesn't happen anything in Execute.

Any other suggestions to resolve this?

Thank you,



Floppy



"Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
news:pan.2007.04.04.17.04.55.538925@uwaterloo.ca...
>I pass null without problems.
>
> The only problem I can think about is that if you have two editor windows
> and they don't share the TransactionalEditingDomain.
>
> Use protocolModelEditingDomain.getResourceSet().getResource(<<harcoded
> data model uri>>, true);
>
> And then call getContents() on the returned resource to get to the data
> model which you pass to your command.
>
> vlad
>
>
> On Wed, 04 Apr 2007 19:47:15 +0300, Florin Banica wrote:
>
>> I was also wondering if the second parameter of the
>> doExecuteWithResult(IProgressMonitor monitor, IAdaptable info), the
>> "info"
>> should be something "special", or it's OK to pass just "null"???
>>
>>
>> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
>> news:pan.2007.04.04.16.17.48.447575@uwaterloo.ca...
>>> Can you describe your scenario so I can give a more informed opinion?
>>>
>>> Do you have a bootstrapped diagram to start with? If not, bootstrapping
>>> code is contained in the generated XXXDiagramEditorUtil.
>>>
>>> Another case I can think of is when you have a model and want to attach
>>> to
>>> it some other model elements created outside the gmf framework. For
>>> instance, if you create model elements through the
>>> XXXFactory.eINSTANCE.createXXXX methods, you can attach them to the gmf
>>> model in a command that calls the corresponding set reference method.
>>>
>>> vlad
>>>
>>>
>>>
>>>
>>> On Wed, 04 Apr 2007 19:03:08 +0300, Florin Banica wrote:
>>>
>>>> Pretty much usless :-(
>>>>
>>>> The method:
>>>>
>>>> protected static List getWorkspaceFiles(EObject eObject) {
>>>> List result = new ArrayList();
>>>>
>>>> if (eObject != null) {
>>>> Resource resource = eObject.eResource();
>>>>
>>>> if (resource != null) {
>>>> IFile file = WorkspaceSynchronizer.getFile(resource);
>>>>
>>>> if (file != null) {
>>>> result.add(file);
>>>> }
>>>> }
>>>> }
>>>>
>>>> return result;
>>>> }
>>>>
>>>> at the line Resource resource = eObject.eResource(); turns my EObject
>>>> back
>>>> into a Resource (GMFResource). Then, the line IFile file =
>>>> WorkspaceSynchronizer.getFile(resource); gives no file (null), so
>>>> nothing
>>>> is
>>>> modified in the end.
>>>>
>>>> So we're back at the starting point... :-(
>>>>
>>>>
>>>>
>>>> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
>>>> news:pan.2007.04.04.15.25.35.323187@uwaterloo.ca...
>>>>> On Wed, 04 Apr 2007 18:08:02 +0300, Florin Banica wrote:
>>>>>
>>>>>> In case you wonder, I have both the diagram and the model saved in
>>>>>> the
>>>>>> same
>>>>>> file. That's why I have a GMFResource...
>>>>> Don't pass the resource, pass one of the EObjects you're modifying.
>>>>>
>>>>>
>>>>>>
>>>>>
>>>>>>
>>>>>> "Florin Banica" <fbanica@soluta.net> wrote in message
>>>>>> news:ev0eqr$59v$1@build.eclipse.org...
>>>>>>> This is the code of the method:
>>>>>>>
>>>>>>> protected static List getWorkspaceFiles(List eObjects) {
>>>>>>> List result = new ArrayList();
>>>>>>>
>>>>>>> for (Iterator i = eObjects.iterator(); i.hasNext();) {
>>>>>>> Object next = i.next();
>>>>>>>
>>>>>>> if (next instanceof EObject) {
>>>>>>> Resource resource = ((EObject) next).eResource();
>>>>>>>
>>>>>>> if (resource != null) {
>>>>>>> IFile file = WorkspaceSynchronizer.getFile(resource);
>>>>>>>
>>>>>>> if (file != null) {
>>>>>>> result.add(file);
>>>>>>> }
>>>>>>> }
>>>>>>> }
>>>>>>> }
>>>>>>>
>>>>>>> return result;
>>>>>>> }
>>>>>>>
>>>>>>> As you can see, it checks "next" if it's instanceof EObject. My
>>>>>>> "affected"
>>>>>>> (to be saved) resource is a GMFResource, which seems to be "NOT
>>>>>>> instanceof
>>>>>>> EObject"...
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
>>>>>>> news:pan.2007.04.04.14.43.02.606731@uwaterloo.ca...
>>>>>>>> This is it:
>>>>>>>> AbstractTransactionalCommand.getWorkspaceFiles(List/EObject)
>>>>>>>>
>>>>>>>> vlad
>>>>>>>>
>>>>>>>> On Wed, 04 Apr 2007 17:34:48 +0300, Florin Banica wrote:
>>>>>>>>
>>>>>>>>> Sorry, I meant "How to "convert" a Resource to a IFile?"
>>>>>>>>> message...
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> "Florin Banica" <fbanica@soluta.net> wrote in message
>>>>>>>>> news:ev0c5g$tb4$1@build.eclipse.org...
>>>>>>>>>> Could it be the "res" parameter? Although it doesn't say anything
>>>>>>>>>> when
>>>>>>>>>> I
>>>>>>>>>> pass a ResourceSet... even if it expects a List<IFile> (at least
>>>>>>>>>> this
>>>>>>>>>> is
>>>>>>>>>> what I found in debug...). See also the recent message "RCP
>>>>>>>>>> Application
>>>>>>>>>> opens files and Eclipse Application opens resurces from the
>>>>>>>>>> workspace?"
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>> "Florin Banica" <fbanica@soluta.net> wrote in message
>>>>>>>>>> news:ev0bsu$sgi$1@build.eclipse.org...
>>>>>>>>>>> The command class:
>>>>>>>>>>>
>>>>>>>>>>> public class AssignDataModelCommand extends
>>>>>>>>>>> AbstractTransactionalCommand
>>>>>>>>>>> {
>>>>>>>>>>> private static String label = "Assign Data Model Command";
>>>>>>>>>>> private ProtocolModel protMod;
>>>>>>>>>>> private DataModel dtMod;
>>>>>>>>>>>
>>>>>>>>>>> public AssignDataModelCommand(ProtocolModel protocolModel,
>>>>>>>>>>> DataModel
>>>>>>>>>>> dataModel, ResourceSet resSet, List res) {
>>>>>>>>>>> super(TransactionUtil.getEditingDomain(resSet), label,
>>>>>>>>>>> res);
>>>>>>>>>>>
>>>>>>>>>>> this.protMod = protocolModel;
>>>>>>>>>>> this.dtMod = dataModel;
>>>>>>>>>>> }
>>>>>>>>>>>
>>>>>>>>>>> @Override
>>>>>>>>>>> protected CommandResult doExecuteWithResult(IProgressMonitor
>>>>>>>>>>> monitor,
>>>>>>>>>>> IAdaptable info) throws ExecutionException {
>>>>>>>>>>> protMod.setDataModel(dtMod);
>>>>>>>>>>>
>>>>>>>>>>> return CommandResult.newOKCommandResult();
>>>>>>>>>>> }
>>>>>>>>>>> }
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> and the execution:
>>>>>>>>>>>
>>>>>>>>>>> ...
>>>>>>>>>>> AssignDataModelCommand cmd = new AssignDataModelCommand(pm,
>>>>>>>>>>> mainPage.dataModel, resSet, resources);
>>>>>>>>>>>
>>>>>>>>>>> try {
>>>>>>>>>>> cmd.execute(new NullProgressMonitor(), null);
>>>>>>>>>>> }
>>>>>>>>>>> catch(ExecutionException e) {
>>>>>>>>>>> System.out.println(e.getStackTrace());
>>>>>>>>>>> }
>>>>>>>>>>> ...
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>> "Vlad Ciubotariu" <vcciubot@uwaterloo.ca> wrote in message
>>>>>>>>>>> news:pan.2007.04.04.14.02.52.966419@uwaterloo.ca...
>>>>>>>>>>>> Could you post the code?
>>>>>>>>>>>>
>>>>>>>>>>>> vlad
>>>>>>>>>>>>
>>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>>>
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>
>>>
>
Re: Problems with Command [message #118799 is a reply to message #118359] Thu, 12 April 2007 08:48 Go to previous message
Eclipse UserFriend
Originally posted by: fbanica.soluta.net

I did make an Eclipse Application (instead of a RCP one). Strange thing,
it's working now (using cmd.execute(new NullProgressMonitor(), null); ),
but, when I close the second workbench, I get 3 errors:

1. Asynchronous viewr update: error
2. children update: An internal error occurred during: "children update".
java.lang.ArrayIndexOutOfBoundsException
3. children update: An internal error occurred during: "children update".
java.lang.ArrayIndexOutOfBoundsException

2 and 3 are the same, indeed, but they are displayed just like that...

So, it seems that there is a problem when working with the RCP application
(the file is not updated at all), but also with the Eclipse application it
gives me those 3 errors... What shal I do next? Please help.



Floppy


"Florin Banica" <fbanica@soluta.net> wrote in message
news:evitij$udt$1@build.eclipse.org...
> Hi, I'm back.
>
> I think the main problem comes from the fact that my application is RCP
> and, in this case, the file in the editor is open "form the file system"
> while parameter passed as IFile "is saw as a Resource" (see also the "RCP
> Application opens files and Eclipse Application opens resurces from the
> workspace?" message in the list above)... As far as I could see in debug,
> this Resource is not seen as "changed" from the transaction's point of
> view... So, it doesn't happen anything in Execute.
>
> Any other suggestions to resolve this?
>
> Thank you,
>
>
>
> Floppy
Previous Topic:Main Menu
Next Topic:Navigate to references
Goto Forum:
  


Current Time: Tue Jul 22 14:01:23 EDT 2025

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

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

Back to the top