diff options
Diffstat (limited to 'org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup')
40 files changed, 0 insertions, 4304 deletions
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/AddContainerAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/AddContainerAction.java deleted file mode 100644 index e3f1ff34a..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/AddContainerAction.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup; - -import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; -import org.eclipse.jface.viewers.IStructuredSelection; - -/** - * The action to add a new source container. - * Used by the CommonSourceNotFoundEditor, the launch configuration source tab, - * and the EditSourceLookupPathDialog. - */ -public class AddContainerAction extends SourceContainerAction { - - private ISourceLookupDirector fDirector; - - public AddContainerAction() { - super(SourceLookupUIMessages.sourceTab_addButton); - } - - /** - * Prompts for a project to add. - * - * @see org.eclipse.jface.action.IAction#run() - */ - public void run() { - AddSourceContainerDialog dialog = new AddSourceContainerDialog(getShell(), getViewer(), fDirector); - dialog.open(); - } - - public void setSourceLookupDirector(ISourceLookupDirector director) { - fDirector = director; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.actions.BaseSelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection) - */ - protected boolean updateSelection(IStructuredSelection selection) { - if(selection == null || selection.isEmpty()) { - return true; - } - return getViewer().getTree().getSelection()[0].getParentItem()==null; - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/AddSourceContainerDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/AddSourceContainerDialog.java deleted file mode 100644 index 5bb6193b5..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/AddSourceContainerDialog.java +++ /dev/null @@ -1,160 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup; - -import java.util.ArrayList; - -import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.debug.core.sourcelookup.ISourceContainer; -import org.eclipse.debug.core.sourcelookup.ISourceContainerType; -import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; -import org.eclipse.debug.internal.ui.DebugPluginImages; -import org.eclipse.debug.internal.ui.IDebugHelpContextIds; -import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; -import org.eclipse.debug.ui.DebugUITools; -import org.eclipse.debug.ui.sourcelookup.ISourceContainerBrowser; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.dialogs.TitleAreaDialog; -import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.ViewerComparator; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.ui.PlatformUI; - -/** - * The dialog for adding new source containers. Presents the user with a list of - * source container types and allows them to select one. - * - * @since 3.0 - */ -public class AddSourceContainerDialog extends TitleAreaDialog { - - private TableViewer fViewer; - private SourceContainerViewer fSourceContainerViewer; - private boolean fDoubleClickSelects = true; - private ISourceLookupDirector fDirector; - - /** - * Constructor - */ - public AddSourceContainerDialog(Shell shell, SourceContainerViewer viewer, ISourceLookupDirector director) { - super(shell); - setShellStyle(getShellStyle() | SWT.RESIZE); - fSourceContainerViewer=viewer; - fDirector = director; - } - - /** - * Creates the dialog area to display source container types that are "browseable" - */ - protected Control createDialogArea(Composite ancestor) { - - getShell().setText(SourceLookupUIMessages.addSourceLocation_title); - setTitle(SourceLookupUIMessages.addSourceLocation_description); - setTitleImage(DebugPluginImages.getImage(IInternalDebugUIConstants.IMG_ADD_SRC_LOC_WIZ)); - - Composite parent = new Composite(ancestor, SWT.NULL); - GridData gd= new GridData(GridData.FILL_BOTH); - GridLayout topLayout = new GridLayout(); - topLayout.numColumns = 1; - parent.setLayout(topLayout); - parent.setLayoutData(gd); - - ISourceContainerType[] types = filterTypes(DebugPlugin.getDefault().getLaunchManager().getSourceContainerTypes()); - - fViewer = new TableViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.SINGLE); - final Table table = fViewer.getTable(); - gd = new GridData(GridData.FILL_BOTH); - table.setLayoutData(gd); - - if (fDoubleClickSelects) { - table.addSelectionListener(new SelectionAdapter() { - public void widgetDefaultSelected(SelectionEvent e) { - if (table.getSelectionCount() == 1) - okPressed(); - } - }); - } - - fViewer.setLabelProvider(new SourceContainerLabelProvider()); - fViewer.setContentProvider(new ArrayContentProvider()); - fViewer.setComparator(new ViewerComparator()); - fViewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - ISelection selection = event.getSelection(); - String desc = null; - if (!selection.isEmpty()) { - ISourceContainerType type = (ISourceContainerType) ((IStructuredSelection)selection).getFirstElement(); - desc = type.getDescription(); - } - setMessage(desc); - } - }); - if(types.length != 0) { - fViewer.setInput(types); - } - Dialog.applyDialogFont(parent); - PlatformUI.getWorkbench().getHelpSystem().setHelp(getShell(), IDebugHelpContextIds.ADD_SOURCE_CONTAINER_DIALOG); - return parent; - } - - /** - * 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 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 (ISourceContainerType[]) validTypes.toArray(new ISourceContainerType[validTypes.size()]); - - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#okPressed() - */ - protected void okPressed() { - //single selection dialog, so take first item in array - //there will always be a selected item since we set it with viewer.setSelection - ISourceContainerType type = (ISourceContainerType) ((IStructuredSelection) fViewer.getSelection()).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(); - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/BasicContainerContentProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/BasicContainerContentProvider.java deleted file mode 100644 index b629d96cd..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/BasicContainerContentProvider.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup; - -import java.util.ArrayList; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.Viewer; -/** - * Provides content for a tree viewer that shows only containers. - * - * @since 3.0 - */ -public class BasicContainerContentProvider implements ITreeContentProvider { - - private boolean fShowClosedProjects = true; - /** - * Creates a new ResourceContentProvider. - */ - public BasicContainerContentProvider() { - } - /** - * The visual part that is using this content provider is about - * to be disposed. Deallocate all allocated SWT resources. - */ - public void dispose() { - } - - /** - * @see ITreeContentProvider#getChildren - */ - public Object[] getChildren(Object element) { - if (element instanceof IWorkspaceRoot) { - // check if closed projects should be shown - IProject[] allProjects = ((IWorkspaceRoot) element).getProjects(); - if (fShowClosedProjects) - return allProjects; - - ArrayList accessibleProjects = new ArrayList(); - for (int i = 0; i < allProjects.length; i++) { - if (allProjects[i].isOpen()) { - accessibleProjects.add(allProjects[i]); - } - } - return accessibleProjects.toArray(); - } - return new Object[0]; - } - - /** - * @see ITreeContentProvider#getElements - */ - public Object[] getElements(Object element) { - return getChildren(element); - } - - /** - * @see ITreeContentProvider#getParent - */ - public Object getParent(Object element) { - if (element instanceof IResource) - return ((IResource) element).getParent(); - return null; - } - - /** - * @see ITreeContentProvider#hasChildren - */ - public boolean hasChildren(Object element) { - return getChildren(element).length > 0; - } - - /** - * @see IContentProvider#inputChanged - */ - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/DownAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/DownAction.java deleted file mode 100644 index 673b78bd9..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/DownAction.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup; - -import java.util.List; - -import org.eclipse.jface.viewers.IStructuredSelection; - -/** - * The action for sorting the order of source containers in the dialog. - * - */ -public class DownAction extends SourceContainerAction { - - public DownAction() { - super(SourceLookupUIMessages.sourceTab_downButton); - } - /** - * @see IAction#run() - */ - public void run() { - List targets = getOrderedSelection(); - if (targets.isEmpty()) { - return; - } - List list = getEntriesAsList(); - int bottom = list.size() - 1; - int index = 0; - for (int i = targets.size() - 1; i >= 0; i--) { - Object target = targets.get(i); - index = list.indexOf(target); - if (index < bottom) { - bottom = index + 1; - Object temp = list.get(bottom); - list.set(bottom, target); - list.set(index, temp); - } - bottom = index; - } - setEntries(list); - } - - /** - * @see SelectionListenerAction#updateSelection(IStructuredSelection) - */ - protected boolean updateSelection(IStructuredSelection selection) { - return !selection.isEmpty() && !isIndexSelected(selection, getEntriesAsList().size() - 1) && getViewer().getTree().getSelection()[0].getParentItem()==null; - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/EditContainerAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/EditContainerAction.java deleted file mode 100644 index 9eadd343b..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/EditContainerAction.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup; - -import java.util.Iterator; - -import org.eclipse.debug.core.sourcelookup.ISourceContainer; -import org.eclipse.debug.core.sourcelookup.ISourceContainerType; -import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; -import org.eclipse.debug.ui.DebugUITools; -import org.eclipse.debug.ui.sourcelookup.ISourceContainerBrowser; -import org.eclipse.jface.viewers.IStructuredSelection; - -/** - * Action used to edit source containers on a source lookup path - */ -public class EditContainerAction extends SourceContainerAction { - - private ISourceLookupDirector fDirector; - private ISourceContainer[] fContainers; - private ISourceContainerBrowser fBrowser; - - public EditContainerAction() { - super(SourceLookupUIMessages.EditContainerAction_0); - } - - /** - * Prompts for a project to add. - * - * @see org.eclipse.jface.action.IAction#run() - */ - public void run() { - ISourceContainer[] replacements = fBrowser.editSourceContainers(getShell(), fDirector, fContainers); - int j = 0; - ISourceContainer[] existing = getViewer().getEntries(); - for (int i = 0; i < existing.length && j < replacements.length; i++) { - ISourceContainer toBeReplaced = fContainers[j]; - ISourceContainer container = existing[i]; - if (container.equals(toBeReplaced)) { - existing[i] = replacements[j]; - j++; - } - } - getViewer().setEntries(existing); - } - - public void setSourceLookupDirector(ISourceLookupDirector director) { - fDirector = director; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.actions.BaseSelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection) - */ - 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 iterator = selection.iterator(); - ISourceContainer container = (ISourceContainer) iterator.next(); - ISourceContainerType type = container.getType(); - fContainers[0] = container; - int i = 1; - while (iterator.hasNext()) { - container = (ISourceContainer) 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; - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/EditSourceLookupPathAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/EditSourceLookupPathAction.java deleted file mode 100644 index 641b01435..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/EditSourceLookupPathAction.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup; - -import org.eclipse.debug.core.ILaunch; -import org.eclipse.debug.core.model.IDebugElement; -import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; -import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.debug.internal.ui.IDebugHelpContextIds; -import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; -import org.eclipse.debug.internal.ui.views.launch.LaunchView; -import org.eclipse.debug.ui.DebugUITools; -import org.eclipse.debug.ui.sourcelookup.SourceLookupDialog; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.SelectionListenerAction; - -/** - * The action for editing the source lookup path. Brings up the - * EditSourceLookupPathDialog. - * - * @since 3.0 - */ -public class EditSourceLookupPathAction extends SelectionListenerAction { - - private ISourceLookupDirector director = null; - private LaunchView fView = null; - - public EditSourceLookupPathAction(LaunchView view) { - super(SourceLookupUIMessages.EditSourceLookupPathAction_0); - setEnabled(false); - PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.EDIT_SOURCELOOKUP_ACTION); - setImageDescriptor(DebugUITools.getImageDescriptor(IInternalDebugUIConstants.IMG_SRC_LOOKUP_MENU)); - fView = view; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.actions.BaseSelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection) - */ - protected boolean updateSelection(IStructuredSelection selection) { - director = null; - if (selection.size() == 1) { - Object object = selection.getFirstElement(); - ILaunch launch = null; - if (object instanceof IDebugElement) { - launch = ((IDebugElement)object).getLaunch(); - } else if (object instanceof ILaunch) { - launch = (ILaunch)object; - } - if (launch != null && launch.getLaunchConfiguration() != null && - launch.getSourceLocator() instanceof ISourceLookupDirector) { - director = (ISourceLookupDirector) launch.getSourceLocator(); - } - } - return director != null; - } - /* (non-Javadoc) - * @see org.eclipse.jface.action.IAction#run() - */ - public void run() { - Shell shell = DebugUIPlugin.getShell(); - SourceLookupDialog dialog = new SourceLookupDialog(shell, director); - if (dialog.open() == Window.OK) { - ISelection selection = fView.getViewer().getSelection(); - if (selection instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection) selection; - if (ss.size() == 1) { - IWorkbenchPage page = fView.getSite().getPage(); - SourceLookupManager.getDefault().displaySource(ss.getFirstElement(), page, true); - } - } - } - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/LookupSourceAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/LookupSourceAction.java deleted file mode 100644 index 8d13d4e49..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/LookupSourceAction.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup; - -import org.eclipse.debug.core.ILaunch; -import org.eclipse.debug.core.model.IStackFrame; -import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; -import org.eclipse.debug.internal.ui.IDebugHelpContextIds; -import org.eclipse.debug.internal.ui.views.launch.LaunchView; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.actions.SelectionListenerAction; - -/** - * Does source lookup for the selected stack frame again. - * - * @since 3.0 - */ -public class LookupSourceAction extends SelectionListenerAction { - - private ISourceLookupDirector director = null; - private LaunchView fView = null; - private IStackFrame frame = null; - - public LookupSourceAction(LaunchView view) { - super(SourceLookupUIMessages.LookupSourceAction_0); - setEnabled(false); - PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IDebugHelpContextIds.LOOKUP_SOURCE_ACTION); - fView = view; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.actions.BaseSelectionListenerAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection) - */ - protected boolean updateSelection(IStructuredSelection selection) { - director = null; - frame = null; - if (selection.size() == 1) { - Object object = selection.getFirstElement(); - if (object instanceof IStackFrame) { - frame = (IStackFrame)object; - ILaunch launch = frame.getLaunch(); - if (launch != null && launch.getLaunchConfiguration() != null && - launch.getSourceLocator() instanceof ISourceLookupDirector) { - director = (ISourceLookupDirector) launch.getSourceLocator(); - } - } - } - return director != null; - } - /* (non-Javadoc) - * @see org.eclipse.jface.action.IAction#run() - */ - public void run() { - ISelection selection = fView.getViewer().getSelection(); - if (selection instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection) selection; - if (ss.size() == 1) { - IWorkbenchPage page = fView.getSite().getPage(); - SourceLookupManager.getDefault().displaySource(ss.getFirstElement(), page, true); - } - } - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/Prompter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/Prompter.java deleted file mode 100644 index 6be4e4543..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/Prompter.java +++ /dev/null @@ -1,86 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.debug.core.DebugPlugin; -import org.eclipse.debug.core.IStatusHandler; -import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.debug.ui.IDebugUIConstants; -import org.eclipse.swt.widgets.Display; - -/** - * Prompts the user in the UI (asynchronously), on behalf of a non-UI client, - * blocking the calling thread until a response is received. - * <p> - * This status handler is registered for for the debug UI plug-in, - * with a status code of <code>STATUS_HANDLER_PROMPT</code>. - * </p> - * @since 3.0 - */ -public class Prompter implements IStatusHandler { - /** - * Prompts the user for input based on the given status and source - * object, blocking the calling thread until the status is resolved. - * - * @param status client status code for which a status handler must - * be registered - * @param source object requesting the status to be resolved - * @return result of resolving the given status - * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object) - */ - public Object handleStatus(final IStatus status, final Object source) throws CoreException { - DebugPlugin dp = DebugPlugin.getDefault(); - // on shutdown the debug plug-in can be null - if (dp == null) { - throw new CoreException(new Status(IStatus.INFO, - IDebugUIConstants.PLUGIN_ID, - IStatus.OK, - SourceLookupUIMessages.Prompter_0, - null)); - } - final IStatusHandler handler = dp.getStatusHandler(status); - if (handler == null) { - throw new CoreException(new Status(IStatus.ERROR, - IDebugUIConstants.PLUGIN_ID, - IStatus.OK, - SourceLookupUIMessages.Prompter_0, - null)); - } - Display display = DebugUIPlugin.getStandardDisplay(); - if (display.getThread().equals(Thread.currentThread())) { - return handler.handleStatus(status, source); - } - final Object[] result = new Object[1]; - final CoreException[] exception = new CoreException[1]; - final Object lock = this; - Runnable r = new Runnable() { - public void run() { - try { - result[0] = handler.handleStatus(status, source); - } catch (CoreException e) { - exception[0] = e; - } - synchronized (lock) { - lock.notifyAll(); - } - } - }; - DebugUIPlugin.getStandardDisplay().syncExec(r); - - if (exception[0] != null ) { - throw exception[0]; - } - return result[0]; - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/RemoveAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/RemoveAction.java deleted file mode 100644 index 7d0efb2d7..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/RemoveAction.java +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup; - -import java.util.List; - -import org.eclipse.jface.viewers.IStructuredSelection; - -/** - * The action used to remove source containers in the source location dialog/tab. - * - */ -public class RemoveAction extends SourceContainerAction { - public RemoveAction() { - super(SourceLookupUIMessages.sourceTab_removeButton); - } - /** - * Removes all selected entries. - * - * @see IAction#run() - */ - public void run() { - List targets = getOrderedSelection(); - List list = getEntriesAsList(); - list.removeAll(targets); - setEntries(list); - } - - /** - * @see SelectionListenerAction#updateSelection(IStructuredSelection) - */ - protected boolean updateSelection(IStructuredSelection selection) { - //check that something is selected and it is a root tree node. - return !selection.isEmpty() && getViewer().getTree().getSelection()[0].getParentItem()==null; - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/ResolveDuplicatesHandler.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/ResolveDuplicatesHandler.java deleted file mode 100644 index 51174e7cc..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/ResolveDuplicatesHandler.java +++ /dev/null @@ -1,82 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.debug.core.IStatusHandler; -import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.debug.ui.sourcelookup.CommonSourceNotFoundEditor; -import org.eclipse.jface.window.Window; -import org.eclipse.ui.dialogs.ElementListSelectionDialog; - -/** - * Status handler to prompt for dupicate source element resolution. - * - * @since 3.0 - */ -public class ResolveDuplicatesHandler implements IStatusHandler { - /* (non-Javadoc) - * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, java.lang.Object) - */ - public Object handleStatus(IStatus status, Object source) throws CoreException { - Object[] args = (Object[])source; - List sources = (List) args[1]; - return resolveSourceElement(sources); - } - - public Object resolveSourceElement(List sources) { - Object file = null; - sources = removeSourceNotFoundEditors(sources); - if(sources.size() == 1) { - return sources.get(0); - } else if(sources.size() == 0) { - return null; - } - ElementListSelectionDialog dialog = new ElementListSelectionDialog(DebugUIPlugin.getShell(), new SourceElementLabelProvider()); - dialog.setMultipleSelection(false); - dialog.setTitle(SourceLookupUIMessages.ResolveDuplicatesHandler_0); - dialog.setMessage(SourceLookupUIMessages.ResolveDuplicatesHandler_1); - dialog.setElements(sources.toArray()); - dialog.open(); - if(dialog.getReturnCode() == Window.OK) { - file = dialog.getFirstResult(); - } - return file; - } - - /** - * Remove extra source not found editors, if any. - * If multiple source not found editors and no "real" source inputs, - * return the first source not found editor. - * @param sources the list to be filtered - * @return the filtered list, may be empty - */ - private List removeSourceNotFoundEditors(List sources){ - Iterator iterator = sources.iterator(); - List filteredList = new ArrayList(); - Object next; - while(iterator.hasNext()) { - next = iterator.next(); - if (!(next instanceof CommonSourceNotFoundEditor)) { - filteredList.add(next); - } - } - if (filteredList.isEmpty() && sources.get(0) != null) { - filteredList.add(sources.get(0)); - } - return filteredList; - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/RestoreDefaultAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/RestoreDefaultAction.java deleted file mode 100644 index 5020eb698..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/RestoreDefaultAction.java +++ /dev/null @@ -1,58 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup; - -import org.eclipse.debug.core.sourcelookup.ISourceContainer; -import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; -import org.eclipse.debug.core.sourcelookup.containers.DefaultSourceContainer; -import org.eclipse.jface.viewers.IStructuredSelection; - -/** - * The action for adding the default container to the list. - * - * @since 3.0 - */ -public class RestoreDefaultAction extends SourceContainerAction { - - private ISourceLookupDirector fDirector; - - public RestoreDefaultAction() { - super(SourceLookupUIMessages.sourceTab_defaultButton); - } - /** - * @see IAction#run() - */ - public void run() { - ISourceContainer[] containers = new ISourceContainer[1]; - containers[0] = new DefaultSourceContainer(); - containers[0].init(fDirector); - getViewer().setEntries(containers); - setEnabled(false); - } - - public void setSourceLookupDirector(ISourceLookupDirector director) { - fDirector = director; - } - - /** - * @see SelectionListenerAction#updateSelection(IStructuredSelection) - */ - protected boolean updateSelection(IStructuredSelection selection) { - //disable if selection is empty, default already present, or non-root node selected - ISourceContainer[] containers = getViewer().getEntries(); - if(containers != null && containers.length == 1) { - if(containers[0] instanceof DefaultSourceContainer) { - return false; - } - } - return true; - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceContainerAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceContainerAction.java deleted file mode 100644 index e9acaf1b6..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceContainerAction.java +++ /dev/null @@ -1,180 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.debug.core.sourcelookup.ISourceContainer; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.actions.SelectionListenerAction; - -/** - * The abstract class for all source lookup actions. - * - * @since 3.0 - */ -public abstract class SourceContainerAction extends SelectionListenerAction { - //the viewer that the action is operating on - private SourceContainerViewer fViewer; - //the button that is used to invoke the action - private Button fButton; - //the shell used to realize this action's dialog (if any) - private Shell fShell; - - /** - * The constructor for the action - * @param label the label for the action's button - */ - public SourceContainerAction(String label) { - super(label); - } - - /** - * Sets the viewer on which this action operates. - * - * @param viewer the viewer on which this action operates - */ - public void setViewer(SourceContainerViewer viewer) { - if (fViewer != null) { - fViewer.removeSelectionChangedListener(this); - } - fViewer = viewer; - if (fViewer != null) { - fViewer.addSelectionChangedListener(this); - update(); - } - } - - /** - * Returns the viewer on which this action operates. - * - * @return the viewer on which this action operates - */ - protected SourceContainerViewer getViewer() { - return fViewer; - } - - /** - * Returns the selected items in the list, in the order they are - * displayed. - * - * @return targets for an action - */ - protected List getOrderedSelection() { - List targets = new ArrayList(); - List selection = - ((IStructuredSelection) getViewer().getSelection()).toList(); - ISourceContainer[] entries = getViewer().getEntries(); - for (int i = 0; i < entries.length; i++) { - ISourceContainer target = entries[i]; - if (selection.contains(target)) { - targets.add(target); - } - } - return targets; - } - - /** - * Returns a list (copy) of the entries in the viewer - */ - protected List getEntriesAsList() { - ISourceContainer[] entries = getViewer().getEntries(); - List list = new ArrayList(entries.length); - for (int i = 0; i < entries.length; i++) { - list.add(entries[i]); - } - return list; - } - - /** - * Updates the entries to the entries in the given list - */ - protected void setEntries(List list) { - getViewer().setEntries( - (ISourceContainer[]) list.toArray(new ISourceContainer[list.size()])); - // update all selection listeners - getViewer().setSelection(getViewer().getSelection()); - } - - /** - * Returns whether the item at the given index in the list - * (visually) is selected. - */ - protected boolean isIndexSelected( - IStructuredSelection selection, - int index) { - if (selection.isEmpty()) { - return false; - } - Iterator entries = selection.iterator(); - List list = getEntriesAsList(); - while (entries.hasNext()) { - Object next = entries.next(); - if (list.indexOf(next) == index) { - return true; - } - } - return false; - } - - /** - * Sets the button that invokes this action - */ - public void setButton(Button button) { - fButton = button; - button.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent evt) { - run(); - } - }); - } - - /** - * @see IAction#setEnabled(boolean) - */ - public void setEnabled(boolean enabled) { - super.setEnabled(enabled); - if (fButton != null) { - fButton.setEnabled(enabled); - } - } - - /** - * Updates the enabled state. - */ - protected void update() { - selectionChanged((IStructuredSelection) getViewer().getSelection()); - } - - /** - * Returns the shell used to realize this action's dialog (if any). - */ - protected Shell getShell() { - if (fShell == null) { - fShell = getViewer().getControl().getShell(); - } - return fShell; - } - - /** - * Sets the shell used to realize this action's dialog (if any). - */ - public void setShell(Shell shell) { - fShell = shell; - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceContainerAdapterFactory.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceContainerAdapterFactory.java deleted file mode 100644 index cc690aa8d..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceContainerAdapterFactory.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup; - -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.ui.model.IWorkbenchAdapter; - -/** - * Adapter factory for standard source containers. - * - * @since 3.0 - */ -public class SourceContainerAdapterFactory implements IAdapterFactory { - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) - */ - public Object getAdapter(Object adaptableObject, Class adapterType) { - if (adapterType.equals(IWorkbenchAdapter.class)) { - return new SourceContainerWorkbenchAdapter(); - } - return null; - } - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() - */ - public Class[] getAdapterList() { - return new Class[] {IWorkbenchAdapter.class}; - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceContainerLabelProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceContainerLabelProvider.java deleted file mode 100644 index 83b09ccb5..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceContainerLabelProvider.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup; - -import org.eclipse.debug.core.sourcelookup.ISourceContainer; -import org.eclipse.debug.core.sourcelookup.ISourceContainerType; -import org.eclipse.debug.ui.DebugUITools; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.model.WorkbenchLabelProvider; - -/** - * Label provider for source containers and source container types. - * - * @since 3.0 - */ -public class SourceContainerLabelProvider extends LabelProvider { - - private ILabelProvider fLabelProvider = null; - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object) - */ - 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); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) - */ - 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); - } - - private ILabelProvider getWorkbenchLabelProvider() { - if (fLabelProvider == null) { - fLabelProvider = new WorkbenchLabelProvider(); - } - return fLabelProvider; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() - */ - public void dispose() { - super.dispose(); - if (fLabelProvider != null) { - fLabelProvider.dispose(); - } - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceContainerViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceContainerViewer.java deleted file mode 100644 index 001c09cb4..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceContainerViewer.java +++ /dev/null @@ -1,210 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Pawel Piech - Bug 173306: When editing source lookup, new source - * containers should be added at the top of the list - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup; - - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.sourcelookup.ISourceContainer; -import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.widgets.Composite; - -/** - * The viewer containing the source containers in the - * SourceContainerLookupTab and the EditSourceLookupPathDialog. - * It is a tree viewer since the containers are represented in tree form. - * - * @since 3.0 - */ -public class SourceContainerViewer extends TreeViewer { - - /** - * Whether enabled/editable. - */ - private boolean fEnabled = true; - /** - * The parent panel - */ - private SourceLookupPanel fPanel; - /** - * The source container entries displayed in this viewer - */ - protected List fEntries = new ArrayList(); - - class ContentProvider implements ITreeContentProvider { - - /** - * @see IStructuredContentProvider#getElements(Object) - */ - public Object[] getElements(Object inputElement) { - return getEntries(); - } - - /** - * @see IContentProvider#dispose() - */ - public void dispose() { - } - - /** - * @see IContentProvider#inputChanged(Viewer, Object, Object) - */ - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - } - - /** - * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) - */ - public Object[] getChildren(Object parentElement) { - try { - return ((ISourceContainer)parentElement).getSourceContainers(); - } catch (CoreException e) { - return new Object[0]; - } - } - - /** - * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object) - */ - public Object getParent(Object element) { - return null; - } - - /** - * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object) - */ - public boolean hasChildren(Object element) { - return ((ISourceContainer)element).isComposite(); - } - - } - - /** - * Creates a runtime classpath viewer with the given parent. - * - * @param parent the parent control - * @param panel the panel hosting this viewer - */ - public SourceContainerViewer(Composite parent, SourceLookupPanel panel) { - super(parent); - setContentProvider(new ContentProvider()); - SourceContainerLabelProvider lp = new SourceContainerLabelProvider(); - setLabelProvider(lp); - fPanel = panel; - } - - /** - * Sets the entries in this viewer - * - * @param entries source container entries - */ - public void setEntries(ISourceContainer[] entries) { - fEntries.clear(); - for (int i = 0; i < entries.length; i++) { - if(entries[i] != null) - fEntries.add(entries[i]); - } - if (getInput() == null) { - setInput(fEntries); - //select first item in list - if(!fEntries.isEmpty() && fEntries.get(0)!=null) - setSelection(new StructuredSelection(fEntries.get(0))); - } else { - refresh(); - } - fPanel.setDirty(true); - fPanel.updateLaunchConfigurationDialog(); - } - - /** - * Returns the entries in this viewer - * - * @return the entries in this viewer - */ - public ISourceContainer[] getEntries() { - return (ISourceContainer[])fEntries.toArray(new ISourceContainer[fEntries.size()]); - } - - /** - * Adds the given entries to the list. If there is no selection - * in the list, the entries are added at the end of the list, - * otherwise the new entries are added before the (first) selected - * entry. The new entries are selected. - * - * @param entries additions - */ - public void addEntries(ISourceContainer[] entries) { - int index = 0; - IStructuredSelection sel = (IStructuredSelection)getSelection(); - if (!sel.isEmpty()) { - index = fEntries.indexOf(sel.getFirstElement()); - } - for (int i = 0; i < entries.length; i++) { - if (!fEntries.contains(entries[i])) { - fEntries.add(index, entries[i]); - index++; - } - } - - refresh(); - if(entries.length > 0) - setSelection(new StructuredSelection(entries)); - fPanel.setDirty(true); - fPanel.updateLaunchConfigurationDialog(); - } - - /** - * Enables/disables this viewer. Note the control is not disabled, since - * we still want the user to be able to scroll if required to see the - * existing entries. Just actions should be disabled. - */ - public void setEnabled(boolean enabled) { - fEnabled = enabled; - // fire selection change to upate actions - setSelection(getSelection()); - } - - /** - * Returns whether this viewer is enabled - */ - public boolean isEnabled() { - return fEnabled; - } - - /** - * Returns the index of an equivalent entry, or -1 if none. - * - * @return the index of an equivalent entry, or -1 if none - */ - public int indexOf(ISourceContainer entry) { - return fEntries.indexOf(entry); - } - - /** - * Returns the source locator associated with the parent panel. - * - * @return the source locator - */ - public ISourceLookupDirector getSourceLocator() - { - return fPanel.fLocator; - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceContainerWorkbenchAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceContainerWorkbenchAdapter.java deleted file mode 100644 index 5d81128d8..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceContainerWorkbenchAdapter.java +++ /dev/null @@ -1,74 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup; - -import java.io.File; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.debug.core.sourcelookup.containers.ArchiveSourceContainer; -import org.eclipse.debug.core.sourcelookup.containers.DirectorySourceContainer; -import org.eclipse.debug.core.sourcelookup.containers.ExternalArchiveSourceContainer; -import org.eclipse.debug.core.sourcelookup.containers.FolderSourceContainer; -import org.eclipse.debug.internal.core.IInternalDebugCoreConstants; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.model.IWorkbenchAdapter; - -/** - * Workbench adapter for standard source containers. - * - * @since 3.0 - */ -public class SourceContainerWorkbenchAdapter implements IWorkbenchAdapter { - /* (non-Javadoc) - * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object) - */ - public Object[] getChildren(Object o) { - return null; - } - /* (non-Javadoc) - * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object) - */ - public ImageDescriptor getImageDescriptor(Object object) { - return null; - } - /* (non-Javadoc) - * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object) - */ - public String getLabel(Object o) { - if (o instanceof DirectorySourceContainer) { - DirectorySourceContainer container = (DirectorySourceContainer) o; - File file = container.getDirectory(); - IPath path = new Path(file.getAbsolutePath()); - return SourceElementWorkbenchAdapter.getQualifiedName(path); - } - if (o instanceof FolderSourceContainer) { - FolderSourceContainer container = (FolderSourceContainer) o; - return SourceElementWorkbenchAdapter.getQualifiedName(container.getContainer().getFullPath()); - } - if (o instanceof ArchiveSourceContainer) { - ArchiveSourceContainer container = (ArchiveSourceContainer)o; - return SourceElementWorkbenchAdapter.getQualifiedName(container.getFile().getFullPath()); - } - if (o instanceof ExternalArchiveSourceContainer) { - ExternalArchiveSourceContainer container = (ExternalArchiveSourceContainer)o; - IPath path = new Path(container.getName()); - return SourceElementWorkbenchAdapter.getQualifiedName(path); - } - return IInternalDebugCoreConstants.EMPTY_STRING; - } - /* (non-Javadoc) - * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object) - */ - public Object getParent(Object o) { - return null; - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceElementAdapterFactory.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceElementAdapterFactory.java deleted file mode 100644 index 6c76f83bd..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceElementAdapterFactory.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup; - -import org.eclipse.core.runtime.IAdapterFactory; -import org.eclipse.ui.model.IWorkbenchAdapter; - -/** - * Adapter factory for source elements. - * - * @since 3.0 - */ -public class SourceElementAdapterFactory implements IAdapterFactory { - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) - */ - public Object getAdapter(Object adaptableObject, Class adapterType) { - if (adapterType.equals(IWorkbenchAdapter.class)) { - return new SourceElementWorkbenchAdapter(); - } - return null; - } - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() - */ - public Class[] getAdapterList() { - return new Class[] {IWorkbenchAdapter.class}; - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceElementLabelProvider.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceElementLabelProvider.java deleted file mode 100644 index ea9c1054f..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceElementLabelProvider.java +++ /dev/null @@ -1,61 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.model.WorkbenchLabelProvider; - -/** - * A label provider for source elements. - * - * @since 3.0 - */ -public class SourceElementLabelProvider extends LabelProvider { - - private ILabelProvider fLabelProvider = null; - - - - private ILabelProvider getWorkbenchLabelProvider() { - if (fLabelProvider == null) { - fLabelProvider = new WorkbenchLabelProvider(); - } - return fLabelProvider; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose() - */ - public void dispose() { - super.dispose(); - if (fLabelProvider != null) { - fLabelProvider.dispose(); - } - } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object) - */ - public Image getImage(Object element) { - return getWorkbenchLabelProvider().getImage(element); - } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) - */ - public String getText(Object element) { - if (element instanceof IResource) { - return SourceElementWorkbenchAdapter.getQualifiedName(((IResource)element).getFullPath()); - } - return getWorkbenchLabelProvider().getText(element); - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceElementWorkbenchAdapter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceElementWorkbenchAdapter.java deleted file mode 100644 index 3e890a44e..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceElementWorkbenchAdapter.java +++ /dev/null @@ -1,90 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup; - -import java.io.File; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage; -import org.eclipse.debug.core.sourcelookup.containers.ZipEntryStorage; -import org.eclipse.debug.internal.core.IInternalDebugCoreConstants; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.model.IWorkbenchAdapter; - -/** - * Workbench adapter for source elements. - * - * @since 3.0 - */ -public class SourceElementWorkbenchAdapter implements IWorkbenchAdapter { - /* (non-Javadoc) - * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object) - */ - public Object[] getChildren(Object o) { - return null; - } - /* (non-Javadoc) - * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object) - */ - public ImageDescriptor getImageDescriptor(Object o) { - if (o instanceof LocalFileStorage || o instanceof ZipEntryStorage) { - return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJ_FILE); - } - return null; - } - /* (non-Javadoc) - * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object) - */ - public String getLabel(Object o) { - if (o instanceof LocalFileStorage) { - LocalFileStorage storage = (LocalFileStorage) o; - IPath path = storage.getFullPath(); - return getQualifiedName(path); - } - if (o instanceof ZipEntryStorage) { - ZipEntryStorage storage = (ZipEntryStorage)o; - StringBuffer buffer = new StringBuffer(); - buffer.append(storage.getZipEntry().getName()); - buffer.append(" - "); //$NON-NLS-1$ - buffer.append(storage.getArchive().getName()); - return buffer.toString(); - } - return IInternalDebugCoreConstants.EMPTY_STRING; - } - /* (non-Javadoc) - * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object) - */ - public Object getParent(Object o) { - return null; - } - - public static String getQualifiedName(IPath path) { - StringBuffer buffer = new StringBuffer(); - String[] segments = path.segments(); - if (segments.length > 0) { - buffer.append(path.lastSegment()); - if (segments.length > 1) { - buffer.append(" - "); //$NON-NLS-1$ - if (path.getDevice() != null) { - buffer.append(path.getDevice()); - } - for (int i = 0; i < segments.length - 1; i++) { - buffer.append(File.separatorChar); - buffer.append(segments[i]); - } - } - return buffer.toString(); - } - return IInternalDebugCoreConstants.EMPTY_STRING; - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupFacility.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupFacility.java deleted file mode 100644 index 13ae678df..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupFacility.java +++ /dev/null @@ -1,490 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Freescale - Teodor Madan - Show IP for active frame only (Bug 49730) - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.DebugException; -import org.eclipse.debug.core.ILaunch; -import org.eclipse.debug.core.model.IDebugElement; -import org.eclipse.debug.core.model.ISourceLocator; -import org.eclipse.debug.core.model.IStackFrame; -import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector; -import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; -import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.debug.internal.ui.DelegatingModelPresentation; -import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; -import org.eclipse.debug.internal.ui.InstructionPointerManager; -import org.eclipse.debug.internal.ui.views.DebugUIViewsMessages; -import org.eclipse.debug.internal.ui.views.launch.Decoration; -import org.eclipse.debug.internal.ui.views.launch.DecorationManager; -import org.eclipse.debug.internal.ui.views.launch.SourceNotFoundEditorInput; -import org.eclipse.debug.internal.ui.views.launch.StandardDecoration; -import org.eclipse.debug.ui.DebugUITools; -import org.eclipse.debug.ui.IDebugEditorPresentation; -import org.eclipse.debug.ui.IDebugModelPresentation; -import org.eclipse.debug.ui.IDebugUIConstants; -import org.eclipse.debug.ui.IInstructionPointerPresentation; -import org.eclipse.debug.ui.ISourcePresentation; -import org.eclipse.debug.ui.sourcelookup.CommonSourceNotFoundEditorInput; -import org.eclipse.debug.ui.sourcelookup.ISourceLookupResult; -import org.eclipse.jface.text.BadLocationException; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.IRegion; -import org.eclipse.jface.text.source.Annotation; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.swt.custom.BusyIndicator; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorReference; -import org.eclipse.ui.IPageListener; -import org.eclipse.ui.IPartListener2; -import org.eclipse.ui.IReusableEditor; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchPartReference; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.texteditor.IDocumentProvider; -import org.eclipse.ui.texteditor.ITextEditor; - -/** - * Utility methods for looking up and displaying source. - * - * @since 3.1 - */ -public class SourceLookupFacility implements IPageListener, IPartListener2, IPropertyChangeListener { - - /** - * Singleton source lookup facility - */ - private static SourceLookupFacility fgDefault; - - /** - * Contains a map of the editor to use for each workbench - * page, when the 'reuse editor' preference is on. - */ - private Map fEditorsByPage; - - /** - * Used to generate annotations for stack frames - */ - private IInstructionPointerPresentation fPresentation = (IInstructionPointerPresentation) DebugUITools.newDebugModelPresentation(); - - /** - * Whether to re-use editors when displaying source. - */ - private boolean fReuseEditor = DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IDebugUIConstants.PREF_REUSE_EDITOR); - - /** - * Returns the source lookup facility - * @return - */ - public static SourceLookupFacility getDefault() { - if (fgDefault == null) { - fgDefault = new SourceLookupFacility(); - } - return fgDefault; - } - - /** - * Performs cleanup - */ - public static void shutdown() { - if (fgDefault != null) { - fgDefault.dispose(); - } - } - - /** - * Constructs a source lookup facility. - */ - private SourceLookupFacility() { - fEditorsByPage = new HashMap(); - DebugUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this); - } - - /** - * Performs source lookup for the given artifact and returns the result. - * - * @param artifact object for which source is to be resolved - * @param locator the source locator to use, or <code>null</code>. When <code>null</code> - * a source locator is determined from the artifact, if possible. If the artifact - * is a debug element, the source locator from its associated launch is used. - * @return a source lookup result - */ - public SourceLookupResult lookup(Object artifact, ISourceLocator locator) { - SourceLookupResult result = new SourceLookupResult(artifact, null, null, null); - IDebugElement debugElement = null; - if (artifact instanceof IDebugElement) { - debugElement = (IDebugElement)artifact; - } - if (locator == null) { - ILaunch launch = null; - if (debugElement != null) { - launch = debugElement.getLaunch(); - } - if (launch != null) { - locator = launch.getSourceLocator(); - } - } - if (locator != null) { - String editorId =null; - IEditorInput editorInput = null; - Object sourceElement = null; - if (locator instanceof ISourceLookupDirector) { - ISourceLookupDirector director = (ISourceLookupDirector)locator; - sourceElement = director.getSourceElement(artifact); - } else { - if (artifact instanceof IStackFrame) { - sourceElement = locator.getSourceElement((IStackFrame)artifact); - } - } - if (sourceElement == null) { - if (locator instanceof AbstractSourceLookupDirector) { - editorInput = new CommonSourceNotFoundEditorInput(artifact); - editorId = IDebugUIConstants.ID_COMMON_SOURCE_NOT_FOUND_EDITOR; - } else { - if (artifact instanceof IStackFrame) { - IStackFrame frame = (IStackFrame)artifact; - editorInput = new SourceNotFoundEditorInput(frame); - editorId = IInternalDebugUIConstants.ID_SOURCE_NOT_FOUND_EDITOR; - } - } - } else { - ISourcePresentation presentation= null; - if (locator instanceof ISourcePresentation) { - presentation= (ISourcePresentation) locator; - } else { - if (debugElement != null) { - presentation= getPresentation(debugElement.getModelIdentifier()); - } - } - if (presentation != null) { - editorInput= presentation.getEditorInput(sourceElement); - } - if (editorInput != null) { - editorId= presentation.getEditorId(editorInput, sourceElement); - } - } - result.setEditorInput(editorInput); - result.setEditorId(editorId); - result.setSourceElement(sourceElement); - } - return result; - } - - /** - * Returns the model presentation for the given debug model, or <code>null</code> - * if none. - * - * @param id debug model id - * @return presentation for the model, or <code>null</code> if none. - */ - protected IDebugModelPresentation getPresentation(String id) { - return ((DelegatingModelPresentation)DebugUIPlugin.getModelPresentation()).getPresentation(id); - } - - /** - * Returns an editor presentation. - * - * @return an editor presentation - */ - protected IDebugEditorPresentation getEditorPresentation() { - return (DelegatingModelPresentation)DebugUIPlugin.getModelPresentation(); - } - - /** - * Opens an editor in the given workbench page for the given source lookup - * result. Has no effect if the result has an unknown editor id or editor input. - * The editor is opened, positioned, and annotated. - * <p> - * Honor's the user preference of whether to re-use editors when displaying source. - * </p> - * @param result source lookup result to display - * @param page the page to display the result in - */ - public void display(ISourceLookupResult result, IWorkbenchPage page) { - IEditorPart editor= openEditor(result, page); - if (editor == null) { - return; - } - IStackFrame frame = null; - if (result.getArtifact() instanceof IStackFrame) { - frame = (IStackFrame) result.getArtifact(); - } - // position and annotate editor for stack frame - if (frame != null) { - IDebugEditorPresentation editorPresentation = getEditorPresentation(); - if (editorPresentation.addAnnotations(editor, frame)) { - Decoration decoration = new StandardDecoration(editorPresentation, editor, frame.getThread()); - DecorationManager.addDecoration(decoration); - } else { - // perform standard positioning and annotations - ITextEditor textEditor = null; - if (editor instanceof ITextEditor) { - textEditor = (ITextEditor)editor; - } else { - textEditor = (ITextEditor) editor.getAdapter(ITextEditor.class); - } - if (textEditor != null) { - positionEditor(textEditor, frame); - InstructionPointerManager.getDefault().removeAnnotations(textEditor); - Annotation annotation = fPresentation.getInstructionPointerAnnotation(textEditor, frame); - InstructionPointerManager.getDefault().addAnnotation(textEditor, frame, annotation); - } - } - } - } - - /** - * Opens the editor used to display the source for an element selected in - * this view and returns the editor that was opened or <code>null</code> if - * no editor could be opened. - */ - private IEditorPart openEditor(ISourceLookupResult result, IWorkbenchPage page) { - IEditorPart editor = null; - IEditorInput input= result.getEditorInput(); - String id= result.getEditorId(); - if (input == null || id == null) { - return null; - } - - if (fReuseEditor) { - IEditorReference[] references = page.findEditors(input, id, IWorkbenchPage.MATCH_ID | IWorkbenchPage.MATCH_INPUT); - if (references.length > 0) { - // activate the editor we want to reuse - IEditorPart refEditor= references[0].getEditor(false); - editor = refEditor; - page.bringToTop(editor); - } - if (editor == null) { - IEditorPart editorForPage = getEditor(page); - if (editorForPage == null || editorForPage.isDirty() || page.isEditorPinned(editorForPage)) { - // open a new editor - editor = openEditor(page, input, id); - editorForPage = editor; - } else if (editorForPage instanceof IReusableEditor && editorForPage.getSite().getId().equals(id)) { - // re-use editor - page.reuseEditor((IReusableEditor)editorForPage, input); - editor = editorForPage; - if(!page.isPartVisible(editor)) { - page.bringToTop(editor); - } - } else { - // close editor, open a new one - editor = openEditor(page, input, id); - page.closeEditor(editorForPage, false); - editorForPage = editor; - } - setEditor(page, editorForPage); - } - } else { - // Open a new editor - editor = openEditor(page, input, id); - } - return editor; - } - - /** - * Positions the text editor for the given stack frame - */ - private void positionEditor(ITextEditor editor, IStackFrame frame) { - try { - int charStart = frame.getCharStart(); - if (charStart >= 0) { - editor.selectAndReveal(charStart, 0); - return; - } - int lineNumber = frame.getLineNumber(); - lineNumber--; // Document line numbers are 0-based. Debug line numbers are 1-based. - IRegion region= getLineInformation(editor, lineNumber); - if (region != null) { - editor.selectAndReveal(region.getOffset(), 0); - } - } catch (DebugException e) { - } - } - - /** - * Returns the line information for the given line in the given editor - */ - private IRegion getLineInformation(ITextEditor editor, int lineNumber) { - IDocumentProvider provider= editor.getDocumentProvider(); - IEditorInput input= editor.getEditorInput(); - try { - provider.connect(input); - } catch (CoreException e) { - return null; - } - try { - IDocument document= provider.getDocument(input); - if (document != null) - return document.getLineInformation(lineNumber); - } catch (BadLocationException e) { - } finally { - provider.disconnect(input); - } - return null; - } - /** - * Opens an editor in the workbench and returns the editor that was opened - * or <code>null</code> if an error occurred while attempting to open the - * editor. - */ - private IEditorPart openEditor(final IWorkbenchPage page, final IEditorInput input, final String id) { - final IEditorPart[] editor = new IEditorPart[] {null}; - Runnable r = new Runnable() { - public void run() { - if (!page.getWorkbenchWindow().getWorkbench().isClosing()) { - try { - editor[0] = page.openEditor(input, id, false, IWorkbenchPage.MATCH_ID|IWorkbenchPage.MATCH_INPUT); - } catch (PartInitException e) { - DebugUIPlugin.errorDialog(DebugUIPlugin.getShell(), - DebugUIViewsMessages.LaunchView_Error_1, - DebugUIViewsMessages.LaunchView_Exception_occurred_opening_editor_for_debugger__2, - e); - } - } - } - }; - BusyIndicator.showWhile(DebugUIPlugin.getStandardDisplay(), r); - return editor[0]; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPageListener#pageActivated(org.eclipse.ui.IWorkbenchPage) - */ - public void pageActivated(IWorkbenchPage page) { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPageListener#pageClosed(org.eclipse.ui.IWorkbenchPage) - */ - public void pageClosed(IWorkbenchPage page) { - fEditorsByPage.remove(page); - page.removePartListener(this); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPageListener#pageOpened(org.eclipse.ui.IWorkbenchPage) - */ - public void pageOpened(IWorkbenchPage page) { - page.addPartListener(this); - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener2#partActivated(org.eclipse.ui.IWorkbenchPartReference) - */ - public void partActivated(IWorkbenchPartReference partRef) { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener2#partBroughtToTop(org.eclipse.ui.IWorkbenchPartReference) - */ - public void partBroughtToTop(IWorkbenchPartReference partRef) { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener2#partClosed(org.eclipse.ui.IWorkbenchPartReference) - */ - public void partClosed(IWorkbenchPartReference partRef) { - // clear the cached editor for the page if it has been closed - IWorkbenchPage page = partRef.getPage(); - IEditorPart editor = getEditor(page); - IWorkbenchPart part = partRef.getPart(false); - if (part != null && part.equals(editor)) { - fEditorsByPage.remove(page); - } - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener2#partDeactivated(org.eclipse.ui.IWorkbenchPartReference) - */ - public void partDeactivated(IWorkbenchPartReference partRef) { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener2#partOpened(org.eclipse.ui.IWorkbenchPartReference) - */ - public void partOpened(IWorkbenchPartReference partRef) { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener2#partHidden(org.eclipse.ui.IWorkbenchPartReference) - */ - public void partHidden(IWorkbenchPartReference partRef) { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener2#partVisible(org.eclipse.ui.IWorkbenchPartReference) - */ - public void partVisible(IWorkbenchPartReference partRef) { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IPartListener2#partInputChanged(org.eclipse.ui.IWorkbenchPartReference) - */ - public void partInputChanged(IWorkbenchPartReference partRef) { - } - - /* (non-Javadoc) - * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) - */ - public void propertyChange(PropertyChangeEvent event) { - String property = event.getProperty(); - if (property.equals(IDebugUIConstants.PREF_REUSE_EDITOR)) { - fReuseEditor = DebugUIPlugin.getDefault().getPreferenceStore().getBoolean(IDebugUIConstants.PREF_REUSE_EDITOR); - } - } - - /** - * Returns the editor to use to display source in the given page, or - * <code>null</code> if a new editor should be opened. - * - * @param page workbench page - * @return the editor to use to display source in the given page, or - * <code>null</code> if a new editor should be opened - */ - protected IEditorPart getEditor(IWorkbenchPage page) { - return (IEditorPart) fEditorsByPage.get(page); - } - - /** - * Sets the editor to use to display source in the given page, or - * <code>null</code> if a new editor should be opened. - * - * @param page workbench page - * @return the editor to use to display source in the given page, or - * <code>null</code> if a new editor should be opened - */ - protected void setEditor(IWorkbenchPage page, IEditorPart editorPart) { - if (editorPart == null) { - fEditorsByPage.remove(page); - } else { - fEditorsByPage.put(page, editorPart); - } - page.addPartListener(this); - page.getWorkbenchWindow().addPageListener(this); - } - - /** - * Performs cleanup. - */ - protected void dispose() { - DebugUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this); - fEditorsByPage.clear(); - fPresentation.dispose(); - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupManager.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupManager.java deleted file mode 100644 index 50dc8a3d9..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupManager.java +++ /dev/null @@ -1,98 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup; - -import java.util.HashMap; -import java.util.Map; - -import org.eclipse.ui.IWindowListener; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; - -/** - * Starts a source lookup service in each workbench window. - * - * @since 3.2 - */ -public class SourceLookupManager implements IWindowListener { - - private static SourceLookupManager fgDefault; - - /** - * Services per window - */ - private Map fServices = new HashMap(); - - private SourceLookupManager() { - IWorkbench workbench = PlatformUI.getWorkbench(); - IWorkbenchWindow[] workbenchWindows = workbench.getWorkbenchWindows(); - for (int i = 0; i < workbenchWindows.length; i++) { - IWorkbenchWindow window = workbenchWindows[i]; - windowOpened(window); - } - workbench.addWindowListener(this); - } - - /** - * Returns the default source lookup manager. - * - * @return - */ - public static SourceLookupManager getDefault() { - if (fgDefault == null) { - fgDefault = new SourceLookupManager(); - } - return fgDefault; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWindowListener#windowActivated(org.eclipse.ui.IWorkbenchWindow) - */ - public void windowActivated(IWorkbenchWindow window) { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWindowListener#windowDeactivated(org.eclipse.ui.IWorkbenchWindow) - */ - public void windowDeactivated(IWorkbenchWindow window) { - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWindowListener#windowClosed(org.eclipse.ui.IWorkbenchWindow) - */ - public void windowClosed(IWorkbenchWindow window) { - SourceLookupService service = (SourceLookupService) fServices.get(window); - if (service != null) { - service.dispose(); - } - } - - /* (non-Javadoc) - * @see org.eclipse.ui.IWindowListener#windowOpened(org.eclipse.ui.IWorkbenchWindow) - */ - public void windowOpened(IWorkbenchWindow window) { - SourceLookupService service = new SourceLookupService(window); - fServices.put(window, service); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.contexts.ISourceDisplayAdapter#displaySource(java.lang.Object, org.eclipse.ui.IWorkbenchPage, boolean) - */ - public void displaySource(Object context, IWorkbenchPage page, boolean forceSourceLookup) { - IWorkbenchWindow window = page.getWorkbenchWindow(); - SourceLookupService service = (SourceLookupService) fServices.get(window); - if (service != null) { - service.displaySource(context, page, forceSourceLookup); - } - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupPanel.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupPanel.java deleted file mode 100644 index 9e5184b1a..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupPanel.java +++ /dev/null @@ -1,392 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * QNX Software Systems - Mikhail Khodjaiants - Bug 89748 - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.ILaunchConfiguration; -import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; -import org.eclipse.debug.core.model.ISourceLocator; -import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector; -import org.eclipse.debug.core.sourcelookup.ISourceContainer; -import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; -import org.eclipse.debug.core.sourcelookup.containers.DefaultSourceContainer; -import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.debug.internal.ui.SWTFactory; -import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; -import org.eclipse.debug.ui.sourcelookup.WorkingSetSourceContainer; -import org.eclipse.jface.util.IPropertyChangeListener; -import org.eclipse.jface.util.PropertyChangeEvent; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IWorkingSet; -import org.eclipse.ui.IWorkingSetManager; - -/** - * The panel that contains the list of source containers. - * - * @since 3.0 - */ -public class SourceLookupPanel extends AbstractLaunchConfigurationTab implements IPropertyChangeListener { - //the configuration being edited - protected ILaunchConfiguration fConfig; - //the viewer displaying the containers - protected SourceContainerViewer fPathViewer; - //the duplicates checkbox - protected Button fDuplicatesButton; - //the source actions - up, down, add, remove, restore - protected List fActions = new ArrayList(6); - //the director that will be used by the tab to manage/store the containers - protected ISourceLookupDirector fLocator; - - protected AddContainerAction fAddAction; - protected EditContainerAction fEditAction; - protected RestoreDefaultAction fRestoreDefaultAction; - - /** - * Creates and returns the source lookup control. - * - * @param parent the parent widget of this control - */ - public void createControl(Composite parent) { - Font font = parent.getFont(); - Composite comp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH); - SWTFactory.createLabel(comp, SourceLookupUIMessages.sourceTab_lookupLabel, 2); - - fPathViewer = new SourceContainerViewer(comp, this); - fPathViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); - fPathViewer.getControl().setFont(font); - - Composite pathButtonComp = SWTFactory.createComposite(comp, comp.getFont(), 1, 1, GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_FILL, 0, 0); - - SWTFactory.createVerticalSpacer(comp, 2); - - fDuplicatesButton = SWTFactory.createCheckButton(comp, SourceLookupUIMessages.sourceTab_searchDuplicateLabel, null, false, 2); - fDuplicatesButton.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent evt) { - setDirty(true); - updateLaunchConfigurationDialog(); - } - }); - - fAddAction = new AddContainerAction(); - Button button = SWTFactory.createPushButton(pathButtonComp, fAddAction.getText(), null); - fAddAction.setButton(button); - addAction(fAddAction); - - fEditAction = new EditContainerAction(); - button = SWTFactory.createPushButton(pathButtonComp, fEditAction.getText(), null); - fEditAction.setButton(button); - addAction(fEditAction); - - SourceContainerAction action = new RemoveAction(); - button = SWTFactory.createPushButton(pathButtonComp, action.getText(), null); - action.setButton(button); - addAction(action); - - action = new UpAction(); - button = SWTFactory.createPushButton(pathButtonComp, action.getText(), null); - action.setButton(button); - addAction(action); - - action = new DownAction(); - button = SWTFactory.createPushButton(pathButtonComp, action.getText(), null); - action.setButton(button); - addAction(action); - - fRestoreDefaultAction = new RestoreDefaultAction(); - button = SWTFactory.createPushButton(pathButtonComp, fRestoreDefaultAction.getText(), null); - fRestoreDefaultAction.setButton(button); - addAction(fRestoreDefaultAction); - - retargetActions(fPathViewer); - - //listen to changes user made to the working sets, if a working set is being removed - //check current list to validate working sets - IWorkingSetManager workingSetMgr = DebugUIPlugin.getDefault().getWorkbench().getWorkingSetManager(); - workingSetMgr.addPropertyChangeListener(this); - /*Dialog.applyDialogFont(comp);*/ - setControl(comp); - } - - /** - * Adds the given action to the action collection in this tab - */ - protected void addAction(SourceContainerAction action) { - fActions.add(action); - } - - /** - * Re-targets actions to the given viewer - */ - protected void retargetActions(SourceContainerViewer viewer) { - Iterator actions = fActions.iterator(); - while (actions.hasNext()) { - SourceContainerAction action = (SourceContainerAction) actions.next(); - action.setViewer(viewer); - } - } - - /** - * Initializes this control based on the settings in the given - * launch configuration. - */ - public void initializeFrom(ILaunchConfiguration configuration) { - if (fLocator != null) { - fLocator.dispose(); - fLocator = null; - } - setErrorMessage(null); - setMessage(null); - String memento = null; - String type = null; - try{ - memento = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, (String)null); - type = configuration.getAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, (String)null); - if (type == null) { - type = configuration.getType().getSourceLocatorId(); - } - } catch(CoreException e){ - setErrorMessage(e.getMessage()); - return; - } - - if(type == null) { - setErrorMessage(SourceLookupUIMessages.sourceLookupPanel_2); - return; - } - - boolean migration = false; - try { - ISourceLocator locator = getLaunchManager().newSourceLocator(type); - if(!(locator instanceof AbstractSourceLookupDirector)) { - // migrate to the new source lookup infrastructure - memento = null; // don't use old memento - type = configuration.getType().getSourceLocatorId(); - if(type == null) { - setErrorMessage(SourceLookupUIMessages.sourceLookupPanel_2); - return; - } - locator = getLaunchManager().newSourceLocator(type); - if (!(locator instanceof AbstractSourceLookupDirector)) { - setErrorMessage(SourceLookupUIMessages.sourceLookupPanel_2); - return; - } - migration = true; - } - fLocator = (AbstractSourceLookupDirector)locator; - if (memento == null) { - fLocator.initializeDefaults(configuration); - } else { - fLocator.initializeFromMemento(memento, configuration); - } - } catch (CoreException e) { - setErrorMessage(e.getMessage()); - return; - } - initializeFrom(fLocator); - if (migration && configuration.isWorkingCopy()) { - // ensure perform apply actual updates the config - setDirty(true); - performApply((ILaunchConfigurationWorkingCopy)configuration); - } - } - - /** - * Initializes this control based on the settings in the given - * AbstractSourceLookupDirector - */ - public void initializeFrom(ISourceLookupDirector locator) { - if(fConfig == null) { - fConfig = locator.getLaunchConfiguration(); - } - fPathViewer.setEntries(locator.getSourceContainers()); - fDuplicatesButton.setSelection(locator.isFindDuplicates()); - fLocator = locator; - fAddAction.setSourceLookupDirector(locator); - fEditAction.setSourceLookupDirector(locator); - fRestoreDefaultAction.setSourceLookupDirector(locator); - setDirty(false); - } - - /** - * Saves the containers and duplicate policy into the given working copy of the configuration. - * Saving the configuration will result in a change event, which will be picked up by the director - * and used to refresh its internal list. - * - * @param workingCopy the working copy of the configuration that these values should be stored in, may be null. - * If null, will be written into a working copy of the configuration referenced by the director. - */ - public void performApply(ILaunchConfigurationWorkingCopy configuration) { - if (isDirty()) { - if (fLocator == null) { - configuration.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, (String)null); - configuration.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, (String)null); - return; - } - ILaunchConfigurationWorkingCopy workingCopy = configuration; - if(configuration == null) { - try { - ILaunchConfiguration config = fLocator.getLaunchConfiguration(); - if(config != null) { - workingCopy = config.getWorkingCopy(); - } - } - catch(CoreException e) { - DebugUIPlugin.log(e); - setErrorMessage(SourceLookupUIMessages.sourceLookupPanel_1); - return; - } - } - if(workingCopy == null) { - DebugUIPlugin.logErrorMessage("Error occurred - a working copy could not be acquired, therefore source lookup path changes will not be applied."); //$NON-NLS-1$ - return; - } - //set new values in director so memento returned is correct - fLocator.setSourceContainers(fPathViewer.getEntries()); - fLocator.setFindDuplicates(fDuplicatesButton.getSelection()); - - //writing to the file will cause a change event and the listeners will be updated - try { - if (isDefault()) { - workingCopy.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, (String)null); - workingCopy.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, (String)null); - } else { - workingCopy.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_MEMENTO, fLocator.getMemento()); - workingCopy.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, fLocator.getId()); - } - } - catch(CoreException e) { - DebugUIPlugin.log(e); - setErrorMessage(SourceLookupUIMessages.sourceLookupPanel_1); - } - - } - } - - /** - * determines of the current source lookup path is the default path - * @param configuration - * @return - */ - protected boolean isDefault() { - ISourceContainer[] current = getEntries(); - return !fDuplicatesButton.getSelection() && current.length == 1 && current[0] instanceof DefaultSourceContainer; - } - - /** - * Returns the entries visible in the viewer - */ - public ISourceContainer[] getEntries() { - return fPathViewer.getEntries(); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#setDirty(boolean) - */ - public void setDirty(boolean dirty) { - super.setDirty(dirty); - - } - - /* (non-Javadoc) - * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName() - */ - public String getName() { - return SourceLookupUIMessages.sourceTab_tabTitle; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) - */ - public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {} - - /* (non-Javadoc) - * @see org.eclipse.debug.ui.AbstractLaunchConfigurationTab#updateLaunchConfigurationDialog() - */ - protected void updateLaunchConfigurationDialog() { - if (getLaunchConfigurationDialog() != null) { - super.updateLaunchConfigurationDialog(); - } - } - - /** - * This is called whenever a working set has been removed. Loops through the original list - * of working sets the user stores in the configuration. If the one being removed is in the - * list, remove it from the list - * @param affectedWorkingSet - the working set being removed - */ - private void validateWorkingSetSourceContainers(IWorkingSet affectedWorkingSet) { - List sourceContainers = (List) fPathViewer.getInput(); - if (sourceContainers != null) { - for (int i = 0; i < sourceContainers.size(); i++) { - if (sourceContainers.get(i) instanceof WorkingSetSourceContainer) { - WorkingSetSourceContainer wsSrcContainer = (WorkingSetSourceContainer) sourceContainers.get(i); - if (wsSrcContainer.getName().equals(affectedWorkingSet.getName())) { - sourceContainers.remove(i); - } - } - } - } - } - - /** - * Listen to working set changes - * @param event - */ - public void propertyChange(PropertyChangeEvent event) { - //if the PropertyChangeEvent has changeId CHANGE_WORKING_SET_REMOVE, - //validate the list to make sure all working sets are valid - //if the PropertyChangeEvent has changeId CHANGE_WORKING_SET_NAME_CHANGE, - //do nothing because the event only has newValue, since oldValue is not provided - //there is no way to identify which working set does the newValue corresponds to - if (event.getProperty().equals(IWorkingSetManager.CHANGE_WORKING_SET_REMOVE)) - validateWorkingSetSourceContainers((IWorkingSet) event.getOldValue()); - } - - - /* (non-Javadoc) - * @see org.eclipse.debug.ui.ILaunchConfigurationTab#activated(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) - */ - public void activated(ILaunchConfigurationWorkingCopy workingCopy) { - initializeFrom(workingCopy); - } - - /** - * Returns the source lookup director associated with this - * panel, or <code>null</code> if none. - * - * @return the source lookup director associated with this - * panel, or <code>null</code> if none - */ - public ISourceLookupDirector getDirector() { - return fLocator; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.ui.ILaunchConfigurationTab#dispose() - */ - public void dispose() { - super.dispose(); - //listen to changes user made to the working sets, if a working set is being removed - //check current list to validate working sets - IWorkingSetManager workingSetMgr = DebugUIPlugin.getDefault().getWorkbench().getWorkingSetManager(); - workingSetMgr.removePropertyChangeListener(this); - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupResult.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupResult.java deleted file mode 100644 index 940dc9253..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupResult.java +++ /dev/null @@ -1,129 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup; - -import org.eclipse.debug.ui.sourcelookup.ISourceLookupResult; -import org.eclipse.ui.IEditorInput; - -/** - * The result of a source lookup contains the source element, editor id, and - * editor input resolved for a debug artifact. - * - * @since 3.1 - */ -public class SourceLookupResult implements ISourceLookupResult { - - /** - * Element that source was resolved for. - */ - private Object fArtifact; - /** - * Corresponding source element, or <code>null</code> - * if unknown. - */ - private Object fSourceElement; - /** - * Associated editor id, used to display the source element, - * or <code>null</code> if unknown. - */ - private String fEditorId; - /** - * Associated editor input, used to display the source element, - * or <code>null</code> if unknown. - */ - private IEditorInput fEditorInput; - - /** - * Creates a source lookup result on the given artifact, source element, - * editor id, and editor input. - */ - public SourceLookupResult(Object artifact, Object sourceElement, String editorId, IEditorInput editorInput) { - fArtifact = artifact; - setSourceElement(sourceElement); - setEditorId(editorId); - setEditorInput(editorInput); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.ui.sourcelookup.ISourceLookupResult#getArtifact() - */ - public Object getArtifact() { - return fArtifact; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.ui.sourcelookup.ISourceLookupResult#getSourceElement() - */ - public Object getSourceElement() { - return fSourceElement; - } - - /** - * Sets the source element resolved for the artifact that source - * lookup was performed for, or <code>null</code> if a source element - * was not resolved. - * - * @param element resolved source element or <code>null</code> if unknown - */ - protected void setSourceElement(Object element) { - fSourceElement = element; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.ui.sourcelookup.ISourceLookupResult#getEditorId() - */ - public String getEditorId() { - return fEditorId; - } - - /** - * Sets the identifier of the editor used to display this source - * lookup result's source element, or <code>null</code> if unknown. - * - * @param id the identifier of the editor used to display this source - * lookup result's source element, or <code>null</code> if unknown - */ - protected void setEditorId(String id) { - fEditorId = id; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.ui.sourcelookup.ISourceLookupResult#getEditorInput() - */ - public IEditorInput getEditorInput() { - return fEditorInput; - } - - /** - * Sets the editor input used to display this source lookup - * result's source element, or <code>null</code> if unknown. - * - * @param input the editor input used to display this source lookup - * result's source element, or <code>null</code> if unknown - */ - protected void setEditorInput(IEditorInput input) { - fEditorInput = input; - } - - /** - * Updates the artifact to refer to the given artifact - * if equal. For example, when a source lookup result is reused - * for the same stack frame, we still need to update in case - * the stack frame is not identical. - * - * @param artifact new artifact state - */ - public void updateArtifact(Object artifact) { - if (fArtifact.equals(artifact)) { - fArtifact = artifact; - } - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupService.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupService.java deleted file mode 100644 index b2d28c017..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupService.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * Wind River - Pawel Piech - Fixed debug context service usage (Bug 258189) - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup; - -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.PlatformObject; -import org.eclipse.debug.internal.ui.views.launch.DebugElementAdapterFactory; -import org.eclipse.debug.ui.DebugUITools; -import org.eclipse.debug.ui.contexts.DebugContextEvent; -import org.eclipse.debug.ui.contexts.IDebugContextListener; -import org.eclipse.debug.ui.contexts.IDebugContextService; -import org.eclipse.debug.ui.sourcelookup.ISourceDisplay; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; - -/** - * Performs source lookup in a window. - * - * @since 3.2 - */ -public class SourceLookupService implements IDebugContextListener, ISourceDisplay { - - private IWorkbenchWindow fWindow; - private IDebugContextService fDebugContextService; - - public SourceLookupService(IWorkbenchWindow window) { - fWindow = window; - fDebugContextService = DebugUITools.getDebugContextManager().getContextService(window); - fDebugContextService.addDebugContextListener(this); - } - - public void dispose() { - fDebugContextService.removeDebugContextListener(this); - } - - public synchronized void debugContextChanged(DebugContextEvent event) { - if ((event.getFlags() & DebugContextEvent.ACTIVATED) > 0) { - displaySource(event.getContext(), event.getDebugContextProvider().getPart(), false); - } - } - - /** - * Displays source for the given selection and part, optionally forcing - * a source lookup. - * - * @param selection - * @param part - * @param force - */ - protected synchronized void displaySource(ISelection selection, IWorkbenchPart part, boolean force) { - if (selection instanceof IStructuredSelection) { - IStructuredSelection structuredSelection = (IStructuredSelection)selection; - if (structuredSelection.size() == 1) { - Object context = (structuredSelection).getFirstElement(); - IWorkbenchPage page = null; - if (part == null) { - page = fWindow.getActivePage(); - } else { - page = part.getSite().getPage(); - } - displaySource(context, page, force); - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.contexts.ISourceDisplayAdapter#displaySource(java.lang.Object, org.eclipse.ui.IWorkbenchPage, boolean) - */ - public void displaySource(Object context, IWorkbenchPage page, boolean forceSourceLookup) { - if (context instanceof IAdaptable) { - IAdaptable adaptable = (IAdaptable) context; - ISourceDisplay adapter = (ISourceDisplay) adaptable.getAdapter(ISourceDisplay.class); - if (adapter == null && !(context instanceof PlatformObject)) { - // for objects that don't properly subclass PlatformObject to inherit default - // adapters, just delegate to the adapter factory - adapter = (ISourceDisplay) new DebugElementAdapterFactory().getAdapter(context, ISourceDisplay.class); - } - if (adapter != null) { - adapter.displaySource(context, page, forceSourceLookup); - } - } - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIMessages.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIMessages.java deleted file mode 100644 index 3e3470ab6..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIMessages.java +++ /dev/null @@ -1,88 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2006 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM - Initial API and implementation - * QNX Software Systems - Mikhail Khodjaiants - Bug 114664 - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup; - -import org.eclipse.osgi.util.NLS; - -public class SourceLookupUIMessages extends NLS { - private static final String BUNDLE_NAME = "org.eclipse.debug.internal.ui.sourcelookup.SourceLookupUIMessages";//$NON-NLS-1$ - - public static String CommonSourceNotFoundEditor_0; - - public static String CommonSourceNotFoundEditor_1; - - // Source search launch configuration tab/errors/dialogs - public static String EditContainerAction_0; - - public static String SourceLookupDialog_0; - - public static String SourceLookupDialog_1; - public static String sourceTab_lookupLabel; - public static String sourceTab_searchDuplicateLabel; - public static String sourceTab_upButton; - public static String sourceTab_downButton; - public static String sourceTab_removeButton; - public static String sourceTab_addButton; - public static String sourceTab_tabTitle; - public static String sourceTab_defaultButton; - - public static String addSourceLocation_title; - public static String addSourceLocation_description; - - public static String addSourceLocation_addButton2; - public static String addSourceLocation_editorMessage; - - public static String sourceSearch_folderSelectionError; - public static String sourceSearch_initError; - - public static String projectSelection_chooseLabel; - public static String projectSelection_requiredLabel; - - public static String folderSelection_title; - public static String folderSelection_label; - - public static String manageSourceDialog_title; - public static String manageSourceDialog_description; - - public static String sourceLookupPanel_1; - public static String sourceLookupPanel_2; - public static String ResolveDuplicatesHandler_0; - public static String ResolveDuplicatesHandler_1; - public static String EditSourceLookupPathAction_0; - public static String LookupSourceAction_0; - public static String ExternalArchiveSourceContainerBrowser_2; - public static String ArchiveSourceContainerBrowser_3; - public static String ArchiveSourceContainerBrowser_4; - public static String DirectorySourceContainerDialog_0; - public static String DirectorySourceContainerDialog_1; - - static { - // load message values from bundle file - NLS.initializeMessages(BUNDLE_NAME, SourceLookupUIMessages.class); - } - - public static String DirectorySourceContainerDialog_2; - - public static String DirectorySourceContainerDialog_3; - - public static String DirectorySourceContainerDialog_4; - - public static String DirectorySourceContainerDialog_5; - - public static String DirectorySourceContainerDialog_6; - - public static String DirectorySourceContainerDialog_7; - - public static String DirectorySourceContainerDialog_8; - - public static String Prompter_0; -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIMessages.properties b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIMessages.properties deleted file mode 100644 index ab28335f8..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIMessages.properties +++ /dev/null @@ -1,64 +0,0 @@ -############################################################################### -# Copyright (c) 2003, 2006 IBM Corporation and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# IBM Corporation - initial API and implementation -# QNX Software Systems - Mikhail Khodjaiants - Bug 114664 -############################################################################### - -# Source search launch configuration tab/errors/dialogs -EditContainerAction_0=&Edit... -sourceTab_lookupLabel = S&ource Lookup Path: -sourceTab_searchDuplicateLabel = Searc&h for duplicate source files on the path -sourceTab_upButton = U&p -sourceTab_downButton = &Down -sourceTab_removeButton = Re&move -sourceTab_addButton = &Add... -sourceTab_tabTitle = Source -sourceTab_defaultButton = Restore Defa&ult - -addSourceLocation_title = Add Source -addSourceLocation_description = Select the type of source to add to the source lookup path - -addSourceLocation_addButton2 = &Edit Source Lookup Path... -addSourceLocation_editorMessage = Source not found. - -sourceSearch_folderSelectionError = Selection must be a folder. -sourceSearch_initError = Unable to initialize source container. - -projectSelection_chooseLabel = Choose &project(s) to add: -projectSelection_requiredLabel = Add &required projects of selected projects - -folderSelection_title=Folder Selection -folderSelection_label=&Choose folders to add: - -manageSourceDialog_title = Edit Source Lookup Path -manageSourceDialog_description = Edit the path used to locate source files. - -sourceLookupPanel_1 = Unable to apply source lookup path changes. -sourceLookupPanel_2 = Launch configuration does not support source lookup -ResolveDuplicatesHandler_0=Select Source File -ResolveDuplicatesHandler_1=Choose a source file (? = any character, * = any string) -EditSourceLookupPathAction_0=Edit Source Loo&kup... -LookupSourceAction_0=Lookup &Source -ExternalArchiveSourceContainerBrowser_2=Select Source Archive -ArchiveSourceContainerBrowser_3=Archive Selection -ArchiveSourceContainerBrowser_4=Choose archives to add: -DirectorySourceContainerDialog_0=Directory Selection -DirectorySourceContainerDialog_1=Choose directory to add: -DirectorySourceContainerDialog_2=File system folder -DirectorySourceContainerDialog_3=Specify folder and whether subfolders should be searched -DirectorySourceContainerDialog_4=&Directory: -DirectorySourceContainerDialog_5=&Browse... -DirectorySourceContainerDialog_6=Search sub&folders -DirectorySourceContainerDialog_7=Add File System Directory -DirectorySourceContainerDialog_8=Edit File System Directory -Prompter_0=Failed to get the root status handler. -CommonSourceNotFoundEditor_0=Select a Context -CommonSourceNotFoundEditor_1=You must select an item in the debug view to use as context for source lookup path changes.\n\nFor example: the launch or one of the threads in the view. -SourceLookupDialog_0=Launch configuration -SourceLookupDialog_1=\ is read only, no source lookup path changes will be saved diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIUtils.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIUtils.java deleted file mode 100644 index 4039d38e7..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/SourceLookupUIUtils.java +++ /dev/null @@ -1,111 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup; - -import java.util.Hashtable; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.IExtensionPoint; -import org.eclipse.core.runtime.Platform; -import org.eclipse.debug.internal.ui.DebugPluginImages; -import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.debug.ui.sourcelookup.ISourceContainerBrowser; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.ImageRegistry; -import org.eclipse.swt.graphics.Image; - -/** - * Utility methods for the UI portion of the source lookup solution. - * - * @since 3.0 - */ -public class SourceLookupUIUtils { - /** - * Constant for the container presentation extension id. - * @since 3.0 - */ - public static final String CONTAINER_PRESENTATION_EXTENSION = "sourceContainerPresentations"; //$NON-NLS-1$ - /** - * Constant for the container presentation icon attribute. - * @since 3.0 - */ - public static final String ICON_ATTRIBUTE = "icon"; //$NON-NLS-1$ - /** - * Constant for the container presentation browser attribute. - * @since 3.0 - */ - public static final String BROWSER_CLASS_ATTRIBUTE = "browserClass"; //$NON-NLS-1$ - /** - * Constant for the container presentation type id attribute. - * @since 3.0 - */ - public static final String CONTAINER_ID_ATTRIBUTE = "containerTypeID"; //$NON-NLS-1$ - - private static Hashtable fSourceContainerPresentationHashtable; - - /** - * Constructor. Reads in Source Container Presentation extension implementations. - */ - public SourceLookupUIUtils(){ - IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(DebugUIPlugin.getUniqueIdentifier(), CONTAINER_PRESENTATION_EXTENSION); - //read in SourceContainer presentation extensions - IConfigurationElement[] sourceContainerPresentationExtensions =extensionPoint.getConfigurationElements(); - fSourceContainerPresentationHashtable = new Hashtable(); - for (int i = 0; i < sourceContainerPresentationExtensions.length; i++) { - fSourceContainerPresentationHashtable.put( - sourceContainerPresentationExtensions[i].getAttribute(CONTAINER_ID_ATTRIBUTE), - sourceContainerPresentationExtensions[i]); - registerContainerImages(sourceContainerPresentationExtensions[i]); - } - } - - - /** - * Retrieves the icon associated with a source container type. - * @param id the container type id - * @return the image for the type specified - */ - public static Image getSourceContainerImage(String id){ - if(fSourceContainerPresentationHashtable == null) - new SourceLookupUIUtils(); - return DebugPluginImages.getImage(id); - } - - /** - * Retrieves the browser class associated with the source container type specified. - * @param typeID the source container type id - * @return the browser class - */ - public static ISourceContainerBrowser getSourceContainerBrowser(String typeID) - { - if(fSourceContainerPresentationHashtable == null) - new SourceLookupUIUtils(); - IConfigurationElement element = (IConfigurationElement)fSourceContainerPresentationHashtable.get(typeID); - ISourceContainerBrowser browser = null; - try{ - if(element!= null && element.getAttribute(BROWSER_CLASS_ATTRIBUTE) != null) - browser = (ISourceContainerBrowser) element.createExecutableExtension(BROWSER_CLASS_ATTRIBUTE); - }catch(CoreException e){} - return browser; - } - - private void registerContainerImages(IConfigurationElement configElement){ - ImageDescriptor imageDescriptor = DebugUIPlugin.getImageDescriptor(configElement, ICON_ATTRIBUTE); - if (imageDescriptor == null) { - imageDescriptor = ImageDescriptor.getMissingImageDescriptor(); - } - String configTypeID = configElement.getAttribute(CONTAINER_ID_ATTRIBUTE); - ImageRegistry imageRegistry = DebugPluginImages.getImageRegistry(); - imageRegistry.put(configTypeID, imageDescriptor); - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/UpAction.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/UpAction.java deleted file mode 100644 index 94110d3c6..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/UpAction.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.jface.viewers.IStructuredSelection; - -/** - * The action used to move source containers up in the list - */ -public class UpAction extends SourceContainerAction { - - public UpAction() { - super(SourceLookupUIMessages.sourceTab_upButton); - } - /** - * Moves all selected entries up one position (if possible). - * - * @see IAction#run() - */ - public void run() { - List targets = getOrderedSelection(); - if (targets.isEmpty()) { - return; - } - int top = 0; - int index = 0; - List list = getEntriesAsList(); - Iterator entries = targets.iterator(); - while (entries.hasNext()) { - Object target = entries.next(); - index = list.indexOf(target); - if (index > top) { - top = index - 1; - Object temp = list.get(top); - list.set(top, target); - list.set(index, temp); - } - top = index; - } - setEntries(list); - } - - /** - * @see SelectionListenerAction#updateSelection(IStructuredSelection) - */ - protected boolean updateSelection(IStructuredSelection selection) { - //check that something is selected, it's not first in the list, and it is a root tree node. - return !selection.isEmpty() && !isIndexSelected(selection, 0) && getViewer().getTree().getSelection()[0].getParentItem()==null; - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/WorkingSetSourceContainerType.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/WorkingSetSourceContainerType.java deleted file mode 100644 index 2356bd14e..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/WorkingSetSourceContainerType.java +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup; - -import java.io.IOException; -import java.io.StringReader; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.core.sourcelookup.ISourceContainer; -import org.eclipse.debug.core.sourcelookup.containers.AbstractSourceContainerTypeDelegate; -import org.eclipse.debug.ui.sourcelookup.WorkingSetSourceContainer; -import org.eclipse.ui.IWorkingSet; -import org.eclipse.ui.PlatformUI; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; - -/** - * The factory for creating/restoring working set source containers. - * - * @since 3.0 - */ -public class WorkingSetSourceContainerType extends AbstractSourceContainerTypeDelegate { - /* (non-Javadoc) - * @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainerTypeDelegate#getMemento(org.eclipse.debug.internal.core.sourcelookup.ISourceContainer) - */ - public String getMemento(ISourceContainer container) throws CoreException { - WorkingSetSourceContainer workingSet = (WorkingSetSourceContainer) container; - Document doc = newDocument(); - Element node = doc.createElement("workingSet"); //$NON-NLS-1$ - node.setAttribute("name", workingSet.getName()); //$NON-NLS-1$ - doc.appendChild(node); - return serializeDocument(doc); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainerType#createSourceContainer(java.lang.String) - */ - public ISourceContainer createSourceContainer(String memento)throws CoreException { - IWorkingSet workingSet = null; - Exception ex = null; - try { - Element root = null; - DocumentBuilder parser = - DocumentBuilderFactory.newInstance().newDocumentBuilder(); - parser.setErrorHandler(new DefaultHandler()); - StringReader reader = new StringReader(memento); - InputSource source = new InputSource(reader); - root = parser.parse(source).getDocumentElement(); - - String name = root.getAttribute("name");//$NON-NLS-1$ - - if (isEmpty(name)) { - abort(SourceLookupUIMessages.sourceSearch_initError,null); - } - workingSet = PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(name); - //check that set still exists - if (workingSet == null) { - abort(SourceLookupUIMessages.sourceSearch_initError, null); - } - return new WorkingSetSourceContainer(workingSet); - - } catch (ParserConfigurationException e) { - ex = e; - } catch (SAXException e) { - ex = e; - } catch (IOException e) { - ex = e; - } - - abort(SourceLookupUIMessages.sourceSearch_initError, ex); - return null; - } - - private boolean isEmpty(String string) { - return string == null || string.length() == 0; - } - - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ArchiveFilter.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ArchiveFilter.java deleted file mode 100644 index c5d55658c..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ArchiveFilter.java +++ /dev/null @@ -1,102 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup.browsers; - -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.swt.custom.BusyIndicator; - -/** - * ArchiveFilter - */ -public class ArchiveFilter extends ViewerFilter { - - /** - * Collection of archives and containers to display - */ - private Set fArchives; - - /** - * Collection of already existing archives - */ - private List fExisting; - - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) - */ - public boolean select(Viewer viewer, Object parentElement, Object element) { - return fArchives.contains(element) && !fExisting.contains(element); - } - - /** - * Constructs a new filter to display archives and their containers, - * excluding the resources in the given list. - * - * @param objects resources to exclude - */ - public ArchiveFilter(List objects) { - fExisting = objects; - init(); - } - - /** - * Search for all archives in the workspace. - */ - private void init() { - BusyIndicator.showWhile(DebugUIPlugin.getStandardDisplay(), new Runnable() { - public void run() { - fArchives = new HashSet(); - traverse(ResourcesPlugin.getWorkspace().getRoot(), fArchives); - } - }); - } - - /** - * Traverse the given container, adding archives to the given set. - * Returns whether any files were added - * - * @param root - */ - private boolean traverse(IContainer container, Set set) { - boolean added = false; - try { - IResource[] resources = container.members(); - for (int i = 0; i < resources.length; i++) { - IResource resource = resources[i]; - if (resource instanceof IFile) { - IFile file = (IFile)resource; - String ext = file.getFileExtension(); - if (ext != null && (ext.equalsIgnoreCase("jar") || ext.equalsIgnoreCase("zip"))) { //$NON-NLS-1$ //$NON-NLS-2$ - set.add(file); - added = true; - } - } else if (resource instanceof IContainer) { - if (traverse((IContainer)resource, set)) { - set.add(resource); - added = true; - } - } - } - } catch (CoreException e) { - } - return added; - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ArchiveSourceContainerBrowser.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ArchiveSourceContainerBrowser.java deleted file mode 100644 index 1b6ed903a..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ArchiveSourceContainerBrowser.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup.browsers; - - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.debug.core.sourcelookup.ISourceContainer; -import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; -import org.eclipse.debug.core.sourcelookup.containers.ArchiveSourceContainer; -import org.eclipse.debug.internal.core.IInternalDebugCoreConstants; -import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupUIMessages; -import org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; -import org.eclipse.ui.dialogs.ISelectionStatusValidator; -import org.eclipse.ui.model.WorkbenchContentProvider; -import org.eclipse.ui.model.WorkbenchLabelProvider; -import org.eclipse.ui.views.navigator.ResourceComparator; - -/** - * Adds an internal jar to the runtime class path. - */ -public class ArchiveSourceContainerBrowser extends AbstractSourceContainerBrowser { - - private ISelectionStatusValidator validator= new ISelectionStatusValidator() { - public IStatus validate(Object[] selection) { - if (selection.length == 0) { - return new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), 0, IInternalDebugCoreConstants.EMPTY_STRING, null); - } - for (int i= 0; i < selection.length; i++) { - if (!(selection[i] instanceof IFile)) { - return new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), 0, IInternalDebugCoreConstants.EMPTY_STRING, null); - } - } - return new Status(IStatus.OK, DebugUIPlugin.getUniqueIdentifier(), 0, IInternalDebugCoreConstants.EMPTY_STRING, null); - } - }; - - /** - * Returns internal jars (source containers) currently used by the - * given source lookup director. - * - * @param director source lookup director jars are being added to - */ - protected List getSelectedJars(ISourceLookupDirector director) { - ISourceContainer[] containers = director.getSourceContainers(); - List 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; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.sourcelookup.ISourceContainerBrowser#createSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.internal.core.sourcelookup.ISourceLookupDirector) - */ - public ISourceContainer[] addSourceContainers(Shell shell, ISourceLookupDirector director) { - ViewerFilter filter= new ArchiveFilter(getSelectedJars(director)); - - ILabelProvider lp= new WorkbenchLabelProvider(); - ITreeContentProvider cp= new WorkbenchContentProvider(); - - ElementTreeSelectionDialog dialog= new ElementTreeSelectionDialog(shell, lp, cp); - dialog.setValidator(validator); - dialog.setTitle(SourceLookupUIMessages.ArchiveSourceContainerBrowser_3); - dialog.setMessage(SourceLookupUIMessages.ArchiveSourceContainerBrowser_4); - dialog.addFilter(filter); - dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); - dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); - - if (dialog.open() == Window.OK) { - Object[] result = dialog.getResult(); - ISourceContainer[] containers = new ISourceContainer[result.length]; - for (int i = 0; i < containers.length; i++) { - containers[i] = new ArchiveSourceContainer((IFile)result[i], true); - } - return containers; - } - return new ISourceContainer[0]; - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/DirectorySourceContainerBrowser.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/DirectorySourceContainerBrowser.java deleted file mode 100644 index b3cbbbad8..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/DirectorySourceContainerBrowser.java +++ /dev/null @@ -1,69 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * QNX Software Systems - Mikhail Khodjaiants - Bug 114664 - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup.browsers; - -import org.eclipse.core.runtime.Path; -import org.eclipse.debug.core.sourcelookup.ISourceContainer; -import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; -import org.eclipse.debug.core.sourcelookup.containers.DirectorySourceContainer; -import org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.widgets.Shell; - -/** - * The browser for adding an external folder source container. - * @since 3.0 - */ -public class DirectorySourceContainerBrowser extends AbstractSourceContainerBrowser { - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.sourcelookup.ISourceContainerBrowser#createSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.ILaunchConfiguration) - */ - public ISourceContainer[] addSourceContainers(Shell shell, ISourceLookupDirector director) { - ISourceContainer[] containers = new ISourceContainer[1]; - DirectorySourceContainerDialog dialog = new DirectorySourceContainerDialog(shell); - if (dialog.open() == Window.OK) { - String directory = dialog.getDirectory(); - if(directory !=null) { - containers[0] = new DirectorySourceContainer(new Path(directory), dialog.isSearchSubfolders()); - return containers; - } - } - return new ISourceContainer[0]; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#canEditSourceContainers(org.eclipse.debug.core.sourcelookup.ISourceLookupDirector, org.eclipse.debug.core.sourcelookup.ISourceContainer[]) - */ - public boolean canEditSourceContainers(ISourceLookupDirector director, ISourceContainer[] containers) { - return containers.length == 1 && DirectorySourceContainer.TYPE_ID.equals(containers[0].getType().getId()); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#editSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.sourcelookup.ISourceLookupDirector, org.eclipse.debug.core.sourcelookup.ISourceContainer[]) - */ - 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; - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/DirectorySourceContainerDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/DirectorySourceContainerDialog.java deleted file mode 100644 index 942cb37e1..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/DirectorySourceContainerDialog.java +++ /dev/null @@ -1,230 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * QNX Software Systems - Mikhail Khodjaiants - Bug 114664 - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup.browsers; - -import java.io.File; - -import org.eclipse.debug.internal.core.IInternalDebugCoreConstants; -import org.eclipse.debug.internal.ui.DebugPluginImages; -import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.debug.internal.ui.IDebugHelpContextIds; -import org.eclipse.debug.internal.ui.IInternalDebugUIConstants; -import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupUIMessages; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.TitleAreaDialog; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.DirectoryDialog; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.PlatformUI; - -/** - * The dialog for selecting the external folder for which a source container will be created. - * - * @since 3.0 - */ -public class DirectorySourceContainerDialog extends TitleAreaDialog { - - private static final String LAST_PATH_SETTING = "EXT_FOLDER_LAST_PATH_SETTING"; //$NON-NLS-1$ - private static final String LAST_SUBDIR_SETTING = "EXT_FOLDER_LAST_SUBDIR_SETTING"; //$NON-NLS-1$ - - private String fDirectory; - private boolean fSearchSubfolders = true; - - private Text fDirText; - private Button fSubfoldersButton; - - private boolean fNewContainer = true; - - /** - * Creates a dialog to select a new file system folder. - * - * @param shell shell - */ - public DirectorySourceContainerDialog(Shell shell) { - this(shell, IInternalDebugCoreConstants.EMPTY_STRING, DebugUIPlugin.getDefault().getDialogSettings().getBoolean(LAST_SUBDIR_SETTING)); - fNewContainer = true; - } - - /** - * Creates a dialog to edit file system folder. - * - * @param shell shell - * @param directory directory to edit or empty string - * @param searchSubfolders whether the search sub-folders button should be checked - * @param newContainer - */ - public DirectorySourceContainerDialog(Shell shell, String directory, boolean searchSubfolders) { - super(shell); - setShellStyle(getShellStyle() | SWT.RESIZE ); - fDirectory = directory; - fSearchSubfolders = searchSubfolders; - fNewContainer = false; - } - - /** - * Returns the result of the dialog.open() operation - * @return the dialog.open() result - */ - public String getDirectory() { - return fDirectory; - } - - /** - * Returns whether the 'search subfolders' option is selected. - * - * @return whether the 'search subfolders' option is selected - */ - public boolean isSearchSubfolders() { - return fSearchSubfolders; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite) - */ - protected Control createDialogArea(Composite parent) { - Image image = (fNewContainer) ? DebugPluginImages.getImage(IInternalDebugUIConstants.IMG_ADD_SRC_DIR_WIZ) : - DebugPluginImages.getImage(IInternalDebugUIConstants.IMG_EDIT_SRC_DIR_WIZ); - setTitle(SourceLookupUIMessages.DirectorySourceContainerDialog_2); - setMessage(SourceLookupUIMessages.DirectorySourceContainerDialog_3); - setTitleImage(image); - Composite parentComposite = (Composite)super.createDialogArea(parent); - Font font = parentComposite.getFont(); - Composite composite = new Composite(parentComposite, SWT.NONE); - GridLayout layout = new GridLayout(); - layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); - layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); - layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); - layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); - composite.setLayout(layout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - composite.setFont(font); - - Composite dirComposite = new Composite(composite, SWT.NONE); - layout = new GridLayout(2, false); - dirComposite.setLayout(layout); - dirComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - dirComposite.setFont(font); - - Label label = new Label(dirComposite, SWT.NONE); - label.setText(SourceLookupUIMessages.DirectorySourceContainerDialog_4); - GridData data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 2; - label.setLayoutData(data); - label.setFont(font); - - fDirText = new Text(dirComposite, SWT.BORDER); - data = new GridData(GridData.FILL_HORIZONTAL); - data.horizontalSpan = 1; - fDirText.setLayoutData(data); - fDirText.setFont(font); - fDirText.addModifyListener(new ModifyListener() { - public void modifyText( ModifyEvent e ) { - validate(); - } - }); - - Button button = new Button(dirComposite, SWT.PUSH); - button.setText(SourceLookupUIMessages.DirectorySourceContainerDialog_5); - data = new GridData(); - int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); - Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); - data.widthHint = Math.max(widthHint, minSize.x); - button.setLayoutData(data); - button.setFont(JFaceResources.getDialogFont()); - button.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent event) { - browse(); - } - }); - - fSubfoldersButton = new Button(composite, SWT.CHECK); - fSubfoldersButton.setText(SourceLookupUIMessages.DirectorySourceContainerDialog_6); - - return parentComposite; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) - */ - protected void configureShell(Shell newShell) { - String title = null; - if (fNewContainer) { - title = SourceLookupUIMessages.DirectorySourceContainerDialog_7; - } else { - title = SourceLookupUIMessages.DirectorySourceContainerDialog_8; - } - newShell.setText(title); - super.configureShell( newShell ); - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.TitleAreaDialog#createContents(org.eclipse.swt.widgets.Composite) - */ - protected Control createContents(Composite parent) { - Control c = super.createContents(parent); - fDirText.setText(fDirectory); - fSubfoldersButton.setSelection(fSearchSubfolders); - validate(); - PlatformUI.getWorkbench().getHelpSystem().setHelp(c, IDebugHelpContextIds.SELECT_DIRECTORY_SOURCE_CONTAINER_DIALOG); - return c; - } - - /* (non-Javadoc) - * @see org.eclipse.jface.dialogs.Dialog#okPressed() - */ - protected void okPressed() { - fDirectory = fDirText.getText().trim(); - fSearchSubfolders = fSubfoldersButton.getSelection(); - DebugUIPlugin.getDefault().getDialogSettings().put(LAST_PATH_SETTING, fDirectory); - DebugUIPlugin.getDefault().getDialogSettings().put(LAST_SUBDIR_SETTING, fSearchSubfolders); - super.okPressed(); - } - - private void browse() { - String last = fDirText.getText().trim(); - if (last.length() == 0) { - last = DebugUIPlugin.getDefault().getDialogSettings().get(LAST_PATH_SETTING); - } - if (last == null) { - last = IInternalDebugCoreConstants.EMPTY_STRING; - } - DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.SINGLE); - dialog.setText(SourceLookupUIMessages.DirectorySourceContainerDialog_0); - dialog.setMessage(SourceLookupUIMessages.DirectorySourceContainerDialog_1); - dialog.setFilterPath(last); - String result = dialog.open(); - if (result == null) { - return; - } - fDirText.setText(result); - } - - private void validate() { - File file = new File(fDirText.getText().trim()); - getButton(IDialogConstants.OK_ID).setEnabled(file.isDirectory() && file.exists()); - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ExternalArchiveSourceContainerBrowser.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ExternalArchiveSourceContainerBrowser.java deleted file mode 100644 index a5e2f036c..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ExternalArchiveSourceContainerBrowser.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup.browsers; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.debug.core.sourcelookup.ISourceContainer; -import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; -import org.eclipse.debug.core.sourcelookup.containers.ExternalArchiveSourceContainer; -import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupUIMessages; -import org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.FileDialog; -import org.eclipse.swt.widgets.Shell; - -/** - * The browser for adding an external archive. - * @since 3.0 - */ -public class ExternalArchiveSourceContainerBrowser extends AbstractSourceContainerBrowser { - - private static final String ROOT_DIR = ExternalArchiveSourceContainerBrowser.class.getName() + ".rootDir"; //$NON-NLS-1$ - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.sourcelookup.ISourceContainerBrowser#createSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.ILaunchConfiguration) - */ - public ISourceContainer[] addSourceContainers(Shell shell, ISourceLookupDirector director) { - FileDialog dialog = new FileDialog(shell, SWT.OPEN | SWT.MULTI); - String rootDir = DebugUIPlugin.getDefault().getDialogSettings().get(ROOT_DIR); - dialog.setText(SourceLookupUIMessages.ExternalArchiveSourceContainerBrowser_2); - dialog.setFilterExtensions(new String[]{"*.jar;*.zip"}); //$NON-NLS-1$ - if (rootDir != null) { - dialog.setFilterPath(rootDir); - } - dialog.open(); - String[] fileNames= dialog.getFileNames(); - int nChosen= fileNames.length; - if (nChosen > 0) { - rootDir = dialog.getFilterPath(); - IPath filterPath= new Path(rootDir); - ISourceContainer[] containers= new ISourceContainer[nChosen]; - for (int i= 0; i < nChosen; i++) { - IPath path= filterPath.append(fileNames[i]).makeAbsolute(); - // TODO: configure auto-detect - containers[i]= new ExternalArchiveSourceContainer(path.toOSString(), true); - } - DebugUIPlugin.getDefault().getDialogSettings().put(ROOT_DIR, rootDir); - return containers; - } - return new ISourceContainer[0]; - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/FolderSourceContainerBrowser.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/FolderSourceContainerBrowser.java deleted file mode 100644 index d040e54e6..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/FolderSourceContainerBrowser.java +++ /dev/null @@ -1,83 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup.browsers; - -import java.util.ArrayList; - -import org.eclipse.core.resources.IFolder; -import org.eclipse.debug.core.sourcelookup.ISourceContainer; -import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; -import org.eclipse.debug.core.sourcelookup.containers.FolderSourceContainer; -import org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; -import org.eclipse.ui.model.WorkbenchContentProvider; -import org.eclipse.ui.model.WorkbenchLabelProvider; - -/** - * The browser for adding a folder source container. - * - * @since 3.0 - */ -public class FolderSourceContainerBrowser extends AbstractSourceContainerBrowser { - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.sourcelookup.ISourceContainerBrowser#createSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.ILaunchConfiguration) - */ - public ISourceContainer[] addSourceContainers(Shell shell, ISourceLookupDirector director) { - FolderSourceContainerDialog dialog = new FolderSourceContainerDialog(shell, new WorkbenchLabelProvider(), new WorkbenchContentProvider()); - - if (dialog.open() == Window.OK) { - Object[] selection= ((ElementTreeSelectionDialog)dialog).getResult(); - ArrayList containers = new ArrayList(); - for (int i= 0; i < selection.length; i++) { - if(selection[i] instanceof IFolder) { - containers.add(new FolderSourceContainer((IFolder)selection[i], dialog.isSearchSubfolders())); - } - } - return (ISourceContainer[])containers.toArray(new ISourceContainer[containers.size()]); - } - return new ISourceContainer[0]; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#canEditSourceContainers(org.eclipse.debug.core.sourcelookup.ISourceLookupDirector, org.eclipse.debug.core.sourcelookup.ISourceContainer[]) - */ - public boolean canEditSourceContainers(ISourceLookupDirector director, ISourceContainer[] containers) { - return containers.length == 1 && containers[0].getType().getId().equals(FolderSourceContainer.TYPE_ID); - } - - /* (non-Javadoc) - * @see org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser#editSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.sourcelookup.ISourceLookupDirector, org.eclipse.debug.core.sourcelookup.ISourceContainer[]) - */ - public ISourceContainer[] editSourceContainers(Shell shell, ISourceLookupDirector director, ISourceContainer[] containers) { - FolderSourceContainerDialog dialog = new FolderSourceContainerDialog(shell, new WorkbenchLabelProvider(), new WorkbenchContentProvider()); - FolderSourceContainer container = (FolderSourceContainer) containers[0]; - dialog.setSearchSubfolders(container.isComposite()); - dialog.setInitialSelection(container.getContainer()); - if (dialog.open() == Window.OK) { - container.dispose(); - Object[] selection= ((ElementTreeSelectionDialog)dialog).getResult(); - ArrayList list = new ArrayList(); - for (int i= 0; i < selection.length; i++) { - if(selection[i] instanceof IFolder) { - list.add(new FolderSourceContainer((IFolder)selection[i], dialog.isSearchSubfolders())); - } - } - return (ISourceContainer[])list.toArray(new ISourceContainer[list.size()]); - } - return new ISourceContainer[0]; - } - - - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/FolderSourceContainerDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/FolderSourceContainerDialog.java deleted file mode 100644 index a3e3864ea..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/FolderSourceContainerDialog.java +++ /dev/null @@ -1,146 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup.browsers; - -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.debug.internal.core.IInternalDebugCoreConstants; -import org.eclipse.debug.internal.ui.DebugUIPlugin; -import org.eclipse.debug.internal.ui.IDebugHelpContextIds; -import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupUIMessages; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.ElementTreeSelectionDialog; -import org.eclipse.ui.dialogs.ISelectionStatusValidator; -import org.eclipse.ui.views.navigator.ResourceComparator; - -/** - * The dialog for selecting the folder for which a source container will be created. - * - * @since 3.0 - */ -public class FolderSourceContainerDialog extends ElementTreeSelectionDialog { - - /** - * Constant to persist the state of the search subfolders button - * - * @since 3.2 - */ - private static final String LAST_SUBDIR_SETTING = "EXT_FOLDER_SOURCE_LAST_SUBDIR_SETTING"; //$NON-NLS-1$ - - /** - * Lets us control searching subfolders - * - * @since 3.2 - */ - private Button fSubfoldersButton; - - /** - * stored value whether to search subfolders or not - * - * @since 3.2 - */ - private boolean fSearchSubfolders = false; - - /** - * We need to add in the new control for indicating whether to search sub folders or not - * - * @since 3.2 - */ - protected Control createDialogArea(Composite parent) { - Composite parentc = (Composite)super.createDialogArea(parent); - fSubfoldersButton = new Button(parentc, SWT.CHECK); - fSubfoldersButton.setText(SourceLookupUIMessages.DirectorySourceContainerDialog_6); - fSubfoldersButton.setSelection(fSearchSubfolders); - return parentc; - } - - /** - * Sets the dialog values for its construction - * @param parent the parent of the dialog - * @param labelProvider the label provider for the content of the tree in the dialog - * @param contentProvider the provider of the tree content for the dialog - */ - public FolderSourceContainerDialog(Shell parent, ILabelProvider labelProvider, ITreeContentProvider contentProvider) { - super(parent, labelProvider, contentProvider); - setTitle(SourceLookupUIMessages.folderSelection_title); // - setInput(ResourcesPlugin.getWorkspace().getRoot()); - setComparator(new ResourceComparator(ResourceComparator.NAME)); - ISelectionStatusValidator validator= new ISelectionStatusValidator() { - public IStatus validate(Object[] selection) { - for (int i= 0; i < selection.length; i++) { - if (!(selection[i] instanceof IFolder)) { - return new Status(IStatus.ERROR, DebugUIPlugin.getUniqueIdentifier(), -1, SourceLookupUIMessages.sourceSearch_folderSelectionError, null); // - } - } - return new Status(IStatus.OK, DebugUIPlugin.getUniqueIdentifier(), 0, IInternalDebugCoreConstants.EMPTY_STRING, null); - } - }; - setValidator(validator); - setDoubleClickSelects(true); - setAllowMultiple(true); - setMessage(SourceLookupUIMessages.folderSelection_label); - PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, IDebugHelpContextIds.ADD_FOLDER_CONTAINER_DIALOG); - setSearchSubfolders(DebugUIPlugin.getDefault().getDialogSettings().getBoolean(LAST_SUBDIR_SETTING)); - addFilter(new ViewerFilter() { - public boolean select(Viewer viewer, Object parentElement, Object element) { - if(!(element instanceof IFolder)) { - if(element instanceof IProject) { - return ((IProject)element).isAccessible(); - } - return false; - } - return true; - } - }); - } - - /** - * Returns whether the 'search subfolders' option is selected. - * - * @since 3.2 - * @return true if the search subfolders button is selected, false otherwise. - */ - public boolean isSearchSubfolders() { - return fSearchSubfolders; - } - - /** - * Sets whether the 'search subfolders' option is selected. - * - * @param subfolders - * @since 3.2 - */ - public void setSearchSubfolders(boolean subfolders) { - fSearchSubfolders = subfolders; - } - - /* (non-Javadoc) - * @see org.eclipse.ui.dialogs.SelectionStatusDialog#okPressed() - */ - protected void okPressed() { - fSearchSubfolders = fSubfoldersButton.getSelection(); - DebugUIPlugin.getDefault().getDialogSettings().put(LAST_SUBDIR_SETTING, fSearchSubfolders); - super.okPressed(); - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ProjectSourceContainerBrowser.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ProjectSourceContainerBrowser.java deleted file mode 100644 index a5c0e8c43..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ProjectSourceContainerBrowser.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup.browsers; - -import java.util.ArrayList; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.debug.core.sourcelookup.ISourceContainer; -import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; -import org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer; -import org.eclipse.debug.internal.ui.sourcelookup.BasicContainerContentProvider; -import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupUIMessages; -import org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser; -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.dialogs.ListSelectionDialog; -import org.eclipse.ui.model.WorkbenchLabelProvider; - -/** - * The browser for creating project source containers. - * - * @since 3.0 - */ -public class ProjectSourceContainerBrowser extends AbstractSourceContainerBrowser { - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.sourcelookup.ISourceContainerBrowser#createSourceContainers(org.eclipse.swt.widgets.Shell,org.eclipse.debug.core.ILaunchConfiguration) - */ - public ISourceContainer[] addSourceContainers(Shell shell, ISourceLookupDirector director) { - Object input = ResourcesPlugin.getWorkspace().getRoot(); - IStructuredContentProvider contentProvider=new BasicContainerContentProvider(); - ILabelProvider labelProvider = new WorkbenchLabelProvider(); - Dialog dialog = new ProjectSourceContainerDialog(shell,input, contentProvider, labelProvider, - SourceLookupUIMessages.projectSelection_chooseLabel); - if(dialog.open() == Window.OK){ - Object[] elements= ((ListSelectionDialog)dialog).getResult(); - ArrayList res= new ArrayList(); - for (int i= 0; i < elements.length; i++) { - if(!(elements[i] instanceof IProject)) - continue; - res.add(new ProjectSourceContainer((IProject)elements[i], ((ProjectSourceContainerDialog)dialog).isAddRequiredProjects())); - } - return (ISourceContainer[])res.toArray(new ISourceContainer[res.size()]); - } - return new ISourceContainer[0]; - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ProjectSourceContainerDialog.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ProjectSourceContainerDialog.java deleted file mode 100644 index 3467f1bf8..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/ProjectSourceContainerDialog.java +++ /dev/null @@ -1,78 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup.browsers; -import org.eclipse.debug.internal.ui.IDebugHelpContextIds; -import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupUIMessages; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.ListSelectionDialog; - -/** - * The dialog for selecting the project for which a source container will be created. - * - * @since 3.0 - */ -public class ProjectSourceContainerDialog extends ListSelectionDialog { - - private boolean fAddRequiredProjects = false; - - public ProjectSourceContainerDialog( - Shell parentShell, - Object input, - IStructuredContentProvider contentProvider, - ILabelProvider labelProvider, - String message) { - super(parentShell, input, contentProvider, labelProvider, message); - } - - - /** - * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) - */ - protected Control createDialogArea(Composite parent) { - Font font = parent.getFont(); - - Composite composite = (Composite)super.createDialogArea(parent); - - final Button addRequired = new Button(composite, SWT.CHECK); - addRequired.setText(SourceLookupUIMessages.projectSelection_requiredLabel); - addRequired.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - fAddRequiredProjects = addRequired.getSelection(); - } - }); - addRequired.setSelection(fAddRequiredProjects); - addRequired.setFont(font); - - applyDialogFont(composite); - PlatformUI.getWorkbench().getHelpSystem().setHelp(getShell(), IDebugHelpContextIds.ADD_PROJECT_CONTAINER_DIALOG); - return composite; - } - - - /** - * Returns whether the user has selected to add required projects. - * - * @return whether the user has selected to add required projects - */ - public boolean isAddRequiredProjects() { - return fAddRequiredProjects; - } -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/WorkingSetSourceContainerBrowser.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/WorkingSetSourceContainerBrowser.java deleted file mode 100644 index ea7a9144a..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/WorkingSetSourceContainerBrowser.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup.browsers; - -import java.util.ArrayList; - -import org.eclipse.debug.core.sourcelookup.ISourceContainer; -import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; -import org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser; -import org.eclipse.debug.ui.sourcelookup.WorkingSetSourceContainer; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkingSet; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.IWorkingSetSelectionDialog; - -/** - * The browser for creating working set source containers. - * - * @since 3.0 - */ -public class WorkingSetSourceContainerBrowser extends AbstractSourceContainerBrowser { - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.sourcelookup.ISourceContainerBrowser#createSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.ILaunchConfiguration) - */ - public ISourceContainer[] addSourceContainers(Shell shell, ISourceLookupDirector director) { - ArrayList containers = new ArrayList(); - IWorkingSetSelectionDialog dialog = PlatformUI.getWorkbench().getWorkingSetManager().createWorkingSetSelectionDialog(shell,true); - - if(dialog.open() == Window.OK) - { - IWorkingSet[] selections = dialog.getSelection(); - if(selections != null) - { - for(int i=0; i<selections.length; i++) - { - containers.add(new WorkingSetSourceContainer(selections[i])); - } - } - } - - return (ISourceContainer[])containers.toArray(new ISourceContainer[containers.size()]); - } - -} diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/WorkspaceSourceContainerBrowser.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/WorkspaceSourceContainerBrowser.java deleted file mode 100644 index 63758920c..000000000 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/sourcelookup/browsers/WorkspaceSourceContainerBrowser.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.debug.internal.ui.sourcelookup.browsers; - -import org.eclipse.debug.core.sourcelookup.ISourceContainer; -import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector; -import org.eclipse.debug.core.sourcelookup.containers.WorkspaceSourceContainer; -import org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser; -import org.eclipse.swt.widgets.Shell; - -/** - * The browser for creating workspace source containers. - * - * @since 3.0 - */ -public class WorkspaceSourceContainerBrowser extends AbstractSourceContainerBrowser { - - /* (non-Javadoc) - * @see org.eclipse.debug.internal.ui.sourcelookup.ISourceContainerBrowser#createSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.ILaunchConfiguration) - */ - public ISourceContainer[] addSourceContainers(Shell shell, ISourceLookupDirector director) { - ISourceContainer[] containers = new ISourceContainer[1]; - - containers[0] = new WorkspaceSourceContainer(); - - return containers; - } - -} |