收藏 分享(赏)

Eclipse+Plug-in+开发参考.pdf

上传人:HR专家 文档编号:6616878 上传时间:2019-04-18 格式:PDF 页数:32 大小:433KB
下载 相关 举报
Eclipse+Plug-in+开发参考.pdf_第1页
第1页 / 共32页
Eclipse+Plug-in+开发参考.pdf_第2页
第2页 / 共32页
Eclipse+Plug-in+开发参考.pdf_第3页
第3页 / 共32页
Eclipse+Plug-in+开发参考.pdf_第4页
第4页 / 共32页
Eclipse+Plug-in+开发参考.pdf_第5页
第5页 / 共32页
点击查看更多>>
资源描述

1、 Eclipse Plug-in 7? I Eclipse Plug-in 7? I S=K / S=K 1: 32: Eclipse Plug-in 7? I B c ECLIPSE Z 7 ? T .3 1.1 ECLIPSE q 3 1.2 Be 0 T F VIEW 4 1.2.1 I 5 1.2.2 q .7 = c ECLIPSE q 7 ? .9 2.1.1 T =Bt V j Fq .9 2.1.2 T Z . 11 c JDT 7? 18 c PDE 7? 19 4.1 q 7? U .20 4.1.1 i jm 20 4.1.2 i jm T“ .21 4.1.3 jm j

2、m T “ .22 4.1.4 I 24 4.1.5 i jm Z .26 c ECLIPSE PLUG-IN API28 5.1 .28 5.1.1 q “d .28 5.1.2 .29 5.2 .30 5.2.1 IWorkbench 30 5.2.2 IWorkbenchPage 31 5.2.3 IWorkbenchPart .31 5.2.4 IWorkbenchWindow31 5.2.5 IWorkbenchSite 32 5.2.6 IPageSite32 5.2.7 IWorkbenchPartSite .32 S=K 2: 32: Eclipse Plug-in 7? I

3、Bc Eclipse Z 7? T 1.1 Eclipseq Eclipse ZB Q y b Z “dlBt H q VNF ?b 10“dJava Team Debug import org.eclipse.swt.widgets.Label; import org.eclipse.swt.SWT; import org.eclipse.ui.part.ViewPart; public class HelloWorldView extends ViewPart Label label; public HelloWorldView() public void createPartContro

4、l(Composite parent) label = new Label(parent, SWT.WRAP); label.setText(“Hello World“); public void setFocus() / ! B widget V V A L= ? createPartControlZE LCb OKC X B jm LC C 5 i | F T b * Eclipseq 1Y X1F j mb YV Z org.eclipse.ui.views Z bYV4 b q plugin.xml Z bq q q #F Zb S=K 5: 32: Eclipse Plug-in 7

5、? I Nq ql a S Mb U Aqb q P T SWT APIyNA U org.eclipse.uibA V b u | helloworld.jar | o b K 2 q_ ZFb org.eclipse.ui.views Z + bn5 jm Z 2 Y bT A U jm V P Y | M1 j m“ B b l 1- Y “Hello” L P A U 1-Fb jm 2 BS M i 4 S=K 6: 32: Eclipse Plug-in 7? I jm LC b jm “Hello Greetings” |A U “A U jm ” jmS5 b q bq P S

6、 Mb Y ZYl1S M jm Z YS M b 1 l q S Mb Y S M P Java - L X q Bb - P+ 1- %b 7 TqS M -z B M5E P b5| 4sO AS M b E Z P M S Mb b X P S M - org.eclipse.examples.helloworld S M Bb N ZE V qi tS M M1b N H X LC jmiq b 2 Fb C1|q L V b 1.2.2 q n5 plugin.xml q l plugin id 7yB “ c | helloworld.jar plugin.xml qb b|qC

7、b eclipse plugin “ c/ V qB“ T -T 511 b H |“d q V q V bN V: c q F Z b T |sqb q$ V P 3 g A U j m A qXF jmb S=K 7: 32: Eclipse Plug-in 7? I N t jm V -i jmb VYV4 AF jm Ini jm b|A U jm Y# B Y/ c jm Vb YV PqV sX org.eclipse.ui.views Z4 Z qT V7y jm Vb “z X| “Hello Greetings” jmF Y “Hello”/ A U jm3 gb S=K 8

