Search in sources :

Example 1 with ScalingHyperlink

use of org.eclipse.mylyn.commons.workbench.forms.ScalingHyperlink in project liferay-ide by liferay.

the class Java8requiredSink method showPopup.

@Override
public void showPopup() {
    if (_popup != null) {
        _popup.close();
    }
    Shell shell = new Shell(PlatformUI.getWorkbench().getDisplay());
    _popup = new NotificationPopup(shell) {

        @Override
        protected void createContentArea(Composite parent) {
            super.createContentArea(parent);
            Composite composite = (Composite) parent;
            ScalingHyperlink hyperlink = new ScalingHyperlink(composite, SWT.NONE);
            hyperlink.setText("Got it, please don't show this alert again.");
            hyperlink.setForeground(new Color(null, 12, 81, 172));
            hyperlink.registerMouseTrackListener();
            hyperlink.addHyperlinkListener(new IHyperlinkListener() {

                @Override
                public void linkActivated(HyperlinkEvent e) {
                    _preventShowNotifications();
                    if (_popup != null) {
                        _popup.close();
                    }
                }

                @Override
                public void linkEntered(HyperlinkEvent e) {
                }

                @Override
                public void linkExited(HyperlinkEvent e) {
                }

                private void _preventShowNotifications() {
                    try {
                        IEclipsePreferences prefs = ConfigurationScope.INSTANCE.getNode(NotificationsCore.PLUGIN_ID);
                        prefs.putBoolean(NotificationsCore.SHOULD_SHOW_NOTIFICATIONS, false);
                        prefs.flush();
                    } catch (BackingStoreException bse) {
                        NotificationsCore.logError(bse);
                    }
                }
            });
        }

        @Override
        protected String getPopupShellTitle() {
            return "Liferay IDE Notification";
        }
    };
    _popup.setFadingEnabled(isAnimationsEnabled());
    List<AbstractNotification> toDisplay = new ArrayList<>(getNotifications());
    Collections.sort(toDisplay);
    _popup.setContents(toDisplay);
    getNotifications().clear();
    _popup.setBlockOnOpen(false);
    _popup.setDelayClose(60 * 1000);
    _popup.open();
}
Also used : ScalingHyperlink(org.eclipse.mylyn.commons.workbench.forms.ScalingHyperlink) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) Color(org.eclipse.swt.graphics.Color) BackingStoreException(org.osgi.service.prefs.BackingStoreException) ArrayList(java.util.ArrayList) Shell(org.eclipse.swt.widgets.Shell) IHyperlinkListener(org.eclipse.ui.forms.events.IHyperlinkListener) NotificationPopup(org.eclipse.mylyn.internal.commons.notifications.ui.popup.NotificationPopup) AbstractNotification(org.eclipse.mylyn.commons.notifications.core.AbstractNotification)

Aggregations

ArrayList (java.util.ArrayList)1 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)1 AbstractNotification (org.eclipse.mylyn.commons.notifications.core.AbstractNotification)1 ScalingHyperlink (org.eclipse.mylyn.commons.workbench.forms.ScalingHyperlink)1 NotificationPopup (org.eclipse.mylyn.internal.commons.notifications.ui.popup.NotificationPopup)1 Color (org.eclipse.swt.graphics.Color)1 Composite (org.eclipse.swt.widgets.Composite)1 Shell (org.eclipse.swt.widgets.Shell)1 HyperlinkEvent (org.eclipse.ui.forms.events.HyperlinkEvent)1 IHyperlinkListener (org.eclipse.ui.forms.events.IHyperlinkListener)1 BackingStoreException (org.osgi.service.prefs.BackingStoreException)1