Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: f5496640e9536158e431db653af182d038b48738 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*******************************************************************************
 * Copyright (c) 2003, 2004 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Common Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-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.ILaunchConfiguration;
import org.eclipse.debug.internal.core.sourcelookup.ISourceContainer;
import org.eclipse.debug.internal.core.sourcelookup.containers.FolderSourceContainer;
import org.eclipse.debug.internal.ui.sourcelookup.ISourceContainerBrowser;
import org.eclipse.jface.dialogs.Dialog;
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 implements ISourceContainerBrowser {
	
	/* (non-Javadoc)
	 * @see org.eclipse.debug.internal.ui.sourcelookup.ISourceContainerBrowser#createSourceContainers(org.eclipse.swt.widgets.Shell, org.eclipse.debug.core.ILaunchConfiguration)
	 */
	public ISourceContainer[] createSourceContainers(Shell shell, ILaunchConfiguration configuration) {
		Dialog 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))
					continue;			
				//TODO add boolean to dialog instead of hard coding
				containers.add(new FolderSourceContainer((IFolder)selection[i], true));				
			}
			return (ISourceContainer[])containers.toArray(new ISourceContainer[containers.size()]);	
		}			
		return new ISourceContainer[0];
	}
	
}

Back to the top