1 /*******************************************************************************2 * Copyright (c) 2000, 2005 IBM Corporation and others.3 * All rights reserved. This program and the accompanying materials4 * are made available under the terms of the Eclipse Public License v1.05 * which accompanies this distribution, and is available at6 * http://www.eclipse.org/legal/epl-v10.html7 * 8 * Contributors:9 * IBM Corporation - initial API and implementation10 *******************************************************************************/11 package org.eclipse.debug.internal.ui.sourcelookup;12 13 import java.io.File ;14 15 import org.eclipse.core.runtime.IPath;16 import org.eclipse.core.runtime.Path;17 import org.eclipse.debug.core.sourcelookup.containers.ArchiveSourceContainer;18 import org.eclipse.debug.core.sourcelookup.containers.DirectorySourceContainer;19 import org.eclipse.debug.core.sourcelookup.containers.ExternalArchiveSourceContainer;20 import org.eclipse.debug.core.sourcelookup.containers.FolderSourceContainer;21 import org.eclipse.jface.resource.ImageDescriptor;22 import org.eclipse.ui.model.IWorkbenchAdapter;23 24 /**25 * Workbench adapter for standard source containers.26 * 27 * @since 3.028 */29 public class SourceContainerWorkbenchAdapter implements IWorkbenchAdapter {30 /* (non-Javadoc)31 * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)32 */33 public Object [] getChildren(Object o) {34 return null;35 }36 /* (non-Javadoc)37 * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)38 */39 public ImageDescriptor getImageDescriptor(Object object) {40 return null;41 }42 /* (non-Javadoc)43 * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)44 */45 public String getLabel(Object o) {46 if (o instanceof DirectorySourceContainer) {47 DirectorySourceContainer container = (DirectorySourceContainer) o;48 File file = container.getDirectory();49 IPath path = new Path(file.getAbsolutePath());50 return SourceElementWorkbenchAdapter.getQualifiedName(path);51 }52 if (o instanceof FolderSourceContainer) {53 FolderSourceContainer container = (FolderSourceContainer) o;54 return SourceElementWorkbenchAdapter.getQualifiedName(container.getContainer().getFullPath());55 }56 if (o instanceof ArchiveSourceContainer) {57 ArchiveSourceContainer container = (ArchiveSourceContainer)o;58 return SourceElementWorkbenchAdapter.getQualifiedName(container.getFile().getFullPath());59 } 60 if (o instanceof ExternalArchiveSourceContainer) {61 ExternalArchiveSourceContainer container = (ExternalArchiveSourceContainer)o;62 IPath path = new Path(container.getName());63 return SourceElementWorkbenchAdapter.getQualifiedName(path);64 } 65 return ""; //$NON-NLS-1$66 }67 /* (non-Javadoc)68 * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)69 */70 public Object getParent(Object o) {71 return null;72 }73 }74