As probably most of the you know, Eclipse is not just a development environment (IDE), but also - and perhaps above all - the software development platform on which "by chance" was a great IDE. Underlying all this is OSGi, for which we will wipe them create applications for Eclipse platform. Even the basic meaning of existence in Eclipse - plugin - is actually packages (bundle) OSGi.
decided to bring some topics for building applications based on Eclipse, and today's column, as required by tradition, provides a basic Hello World in the world of the Eclipse Platform.
to create the simplest of the project does not take much - just installed Eclipse PDE (Plugin Development Environment). I would use the version 3.3 which I have just appended PDE.
Before we begin, you need a brief theoretical introduction. One of the basic concepts of Eclipse is the point extensions (Extension Point). Using extension points our plugins can enrich the functions of existing plug-ins (including those indigenous Eclipsowe), and also allow other plugins to extend its functionality. For example, Eclipse provides Extension point through which we can add additional menu to the top menu (which will show in a minute).
On the other hand, imagine an application that is used to convert bitmap images such as different graphic formats. Open the BMP file and the window we see a combo box with available target image formats. The Eclipse platform design of such applications can benefit from the modularity and extensibility, if each converter will do as an extension (extension), shared his point of extensions (Extension point'a). The platform allows download all the extensions that "wpinają" in a given point, so it is very easy to create a list of available target formats conversion. If we decide to add a converter to the new file format, simply to declare (via XML), that it also plugs in a given point extensions and no modification of existing code it is available in the application.
Extension Point is named (eg pl.kadamczyk.bmpconverter) and the definition in the form of XSD. The creation of points of expansion will not go far, but I hope that I can write about this in the future. Highlights for now, to remember that the point of contact extension is a place where modules can provide its functionality to other modules.
Ok, first let's make this last przydługawym first, very simple project:
Determine the name of the project, without changing the other options:
On the following screens do not change any options and finish the wizard which, after completion of his work opens a graphical editor plugin.xml file. will want to add our Eclipse menu, and select it, after selecting the info window is displayed.
To this end, open the Extensions tab . On this tab, define how the plugin is to expand our "environment" (ie, creating Eclipse plug-ins in this case). We want to add the item to the top menu, Eclipse, and this is the point extensions org.eclipse.ui.actionSets . On the Extensions, select Add, and in the available text field Extension point type filter org.eclipse.ui.actionSets. Close the window, which adds the extension. Now you need to configure this extension. Extension point
actionSets contains have an element that you configure like this:
Then add to the menu is configured Action Set. Right click on "First action set", select New-> menu. label type such as "Menu" Hello World "- it will appear in the menu bar when you start Eclipse. Let's leave the automatically generated ID (PluginHelloWorld.menu1)
analogy to the menu, then add a separator, without changing its properties (generated ID: "PluginHelloWorld.separator1").
At the end of the same action set way to add an action (action) and configure it like this:
Left yet to define the most important, or what action is to do. This editor allows you to name the class that is responsible for the operation of share class as a parameter the bottom of the drawing. You can also click on the link class which will run the mini-wizard. Simply select the package and enter the name of the class, and the wizard himself, "be up" the class with appropriate methods, which we have "only" fill:
define the class of shares as follows:
sampleeclipseplugin package;
org.eclipse import. jface.action.IAction;
org.eclipse.jface.dialogs.MessageDialog import;
import org.eclipse.jface.viewers.ISelection;
org.eclipse.ui.IWorkbenchWindow import, import
org.eclipse.ui.IWorkbenchWindowActionDelegate;
public class implements SayHelloAction IWorkbenchWindowActionDelegate {
private IWorkbenchWindow window;
public void dispose () {
/ / empty
} public void init (final IWorkbenchWindow window) {
this.window = window;
} public void run (final IAction action) {
MessageDialog.openInformation (window.getShell ( ), "Hello!"
"I'm the first plugin for Eclipse");}
public void selectionChanged (final IAction action, final
ISelection selection) {
/ / empty
}}
At this point the plugin.xml file looks like this:
plugin to start moving the first tab editor plugin.xml file, and there in the Testing section, choose the Launch an Eclipse application. Running is a new instance of Eclipse with an accompanying our plugin. In the top menu is already visible extension defined by us (new menu item).
\u0026lt;? xml version = "1.0" encoding = "UTF UTF-8 "?>
\u0026lt;? eclipse version =" 3.2 "?>
\u0026lt;plugin>
\u0026lt;extension
id="myActionSet"
point="org.eclipse.ui.actionSets">
\u0026lt; ; actionSet
id = "PluginHelloWorld.actionSet1"
label = "My simple plugin"
visible = "true">
\u0026lt;menu
id = "PluginHelloWorld.menu1"
label = "My free menu">
\u0026lt;separator
name="PluginHelloWorld.separator1">
\u0026lt;/ separator>
\u0026lt;/ menu>
\u0026lt;
class action = "sampleeclipseplugin.SayHelloAction"
id = "PluginHelloWorld.action1"
label = "Przedstaw sie"
menubarPath = "PluginHelloWorld.menu1/PluginHelloWorld.separator1">
\u0026lt;/ action>
\u0026lt;/ Actions>
\u0026lt; / extension>
\u0026lt;/ plugin>
That way we finished the first, simplest plugin for Eclipse - maybe he has not advanced "ficzerami," but this is the first step to create something interesting. I'll try one of the following posts to extend the functionality plug-and - who knows - maybe the way manages to create something useful;)
0 comments:
Post a Comment