I want to achieve following functionality:
User places the mouse cursor over a text item in the editor and this is being detected automatically, triggering a menu item to be enabled in the menu (when user moves mouse away, the menu item is disabled again).
As I'm a little new to xtext and RCP in general, I don't know where to start. I only don't know how to implement detecting if the cursor is over a certain element in my DSL code. Is there any way to achieve this?
Kind regards,
Marko
Yes, XText support hover detection. There are some sources in internet, that might be helpful for you.
http://christiandietrich.wordpress.com/2011/07/16/hover-support-in-xtext-2-0-tutorial/
http://ckulla.wordpress.com/2011/02/06/hover-support-in-xtext-2-0/
http://www.eclipse.org/forums/index.php/mv/msg/452862/1008201/#msg_1008201
Related
I am developing a simple swing application and I would like to have something which can help user with it.
As example a little popup window will appear over "Start" button when user runs app first time and say "Hey, click here to start playing with me!"
Do you know the way to create something like quick doc in Intellij Idea?
Could you please put me on the right way to sources, examples, source codes or anything else which could be useful?
Below is example of how it can look like
PS. I have updated the picture.
As I said in the comment use javax.swing.PopupFactory to show popup for any component (which is probably not pointed by the mouse)
Popup p = PopupFactory.getSharedInstance().getPopup(component, new JLabel("It's a hint!"), 5, 5);
p.show();
component is the widget for which the popup must be shown.
You can also use the javax.swing.Timer to hide this popup automatically.
Tooltips are used in Swing to give the hover-over text that you are looking for. It is very easy to use a tooltip, all you have to do is set the tooltip text on your button
btnStart.setToolTipText("Hey, click here to start playing with me!");
Here is a pretty useful guide that explains the topic in more depth http://docs.oracle.com/javase/tutorial/uiswing/components/tooltip.html
I have a graphical editor written with GEF. In this editor it's possible to drag and drop elements around and create connection by dragging and dropping on specific anchor points.
Everything works fine, except that the diagram does not automatically scroll when the user drags stuff around.
I would expect the diagram to scroll automatically when the user reaches the side of it while dragging something.
Is such a feature supported by GEF? Which class/setter should be called to enable it?
If it's not directly supported, how to proceed to achieve it?
It's been a while since I last fiddled with GEF.
Does drag and drop not work at all or just in the direction of negative coordinates?
What Layout are you using?
IIRC, there were different layouts with one of them (FreeForm?) supporting negative coordinates, so if you just have trouble with negative coords, you could try to change the Layout.
Here is an example of a Scrolling Graphical editor (the author says ;)) which might give you a good hint.
And there is a class named org.eclipse.gef.ui.parts.ScrollingGraphicalViewer that might help, too.
Only hints, though, since I don't know your code.
First step is to make your canvas scrollable. This is explained in this book, pages 96 - 101.
Assuming you are already drawing your figures on a FigureCanvas and you're using FreeformFigures and FreeformLayer, you can do the following:
Add a MouseMoveListener on your Figure in its EditPart. Each time a drag is detected, in the mouseDragEvent method, reveal your figure with getViewer().reveal(EditPart.this).
This will cause your Figure to always be constantly revealed when it's being dragged.
I'm using a dynamic graphic library to display data. By clicking with the left button on a node, a window pops out displaying info about it. I would like to use the right button instead, which by now is used to move the node around (without the window popping out). The problem is: the graph listeners I'm using only respond to the left button. So the only solution I can think of is to swap the mouse buttons mapping on the java application. Is there a way to achieve this?
I might be wrong, but can you use MouseListeners for right click, and than use java.awt.Robot to left click that? just a thought. good luck.
Whoops, sorry. I already solved this a long time ago and I forgot to post the answer: The library I'm using is graphstream, and I just needed to set the graph DefaultMouseManagerm (with overriden functions) which takes care of mouse clicks on the graph.
I'm currently teaching myself LWJGL's mouse class, but there is something I still don't know how to do. I want to be able to handle double-click mouse events, but I don't know how.
It is not (AFAIK) natively supported. You have to do it yourself.
One way to do that : memorize the event date (System.curentTimeMS() or equivalent).
If the previous clic event was recent (~200 ms), it's a double-clic. else, simple clic.
Hope it helps...
When using a screenreader, like NVDA, I want to be able to hear the text of the menu when I hover my mouse over it. I am able to hear the text when I push the buttons in the menubar, but not when I hover over them (the screenreader does reads the menu's of other programs when only hovering over the buttons).
I have set the AccessibleContext like below:
JMenu.getAccessibleContext().setAccessibleName("text");
JMenu.getAccessibleContext().setAccessibleDescription("more text");
I can set listeners to the objects that detects when a mouse hovers over them, but I do not know if/how I can cast a text to the screenreader to read. I tried ToolTipText, but that text is not read by the screenreader either. RequestFocus on the JMenu works, but setting the focus to an object just by hovering over it with the mouse provides other problems.
Does anyone knows how I can let a screenreader reads the JMenu-text when hovering with the mouse over the menubar?
I am using Java6 EE and the Java AccesBridge (version 2.02) on a Windows machine (XP and w7).
Swing is the weaker of the GUI technologies relating to accessibility in Java, compared to SWT at any rate. There's a few things you can try.
First is to make sure any accessibility fields are set (which you've started on). I can't remember if Java has an AccessibleRole field, but you can try setting that to menu and menuitem for your menu items.
Another thing you can try is the AccessibleMenu JMenu.AccessibleJMenu component. This one's the product of further reading, so I can't verify it from experience. But it and its surrounding classes may suit your needs.
If those don't work, you could try the option of talking to people's screen readers directly. Quentin C has a good library to do this, Universal Speech. I'm new to this library myself, but it does have a Java implementation in there that should show you how to use it in a Java program. Normally I wouldn't recommend this approach unless making the UI accessible really isn't working.
The last option would be to use the SWT components instead of the Swing ones, even if just for your menu bar. I wasn't sure how keen you'd be on this one, but it is an option and should resolve it.
I hope one of these suggestions helps you solve your problem.