Compare commits

...

2 Commits

Author SHA1 Message Date
bhe-talendbj
fdc6830cf1 feat: notification demo 2021-08-31 18:02:57 +08:00
bhe-talendbj
d753d68d15 feat: notification demo 2021-08-31 17:56:21 +08:00
3 changed files with 89 additions and 1 deletions

View File

@@ -35,7 +35,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.talend.core.runtime,
org.eclipse.e4.ui.workbench,
javax.inject,
org.eclipse.m2e.core
org.eclipse.m2e.core,
org.eclipse.jface.notifications
Eclipse-LazyStart: true
Export-Package: org.talend.rcp,
org.talend.rcp.intro,

View File

@@ -24,6 +24,8 @@ import java.util.HashSet;
import java.util.Hashtable;
import java.util.List;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;
import org.apache.log4j.Logger;
import org.eclipse.core.commands.IHandler;
@@ -147,6 +149,8 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
public static final IExtensionPointLimiter GLOBAL_ACTIONS = new ExtensionPointLimiterImpl("org.talend.core.global_actions", //$NON-NLS-1$
"GlobalAction"); //$NON-NLS-1$
private Timer timer = new Timer();
/**
* constant from org.eclipse.ui.internal.IWorkbenchConstants;
*/
@@ -456,6 +460,23 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
}
});
}
timer.schedule(new TimerTask() {
@Override
public void run() {
Display.getDefault().asyncExec(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
NotificationPopUp np = new NotificationPopUp(PlatformUI.getWorkbench().getDisplay());
np.open();
}
});
}
}, 20000);
}
private void showStarting() {
@@ -619,6 +640,10 @@ public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
}
}
super.postWindowClose();
if (timer != null) {
timer.cancel();
}
}
/*

View File

@@ -0,0 +1,62 @@
// ============================================================================
//
// Copyright (C) 2006-2021 Talend Inc. - www.talend.com
//
// This source code is available under agreement available at
// %InstallDIR%\features\org.talend.rcp.branding.%PRODUCTNAME%\%PRODUCTNAME%license.txt
//
// You should have received a copy of the agreement
// along with this program; if not, write to Talend SA
// 9 rue Pages 92150 Suresnes, France
//
// ============================================================================
package org.talend.rcp.intro;
import org.eclipse.jface.notifications.AbstractNotificationPopup;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Shell;
/**
* @author bhe created on Aug 31, 2021
*
*/
public class NotificationPopUp extends AbstractNotificationPopup {
private Display display;
/**
* @param display
*/
public NotificationPopUp(Display display) {
super(display);
this.display = display;
}
@Override
protected String getPopupShellTitle() {
return "Update R2022-01 is available";
}
@Override
protected void createContentArea(Composite parent) {
Link link = new Link(parent, SWT.WRAP);
link.setText("<a>More information</a>");
Button btn = new Button(parent,SWT.NONE);
btn.setText("Update now");
}
@Override
public boolean close() {
boolean closed = super.close();
return closed;
}
protected Shell getParentShell() {
return this.display.getActiveShell();
}
}