Eclipse plugin. Resolve variable + dynamic variables - doesn't work - java

I tried to make an eclipse plugin and I had some difficulties.
First of all I created two extension points:
<extension point="org.eclipse.ui.propertyPages">
<page
id="com.coffee.projectPage"
name="Coffee Java Properties"
class="com.coffee.cona.properties.CoffeePropertyPage">
<enabledWhen>
<resolve variable="MYCOFFEE" args="">
<equals value="cona"/>
</resolve>
</enabledWhen>
</page>
</extension>
<extension point="org.eclipse.core.variables.dynamicVariables">
<variable
name="MYCOFFEE"
resolver="com.coffee.properties.CoffeeTimeResolver"
description="Coffee time"
supportsArgument="true">
</variable>
</extension>
In my com.coffee.properties.CoffeeTimeResolver I wrote:
...
public class CoffeeTimeResolver implements IDynamicVariableResolver {
public String resolveValue(IDynamicVariable variable, String argument){
return "cona";
...
...
But it doesn't work! En Eclipse console I see this message:
!MESSAGE The variable MYCOFFEE is not defined
Where I was wrong?
All I need to do es show Property Page only in *.java files that have classes that extend Applet, I mean:
class Xxx extends Applet
but I really don't know how to reach it using test element
Many thanks in advance!

Eclipse has a number of things referred to as variables. org.eclipse.core.variables.dynamicVariables defines a dynamic string substitution variable, this is not the type of variable that the resolve element requires.
As far as I can see there is currently no way to define the IVariableResolver that resolve requires (but the Eclipse code is very large so I may have missed something).
You can probably use the test element instead and use the org.eclipse.core.expressions.propertyTesters extension point which definitely works properly.

Related

Disable name prefix in javadoc

When generating the Javadoc, it adds on prefix to the imported class name, as shown below on the first line 'java.lang'.
How to properly disable that?
Have tried adding -noqualifier in Other command line arguments in my IntelliJ popup window but the following error occurred:
javadoc: error - Illegal package name: "/Users"
Below is a snippet from the Javadoc I generated:
public TrainRoute(java.lang.String name,
int routeNumber)
Creates a new TrainRoute with the given name and number.
Should meet the specification of Route.Route(String, int)
Parameters:
name - The name of the route.
routeNumber - The route number of the route.
I know this is an old question, but still relevant. I am aware of two solution which can be used alone or in combination:
To suppress prefixes on java packages use:
-noqualifier java.*
To suppress prefixes and link to the actual Java docs use:
-link https://docs.oracle.com/javase/8/docs/api
Both suppress the java name qualifiers. The second also links to the Oracle docs.
See javadoc options docs for more info.

Eclipse 4 plugin - key bindings

I want to migrate my eclipse plugin to use Eclipse 4. That basically means to get rid of the dependency on the compatibility layer?
My plugin has an Activator class, a command with an attached handler and a key binding to trigger this command. What I did so far is install the e4 tools, and add fragment.e4xmi to my plugin-project and org.eclipse.e4.workbench.model to the extensions in plugin.xml. Following these instructions http://www.vogella.com/tutorials/EclipsePlugin/article.html, I was able to add a menu contribution to the main menu of eclipse and attach an e4 handler to this menu (That uses the cool dependency injection stuff!).
My problem is the key binding. In my plugin.xml, it looked this way
<extension
point="org.eclipse.ui.bindings">
<key
commandId="com.florian.regexfindandreplace.commands.FindAndReplaceCommand"
contextId="org.eclipse.ui.textEditorScope"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M1+F5">
</key>
<scheme
name="Default"
description="Default shortcuts for Eclipse"
id="default.id" />
</extension>
In fragment.e4xmi, I added a model fragment with Extended Element id: org.eclipse.e4.legacy.ide.application and with Feature name keyBindings.
Under that node I created a BindingContext with Id org.eclipse.ui.contexts.window (I imported that binding context) and a BindingTable using this context and a key binding on M1 + F5.
But when I press Ctrl + F5 when the plugin is running (the menu is visible and the command can be triggered from there), the command isn't triggered.
Here is my frament.e4xmi file
<?xml version="1.0" encoding="ASCII"?>
<fragment:ModelFragments xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:commands="http://www.eclipse.org/ui/2010/UIModel/application/commands" xmlns:fragment="http://www.eclipse.org/ui/2010/UIModel/fragment" xmlns:menu="http://www.eclipse.org/ui/2010/UIModel/application/ui/menu" xmi:id="_GxS4UF4xEea8x7AIe1PlrQ">
<imports xsi:type="commands:BindingContext" xmi:id="_vgCiAF8lEea2fbkyfFHzhA" elementId="org.eclipse.ui.contexts.dialogAndWindow"/>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_OX6rcF4xEea8x7AIe1PlrQ" featurename="commands" parentElementId="org.eclipse.e4.legacy.ide.application">
<elements xsi:type="commands:Command" xmi:id="_XcrQgF4xEea8x7AIe1PlrQ" elementId="com.florian.regexfindandreplace.command.openfindreplacedialog" commandName="Open find/replace dialog" description="Opens the find/replace dialog"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_dc1cIF4xEea8x7AIe1PlrQ" featurename="handlers" parentElementId="org.eclipse.e4.legacy.ide.application">
<elements xsi:type="commands:Handler" xmi:id="_ioC8wF4xEea8x7AIe1PlrQ" elementId="com.florian.regexfindandreplace.handler.openfindreplacedialog" contributionURI="bundleclass://com.florian.regexfindandreplace/com.florian.regexfindandreplace.handlers.OpenFindReplaceDialogE4Handler" command="_XcrQgF4xEea8x7AIe1PlrQ"/>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="_ok-OMF4xEea8x7AIe1PlrQ" featurename="menuContributions" parentElementId="org.eclipse.e4.legacy.ide.application">
<elements xsi:type="menu:MenuContribution" xmi:id="_1fot0F4xEea8x7AIe1PlrQ" elementId="com.florian.regexfindandreplace.menucontribution.firstmenu" positionInParent="after=additions" parentId="org.eclipse.ui.main.menu">
<children xsi:type="menu:HandledMenuItem" xmi:id="_FTLfEF4yEea8x7AIe1PlrQ" elementId="id.openfindreplacedialog" label="Open find/replace dialog" command="_XcrQgF4xEea8x7AIe1PlrQ"/>
</elements>
</fragments>
<fragments xsi:type="fragment:StringModelFragment" xmi:id="__aNm8F45Eea8x7AIe1PlrQ" featurename="keyBindings" parentElementId="org.eclipse.e4.legacy.ide.application">
<elements xsi:type="commands:BindingTable" xmi:id="_2seTgF8lEea2fbkyfFHzhA" elementId="com.florian.regexfindandreplace.bindingtable.0" bindingContext="_vgCiAF8lEea2fbkyfFHzhA">
<bindings xmi:id="_3ySFAF8lEea2fbkyfFHzhA" elementId="com.florian.regexfindandreplace.keybinding.0" keySequence="CTRL+F5" command="_XcrQgF4xEea8x7AIe1PlrQ"/>
</elements>
</fragments>
</fragment:ModelFragments>
What did I do wrong? Any help is appreciated!
I got my problem solved. The model fragment for my key bindings had to have the featurename = "bindingTables". So you can't have an arbitrary name here as I thought when I gabe it the name "keyBindings".

Clojure interop with Java: how to call a class?

I have a Java app that has a class at this address, inside a standard Maven layout:
src/main/java/com/ollio/nlp/Transformer.java
The class and method that I want looks like this:
package com.ollio.nlp;
public class Transformer {
public String transform(String JSONInput) {
I store the jar artifact locally in my Clojure app at this address:
maven_repository/local/nlp/1.0-SNAPSHOT/nlp-1.0-SNAPSHOT.jar
I have tried a dozen variations to import it into my Clojure app, such as:
(:import
[com.ollio.nlp.Transformer])
But I keep getting the error "No such namespace".
What is the correct way to import this?
EDITED:
Here is how I currently try to do the import statement:
(ns slick.query
(:import
[nlp.*])
I also tried:
(ns slick.query
(:import
[com.ollio.nlp.*])
I tried a few other variations.
The project.clj file looks like this:
(defproject slick "0.1"
:description "slick is an API for other ollio services, such as our mobile app."
:dependencies [[org.clojure/clojure "1.6.0"]
[com.taoensso/timbre "3.2.1"]
[dire "0.5.1"]
[slingshot "0.10.3"]
[ring "1.4.0-RC1"]
[clj-time "0.6.0"]
[org.clojure/data.json "0.2.5"]
[compojure "1.3.4"]
[com.novemberain/monger "2.0.1"]
[org.clojure/tools.namespace "0.2.4"]
[manifold "0.1.0"]
[me.raynes/fs "1.4.4"]
[org.clojure/core.incubator "0.1.3"]
[clj-stacktrace "0.2.7"]
[overtone/at-at "1.2.0"]
[ring/ring-json "0.3.1"]
[clj-http "1.1.2"]
[org.clojure/core.cache "0.6.4"]
[cheshire "5.5.0"]
[org.clojure/core.match "0.3.0-alpha4"]
[local/nlp "1.0-SNAPSHOT"]]
:repositories {"local" ~(str (.toURI (java.io.File. "maven_repository")))}
:disable-implicit-clean true
:source-paths ["src/clojure"]
:java-source-paths ["src/java"]
:main slick.core
:aot :all
:jvm-opts ["-Xms100m" "-Xmx1000m" "-XX:-UseCompressedOops"])
If you are mixing java and clojure source code in one project, you should first review the lein docs: https://github.com/technomancy/leiningen/blob/master/doc/MIXED_PROJECTS.md
Also, if you posted your project.clj and the layout of your java/clojure sources, it would be easier to spot what is missing.
You probably want to change the last period in your :import statement into a space:
(ns mynamespace
(:import [com.ollio.nlp Transformer]))
(EDIT: You can't use wildcards here. Every class that in com.ollio.nlp must be listed explicitly, separated by spaces.) That will allow you to use Transformer unqualified:
(.transform (Transformer. <add constructor args here>) my-json-input)
As #noisesmith said, the :import statement should be part of an ns declaration.
There's also a good chance that there are problems with the way that the project is set up. You've given no indication that that is likely, but it often happens when one is starting to use Java interop, I believe. (It happened to me, in any event.) So #AlanThompson's advice may be relevant.
You an also simply remove the :import statement, and use the Java class name in fully qualified form, e.g.:
(.transform (com.ollio.nlp.Transformer. <add constructor args here>) my-json-input)
If you get an error when you do that, then there's probably a problem with the setup (unless you're using the class incorrectly).
(I'm not sure how helpful any of this. Alan Thompson's answer is probably the appropriate one.)

Shortcut key is not working in eclipse RCP java project

I have eclipse RCP java project, in which i have enabled shortcut keys Ctrl+H and ctrl+S for save and other activities. it was working fine until i have imported my project in 64 bit Eclipse indigo. Most of the keys are working but these two not. I have checked Ctrl+S is associated with defaultHandler.
Now it is throwing following Exception:
ENTRY org.eclipse.ui.workbench 2 0 2015-01-21 15:07:08.646
!MESSAGE A handler conflict occurred. This may disable some commands.
!SUBENTRY 1 org.eclipse.ui.workbench 2 0 2015-01-21 15:07:08.646
!MESSAGE Conflict for 'org.eclipse.ui.file.save':
HandlerActivation(commandId=org.eclipse.ui.file.save,
handler=org.eclipse.ui.internal.handlers.SaveHandler#4e65ad52,
expression=,sourcePriority=0)
Update:
public class KBShortcutsHandler extends AbstractHandler {
#Override
public Object execute(ExecutionEvent event) throws ExecutionException {
if (event.getCommand().getId().equals("org.eclipse.ui.file.save")) {
new XyzHandler(XConstants.SAVE_EDITOR_ID)
.run();
}
}
}
in plugin.xml
<command
defaultHandler="KBShortcutsHandler"
id="org.eclipse.ui.file.save"
name="save">
</command>
and simply write code to "Add Action" it was working fine but not now.
Eclipse already has a definition of the org.eclipse.ui.file.save command so you should not be trying to define it yourself. Instead use the org.eclipse.ui.handlers extension point to define a handler to be used when your code is active.
The following is an example of how the Debug plugin handles the 'delete' command:
<extension
point="org.eclipse.ui.handlers">
<handler
class="org.eclipse.debug.internal.ui.views.launch.TerminateAndRemoveHandler"
commandId="org.eclipse.ui.edit.delete">
<activeWhen>
<iterate
ifEmpty="false"
operator="and">
<adapt
type="org.eclipse.debug.core.model.ITerminate">
</adapt>
</iterate>
</activeWhen>
</handler>
</extension>
I notice your constants XConstants.SAVE_EDITOR_ID - if you are trying to save in an editor there should not be any need to do anything if it is based on EditorPart.
This "org.eclipse.ui.workbench_3.7.1.v20120104-1859.jar" workBench
jar must contain the SaveHandler class which is present inside
org.eclipse.ui.internal.handlers package.
Below line must removed from plugin.xml
This works for me.

Flex blank/white screen after deploy

Just uploaded a .war file to the server.. everthing is ok there.. but by no reason the login page is not loading anything..
i earned this flex+java projects on my new job.. its kind strange to me..
i can't even use firebug on it.. it dysplay nothing on eclipse console.
plz someone give me a hand !
The login page mxml:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="100%" height="100%" initialize="Spinner.init(this)" >
<mx:Style source="../flexdesign/css/Login.css"/>
<mx:Style source="../flexdesign/css/principal.css"/>
<mx:Style source="../flexdesign/css/conteudo.css"/>
<mx:Script>
<![CDATA[
import automacao.ui.Spinner;
import flash.net.navigateToURL;
import mx.controls.Alert;
public function abreMenu(url:String):void{
try {
navigateToURL(new URLRequest(url),"_parent");
} catch (e:Error) {
trace("Error occurred!");
}
}
]]>
</mx:Script>
<mx:Move id="cimabaixo" duration="1100" yFrom="0" yTo="0" xFrom="300" xTo="0"/>
<mx:Iris id="zoom" duration="300" xFrom="0" xTo="1" yFrom="0" yTo="1"/>
<mx:Zoom id="zoomhide" duration="500" zoomWidthFrom="1" zoomWidthTo="0" zoomHeightFrom="1" zoomHeightTo="0"/>
<mx:Glow id="brilho" duration="300" alphaFrom="0" alphaTo=".4" blurXFrom="0" blurXTo="20" blurYFrom="0" blurYTo="20" color="0xBBBBBB" strength="3"/>
<mx:Glow id="sembrilho" duration="500" alphaFrom=".6" alphaTo="0" blurXFrom="20" blurXTo="0" blurYFrom="20" blurYTo="0" color="0xBBBBBB" strength="3"/>
<mx:Glow id="brilhoradio" duration="200" alphaFrom="0" alphaTo=".4" blurXFrom="0" blurXTo="15" blurYFrom="0" blurYTo="15" color="0xBBBBBB" strength="2"/>
<mx:Glow id="sembrilhoradio" duration="200" alphaFrom=".3" alphaTo="0" blurXFrom="15" blurXTo="0" blurYFrom="15" blurYTo="0" color="0xBBBBBB" strength="2"/>
<mx:Fade id="fadeOut" duration="300" alphaFrom="1.0" alphaTo="0.0"/>
<mx:Fade id="fadeIn" duration="300" alphaFrom="0.0" alphaTo="1.0"/>
<mx:ModuleLoader id="workspace" x="0" y="0" width="100%" height="100%" url="LoginView.swf"/>
</mx:Application>
it was working like a piece of cake.. i just make some java business change and deploy the project..
Haven't worked with Flex either, but just see if any of these ideas help.
1) Restore the backup and confirm it does still work, and it's your changes. (Just get that out of the way)
2) Ensure you can find those imports on the classpath (i.e. automacao.ui.Spinner etc.) Your WAR might not have included them for some reason.
3) Add into that abreMenu function some sort of generic output to a file to see if it's getting there. I'll suspect its not.
4) Turn on trace-level debugging in log4j/slf4j or whatever you're using.
When you find the answer, post back. :)
Is LoginView.swf still on the same directory?
Also download the Flash debug version so that you will see the "silenced" errors.
If you were using Flex Builder, Go to Project --> Properties --> FlexModules.
Make sure you have added your module LoginView to that. This might be a reason for module not loading.

Categories

Resources