In the user interface, how to display an extension, where is it displayed?
This is a gentle tip that we have got an answer. We want to display the context menu options for one or more selected methods, which allow us to change the visibility of the method only with one action. We prefer to use these menu options anywhere where you can display methods, such as in the Hierarchy view and Package Explorer. This takes us to the next question.
How often is it to extend the user interface?
By an example to learn more interesting, the Plug-In Project Wizard can help, it provides some sample code, we can modify these code to meet our needs. We will answer several questions in the wizard, which will automatically launch a specialistic perspective for plug-in development, called Plug-in Development Environment (PDE) to prepare tests. The wizard contains many examples that can help us start. In fact, our old friend "Hello World" is there. In order to follow this tradition, we will generate this "Hello World" to view the results to verify that the environment is installed correctly, then modify it to help us answer the current problem and bring us to the next question: Extended the user interface How do I know a basic event similar to "Select"? This is important because we want to apply our newly introduced menu options to the currently selected method.
Note that these instructions assume that you are starting with a new Eclipse installation. If you modify the environment or change the preferences, it may not be entirely as follows. You can consider launching Eclipse from a new work space: Open the command prompt window, change it to
/ Eclipse directory, then start Eclipse using the -Data parameter, as shown in Listing 1.
Listing 1. Start a new Eclipse instance
CD c: /eclipse2.1/eclipse
Eclipse.exe -data WorkspaceDevworks
Create a plugin project from using the New Plug-In Project Wizard. Select File> New> Project. In the New Project dialog, select Plug-in Development and Plug-In Project in the Will List, then select Next. Name the project com.ibm.Lab.Helloworld. The wizard will create a plug-in identity based on this name, so it must be unique in the system (the same is true, the project name, and the plug-in identification). Use the recommended default workspace location below to "Project Contents" is ok; select Next.
On the next page, select Next to accept the default plugin project structure. The plug-in code generator page recommends many samples, wizards can help you further parameterize the project. Select the "Hello, World" option and select Next. Next page (shown in Figure 4) It is recommended to recommend a plug-in name and plugin class name. These names are based on the last word of the plug-in project com.ibm.Lab.Helloworld. This example does not require any plug-in convenience method, so unpacking the selection of three code generation options (as shown in Figure 4), then select Next (not finish; you still have a page).
Figure 4. Simple Plug-in Content
You can specify parameters in the next page (shown in Figure 5), which is unique to "Hello, Worlds" example, such as the message to be displayed.
Figure 5. Sample Action Set To simplify the generated code, change the target package name of the action from com.ibm.Lab.HelloWorld.Ibm.Lab.HelloWorld, which is the same as the name of the project. Although in the actual plug-in, you can choose to group related classes with different packages, but in this case, there are only two classes, so don't do this. This also follows the same practice as the "master" package name and project name. Select Finish now.
You should see a message: "Plug-inscription to Compile Java Classes in this plug-in all currently disabled. The Wizard Will Enable Them To Avoid Compile Errors." Select OK to continue. If this is a new work space, you will also see another information message: "This Kind of Project is associated with the plug-in development personpective. Do you want to switch to this perspection.?". Select YES to switch according to the recommendations of this message.
To verify that all things are set correctly, let us test new plugins. Select Run> Run as> Run-Time Workbench. This will start the second instance of Eclipse, which will contain your plugin. This new instance will create a new space directory called Runtime-Workspace, so don't worry; any tests made to this instance will not affect the development settings. You should see similar to Figure 6, where there is a new drop-down menu, which is the Sample Menu, which has a single option sample action. Select it will display the following message. If you are not starting from a new workspace, you can choose Window> Reset Perspective to view the newly generated drop-down menu; this menu will not be displayed from the existing workspace, because the workbench "remember" What is the last Eclipse runtime? The set is active (you can also add / delete the operation set on the Window> Customize Perspective ... drop-down menu option).
Figure 6. Hello, Eclipse World
Let's quickly browse the plug-in list file plugin.xml. Double-click it to open it in the Plug-In Manifest Editor. This editor provides several pages similar to the wizard and a "original" source page. Transfer to the source code page by selecting the Source tab. You will see the code similar to the code displayed below; we are interested in the part of the bold display.
Listing 2. "Hello, World" plugin.xml
Point = "org.eclipse.ui.actionsets" >> Label = "Sample Action SET" Visible = "True" ID = "com.ibm.lab.helloWorld.AnctionSet">