From 3ffbac56da0fadbb0ff39bd08eb5ab572b0678c5 Mon Sep 17 00:00:00 2001 From: serge-rider Date: Fri, 6 Apr 2018 23:59:41 +0300 Subject: [PATCH] #3278 Popup UI model --- .../org.jkiss.dbeaver.ui/META-INF/MANIFEST.MF | 4 +- .../ui/notifications/NotificationPopup.java | 25 ++++++++++ .../NotificationPopupMessage.java | 47 +++++++++++++++++++ 3 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/notifications/NotificationPopup.java create mode 100644 plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/notifications/NotificationPopupMessage.java diff --git a/plugins/org.jkiss.dbeaver.ui/META-INF/MANIFEST.MF b/plugins/org.jkiss.dbeaver.ui/META-INF/MANIFEST.MF index 0353dcaacd..5a444f5995 100644 --- a/plugins/org.jkiss.dbeaver.ui/META-INF/MANIFEST.MF +++ b/plugins/org.jkiss.dbeaver.ui/META-INF/MANIFEST.MF @@ -15,5 +15,7 @@ Require-Bundle: org.eclipse.core.runtime, org.eclipse.ui.editors, org.eclipse.ui.views, org.eclipse.ui.workbench.texteditor, + org.eclipse.mylyn.commons.ui, org.jkiss.dbeaver.model -Export-Package: org.jkiss.dbeaver.ui +Export-Package: org.jkiss.dbeaver.ui, + org.jkiss.dbeaver.ui.notifications diff --git a/plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/notifications/NotificationPopup.java b/plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/notifications/NotificationPopup.java new file mode 100644 index 0000000000..e33c6c2356 --- /dev/null +++ b/plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/notifications/NotificationPopup.java @@ -0,0 +1,25 @@ +package org.jkiss.dbeaver.ui.notifications; + +import org.eclipse.mylyn.commons.ui.dialogs.AbstractNotificationPopup; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.ui.PlatformUI; +import org.jkiss.dbeaver.model.DBPDataSource; +import org.jkiss.dbeaver.utils.GeneralUtils; + +public abstract class NotificationPopup extends AbstractNotificationPopup { + + public NotificationPopup(Display display) { + super(display); + } + + public NotificationPopup(Display display, int style) { + super(display, style); + } + + + +} \ No newline at end of file diff --git a/plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/notifications/NotificationPopupMessage.java b/plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/notifications/NotificationPopupMessage.java new file mode 100644 index 0000000000..b6e891ee6d --- /dev/null +++ b/plugins/org.jkiss.dbeaver.ui/src/org/jkiss/dbeaver/ui/notifications/NotificationPopupMessage.java @@ -0,0 +1,47 @@ +package org.jkiss.dbeaver.ui.notifications; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.ui.PlatformUI; +import org.jkiss.dbeaver.model.DBPDataSource; +import org.jkiss.dbeaver.utils.GeneralUtils; + +public class NotificationPopupMessage extends NotificationPopup { + + private final DBPDataSource dataSource; + private String messageText; + + public NotificationPopupMessage(String text) { + this(null, text); + } + + public NotificationPopupMessage(DBPDataSource dataSource, String text) { + super(PlatformUI.getWorkbench().getDisplay()); + + this.dataSource = dataSource; + this.messageText = text; + setDelayClose(3000); + } + + @Override + protected String getPopupShellTitle() { + return dataSource == null ? GeneralUtils.getProductName() : dataSource.getContainer().getName(); + } + + @Override + protected void createContentArea(Composite composite) + { + composite.setLayout(new GridLayout(1, true)); + Label linkGoogleNews = new Label(composite, SWT.NONE); + linkGoogleNews.setText(messageText); + //linkGoogleNews.setSize(400, 100); + } + + public static void showMessage(DBPDataSource dataSource, String text) { + Display.getDefault().syncExec(() -> new NotificationPopupMessage(dataSource, text).open()); + } + +} \ No newline at end of file -- GitLab