Eclipse plugin development: how to add functionality to editor - plugins

I have been trying there last days to extend the default editor (java, xml, all of them) functionality,
what I want to do is add a big ruler with text on the side of every editor.
example:
a default editor page looks like this:
|-----------|
|source |
|code |
| |
|-----------|
but i want it to be like this
|------|----|
|source| |
|code |line|
| |text|
|------|----|
also i can't use a view because the text in my ruler corresponds to a certain line and has to scroll along with the source code.
I have tried to do this by implementing IEditorActionDelegate
since I don't want a new editor, but to add functionality, but I could not find any solutions.
Wanted to mention that for putting my solution in practice i extended AbstractContributedRulerColumn
public class MyRuler extends AbstractContributedRulerColumn {
....
}

Arne's answer gave some good suggestions, but it still took me a while to figure out how to write a plugin that adds a column of text next to the editor.
I published a sample that just displays line numbers with an "x" after each line. Some useful resources I found along the way were:
Introduction to plugin development
Eclipse extensions and extension points
LineNumberColumn example that is really just a small amount of code that delegates to LineNumberRulerColumn buried in a bunch of compatibility stuff.

I think you are after the extension point org.eclipse.ui.workbench.texteditor.rulerColumns. The component that displays the line numbers in text editors is added using this point, so it should be possible to add other information, too.
Example from the API doc:
<extension
point="org.eclipse.ui.workbench.texteditor.rulerColumns">
<column
id="org.eclipse.ui.editors.columns.linenumbers"
name="Line Numbers"
class="org.eclipse.ui.internal.texteditor.LineNumberColumn"
enabled="false"
global="true"
includeInMenu="false">
<placement
gravity="0.9">
<after id="org.eclipse.ui.editors.columns.annotations"/>
</placement>
<targetClass
class="org.eclipse.ui.texteditor.AbstractDecoratedTextEditor">
</targetClass>
</column>
</extension>

After working with the ruler columns extension point for a while, I learned about the org.python.pydev.pydev_pyedit_listener extension point that lets you intercept the PyEdit creation event and wrap other controls around it. Some digging in the SWT widget reference let me add another pane on the right with a splitter, and I published a sample project. The main advantages are that you can choose where the new display appears, you can use any controls you like, and the user can scroll if there's too much text to fit in the display.

Related

In Microsoft Dynamics 365, why is my filter not a combo box when I am running start my Visual Studio Project?

I'm currently following the tutorial "Creating a custom filter control" in Dynamics 365 for Finance and Operations Development Cookbook - Fourth Edition
I've created the extension to the MainAccount which includes, under NavigationList(Group) -> Filter (Group)", an instance of Combo Box with the following properties:
| Property | Value |
| Name | FilterType |
| AutoDeclaration | Yes |
| EnumType | DimensionLedgerAccountType |
| Selection | 10 |
In Visual Studio's preview, this displays correctly and offers the expected set of values.
I've set my project to be my startup project.
I've set my form extension to be my startup object.
... and then I click "Start".
After some long wait for the page to render, I find the labels for the fields are displayed with short black lines where the input fields should be, but the input fields hardly allow any interaction. I can click on them to select them, transforming them into blue box shapes, but I can't actually type anything into them and the input which should be a drop-down/combo-box for "type" has no visual or functional distinctions from the input for "name" which should just be text.
Is Visual Studio failing to deploy something?
Is there some additional modification needed in my metadata for this to render as expected?
What do I need to do to fix this?
Because you mention that you click "Apply", I think you are in the wrong area of the form.
Take a look at the screenshot from my implementation of the recipe, you can see there are two filter areas on the form. The first is the standard filter experience and the listed fields are based on the ranges set on the query of the form. Those fields are text fields because they allow you to enter filter values which may be different from one possible value. The second area is the one where the two custom filter controls described by the recipe in the cookbook were added. As you can see in the screenshot, the "Main account type" control provides a combo box behavior with the allowed values. If you change a value in on of these two controls, you don't need to click "Apply". Instead, the filters are applied automatically when the onModified event of the control fires.
With thanks to FH-Inway who spent some time screen sharing, it turns out the problem was not with the solution but with my expectations.
I expected the filter fields to simply be displayed and immediately available for use.
However, in actually -- completely counter-intuitively -- the fields, being created as part of the form, are only editable after one clicks the "Edit" button.
Once in edit mode, the fields display and interact as expected.

Highlighting Flex 3.5 CDATA component in Eclipse

Is there any way to highlight the CDATA component in a .mxml file?
I have Eclipse and Flash Builder 3.5 and the flex components are highlighted, but the CDATA isn't. It contains action script.
Sorry, I meant syntax highlighting. For example:
<mx:Canvas ... >
<mx:Script>
<![CDATA[
private function foo():void {}
]]>
</mx:Script>
I don't think so, but your Outline View should allow you to click on any script tags to highlight them. Unfortunately you can't give them different ID's, so splitting your code among different blocks doesn't help much.

How to use TableViewer in WindowBuilderPro?

