/** * Returns true if given structured selection matches the conditions specified in the registry for * this action. */ private boolean isEnabledFor(ISelection sel) { Object obj = sel; int count = sel.isEmpty() ? 0 : 1; if (verifySelectionCount(count) == false) { return false; } // Compare selection to enablement expression. if (enablementExpression != null) { return enablementExpression.isEnabledFor(obj); } // Compare selection to class requirements. if (classes.isEmpty()) { return true; } if (obj instanceof IAdaptable) { IAdaptable element = (IAdaptable) obj; if (verifyElement(element) == false) { return false; } } else { return false; } return true; }
private void updateRemoveButtons(boolean updateRemove, boolean updateRemoveAll) { TablePart tablePart = getTablePart(); Table table = tablePart.getTableViewer().getTable(); TableItem[] tableSelection = table.getSelection(); if (updateRemove) { ISelection selection = getViewerSelection(); tablePart.setButtonEnabled( 3, isEditable() && !selection.isEmpty() && selection instanceof IStructuredSelection && ((IStructuredSelection) selection).getFirstElement() instanceof IProductPlugin); } int count = fPluginTable.getTable().getItemCount(); if (updateRemoveAll) tablePart.setButtonEnabled(4, isEditable() && count > 0); tablePart.setButtonEnabled(2, isEditable() && count > 0); tablePart.setButtonEnabled(5, isEditable() && tableSelection.length == 1); }
private void updateSelectionBasedEnablement(ISelection theSelection, boolean available) { if (available) fAddButton.setEnabled(!theSelection.isEmpty()); else fRemoveButton.setEnabled(!theSelection.isEmpty()); }