Plug-ins Crash Course Roland Overgaauw e-mail: [email protected] Plug-ins Crash Course Wat is Eclipse • een opensource framework • een kernel & een verzameling Plug-ins Eclipse Bouwstenen Workbench UI (bestaat uit plug-ins) Gui JFace perspectives editors views dialogs etc... SWT Help Team Workspace/Resources Platform Core (load en execute plugins) plug-ins afhankelijk van plug-ins extention points plug-ins Tool 2 Tool 1 Tool 4 Tool 3 Java Devl Tool Workbench UI Platform Core Wat is een Plug-in(1) Wat is een Plug-in(2) • directory in [INSTALL]/plugins [INSTALL] Plug-ins Wat is een Plug-in(3) • must have – directory – plugin manifest: plugin.xml – (jar file) Hello Frodo (1) wizard 1 • The hard way / The Easy way – File -> new -> Project – of klik Hello Frodo (2) wizard 2 Hello Frodo (3) wizard 3 Hello Frodo (3) wizard 4 Hello Frodo (4) wizard 5 Hello Frodo (5.1) easy 1 Hello Frodo (5.1) easy 2 Hello Frodo (5.1) easy 3 Hello Frodo (5.1) easy 4 Hello Frodo (5.2) easy 5 Hello Frodo (6) result Hello Frodo (7) plugin.xml 1 <?xml version="1.0" encoding="UTF-8"?> <?eclipse version="3.0"?> <plugin id="nl.java2.demo.plugin02" name="Plugin02 Plug-in" version="1.0.0" provider-name="java 2 nl" class="nl.java2.demo.plugin02.Plugin02Plugin"> <runtime> <library name="plugin02.jar"> <export name="*"/> </library> </runtime> <requires> <import plugin="org.eclipse.ui"/> <import plugin="org.eclipse.core.runtime.compatibility"/> </requires> </plugin> Hello Frodo (8) plugin.xml 2 • plugin.xml - Manifest – dependencies • welke andere plugins heb ik nodig – runtime • waar kan ik mijn classjes vinden (jarfile) – extentions • welke andere extention point(s) gebruik ik – extentionspoint • welke nieuwe extention point(s) lever ik Hello Frodo (9) extensions page Hello Frodo (10) add extension Hello Frodo (11) choose extension point Hello Frodo (12) add actionSet Hello Frodo (13) add menu Hello Frodo (14) add ction Hello Frodo (15) add separation Hello Frodo (16) add ActionClass Hello Frodo (17) add ActionClass Hello Frodo (18) ActionClass package nl.java2.demo.plugin02; import import import import org.eclipse.jface.action.IAction; org.eclipse.jface.viewers.ISelection; org.eclipse.ui.IWorkbenchWindow; org.eclipse.ui.IWorkbenchWindowActionDelegate; public class MyAction implements IWorkbenchWindowActionDelegate { private IWorkbenchWindow workbenchWindow; public MyAction() { } public void run(IAction action) { MessageDialog.openInformation(workbenchWindow.getShell(), "Plugin02 Plug-in", "Hello, Frodo” ); } public void selectionChanged(IAction action, ISelection selection) } public void dispose() { } public void init(IWorkbenchWindow window) { workbenchWindow = window; } } { Hello Frodo (19) testen Hello Frodo (20) perspective Hello Frodo (21) commands Hello Frodo (22) result 1 properties van (menu) Hello Frodo (23) result 2 Hello Frodo (24) deploying plug-ins Hello Frodo (25) deploying plug-ins Hello Frodo (26) finished extention points (1) Perspectives Editors Views extention points (2) perspectives • ui.perspectives – niewe workbench perspectives en default layout • ui.perspectiveExtensions – toegevoegde waarde aan bestaande perspectives extention points (3) editors & views • ui.editors – editors in de editors pane • ui.editorActions – toevoegen van Actions aan bestaande editors menu of toolbar • ui.views • ui.viewsActions extention points (4) actions • ui.actionsSets – User actions in menu’s, toolbars • ui.actionsSetPartAssociations – Verbinding tussen actions en componenten • ui.popupMenus extention points (5) • ui.commands – Shortcuts via Keyboard – (Windows -> Preferences -> Workebench -> Keys) • ui.dropActions – sleur n pleur extention points (6) • • • • ui.preferencePages ui.propertiesPages ui.startup ui.workingSets extention points (7) Gandalfs • ui.exportWizards • ui.importWizards • ui.newWizards – extends org.eclipse.jface.wizard.Wizard – implement org.eclipse.ui.INewWizard – methode addPage() gebruiken om WizardPage toe te voegen. extention points (8) help • ui.markerHelp – toeveoegen van help markers • ui.markerResolution – class MarkerResolutionGenerator – voor gebruik van QuickFix functies • help.contexts • help.support • help.ui.browser Q&A Thanx! presentatie te bekijken op http://www.xs4all.nl/~rfover