68
68
* >Eclipse Wiki</a>.
69
69
*
70
70
*/
71
+ @ SuppressWarnings ("restriction" )
71
72
public class EclipseUtils {
72
73
73
74
// ------------------------------------------------------------------------
@@ -157,10 +158,13 @@ public static IProject getSelectedProject() {
157
158
IWorkbenchWindow window = PlatformUI .getWorkbench ()
158
159
.getActiveWorkbenchWindow ();
159
160
if (window != null ) {
160
- IStructuredSelection selection = (IStructuredSelection ) window
161
- .getSelectionService ().getSelection ();
162
- if ((selection != null ) && (selection .size () == 1 )) {
163
- Object firstElement = selection .getFirstElement ();
161
+
162
+ Object selection = window .getSelectionService ().getSelection ();
163
+ if ((selection != null )
164
+ && (selection instanceof IStructuredSelection )
165
+ && (((IStructuredSelection ) selection ).size () == 1 )) {
166
+ Object firstElement = ((IStructuredSelection ) selection )
167
+ .getFirstElement ();
164
168
if (firstElement instanceof IAdaptable ) {
165
169
IProject project = (IProject ) ((IAdaptable ) firstElement )
166
170
.getAdapter (IProject .class );
@@ -234,7 +238,6 @@ public static void ClearStatusMessage() {
234
238
235
239
Display .getDefault ().syncExec (new Runnable () {
236
240
237
- @ SuppressWarnings ("restriction" )
238
241
public void run () {
239
242
IWorkbenchWindow window = PlatformUI .getWorkbench ()
240
243
.getActiveWorkbenchWindow ();
@@ -259,7 +262,6 @@ public static void showStatusMessage(final String message) {
259
262
System .out .println (message );
260
263
Display .getDefault ().syncExec (new Runnable () {
261
264
262
- @ SuppressWarnings ("restriction" )
263
265
public void run () {
264
266
IWorkbenchWindow window = PlatformUI .getWorkbench ()
265
267
.getActiveWorkbenchWindow ();
@@ -276,7 +278,6 @@ public static void showStatusErrorMessage(final String message) {
276
278
System .out .println (message );
277
279
Display .getDefault ().syncExec (new Runnable () {
278
280
279
- @ SuppressWarnings ("restriction" )
280
281
public void run () {
281
282
IWorkbenchWindow window = PlatformUI .getWorkbench ()
282
283
.getActiveWorkbenchWindow ();
0 commit comments