Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » delete from explorer AND editor window
delete from explorer AND editor window [message #459742] Mon, 15 August 2005 09:56 Go to next message
shane is currently offline shaneFriend
Messages: 11
Registered: July 2009
Junior Member
Hi,

My query relates to the plug-in project template "Plug-in with a
multi-page editor". I run this project in a runtime environment and
everything works fine. But if I delete a file from the explorer (say
"new_file.mpe") and this file is open in the editor, then although the
file is deleted from the explorer view, it remains open in the editor.

If i then try to modify the open file (which technically no longer exists
and should have disappeared when it was deleted from the explorer), I get
the following message: "The file has been deleted from the file system.
Do you want to save your changes or close the editor without saving?"

How do I get this file to close in the editor view, when it is deleted
from the explorer?

Thanks
Shane
Re: delete from explorer AND editor window [message #459757 is a reply to message #459742] Mon, 15 August 2005 16:24 Go to previous message
shane is currently offline shaneFriend
Messages: 11
Registered: July 2009
Junior Member
Ok, i managed to get things working. I added the following code to the
resourceChanged methond:

if( event.getType() == IResourceChangeEvent.POST_CHANGE )
{
if( !( (FileEditorInput) editor.getEditorInput() ).getFile()
.exists() )
{
Display.getDefault().asyncExec( new Runnable()
{

public void run()
{
getSite().getPage().closeEditor(
MultiPageEditor.this,
false );
}
} );
}
}


......but i'm curious, why is this automatic for a single-page editor,
i.e. one that extends org.eclipse.ui.part.EditorPart, but for a multi-page
editor, i.e. one that extends org.eclipse.ui.part.MultiPageEditorPart (as
in my case), this functionality of closing the editor when a file is
deleted, has to be implemented manually!

Any thoughts?
Previous Topic:DOTEclipse
Next Topic:ProgressMonitorDialog problem!!!!
Goto Forum:
  


Current Time: Wed Apr 14 09:10:15 GMT 2021

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

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

Back to the top