8、: 32: Eclipse Plug-in 7? I Y jmS| V plugin.xml Z S:b N H q plugin.xml 2 P T “Hello” YB “Hello View” jmb LC jmb %A U jm - b TVA U jm V4 “Hello Greetings” jm 5T |q Li S jm iT A U jm# jmbC b Bq =c Eclipse q 7? V 0 Xv Eclipse Plug-in Z Z 7? T/ A AT Z# ZZEb 2.1.1 T =Bt V jFq X P T V U “ Hu 73 g ”b P T H

9、T 3 g IWorkbenchWindowbT 3 g T )3 gb i a a a y Z T : O bY 1 T 3 g I b 1 * S=K 9: 32: Eclipse Plug-in 7? I bV4 AT c jmI bBt LCT 3 gb 2.1.1.1 : T 3 g = |?CB: IWorkbenchPage 9cqb : |qsFLCbY 1: I | A )I k /b 2.1.1.2 i jm i jmT : =4FFbi jml jmat jm V T a“b WM H Vi jmW MbV LC Ai jm e t jmA UT : i et jmvlb

10、i jmYI b 2.1.1.3 jmI jmI LCW% -15 BtnqIb| V jFqFT H A %X1 LC jm I b %$ jmY Qu 7I A UI b t jm T uQb v jmA U1I b jm V ib I Y I bI TN “u 7 i 1 ” q“dI *“b I Java I T I U b B f /| n y jmI b LC createPartControl Z E 7yV U V jFq SWT l3 gb A 1 P tl3 gis A U jmI M1 b jmI H | l setFocus Y V| ! l3 gb 1 jmI H |

11、 l“ hV U1 jmI bN HX“ createPartControl s eq A“ jmI s m ;SamS38 b S=K 10: 32: Eclipse Plug-in 7? I T jmI b l3 g e V 1 P eb 5 -y Hello World jm H A Ke jmbC Q A A import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.SWT; import org.eclipse.ui.part.ViewP

12、art; public class HelloWorldView extends ViewPart Label label; public HelloWorldView() public void createPartControl(Composite parent) label = new Label(parent, SWT.WRAP); label.setText(“Hello World“); public void setFocus() / ! B widget V b i 1 LC dispose() ZE y TV createPartControl(parent) ZE7y B

13、Labelb T Xs m38 5N)|1“ b Z ViewPart yN Z dispose() “ T ” LCb 2.1.2 T Z T l Z t Z q|FC jmI jmI 4LCb |V BT “ 1 q iT Z At ZFb/mA U1 q FT Bt ?q S=K 11 : 32: Eclipse Plug-in 7? I 2.1.2.1 org.eclipse.ui.views Z org.eclipse.ui.views q| jmFT b 4 jmY MI b jm g IViewPart l q V4 Z ViewPart 7 i u LC IViewPartb

14、YV Z ViewPart createPartControl Z E S=K 12: 32: Eclipse Plug-in 7? I M1 q 1 3 6 7 13 14 1-2 Zb 3-6l jm s b 7-13l j mBt b 2.1.2.2 org.eclipse.ui.viewActions qT Xi jmF nb YV org.eclipse.ui.viewActions Z bN Z q C j m / F a0 H“b S=K 13: 32: Eclipse Plug-in 7? I M1 q 1 2 5 14 15 16 17 1 Zb 2-16 jmF b 3 B

15、S M jmFb 4 targetID | TF “S jmb t F Tb 6-8 S|# T b 13-14 THqb V A B4 enablesFor=“1“ IFile class=“org.eclipse.core.resources.IFile“ q Z name=“*.readme“ “.readme” H| N Tb *z t H ? 3 f b 12 T LC ViewActionDelegateA L C IViewActionDelegate g S=K 14: 32: Eclipse Plug-in 7? I public void run(org.eclipse.j

