@Override public boolean supportsSourceContainerType(ISourceContainerType type) { return !fFilteredTypes.contains(type.getId()); } }
@Override public synchronized String getMemento() throws CoreException { Document doc = DebugPlugin.newDocument(); Element rootNode = doc.createElement(DIRECTOR_ROOT_NODE); doc.appendChild(rootNode); Element pathNode = doc.createElement(CONTAINERS_NODE); if(fDuplicates) { pathNode.setAttribute(DUPLICATES_ATTR, "true"); //$NON-NLS-1$ } else { pathNode.setAttribute(DUPLICATES_ATTR, "false"); //$NON-NLS-1$ } rootNode.appendChild(pathNode); if(fSourceContainers !=null){ for(int i=0; i<fSourceContainers.length; i++){ Element node = doc.createElement(CONTAINER_NODE); ISourceContainer container = fSourceContainers[i]; ISourceContainerType type = container.getType(); node.setAttribute(CONTAINER_TYPE_ATTR, type.getId()); node.setAttribute(CONTAINER_MEMENTO_ATTR, type.getMemento(container)); pathNode.appendChild(node); } } return DebugPlugin.serializeDocument(doc); }
@Override public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = event.getStructuredSelection(); if (!selection.isEmpty()) { ISourceContainerType type = (ISourceContainerType) selection.getFirstElement(); setMessage(type.getDescription()); getButton(IDialogConstants.OK_ID).setEnabled(true); } else { getButton(IDialogConstants.OK_ID).setEnabled(false); setMessage(SourceLookupUIMessages.AddSourceContainerDialog_select_source_container); } } });
@Override public String getText(Object element) { // first, allo workbench adapter to provide label String label = getWorkbenchLabelProvider().getText(element); if (label == null || label.length() == 0) { if (element instanceof ISourceContainer) { return ((ISourceContainer) element).getName(); } else if (element instanceof ISourceContainerType) { return ((ISourceContainerType)element).getName(); } } else { return label; } return super.getText(element); }
abort(SourceLookupMessages.AbstractSourceLookupDirector_13, null); ISourceContainer container = type.createSourceContainer(memento); containers.add(container);
@Override public boolean supportsSourceContainerType(ISourceContainerType type) { return !fFilteredTypes.contains(type.getId()); } }
public boolean supportsSourceContainerType(ISourceContainerType type) { return !fFilteredTypes.contains(type.getId()); }
@Override public boolean canEditSourceContainers(ISourceLookupDirector director, ISourceContainer[] containers) { return containers.length == 1 && containers[0].getType().getId().equals(FolderSourceContainer.TYPE_ID); }
@Override public boolean canEditSourceContainers(ISourceLookupDirector director, ISourceContainer[] containers) { return containers.length == 1 && DirectorySourceContainer.TYPE_ID.equals(containers[0].getType().getId()); }
/** * Returns internal jars (source containers) currently used by the * given source lookup director. * * @param director source lookup director jars are being added to * @return the list of any found {@link ArchiveSourceContainer}s */ protected List<ISourceContainer> getSelectedJars(ISourceLookupDirector director) { ISourceContainer[] containers = director.getSourceContainers(); List<ISourceContainer> jars = new ArrayList<>(); for (int i = 0; i < containers.length; i++) { ISourceContainer container = containers[i]; if (container.getType().getId().equals(ArchiveSourceContainer.TYPE_ID)) { jars.add(container); } } return jars; }
/** * Removes types without browsers from the provided list of types. * @param types the complete list of source container types * @return the list of source container types that have browsers */ private ISourceContainerType[] filterTypes(ISourceContainerType[] types){ ArrayList<ISourceContainerType> validTypes = new ArrayList<>(); for (int i=0; i< types.length; i++) { ISourceContainerType type = types[i]; if (fDirector.supportsSourceContainerType(type)) { ISourceContainerBrowser sourceContainerBrowser = DebugUITools.getSourceContainerBrowser(type.getId()); if(sourceContainerBrowser != null && sourceContainerBrowser.canAddSourceContainers(fDirector)) { validTypes.add(type); } } } return validTypes.toArray(new ISourceContainerType[validTypes.size()]); } }
/** * if containers contains target source container * * @param containers * exsited source containers * @param target * @return */ private boolean contains(ISourceContainer[] containers, ISourceContainer target) { String name = target.getName(); String type = target.getType().getId(); for (ISourceContainer container : containers) { if (name.equals(container.getName()) && type.equals(container.getType().getId())) { return true; } } return false; } private Set<String> searchUserClass(IRuntimeClasspathEntry[] entries) {
/** * Returns the possible projects that can be added * * @param director the source lookup director currently being edited */ protected List getPossibleAdditions(ISourceLookupDirector director) { IJavaProject[] projects; IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); try { projects= JavaCore.create(root).getJavaProjects(); } catch (JavaModelException e) { JDIDebugUIPlugin.log(e); projects= new IJavaProject[0]; } List remaining = new ArrayList(); for (int i = 0; i < projects.length; i++) { remaining.add(projects[i]); } List alreadySelected = new ArrayList(); ISourceContainer[] containers = director.getSourceContainers(); for (int i = 0; i < containers.length; i++) { ISourceContainer container = containers[i]; if (container.getType().getId().equals(JavaProjectSourceContainer.TYPE_ID)) { alreadySelected.add(((JavaProjectSourceContainer)container).getJavaProject()); } } remaining.removeAll(alreadySelected); return remaining; }
@Override public ISourceContainer[] editSourceContainers(Shell shell, ISourceLookupDirector director, ISourceContainer[] containers) { if (containers.length == 1 && DirectorySourceContainer.TYPE_ID.equals(containers[0].getType().getId()) ) { DirectorySourceContainer c = (DirectorySourceContainer)containers[0]; DirectorySourceContainerDialog dialog = new DirectorySourceContainerDialog(shell, c.getDirectory().getPath(), c.isComposite()); if (dialog.open() == Window.OK) { String directory = dialog.getDirectory(); if(directory !=null) { containers[0].dispose(); return new ISourceContainer[]{ new DirectorySourceContainer(new Path(directory), dialog.isSearchSubfolders())}; } } } return containers; }
@Override protected boolean updateSelection(IStructuredSelection selection) { if(selection == null || selection.isEmpty()) { return false; } if (getViewer().getTree().getSelection()[0].getParentItem()==null) { // can only edit top level items of same type fContainers = new ISourceContainer[selection.size()]; Iterator<ISourceContainer> iterator = selection.iterator(); ISourceContainer container = iterator.next(); ISourceContainerType type = container.getType(); fContainers[0] = container; int i = 1; while (iterator.hasNext()) { container = iterator.next(); fContainers[i] = container; i++; if (!container.getType().equals(type)) { return false; } } // all the same type, see if editing is supported fBrowser = DebugUITools.getSourceContainerBrowser(type.getId()); if (fBrowser != null) { return fBrowser.canEditSourceContainers(fDirector, fContainers); } } return false; } }
@Override public Image getImage(Object element) { // first allow workbench adapter to provide image Image image = getWorkbenchLabelProvider().getImage(element); if (image == null) { ISourceContainerType type = null; if (element instanceof ISourceContainer) { type = ((ISourceContainer)element).getType(); } else if (element instanceof ISourceContainerType) { type = (ISourceContainerType) element; } if (type != null) { // next consult contributed image image = DebugUITools.getSourceContainerImage(type.getId()); } } if (image != null) { return image; } return super.getImage(element); }
for (int i = 0; i < containers.length; i++) { ISourceContainer container = containers[i]; if (container.getType().getId().equals(ArchiveSourceContainer.TYPE_ID)) { IFile file = ((ArchiveSourceContainer)container).getFile(); IProject project = file.getProject();
for (int i = 0; i < containers.length; i++) { ISourceContainer container = containers[i]; if (container.getType().getId().equals(ArchiveSourceContainer.TYPE_ID)) { IFile file = ((ArchiveSourceContainer)container).getFile(); IProject project = file.getProject();
@Override protected void okPressed() { ISourceContainerType type = (ISourceContainerType) fViewer.getStructuredSelection().getFirstElement(); if (type != null) { ISourceContainerBrowser browser = DebugUITools.getSourceContainerBrowser(type.getId()); if (browser != null) { ISourceContainer[] results = browser.addSourceContainers(getShell(), fDirector); if (results != null && results.length > 0) { fSourceContainerViewer.addEntries(results); super.okPressed(); } else { return; } } } super.okPressed(); }