Eclipse Remote Application Platform (RAP) - Deploy Custom Theme - eclipse

Currently trying to get my Eclipse RAP application to work with a custom styling. The documentation is giving me one headache after another and it's really hard getting into it.
Following their docs and trying to extend the default theme, I have set up my plugin.xml as follows:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.rap.ui.entrypoint">
<entrypoint
applicationId="org.______.rap.branding.application"
id="org.______.rap.branding.entrypoint"
brandingId="______"
path="/rap">
</entrypoint>
</extension>
<extension
id="org.______.rap.branding.application"
point="org.eclipse.core.runtime.applications">
<application
cardinality="singleton-global"
thread="main"
visible="true">
<run
class="org.______.rap.branding.Application">
</run>
</application>
</extension>
<extension
point="org.eclipse.ui.perspectives">
<perspective
class="org.______.rap.branding.Perspective"
id="org.______.rap.branding.perspective"
name="name">
</perspective>
</extension>
<extension
point="org.eclipse.rap.ui.branding">
<branding
id="______"
themeId="org.eclipse.rap.rwt.theme"
title="______ Theme">
</branding>
</extension>
<extension
point="org.eclipse.rap.ui.themes">
<themeContribution
file="theme/______.css"
themeId="org.eclipse.rap.rwt.theme" />
</extension>
</plugin>
I've blanked out some parts, just asume they're all the same keyword, lowercase letters only.
My .css-File is as simple as it could be to see, if the hook works:
* {
background: red !Important;
}
But it just loads the default theme, no changes whatsoever and I can't detect the injection anywhere on the page.

Appears the hook itself is correct, but RAP couldn't handle the background-property. Changing it to background-color instead did the trick.

Related

The command is not visible in my eclipse plugin

I am new to Eclipse plugin development. Recently, I downloaded a completed source code of an Eclipse plugin from another team. The popup menu of the plugin is not visible, so I just created a simple popup-menu-command for testing.
In the project, I only changed the plugin.xml to :
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<extension
point="org.eclipse.ui.commands">
<command
description="some description"
id="com.something.aCommand"
name="somet name">
</command>
</extension>
<extension point="org.eclipse.ui.menus">
<menuContribution locationURI="popup:org.eclipse.jdt.ui.PackageExplorer">
<command commandId="com.something.aCommand"
label="Create HTML" style="push">
</command>
</menuContribution>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="com.something.aHandler"
commandId="com.something.aCommand">
</handler>
</extension>
</plugin>
(The aCommand and aHandler are nicknames of the real command and handler which do exist)
This sample is similar to the example here http://www.vogella.com/tutorials/EclipsePlugin/article.html#extending-the-eclipse-ide
And I tested it by Run as-> Eclipse Appliication, the right-click-pupup-command "Create HTML" is not visible.
Besides, this project does not contain fragment.e4mi file, does this mean it is a Eclipse 3 plug-in ? Because I find almost all eclipse plug-in tutorials are using fragment.e4mi and the e4 model fragment UI.
Environment:
Windows 10 64-bits
Eclipse Oxygen.1a Release (4.7.1a)
This is basically OK but is only contributing to the Package Explorer view (id org.eclipse.jdt.ui.PackageExplorer)
For Project Explorer to context menu id is org.eclipse.ui.navigator.ProjectExplorer#PopupMenu.
You can also use popup:org.eclipse.ui.popup.any to contribute to any menu.

RAP Key Binding CTRL + S calls Browser save

I'm using RAP 2.3 and added a Key binding like that:
<extension
point="org.eclipse.ui.bindings">
<key
commandId="mysave"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M1+S">
</key>
</extension>
<extension
point="org.eclipse.ui.commands">
<command
defaultHandler="de.application.ui.SaveHandler"
id="mysave"
name="name">
</command>
</extension
But when I press CTRL+S in my Application the Browser-SaveAction is called and not my SaveHandler. Does anybody have an idea how to fix that?

Optional extension points in plugin.xml

I want to define an extension point in my plugin.xml which is not available in my target platform. This is fine for me, because I want to take advantage of it only if it's available .
However ,when I add it Eclipse flags it with an error
Unknown extension point: 'org.eclipse.ui.trace.traceComponents'
Can I somehow mark this extension point as optional? I know that I can reduce the Unresolved extension points severity per-workspace or per-project, but I'd rather not do that for just one error.
The complete plugin.xml is
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
id="org.apache.sling.slingclipse.preferences"
name="Slingclipse Preferences"
point="org.eclipse.ui.preferencePages">
<page
name="Slingclipse"
class="org.apache.sling.slingclipse.preferences.SlingclipsePreferencePage"
id="org.apache.sling.slingclipse.preferences.defaultPreferences">
</page>
</extension>
<extension
point="org.eclipse.core.runtime.preferences">
<initializer
class="org.apache.sling.slingclipse.preferences.PreferenceInitializer">
</initializer>
</extension>
<extension
point="org.eclipse.ui.startup">
<startup
class="org.apache.sling.slingclipse.SlingclipseStrartup">
</startup>
</extension>
<extension
point="org.eclipse.ui.importWizards">
<category
id="org.apache.sling.slingclipse.ui.wizards.sampleCategory"
name="Sling">
</category>
<wizard
category="org.apache.sling.slingclipse.ui.wizards.sampleCategory"
class="org.apache.sling.slingclipse.ui.wizards.ImportWizard"
icon="icons/sample.gif"
id="org.apache.sling.slingclipse.ui.wizards.ImportWizard"
name="Import from Repository">
<description>
Import a file from the local file system into the workspace.
</description>
</wizard>
</extension>
<extension
point="org.eclipse.ui.trace.traceComponents">
<component
id="org.eclipse.ui.trace.tracingPrefPage"
label="Slingclipse">
<bundle
name="org.apache.sling.slingclipse"></bundle>
</component>
</extension>
</plugin>
You are mixing two concepts here: Development time versus runtime.
Extension points are dependencies declared at development time. Therefore you should have the plugin defining that extension point in your target platform at development time. But you are right, you can generally write the manifest XML for extending that extension point without it being available. In practice this does not work well because many extension points require to implement an interface which itself is also defined in the (non existing) plugin.
To make the functionality be optional for a user (and to not force him to have the defining plugin), you need to make the installation of your plugin optional. But that is not related to the manifest and the use of extension points at all. E.g. you have to declare a feature containing your plugin and make that feature depend on the feature containing the plugin defining the extension point.

