/** * @param candidates Array of IFeatureModel * @param monitor * @throws CoreException */ public void doAdd(Object[] candidates) throws CoreException { // Category to add features to String categoryName = null; ISelection selection = fCategoryViewer.getSelection(); if (!selection.isEmpty() && selection instanceof IStructuredSelection) { Object element = ((IStructuredSelection) selection).getFirstElement(); if (element instanceof ISiteCategoryDefinition) { categoryName = ((ISiteCategoryDefinition) element).getName(); } else if (element instanceof SiteFeatureAdapter) { categoryName = ((SiteFeatureAdapter) element).category; } } // ISiteFeature[] added = new ISiteFeature[candidates.length]; for (int i = 0; i < candidates.length; i++) { IFeatureModel candidate = (IFeatureModel) candidates[i]; ISiteFeature child = createSiteFeature(fModel, candidate); if (categoryName != null) { addCategory(child, categoryName); } added[i] = child; } // Update model fModel.getSite().addFeatures(added); // Select last added feature if (added.length > 0) { if (categoryName != null) { expandCategory(categoryName); } fCategoryViewer.setSelection( new StructuredSelection(new SiteFeatureAdapter(categoryName, added[added.length - 1])), true); } }
protected void fillContextMenu(IMenuManager manager) { Action removeAction = new Action(PDEUIMessages.CategorySection_remove) { public void run() { doGlobalAction(ActionFactory.DELETE.getId()); } }; removeAction.setEnabled(isEditable()); manager.add(removeAction); getPage().getPDEEditor().getContributor().contextMenuAboutToShow(manager); ISelection selection = fCategoryViewer.getSelection(); if (!selection.isEmpty() && selection instanceof IStructuredSelection) { final ISiteFeature[] features = getFeaturesFromSelection((IStructuredSelection) selection); if (features.length > 0) { manager.add(new Separator()); Action synchronizeAction = new SynchronizePropertiesAction(features, fModel); manager.add(synchronizeAction); Action buildAction = new Action(PDEUIMessages.CategorySection_build) { public void run() { ((SiteEditor) getPage().getPDEEditor()).handleBuild(features); } }; buildAction.setEnabled(isEditable()); manager.add(buildAction); } } }
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); }
@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); } }