5, define actions
(1) Operation overview
l In the Eclipse workbench, the action is the command that the application user triggers.
l General, action can be divided into three different types: buttons, tools and menu items
l When performing actions within the table, the running RUN method performs its specific function in the application.
L In addition to the action class, the action can also have other properties to be used to control actions in the workbench, including text tags, tooltips, and icons.
l There are two actions in the Google application of this tutorial: a to exit the application (menu item action), another allows the user to activate the license key wizard by clicking the License Key button in the Search view (button action)
(2) Definition org.eclipse.ui.ViewActionS extension
Point = "Org.eclipse.ui.ViewActions"> Targetid = "com.xqtu.igoogle.views.searchview" ID = "com.xqtu.igoogle.views.contribution"> Toolbarpath = "additions" Label = "License Key" Tooltip = "Google License Key" Class = "com.xqtu.google.Actions.LicenseKeyAction" STYLE = "push" State = "false" ID = "com.xqtu.igoogle.Actions.LicenseKeyAction" /> viewcontribution> extension> l The action in the view, you need to define org.eclipse.ui.ViewActions extensions in Plugin l L Ø ToolBarpath: A nomenclature in the target view toolbar, the default is additions; similar MenuBarPath properties correspond to the drop-down menu Ø Label: Action Label Ø Tooltip: Tools Tool Tips for Works Ø Class: Realize the full path of the class of org.eclipse.ui.iviewActionDelegate interface (view action agent) Ø Style: The style of action can be Push, Radio or Toggle Ø State: When the style of action is Toggle, the initial state of the specified action Ø ID: Unique identification of the action (3) Creating a licenseKeyAction class Package com.xqtu.google.Actions; Import org.eclipse.jface.action.IAction; Import org.eclipse.jface.viewers.Iction; import org.eclipse.jface.wizard.wizarddialog; Import org.eclipse.ui.iviewActionDelegate; Import org.eclipse.ui.iviewpart; Import com.xqtu.igoogle.views.searchview; Import com.xqtu.google.wizards.LicenseKeywizard; Public class licenseKeyaction imports iViewActionDelegate { PRIVATE SEARCHVIEW SEARCHVIEW; Public void init (iViewPart view) { This.SearchView = (searchview) View; } Public void run (IAAADITION Action) { LicenseKeyWizard Wizard = new licenseKeyWizard (); WizardDialog Dialog = New WizardDialog (SearchView.getViewsite () .getshell (), wizard; Dialog.open (); } Public void SelectionChanged (IADITION Action, ISELECTION Selection) { } } licenseKeyAction action class implements the iViewActionDelegate interface; save the target view object in the init method; activate the License Key Wizard by WizardDialog in the RUN method