Révision 2592
tmp/org.txm.rcp/src/main/java/org/txm/rcp/notifications/Notifications.java (revision 2592) | ||
---|---|---|
1 |
package org.txm.rcp.notifications; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.io.IOException; |
|
5 |
|
|
6 |
import org.eclipse.swt.widgets.Display; |
|
7 |
import org.txm.utils.logger.Log; |
|
8 |
|
|
9 |
public class Notifications { |
|
10 |
|
|
11 |
final static protected File notifySendFile = new File("/usr/bin/notify-send"); |
|
12 |
/** |
|
13 |
* Display a notification, must be called within the UI thread |
|
14 |
* @param title |
|
15 |
* @param message |
|
16 |
*/ |
|
17 |
public static void simple(String title, String message) { |
|
18 |
simple(Display.getCurrent(), title, message); |
|
19 |
} |
|
20 |
|
|
21 |
/** |
|
22 |
* Display a simple notification title+message using the given Display |
|
23 |
* |
|
24 |
* If /usr/bin/notify-send exists (linux & gtk), it is used instead of the SimpleNotification class |
|
25 |
* @param display |
|
26 |
* @param title |
|
27 |
* @param message |
|
28 |
*/ |
|
29 |
public static void simple(Display display, String title, String message) { |
|
30 |
if (notifySendFile.exists() && notifySendFile.canExecute()) { |
|
31 |
String[] cmds = {"/usr/bin/notify-send", title, message, "--icon=dialog-information"}; |
|
32 |
try { |
|
33 |
Runtime.getRuntime().exec(cmds); |
|
34 |
} catch (IOException e) { |
|
35 |
// TODO Auto-generated catch block |
|
36 |
e.printStackTrace(); |
|
37 |
} |
|
38 |
} else { |
|
39 |
if (display == null) { |
|
40 |
Log.info(title+": "+message); |
|
41 |
} else { |
|
42 |
new SimpleNotification(display, title, message).open(); |
|
43 |
} |
|
44 |
} |
|
45 |
|
|
46 |
// MAC : |
|
47 |
// osascript -e 'tell app "Finder" to display dialog "Hello World"' |
|
48 |
// foreground : “System Events” |
|
49 |
// osascript -e 'display notification "Lorem ipsum dolor sit amet" with title "Title"' |
|
50 |
|
|
51 |
// WIN |
|
52 |
// errr... |
|
53 |
} |
|
54 |
} |
|
0 | 55 |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/notifications/AbstractNotificationPopup.java (revision 2592) | ||
---|---|---|
44 | 44 |
|
45 | 45 |
private static final int MIN_HEIGHT = 100; |
46 | 46 |
|
47 |
private static final long DEFAULT_DELAY_CLOSE = 8 * 1000;
|
|
47 |
private static final long DEFAULT_DELAY_CLOSE = 10 * 1000;
|
|
48 | 48 |
|
49 | 49 |
private static final int PADDING_EDGE = 5; |
50 | 50 |
|
... | ... | |
77 | 77 |
return; |
78 | 78 |
} |
79 | 79 |
|
80 |
AbstractNotificationPopup.this.closeFade();
|
|
80 |
AbstractNotificationPopup.this.close(); |
|
81 | 81 |
} |
82 | 82 |
|
83 | 83 |
}); |
... | ... | |
159 | 159 |
titleTextLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, true)); |
160 | 160 |
titleTextLabel.setCursor(parent.getDisplay().getSystemCursor(SWT.CURSOR_HAND)); |
161 | 161 |
|
162 |
final Label button = new Label(parent, SWT.NONE); |
|
163 |
button.setText("close"); |
|
162 |
final Label button = new Label(parent, SWT.NONE|SWT.BORDER); |
|
163 |
button.setText("x"); |
|
164 |
button.setCursor(parent.getDisplay().getSystemCursor(SWT.CURSOR_HAND)); |
|
164 | 165 |
|
165 | 166 |
MouseAdapter closeAdapter = new MouseAdapter() { |
166 | 167 |
|
... | ... | |
258 | 259 |
shell.setAlpha(0); |
259 | 260 |
} |
260 | 261 |
shell.setVisible(true); |
262 |
|
|
263 |
scheduleAutoClose(); |
|
261 | 264 |
// fadeJob = AnimationUtil.fadeIn(shell, new IFadeListener() { |
262 | 265 |
// public void faded(Shell shell, int alpha) { |
263 | 266 |
// if (shell.isDisposed()) { |
... | ... | |
265 | 268 |
// } |
266 | 269 |
// |
267 | 270 |
// if (alpha == 255) { |
268 |
// scheduleAutoClose();
|
|
271 |
// |
|
269 | 272 |
// } |
270 | 273 |
// } |
271 | 274 |
// }); |
Formats disponibles : Unified diff