KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > ui > sourcelookup > ClasspathVariableSourceContainerBrowser


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.jdt.internal.debug.ui.sourcelookup;
12
13 import org.eclipse.core.runtime.IPath;
14 import org.eclipse.debug.core.sourcelookup.ISourceContainer;
15 import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
16 import org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser;
17 import org.eclipse.jdt.launching.sourcelookup.containers.ClasspathVariableSourceContainer;
18 import org.eclipse.jdt.ui.wizards.BuildPathDialogAccess;
19 import org.eclipse.swt.widgets.Shell;
20
21 /**
22  * Used to choose a classpath variable.
23  *
24  * @since 3.0
25  */

26 public class ClasspathVariableSourceContainerBrowser extends AbstractSourceContainerBrowser {
27     /* (non-Javadoc)
28      * @see org.eclipse.debug.ui.sourcelookup.ISourceContainerBrowser#canEditSourceContainers(org.eclipse.debug.core.sourcelookup.ISourceLookupDirector, org.eclipse.debug.core.sourcelookup.ISourceContainer[])
29      */

30     public boolean canEditSourceContainers(ISourceLookupDirector director, ISourceContainer[] containers) {
31         return containers.length == 1;
32     }
33     /* (non-Javadoc)
34      * @see org.eclipse.debug.ui.sourcelookup.ISourceContainerBrowser#editSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.sourcelookup.ISourceLookupDirector, org.eclipse.debug.core.sourcelookup.ISourceContainer[])
35      */

36     public ISourceContainer[] editSourceContainers(Shell shell, ISourceLookupDirector director, ISourceContainer[] containers) {
37         ClasspathVariableSourceContainer container = (ClasspathVariableSourceContainer) containers[0];
38         IPath path = BuildPathDialogAccess.configureVariableEntry(shell, container.getPath(), new IPath[]{container.getPath()});
39         if (path != null) {
40             containers = new ISourceContainer[1];
41             containers[0] = new ClasspathVariableSourceContainer(path);
42             return containers;
43         }
44         return new ISourceContainer[0];
45     }
46     /* (non-Javadoc)
47      * @see org.eclipse.debug.internal.ui.sourcelookup.ISourceContainerBrowser#createSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.ILaunchConfiguration)
48      */

49     public ISourceContainer[] addSourceContainers(Shell shell, ISourceLookupDirector director) {
50         IPath[] paths = BuildPathDialogAccess.chooseVariableEntries(shell, new IPath[0]);
51         if (paths != null) {
52             ISourceContainer[] containers = new ISourceContainer[paths.length];
53             for (int i = 0; i < containers.length; i++) {
54                 containers[i] = new ClasspathVariableSourceContainer(paths[i]);
55             }
56             return containers;
57         }
58         return new ISourceContainer[0];
59     }
60 }
61
Popular Tags