How to Implement org.eclipse.wst.sse.ui.semanticHighlighting - eclipse-plugin

I'm trying to implement content-assist and some custom highlighting as a plugin for Eclipse, after a lot of research I found this eclipse document.
I got content-assist working for XML documents, the problem is the part about SemanticHighlighting, I didn't find any information about how to implement this extension-point and I'm a bit lost. The only info that I found is the XSD for the extension point.
I'm trying to make some customs expressions on XML get a different color Ex:
<span>%%colored_text%%</span>
Where can I get more information about this org.eclipse.wst.sse.ui.semanticHighlighting and how to implement it?

I don't think there's a lot of a documentation on the semantic highlighting for SSE. The document that you found is a little light on details. For an example, the XSL project implemented semantic highlighting using the extension point.
The basic idea behind the semantic highlighting extension point is that when a change occurs, implementors will be asked if it can 'consume' a region of the document. If it can, it will return an array of Positions that can be highlighted by that particular highlighter. It can apply only one style, so it ends up being very specific. For example, you wouldn't be able to say 'color this part of the region blue and this other part of the region red'. You would need two separate highlighters to accomplish that.
The highlighter obtains style information for the highlight by using a preference store that you return from getPreferenceStore(). You'll then need to set up keys that the highlighter will use to look up styles from that preference store. If you use the styleStringKey on the extension point, the only key of importance from the semantic highlighting implementation is the one returned from getEnabledPreferenceKey(). This is kind of the condensed way to declare a style, as it only takes 2 preferences to get going. The semantic highlighting framework knows how the parse the string value returned by the preference store for the styleStringKey into the appropriate style components. Just follow the format as defined on the New Help for Old Friends document that you linked to.
Now, if you want to keep all the style components separate, the other get*PreferenceKey() methods become important. You'll have to define keys for each of them, and then add default values for each of those keys in your preference initializer.
org.eclipse.wst.xsl.ui.internal.preferences.XSLUIPreferenceInitializer has examples of both ways to define these style defaults.

Related

Mechanical Turk: Categorization project via Request UI diffictulties

I am a newbie in MTurk, and I am trying to create a very simple Categorization Project via their Requester UI (rather then the API).
Each batch I use has 10 items (question and possible answer). I have searched their documentation and forums with not help and so I have several questions:
When i use their Standard Categorization template, I have no option for modifying the HTML and layout (as shown for "Tagging of an image" project). the only formatting options are for the categories, instructions and includes/excludes. Is there a way to edit the HTML of the standard template they provide?
In the Standard Categorization template, while my input data file (csv file) contains 10 items, only 5 are shown (tried with 6, still only 5 are displayed in the preview). Is there a way to change this limitation?
When I try to use the "Create HITs Individually" (rather than the standard template, as explained above), I have the "Design Layout" options, but I cannot find a way to make the questions in the "form" required (which is possible via the API). Is there a way to achieve this?
If you stick to the standard project templates, you can't modify them. That's the reason to create HITs individually (through the RUI or via the API).
You'll have to show us your CSV file, because it's not really clear from your description what the issues could be.
Your third question is unclear, but basically for creating HITs individually, you simply do standard HTML markup and put in ${variablename} placeholders wherever you want one of your CSV upload variables to be placed.
If your project is at all large, I would definitely recommend going through the API. It's simply much more flexible than the RUI for creating any kind of customized design.

Make IntelliJ aware of links to Java elements in XML files

