Difference between revisions of "Eclipse4/RCP/FAQ"

From Eclipsepedia

< Eclipse4‎ | RCP
Jump to: navigation, search
(New page: == Why won't my application start? == E4AP products require having the following plugins: * org.eclipse.equinox.ds (must be started) * org.eclipse.equinox.event (must be started) Note th...)
 
Line 1: Line 1:
 +
== How do I adopt the Eclipse 4 Application Platform? ==
 +
 +
<table border=0>
 +
 +
<!-- ===================================================================== -->
 +
<td colspan=2>
 +
<h3>Accessing the status line</h3>
 +
</td>
 +
<tr>
 +
    <td style="background:#ebd3d2;">Eclipse 3.x</td>
 +
    <td style="background:#dbf1d2;">Eclipse 4.0</td>
 +
</tr>
 +
<tr>
 +
<td style="background:#ebd3d2;">
 +
<pre>
 +
getViewSite()
 +
  .getActionsBars()
 +
      .getStatusLineManager()
 +
          .setMessage(msg);
 +
</pre>
 +
</td>
 +
<td style="background:#dbf1d2;">
 +
<pre>
 +
@Inject
 +
IStatusLineManager statusLine;
 +
...
 +
statusLine.setMessage(msg);
 +
</pre>
 +
</td>
 +
</tr>
 +
 +
<!-- ===================================================================== -->
 +
<td colspan=2>
 +
<h3>Associating help context with a control</h3>
 +
</td>
 +
<tr>
 +
<td style="background:#ebd3d2;">
 +
<pre>
 +
getSite()
 +
  .getWorkbenchWindow()
 +
    .getWorkbench()
 +
      .getHelpSystem().setHelp(
 +
              viewer.getControl(), some_id)
 +
</pre>
 +
</td>
 +
<td style="background:#dbf1d2;">
 +
<pre>
 +
@Inject
 +
IWorkbenchHelpSystem helpSystem;
 +
...
 +
helpSystem.setHelp(
 +
        viewer.getControl(), some_id);
 +
</pre>
 +
</td>
 +
</tr>
 +
 +
<!-- ===================================================================== -->
 +
<td colspan=2>
 +
<h3>Handling errors and exceptions</h3>
 +
</td>
 +
 +
<tr>
 +
<td style="background:#ebd3d2;">
 +
<pre>
 +
try {
 +
    ...
 +
} catch (Exception ex) {
 +
    IStatus status = new Status(
 +
      IStatus.ERROR, "plugin-id",
 +
      "Error while ...", ex);
 +
    StatusManager.getManager()
 +
        .handle(status, StatusManager.SHOW);
 +
}
 +
</pre>
 +
</td>
 +
<td style="background:#dbf1d2;">
 +
<pre>
 +
@Inject
 +
StatusReporter statusReporter;
 +
...
 +
try{
 +
    ...
 +
} catch (Exception ex) {
 +
    statusReporter.show("Error while ...", ex);
 +
}
 +
</pre>
 +
</td>
 +
</tr>
 +
 +
<!-- ===================================================================== -->
 +
<td colspan=2>
 +
<h3>Accessing preference values</h3>
 +
</td>
 +
 +
<tr>
 +
<td style="background:#ebd3d2;">
 +
<pre>
 +
IPreferenceStore store =
 +
    IDEWorkbenchPlugin.getDefault()
 +
        .getPreferenceStore();
 +
boolean saveBeforeBuild = store
 +
    .getBoolean(SAVE_BEFORE_BUILD);
 +
</pre>
 +
</td>
 +
<td style="background:#dbf1d2;">
 +
<pre>
 +
@Inject @Preference(SAVE_BEFORE_BUILD)
 +
boolean saveBeforeBuild;
 +
</pre>
 +
</td>
 +
</tr>
 +
 +
</table>
 +
 
== Why won't my application start? ==
 
== Why won't my application start? ==
  

Revision as of 15:15, 7 April 2011

Contents

How do I adopt the Eclipse 4 Application Platform?

Accessing the status line

Eclipse 3.x Eclipse 4.0
getViewSite()
  .getActionsBars()
      .getStatusLineManager()
          .setMessage(msg);
@Inject
IStatusLineManager statusLine;
...
statusLine.setMessage(msg);

Associating help context with a control

getSite()
  .getWorkbenchWindow()
    .getWorkbench()
       .getHelpSystem().setHelp(
               viewer.getControl(), some_id)
@Inject
IWorkbenchHelpSystem helpSystem;
...
helpSystem.setHelp(
        viewer.getControl(), some_id);

Handling errors and exceptions

try {
    ...
} catch (Exception ex) {
    IStatus status = new Status(
       IStatus.ERROR, "plugin-id",
       "Error while ...", ex);
    StatusManager.getManager()
        .handle(status, StatusManager.SHOW);
}
@Inject
StatusReporter statusReporter;
...
try{
    ...
} catch (Exception ex) {
    statusReporter.show("Error while ...", ex);
}

Accessing preference values

IPreferenceStore store =
    IDEWorkbenchPlugin.getDefault()
        .getPreferenceStore();
boolean saveBeforeBuild = store
    .getBoolean(SAVE_BEFORE_BUILD);
@Inject @Preference(SAVE_BEFORE_BUILD)
boolean saveBeforeBuild;

Why won't my application start?

E4AP products require having the following plugins:

  • org.eclipse.equinox.ds (must be started)
  • org.eclipse.equinox.event (must be started)

Note that org.eclipse.equinox.ds must be explicitly started. In your product file, you should have a section:

  <configurations>
     <plugin id="org.eclipse.core.runtime" autoStart="true" startLevel="2" />
     <plugin id="org.eclipse.equinox.ds" autoStart="true" startLevel="3" />
     <plugin id="org.eclipse.equinox.event" autoStart="true" startLevel="3" />
  </configurations>


What is the difference between IEclipseContext#set and IEclipseContext#modify?