KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.util.ArrayList JavaDoc;
14 import org.eclipse.core.resources.IProject;
15 import org.eclipse.core.resources.ResourcesPlugin;
16 import org.eclipse.debug.core.sourcelookup.ISourceContainer;
17 import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
18 import org.eclipse.debug.core.sourcelookup.containers.ProjectSourceContainer;
19 import org.eclipse.debug.internal.ui.sourcelookup.BasicContainerContentProvider;
20 import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupUIMessages;
21 import org.eclipse.debug.ui.sourcelookup.AbstractSourceContainerBrowser;
22 import org.eclipse.jface.dialogs.Dialog;
23 import org.eclipse.jface.viewers.ILabelProvider;
24 import org.eclipse.jface.viewers.IStructuredContentProvider;
25 import org.eclipse.jface.window.Window;
26 import org.eclipse.swt.widgets.Shell;
27 import org.eclipse.ui.dialogs.ListSelectionDialog;
28 import org.eclipse.ui.model.WorkbenchLabelProvider;
29
30 /**
31  * The browser for creating project source containers.
32  *
33  * @since 3.0
34  */

35 public class ProjectSourceContainerBrowser extends AbstractSourceContainerBrowser {
36     
37     /* (non-Javadoc)
38      * @see org.eclipse.debug.internal.ui.sourcelookup.ISourceContainerBrowser#createSourceContainers(org.eclipse.swt.widgets.Shell,org.eclipse.debug.core.ILaunchConfiguration)
39      */

40     public ISourceContainer[] addSourceContainers(Shell shell, ISourceLookupDirector director) {
41         Object JavaDoc input = ResourcesPlugin.getWorkspace().getRoot();
42         IStructuredContentProvider contentProvider=new BasicContainerContentProvider();
43         ILabelProvider labelProvider = new WorkbenchLabelProvider();
44         Dialog dialog = new ProjectSourceContainerDialog(shell,input, contentProvider, labelProvider,
45                 SourceLookupUIMessages.projectSelection_chooseLabel);
46         if(dialog.open() == Window.OK){
47             Object JavaDoc[] elements= ((ListSelectionDialog)dialog).getResult();
48             ArrayList JavaDoc res= new ArrayList JavaDoc();
49             for (int i= 0; i < elements.length; i++) {
50                 if(!(elements[i] instanceof IProject))
51                     continue;
52                 res.add(new ProjectSourceContainer((IProject)elements[i], ((ProjectSourceContainerDialog)dialog).isAddRequiredProjects()));
53             }
54             return (ISourceContainer[])res.toArray(new ISourceContainer[res.size()]);
55         }
56         return new ISourceContainer[0];
57     }
58     
59 }
60
Popular Tags