I have a custom XML format that links to Java resources. For the sake of simplicity let's assume my XML file would look like this:
<root>
<java-class>my.fully.qualified.class.name</java-class>
</root>
Eventually my references will be somewhat more complicated. It will not contain the fully qualified class name directly and I will need some logic to resolve the correct class, but I want to keep the example as simple as possible here.
Now I want it to be possible to Strg+Click on the element's text and want IntelliJ to carry me to the .java file, just like it is possible in Spring-XML files. In the IDEA Plugin Development FAQ there is a link called "How do I add custom references to Java elements in XML files?" which so much sounds like exactly what I need. Unfortunately it links to a discussion where someone is more or less done implementing something like this, having some minor problems. Nevertheless I understood that I probably need to write an implementation of the interface com.intellij.psi.PsiReference. Googling for "PsiReference" and "IntelliJ" or "IDEA" unfortunately did not bring up any tutorials on how to use it, but I found the class XmlValueReference which sounds useful. Yet again googling for "XmlValueReference" did not turn up anything useful on how to use the class. At least the PSI Cookbook tells me that I can find the Java class by using JavaPsiFacade.findClass(). I'd be thankful for any tutorials, hints and the like, that tell the correct usage.
The above linked discussion mentions that I need to call registry.registerReferenceProvider(XmlTag.class, provider) in order to register my provider once I eventually managed to implement it, but of which type is "registry" and where do I get it from?
First of all, here's a nice tutorial that came up a few days ago, which explains the basics of IntelliJ plugin development (you should take a look at the section Reference Contributor).
You will likely have to define your own PsiReferenceContributor, which will be referenced in your plugin.xml like this:
<psi.referenceContributor implementation="com.yourplugin.YourReferenceContributor"/>
In your reference contributor, there's a method registerReferenceProviders(PsiReferenceRegistrar) where you will be able to call registry.registerReferenceProvider(XmlTag.class, provider).
Finally, in your instance of PsiReferenceProvider, you will have to test the tag name to filter out tags which don't contain class references, then find the right Java class using JavaPsiFacade.findClass().
From my experience, the best place to get help regarding IntelliJ plugin development is JetBrains' forums.

Custom GUI template script creator

My app currently reads a script containing instructions on what the app should do next. Think of it this way ---> My app is like an orchestra, and when it is passed sheet music (the script), it knows what to do. The sheet defines what different parts of the orchestra do at different times.
Currently, writing the script by hand is tedious. I want to be able to define chunks, which I can drag and drop from my gui to the script. I was wondering if there already is tools which let you do something like this, or if I should write my own tool.
Basically, when I click on something in the gui, it should insert a template into my plist, which I can tweak.
EDIT: It looks like the ability to create "Property list Structure Definitions" is what I am after. I have tried searching the apple site, but I can't find any documentation.
Two things come to mind:
You don't mention what format the input is in, nor what you want the GUI tool to do beyond letting you "drag chunks". But if you can define your format into an XML schema, then you can use any number of XML authoring tools that customize their interface based on schema. Also gives you the ability to make it easy to let the UI enter parameters/customization, which your script language likely has. Final bonus: you might be able to convert script directly into a plist with a simple XSLT file.
Check out Briefs, which is a prototyping application for iOS apps that has a similar architecture.

Add custom words and definitions to UIReferenceLibraryViewController

I would like to provide custom definitions for financial terms (in different languages) in my application using the UIReferenceLibraryViewController, which was introduced in iOS 5.
However, I have not found any information on how to add custom definitions to the reference.
Do you have any suggestions on how to implement this useful feature?
From the documentation:
It should not be used to display wordlists, create a standalone dictionary app, or republish the content in any form.
So, you won't be able to add new definitions.
A quick search on github gives some dictionary sample apps that could be a starting point. See : http://github.com/mattneary/Etymology-for-iPhone or http://github.com/ioseb/LinGEO

How to generate navigation tree in doxygen output?

If you've used javadoc and then come to doxygen, you may know what I mean when I say I miss the hierarchical (frame-based) view that made jumping from class to class and method to method easy. (For those who haven't seen it, imagine a tree-navigator in an IDE or over a filesystem).
How can I get Doxygen to include a navigation tree, if it's even possible?
A similar question was asked in October, but that was just about stylesheet alternatives and only one turned up. I think I'm looking for something more major.
Note that all you need to do to get the tree on the left in Quinn's example is setting GENERATE_TREEVIEW to YES in the config file.
At a basic level, Doxygen output is what it is, and I don't think there's "a better way to view" static HTML content. I think what you want is for Doxygen to produce HTML output that is more similar to Javadoc, which has both pros and cons. (The biggest drawback is that it's unlikely to happen, due to the effort involved and the broad user base.)
I manage a project that is documented using Doxygen, and I'm not sure to what degree my config uses the Doxygen defaults, but I get a sections in the left frame for a flat class list and a class hierarchy. Also, since I have diagrams enabled, the Graphical Class Hierarchy is a fairly quick way to jump to where I want. I haven't delved into Doxygen modules, so I don't have any experience with whether that might segment things similar to how Javadoc does with packages.