1
1
package cn .ieclipse .smartim .common ;
2
2
3
- import java .awt .Insets ;
4
- import java .awt .Toolkit ;
5
3
import java .lang .reflect .Method ;
6
4
import java .util .Timer ;
7
5
import java .util .TimerTask ;
8
6
9
- import javax .swing .JFrame ;
10
-
11
7
import org .eclipse .core .runtime .Platform ;
12
8
import org .eclipse .swt .SWT ;
13
9
import org .eclipse .swt .events .MouseAdapter ;
@@ -40,9 +36,9 @@ public class Notifications extends Shell {
40
36
public static void main (String args []) {
41
37
try {
42
38
final Display display = Display .getDefault ();
43
- // Notifications.getInstance(new Shell(display)).setMock(true)
44
- // .setMessage(null, "test");
45
- // Notifications.notify("title", "message");
39
+ // Notifications.getInstance(new Shell(display)).setMock(true)
40
+ // .setMessage(null, "test");
41
+ // Notifications.notify("title", "message");
46
42
Notifications instance = new Notifications (display );
47
43
instance .open ();
48
44
instance .layout ();
@@ -69,7 +65,7 @@ public static void main(String args[]) {
69
65
* @wbp.parser.constructor
70
66
*/
71
67
public Notifications (Display display ) {
72
- this (display , SWT .ON_TOP | SWT .CLOSE | SWT .TITLE );
68
+ this (display , SWT .ON_TOP | SWT .CLOSE | SWT .TITLE );
73
69
}
74
70
75
71
/**
@@ -107,18 +103,19 @@ protected void createContents() {
107
103
setSize (300 , 150 );
108
104
109
105
setLayout (new GridLayout (2 , false ));
110
- if (Platform .OS_LINUX .equals (Platform .getOS ()))
111
- {
106
+ if (Platform .OS_LINUX .equals (Platform .getOS ())) {
112
107
fIcon = new Label (this , SWT .NONE );
113
- fIcon .setLayoutData (new GridData (SWT .FILL , SWT .CENTER , false , false , 1 , 1 ));
114
- fIcon .setImage (SWTResourceManager .getImage (org .eclipse .ui .IWorkbench .class ,
115
- "/icons/full/etool16/delete_edit.png" ));
108
+ fIcon .setLayoutData (
109
+ new GridData (SWT .FILL , SWT .CENTER , false , false , 1 , 1 ));
110
+ fIcon .setImage (
111
+ SWTResourceManager .getImage (org .eclipse .ui .IWorkbench .class ,
112
+ "/icons/full/etool16/delete_edit.png" ));
116
113
fIcon .addMouseListener (new MouseAdapter () {
117
- @ Override
118
- public void mouseDown (MouseEvent e ) {
119
- setVisible (false );
120
- }
121
- });
114
+ @ Override
115
+ public void mouseDown (MouseEvent e ) {
116
+ setVisible (false );
117
+ }
118
+ });
122
119
123
120
fTitle = new Label (this , SWT .NONE );
124
121
fTitle .setText ("通知" );
@@ -157,10 +154,13 @@ public void widgetSelected(SelectionEvent e) {
157
154
}
158
155
});
159
156
160
- Insets sd = Toolkit .getDefaultToolkit ().getScreenInsets (
161
- new JFrame ().getGraphicsConfiguration ());
157
+
162
158
Rectangle screen = Display .getDefault ().getClientArea ();
163
- screen .height = screen .height - sd .bottom ;
159
+ if (Platform .OS_LINUX .equals (Platform .getOS ())) {
160
+ java .awt .Insets sd = java .awt .Toolkit .getDefaultToolkit ()
161
+ .getScreenInsets (new java .awt .Frame ().getGraphicsConfiguration ());
162
+ screen .height = screen .height - sd .bottom ;
163
+ }
164
164
ta = new TranslateAnimation (screen .width , screen .width - getSize ().x ,
165
165
screen .height , screen .height - getSize ().y ).setTarget (this )
166
166
.setDuration (300 );
@@ -219,7 +219,7 @@ private void doSetMessage(String title, CharSequence text) {
219
219
if (title != null ) {
220
220
this .setText (title );
221
221
if (fTitle != null ) {
222
- fTitle .setText (title );
222
+ fTitle .setText (title );
223
223
}
224
224
}
225
225
this .fText .setText (text == null ? "" : text .toString ());
0 commit comments