I have an Eclipse plugin that makes use of several keybindings (Alt-G x, Alt-G y, etc...). For most keyboard layouts, there are no problems for these specific keybindings. However, for Swiss German, it turns out that 'Alt-G' creates '#' and this makes it very hard for Swiss Germans to use the plugins I created. I do not want to change the current keybindings since this would confuse existing users.
My question is:
How can I programmatically detect that a user is on a Swiss German keyboard and programmatically disable (or change) those keybindings?
(Is this something I can specify in the plugin.xml?)
To answer my own question, you can use the org.eclipse.ui.bindings extension point to completely solve the problem.
First, you set a keybinding as you normally would, and then you can un-set that particular keybinding on a single locale. And for that locale only, you can re-set the binding to something different.
This works, but is unfortunately very verbose if you have lots of keys to bind, unbind, and rebind.
Here is an example:
<!-- set binding globally -->
<key
commandId="com.foo.myCommandId"
contextId="org.eclipse.ui.contexts.window"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M3+G T"/>
<!-- un-set binding for Swiss German -->
<key
commandId="com.foo.myCommandId"
contextId="org.eclipse.ui.contexts.window"
locale="de_CH"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M3+G C"/>
<!-- re-set binding for Swiss German with a new key combo -->
<key
commandId="com.foo.myCommandId"
contextId="org.eclipse.ui.contexts.window"
locale="de_CH"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M1+M3+G C"/>
Related
I have a eclipse plug-in, to be more precise I have an action which is triggered via the context menu of any folder. I do also have a Preferences page where I have a checkbox. I want to only display the action if that checkbox is enabled.
My plugin.xml:
<action
class="com.something.MyClass"
enablesFor="1"
id="com.something.MyClass"
label="Label
menubarPath="path/group.smth">
<enablement>
<objectClass
name="org.eclipse.core.resources.IFolder">
</objectClass>
</enablement>
</action>
So. Is there any possibility to display the action based on a specific preference?
Thanks in advance.
I don't think you can do that using (deprecated) actions as the enablement expression is rather limited.
You can also use the org.eclipse.ui.menus extension point to contribute to context menus. In this case you can use the test element to invoke a 'property tester' defined using the org.eclipse.core.expressions.propertyTesters extension point. I don't think there are any predefined property testers for preferences but testers are not difficult to write.
I'm developing tow eclipse plugin, I have the next problem:
I have two perspective that manages the same files. I would like to make an association between file extension - editor - perspective.
I mean if I open the file extension .XXX in perspective 1 it uses the editor A, but if I open the same file extension .XXX in perspective 2, it uses the editor B.
is it possible? Since now, I used the launcher but now I need more differentiation.
Thanks.
(Sorry, this is one of those "don't do that!" non-answers. :))
As mentioned in the comments, I'd recommend against opening a different editor depending on the current perspective. I think that goes against the expectations of the user, and has some unintuitive consequences, e.g. when I create my own perspectives.
I'd recommend going the path of Eclipse' XML/Plug-in manifest editors, for example. Tabs at the bottom allow the user to choose between the different views, independent of any perspective choice or configuration.
While I agree that this seems a little strange to have the default editor be different for the same file based on the open perspective, here is how you could do it.
Create two new Content Type extensions
Register your first editor as default editor for 1st new Content Type
Register your 2nd editor as the default editor for the 2nd new Content Type
For each content type, you have a 'content type describer'. In these describer classes, have it check the active workbench page for the current perspective ID and if it matches the expected value, then VALID, if perspective id doesn't match, return INVALID.
For both editors you need to associate those editors with a content-type instead of a file-extension or filename
Now only one content type will match at a time depending on which perspective is open. Make sure that one of the content types is the 'default' so that it will always match if the user has some other perspective open.
Update #1 added some examples
There are some online tutorials for this. But here is some example code to make it easier to see what work is required. Here is how you declare your content types (you would need two of them)
<plugin>
<extension
point="org.eclipse.core.contenttype.contentTypes">
<content-type
base-type="org.eclipse.core.runtime.xml"
describer="com.liferay.ide.core.FirstContentTypeDescriber"
id="com.liferay.ide.core.contentType1"
name="First Content Type"
priority="normal">
</content-type>
</extension>
</plugin>
Then in the Describer class you would do your matching logic. Then in the editor extension point you reference a content type instead of a file-name or extension like this:
<extension
point="org.eclipse.ui.editors">
<editor
class="com.liferay.ide.ui.FirstEditor"
default="false"
id="com.liferay.ide.ui.editor1"
name="My First Editor">
<contentTypeBinding
contentTypeId="com.liferay.ide.core.firstContentType">
</contentTypeBinding>
</editor>
</extension>
I would recommend to rethink your approach, and take some cues from WindowBuilder: have one editor associated with the file type which opens a tabbed editor; if a second plugin is added, have it create a separate tab on the same editor.
Other option may be programmatically change file type association with Java code shown in
Eclipse RCP: programmatically associate file type with Editor?
Then there is only a question how to execute that code on perspective change event.
How to change caret (cursor) blinking rate in NetBeans? (7.0)
NetBeans developers say that this is supported as a Swing option, see Bug 124211 - Cursor blink rate too fast but I can't figure out the name of this Swing option to set from the command line.
The closest example of setting Swing option that I found is setting look and feel by putting
-J-Dswing.defaultlaf=com.sun.java.swing.plaf.windows.WindowsLookAndFeel to the netbeans.conf.
I realize this is old, but it's quite high up in google search so I thought I'd add an updated solution. The solution above by Tushar Joshi does not work for me in Netbeans 7.1.1. What I had to do, was quite similar though:
Basically, the setting have moved to <userdir>\config\Editors\text\x-java\Preferences\org-netbeans-modules-editor-settings-CustomPreferences.xml.
The path for Unix/Linux is $HOME/.netbeans/<NetbeansVersion>/config/Editors/Preferences/org-netbeans-modules-editor-settings-CustomPreferences.xml.
Exit netbeans and modify the file by adding the entry
<entry javaType="java.lang.Integer" name="caret-blink-rate" xml:space="preserve">
<value>1000</value>
</entry>
The value is the number of milliseconds of blink rate. I added a whole second. I added it so it lined up alphabetically with the other name properties of the other entries, but I don't know if that's important or not. That's it:)
There was a module for customizing the Cursor Blinking Rate created by Emilian Bold, but that module is not found easily available. Let me provide a less intuitive way but this solution works with NetBeans IDE 7.0.1 as tested by me.
Make sure the NetBeans IDE is shut down before making these changes.
Create file <userdir>/config/Editors/text/x-java/properties.xmlHere the <userdir> means the User directory used by NetBeans IDE. This directory can be found from the NetBeans Help > About menu. The config folder will already be there in this directory but the folders Editors/text/x-java may not be there and we will have to create them, they are case sensitive. The properties.xml file shall also be created in the x-java folder.
Add the following contents to the properties.xml file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties PUBLIC "-//NetBeans//DTD Editor Properties settings
1.0//EN" "http://www.netbeans.org/dtds/EditorProperties-1_0.dtd">
<properties>
<property class="java.lang.Integer" name="caret-blink-rate" value="0"/>
</properties>
The value="0" portion can be customized by desired blink rate in miliseconds, the default value used by NetBeans IDE is 300 in my opinion, but it can be changed with a new value, 0 will mean no blinking.
Start NetBeans IDE again and now you will get your desired blink rate for the cursor in Java files.
If you would like to disable it for all editors, instead of just the Java editor, add the following:
<entry javaType="java.lang.Integer" name="caret-blink-rate" xml:space="preserve">
<value>2147483647</value>
</entry>
under the <editor-preferences> element to the file:
config/Editors/Preferences/org-netbeans-modules-editor-settings-CustomPreferences.xml
The full paths are:
On Mac:
~/Library/Application Support/NetBeans/8.2/config/Editors/Preferences/org-netbeans-modules-editor-settings-CustomPreferences.xml
On Windows:
%APPDATA%\NetBeans\8.2\config\Editors\Preferences\org-netbeans-modules-editor-settings-CustomPreferences.xml
Source: https://forums.netbeans.org/topic9561.html
Is is possible to get Emacs show different parts of file with different fonts? As a specific problem, I would like to be able to render following small XML file otherwise normally but the 'text' part inside 'example' elements with different font and font size.
<?xml version="1.0"?>
<root>
<example>text</example>
</root>
If it makes any difference I have GTK+ Version 2.22.0 of GNU Emacs 23.1.1.
Yes. Assuming you're using something like nxhtml-mode (which uses mumamo or "multiple major modes mode"), you should be able to do M-x customize-group mumamo [RET], find the font face you want to customize, and go at it. It'll place a block of code in your ~/.emacs that you can look at if you'd like to tweak it by hand.
Is it possible to set tabs to have a different background color (e.g. slightly grey) or put a little symbol (like "↦") in Eclipse text editors? If it's language specific, I'm using PHP.
Our company coding standard is Tabs for indenting, but often there are spaces in the source code, so it would be great to see where these spaces are so that I can correct them when working on that bit of the code. I don't want to run a script to just fix them globally because that would break merging in our version control, and they may come back without the developer realising if they copy and paste some sample code or something.
What would be really nice is if it could highlight spaces at the beginning of lines or spaces after tabs with a red background or something. I can sort-of simulate this by doing a regex search for "^|\t +", but that also highlights the tab itself, and I'd like this to be permanently highlighted, even when I am using the search for other things.
In the preferences dialog: General -> Editors -> Text Editors : Show whitespace characters.
(This works in Eclipse 3.5 at least).
You need an external plugin for that.
The following uses Checkstyle (for Java) for illustration.
But you can use phpcheckstyle (same idea, but you need to patch that oppen source to add the regex detection. See the forum for patch examples)
^[\t]*? [\t ]*?\S.*?$
alt text http://img825.imageshack.us/img825/390/eclipsecsspace.png
Use the following module:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "configuration_1_3.dtd">
<!--
This configuration file was written by the eclipse-cs plugin configuration editor
-->
<!--
Checkstyle-Configuration: t
Description: none
-->
<module name="Checker">
<property name="severity" value="warning"/>
<module name="TreeWalker">
<module name="Regexp">
<property name="format" value="^[\t]*? [\t ]*?\S.*?$"/>
<property name="message" value="spaces are used instead of tab for indent"/>
<property name="illegalPattern" value="true"/>
</module>
</module>
</module>
Note the configuration_1_3.dtd: you need one dtd if you can't access the one originally written in the module xml file (http://www.puppycrawl.com/dtds/configuration_1_2.dtd: see Module XML configuration)