RED
RED copied to clipboard
How can I launch a robot script in my own Eclipse-Plugin?
After installed red, I can launch the .robot script by press the "Run" key in Eclipse toolbar.
Now I am building a new Eclipse-Plugin (it depends on red), I need launch a robot script in my java code. I got the IFile object in robot project, how can I lanuch it (just like I press the "Run" key)?
By the way, How can I get the robot script editor's content in my plugin? I need the script content and the current line num.
Hi,
as you can see here: https://github.com/nokia/RED/blob/master/src/Eclipse-IDE/org.robotframework.ide.eclipse.main.plugin/META-INF/MANIFEST.MF we currently do not export anything through Export-Package directive in bundle manifest. This basically means that as for now our plugin do not expose any API which you can use.
What you need to do is to define your requirements and we should agree on the part of the API which we have to expose for you. For sure we do not want to expose everything because this would impose restrictions on us when it comes to making changes and normal daily development. In general the API should be stable, so exporting everything is not an option.
Without this you can only bypass our code: in this example you could theoretically create ILaunchConfiguration of proper ID filled with proper data for your IFile and launch it, but this would require implementation to be done on your side and additionally this would be also vulnerable for our changes if we do not consider those code an API.
As to the editor: you can do it using only eclipse API: you may look trough open editors pick the one you're interested in (by IFile or editor's id) and then you may call getAdapter(ITextEditor.class). This would give you access to IDocument from which content can be taken as well as to ISelectionProvider which would give you current selection inside the editor (although caret position may be different and it have to be taken from the control itself I think or from ISourceViewer).
Thanks, I think there are 3 APIs I need: /*lanuch a script/ void API.lanuchScript(IFile script, IMonitor monitor)
/*get current active editor's text, can return full text, or only text selected/ String API.getActiveEditorText(boolean onlySelectedText)
/** After the keyword, press ctrl+space will show the spec AutoComplete words For example, When there is a keyword "send mail ${sendto}", I can set a list of mail address to auto complete the ${sendto} arg */ void API.registerArgsAutoComplete(String key, String[][] argsAutoComplete)