Search in sources :

Example 1 with AbstractNotification

use of org.eclipse.mylyn.commons.notifications.core.AbstractNotification 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)

Example 2 with AbstractNotification

use of org.eclipse.mylyn.commons.notifications.core.AbstractNotification in project liferay-ide by liferay.

the class ImportGlobalSettingsNotificationSink 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);
            hookHyperlink(parent);
        }

        @Override
        protected String getPopupShellTitle() {
            return "Liferay IDE Notification";
        }

        private void hookHyperlink(Composite parent) {
            Hyperlink hyperlink = null;
            for (Control child : parent.getChildren()) {
                if (child instanceof Hyperlink) {
                    hyperlink = (Hyperlink) child;
                    hyperlink.addHyperlinkListener(new IHyperlinkListener() {

                        public void linkExited(HyperlinkEvent e) {
                        }

                        public void linkEntered(HyperlinkEvent e) {
                        }

                        public void linkActivated(HyperlinkEvent e) {
                            if (popup != null) {
                                popup.closeFade();
                            }
                        }
                    });
                    return;
                } else if (child instanceof Composite) {
                    hookHyperlink((Composite) child);
                }
            }
        }
    };
    popup.setFadingEnabled(isAnimationsEnabled());
    List<AbstractNotification> toDisplay = new ArrayList<AbstractNotification>(getNotifications());
    Collections.sort(toDisplay);
    popup.setContents(toDisplay);
    getNotifications().clear();
    popup.setBlockOnOpen(false);
    popup.setDelayClose(60 * 1000);
    popup.open();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) Control(org.eclipse.swt.widgets.Control) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) ArrayList(java.util.ArrayList) 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) Hyperlink(org.eclipse.ui.forms.widgets.Hyperlink)

Aggregations

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