Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » IFile Open Listener(Problems listening to an open event!)
IFile Open Listener [message #528578] Wed, 21 April 2010 07:23 Go to next message
Alexander Mack is currently offline Alexander MackFriend
Messages: 100
Registered: July 2009
Senior Member
Hello @ all,
I have got a problem concerning IFIles:

If I open an IFile in my own view I have to do xy.
The problem is, I need to do xy if I am opening the IFile outside of my view, too.

Example:
Open IFile via MyView should call the method xy.
Open File via PackageExplorer should call the same method.

Is this possible?

I tried to add a ResourceChangeListener with an IResourceDeltaVisitor but it seems that the IResourceDelta.OPEN flag is never in use.
The delta visitor will not get called if I open the file!?

I would appreciate any help, because atm I have no idea how to solve that problem!

Thanks in advance.

Alex
Re: IFile Open Listener [message #528595 is a reply to message #528578] Wed, 21 April 2010 08:37 Go to previous message
Devi Vara Prasad Bandaru is currently offline Devi Vara Prasad BandaruFriend
Messages: 100
Registered: March 2010
Location: Hyderabad
Senior Member

Hi Alex,
Add an org.eclipse.ui.IPartListener to the active workbench page(IWorkbenchPage) and implement the partOpened method like this

public void partOpened(IWorkbenchPart part) {
		if (part instanceof IEditorPart) {
			IEditorInput editorInput = ((IEditorPart) part).getEditorInput();
			if (editorInput instanceof IFileEditorInput) {
				IFile file = ((IFileEditorInput) editorInput).getFile();
				if (file.getName().endsWith(".xml")) { // replace this with desired condition
					System.out.println("Xml file openend ");// call xy method here
				}
			}
		}
	}


Previous Topic:Contribution Item on status line still visible if status line is set invisible
Next Topic:Multilanguage Preferences -> Help page
Goto Forum:
  


Current Time: Sat Sep 21 03:58:08 GMT 2024

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

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

Back to the top