KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > ui > sourcelookup > browsers > ExternalArchiveSourceContainerBrowser


1 /*******************************************************************************
2  * Copyright (c) 2003, 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.debug.internal.ui.sourcelookup.browsers;
12
13 import org.eclipse.core.runtime.IPath;
14 import org.eclipse.core.runtime.Path;
15 import org.eclipse.debug.core.sourcelookup.ISourceContainer;
16 import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
17 import org.eclipse.debug.core.sourcelookup.containers.ExternalArchiveSourceContainer;
18 import org.eclipse.debug.internal.ui.DebugUIPlugin;
19 import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupUIMessages;
20 import org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser;
21 import org.eclipse.swt.SWT;
22 import org.eclipse.swt.widgets.FileDialog;
23 import org.eclipse.swt.widgets.Shell;
24
25 /**
26  * The browser for adding an external archive.
27  * @since 3.0
28  */

29 public class ExternalArchiveSourceContainerBrowser extends AbstractSourceContainerBrowser {
30     
31     private static final String JavaDoc ROOT_DIR = ExternalArchiveSourceContainerBrowser.class.getName() + ".rootDir"; //$NON-NLS-1$
32

33     /* (non-Javadoc)
34      * @see org.eclipse.debug.internal.ui.sourcelookup.ISourceContainerBrowser#createSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.ILaunchConfiguration)
35      */

36     public ISourceContainer[] addSourceContainers(Shell shell, ISourceLookupDirector director) {
37         FileDialog dialog = new FileDialog(shell, SWT.OPEN | SWT.MULTI);
38         String JavaDoc rootDir = DebugUIPlugin.getDefault().getDialogSettings().get(ROOT_DIR);
39         dialog.setText(SourceLookupUIMessages.ExternalArchiveSourceContainerBrowser_2);
40         dialog.setFilterExtensions(new String JavaDoc[]{"*.jar;*.zip"}); //$NON-NLS-1$
41
if (rootDir != null) {
42             dialog.setFilterPath(rootDir);
43         }
44         dialog.open();
45         String JavaDoc[] fileNames= dialog.getFileNames();
46         int nChosen= fileNames.length;
47         if (nChosen > 0) {
48             rootDir = dialog.getFilterPath();
49             IPath filterPath= new Path(rootDir);
50             ISourceContainer[] containers= new ISourceContainer[nChosen];
51             for (int i= 0; i < nChosen; i++) {
52                 IPath path= filterPath.append(fileNames[i]).makeAbsolute();
53                 // TODO: configure auto-detect
54
containers[i]= new ExternalArchiveSourceContainer(path.toOSString(), true);
55             }
56             DebugUIPlugin.getDefault().getDialogSettings().put(ROOT_DIR, rootDir);
57             return containers;
58         }
59         return new ISourceContainer[0];
60     }
61     
62 }
63
Popular Tags