|  | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> | 
|  | <html lang="en"> | 
|  |  | 
|  | <head> | 
|  | <meta name="copyright" content="Copyright (c) IBM Corporation and others 2000, 2018. This page is made available under license. For full details see the LEGAL in the documentation book that contains this page." > | 
|  | <meta http-equiv="Content-Language" content="en-us"> | 
|  | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> | 
|  | <meta name="GENERATOR" content="Microsoft FrontPage 4.0"> | 
|  | <meta name="ProgId" content="FrontPage.Editor.Document"> | 
|  | <link rel="STYLESHEET" href="../book.css" type="text/css"> | 
|  | <script language="JavaScript" src="PLUGINS_ROOT/org.eclipse.help/livehelp.js" type="text/javascript"></script> | 
|  | <title>PDE Tips and Tricks</title> | 
|  | </head> | 
|  |  | 
|  | <body> | 
|  |  | 
|  | <h2>Tips and Tricks</h2> | 
|  |  | 
|  |  | 
|  | <table border="1" cellpadding="10" cellspacing="0"> | 
|  | <tr> | 
|  | <td valign="top" align="left" width="20%"><b>Reference an existing target inside another one</b></td> | 
|  | <td valign="top" align="left" width="80%"> | 
|  | It is now possible to reference an existing target file inside another target: | 
|  | <p> | 
|  | <img src="images/include_target_1.png" alt="" /> | 
|  | </p> | 
|  | This could be used for different purposes: | 
|  | <ul> | 
|  | <li>You could use a target from a remote location (e.g. github-repository using http-protocol) in your local IDE.</li> | 
|  | <li>You could use a target deployed at a maven repository using the mvn:<groupid>:<artifactid>:<version> (this requires m2eclipse with PDE integration)</li> | 
|  | <li>You could extend an existing local target using eclipse-variables</li> | 
|  | <li>You could combine any of the above options</li> | 
|  | </ul> | 
|  |  | 
|  | </td> | 
|  | </tr> | 
|  | <tr> | 
|  | <td valign="top" align="left" width="20%"><b>Show Command Line button in PDE Launch Configuration</b></td> | 
|  | <td valign="top" align="left" width="80%"> | 
|  | You can view the command line used for launching the application by clicking the <b>Show Command Line</b> button on the PDE launch configuration dialog. | 
|  | <p> | 
|  | <img src="images/pde_show_command_line.png" alt=""> | 
|  | </p> | 
|  | </td> | 
|  | </tr> | 
|  | <tr> | 
|  | <td valign="top" align="left" width="20%"><b>Disable API analysis builder</b></td> | 
|  | <td valign="top" align="left" width="80%"> | 
|  | You can disable the API analysis builder on the <b>Plug-in Development</b> preference page. | 
|  | <p> | 
|  | <img src="images/pde-disable-analysis-builder.png" alt=""> | 
|  | </p> | 
|  | <p> | 
|  | </td> | 
|  | </tr> | 
|  | <tr> | 
|  | <td valign="top" align="left" width="20%"><b>Layout Spy tool</b></td> | 
|  | <td valign="top" align="left" width="80%"> | 
|  | To debug SWT layouts, you can activate the Layout Spy tool by using the shortcut <b>Ctrl+Alt+Shift+F9</b> from any window. | 
|  | <p> | 
|  | <img src="images/layout-spy.png" alt=""> | 
|  | </p> | 
|  | <p>Usage:</p> | 
|  | <ul> | 
|  | <li>Click <b>Select Control</b> then click the control you want to inspect.</li> | 
|  | <li>Enable <b>Show overlay</b> and navigate the widget hierarchy until you find a | 
|  | control whose boundary is correct (the red rectangle) and whose child's boundary | 
|  | is incorrect (the yellow rectangle).</li> | 
|  | <li>Look at the results of computeSize. If the result of computeSize is correct, | 
|  | the problem is in the parent layout or its attributes. Otherwise, the problem | 
|  | is in the child widget.</li> | 
|  | </ul> | 
|  | </td> | 
|  | </tr> | 
|  | <tr> | 
|  | <td valign="top" align="left" width="20%"><b>Change problem severity</b></td> | 
|  | <td valign="top" align="left" width="80%"> | 
|  | You can configure the severity of an API tools problem or PDE compiler problem by invoking the <b>Quick Fix</b> (<b>Ctrl+1</b>) which opens the | 
|  | corresponding preference page and highlights the configurable problem. | 
|  | <p> | 
|  | <img src="images/pde-configure-problem-pde-compiler.png" alt=""> | 
|  | </p> | 
|  | </td> | 
|  | </tr> | 
|  | <tr> | 
|  | <td valign="top" align="left" width="20%"><b>Workspace plug-ins overriding target plug-ins</b></td> | 
|  | <td valign="top" align="left" width="80%"> | 
|  | On the Plug-in Development preference page, there is an option to specify if workspace plug-ins should override target platform plug-ins | 
|  | with the same id. By default, this option is enabled. When disabled, all plug-in versions from workspace and target platform will | 
|  | be used and for a plug-in id, the best available plug-in will be chosen. | 
|  | <p> | 
|  | <img src="images/workspace-plugins-override-target.png" alt=""> | 
|  | </p> | 
|  | </td> | 
|  | </tr> | 
|  | <tr> | 
|  | <td valign="top" align="left" width="20%"><b>Support for OSGi Declarative Services Annotations</b></td> | 
|  | <td valign="top" align="left" width="80%"> | 
|  | OSGi Declarative Services provide a powerful mechanism for developing complex, service-oriented | 
|  | applications. With proper tooling, annotations added to Declarative Services make it easy | 
|  | to generate and maintain the required component descriptor files. | 
|  | <p> | 
|  | When enabled, PDE automatically generates and updates Declarative Services component | 
|  | descriptor files from appropriately annotated Java source. This is done without requiring | 
|  | any additional builder to be configured in your project. | 
|  | </p> | 
|  | <p> | 
|  | When you annotate your component implementation classes with <code>@Component</code>, and any | 
|  | reference bind methods with <code>@Reference</code>, PDE will validate your annotations | 
|  | and generate the corresponding component descriptor files. Any errors discovered during validation | 
|  | are highlighted and reported. | 
|  | </p> | 
|  | <p> | 
|  | In addition, PDE also maintains the project's MANIFEST.MF and build.properties file | 
|  | -- generated component descriptor files are automatically added to the manifest | 
|  | and included in the build. | 
|  | </p> | 
|  | <p> | 
|  | To enable this feature, go to <b>Preferences</b> or <b>Project Properties > Plug-in Development > DS Annotations</b> | 
|  | and check <b>Generate descriptors from annotated sources</b>. | 
|  | </p> | 
|  | </td> | 
|  | </tr> | 
|  | <tr> | 
|  | <td valign="top" align="left" width="20%"><b>Convert API Tools Javadoc tags to annotations</b></td> | 
|  | <td valign="top" align="left" width="80%"> | 
|  | Plug-ins using API Tools can add restrictions to API Java types (such as No Reference, No Extend) | 
|  | using Javadoc tags or annotations.  It is recommended that projects use annotations, so PDE | 
|  | provides a conversion wizard that will replace the tags with the equivalent PDE annotations. | 
|  | <p> | 
|  | The wizard is available by right clicking on an API Tools enabled plug-in project and selecting | 
|  | <b>Plug-in Tools > Convert API Tools Javadoc Tags</b>. | 
|  | </p> | 
|  | <p> | 
|  | A list of the available restrictions is available on the API Tools | 
|  | <a href="https://wiki.eclipse.org/PDE/API_Tools/Restrictions" target="_blank">wiki page</a>. | 
|  | </p> | 
|  | </td> | 
|  | </tr> | 
|  | <tr> | 
|  | <td valign="top" align="left" width="20%"><b>Show the current target platform in status bar</b></td> | 
|  | <td valign="top" align="left" width="80%"> | 
|  | If you regularly switch between target platforms, PDE provides an option to show the current target | 
|  | platform in the status bar.  On the <b>Plug-in Development</b> preference page, select | 
|  | <b>Show current target platform in status bar</b>.  The status bar entry will show the name of | 
|  | the active target definition and will show an error icon if there are problems with the target. | 
|  | </td> | 
|  | </tr> | 
|  | <tr> | 
|  | <td valign="top" align="left" width="20%"><b>Find a feature by entering a plug-in name in the feature selection dialog</b></td> | 
|  | <td valign="top" align="left" width="80%"> | 
|  | When adding a feature to a product, feature or launch configuration, you can enter the name of a plug-in in the filter text box | 
|  | of the feature selection dialog.  Features that include that plug-in will match the filter and be displayed. | 
|  | </td> | 
|  | </tr> | 
|  | <tr> | 
|  | <td valign="top" align="left" width="20%"><b>Reload button in target editor</b></td> | 
|  | <td valign="top" align="left" width="80%"> | 
|  | In scenarios where the target editor is left in inconsistent state due to issues like unstable network connection and | 
|  | it is impossible to resolve the condition without manually editing the target editor file, you can use the <b>Reload</b> button in the <b>Locations</b> section of <b>Target editor</b>. | 
|  | It clears the cached p2 profile and then resolves the target. | 
|  | </td> | 
|  | </tr> | 
|  | <tr> | 
|  | <td valign="top" align="left" width="20%"><b>Set default preference values for your product</b></td> | 
|  | <td valign="top" align="left" width="80%"> | 
|  | In order to set default preference values for your product, instead of manually adding the preferences to product's customization file, you can use the | 
|  | <b>Convert Preferences</b> wizard in the <b>Customization</b> section of your <b>Product editor</b>. | 
|  | </td> | 
|  | </tr> | 
|  | <tr> | 
|  | <td valign="top" align="left" width="20%"><b>Create an API Baseline from a Target Definition</b></td> | 
|  | <td valign="top" align="left" width="80%"> | 
|  | To avail API tooling functionalities for <b>any target definition</b>, you can create an API Baseline in the <b>Plug-in Development > API Baselines</b> preference page. | 
|  | </td> | 
|  | </tr> | 
|  | <tr> | 
|  | <td valign="top" align="left" width="20%"><b>Quickly search for any plug-in artifact</b></td> | 
|  | <td valign="top" align="left" width="80%"> | 
|  | Use the <b>Open Plug-in Artifact</b> dialog to quickly find and open plug-in artifacts.  Search | 
|  | by the name of the plug-in, feature or product, or search for a specific package, extension point | 
|  | or extension.  The icons can be used to see whether the artifact is available in the workspace or | 
|  | if it comes from the target platform.  You can press <b>Ctrl-Shift-A</b> to open the dialog. | 
|  | </td> | 
|  | </tr> | 
|  | <tr> | 
|  | <td valign="top" align="left" width="20%"><b>To clean or not to clean</b></td> | 
|  | <td valign="top" align="left" width="80%">When you create a new runtime | 
|  | workbench launch configuration, PDE presets the Program Arguments on the | 
|  | launch configuration to include a -clean argument.  | 
|  | <p>This -clean argument clears all runtime-cached data in your runtime | 
|  | workbench from one invocation to the next to ensure that all the changes | 
|  | made in your host workbench, e.g. new Java packages were added to a plug-in | 
|  | project, etc., are picked up when you launch a runtime workbench.</p> | 
|  | <p>This clearing of the cache may hinder performance if your target platform | 
|  | contains a large number of plug-ins.  </p> | 
|  | <p>Therefore, if you're in a situation where your target platform has a | 
|  | large number of plug-ins and you're at a stage where you are not actively | 
|  | adding/removing packages from your plug-in projects, you could remove the | 
|  | -clean argument from the launch configuration to improve startup time.</p></td> | 
|  | </tr> | 
|  | <tr> | 
|  | <td valign="top" align="left" width="20%"><b>Importing with linking</b></td> | 
|  | <td valign="top" align="left" width="80%">Importing external plug-ins and | 
|  | fragments can be time consuming and may result in large workspaces, | 
|  | depending on the content of the plug-ins being imported.  Therefore, | 
|  | the 'Import External Plug-ins and Fragments' wizard gives you the option to | 
|  | import with linking.  This means that the import operation will not | 
|  | copy the resources being imported into your workspace.  It will simply | 
|  | create links to the files being imported.  You will be able to browse | 
|  | these linked resources, as if they had been copied into your workspace.  | 
|  | However, they are physically not there on your file system, so you will not | 
|  | be able to modify them.  Beware of operations that depend on files | 
|  | being physically in your workspace, as they will not work on linked | 
|  | resources.</td> | 
|  | </tr> | 
|  | <tr> | 
|  | <td valign="top" align="left" width="20%" height="112"><b>Templates</b></td> | 
|  | <td valign="top" align="left" width="80%" height="112">For a quick start, PDE provides | 
|  | several template plug-ins that will generate a plug-in with one or more | 
|  | fully-working extensions.  In addition, if at any point, you would like | 
|  | to add a new extension from the template list (without having to generate a | 
|  | plug-in), you could access these extension templates directly from the | 
|  | manifest editor.  From the 'Extensions' page of the editor, click | 
|  | 'Add...'.  In the wizard that comes up, select Extension Templates in | 
|  | the left pane and choose the template of choice in the right pane.</td> | 
|  | </tr> | 
|  | <tr> | 
|  | <td width="20%" valign="top" align="left" height="280"><b>Plug-in dependency extent</b></td> | 
|  | <td width="80%" valign="top" align="left" height="280">If you have ever looked at the | 
|  | list of plug-ins that your plug-in depends on and wondered why your plug-in | 
|  | needs a particular plug-in X, now you can easily find out why.  | 
|  | <p>The <b>Compute Dependency Extent </b>operation | 
|  | found on the context menu in several contexts (including manifest file | 
|  | Dependencies page and Plug-in Dependencies view) performs a combined Java and | 
|  | plug-in search to find all Java types and extension points provided by | 
|  | plug-in X which are referenced | 
|  | by your plug-in. The results will be displayed in the Search view.  When a type is selected in the Search results view, the <b>References | 
|  | in <i>MyPlugIn</i></b> action in the context menu searches for the places | 
|  | in the plug-in where the selected type is referenced. </p> | 
|  | <p>If the | 
|  | search returns 0 results, you should definitely remove plug-in X from your | 
|  | list of dependencies, as it is not being used at all, and it would just slow | 
|  | class loading.</p> | 
|  | <p>The <b>Compute Dependency Extent</b> is also useful to check if you are | 
|  | using internal (non-API) classes from plug-in X, which might not be | 
|  | desirable.</p></td> | 
|  | </tr> | 
|  | <tr> | 
|  | <td width="20%" valign="top" align="left" height="112"><b>Finding unused dependencies</b></td> | 
|  | <td width="80%" valign="top" align="left" height="112">Minimizing a plug-in's number of | 
|  | dependencies is certain to improve performance.  As your plug-in | 
|  | evolves, its list of dependencies might become stale, as it might be still | 
|  | containing references to plug-ins that it no longer needs.  A quick way | 
|  | to check that all dependencies listed by your plug-in are actually used by | 
|  | the plug-in is to run the 'Find Unused Dependencies' utility, which is | 
|  | available through the context menu of the 'Dependencies' page of PDE's | 
|  | manifest editor.</td> | 
|  | </tr> | 
|  | <tr> | 
|  | <td width="20%" valign="top" align="left" height="80"><b>Extending the Java | 
|  | search scope</b></td> | 
|  | <td width="80%" valign="top" align="left" height="80">Java Search is limited to projects | 
|  | in your workspace and external jars that these projects reference.  If | 
|  | you would like to add more libraries from external plug-ins into the search: | 
|  | open the <b>Plug-ins View</b>, select a plug-in and choose <b>Add to Java Workspace Scope</b> | 
|  | from the context menu. This is handy for remaining | 
|  | aware of other plug-ins that depend on ones you're working on. | 
|  | <p>On the <b>Plug-in Development</b> preference page you can also turn on | 
|  | <b>Include all plug-ins from target in Java workspace scope</b>, which will add every | 
|  | plug-in in your target platform to the search scope.</p></td> | 
|  | </tr> | 
|  | <tr> | 
|  | <td valign="top" align="left" width="20%"> | 
|  | <b>Creating a Rich Client Application</b> | 
|  | </td> | 
|  | <td valign="top" align="left" width="80%"> | 
|  | The | 
|  | <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.cheatsheets.openCheatSheet(cheatSheetId=org.eclipse.pde.rcpapp)")'> | 
|  | <img src="PLUGINS_ROOT/org.eclipse.help/command_link.svg" alt="Open the RCP cheat sheet"><strong>Creating a Rich Client Application</strong></a> | 
|  | cheat sheet will guide you through the individual steps to create a plug-in, | 
|  | define a plug-in based product, customize a product, export a Rich Client Platform (RCP) | 
|  | application and define a feature-based product using the Plug-in Development Environment (PDE). | 
|  | </td> | 
|  | </tr> | 
|  | <tr> | 
|  | <td valign="top" align="left" width="20%"> | 
|  | <b>Creating an Eclipse Plug-in</b> | 
|  | </td> | 
|  | <td valign="top" align="left" width="80%"> | 
|  | The | 
|  | <a class="command-link" href='javascript:executeCommand("org.eclipse.ui.cheatsheets.openCheatSheet(cheatSheetId=org.eclipse.pde.helloworld)")'> | 
|  | <img src="PLUGINS_ROOT/org.eclipse.help/command_link.svg" alt="Open the hello world cheat sheet"><strong>Creating an Eclipse Plug-in</strong></a> | 
|  | cheat sheet will guide you through the individual steps to create a plug-in, a plug-in extension, | 
|  | a feature and an update site using the Plug-in Development Environment (PDE). | 
|  | It will also demonstrate how to install and uninstall a feature using Install/Update. | 
|  | </td> | 
|  | </tr> | 
|  | </table> | 
|  |  | 
|  | </body> | 
|  |  | 
|  | </html> |