I have to create a table in my wizard page and I want to create it using TableViewer. I'm using WindowBuilderPro for designing my wizard page. The TableViewer control is available in the palette of WindowBuilderPro but I'm not getting how to use it properly.
Has any body used the same?
Thanks a lot in advance!!
You have two ways of filling the TableViewer with contents (similar to TableViewers in JFace):
You can define a content provider and a label provider manually. A content provider has to return a set of Objects, that represent each line of the table; while the TableLabelProvider translates the returned objects to texts in the columns. The content and label providers are to set in the Properties box on the left. In this case, the resulting code should look like the following snippets: http://wiki.eclipse.org/JFaceSnippets#Snippet001TableViewer or http://wiki.eclipse.org/JFaceSnippets#Snippet007FullSelection.
On the other hand you could define JFace Data Bindings to fill the table with contents. In this case you have to define a corresponding binding, that returns the list of all contents; additionally you have to create a label provider, that works similar to the previous one.
There is also a way to fill the table content using a newer API then supported directly by WindowBuilder: you could create TableViewerColumns, and ColumnLabelProviders for each column, thus resulting in much nicer code for Label Providers (and also this API is newer, so it should be preferred for new JFace based code) - but in this case you have to create your code manually. See the JFace Table tutorial from Lars Vogel.
Additionally, if you don't know the JFace Viewer framework from before, I suggest reading the first few questions listed in the JFace FAQ to gain a better understanding of the ideas (and the tutorial from Lars Vogel is also nice for this reason).

How to make tinymce styleselect to overwrite actual class with selected one

As i use styleselect combobox, i am able to apply many classes to one object simply by chosing each style from styleselect combobox, and I can turn off class only by chosing same class again. so all styles work like "checkboxes", and i wish to make from them "radiobuttons", i want mine tinymce to apply max 1 class to object, if parent has class, then split parent and aply class, for example
Some text here (i select "text" and set my_class2) and i wish to get result:
Some text here
and 2nd case, if i select all "Some text here" and aply my_class2 i wish to get result:
Some text here
(now result will be: Some text here
I hope it's clear now ;)
Best regards!
You might, if you don't mind meddling in their code. using the formatselect option, check out theme_advanced_blockformats in editor_template_src.js and add your tags with 'class=moshe' in them.. there could be only one tag (it replaces them), so you got your radio buttons :)
There is no standard way to insert checkboxes inside the tinymce UI. You should be able to make it work using checkboxes outside the editor and link to the function the style plugin uses.

Looking for a Combo(Viewer) in SWT/JFace which supports autocomplete

I'm looking for a Combo(Viewer) in SWT/JFace which supports autocomplete / type-ahead, i.e. the user can enter a couple of characters and the drop down list should show all matching elements.
You can also check out the org.eclipse.jface.fieldassist.AutoCompleteField class. It's not a combo, just a text field, but it adds auto complete functionality as if it were a combo very easily. You can do something as simple as this:
Text textField = new Text(parentComposite, SWT.BORDER);
new AutoCompleteField(textField, new TextContentAdapter(), new String[]
{"autocomplete option 1", "autocomplete option 2"});
I don't think there is anything like this built into either Combo or ComboViewer.
As thehiatus suggests org.eclipse.jface.fieldassist.AutoCompleteField is probably the best place to look for this, however, there is support for Combos:
new AutoCompleteField(combo, new ComboContentAdapter(), new String[]
{"item0", "item1"});
You may be interested in Eclipse's "Content Assist" feature. You can see it in action when using the Eclipse IDE's Java editor. As you edit source code, you will sometimes see a drop-down menu with phrases that complete what you were typing. (Note that you can press Ctrl+Space to force the drop-down menu to be displayed.)
You can implement this in your own SWT/JFace application as well. The "Java Developer's Guide to Eclipse" has an sample application that implements Content Assist. The sample application is a SQL editor, and it is described in Chapter 26, "Building a Custom Text Editor with JFace Text." There's actually an online overview of the chapter here. The sample SQL editor project, com.ibm.jdg2e.editor.jfacetext.sql, can be found here.
On the other hand, if you want to create your own Combo widget and auto-populate it based on input that is being entered, then this might not be very applicable. I'm thinking the org.eclipse.jface.viewers.ComboViewer might be helpful (though I'm not positive).
Check out: http://sourceforge.net/projects/swtaddons/
I use it in my project (with a little tweak).
It's really dead easy to set this up.
As thanks to paz117's comment, thought I'd share the code to make this work:
String[] proposals = new String[controller.model().size()];
for (int i = 0; i < controller.model().size(); i++)
proposals[i] = controller.model().get(i).getAppropriateName();
comboViewer = new ComboViewer(parent, SWT.NONE);
comboViewer.setContentProvider(new ArrayContentProvider());
comboViewer.setLabelProvider(new AppropriateLabelProvider());
comboViewer.setInput(_controller.model());
// additionally, configure the comboViewer arbitrary
new AutoCompleteField(comboViewer.getCombo(), new ComboContentAdapter(), proposals);
The only minor nuisance is that you have to separately populate the model of ComboViewer and AutoCompleteField separately, but that can be at least automated via a static utility method or something similar.
As reference for future visitors, the AutocompleteComboInput (SWT Add-on), can also be a way to achieve this.
Code snippet for screenshot (refer to documentation link above for the code template):
import net.sf.swtaddons.autocomplete.combo.AutocompleteComboInput;
...
subjectCodeCombo = new Combo(tab3Composite, SWT.DROP_DOWN);
// other code modifying Combo appearance here...
// returns a String[] of items retrieved from database
String[] subjectCodeArray = dbQuery.subjectsToArray();
subjectCodeCombo.setItems(subjectCodeArray);
subjectCodeCombo.setText("- SELECT -");
new AutocompleteComboInput(subjectCodeCombo);
The add-on requires all JARs below to be added to the Library: (more info)
eclipse-equinox-common-3.5.0.jar
net.sf.swtaddons_0.1.1_bin_src.jar (sourceforge)
org.eclipse.core.commands.jar
org.eclipse.jface-3.6.0.jar
Click here for JAR pack.