Eclipse plug-in compiling (2) and eclipse plug-in compiling

Source: Internet
Author: User

Eclipse plug-in compiling (2) and eclipse plug-in compiling

In the previous article, I briefly wrote how to create an eclipse plug-in project. This time I wrote how to add several menus to the previous project, such as the menu bar menu, toolbar menu, and right-click menu.

To create a complete menu, you need to understand three extension points, namely menus, commands, and handlers. menus is the extension point of the menu. After the menu extension point is introduced, A menu is added when a menu is added. commands is a behavior extension point, that is, a behavior operation, such as eating and running, and handlers is a specific behavior operation extension point, the specific implementation of eating and running. A menu is associated with a command, and a command is associated with a handler.

 

Open the plug-in. xml file of the last project created by using the PVDF plug-in, open the Extensions tab,

package com.yunzaipiao.menu.handler;
 
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.jface.dialogs.MessageDialog;
 
public class SampleHandler extends AbstractHandler {
 
public SampleHandler() {
// TODO Auto-generated constructor stub
}
 
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
MessageDialog.openInformation(
null,
"Test plug-in ",
"The right-click menu is displayed! ");
return null;
}
 
}
 

After creating the implementation class, introduce the handler extension point to associate the extension point with the modified implementation class. Open the Add menu and command tab, and click Add:

Add a handler and configure it after selection:

CommandId: corresponds to the command created above

Class: Corresponding execution class, the execution class just created

 

 

Run the command to see the effect:

Right-click the plug-in project Run as> Eclipse Application, find a place in the new eclipse, right click, and the menu appears

A prompt box is displayed when you click the menu.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.