0

I have an eclipse RCP application (RCP version 4.12.0.v20190605-1801) using SWT. I want to add the eclipse QuickAccess TextField as search bar to my project like in the Java eclipse IDE (which is also available by pressing ctrl + 3).

Eclipse view of QuickAccess

I have scoured the documentation and the only thing I have found is the following:

@Override
protected void fillCoolBar(ICoolBarManager coolBar) {
    // ToolBar File & Additions
    IToolBarManager fileToolBar = new ToolBarManager(coolBar.getStyle());
    fileToolBar.add(ActionFactory.SHOW_QUICK_ACCESS.create(window));   // window == class attribute

    // Add some other stuff
}

This produces a QuickAccess button in my case, but no TextField. It works the same way if you click on it, but I would prefer to have the TextField as it is more clear to the user.

My QuickAccess button using org.eclipse.ui.acitons.ActionFactory

I only found threads on how to remove the TextField, but not how to add it, e.g. SO post here. So I guess it must be a somewhat built in feature.

If anyone's interested it is for the JCrypTool project:

Hope I didn't miss anything important, thanks for your help in advance.

  • You are going to have to look at the source code - be sure to use the correct source as this code has changed several times. For example the code you show does not match Eclipse 2020-03. At a guess something is defined in the LegacyIDE.e4xmi – greg-449 Mar 22 '20 at 16:56
  • @greg-449 Ah yes, I completely overlooked I use an old version of Eclipse. I see the new one uses a search icon, which would also be fine. I will take a look into it - thanks. – tassadarius Mar 23 '20 at 10:33

1 Answers1

0

I now settled on a slightly different solution.

I included the QuickAccess entry as Extension in my plugin.xml where I define my toolbar. Instead of an input text, it is now a button (depicting a magnifier icon). I took this approach because it is quite easy to implement using the RCP extension points.

This is a (reduced) version of what my plugin.xml looks like now. The relevant part is the extension point org.eclipse.ui.menus which calls org.eclipse.ui.window.quickAccess

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
   <extension id="application" point="org.eclipse.core.runtime.applications">
      <application>
         <run class="org.jcryptool.core.Application"/>
      </application>
   </extension>

   <extension point="org.eclipse.ui.menus">
      <menuContribution
            allPopups="false"
            locationURI="toolbar:org.jcryptool.core.searchToolbar">
         <command
               commandId="org.eclipse.ui.window.quickAccess"
               icon="icons/searchIcon.png"
               style="push">
         </command>
      </menuContribution>
   </extension>

   <extension id="product" point="org.eclipse.core.runtime.products">
      <product application="org.jcryptool.core.application" name="JCrypTool">
         <property name="appName" value="JCrypTool"/>
         <property name="cssTheme" value="org.jcryptool.themes.default"/>
      </product>
   </extension>

</plugin>

This looks like this:

enter image description here

For a really fancy implementation I guess you have to write some code for it. But as quite nice RCP solution it's ok for me.