private void updateButtons() { Object[] selected = ((IStructuredSelection) fPackageViewer.getSelection()).toArray(); TablePart tablePart = getTablePart(); tablePart.setButtonEnabled(ADD_INDEX, canAddExportedPackages()); tablePart.setButtonEnabled(REMOVE_INDEX, isEditable() && selected.length > 0); tablePart.setButtonEnabled(PROPERTIES_INDEX, shouldEnableProperties(selected)); tablePart.setButtonEnabled( CALCULATE_USE_INDEX, isEditable() && fPackageViewer.getTable().getItemCount() > 0); }
@Override protected void fillContextMenu(IMenuManager manager) { ISelection selection = fPackageViewer.getSelection(); manager.add(fAddAction); boolean singleSelection = selection instanceof IStructuredSelection && ((IStructuredSelection) selection).size() == 1; if (singleSelection) manager.add(fGoToAction); manager.add(new Separator()); if (!selection.isEmpty()) manager.add(fRemoveAction); getPage().getPDEEditor().getContributor().contextMenuAboutToShow(manager); if (singleSelection) manager.add( new Action(PDEUIMessages.ExportPackageSection_findReferences) { @Override public void run() { doSearch(fPackageViewer.getSelection()); } }); if (shouldEnableProperties(((IStructuredSelection) fPackageViewer.getSelection()).toArray())) { manager.add(new Separator()); manager.add(fPropertiesAction); } }
private void handleOpenProperties() { Object[] selected = ((IStructuredSelection) fPackageViewer.getSelection()).toArray(); ExportPackageObject first = (ExportPackageObject) selected[0]; DependencyPropertiesDialog dialog = new DependencyPropertiesDialog(isEditable(), first); dialog.create(); PlatformUI.getWorkbench() .getHelpSystem() .setHelp(dialog.getShell(), IHelpContextIds.EXPORTED_PACKAGE_PROPERTIES); SWTUtil.setDialogSize(dialog, 400, -1); if (selected.length == 1) dialog.setTitle(((ExportPackageObject) selected[0]).getName()); else dialog.setTitle(PDEUIMessages.ExportPackageSection_props); if (dialog.open() == Window.OK && isEditable()) { String newVersion = dialog.getVersion(); for (Object selectedObject : selected) { ExportPackageObject object = (ExportPackageObject) selectedObject; if (!newVersion.equals(object.getVersion())) object.setVersion(newVersion); } } }
private void handleRemove() { Object[] removed = ((IStructuredSelection) fPackageViewer.getSelection()).toArray(); for (Object removedObject : removed) { fHeader.removePackage((PackageObject) removedObject); } }