Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » get current name file (get current name file )
get current name file [message #758514] Wed, 23 November 2011 14:33 Go to next message
samir  is currently offline samir Friend
Messages: 27
Registered: September 2011
Junior Member
hello
I created the short-cut from the handler class how do I get the file name?

**
* Our sample handler extends AbstractHandler, an IHandler base class.
* @see org.eclipse.core.commands.IHandler
* @see org.eclipse.core.commands.AbstractHandler
*/
public class SampleHandler extends AbstractHandler {
/**
* The constructor.
*/
public SampleHandler() {
}

/**
* the command has been executed, so extract extract the needed information
* from the application context.
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);
ISelection selection = HandlerUtil.getCurrentSelection(event);

IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
MessageDialog.openInformation(
window.getShell(),
"polyTime.ui",
selection.toString());
return null;
}
}


thanx
Re: get current name file [message #758517 is a reply to message #758514] Wed, 23 November 2011 14:41 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13465
Registered: July 2009
Senior Member
http://christiandietrich.wordpress.com/2011/10/15/xtext-calling-the-generator-from-a-context-menu/

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: get current name file [message #758548 is a reply to message #758517] Wed, 23 November 2011 16:08 Go to previous messageGo to next message
samir  is currently offline samir Friend
Messages: 27
Registered: September 2011
Junior Member
I'm not interested to Calling the Generator from a Context Menu.

what I want is when I run my Eclipse Application. and I do the short-cut, then get the name of the file on which I was writing.

thanks so much
Re: get current name file [message #758557 is a reply to message #758548] Wed, 23 November 2011 16:28 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13465
Registered: July 2009
Senior Member
Have a look at the blogpost.
there is a description for what you are doing

IEditorPart activeEditor = HandlerUtil.getActiveEditor(event);  
IFile file = (IFile) activeEditor.getEditorInput().getAdapter(IFile.class);  


~Christian


Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/xtext/
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Solution to content assist...Internal<project>Parser.java static initiailizer size limit
Next Topic:Error after creating a new eclipse instance
Goto Forum:
  


Current Time: Tue May 26 10:51:39 GMT 2020

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

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

Back to the top