How to Add more than one object contribution for Eclipse Plugin? - eclipse

Heloo,
I have a plugin with the plugin.xml file below,
<extension
point="org.eclipse.ui.popupMenus">
<objectContribution
objectClass="org.eclipse.xxx.xxx.a"
objectClass="org.eclipse.xxx.xxx.b" (ERROR !!)
id="xxx">
<menu
label="NewMenu"
path="additions"
id="xxx">
<separator
name="group1">
</separator>
</menu>..... blah blah blah
My intention is to enable this "newmenu" for only two types of classes -
org.eclipse.xxx.xxx.a & org.eclipse.xxx.xxx.b
When I tried to declare a new object class I get an error
ERROR: Description Resource Path Location Type Attribute "objectClass" was
already specified for element "objectContribution".
How do I chieve my intention ??

Related

Could not create content describer for com.example.cstfile. Content type has been disabled

I'm trying to add a content type for my XML files with a custom file extension(CST) and I get the following error -
Could not create content describer for com.example.cstfile. Content type has been disabled.
Here's my plugin.xml file -
<extension point="org.eclipse.core.contenttype.contentTypes">
<content-type
base-type="org.eclipse.core.runtime.xml"
file-extensions="cst,xml"
id="cstfile"
name="CST File"
priority="normal">
<describer class="org.eclipse.core.runtime.content.XMLRootElementContentDescriber2"
plugin="org.eclipse.core.runtime">
<parameter name="elementNames" value="CSTFile"/>
</describer>
</content-type>
<file-association
content-type="org.eclipse.core.runtime.xml"
file-extensions="cst">
</file-association>
</extension>
I'm trying to figure out the reason by debugging org.eclipse.core.internal.content.ContentTypeCatalog but have not found any reasons so far, any help is appreciated.
It looks like it comes from calls to ContentTypes.invalidateDescriber - the content describer has thrown an exception.
Looking at XMLRootElementContentDescriber2 it will throw an exception if it gets a javax.xml.parsers.ParserConfigurationException exception when try to parse the XML.
There should be more information in the .log file in the .metadata directory of the workspace.

Where does eclipse store its default key bindings?

I want to know command ids of all the default keybindings in eclipse. Is there a snappy way to get it?
I have searched all relevant eclipse folders for keywords like "ALT" "CTRL". But none of them have all the default operations.
For example : I have exported all the key preferences in a csv file that looks something like this:
text editing | delete line | ctrl+d | editing text |
window | next editor | ctrl+f6 | in windows |
Now I need to know the corresponding command ids for all such keybindings. I want this to use in my vrapperrc file.
The defaults come from all the plugins that contribute to the key binding service using the org.eclipse.ui.bindings extension point. The bindings are defined in the plugin.xml for each plugin.
So, for example, the org.eclipse.ui plugin defines bindings like:
<extension point="org.eclipse.ui.bindings">
<key
commandId="org.eclipse.ui.newWizard"
sequence="M1+N"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" />
<key
commandId="org.eclipse.ui.file.close"
sequence="M1+W"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" />
... many more ....
In a plugin you can all these bindings using the getBindings method of the IBindingService service:
IBindingService bindingService = PlatformUI.getWorkbench().getAdapter(IBindingService.class);
Binding [] bindings = bindingService.getBindings();
Binding has a getParameterizedCommand method to get the command the key is bound to.

MyBatis: Error when adding a 'bind' inside of 'foreach'

I'm using MyBatis for handling SQL queries. Here is my problematic piece of code:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.foo.Foo">
...
<insert id="insert" parameterType="com.foo.FooParam">
<foreach collection="bars" item="bar" separator=" ">
<bind name="inFavorites" value="bar.sectionId == '_favorites'" />
<foreach collection="bar.bars2" item="bar2" index="index" separator=" ">
...
</foreach>
</foreach>
</insert>
...
</mapper>
Intelij shows the following error when validiting the xml:
Error:(24, 74) Element type "bind" must be declared.
Error:(28, 19) The content of element type "foreach" must match "(include|trim|where|set|foreach|choose|if)".
And when i put a compiled module as an osgi package in a jetty server (mvn compiles it w/o errors and warnings) I'm getting the following error:
lineNumber: 28; columnNumber: 19; The content of element type "foreach"
must match "(include|trim|where|set|foreach|choose|if)".
So Ok, I get this. I cannot add a 'bind' element inside of a 'foreach'.
But why, if http://mybatis.org/dtd/mybatis-3-mapper.dtd says otherwise?
<!ELEMENT foreach (#PCDATA | include | trim | where | set | foreach | choose | if | bind)*>
bind inside foreach is allowed since version 3.2.3. You are obviously using an older version.
dtd file is not downloaded from the internet but the version packaged in mybatis jar is used.

WSDL type "soapenc:string" cannot be resolved

importing my WSDL into RAD 8 (websphere 6.1) gives error:
<wsdl:part name="muid" type="soapenc:string"/>
The string type that is references by muid cannot be resolved.
XSD: Type reference 'http://schemas.xmlsoap.org/soap/encoding/#string' is unresolved
string is a type which has been defined in "the" XML Schema. Check, which prefix is used to reference the namespace http://www.w3.org/2001/XMLSchema (the XML Schema-namespace) in your WSDL (most probably something similar to xsi, xs, xsd).
Then change the line to
<wsdl:part name="muid" type="xs:string"/>
where xs is your namespace prefix.

How do I optionally require a command line arguement for Ant?

I'm new to ant, and I want to require a file name if something other than the default target is used, so the calling syntax would be something like this:
ant specifictarget -Dfile=myfile
I'm using the ant contrib package to give me additional functionality, so I have this:
<if>
<equals arg1="${file}" arg2="" />
<then>
<!-- fail here -->
</then>
</if>
My thinking is that if file was not specified it might be equal to the empty string. Obviously, this didn't work, and I'm not finding any examples on google or the right syntax in the manual.
So what syntax should I use?
You don't really need the contrib package. This is more conveniently done using built-in ant capabilities like if/unless and depends. See below:
<target name="check" unless="file" description="check that the file property is set" >
<fail message="set file property in the command line (e.g. -Dfile=someval)"/>
</target>
<target name="specifictarget" if="file" depends="check" description=" " >
<echo message="do something ${file}"/>
</target>
You've got the right idea. The
ant specifictarget -Dfile=myfile
sets Ant Properties from the command line. All you really need is
<property name="file" value=""/>
for your default value. That way if file is not specified, it will be equal to the empty string.
Since properties are not mutable in Ant, you can add this:
<property name="file" value="" />
This will set the property file to an empty string if it hasn't already been set on the command line. Then your equality test will work as you intended.
Alternately, you can use escape the value since ant just spits out the actual text when it can't do a property substitution.
<if>
<equals arg1="${file}" arg2="$${file}" />
<then>
<echo>BARF!</echo>
</then>
</if>