public void addSelectedFilesToTargetList() { ISelection selection = sourceFileViewer.getSelection(); if (isValidSourceFileViewerSelection(selection)) { java.util.List list = null; if (selection instanceof IStructuredSelection) { list = ((IStructuredSelection) selection).toList(); if (list != null) { list = ((IStructuredSelection) selection).toList(); for (Iterator i = list.iterator(); i.hasNext(); ) { IResource resource = (IResource) i.next(); if (resource instanceof IFile) { // Check if its in the list. Don't add it if it is. String resourceName = resource.getFullPath().toString(); if (selectedListBox.indexOf(resourceName) == -1) selectedListBox.add(resourceName); } } setFiles(selectedListBox.getItems()); } setAddButtonEnabled(false); if (selectedListBox.getItemCount() > 0) { removeAllButton.setEnabled(true); if (isFileMandatory) setPageComplete(true); if (selectedListBox.getSelectionCount() > 0) setRemoveButtonEnabled(true); else setRemoveButtonEnabled(false); } } } }
/** * @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 handleImportEnvironment() { IStructuredSelection sel = (IStructuredSelection) fCategoryViewer.getSelection(); final ISiteFeature[] selectedFeatures = getFeaturesFromSelection(sel); BusyIndicator.showWhile( fCategoryTreePart.getControl().getDisplay(), new Runnable() { public void run() { new SynchronizePropertiesAction(selectedFeatures, getModel()).run(); } }); }
private void updateButtons() { if (!isEditable()) { return; } IStructuredSelection sel = (IStructuredSelection) fCategoryViewer.getSelection(); fCategoryTreePart.setButtonEnabled( BUTTON_BUILD_FEATURE, getFeaturesFromSelection(sel).length > 0); int featureCount = fModel.getSite().getFeatures().length; fCategoryTreePart.setButtonEnabled(BUTTON_BUILD_ALL, featureCount > 0); fCategoryTreePart.setButtonEnabled(BUTTON_IMPORT_ENVIRONMENT, featureCount > 0); }
@Override public void run() { StructuredSelection selection = (StructuredSelection) fExtensionTree.getSelection(); if (fExtensionTree.getTree().getSelectionCount() > 0) { TreeItem[] items = fExtensionTree.getTree().getSelection(); try { fFilteredTree.setRedraw(false); int state = getStateChangeRequired(items); toggleExpandState(state, selection); } finally { fFilteredTree.setRedraw(true); fExtensionTree.refresh(); } } }
private boolean handleRemove() { IStructuredSelection ssel = (IStructuredSelection) fCategoryViewer.getSelection(); Iterator<?> iterator = ssel.iterator(); boolean success = true; Set<?> removedCategories = new HashSet<Object>(); while (iterator.hasNext()) { Object object = iterator.next(); if (object == null) continue; if (object instanceof ISiteCategoryDefinition) { if (!handleRemoveCategoryDefinition((ISiteCategoryDefinition) object)) { success = false; } } else { // check if some of features was not removed during category removal SiteFeatureAdapter fa = (SiteFeatureAdapter) object; if (removedCategories.contains(fa.category)) continue; if (!handleRemoveSiteFeatureAdapter(fa)) { success = false; } } } return success; }
void fireSelection() { fCategoryViewer.setSelection(fCategoryViewer.getSelection()); }
private void handleBuild() { IStructuredSelection sel = (IStructuredSelection) fCategoryViewer.getSelection(); ((SiteEditor) getPage().getPDEEditor()).handleBuild(getFeaturesFromSelection(sel)); }
protected Object[] getSelectedElements() { return ((IStructuredSelection) treeViewer.getSelection()).toArray(); }