@Override public void selectionChanged(IStructuredSelection selection) { if (!selection.isEmpty()) { // cannot cut top-level types. this deletes the cu and then you cannot paste because the cu is gone. if (!containsOnlyElementsInsideCompilationUnits(selection) || containsTopLevelTypes(selection)) { setEnabled(false); return; } fCopyToClipboardAction.selectionChanged(selection); setEnabled(fCopyToClipboardAction.isEnabled() && RefactoringAvailabilityTester.isDeleteAvailable(selection)); } else setEnabled(false); }
@Override public void selectionChanged(IStructuredSelection selection) { if (!selection.isEmpty()) { // cannot cut top-level types. this deletes the cu and then you cannot paste because the cu is gone. if (!containsOnlyElementsInsideCompilationUnits(selection) || containsTopLevelTypes(selection)) { setEnabled(false); return; } fCopyToClipboardAction.selectionChanged(selection); setEnabled(fCopyToClipboardAction.isEnabled() && RefactoringAvailabilityTester.isDeleteAvailable(selection)); } else setEnabled(false); }
public void selectionChanged(IStructuredSelection selection) { if (!selection.isEmpty()) { try { // cannot cut top-level types. this deletes the cu and then you cannot paste because the cu is gone. if (!containsOnlyElementsInsideCompilationUnits(selection) || containsTopLevelTypes(selection)) { setEnabled(false); return; } fCopyToClipboardAction.selectionChanged(selection); setEnabled(fCopyToClipboardAction.isEnabled() && RefactoringAvailabilityTester.isDeleteAvailable(selection)); } catch (CoreException e) { // no ui here - this happens on selection changes // http://bugs.eclipse.org/bugs/show_bug.cgi?id=19253 if (JavaModelUtil.isExceptionToBeLogged(e)) JavaPlugin.log(e); setEnabled(false); } } else setEnabled(false); }