Java RCP/SWT - “Android Toast like” dialog in Eclipse RCP

我怕爱的太早我们不能终老 提交于 2019-12-21 18:35:30

问题


Does anybody know if there exist some implementation of some popup window, something like in Android: TOAST ?


回答1:


The notifications are part of Mylyn commons.

To integrate them, add the Mylyn Commons Notifications feature from http://download.eclipse.org/mylyn/releases/latest to your target platform definition. The relevant bundles are

  • org.eclipse.mylyn.commons.notifications.ui
  • org.eclipse.mylyn.commons.notifications.core.

You can add a category and an event to the notifications extension point like this:

</extension>
  <extension
        point="org.eclipse.mylyn.commons.notifications.ui.notifications">
     <category
           icon="icons/obj16/repository.gif"
           id="myNotificationCategory"
           label="My Category">
     </category>
     <event
           categoryId="myNotificationCategory"
           icon="icons/obj16/some-image.gif"
           id="myEvent"
           label="Hello World">
        <defaultHandler
              sinkId="org.eclipse.mylyn.commons.notifications.sink.Popup">
        </defaultHandler>
        <description>
          This is the description of the event.
        </description>
     </event>
</extension>

To trigger a notification, use the NotificationService like this:

AbstractUiNotification notification = ...
NotificationsUi.getService().notify( asList( notification ) );

The notification must be a subclass of AbstractUiNotification where the eventId passed to the constructor must match the one from the extension.

The notifications plug-in also adds a preference page under General > Notifications that lets the user choose which notifications should be shown.




回答2:


No, but you can use the plugin org.eclipse.mylyn.commons.ui, which contains interesting classes to display notification(s) at the bottom right of the screen.



来源:https://stackoverflow.com/questions/17110234/java-rcp-swt-android-toast-like-dialog-in-eclipse-rcp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!