How to delete shortcut with no element exists instantly when switch editors [message #41314] |
Wed, 06 September 2006 23:19  |
Eclipse User |
|
|
|
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 #42220 is a reply to message #41512] |
Thu, 07 September 2006 13:53   |
Eclipse User |
|
|
|
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> </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 from =
this edit=20
domain, I 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> </DIV>
<DIV>I use the code below to reload the diagram:</DIV>
<DIV> </DIV>
<DIV>TransactionalEditingDomain=20
editingDomain=3D((FileDiagramEditor)part).getEditingDomain() ; <BR> &n=
bsp; Map=20
resMap =3D=20
editingDomain.getResourceSet().getLoadOptions();<BR> &nb=
sp;IEditorInput=20
activeInput=20
=3D((FileDiagramEditor)part).getEditorInput();<BR>  =
;IFile=20
diagramFile =3D=20
((IFileEditorInput)activeInput).getFile(); &nbs p; <BR>&nb=
sp; IPath=20
resourcePath =3D =
diagramFile.getFullPath();<BR> ResourceSet=20
resourceSet =3D=20
editingDomain.getResourceSet();//myEditingDomain.getResource Set(); &=
nbsp; & nbsp; <BR> try =
{<BR> Resource modelResource =3D=20
resourceSet.getResource(<BR> URI=
..createPlatformResourceURI(resourcePath<BR> =
.toString()),=20
true);<BR> try=20
{   ; <BR> &n=
bsp;modelResource.unload();<BR> modelR=
esource.load(resMap);<BR> }=20
catch (IOException e) {<BR> // TODO=20
Auto-generated catch=20
block<BR> e.printStackTrace(); <BR>&nbs=
p; }<BR> }=20
catch (WrappedException e)=20
{<BR> ProcessDia gramEditorPlugin <BR> &n=
bsp; .getIn stance() <BR> &nb=
sp; .logError(<BR> &n=
bsp; "Unable=20
to load resource: " + resourcePath.toString(), e);=20
//$NON-NLS-1$<BR> } </DIV>
<DIV> </DIV>
<DIV>I debug through the code and it did not report error, but after =
execute the=20
code above, the shortcut with no element still remains on =
editor...and=20
then I add element to the editor using palette tool, the editor =
did not=20
show the element view. By debug through the code, I found that the=20
element was added into 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> </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> </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 anyone have any simple way to fulfill =
this?</FONT></DIV>
<DIV>"Alex Shatalin" <<A=20
href=3D"mailto:vano@borland.com">vano@borland.com</A>>=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>> Hello=20
dzh,<BR>> <BR>> Shortcut should disappear if you reopen second =
editor. To=20
automate this process <BR>> you should either listen for any changes =
in the=20
resource and update diagram <BR>> (reload it) by yourself or load =
both=20
diagrams into the same resource set. <BR>> Both topics was several =
times=20
discussed in the newsgroup (m.b. in old one).<BR>> <BR>>=20
-----------------<BR>> Alex Shatalin<BR>> <BR>></BODY></HTML>
------=_NextPart_000_000B_01C6D2E9.8FDDD290--
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04679 seconds