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.launchConfigurations;
 
 import java.io.File;
 import java.net.URL;
 import java.util.List;
 
A classpath entry that contains a contributed classpath entries via the extraClasspathEntries extension point.

Since:
3.0
 
 	
 	public static final String TYPE_ID = "org.eclipse.ant.ui.classpathentry.extraClasspathEntries"//$NON-NLS-1$
     
     public static List fgSWTEntriesnull;

Default contructor required to instantiate persisted extensions.
 
 	}
 	
 	/* (non-Javadoc)
 	 * @see org.eclipse.jdt.internal.launching.AbstractRuntimeClasspathEntry#buildMemento(org.w3c.dom.Document, org.w3c.dom.Element)
 	 */
 	protected void buildMemento(Document documentElement mementothrows CoreException {
 	}
 	
 	/* (non-Javadoc)
 	 * @see org.eclipse.jdt.internal.launching.IRuntimeClasspathEntry2#initializeFrom(org.w3c.dom.Element)
 	 */
 	public void initializeFrom(Element mementothrows CoreException {
 	}
 	
 	/* (non-Javadoc)
 	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getTypeId()
 	 */
 	public String getTypeId() {
 		return ;
 	}
 	
 	/* (non-Javadoc)
 	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getRuntimeClasspathEntries(org.eclipse.debug.core.ILaunchConfiguration)
 	 */
 		boolean separateVM= AntUtil.isSeparateJREAntBuild(configuration);
 		boolean setInputHandlerconfiguration.getAttribute(.true);
 		AntCorePreferences prefs= AntCorePlugin.getPlugin().getPreferences();
 		IAntClasspathEntry[] antClasspathEntries = prefs.getContributedClasspathEntries();
 		List rtes = new ArrayList(antClasspathEntries.length + userEntries.length);
 		for (int i = 0; i < antClasspathEntries.lengthi++) {
 			 entryantClasspathEntries[i];
 			if (!separateVM || (separateVM && !entry.isEclipseRuntimeRequired())) {
 				rtes.add(JavaRuntime.newStringVariableClasspathEntry(entry.getLabel()));
 			}
 		}
 		boolean haveToolsEntryfalse;
 		String path;
 		for (int i = 0; i < userEntries.lengthi++) {
 			entry = userEntries[i];
			pathentry.getLabel();
            IPath toolsPathnew Path(path);
			if (toolsPath.lastSegment().equals("tools.jar")) { //$NON-NLS-1$
				haveToolsEntrytrue;
				// replace with dynamically resolved tools.jar based on
				// the JRE being used
				addToolsJar(configurationrtespath);
else {
				rtes.add(JavaRuntime.newStringVariableClasspathEntry(path));
			}
		}
		if (!haveToolsEntry) {
			addToolsJar(configurationrtesnull);
		}
		if (setInputHandler && separateVM) {
		}
	}
	private void addToolsJar(ILaunchConfiguration configurationList rtesString path) {
		IRuntimeClasspathEntry tools = getToolsJar(configuration);
		if (tools == null) {
			if (path != null) {
				//use the global entry
				rtes.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(path)));
else {
				//use the default vm install to try to find a tools.jar
				IVMInstall install= JavaRuntime.getDefaultVMInstall();
				if (install != null) {
					if (entry != null) {
						rtes.add(JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(entry.getEntryURL().getPath())));
					}
				}
			}
else {
			rtes.add(tools);
		}
	}
	private void addSWTJars(List rtes) {
        if ( == null) {
            new ArrayList();
            Bundle bundle= Platform.getBundle("org.eclipse.swt"); //$NON-NLS-1$
            BundleDescription description= Platform.getPlatformAdmin().getState(false).getBundle(bundle.getBundleId());
            BundleDescription[] fragmentsdescription.getFragments();
            for (int i = 0; i < fragments.lengthi++) {
                Bundle fragmentBundle= Platform.getBundle(fragments[i].getName());
                URL bundleURL;
                try {
                    bundleURL = FileLocator.resolve(fragmentBundle.getEntry("/")); //$NON-NLS-1$
                } catch (IOException e) {
                    AntUIPlugin.log(e);
                   continue;
                }
                String urlFileNamebundleURL.getFile();
                if (urlFileName.startsWith("file:")) { //$NON-NLS-1$
                    try {
                        urlFileNamenew URL(urlFileName).getFile();
                        if (urlFileName.endsWith("!/")) { //$NON-NLS-1$
                            urlFileNameurlFileName.substring(0, urlFileName.length() - 2);
                        }
                    } catch (MalformedURLException e) {
                        AntUIPlugin.log(e);
                       continue;
                    }
                }
                IPath fragmentPathnew Path(urlFileName);
                if (fragmentPath.getFileExtension() != null) { //JAR file
                    .add(JavaRuntime.newArchiveRuntimeClasspathEntry(fragmentPath));
                } else { // folder
                    File bundleFolderfragmentPath.toFile();
                    if (!bundleFolder.isDirectory()) {
                        continue;
                    }
                    String[] namesbundleFolder.list(new FilenameFilter() {
                        public boolean accept(File dirString name) {
                            return name.endsWith(".jar"); //$NON-NLS-1$
                        }
                    });
                    for (int j = 0; j < names.lengthj++) {
                        String jarName = names[j];
                        .add(JavaRuntime.newArchiveRuntimeClasspathEntry(fragmentPath.append(jarName)));
                    }
                }
            }
        }
        rtes.addAll();
	}
    
Returns the tools.jar to use for this launch configuration, or null if none.

Parameters:
configuration configuration to resolve a tools.jar for
Returns:
associated tools.jar archive, or null
		try {
			IVMInstall install = JavaRuntime.computeVMInstall(configuration);
			if (install != null) {
				if (entry != null) {
					return JavaRuntime.newArchiveRuntimeClasspathEntry(new Path(entry.getEntryURL().getPath()));
				}
			}
catch (CoreException ce) {
			//likely dealing with a non-Java project
		}
		return null;
	}
	/* (non-Javadoc)
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#getName()
	 */
	public String getName() {
	}
	/* (non-Javadoc)
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry#getType()
	 */
	public int getType() {
	}
	/* (non-Javadoc)
	 * @see org.eclipse.jdt.launching.IRuntimeClasspathEntry2#isComposite()
	 */
	public boolean isComposite() {
		return true;
	}
	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	public boolean equals(Object obj) {
		return obj instanceof ContributedClasspathEntriesEntry;
	}
	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	public int hashCode() {
		return getClass().hashCode();
	}
New to GrepCode? Check out our FAQ X