accessing Statusline in Plug-ins
Workbenchwindow window = Platfromui.getworkbench (). Getactiveworkbenchwindow (); Istatuslinemanager status = Window.getstatuslinemanager (); Quit RCP program
Platformui.getworkbench (). restart (); Restart RCP application
Platformui.getworkbench (). restart ();
Look for perspective in the plug-in repository (other extend point resources are similar)
Iperspectivedescriptor IPD = Platformui.getworkbench (). Getperspectiveregistry (). Findperspectivewithid ( Favoriteperspective.id); Get the shell of the current RCP application
Shell shell = Platformui.getworkbench (). Getactiveworkbenchwindow (). Getshell (); Display Help information
Platformui.getworkbench (). Gethelpsystem (). Displayhelp (); Show memory
Platformui.getpreferencestore (). SetValue (Iworkbenchpreferenceconstants.show_memory_monitor, true); A method for capturing the image resource sharing of Eclipse platform
Platformui.getworkbench (). Getsharedimages (). Getimagedescriptor (Isharedimages.img_objs_info_task)); RCP (plug-in development) get Plug-in version information
/**
* Get Plugin version
* @return
*/
Public String getversion () {
Return ((Bundlehost) Getbundle ()). GetVersion (). toString ();
}
* Get a reference to a view in another view
Platformui.getworkbench (). Getactiveworkbenchwindow (). GetActivePage (). Findview ("Viewid"); How to restart the RCP program using code.
Platformui.getworkbench (). restart (); Several ways to get the parent shell
Iviewpart or Ieditorpart:
Ishellprovider Shellprovider = Vieworeditor.getsite ();
Platformui:
Shell Parentshell =
Platformui.getworkbench (). Getactiveworkbenchwindow (). Getshell ();
Display:
Shell Parentshell = Display.getdefault (). Getactiveshell ();
In a class that implements the Iworkbenchwindowactiondelegate interface:
Private Iworkbenchwindow window;
public void init (Iworkbenchwindow window) {
This.window = window;
}
public void Run (IAction action) {
Shell Parentshell = Window.getshell ();
Mydialog dialog = new Mydialog (Parentshell,);
etc
Get program Startup Parameters
string[] args = Platform.getcommandlineargs (); Closes a current perspective to open a new perspective
Iworkbench W=platformui.getworkbench ();
Actionfactory.iworkbenchaction closeperspectiveaction
= ActionFactory.CLOSE_PERSPECTIVE.create (W.getactiveworkbenchwindow ());
Closeperspectiveaction.run ();
Try ... {
Platformui.getworkbench (). Showperspective ("Com.ibm.demo.saic.ui.views.NextPerspective"),
W.getactiveworkbenchwindow ());
catch (Workbenchexception e) ... {
E.printstacktrace ();
Customize Console View toolbar: Remove the Open console and select in RCP console view
the console button.
Workbenchpage page = Platformui.getworkbench (). Getworkbenchwindows () [0].getpages () [0];
Iviewpart Viewpart = Page.findview (Iconsoleconstants.id_console_view);
Iactionbars Actionbar = Viewpart.getviewsite (). Getactionbars ();
Itoolbarmanager toolbarmgr = Actionbar.gettoolbarmanager ();
icontributionitem[] items = Toolbarmgr.getitems ();
for (Icontributionitem Item:items) {
if (item instanceof Actioncontributionitem) {
IAction action = ((Actioncontributionitem) item). Getaction ();
String text = Action.gettext ();
if (text.equals ("Open console") | | text.equals ("SELECT Console")) {
Toolbarmgr.remove (item);
}
}
}
Actionbar.updateactionbars (); If you don't need anything in the toobar, you can directly
Toolbarmgr.removeall (); You can see that there are a lot of menubar on RCP now, which we don't need, and you can simplify by adding the following code to the code
MenuBar
Iworkbenchpage page = Platformui.getworkbench (). Getworkbenchwindows () [0]
. GetPages () [0];
Iviewpart Viewpart = Page.findview (Iconsoleconstants.id_console_view);
//Iactionbars Actionbar = Viewpart.getviewsite (). Getactionbars ();
Itoolbarmanager toolbarmgr = Viewpart.getviewsite (). Getactionbars ()
. Gettoolbarmanager ();
//Itoolbarmanager toolbarmgr = Actionbar.gettoolbarmanager ();
icontributionitem[] items = Toolbarmgr.getitems ();
for (Icontributionitem item:items) {
if (item instanceof actioncontributionitem) {
IAction action = (Act Ioncontributionitem) Item). Getaction ();
String Text = Action.gettext ();
if (text.equals ("Open console")
| | text.equals ("SELECT Console")) {
Toolbarmgr.remove (item);
}
}
}
Viewpart.getviewsite (). Getactionbars (). Updateactionbars ();