Skip to main content



      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 03:05 Go to next message
Eclipse UserFriend
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 03:18 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: automatically adding a xtext nature to an existing file [message #893950 is a reply to message #893946] Fri, 06 July 2012 03:44 Go to previous messageGo to next message
Eclipse UserFriend
Edit: double post

[Updated on: Fri, 06 July 2012 03:59] by Moderator

Re: automatically adding a xtext nature to an existing file [message #893952 is a reply to message #893946] Fri, 06 July 2012 03:45 Go to previous messageGo to next message
Eclipse UserFriend
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 03:52 Go to previous messageGo to next message
Eclipse UserFriend
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 03:57 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: automatically adding a xtext nature to an existing file [message #893957 is a reply to message #893953] Fri, 06 July 2012 03:58 Go to previous messageGo to next message
Eclipse UserFriend
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
Re: automatically adding a xtext nature to an existing file [message #894481 is a reply to message #893957] Mon, 09 July 2012 07:48 Go to previous message
Eclipse UserFriend
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: Mon Jul 07 00:38:55 EDT 2025

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

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

Back to the top