16、face.action.IAction action) MessageDialog.openInformation(view.getSite().getShell(), MessageUtil.getString(“Readme_Editor“), MessageUtil.getString(“View_Action_executed“); 2.1.2.3 org.eclipse.ui.editors q PT Z org.eclipse.ui.editors |I FT b I BTq I Y q bI Z T q“dI V “ T bI 9 IEditorInputM1 b V| ATI

17、qb iI T -4tb I g IEditorPart l q V 4 Z EditorPart 7 iu LC IEditorPartb M1 q 1 2 9 1 Zb 7 extensions I V q b T1 8Bt V filenamesb class LCI i O contributorClass 34 I M1 Tb F |I M1 TFT b A LC IEditorActionBarContributor gb FI action1.setToolTipText(MessageUtil.getString(“Readme_Editor_Action1“); action

18、1.setDisabledImageDescriptor(ReadmeImages.EDITOR_ACTION1_IMAGE_DISABLE);action1.setImageDescriptor(ReadmeImages.EDITOR_ACTION1_IMAGE_ENABLE); . action2 = new RetargetAction(IReadmeConstants.RETARGET2, MessageUtil.getString(“Editor_Action2“); action2.setToolTipText(MessageUtil.getString(“Readme_Edito

19、r_Action2“); action2.setDisabledImageDescriptor(ReadmeImages.EDITOR_ACTION2_IMAGE_DISABLE);action2.setImageDescriptor(ReadmeImages.EDITOR_ACTION2_IMAGE_ENABLE); . S=K 16: 32: Eclipse Plug-in 7? I action3 = new LabelRetargetAction(IReadmeConstants.LABELRETARGET3, MessageUtil.getString(“Editor_Action3

20、“); action3.setDisabledImageDescriptor(ReadmeImages.EDITOR_ACTION3_IMAGE_DISABLE);action3.setImageDescriptor(ReadmeImages.EDITOR_ACTION3_IMAGE_ENABLE); . T mS 7 plugin.xml !b i T jm TS: A viewActions M b t T ! y 15 BI L W T Zb/f 7y T H I + L b I i O T1 T H | setActiveEditor h ?FbF|I T+I M public voi

21、d setActiveEditor(IEditorPart editor) . action1.setActiveEditor(editor); . A1 qI H TA UT b I H A Ut b V *“ b S=K 17: 32: Eclipse Plug-in 7? I 2.1.2.4 l T 7 Zb “T Z9d 1Z _ Z n Z ? Z b EBB P Z Ev M ? ps M Z L C Z tZE r 1- ? b 1M plugin.xmlqb Z V Eclipse b c JDT 7? “Java 7? ”JDT IaIra ka kI Java IIb JD

22、T q 7? Z Ob KeZE | JDT AT BFqtq|+ Java FB i_T F+ Java jmaI Tb JDT 4 ? Java IDE Hq/ I 1 P JDT API$ TyBqqT ?Bs Java T51/ B T P) Java 7y “a 3 Java a y_ 5b V P Java 4 VM “ Java H | ? Z ?F Java IDE if (myJavaProject = null) / the project is not configured for Java (has no Java nature) return; S=K 18: 32:

23、 Eclipse Plug-in 7? I / get a package fragment or package fragment root IJavaElement myPackageFragment = JavaCore.create(myFolder); / get a .java (compilation unit), .class (class file), or / .jar (package fragment root) IJavaElement myJavaFile = JavaCore.create(myFile); B Java V P JDT API R b V c J

24、ava =d Java private void createJavaElementsFrom(IProject myProject, IFolder myFolder, IFile myFile) . / get the non Java resources contained in my project. Object nonJavaChildren = myJavaProject.getNonJavaResources(); . $ ) DOM) Z Tb L= JDT 9 P DOM org.eclipse.jdt.core.dom c PDE 7? “q 7? ”PDE B T T H “ “VBq iclqqCq # | TZ Tb tq| T ui|A Ut # Java 5 A UT u jmb qB Q 7q l?Sb PDE “S 7yq HN?5 L itqb PDE YVi jm4 BF ZF jma I i jm PT = 7?q b

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报