Review above: Customizing the Eclipse IDE's feature chapter (i) This article will record some of the eclipse plug-in features, Smart but useful.
first, set the encoding of the workspace text fileWorkaround: Execute this sentence in the Org.eclipse.ui.startup extension (only once):
Resourcesplugin.getplugin (). Getpluginpreferences (). SetValue ("Encoding", "UTF-8");
Second, the default display line number
Workaround: Execute this sentence in the Org.eclipse.ui.startup extension (only once):
Editorsplugin.getdefault (). Getpreferencestore (). SetValue ("Linenumberruler", "true");
Combo Control Display label Gets the valueIt's possible that we're going to get the value when the combo control displays the label, but gets it. WORKAROUND: Set the label and value:
Combo Combo = (Combo) Control;combo.removeall (); for (int i = 0; i < list.size (); i++) { deviceinfo obj=list.get (i); Combo.add (Obj.getname ()); // label Combo.setdata (i + "", Obj.getserialnumber ()); // Value}
Get Value:
String key = "" + Combodevice.getselectionindex (); String Value= string.valueof (Combodevice.getdata (key));
Iv. writing files, generating file encoding issuesAt first I wrote this file, but found that the other plugin read this file (in UTF-8), garbled (check the generated file encoding is ANSI):
New PrintWriter (new FileWriter (FilePath)); Pw.print (content); Pw.close ();
solutions;
New OutputStreamWriter (new FileOutputStream (FilePath), "UTF-8"); Outputstream.write (content); Outputstream.close ();
v. SYSTEM.OUT.PRINTLN can be displayed on the consoleIf your plugin does not do anything, then the content of the SYSTEM.OUT.PRINTLN output inside your plugin will not be displayed on the console. Workaround:
ImportJava.io.PrintStream;ImportOrg.eclipse.ui.console.ConsolePlugin;ImportOrg.eclipse.ui.console.IConsole;Importorg.eclipse.ui.console.IConsoleFactory;ImportOrg.eclipse.ui.console.IConsoleManager;ImportOrg.eclipse.ui.console.MessageConsole;ImportOrg.eclipse.ui.console.MessageConsoleStream; Public classConsolefactoryImplementsIconsolefactory {StaticMessageconsole console =NewMessageconsole ("Console log",NULL); Public voidOpenconsole () {showconsole (); } Public Static voidShowconsole () {if(Console! =NULL) {Iconsolemanager Manager=Consoleplugin.getdefault (). Getconsolemanager (); Iconsole[] Existing=Manager.getconsoles (); Booleanexists =false; for(inti = 0; i < existing.length; i++) { if(Console = =Existing[i]) exists=true; } if(!exists) {Manager.addconsoles (Newiconsole[] {console}); } manager.showconsoleview (console); Messageconsolestream Stream=Console.newmessagestream (); System.setout (NewPrintStream (stream)); } } Public Static voidCloseconsole () {Iconsolemanager Manager=Consoleplugin.getdefault (). Getconsolemanager (); if(Console! =NULL) {manager.removeconsoles (Newiconsole[] {console}); } } Public Staticmessageconsole Getconsole () {returnconsole; }}
This is the class I found on the Internet, in addition to calling Consolefactory.showconsole () before System.out.println;
vi. Hidden quickaccessSometimes we don't want to show the quickaccess in the upper right corner, we try to hide, not to say manual shut down. Workaround: Execute in org.eclipse.ui.startup extension (each time you open Eclipse):
Uijob JOBH =NewUijob ("Hide Quick access") {@Override Publicistatus runinuithread (Iprogressmonitor monitor) {Iworkbenchwindow window=platformui.getworkbench (). Getactiveworkbenchwindow (); if(Window = =NULL) returnStatus.cancel_status; if(WindowinstanceofWorkbenchwindow) {Mtrimbar Toptrim=( (Workbenchwindow) window). Gettoptrim (); for(Mtrimelement Element:topTrim.getChildren ()) {if("Searchfield". Equals (Element.getelementid ())) {Control Contorl=(Control) element.getwidget (); Contorl.setvisible (false); Break; } } } returnStatus.ok_status; }};jobh.schedule (0L);
PS: There is no way to find once and for all, the online legend of the style can be hidden is not possible.
vii. automatic updating of filesI'm talking about automatic file updates, not that eclipse is automatically updated, but that you're just updating some of the eclipse content. Here is a simple way to check the update, no-end service implementation. Service side: Just put these resources in the server, and the inside version is determined by a version.properties, each version corresponds to a record. Client: Each time eclipse is opened, the remote Version.properties file is automatically downloaded, compared to the local version.properties file. When there is a new version or the timestamp after the version has changed, download the file overwriting the local. Function Chapter first here, the other chapters to be continued. This article for the original article, reproduced please retain the original source, convenient traceability, if there is the wrong place, thank you correct.
This address: http://www.cnblogs.com/lovesong/p/4694522.html
Customizing the Eclipse IDE's features (ii)