Recently, I am engaged in android development. It is very troublesome to write the View variable associated with the id in the activity after the layout interface file is designed, why not automatically create variables after setting a view object in vc ++? So let me get an eclipse plug-in! Haha
1. Install the plug-in development environment: Eclipse plug-in development environment.
2. Create a Plug-in Project: File-> new-> Plug-in Development. After you select the Plug-in Project, you can select a template type. I will select Hello, world.
In the Overview of the MANIFEST. MF file, select Launch an Eclipse application under Testing to start the new eclipse. This eclipse is loaded with my plug-in.
To read the xml file of layout, you must find the path of the current file for easy reading.
Then, I want to retrieve the id and the corresponding type. For example, there is a Button whose ID is btSave. Why? I just need to display it in the terminal
Button btSave;
BtSave = (Button) findViewById (R. id. btSave );
You can.
Dependencies in the MANIFEST. MF file adds some plug-in support packages. Otherwise, some eclipse classes cannot be called.
Resource usage: org. eclipse. core. resources
Console: org. eclipse. ui. console
I also added org. eclipse. ui. ide
Now, let's start writing programs.
I want to get the address of the currently edited xml file.
> Get the currently edited object
IEditorPart activeEditor = PlatformUI. getWorkbench ()
. GetActiveWorkbenchWindow (). getActivePage (). getActiveEditor ();
If (activeEditor! = Null ){
IEditorInput editorInput = activeEditor. getEditorInput ();
If (editorInput instanceof org. eclipse. ui. part. FileEditorInput ){
Org. eclipse. ui. part. FileEditorInput input = (org. eclipse. ui. part. FileEditorInput) editorInput;
IPath path = input. getPath (); // This path is the currently edited xml file.
/** The next step is to parse the xml file and display the function in the eclipse console **/
}
For more information about how to display on the console: I will not do this.
Finally, you can package and release it. The Overview of MANIFEST. MF has an Export in the upper right corner. Export it as a jar file and put it in the eclipse plug-in directory. It is possible to start it.