Skip to main content



      Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to delete shortcut with no element exists instantly when switch editors
How to delete shortcut with no element exists instantly when switch editors [message #41314] Wed, 06 September 2006 23:19 Go to next message
Eclipse UserFriend
Originally posted by: dzhpingbo.sohu.com

I enable canonical behavior and it works. It can delete shortcut with no
element exists.
If I create element with its shortcut in the same editor and then I delete
the elment using "Delete From Model", the shortcut will be deleted
instantly, but if I create shortcut and its element in different editors,
then I delete the elment using "Delete From Model", switch to the editor
which contains the shortcut, the shortcut still exists.
How can I delete shortcut with no element exists instantly when switch
editors?
Re: How to delete shortcut with no element exists instantly when switch editors [message #41512 is a reply to message #41314] Thu, 07 September 2006 05:32 Go to previous messageGo to next message
Eclipse UserFriend
Hello dzh,

Shortcut should disappear if you reopen second editor. To automate this process
you should either listen for any changes in the resource and update diagram
(reload it) by yourself or load both diagrams into the same resource set.
Both topics was several times discussed in the newsgroup (m.b. in old one).

-----------------
Alex Shatalin
Re: How to delete shortcut with no element exists instantly when switch editors [message #41799 is a reply to message #41512] Thu, 07 September 2006 08:40 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dzhpingbo.sohu.com

Could you please tell me which method should I use to update diagram(relaod
it), I have found the newgroup and got nothing...
Best regards,
dzh
"Alex Shatalin" <vano@borland.com> д
Re: How to delete shortcut with no element exists instantly when switch editors [message #42220 is a reply to message #41512] Thu, 07 September 2006 13:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dzhpingbo.sohu.com

This is a multi-part message in MIME format.

------=_NextPart_000_000B_01C6D2E9.8FDDD290
Content-Type: text/plain;
charset="utf-8"
Content-Transfer-Encoding: quoted-printable


I follow the =
news:http://dev.eclipse.org/newslists/news.eclipse.technolog y.gmf/msg0388=
1.html
I get the TransactionalEditingDomain From Editor, and from this edit =
domain, I get the ResourceSet and find the resource corresponding to the =
ecore mode. Then I unload and load again this resource using as option =
editingDomain.getResourceSet().getLoadOptions().

I use the code below to reload the diagram:

TransactionalEditingDomain =
editingDomain=3D((FileDiagramEditor)part).getEditingDomain() ;
Map resMap =3D editingDomain.getResourceSet().getLoadOptions();
IEditorInput activeInput =
=3D((FileDiagramEditor)part).getEditorInput();
IFile diagramFile =3D ((IFileEditorInput)activeInput).getFile(); =20
IPath resourcePath =3D diagramFile.getFullPath();
ResourceSet resourceSet =3D =
editingDomain.getResourceSet();//myEditingDomain.getResource Set(); =
=20
try {
Resource modelResource =3D resourceSet.getResource(
URI.createPlatformResourceURI(resourcePath
.toString()), true);
try { =20
modelResource.unload();
modelResource.load(resMap);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (WrappedException e) {
ProcessDiagramEditorPlugin
.getInstance()
.logError(
"Unable to load resource: " + resourcePath.toString(), e); =
//$NON-NLS-1$
}

I debug through the code and it did not report error, but after execute =
the code above, the shortcut with no element still remains on =
editor...and then I add element to the editor using palette tool, the =
editor did not show the element view. By debug through the code, I found =
that the element was added into DiagramImpl which exsits in memory, but =
it can not be saved into model file and diagram file...

Am I something wrong with the code above?

In fact, I just want to delete the shortcut without element exsits, do =
anyone have any simple way to fulfill this?
"Alex Shatalin" <vano@borland.com> =
=E5=86=99=E5=85=A5=E6=B6=88=E6=81=AF=E6=96=B0=E9=97=BB:cd695 fb3116018c8a0=
8860a535fd@news.eclipse.org...
> Hello dzh,
>=20
> Shortcut should disappear if you reopen second editor. To automate =
this process=20
> you should either listen for any changes in the resource and update =
diagram=20
> (reload it) by yourself or load both diagrams into the same resource =
set.=20
> Both topics was several times discussed in the newsgroup (m.b. in old =
one).
>=20
> -----------------
> Alex Shatalin
>=20
>
------=_NextPart_000_000B_01C6D2E9.8FDDD290
Content-Type: text/html;
charset="utf-8"
Content-Transfer-Encoding: quoted-printable

=EF=BB=BF<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dutf-8">
<META content=3D"MSHTML 6.00.2900.2769" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3D=E5=AE=8B=E4=BD=93 size=3D2></FONT>&nbsp;</DIV>
<DIV>I follow the <A=20
href=3D" news:http://dev.eclipse.org/newslists/news.eclipse.technolog y.gmf=
/msg03881.html">news:http://dev.eclipse.org/newslists/news.eclipse.techno=
logy.gmf/msg03881.html</A></DIV>
<DIV>I get the TransactionalEditingDomain From Editor, and&nbsp;from =
this edit=20
domain, I&nbsp;get the ResourceSet and find the resource corresponding =
to the=20
ecore mode. Then I unload and load again this resource using as option=20
editingDomain.getResourceSet().getLoadOptions().</DIV>
<DIV><FONT face=3D=E5=AE=8B=E4=BD=93 size=3D2></FONT>&nbsp;</DIV>
<DIV>I use the code below to reload the diagram:</DIV>
<DIV>&nbsp;</DIV>
<DIV>TransactionalEditingDomain=20
editingDomain=3D((FileDiagramEditor)part).getEditingDomain() ; <BR>&nbsp;&n=
bsp;&nbsp;&nbsp;Map=20
resMap =3D=20
editingDomain.getResourceSet().getLoadOptions();<BR>&nbsp;&nbsp;&nbsp;&nb=
sp;IEditorInput=20
activeInput=20
=3D((FileDiagramEditor)part).getEditorInput();<BR>&nbsp;&nbsp;&nbsp;&nbsp=
;IFile=20
diagramFile =3D=20
((IFileEditorInput)activeInput).getFile();&nbsp;&nbs p;&nbsp;&nbsp; <BR>&nb=
sp;&nbsp;&nbsp;&nbsp;IPath=20
resourcePath =3D =
diagramFile.getFullPath();<BR>&nbsp;&nbsp;&nbsp;&nbsp;ResourceSet=20
resourceSet =3D=20
editingDomain.getResourceSet();//myEditingDomain.getResource Set();&nbsp;&=
nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;& nbsp; <BR>&nbsp;&nbsp;&nbsp;&nbsp;try =

{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Resource modelResource =3D=20
resourceSet.getResource(<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;URI=
..createPlatformResourceURI(resourcePath<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=
&nbsp;&nbsp;&nbsp;&nbsp;.toString()),=20
true);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try=20
{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp ; <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&n=
bsp;modelResource.unload();<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; modelR=
esource.load(resMap);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}=20
catch (IOException e) {<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // TODO=20
Auto-generated catch=20
block<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; e.printStackTrace(); <BR>&nbs=
p;&nbsp;&nbsp;&nbsp;&nbsp;}<BR>&nbsp;&nbsp;&nbsp;&nbsp;}=20
catch (WrappedException e)=20
{<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ProcessDia gramEditorPlugin <BR>&nbsp;&n=
bsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;.getIn stance() <BR>&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp;&nbsp;&nbsp;.logError(<BR> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &n=
bsp;&nbsp;&nbsp;"Unable=20
to load resource: " + resourcePath.toString(), e);=20
//$NON-NLS-1$<BR>&nbsp;&nbsp;&nbsp;&nbsp;} </DIV>
<DIV>&nbsp;</DIV>
<DIV>I debug through the code and it did not report error, but after =
execute the=20
code above, the shortcut&nbsp;with no element&nbsp;still remains on =
editor...and=20
then I add element to the editor using palette tool, &nbsp;the editor =
did not=20
show the element view. By debug through the code, I found that the=20
element&nbsp;was added into&nbsp;DiagramImpl which exsits in memory, but =
it can=20
not be saved into model file and diagram file...</DIV>
<DIV><FONT face=3D=E5=AE=8B=E4=BD=93 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D=E5=AE=8B=E4=BD=93 size=3D2>Am I something wrong with =
the code above?</FONT></DIV>
<DIV><FONT face=3D=E5=AE=8B=E4=BD=93 size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3D=E5=AE=8B=E4=BD=93 size=3D2>In fact, I just want to =
delete the shortcut without=20
element exsits, do&nbsp;anyone have any simple way to fulfill =
this?</FONT></DIV>
<DIV>"Alex Shatalin" &lt;<A=20
href=3D"mailto:vano@borland.com">vano@borland.com</A>&gt;=20
=E5=86=99=E5=85=A5=E6=B6=88=E6=81=AF=E6=96=B0=E9=97=BB:cd695 fb3116018c8a0=
8860a535fd@news.eclipse.org...</DIV>&gt; Hello=20
dzh,<BR>&gt; <BR>&gt; Shortcut should disappear if you reopen second =
editor. To=20
automate this process <BR>&gt; you should either listen for any changes =
in the=20
resource and update diagram <BR>&gt; (reload it) by yourself or load =
both=20
diagrams into the same resource set. <BR>&gt; Both topics was several =
times=20
discussed in the newsgroup (m.b. in old one).<BR>&gt; <BR>&gt;=20
-----------------<BR>&gt; Alex Shatalin<BR>&gt; <BR>&gt;</BODY></HTML>

------=_NextPart_000_000B_01C6D2E9.8FDDD290--
Re: How to delete shortcut with no element exists instantly when switch editors [message #42599 is a reply to message #42220] Fri, 08 September 2006 05:41 Go to previous messageGo to next message
Eclipse UserFriend
Hello dzh,

> IFile diagramFile = ((IFileEditorInput)activeInput).getFile();
> IPath resourcePath = diagramFile.getFullPath();
You are unloading/loading diagram file resource. Suggeston described by
Thomas Wirtz-Baumann is to unload/load model resource.

-----------------
Alex Shatalin
Re: How to delete shortcut with no element exists instantly when switch editors [message #43190 is a reply to message #42599] Fri, 08 September 2006 12:32 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dzhpingbo.sohu.com

Thank you for you to correct me :)
Now I unload/load model resource(model files) when switch editors, and then
I can add view on canvas normally, a little progress:) but I still can not
delete the shortcut with no element exists. Reload model files did not
work....
So I close the editor and reopen it, the shortcut with no element gone
away.
I want to know what code should I write to perform the function just like
reopening editor did?
Best regards,
dzh
"Alex Shatalin" <vano@borland.com> д
Re: How to delete shortcut with no element exists instantly when switch editors [message #43385 is a reply to message #41512] Sat, 09 September 2006 02:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dzhpingbo.sohu.com

I had follow the
news:http://dev.eclipse.org/newslists/news.eclipse.technolog y.gmf/msg03881.html,
but it seems does not work, could you please give me other links about what
you suggest me to do? Thank you,
best regards,
dzh
"Alex Shatalin" <vano@borland.com> д
Re: How to delete shortcut with no element exists instantly when switch editors [message #44601 is a reply to message #43190] Mon, 11 September 2006 06:31 Go to previous messageGo to next message
Eclipse UserFriend
Hello dzh,

> I can add view on canvas normally, a little progress:) but I still can
> not delete the shortcut with no element exists. Reload model files did not
> work....
I did not tried that code myself. I only base my suggestion on the fact
that Thomas Wirtz-Baumann implemented that solution successfully. You can
either ask Thomas directly in the newsgroup, or try to found another solution.

> I want to know what code should I write to perform the function just
> like reopening editor did?
Generated diagram ???CanonicalEditPolicy will be activated on opening editor,
so if you’d like to perform exactly the same action, you should get corresponding
EditPolicy and call refresh() for it.

-----------------
Alex Shatalin
Re: How to delete shortcut with no element exists instantly when switch editors [message #44631 is a reply to message #43385] Mon, 11 September 2006 06:50 Go to previous message
Eclipse UserFriend
Hello dzh,

> but it seems does not work, could you please give me other links about
> what you suggest me to do?
You can follow the discussion ending by this posting: http://dev.eclipse.org/newslists/news.eclipse.technology.gmf /msg03937.html

-----------------
Alex Shatalin
Previous Topic:"Diagram element" dropdown list in gmfgraph Wizard
Next Topic:How to delete the view without element instantly?
Goto Forum:
  


Current Time: Sun May 04 08:47:03 EDT 2025

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

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

Back to the top