Is there any way to add a shortcut key in eclipse from plugin on runtime?

I am developing a plugin in eclipse . Currently we are using "org.eclipse.ui.bindings" extension point for providing shortcut keys . But it's a static option for providing shortcut key for action . Our user's face some difficulty to using my plugin without shortcut keys . Is there any option to add a shortcut keys on runtime via eclipse plugin ?.
<extension
point="org.eclipse.ui.commands">
<category
name="ZMedia Shortcuts Category"
id="com.zmedia.viewer.commands.category">
</category>
<command
name="Update Zmedia Deployable Instances"
categoryId="com.zmedia.viewer.commands.category"
id="com.zmedia.viewer.commands.UpdateZmediaDeployableInstances">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
class="com.zmedia.viewer.handlers.UpdateZmediaDeployableInstances"
commandId="com.zmedia.viewer.commands.UpdateZmediaDeployableInstances">
</handler>
</extension>
<extension
point="org.eclipse.ui.bindings">
<key
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
commandId="com.zmedia.viewer.commands.UpdateZmediaDeployableInstances"
sequence="M1+M2+ESC">
</key>
</extension>
The extension point description explicitly denies that:
API Information:
There is no public API for defining bindings. To try to achieve stability for the user, bindings are only defined through the extension points. If you are an RCP application, you should be able to override this behaviour in the WorkbenchAdvisor.

How to extend the source menu in Eclipse? (or: What is its locationURI?)

I am developing an eclipse plugin and trying to extend the source menu (mainMenubar/Source - visible when editing in the java-editor) in Eclipse 3.7.
The documentation says to rely on the org.eclipse.ui.menus-extension point since the older extension points are deprecated. It is a complete secret to me where to obtain reliable locationURIs, but I finally managed to find some plausible URI with the Plugin Spy (following an advice here).
So the following should be the extension snippet for the plugin.xml:
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.eclipse.jdt.ui.source.menu">
<command
commandId="some.command.id"
label="Some label"
style="push">
</command>
</menuContribution>
</extension>
Unfortunately, when running the plugin for my development IDE no command appears, and also no error message. Just nothing happens. When I set the locationURI to "menu:help", the new command appears in the help menu, so the problem seems to be really the locationURI.
This thread reports having added an entry in the main Source menu:
<!-- main menu -->
<extension point="org.eclipse.ui.actionSets">
<actionSet label="Java Coding"
description="Action set containing coding related Java actions"
visible="true"
id="org.eclipse.jdt.ui.CodingActionSet2">
<menu label="&Source"
path="edit"
id="org.eclipse.jdt.ui.source.menu">
</menu>
<action class="org.gsoc.eclipse.tostringgenerator.actions.GenerateToStringActionDelegate "
id="org.gsoc.eclipse.tostringgenerator.action"
label="Generate to&String()..."
menubarPath="org.eclipse.jdt.ui.source.menu/generateGroup">
</action>
</actionSet>
</extension>
I ran into the same problem. I finally figured out that extending the Source menu using the (recommended) extension point org.eclipse.ui.menus is not possible.
The reason is that a menu defined in an old style actionSet (like the Source menu) is created after the processing of org.eclipse.ui.menus-extensions. The way it is, these extensions can only contribute to already existing menus.
So sticking to the old API (as suggested by VonC) is probably the best option until the jdt plugin is migrated to the new approach...
You can use the popup: space instead of the menu: space. Here is a working example:
<extension point="org.eclipse.ui.commands">
<command defaultHandler="com.igenox.plugin.dpbuilder.rcp.handler.CreateBuilderHandler"
id="com.igenox.plugin.DPBuilder.CreateBuilderPattern" name="CreateBuilderPattern">
</command>
</extension>
<extension point="org.eclipse.ui.menus">
<menuContribution
locationURI="popup:org.eclipse.jdt.ui.source.menu?after=DPSeparator">
<command commandId="com.igenox.plugin.DPBuilder.CreateBuilderPattern"
id="createBuilder" label="Create Builder Pattern">
</command>
</menuContribution>
<menuContribution
locationURI="popup:org.eclipse.jdt.ui.source.menu?after=additions">
<separator name="DPSeparator" visible="true">
</separator>
</menuContribution>
</extension>