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 http://www.eclipse.org/legal/epl-v10.html Contributors: IBM Corporation - initial API and implementation /
 
 package org.eclipse.ant.internal.ui.preferences;
 
 
 import java.io.File;
 import java.net.URL;
 import java.util.List;
 
 import  org.eclipse.swt.SWT;
 import  org.eclipse.swt.graphics.Font;
 import  org.eclipse.swt.layout.GridData;
 import  org.eclipse.swt.layout.GridLayout;
 import  org.eclipse.swt.widgets.Button;
 import  org.eclipse.swt.widgets.Composite;
 import  org.eclipse.swt.widgets.TabFolder;
 import  org.eclipse.swt.widgets.TabItem;
Sub-page that allows the user to enter custom classpaths to be used when running Ant build files.
 
 public class AntClasspathPage implements IAntBlockContainer {
 
 	private ClasspathModel fModel;

Creates an instance.
 
 	public AntClasspathPage(AntRuntimePreferencePage preferencePage) {
 		 = preferencePage;
 	}

Returns the specified user classpath entries

Returns:
set of user classpath entries
 
 	}

Returns the specified ant home classpath entries
 
 	}

Returns the contributed classpath entries
 
 	}
 	
 	protected String getAntHome() {
 	}

Sets the contents of the tables on this page.
 
 	protected void initialize() {
 		
 		AntCorePreferences prefs= AntCorePlugin.getPlugin().getPreferences();
 		
 	}
 	
 	protected void createClasspathModel() {
 		AntCorePreferences prefs= AntCorePlugin.getPlugin().getPreferences();
	}
	protected void performDefaults() {
		AntCorePreferences prefs= AntCorePlugin.getPlugin().getPreferences();
		List additionalEntriesgetDefaultAdditionalEntries();
		if (additionalEntries != null) {
			.setGlobalEntries((IAntClasspathEntry[]) additionalEntries.toArray(new IAntClasspathEntry[additionalEntries.size()]));
else {
		}
	}
		IAntClasspathEntry toolsJarEntry= AntCorePlugin.getPlugin().getPreferences().getToolsJarEntry();
		//TODO should use AntCorePreferences.getUserLibraries when promoted to API post 3.1
		File libDirnew File(System.getProperty("user.home"), ".ant" + . + "lib"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
		URL[] urlsnull;
		try {
			urlsgetLocationURLs(libDir);
catch (MalformedURLException e) {
            AntUIPlugin.log(e);
            return new ArrayList(0);
		}
		List entriesnew ArrayList(urls.length);
		for (int i = 0; i < urls.lengthi++) {
			AntClasspathEntry entrynew AntClasspathEntry(urls[i]);
			entries.add(entry);
		}
		if (toolsJarEntry != null) {
			entries.add(toolsJarEntry);
		}
		return entries;
	}
	private URL[] getLocationURLs(File locationthrows MalformedURLException {
		 final String extension".jar"//$NON-NLS-1$
		 URL[] urls = new URL[0];
		 
		 if (!location.exists()) {
			 return urls;
		 }
		 
		 if (!location.isDirectory()) {
			 urls = new URL[1];
			 String path = location.getPath();
			 if (path.toLowerCase().endsWith(extension)) {
				 urls[0] = location.toURL();
			 }
			 return urls;
		 }
		 
		 File[] matches = location.listFiles(
			 new FilenameFilter() {
				 public boolean accept(File dirString name) {
					return name.toLowerCase().endsWith(extension);
				 }
			 });
		 
		 urls = new URL[matches.length];
		 for (int i = 0; i < matches.length; ++i) {
			 urls[i] = matches[i].toURL();
		 }
		 return urls;
	 }

Creates the tab item that contains this sub-page.
	protected TabItem createTabItem(TabFolder folder) {
		TabItem item = new TabItem(folder, SWT.NONE);
		item.setData(this);
		item.setControl(createContents(folder));
		return item;
	}

Creates this page's controls
	protected Composite createContents(Composite parent) {
		Font font = parent.getFont();
		Composite top = new Composite(parent, SWT.NONE);
		top.setFont(font);
		GridLayout layout = new GridLayout();
		layout.numColumns = 2;
		layout.marginHeight = 2;
		layout.marginWidth = 2;
		top.setLayout(layout);
		top.setLayoutData(new GridData(GridData.FILL_BOTH));
		return top;
	}
	/* (non-Javadoc)
	 * @see org.eclipse.ant.internal.ui.preferences.IAntBlockContainer#update()
	 */
	public void update() {
			return;
		}
		if (valid) {
		}
	}
	/* (non-Javadoc)
	 * @see org.eclipse.ant.internal.ui.preferences.IAntBlockContainer#setMessage(java.lang.String)
	 */
	public void setMessage(String message) {
	}
	/* (non-Javadoc)
	 * @see org.eclipse.ant.internal.ui.preferences.IAntBlockContainer#setErrorMessage(java.lang.String)
	 */
	public void setErrorMessage(String message) {
	}
	/* (non-Javadoc)
	 * @see org.eclipse.ant.internal.ui.preferences.IAntBlockContainer#createPushButton(org.eclipse.swt.widgets.Composite, java.lang.String)
	 */
	public Button createPushButton(Composite parentString buttonText) {
		Button button = new Button(parent, SWT.PUSH);
		button.setFont(parent.getFont());
		button.setText(buttonText);
		return button;
	}
New to GrepCode? Check out our FAQ X