how to fire dragble event in zk calendar component - java

Hi zk provide Drop event, but we need drag event for Calendar.When user drag content in that time some available field will be display, after drop it will be remove.

Zk doesn't provide a drag event at all.
So you have to use jquery to a add one to your component and fire
a zk event your self. Here is a short jq guide for dragging. Number 6
looks like the stuff you want to do.
Now, you could send an zk event in the callback method.
But, I think if you try to update the UI at server side, you
could get problems, because of zks repainting. I never
done this my self, so you have to try. But for sure, you
could mark the droppable areas at client side so you won't
have this problems.
If you try what I just discribed, please tell us your experiences
or problems, so that I/we can help.

Related

Block Swing pop-up from losing focus and closing

I'm developing a plugin for IntelliJ IDEA, which obviously uses Swing.
For a feature I have introduced I'd like to stop a JPopupMenu which uses JCheckBoxMenuItems from losing focus and closing.
You can see it in action.
I've debugged the code, but I couldn't figure out how to do it, also being I'm not that into Swing.
Could you maybe point me to useful listeners/blocks of code/ways to prevent this?
If you want to see code, the IntelliJ classes are
ActionPopupMenuImpl.MyMenu
ActionMenuItem
Edit: a better way need to be found as the uiRefreshed event isn't always called at the right time.
Just coordinate your code in a good way ;)
The Swing mechanism in IDEA is too complicated, and maybe it's better to not touch it. Just know that the mouse events are handled by a special listener and then redirected to Component(s).
That said, having an hold on the menu ActionButton. You can listen for the Lookup's uiRefreshed event and programmatically:
myMenuButton.click()
That's all.
You need to call it after the UI has been refreshed because the LookupUi might have changed in dimension or location.

Monitor interaction with child components of a top-level container [duplicate]

I have a Java swing application with several panel and transitions between them (button, inputs ...).
What I want now is to set a timeout for my whole application (that will logout the user on my software), and bring back the user to another JPanel (I don't need help for that part).
After some research I have found something that seems to work (not fully implemented atm), I'm adding Key, MouseMotion and MouseWheel listener to ALL my swing elements and reloading my timer for any user action.
I wanted to know if there is any built-in function that can handle such a situation or a nicer way to do it. Thanks
I'm adding Key, MouseMotion and MouseWheel listener to ALL my swing elements
You can check out Application Inactivity which does this using an AWTEventListener so you don't need to do it for all your components.
You provide the listener with an Action to invoke after your period of inactivity.

Key press events for GXT FileUploadField

GXT 3.x only.
It is becoming apparent to me that Sencha had deliberately designed FileUploadField to shunt off all key press events from ever being detected.
I tried to intercept onBrowserEvent(Event) and could not detect any key press events which I would have generated by keypresses while having focus on the FileUploadField component.
Where is the key-press event shunt?
I could not find any keypress handler insertion methods.
I wish to allow triggering the file upload by either press on the space-bar or enter key.
Short of rewriting a whole new component from scratch, could someone advise me what I could do to achieve my goal of a keyboard activated file upload?
onBrowserEvent won't recieve any events unless you sink them - did you make sure to call sinkEvents? How are you adding handlers? If you use addDomHandler, it will sink them for you, but addHandler either assumes that they are not dom events, or that you already called sinkEvents. Without sinking an event, the browser doesn't know to pass that event on to a GWT widget. If all events were sunk automatically, then every time you moved the mouse across the page you would see a firestorm of events as mousemove fired for every widget you passed, and all of its parents.
If you override onBrowserEvent, then you are building the method that describes how to handle the actual event that comes from the browser - that is where the com.google.gwt.user.client.DOM class wires into the Widget to give it events. Short of making that method final, there is no way to prevent you, the widget user, from getting those events as long as the browser is generating them and passing them through the event listener.
Even if onBrowserEvent has been overridden and made final, you can still get access to many events by creating a NativePreviewHandler and checking where the event is occurring. This gets you in to the event before it even goes to the widget itself - there you can call NativePreviewEvent.cancel() to prevent it from happening on the widget itself, or you can handle it early in the handler.

fire both blur and focus tightly coupled?

Any idea how I can fire the blur even just after the focus event, such that it doesn't occur "loosly coupled" (the actions are send one-by-one to the selenium server).
Let me explain:
In Selenium RC you fire the blur and focus through fireEvent(locator, "blur") and fireEvent(locator, "focus"). However, after the blur event is send to the browser the focus event doesn't directly follow the blur event in the javascript command stack. This is a problem is in the following case: detecting the blur of a group of widgets, like a group of textboxes.
What I do: all text boxes share the same listener and when a blur occurs I simple run an additional command that checks if a focus event was captured by one of the textboxes, if so, you ignore the blur. This additional command that I run in javascript is automatically executed after all waiting commands are run, in this case, a focus command is one of these waiting commands.
Back to Selenium RC: after the blur event is fired by the Selenium server, it waits for the next command, in this case the focus event and will fire it. However, as you can understand, in the mean time, the addiontal command already has been fired and no new focus event has been detected. As such, a group-blur is detected and handled, in this case however the blur is incorrectly handled as the focus isn't fired directly after the blur, such as a browser would do....
I hope you understand my problem as it's a bit hard to explain.
Any idea's on how to solve this? so I can test the correct behavior? (no my validation takes place too early as a group-blur isn't correctly captured)
I think the way to solve this: send a piece of javascript to the Selenium server that will be evaluated and will fire both events after eachother. Or not?... And you how would I do this?
I belive you are looking for:
selenium.getEval("[my JavaScript here]");
You can send a javascript snippet of your choice to get evaluated by the browser, this should enable you to chain a focus and blur into one command.

Global context menu for Cut/Copy/Paste with JTextField in Swing App?

What is the best way to implement a global default context menu for a Swing app that has the Windows-standard cut/copy/paste/etc. popup menu for things like JTextField? Tim Boudreau suggested installing a custom UI delegate in this javalobby thread but that was written with Java 5 in mind, so I'm wondering if there's a better way today.
Are there plans to add this behavior in a future version of Swing itself?
Good timing. My blog entry for tomorrow was going to be about using Global Event Listeners. The simple answer is to use an AWTEventListener (instead of a custom EventQueue) to listen for MouseEvents and to then check the mouse event to see if it is a popup trigger.
I'll post the link to the entry tomorrow afternoon (EDT) when I get it published.
Then you can decide which approach is better.
You can now check out the Global Event Listeners entry for a really simple example of using an AWTEventListener.

Categories

Resources