Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Closing a diagram programaticaly
Closing a diagram programaticaly [message #198694] Wed, 23 July 2008 21:29 Go to next message
Eclipse UserFriend
Originally posted by: julan1984.gmail.com

Hello All,


Is there a way to close a GMF diagram programatically?

Hope to hear from some one.

Thanks,

Anoop
Re: Closing a diagram programaticaly [message #198710 is a reply to message #198694] Thu, 24 July 2008 04:39 Go to previous messageGo to next message
BG is currently offline BGFriend
Messages: 45
Registered: July 2009
Member
Hi
get the editor reference from the workbench
TransactionalEditingDomain editingDomain = ((FlowVinciDiagramEditor)
editorReference
.getPart(false))
.getEditingDomain();
if (editingDomain != null) {
ResourceSet resourceSet = editingDomain
.getResourceSet();
for (Resource element : resourceSet
.getResources()) {
resource.add(element);
}
for (Resource element : resource) {

resourceSet.getResources()
.remove(element);
}
}
((FlowVinciDiagramEditor) editorReference
.getPart(false)).close(false);

Once the reference is avilable remove the domain,diagram resource from
resource set.

This is how we are doing in our project.

Regards
BG
Re: Closing a diagram programaticaly [message #198726 is a reply to message #198710] Thu, 24 July 2008 06:33 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: julan.gmail.com

Hello BG,

Thanks for the reply. I didnt understand one thing.

"get the editor reference from the workbench TransactionalEditingDomain"

How is this done?

Hope to hear from you.

Thanks,

Julan
Re: Closing a diagram programaticaly [message #198758 is a reply to message #198726] Thu, 24 July 2008 08:16 Go to previous messageGo to next message
BG is currently offline BGFriend
Messages: 45
Registered: July 2009
Member
Hi,
Some thing like this...
IWorkbench workbench = PlatformUI.getWorkbench();
if (workbench != null) {
try {
if (workbench.getWorkbenchWindows()[0] != null
&&workbench.getWorkbenchWindows()[0].getActivePage() != null) {
IWorkbenchPage page = workbench.getWorkbenchWindows()[0].getActivePage();
if (page != null&& page.getEditorReferences().length > 0) {
ArrayList<Resource> resource = new ArrayList<Resource>();
for (IEditorReference editorReference : page.getEditorReferences()) {
if (fileName.contains(editorReference.getName())) {

to get the editor reference for your diagram file

Regards
BG
Re: Closing a diagram programaticaly [message #198799 is a reply to message #198758] Thu, 24 July 2008 10:14 Go to previous message
Eclipse UserFriend
Originally posted by: julan.gmail.com

Thanks a bunch. It worked as expected.

Julan
Previous Topic:Change action when click an entry in the palette
Next Topic:GMF not freeing JVM memory after an editor is closed
Goto Forum:
  


Current Time: Mon May 25 06:09:11 GMT 2020

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

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

Back to the top