Lines 40-45
Link Here
|
40 |
import org.eclipse.swt.widgets.Event; |
40 |
import org.eclipse.swt.widgets.Event; |
41 |
import org.eclipse.ui.IPartListener; |
41 |
import org.eclipse.ui.IPartListener; |
42 |
import org.eclipse.ui.IPropertyListener; |
42 |
import org.eclipse.ui.IPropertyListener; |
|
|
43 |
import org.eclipse.ui.ISelectionService; |
43 |
import org.eclipse.ui.IWorkbenchPage; |
44 |
import org.eclipse.ui.IWorkbenchPage; |
44 |
import org.eclipse.ui.IWorkbenchPart; |
45 |
import org.eclipse.ui.IWorkbenchPart; |
45 |
import org.eclipse.ui.PlatformUI; |
46 |
import org.eclipse.ui.PlatformUI; |
Lines 409-425
Link Here
|
409 |
* @return The current selection. |
410 |
* @return The current selection. |
410 |
*/ |
411 |
*/ |
411 |
protected ISelection getSelection() { |
412 |
protected ISelection getSelection() { |
412 |
ISelection selection = null; |
413 |
ISelection selection = null; |
413 |
ISelectionProvider selectionProvider = getWorkbenchPart().getSite() |
414 |
ISelectionService selectionService = null; |
414 |
.getSelectionProvider(); |
415 |
if (getWorkbenchPart() != null && getWorkbenchPart().getSite().getWorkbenchWindow() != null) { |
|
|
416 |
selectionService = getWorkbenchPart().getSite() |
417 |
.getWorkbenchWindow().getSelectionService(); |
418 |
} |
415 |
|
419 |
|
416 |
if (selectionProvider != null) { |
420 |
if (selectionService != null) { |
417 |
selection = selectionProvider.getSelection(); |
421 |
selection = selectionService.getSelection(); |
418 |
} |
422 |
} |
419 |
|
423 |
|
420 |
return (selection != null) ? selection |
424 |
return (selection != null) ? selection |
421 |
: StructuredSelection.EMPTY; |
425 |
: StructuredSelection.EMPTY; |
422 |
} |
426 |
} |
423 |
|
427 |
|
424 |
/** |
428 |
/** |
425 |
* Retrieves the current structured selection. |
429 |
* Retrieves the current structured selection. |
Lines 427-446
Link Here
|
427 |
* @return The current structured selection. |
431 |
* @return The current structured selection. |
428 |
*/ |
432 |
*/ |
429 |
protected IStructuredSelection getStructuredSelection() { |
433 |
protected IStructuredSelection getStructuredSelection() { |
430 |
IStructuredSelection selection = null; |
434 |
ISelection selection = getSelection(); |
431 |
ISelectionProvider selectionProvider = null; |
435 |
return (selection instanceof StructuredSelection) ? (StructuredSelection) selection |
432 |
if (getWorkbenchPart() != null) { |
436 |
: StructuredSelection.EMPTY; |
433 |
selectionProvider = getWorkbenchPart().getSite() |
437 |
} |
434 |
.getSelectionProvider(); |
|
|
435 |
} |
436 |
|
437 |
if (selectionProvider != null |
438 |
&& selectionProvider.getSelection() instanceof IStructuredSelection) { |
439 |
selection = (IStructuredSelection) selectionProvider.getSelection(); |
440 |
} |
441 |
return (selection != null) ? selection |
442 |
: StructuredSelection.EMPTY; |
443 |
} |
444 |
|
438 |
|
445 |
/** |
439 |
/** |
446 |
* Retrieves a Boolean indicating whether this action handler can be run. |
440 |
* Retrieves a Boolean indicating whether this action handler can be run. |