Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » automatically adding a xtext nature to an existing file
automatically adding a xtext nature to an existing file [message #893942] Fri, 06 July 2012 07:05 Go to next message
Juliane Mueller is currently offline Juliane MuellerFriend
Messages: 30
Registered: August 2011
Member
Hello!

In my project a new temporary editor-file is built by clicking on a button. This file ends everytime on ".calculation". Furthermore an anomaly of this file is that it does not belong to a project.
Now I want to add my xtext-nature to this file.
I've tried it with tis code:
public class NatureAddingEditorCallback extends AbstractDirtyStateAwareEditorCallback {
	
	@Inject
	private ToggleXtextNatureAction toggleNature;

	@Override
	public void afterCreatePartControl(XtextEditor editor) {
		super.afterCreatePartControl(editor);
		IResource resource = editor.getResource();
		if (resource!=null && resource.getName().contains(".calculation")){		
                        toggleNature.toggleNature(resource.getProject());
		}
	}
}


But this method is not called.
Can you help me, please?

Nice regards
Jule
Re: automatically adding a xtext nature to an existing file [message #893946 is a reply to message #893942] Fri, 06 July 2012 07:18 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
How did you bind the callback?

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: automatically adding a xtext nature to an existing file [message #893950 is a reply to message #893946] Fri, 06 July 2012 07:44 Go to previous messageGo to next message
Juliane Mueller is currently offline Juliane MuellerFriend
Messages: 30
Registered: August 2011
Member
Edit: double post

[Updated on: Fri, 06 July 2012 07:59]

Report message to a moderator

Re: automatically adding a xtext nature to an existing file [message #893952 is a reply to message #893946] Fri, 06 July 2012 07:45 Go to previous messageGo to next message
Juliane Mueller is currently offline Juliane MuellerFriend
Messages: 30
Registered: August 2011
Member
I've bound it this way:
public class CalculationUiModule extends de.dlr.virsat.calculation.model.ui.AbstractCalculationUiModule {
	public CalculationUiModule(AbstractUIPlugin plugin) {
		super(plugin);
	}
	
	 public Class<? extends org.eclipse.xtext.ui.editor.IXtextEditorCallback> bindIXtextEditorCallback() {

		// return your version of the NatureAddingEditorCallback
		return NatureAddingEditorCallback.class;
		}
}
Re: automatically adding a xtext nature to an existing file [message #893953 is a reply to message #893952] Fri, 06 July 2012 07:52 Go to previous messageGo to next message
Juliane Mueller is currently offline Juliane MuellerFriend
Messages: 30
Registered: August 2011
Member
Maybe it is because I don't have a project to add the xtext-nature on?
Is it possible to add the xtext-nature only to a file without project?
Re: automatically adding a xtext nature to an existing file [message #893956 is a reply to message #893952] Fri, 06 July 2012 07:57 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hmm looks good so far - recheck this adding the override annotation

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: automatically adding a xtext nature to an existing file [message #893957 is a reply to message #893953] Fri, 06 July 2012 07:58 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
No you need an .mydsl file contained in a project

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Re: automatically adding a xtext nature to an existing file [message #894481 is a reply to message #893957] Mon, 09 July 2012 11:48 Go to previous message
Jonathan Blakes is currently offline Jonathan BlakesFriend
Messages: 4
Registered: February 2011
Junior Member
This might be relevant: code.google.com/p/protobuf-dt/source/browse/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/builder/nature/AutoAddNatureEditorCallback.java
Previous Topic:How to know the information of project during Lexical analyzing
Next Topic:manage syntax highlighting
Goto Forum:
  


Current Time: Sat Apr 20 02:16:30 GMT 2024

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

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

Back to the top