Révision 2733
tmp/org.txm.rcp/src/main/java/org/txm/rcp/StatusLine.java (revision 2733) | ||
---|---|---|
36 | 36 |
|
37 | 37 |
/** |
38 | 38 |
* Shortcut to the RCP status bar |
39 |
* |
|
39 |
* FIXME: define messages, how and when show them then uncomment message methods |
|
40 |
* |
|
40 | 41 |
* @author mdecorde. |
41 | 42 |
*/ |
42 | 43 |
public class StatusLine { |
43 |
|
|
44 |
|
|
44 | 45 |
/** The timer */ |
45 | 46 |
private static Timer timer; |
47 |
|
|
46 | 48 |
private static int time = 15000; |
49 |
|
|
47 | 50 |
private static boolean timerScheduled = false; |
48 | 51 |
|
49 | 52 |
/** The status line. */ |
... | ... | |
57 | 60 |
public static void set(IStatusLineManager statusline) { |
58 | 61 |
StatusLine.statusLine = statusline; |
59 | 62 |
} |
60 |
|
|
63 |
|
|
61 | 64 |
static int MAX = 50; |
65 |
|
|
62 | 66 |
/** |
63 | 67 |
* Shows a message in the status line. |
64 | 68 |
* |
65 | 69 |
* @param message the new message |
66 | 70 |
*/ |
67 | 71 |
public static void setMessage(final String message) { |
68 |
Display.getDefault().syncExec(new Runnable() { |
|
69 |
@Override |
|
70 |
public void run() { |
|
71 |
if (statusLine != null) { |
|
72 |
if (message != null && message.length() > MAX) { |
|
73 |
statusLine.setMessage(null, message.substring(0, MAX)+"..."); |
|
74 |
} else { |
|
75 |
statusLine.setMessage(null, message); |
|
76 |
} |
|
77 |
} |
|
78 |
} |
|
79 |
}); |
|
72 |
return; |
|
73 |
// FIXME: define messages, how and when show them then uncomment message methods |
|
74 |
// Display.getDefault().syncExec(new Runnable() { |
|
75 |
// @Override |
|
76 |
// public void run() { |
|
77 |
// if (statusLine != null) { |
|
78 |
// if (message != null && message.length() > MAX) { |
|
79 |
// statusLine.setMessage(null, message.substring(0, MAX)+"..."); |
|
80 |
// } else { |
|
81 |
// statusLine.setMessage(null, message); |
|
82 |
// } |
|
83 |
// } |
|
84 |
// } |
|
85 |
// }); |
|
80 | 86 |
|
81 |
//cancelTimer(); |
|
82 |
//scheduleTimer(); |
|
87 |
// cancelTimer();
|
|
88 |
// scheduleTimer();
|
|
83 | 89 |
} |
84 | 90 |
|
85 | 91 |
/** |
... | ... | |
88 | 94 |
* @param message the new message |
89 | 95 |
*/ |
90 | 96 |
public static void setMessage(final String message, boolean keep) { |
91 |
if (!keep) { |
|
92 |
setMessage(message); |
|
93 |
return; |
|
94 |
} |
|
95 |
Display.getDefault().syncExec(new Runnable() { |
|
96 |
@Override |
|
97 |
public void run() { |
|
98 |
statusLine.setMessage(null, message); |
|
99 |
} |
|
100 |
}); |
|
101 |
cancelTimer(); |
|
97 |
return; |
|
98 |
// FIXME: define messages, how and when show them then uncomment message methods |
|
99 |
// if (!keep) { |
|
100 |
// setMessage(message); |
|
101 |
// return; |
|
102 |
// } |
|
103 |
// Display.getDefault().syncExec(new Runnable() { |
|
104 |
// @Override |
|
105 |
// public void run() { |
|
106 |
// statusLine.setMessage(null, message); |
|
107 |
// } |
|
108 |
// }); |
|
109 |
// cancelTimer(); |
|
102 | 110 |
} |
103 |
|
|
111 |
|
|
104 | 112 |
/** |
105 | 113 |
* Shows an error message in the status line. |
106 | 114 |
* |
107 | 115 |
* @param string the string |
108 | 116 |
*/ |
109 | 117 |
public static void error(final String message) { |
110 |
Display.getDefault().syncExec(new Runnable() { |
|
111 |
@Override |
|
112 |
public void run() { |
|
113 |
statusLine.setErrorMessage(null, message); |
|
114 |
} |
|
115 |
}); |
|
116 |
cancelTimer(); |
|
117 |
scheduleTimer(); |
|
118 |
return; |
|
119 |
// FIXME: define messages, how and when show them then uncomment message methods |
|
120 |
// Display.getDefault().syncExec(new Runnable() { |
|
121 |
// @Override |
|
122 |
// public void run() { |
|
123 |
// statusLine.setErrorMessage(null, message); |
|
124 |
// } |
|
125 |
// }); |
|
126 |
// cancelTimer(); |
|
127 |
// scheduleTimer(); |
|
118 | 128 |
} |
119 | 129 |
|
120 | 130 |
/** |
... | ... | |
123 | 133 |
* @param string the string |
124 | 134 |
*/ |
125 | 135 |
public static void error(final String message, boolean keep) { |
126 |
if (!keep) { |
|
127 |
setMessage(message); |
|
128 |
return; |
|
129 |
} |
|
130 |
Display.getDefault().syncExec(new Runnable() { |
|
131 |
@Override |
|
132 |
public void run() { |
|
133 |
statusLine.setErrorMessage(null, message); |
|
134 |
} |
|
135 |
}); |
|
136 |
cancelTimer(); |
|
136 |
return; |
|
137 |
// FIXME: define messages, how and when show them then uncomment message methods |
|
138 |
// if (!keep) { |
|
139 |
// setMessage(message); |
|
140 |
// return; |
|
141 |
// } |
|
142 |
// Display.getDefault().syncExec(new Runnable() { |
|
143 |
// @Override |
|
144 |
// public void run() { |
|
145 |
// statusLine.setErrorMessage(null, message); |
|
146 |
// } |
|
147 |
// }); |
|
148 |
// cancelTimer(); |
|
137 | 149 |
} |
138 | 150 |
|
139 | 151 |
/** |
140 | 152 |
* Stops the timer |
141 | 153 |
*/ |
142 | 154 |
private static void cancelTimer() { |
143 |
// if (!timerScheduled)
|
|
144 |
// return;
|
|
145 |
// timerScheduled = false;
|
|
146 |
// timer.cancel();
|
|
155 |
// if (!timerScheduled)
|
|
156 |
// return;
|
|
157 |
// timerScheduled = false;
|
|
158 |
// timer.cancel();
|
|
147 | 159 |
} |
148 | 160 |
|
149 | 161 |
/** |
150 | 162 |
* Starts the timer |
151 | 163 |
*/ |
152 | 164 |
private static void scheduleTimer() { |
153 |
// if (timerScheduled)
|
|
154 |
// return;
|
|
155 |
// timerScheduled = true;
|
|
156 |
// timer = new Timer();
|
|
157 |
// TimerTask timerTask = new TimerTask() {
|
|
158 |
// @Override
|
|
159 |
// public void run() {
|
|
160 |
// Runnable r = new Runnable() {
|
|
161 |
// @Override
|
|
162 |
// public void run() {
|
|
163 |
// StatusLine.setMessage(""); //$NON-NLS-1$
|
|
164 |
// }
|
|
165 |
// };
|
|
166 |
// Display.getDefault().syncExec(r);
|
|
167 |
// }
|
|
168 |
// };
|
|
169 |
// timer.schedule(timerTask, time);
|
|
165 |
// if (timerScheduled)
|
|
166 |
// return;
|
|
167 |
// timerScheduled = true;
|
|
168 |
// timer = new Timer();
|
|
169 |
// TimerTask timerTask = new TimerTask() {
|
|
170 |
// @Override
|
|
171 |
// public void run() {
|
|
172 |
// Runnable r = new Runnable() {
|
|
173 |
// @Override
|
|
174 |
// public void run() {
|
|
175 |
// StatusLine.setMessage(""); //$NON-NLS-1$
|
|
176 |
// }
|
|
177 |
// };
|
|
178 |
// Display.getDefault().syncExec(r);
|
|
179 |
// }
|
|
180 |
// };
|
|
181 |
// timer.schedule(timerTask, time);
|
|
170 | 182 |
} |
171 | 183 |
} |
Formats disponibles : Unified diff