让 JFace 窗口在任务栏中闪烁或引起用户注意?
我想知道有人知道如何解决这个问题:
在我的 Java Eclipse 插件中,有一些过程需要一些时间。因此,用户可能最小化窗口并让进程在后台运行。
现在,当过程完成时,我可以强制窗口再次回到顶部,但这在可用性方面是禁忌。我宁愿让进程在任务栏中闪烁。有什么办法可以实现这一点吗?
我查看了 org.eclipse.jface.window 但找不到类似的东西,SWT 文档也是如此...
我想到的另一件事 - 由于人们也在 mac os x 和 linux 上使用这个应用程序,是否有一个独立于平台的解决方案 ,这将通知用户该过程已完成但不将窗口带到顶部?
非常欢迎任何想法!
编辑:
我发现在 Windows 上,用户可以调整是否要启用强制前台功能。如果禁用该选项,任务将在任务栏中闪烁...
这是一个很好的阅读 在那...
如果有人知道实现这种行为的某种独立于平台的方法,请与我分享您的知识!
I wonder someone has any idea how to solve this:
In my Java Eclipse plugin there are some processes which take some time. Therefore the user might minimize the window and let the process run in the background.
Now, when the process is finished, I can force the window to come to the top again, but that is a no-no in usability. I'd rather want the process to blink in the taskbar instead. Is there any way to achieve this?
I had a look at the org.eclipse.jface.window but could'nt find anything like that, same goes for the SWT documentation...
Another thing which came to my mind - as people are using this app on mac os x and linux as well, is there a platform independant solution, which will inform the user that the process has finished but without bringing the window to the top?
Any ideas are highly welcome!
Edit:
I found out that on windows the user can adjust whether he would like to enable a force to foreground or not. If that option is disabled, the task will just blink in the taskbar...
Here's a good read on that...
If anyone maybe knows about some platform independant way of achieving this kind of behaviour, please share your knowledge with me!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我认为没有一种独立于平台的方法可以做到这一点。您必须查看特定于平台的 API 调用并通过 JNI 或 JNA 实现它们。
对于 Windows,以下是我自己的一个应用程序的片段:
这是
getLibrary()
的简化版本:完成后请注意
dispose()
库它。I don't think there's a platform independent way of doing this. You will have to take a look at the platform-specific API calls and implement them via JNI or JNA.
For Windows, here's a snippet from one of my own applications:
Here's a simplified version of
getLibrary()
:Take care to
dispose()
the library when you're done with it.嗯,这并不完全是闪烁,但是从 Eclipse 3.6 M6 开始,您可以使用 SWT 以独立于平台的方式将文本、图像或进度条覆盖到 TaskItem。请参阅新增内容 和 SWT 片段.
Well, that's not exactly blinking, but since Eclipse 3.6 M6, you can overlay text, image or progress bar to the TaskItem in a platform-independent way with SWT. See the New and Noteworthy and the SWT snippet.
为了吸引用户的注意力而不令人烦恼,您可以做的就是更改窗口文本,这很简单:
这将允许用户在最小化窗口的同时获得更新,然后添加一个焦点侦听器以将窗口返回到重新获得焦点时其正常文本。这将在通知用户的同时将干扰降至最低。
What you could do to get the users attention without being annoying is to change the windows text this is protable with a simple:
this would allow the user to get an update while having the window minimized and then add a focus listener to return the window to its normal text when focus is regained. This would allow for minimal intrusiveness while informing the user.
我的插件也有类似的问题。
我最终做的是在较低的状态停靠栏(或底部的任何名称)中为我的程序创建一个小图标。根据进程和其他后台事件的完成,我的图标会改变颜色并闪烁(例如,当初始设置完成时,从灰色变为绿色)。
通过双击或右键单击该图标上下文相关,我可以执行诸如打开相应窗口之类的操作。
I had a similar problem with my plug-in.
What I ended up doing is creating a small icon for my program in the lower status dock (or whatever that thing at the bottom is called). Based on the completion of processes and other background events, my icon changes color and flashes (e.g., goes from grey to green when its initial setup is complete).
By making double clicks or right-clicks on this icon context-sensitive, I can then do things like open a corresponding window.