Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2000, 2006 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at Contributors: IBM Corporation - initial API and implementation /
package org.eclipse.ant.internal.ui.views.actions;
import  org.eclipse.swt.widgets.Display;
This action opens a dialog to search for build files and adds the resulting projects to the ant view.
public class SearchForBuildFilesAction extends Action {
	private AntView view;

Opens the SearchForBuildFilesDialog and adds the results to the ant view.
	public void run() {
		if ( != .) {
			final IFile[] filesdialog.getResults();
			final boolean includeErrorNodesdialog.getIncludeErrorResults();
			final AntProjectNode[] existingProjects.getProjects();
			try {
					public void run(IProgressMonitor monitor) {
						for (int i = 0; i < files.length && !monitor.isCanceled(); i++) {
							String buildFileNamefiles[i].getFullPath().toString();
							monitor.subTask(MessageFormat.format(.new String[] {buildFileName}));
							if (alreadyAdded(buildFileName)) {
								// Don't parse projects that have already been added.
							final AntProjectNodeProxy projectnew AntProjectNodeProxy(buildFileName);
							// Force the project to be parsed so the error state is set.
							if (includeErrorNodes || !(project.isErrorNode())) {
								Display.getDefault().asyncExec(new Runnable() {
									public void run() {
Returns whether or not the given build file already exists in the ant view.
					private boolean alreadyAdded(String buildFileName) {
						for (int j = 0; j < existingProjects.lengthj++) {
							AntProjectNode existingProject = existingProjects[j];
							if (existingProject.getBuildFileName().equals(buildFileName)) {
								return true;
						return false;
catch (InvocationTargetException e) {
catch (InterruptedException e) {
New to GrepCode? Check out our FAQ X