diff options
Diffstat (limited to 'plugins/org.eclipse.jst.common.frameworks/src/org/eclipse')
26 files changed, 0 insertions, 3283 deletions
diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/frameworks/CommonFrameworksPlugin.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/frameworks/CommonFrameworksPlugin.java deleted file mode 100644 index 30c8da29e..000000000 --- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/frameworks/CommonFrameworksPlugin.java +++ /dev/null @@ -1,57 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005 BEA Systems, Inc. - * 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: - * Konstantin Komissarchik - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.common.frameworks; - -import org.eclipse.core.runtime.ILog; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.wst.common.frameworks.internal.WTPPlugin; - -public final class CommonFrameworksPlugin - - extends WTPPlugin - -{ - public static final String PLUGIN_ID = "org.eclipse.jst.common.frameworks"; //$NON-NLS-1$ - public static final String DEFAULT_SOURCE_FOLDER = "defaultSource"; //$NON-NLS-1$ - public static final String OUTPUT_FOLDER = "outputFolder"; //$NON-NLS-1$ - - private static CommonFrameworksPlugin inst; - - /** - * Get the plugin singleton. - */ - - public static CommonFrameworksPlugin getDefault() - { - return inst; - } - - public CommonFrameworksPlugin() { - super(); - if (inst == null) - inst = this; - } - public String getPluginID() - { - return PLUGIN_ID; - } - - public static void log( final Exception e ) - { - final ILog log = CommonFrameworksPlugin.getDefault().getLog(); - final String msg = "Encountered an unexpected exception."; //$NON-NLS-1$ - - log.log( new Status( IStatus.ERROR, PLUGIN_ID, IStatus.OK, msg, e ) ); - } - -} diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/frameworks/CommonFrameworksPreferenceInitializer.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/frameworks/CommonFrameworksPreferenceInitializer.java deleted file mode 100644 index 9aaf3adb2..000000000 --- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/frameworks/CommonFrameworksPreferenceInitializer.java +++ /dev/null @@ -1,71 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2005, 2007 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.jst.common.frameworks; - -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; -import org.eclipse.core.runtime.preferences.DefaultScope; -import org.eclipse.core.runtime.preferences.IEclipsePreferences; - -public class CommonFrameworksPreferenceInitializer extends - AbstractPreferenceInitializer { - - private static final String DEFAULT_SOURCE_FOLDER_VALUE = "src"; //$NON-NLS-1$ - private static final String DEFAULT_OUTPUT_FOLDER_VALUE = "build/classes"; //$NON-NLS-1$ - - public CommonFrameworksPreferenceInitializer() { - // TODO Auto-generated constructor stub - } - - public void initializeDefaultPreferences() { - IEclipsePreferences node = new DefaultScope().getNode(CommonFrameworksPlugin.getDefault().getBundle().getSymbolicName()); - - node.put(CommonFrameworksPlugin.DEFAULT_SOURCE_FOLDER, getDefaultSourceFolder()); - node.put(CommonFrameworksPlugin.OUTPUT_FOLDER, getDefaultOutputFolder()); - } - - private static String getDefaultSourceFolder() - { - String res = getProductProperty( CommonFrameworksPlugin.DEFAULT_SOURCE_FOLDER ); - - if( res == null ) - { - res = DEFAULT_SOURCE_FOLDER_VALUE; - } - - return res; - } - - private static String getDefaultOutputFolder() - { - String res = getProductProperty( CommonFrameworksPlugin.OUTPUT_FOLDER ); - - if( res == null ) - { - res = DEFAULT_OUTPUT_FOLDER_VALUE; - } - - return res; - } - - private static String getProductProperty( final String propName ) - { - String value = null; - - if( Platform.getProduct() != null ) - { - value = Platform.getProduct().getProperty( propName ); - } - - return value; - } - -} diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/ClasspathDecorations.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/ClasspathDecorations.java deleted file mode 100644 index 4e4cb5f5d..000000000 --- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/ClasspathDecorations.java +++ /dev/null @@ -1,75 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005 BEA Systems, Inc. - * 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: - * Konstantin Komissarchik - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.common.jdt.internal.classpath; - -import java.util.ArrayList; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.jdt.core.IClasspathAttribute; -import org.eclipse.jdt.core.JavaCore; - -/** - * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a> - */ - -public final class ClasspathDecorations -{ - private IPath sourceAttachmentPath; - private IPath sourceAttachmentRootPath; - private ArrayList extraAttributes = new ArrayList(); - - public IPath getSourceAttachmentPath() - { - return this.sourceAttachmentPath; - } - - public void setSourceAttachmentPath( final IPath sourceAttachmentPath ) - { - this.sourceAttachmentPath = sourceAttachmentPath; - } - - public IPath getSourceAttachmentRootPath() - { - return this.sourceAttachmentRootPath; - } - - public void setSourceAttachmentRootPath( final IPath sourceAttachmentRootPath ) - { - this.sourceAttachmentRootPath = sourceAttachmentRootPath; - } - - public IClasspathAttribute[] getExtraAttributes() - { - final IClasspathAttribute[] array - = new IClasspathAttribute[ this.extraAttributes.size() ]; - - return (IClasspathAttribute[]) this.extraAttributes.toArray( array ); - } - - public void setExtraAttributes( final IClasspathAttribute[] attrs ) - { - for( int i = 0; i < attrs.length; i++ ) - { - this.extraAttributes.add( attrs[ i ] ); - } - } - - public void addExtraAttribute( final String name, - final String value ) - { - final IClasspathAttribute attr - = JavaCore.newClasspathAttribute( name, value ); - - this.extraAttributes.add( attr ); - } - -} diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/ClasspathDecorationsManager.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/ClasspathDecorationsManager.java deleted file mode 100644 index c66358a53..000000000 --- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/ClasspathDecorationsManager.java +++ /dev/null @@ -1,371 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005 BEA Systems, Inc. - * 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: - * Konstantin Komissarchik - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.common.jdt.internal.classpath; - -import java.io.BufferedInputStream; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.PrintWriter; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.NoSuchElementException; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.IClasspathAttribute; -import org.eclipse.jst.common.frameworks.CommonFrameworksPlugin; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -/** - * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a> - */ - -public final class ClasspathDecorationsManager -{ - private final File f; - private final HashMap decorations; - - public ClasspathDecorationsManager( final String plugin ) - { - final IWorkspace ws = ResourcesPlugin.getWorkspace(); - final File wsdir = ws.getRoot().getLocation().toFile(); - final File wsmdroot = new File( wsdir, ".metadata/.plugins" ); //$NON-NLS-1$ - final File pmdroot = new File( wsmdroot, plugin ); - - this.f = new File( pmdroot, "classpath.decorations.xml" ); //$NON-NLS-1$ - this.decorations = read(); - } - - public ClasspathDecorations getDecorations( final String key, - final String entry ) - { - final HashMap submap = (HashMap) this.decorations.get( key ); - - if( submap == null ) - { - return null; - } - - return (ClasspathDecorations) submap.get( entry ); - } - - public void setDecorations( final String key, - final String entry, - final ClasspathDecorations dec ) - { - HashMap submap = (HashMap) this.decorations.get( key ); - - if( submap == null ) - { - submap = new HashMap(); - this.decorations.put( key, submap ); - } - - submap.put( entry, dec ); - } - - public void clearAllDecorations( final String key ) - { - this.decorations.remove( key ); - } - - public void save() - { - final File folder = this.f.getParentFile(); - - if( ! folder.exists() && ! folder.mkdirs() ) - { - return; - } - - PrintWriter w = null; - - try - { - w = new PrintWriter( new BufferedWriter( new FileWriter( this.f ) ) ); - - w.println( "<classpath>" ); //$NON-NLS-1$ - - for( Iterator itr1 = decorations.entrySet().iterator(); - itr1.hasNext(); ) - { - final Map.Entry entry1 = (Map.Entry) itr1.next(); - final Map submap = (Map) entry1.getValue(); - - w.print( " <container id=\"" ); //$NON-NLS-1$ - w.print( (String) entry1.getKey() ); - w.println( "\">" ); //$NON-NLS-1$ - - for( Iterator itr2 = submap.entrySet().iterator(); - itr2.hasNext(); ) - { - final Map.Entry entry2 = (Map.Entry) itr2.next(); - - final ClasspathDecorations dec - = (ClasspathDecorations) entry2.getValue(); - - w.print( " <entry id=\"" ); //$NON-NLS-1$ - w.print( (String) entry2.getKey() ); - w.println( "\">" ); //$NON-NLS-1$ - - if( dec.getSourceAttachmentPath() != null ) - { - w.print( " <source-attachment-path>" ); //$NON-NLS-1$ - w.print( dec.getSourceAttachmentPath().toString() ); - w.println( "</source-attachment-path>" ); //$NON-NLS-1$ - } - - if( dec.getSourceAttachmentRootPath() != null ) - { - w.print( " <source-attachment-root-path>" ); //$NON-NLS-1$ - w.print( dec.getSourceAttachmentRootPath().toString() ); - w.println( "</source-attachment-root-path>" ); //$NON-NLS-1$ - } - - final IClasspathAttribute[] attrs - = dec.getExtraAttributes(); - - for( int i = 0; i < attrs.length; i++ ) - { - final IClasspathAttribute attr = attrs[ i ]; - - w.print( " <attribute name=\"" ); //$NON-NLS-1$ - w.print( attr.getName() ); - w.print( "\">" ); //$NON-NLS-1$ - w.print( attr.getValue() ); - w.println( "</attribute>" ); //$NON-NLS-1$ - } - - w.println( " </entry>" ); //$NON-NLS-1$ - } - - w.println( " </container>" ); //$NON-NLS-1$ - } - - w.println( "</classpath>" ); //$NON-NLS-1$ - } - catch( IOException e ) - { - CommonFrameworksPlugin.log( e ); - } - finally - { - w.close(); - } - } - - private HashMap read() - { - final HashMap map = new HashMap(); - if( ! this.f.exists() ) return map; - - InputStream in = null; - Element root = null; - - try - { - final DocumentBuilderFactory factory - = DocumentBuilderFactory.newInstance(); - - final DocumentBuilder docbuilder = factory.newDocumentBuilder(); - - in = new BufferedInputStream( new FileInputStream( f ) ); - root = docbuilder.parse( in ).getDocumentElement(); - } - catch( Exception e ) - { - CommonFrameworksPlugin.log( e ); - return map; - } - finally - { - if( in != null ) - { - try - { - in.close(); - } - catch( IOException e ) {} - } - } - - for( Iterator itr1 = elements( root, "container" ); itr1.hasNext(); ) //$NON-NLS-1$ - { - final Element e1 = (Element) itr1.next(); - final String cid = e1.getAttribute( "id" ); //$NON-NLS-1$ - - final HashMap submap = new HashMap(); - map.put( cid, submap ); - - for( Iterator itr2 = elements( e1, "entry" ); itr2.hasNext(); ) //$NON-NLS-1$ - { - final Element e2 = (Element) itr2.next(); - final String eid = e2.getAttribute( "id" ); //$NON-NLS-1$ - final ClasspathDecorations dec = new ClasspathDecorations(); - - submap.put( eid, dec ); - - for( Iterator itr3 = elements( e2 ); itr3.hasNext(); ) - { - final Element e3 = (Element) itr3.next(); - final String n = e3.getNodeName(); - - if( n.equals( "source-attachment-path" ) ) //$NON-NLS-1$ - { - dec.setSourceAttachmentPath( new Path( text( e3 ) ) ); - } - else if( n.equals( "source-attachment-root-path" ) ) //$NON-NLS-1$ - { - dec.setSourceAttachmentRootPath( new Path( text( e3 ) ) ); - } - else if( n.equals( "attribute" ) ) //$NON-NLS-1$ - { - final String name = e3.getAttribute( "name" ); //$NON-NLS-1$ - dec.addExtraAttribute( name, text( e3 ) ); - } - } - } - } - - return map; - } - - private static String text( final Element el ) - { - final NodeList nodes = el.getChildNodes(); - - String str = null; - StringBuffer buf = null; - - for( int i = 0, n = nodes.getLength(); i < n; i++ ) - { - final Node node = nodes.item( i ); - - if( node.getNodeType() == Node.TEXT_NODE ) - { - final String val = node.getNodeValue(); - - if( buf != null ) - { - buf.append( val ); - } - else if( str != null ) - { - buf = new StringBuffer(); - buf.append( str ); - buf.append( val ); - - str = null; - } - else - { - str = val; - } - } - } - - if( buf != null ) - { - return buf.toString(); - } - return str; - } - - private static Iterator elements( final Element el, - final String name ) - { - return new ElementsIterator( el, name ); - } - - private static Iterator elements( final Element el ) - { - return new ElementsIterator( el, null ); - } - - private static final class ElementsIterator - - implements Iterator - - { - private final NodeList nodes; - private final int length; - private final String name; - private int position; - private Element element; - - public ElementsIterator( final Element parent, - final String name ) - { - this.nodes = parent.getChildNodes(); - this.length = nodes.getLength(); - this.position = -1; - this.name = name; - - advance(); - } - - private void advance() - { - this.element = null; - this.position++; - - for( ; this.position < this.length && this.element == null; - this.position++ ) - { - final Node node = this.nodes.item( this.position ); - - if( node.getNodeType() == Node.ELEMENT_NODE && - ( this.name == null || - node.getNodeName().equals( this.name ) ) ) - { - this.element = (Element) node; - } - } - } - - public boolean hasNext() - { - return ( this.element != null ); - } - - public Object next() - { - final Element el = this.element; - - if( el == null ) - { - throw new NoSuchElementException(); - } - - advance(); - - return el; - } - - public void remove() - { - throw new UnsupportedOperationException(); - } - } - -} diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/ClasspathUtil.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/ClasspathUtil.java deleted file mode 100644 index c4161f49b..000000000 --- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/ClasspathUtil.java +++ /dev/null @@ -1,113 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2006 BEA Systems, Inc. - * 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: - * Konstantin Komissarchik - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.common.jdt.internal.classpath; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.jdt.core.IClasspathContainer; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jem.util.logger.proxy.Logger; - -/** - * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a> - */ - -public final class ClasspathUtil -{ - private ClasspathUtil() {} - - public static Set getResolvedClasspath( final IJavaProject jproj, - final IPath entryToIgnore ) - { - return getResolvedClasspath( jproj, Collections.singleton( entryToIgnore ) ); - } - - public static Set getResolvedClasspath( final IJavaProject jproj, - final Set entriesToIgnore ) - { - final Set resolved = new HashSet(); - - try - { - final IClasspathEntry[] entries = jproj.getRawClasspath(); - - for( int i = 0; i < entries.length; i++ ) - { - IClasspathEntry entry = entries[ i ]; - - if( entriesToIgnore.contains( entry.getPath() ) ) - { - continue; - } - - switch( entry.getEntryKind() ) - { - case IClasspathEntry.CPE_LIBRARY: - case IClasspathEntry.CPE_PROJECT: - { - resolved.add( entry.getPath() ); - break; - } - case IClasspathEntry.CPE_VARIABLE: - { - entry = JavaCore.getResolvedClasspathEntry( entry ); - - if( entry != null ) - { - resolved.add( entry.getPath() ); - } - - break; - } - case IClasspathEntry.CPE_CONTAINER: - { - final IClasspathContainer container; - - try - { - container = JavaCore.getClasspathContainer( entry.getPath(), jproj ); - } - catch( JavaModelException e ) - { - Logger.getLogger().logError( e ); - continue; - } - - if( container != null ) - { - final IClasspathEntry[] containerEntries - = container.getClasspathEntries(); - - for( int j = 0; j < containerEntries.length; j++ ) - { - resolved.add( containerEntries[ j ].getPath() ); - } - } - } - } - } - } - catch( JavaModelException e ) - { - Logger.getLogger().logError( e ); - } - - return resolved; - } - -} diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/FlexibleProjectContainer.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/FlexibleProjectContainer.java deleted file mode 100644 index fdbb9267b..000000000 --- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/FlexibleProjectContainer.java +++ /dev/null @@ -1,572 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005, 2006 BEA Systems, Inc. - * 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: - * Konstantin Komissarchik - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.common.jdt.internal.classpath; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceChangeEvent; -import org.eclipse.core.resources.IResourceChangeListener; -import org.eclipse.core.resources.IResourceDelta; -import org.eclipse.core.resources.IResourceDeltaVisitor; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.jdt.core.IAccessRule; -import org.eclipse.jdt.core.IClasspathAttribute; -import org.eclipse.jdt.core.IClasspathContainer; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jst.common.frameworks.CommonFrameworksPlugin; -import org.eclipse.wst.common.componentcore.ComponentCore; -import org.eclipse.wst.common.componentcore.ModuleCoreNature; -import org.eclipse.wst.common.componentcore.internal.resources.VirtualArchiveComponent; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.componentcore.resources.IVirtualComponent; -import org.eclipse.wst.common.componentcore.resources.IVirtualFolder; -import org.eclipse.wst.common.componentcore.resources.IVirtualReference; -import org.eclipse.wst.common.componentcore.resources.IVirtualResource; - -/** - * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a> - */ - -public abstract class FlexibleProjectContainer - - implements IClasspathContainer - -{ - protected static final class PathType - { - public static final PathType - LIB_DIRECTORY = new PathType(), - CLASSES_DIRECTORY = new PathType(); - } - - private static ClasspathDecorationsManager decorations; - - static - { - // Register the resource listener that will listen for changes to - // resources relevant to flexible project containers across the - // workspace and refresh them as necessary. - - Listener.register(); - - // Read the decorations from the workspace metadata. - - final String plugin = CommonFrameworksPlugin.PLUGIN_ID; - decorations = new ClasspathDecorationsManager( plugin ); - } - - private static final String SEPARATOR = "!"; //$NON-NLS-1$ - - public static String getDecorationManagerKey(IProject project, String container){ - return project.getName() + SEPARATOR + container; - } - - protected final IPath path; - protected final IJavaProject owner; - protected final IProject project; - private final IPath[] paths; - private final PathType[] pathTypes; - private final List entries; - private final IClasspathEntry[] cpentries; - private static final Set containerTypes = new HashSet(); - - public FlexibleProjectContainer( final IPath path, - final IJavaProject owner, - final IProject project, - final IPath[] paths, - final PathType[] types ) - { - this.path = path; - this.owner = owner; - this.project = project; - this.paths = paths; - this.pathTypes = types; - - if( ! isFlexibleProject( this.project ) ) - { - // Silently noop if the referenced project is not a flexible - // project. Should I be doing something else here? - - this.entries = Collections.EMPTY_LIST; - this.cpentries = new IClasspathEntry[ 0 ]; - - return; - } - - addFlexibleProjectContainerType( path.segment( 0 ) ); - - this.entries = computeClasspathEntries(); - this.cpentries = new IClasspathEntry[ this.entries.size() ]; - - for( int i = 0, n = this.entries.size(); i < n; i++ ) - { - IPath entryPath = (IPath) this.entries.get( i ); - IResource resource =ResourcesPlugin.getWorkspace().getRoot().findMember(entryPath); - if(null != resource && resource.getType() == IResource.PROJECT) - this.cpentries[ i ] = JavaCore.newProjectEntry(entryPath, false); - else - this.cpentries[ i ] = newLibraryEntry( entryPath ); - } - } - - public int getKind() - { - return K_APPLICATION; - } - - public IPath getPath() - { - return this.path; - } - - public IClasspathEntry[] getClasspathEntries() - { - return this.cpentries; - } - - public boolean isOutOfDate( final IResourceDelta delta ) - { - if( delta == null ) - { - return false; - } - - final List currentEntries = computeClasspathEntries(); - return ! this.entries.equals( currentEntries ); - } - - public abstract void refresh(); - - static ClasspathDecorationsManager getDecorationsManager() - { - return decorations; - } - - private List computeClasspathEntries() - { - final List entries = new ArrayList(); - - final IVirtualComponent vc - = ComponentCore.createComponent( this.project ); - - if( vc == null ) - { - return entries; - } - - final Set existingEntries - = ClasspathUtil.getResolvedClasspath( this.owner, getPath() ); - - IVirtualReference[] refs = vc.getReferences(); - IVirtualComponent comp = null; - Set jarsHandled = new HashSet(); - String jarName = null; - for (int i = 0; i < refs.length; i++) { - comp = refs[i].getReferencedComponent(); - if (!refs[i].getRuntimePath().equals(paths[0].makeAbsolute())) - continue; - jarName = refs[i].getArchiveName(); - if(null != jarName){ - jarsHandled.add(jarName); - } - IPath newPath = null; - if (comp.isBinary()) { - VirtualArchiveComponent archiveComp = (VirtualArchiveComponent) comp; - if (archiveComp.getArchiveType().equals(VirtualArchiveComponent.CLASSPATHARCHIVETYPE)) { - // do not process components dynamically computed from the Java classpath - continue; - } - java.io.File diskFile = archiveComp.getUnderlyingDiskFile(); - if (diskFile.exists()) { - newPath =new Path(diskFile.getAbsolutePath()); - } else { - IFile iFile = archiveComp.getUnderlyingWorkbenchFile(); - if (!entries.contains(iFile.getFullPath())){ - newPath = iFile.getFullPath(); - } - } - } else { - IProject project = comp.getProject(); - newPath = project.getFullPath(); - } - - if( newPath != null && ! existingEntries.contains( newPath ) ) - { - entries.add( newPath ); - } - } - - for( int i = 0; i < this.paths.length; i++ ) - { - final IVirtualFolder rootFolder = vc.getRootFolder(); - final IVirtualFolder vf = rootFolder.getFolder( paths[ i ] ); - - if( this.pathTypes[ i ] == PathType.LIB_DIRECTORY ) - { - final IVirtualResource[] contents; - - try - { - contents = members( vf ); - } - catch( CoreException e ) - { - CommonFrameworksPlugin.log( e ); - continue; - } - - for( int j = 0; j < contents.length; j++ ) - { - final IResource r = contents[ j ].getUnderlyingResource(); - final IPath p = r.getFullPath(); - - if(!jarsHandled.contains(p.lastSegment()) && isJarFile( r ) ) - { - jarsHandled.add(p.lastSegment()); - - if( ! existingEntries.contains( p ) ) - { - entries.add( p ); - } - } - } - } - else - { - final IContainer[] uf = vf.getUnderlyingFolders(); - - for( int j = 0; j < uf.length; j++ ) - { - final IPath p = uf[ j ].getFullPath(); - - if( ! jarsHandled.contains( p.lastSegment() ) && - ! isSourceOrOutputDirectory( p ) ) - { - jarsHandled.add(p.lastSegment()); - - if( ! existingEntries.contains( p ) ) - { - entries.add( p ); - } - } - } - } - } - - return entries; - } - - // TODO: This method was created to provide a safe last-minute workaround - // for the issue described in https://bugs.eclipse.org/bugs/show_bug.cgi?id=162974. - // This code needs to be revisited in a future release to find a more - // permanent solution. - - protected IVirtualResource[] members( final IVirtualFolder vf ) - - throws CoreException - - { - return vf.members(); - } - - private IClasspathEntry newLibraryEntry( final IPath p ) - { - IPath srcpath = null; - IPath srcrootpath = null; - IClasspathAttribute[] attrs = {}; - IAccessRule[] access = {}; - - final ClasspathDecorations dec - = decorations.getDecorations( getDecorationManagerKey(project, getPath().toString()), p.toString() ); - - if( dec != null ) - { - srcpath = dec.getSourceAttachmentPath(); - srcrootpath = dec.getSourceAttachmentRootPath(); - attrs = dec.getExtraAttributes(); - } - - return JavaCore.newLibraryEntry( p, srcpath, srcrootpath, access, attrs, - false ); - - } - - private boolean isSourceOrOutputDirectory( final IPath aPath ) - { - if( isJavaProject( this.project ) ) - { - try - { - final IJavaProject jproject = JavaCore.create( this.project ); - final IClasspathEntry[] cp = jproject.getRawClasspath(); - - for( int i = 0; i < cp.length; i++ ) - { - final IClasspathEntry cpe = cp[ i ]; - - if( cpe.getEntryKind() == IClasspathEntry.CPE_SOURCE ) - { - final IPath src = cpe.getPath(); - final IPath output = cpe.getOutputLocation(); - - if( src.equals( aPath ) || - output != null && output.equals( aPath ) ) - { - return true; - } - } - } - - if( jproject.getOutputLocation().equals( aPath ) ) - { - return true; - } - } - catch( JavaModelException e ) - { - CommonFrameworksPlugin.log( e ); - } - } - - return false; - } - - private static boolean isJavaProject( final IProject pj ) - { - try - { - return pj.getNature( JavaCore.NATURE_ID ) != null; - } - catch( CoreException e ) - { - return false; - } - } - - private static boolean isFlexibleProject( final IProject pj ) - { - try - { - return pj.getNature( IModuleConstants.MODULE_NATURE_ID ) != null; - } - catch( CoreException e ) - { - return false; - } - } - - private static boolean isJarFile( final IResource f ) - { - if( f.getType() == IResource.FILE ) - { - final String fname = f.getName(); - - if( fname.endsWith( ".jar" ) || fname.endsWith( ".zip" ) ) //$NON-NLS-1$ //$NON-NLS-2$ - { - return true; - } - } - - return false; - } - - private static boolean isMetadataFile( final IResource f ) - { - if( f.getType() == IResource.FILE ) - { - final String fname = f.getName(); - - if( fname.equals( ".component" ) || //$NON-NLS-1$ - fname.equals( "org.eclipse.wst.common.component" ) || //$NON-NLS-1$ - fname.equals( ".classpath")) //$NON-NLS-1$ - { - return true; - } - } - - return false; - } - - private static boolean isFlexibleProjectContainer( final IPath path ) - { - synchronized( containerTypes ) - { - return containerTypes.contains( path.segment( 0 ) ); - } - } - - private static void addFlexibleProjectContainerType( final String type ) - { - synchronized( containerTypes ) - { - containerTypes.add( type ); - } - } - - private static final class Listener - - implements IResourceChangeListener - - { - public static void register() - { - final Listener listener = new Listener(); - final IWorkspace ws = ResourcesPlugin.getWorkspace(); - ws.addResourceChangeListener( listener, IResourceChangeEvent.PRE_BUILD ); - } - - public void resourceChanged( final IResourceChangeEvent event ) - { - // Screen the delta before going any further. - - if( ! isInterestingEvent( event ) ) - { - return; - } - - // Locate all of the flexible project containers. - - final ArrayList containers = new ArrayList(); - - final IProject[] projects - = ResourcesPlugin.getWorkspace().getRoot().getProjects(); - - for( int i = 0; i < projects.length; i++ ) - { - final IProject project = projects[ i ]; - - try - { - if( isJavaProject( project ) ) - { - final IJavaProject jproj = JavaCore.create( project ); - final IClasspathEntry[] cpes = jproj.getRawClasspath(); - - for( int j = 0; j < cpes.length; j++ ) - { - final IClasspathEntry cpe = cpes[ j ]; - final IPath path = cpe.getPath(); - - if( cpe.getEntryKind() == IClasspathEntry.CPE_CONTAINER && - isFlexibleProjectContainer( path ) ) - { - final IClasspathContainer cont - = JavaCore.getClasspathContainer( path, jproj ); - - containers.add( cont ); - } - } - } - } - catch( JavaModelException e ) - { - CommonFrameworksPlugin.log( e ); - } - } - - // Refresh the containers that are out of date. - - final IResourceDelta delta = event.getDelta(); - - for( int i = 0, n = containers.size(); i < n; i++ ) - { - final FlexibleProjectContainer c - = (FlexibleProjectContainer) containers.get( i ); - - if( c.isOutOfDate( delta ) ) - { - c.refresh(); - } - } - } - - private static boolean isInterestingEvent( final IResourceChangeEvent event ) - { - final boolean[] result = new boolean[ 1 ]; - - final IResourceDeltaVisitor visitor = new IResourceDeltaVisitor() - { - public boolean visit( final IResourceDelta delta ) - { - final IResource r = delta.getResource(); - - switch( r.getType() ) - { - case IResource.ROOT: - { - return true; - } - case IResource.PROJECT: - { - return ModuleCoreNature.isFlexibleProject( (IProject) r ); - } - case IResource.FOLDER: - { - final int kind = delta.getKind(); - - if( kind == IResourceDelta.ADDED || - kind == IResourceDelta.REMOVED ) - { - result[ 0 ] = true; - return false; - } - else - { - return true; - } - } - case IResource.FILE: - { - if( isJarFile( r ) || isMetadataFile( r ) ) - { - result[ 0 ] = true; - } - - return false; - } - default: - { - return false; - } - } - } - }; - - try - { - event.getDelta().accept( visitor, false ); - } - catch( CoreException e ) - { - CommonFrameworksPlugin.log( e ); - } - - return result[ 0 ]; - } - } - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/FlexibleProjectContainerInitializer.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/FlexibleProjectContainerInitializer.java deleted file mode 100644 index 90540683d..000000000 --- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/classpath/FlexibleProjectContainerInitializer.java +++ /dev/null @@ -1,83 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005, 2006 BEA Systems, Inc. - * 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: - * Konstantin Komissarchik - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.common.jdt.internal.classpath; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jdt.core.ClasspathContainerInitializer; -import org.eclipse.jdt.core.IClasspathAttribute; -import org.eclipse.jdt.core.IClasspathContainer; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; - -/** - * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a> - */ - -public abstract class FlexibleProjectContainerInitializer - - extends ClasspathContainerInitializer - -{ - private static final ClasspathDecorationsManager decorations - = FlexibleProjectContainer.getDecorationsManager(); - - public boolean canUpdateClasspathContainer( final IPath containerPath, - final IJavaProject project) - { - return true; - } - - public void requestClasspathContainerUpdate( final IPath containerPath, - final IJavaProject project, - final IClasspathContainer sg ) - - throws CoreException - - { - final String key = FlexibleProjectContainer.getDecorationManagerKey(project.getProject(), containerPath.toString()); - - final IClasspathEntry[] entries = sg.getClasspathEntries(); - - decorations.clearAllDecorations( key ); - - for( int i = 0; i < entries.length; i++ ) - { - final IClasspathEntry entry = entries[ i ]; - - final IPath srcpath = entry.getSourceAttachmentPath(); - final IPath srcrootpath = entry.getSourceAttachmentRootPath(); - final IClasspathAttribute[] attrs = entry.getExtraAttributes(); - - if( srcpath != null || attrs.length > 0 ) - { - final String eid = entry.getPath().toString(); - final ClasspathDecorations dec = new ClasspathDecorations(); - - dec.setSourceAttachmentPath( srcpath ); - dec.setSourceAttachmentRootPath( srcrootpath ); - dec.setExtraAttributes( attrs ); - - decorations.setDecorations( key, eid, dec ); - } - } - - decorations.save(); - - final IClasspathContainer container - = JavaCore.getClasspathContainer( containerPath, project ); - - ( (FlexibleProjectContainer) container ).refresh(); - } - -} diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaArtifactEditModel.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaArtifactEditModel.java deleted file mode 100644 index 3e18885b5..000000000 --- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaArtifactEditModel.java +++ /dev/null @@ -1,217 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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.jst.common.jdt.internal.integration; - -import java.util.Set; - -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.wst.common.componentcore.internal.ArtifactEditModel; -import org.eclipse.wst.common.frameworks.internal.SaveFailedException; -import org.eclipse.wst.common.internal.emf.resource.CompatibilityXMIResource; -import org.eclipse.wst.common.internal.emf.resource.ReferencedResource; -import org.eclipse.wst.common.internal.emf.resource.TranslatorResource; -import org.eclipse.wst.common.internal.emfworkbench.EMFWorkbenchContext; - -public class JavaArtifactEditModel extends ArtifactEditModel implements WorkingCopyProvider { - - private WorkingCopyManager workingCopyManager = null; - - /** - * @param anEditModelId - * @param aContext - * @param toMakeReadOnly - * @param toAccessUnknownResourcesAsReadOnly - * @param aModuleURI - */ - public JavaArtifactEditModel(String anEditModelId, EMFWorkbenchContext aContext, boolean toMakeReadOnly, boolean toAccessUnknownResourcesAsReadOnly, URI aModuleURI) { - super(anEditModelId, aContext, toMakeReadOnly, - toAccessUnknownResourcesAsReadOnly, aModuleURI); - // TODO Auto-generated constructor stub - } - - /** - * @param anEditModelId - * @param aContext - * @param toMakeReadOnly - * @param aModuleURI - */ - public JavaArtifactEditModel(String anEditModelId, EMFWorkbenchContext aContext, boolean toMakeReadOnly, URI aModuleURI) { - super(anEditModelId, aContext, toMakeReadOnly, aModuleURI); - // TODO Auto-generated constructor stub - } - - /** - * This will delete - * - * @cu from the workbench and fix the internal references for this working copy manager. - */ - public void delete(org.eclipse.jdt.core.ICompilationUnit cu, org.eclipse.core.runtime.IProgressMonitor monitor) { - getWorkingCopyManager().delete(cu, monitor); - } - - /** - * This method should only be called by the J2EENature. - */ - protected void doDispose() { - super.doDispose(); - resetWorkingCopyManager(); - } - - public Set getAffectedFiles() { - java.util.Set affected = super.getAffectedFiles(); - if (getWorkingCopyManager() != null) - affected.addAll(getWorkingCopyManager().getAffectedFiles()); - - return affected; - } - - /** - * Returns the working copy remembered for the compilation unit encoded in the given editor - * input. Does not connect the edit model to the working copy. - * - * @param input - * ICompilationUnit - * @return the working copy of the compilation unit, or <code>null</code> if the input does - * not encode an editor input, or if there is no remembered working copy for this - * compilation unit - */ - public org.eclipse.jdt.core.ICompilationUnit getExistingWorkingCopy(org.eclipse.jdt.core.ICompilationUnit cu) throws org.eclipse.core.runtime.CoreException { - return getWorkingCopyManager().getExistingWorkingCopy(cu); - } - - /** - * Returns the working copy remembered for the compilation unit. - * - * @param input - * ICompilationUnit - * @return the working copy of the compilation unit, or <code>null</code> if there is no - * remembered working copy for this compilation unit - */ - public org.eclipse.jdt.core.ICompilationUnit getWorkingCopy(ICompilationUnit cu, boolean forNewCU) throws CoreException { - return getWorkingCopyManager().getWorkingCopy(cu, forNewCU); - } - - /** - * Save the new compilation units only. - */ - protected void handleSaveIfNecessaryDidNotSave(IProgressMonitor monitor) { - getWorkingCopyManager().saveOnlyNewCompilationUnits(monitor); - } - - /** - * @see org.eclipse.jst.j2ee.internal.internal.workbench.J2EEEditModel#isDirty() - */ - public boolean isDirty() { - boolean dirtyBool = super.isDirty(); - if (!dirtyBool && getWorkingCopyManager() != null) - dirtyBool = getWorkingCopyManager().hasWorkingCopies(); - return dirtyBool; - } - - /** - * This will force all of the referenced Resources to be saved. - */ - public void primSave(IProgressMonitor monitor) { - saveCompilationUnits(monitor); - if (monitor == null || !monitor.isCanceled()) - super.primSave(monitor); - } - protected void runSaveOperation(IWorkspaceRunnable runnable, IProgressMonitor monitor) throws SaveFailedException { - try { - ResourcesPlugin.getWorkspace().run(runnable, null,IWorkspace.AVOID_UPDATE,monitor); - } catch (CoreException e) { - throw new SaveFailedException(e); - } - } - - /** - * Insert the method's description here. Creation date: (4/11/2001 4:14:26 PM) - * - * @return java.util.Set - */ - public void processResource(Resource aResource) { - if (aResource != null && !getResources().contains(aResource)) { - if (aResource instanceof ReferencedResource) { - access((ReferencedResource) aResource); - //We need a better way to pass this through the save options instead. - //We also need to make this dynamic based on the project target - ((ReferencedResource) aResource).setFormat(CompatibilityXMIResource.FORMAT_MOF5); - } else if (!isReadOnly()) - aResource.setTrackingModification(true); - addResource(aResource); - } - } - - /** - * Release each of the referenced resources. - */ - protected void release(Resource aResource) { - - removeResource(aResource); - if (aResource != null) { - boolean isRefRes = aResource instanceof ReferencedResource; - if (isRefRes) - release((ReferencedResource) aResource); - if (!isDisposing()) - resetWorkingCopyManager(); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jst.j2ee.internal.internal.workbench.J2EEEditModel#resourceIsLoadedChanged(org.eclipse.emf.ecore.resource.Resource, - * boolean, boolean) - */ - protected void resourceIsLoadedChanged(Resource aResource, boolean oldValue, boolean newValue) { - if (!isReverting && !disposing && !isReadOnly() && oldValue && !newValue && aResource instanceof TranslatorResource) - resetWorkingCopyManager(); - super.resourceIsLoadedChanged(aResource, oldValue, newValue); - } - - protected void reverted(ReferencedResource revertedResource) { - if (getWorkingCopyManager() != null) - getWorkingCopyManager().revert(); - revertAllResources(); - } - - /** - * This will save all of the referenced CompilationUnits to be saved. - */ - public void saveCompilationUnits(IProgressMonitor monitor) { - getWorkingCopyManager().saveCompilationUnits(monitor); - } - - public WorkingCopyManager getWorkingCopyManager() { - if (workingCopyManager == null) - workingCopyManager = WorkingCopyManagerFactory.newRegisteredInstance(); - return workingCopyManager; - } - - /** - * Reset the working copy manager because the ejb-jar.xml was removed without disposing. - */ - protected void resetWorkingCopyManager() { - if (workingCopyManager != null) { - workingCopyManager.dispose(); - workingCopyManager = null; - } - } - - -} diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaArtifactEditModelFactory.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaArtifactEditModelFactory.java deleted file mode 100644 index e25d714bb..000000000 --- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaArtifactEditModelFactory.java +++ /dev/null @@ -1,63 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 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.jst.common.jdt.internal.integration; - -import java.util.Map; - -import org.eclipse.emf.common.util.URI; -import org.eclipse.wst.common.internal.emfworkbench.EMFWorkbenchContext; -import org.eclipse.wst.common.internal.emfworkbench.integration.EditModel; -import org.eclipse.wst.common.internal.emfworkbench.integration.EditModelFactory; - -/** - * <p> - * The following class is experimental until fully documented. - * </p> - */ -public class JavaArtifactEditModelFactory extends EditModelFactory { - - public static final String MODULE_EDIT_MODEL_ID = "org.eclipse.jst.modulecore.editModel"; //$NON-NLS-1$ - - public static final String PARAM_MODULE_URI = "MODULE_URI"; //$NON-NLS-1$ - - /* (non-Javadoc) - * @see org.eclipse.wst.common.internal.emfworkbench.integration.EditModelFactory#createEditModelForRead(java.lang.String, org.eclipse.wst.common.internal.emfworkbench.EMFWorkbenchContext, java.util.Map) - */ - public EditModel createEditModelForRead(String editModelID, EMFWorkbenchContext context, Map params) { - URI moduleURI = (URI) ((params != null) ? params.get(PARAM_MODULE_URI) : null); - if(moduleURI == null) - throw new IllegalStateException("A Module URI must be provided"); //$NON-NLS-1$ - - return new JavaArtifactEditModel(editModelID, context, true, moduleURI); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.internal.emfworkbench.integration.EditModelFactory#createEditModelForWrite(java.lang.String, org.eclipse.wst.common.internal.emfworkbench.EMFWorkbenchContext, java.util.Map) - */ - public EditModel createEditModelForWrite(String editModelID, EMFWorkbenchContext context, Map params) { - URI moduleURI = (URI) ((params != null) ? params.get(PARAM_MODULE_URI) : null); - if(moduleURI == null) - throw new IllegalStateException("A Module URI must be provided"); //$NON-NLS-1$ - return new JavaArtifactEditModel(editModelID, context, false,false, moduleURI); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.internal.emfworkbench.integration.EditModelFactory#getCacheID(java.lang.String, java.util.Map) - */ - public String getCacheID(String editModelID, Map params) { - URI moduleURI = (URI)params.get(PARAM_MODULE_URI); - if(moduleURI != null) - return editModelID+":"+moduleURI.toString(); //$NON-NLS-1$ - return editModelID+":NOURI"; //$NON-NLS-1$ - } - - -} diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaProjectValidationHandler.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaProjectValidationHandler.java deleted file mode 100644 index ece991275..000000000 --- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/JavaProjectValidationHandler.java +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 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.jst.common.jdt.internal.integration; - -import org.eclipse.core.resources.IResource; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.wst.validation.internal.IValidationSelectionHandler; - - -/** - * Java Project validation - */ -public class JavaProjectValidationHandler implements IValidationSelectionHandler { - - private String validationType = null; - - /** - * Default constructor - */ - public JavaProjectValidationHandler() { - super(); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.frameworks.internal.IValidationSelectionHandler#getBaseValidationType(java.lang.Object) - */ - public IResource getBaseValidationType(Object selection) { - if (selection instanceof IJavaProject) - return ((IJavaProject)selection).getProject(); - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.frameworks.internal.IValidationSelectionHandler#getValidationTypeString() - */ - public String getValidationTypeString() { - return validationType; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.frameworks.internal.IValidationSelectionHandler#setValidationTypeString(java.lang.String) - */ - public void setValidationTypeString(String validationType) { - this.validationType = validationType; - } - -} diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/WTPWorkingCopyManager.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/WTPWorkingCopyManager.java deleted file mode 100644 index dd1e4e2ef..000000000 --- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/WTPWorkingCopyManager.java +++ /dev/null @@ -1,542 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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.jst.common.jdt.internal.integration; - - - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.IWorkspaceRunnable; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jdt.core.ICompilationUnit; -import org.eclipse.jdt.core.IJavaElement; -import org.eclipse.jdt.core.IPackageFragment; -import org.eclipse.jdt.core.JavaModelException; -import org.eclipse.jem.util.logger.proxy.Logger; -import org.eclipse.wst.common.frameworks.internal.ISaveHandler; -import org.eclipse.wst.common.frameworks.internal.SaveFailedException; -import org.eclipse.wst.common.frameworks.internal.SaveHandlerHeadless; -import org.eclipse.wst.common.frameworks.internal.SaveHandlerRegister; -import org.eclipse.wst.common.frameworks.internal.plugin.WTPCommonPlugin; - -/** - * Insert the type's description here. Creation date: (4/27/2001 4:14:30 PM) - * - * @author: Administrator - */ -public class WTPWorkingCopyManager implements WorkingCopyManager { - - //New CUs that will need to be deleted upon dispose - private List originalNewCompilationUnits; - //New CUs that were created that need saved immediately (after each gen) - private List needsSavingCompilationUnits; - //A complete list of new CUs that is only cleared on save and dispose - private List newCompilationUnits; - private HashMap deletedCompilationUnits; - protected static final Class IRESOURCE_CLASS = IResource.class; - - /** - * WTPWorkingCopyManager constructor comment. - */ - public WTPWorkingCopyManager() { - super(); - } - - protected void addDeletedCompilationUnit(ICompilationUnit cu) { - getNeedsSavingCompilationUnits().remove(cu); - if (!getOriginalNewCompilationUnits().contains(cu) && !getDeletedCompilationUnits().containsKey(cu)) - primAddDeletedCompilationUnit(cu); - getOriginalNewCompilationUnits().remove(cu); - } - - protected void addNewCompilationUnit(ICompilationUnit cu, ICompilationUnit workingCopy) { - getNewCompilationUnits().add(cu); - getNeedsSavingCompilationUnits().add(workingCopy); - if (!getDeletedCompilationUnits().containsKey(cu)) - getOriginalNewCompilationUnits().add(cu); - } - - /** - * This will save all of the new CompilationUnits to be saved. - */ - protected void commitWorkingCopy(ICompilationUnit wc, IProgressMonitor monitor) { - try { - try { - wc.commitWorkingCopy(false, monitor); - } catch (JavaModelException e) { - if (isFailedWriteFileFailure(e) && shouldSaveReadOnly(wc)) - wc.commitWorkingCopy(false, monitor); - else - throw e; - } - } catch (JavaModelException e) { - org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError(e); - throw new SaveFailedException(e); - } finally { - try { - wc.discardWorkingCopy(); - } catch (JavaModelException e1) { - org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError(e1); - throw new SaveFailedException(e1); - } - } - } - - /** - * This will delete - * - * @cu from the workbench and fix the internal references for this working copy manager. - */ - public void delete(ICompilationUnit cu, IProgressMonitor monitor) { - if (cu.isWorkingCopy()) - cu = cu.getPrimary(); - addDeletedCompilationUnit(cu); - try { - cu.delete(false, monitor); - } catch (JavaModelException e) { - if (e.getStatus().getCode() != org.eclipse.jdt.core.IJavaModelStatusConstants.ELEMENT_DOES_NOT_EXIST) - org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError(e); - } - } - - protected void discardOriginalNewCompilationUnits() { - if (getOriginalNewCompilationUnits().isEmpty()) - return; - List cus = getOriginalNewCompilationUnits(); - ICompilationUnit cu; - ICompilationUnit wc = null; - for (int i = 0; i < cus.size(); i++) { - cu = (ICompilationUnit) cus.get(i); - if (cu.isWorkingCopy()) { - wc = cu; - cu = wc.getPrimary(); - } - primDelete(cu); - if (wc != null) - try { - wc.discardWorkingCopy(); - } catch (JavaModelException e) { - Logger.getLogger().logError(e); - } - } - } - - public void dispose() { - IWorkspaceRunnable runnable = new IWorkspaceRunnable() { - public void run(IProgressMonitor aMonitor) { - primDispose(); - } - }; - try { - if (!WTPCommonPlugin.getWorkspace().isTreeLocked()) { - WTPCommonPlugin.getWorkspace().run(runnable,null, IWorkspace.AVOID_UPDATE,null); - } else { - runnable.run(null); - } - } catch (CoreException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - //runOperation(runnable, null, true); - } - - public void revert() { - IWorkspaceRunnable runnable = new IWorkspaceRunnable() { - public void run(IProgressMonitor aMonitor) { - primRevert(); - } - }; - runOperation(runnable, null, true); - } - - public Set getAffectedFiles() { - return Collections.EMPTY_SET; - } - - /** - * Insert the method's description here. Creation date: (7/11/2001 6:43:37 PM) - * - * @return java.util.HashMap - */ - protected HashMap getDeletedCompilationUnits() { - if (deletedCompilationUnits == null) - deletedCompilationUnits = new HashMap(); - return deletedCompilationUnits; - } - - /** - * Returns the working copy remembered for the compilation unit encoded in the given editor - * input. Does not connect the edit model to the working copy. - * - * @param input - * ICompilationUnit - * @return the working copy of the compilation unit, or <code>null</code> if the input does - * not encode an editor input, or if there is no remembered working copy for this - * compilation unit - */ - public org.eclipse.jdt.core.ICompilationUnit getExistingWorkingCopy(ICompilationUnit cu) throws CoreException { - ICompilationUnit newCU = getNewCompilationUnitWorkingCopy(cu); - if (newCU != null) - return newCU; - return null; - } - - /** - * Insert the method's description here. Creation date: (7/19/2001 11:00:19 AM) - * - * @return java.util.List - */ - protected java.util.List getNeedsSavingCompilationUnits() { - if (needsSavingCompilationUnits == null) - needsSavingCompilationUnits = new ArrayList(); - return needsSavingCompilationUnits; - } - - /** - * Insert the method's description here. Creation date: (4/26/2001 3:49:05 PM) - * - * @return java.util.List - */ - protected java.util.List getNewCompilationUnits() { - if (newCompilationUnits == null) - newCompilationUnits = new ArrayList(); - return newCompilationUnits; - } - - /** - * It is possible that we have already created this CompilationUnit and its working copy. If - * this is the case, return our new working copy and do not create a new one. - */ - protected ICompilationUnit getNewCompilationUnitWorkingCopy(ICompilationUnit cu) { - if (hasNewCompilationUnit(cu)) { - List list = getNeedsSavingCompilationUnits(); - ICompilationUnit copy; - for (int i = 0; i < list.size(); i++) { - copy = (ICompilationUnit) list.get(i); - if (cu.equals(copy.getPrimary())) - return copy; - } - } - return null; - } - - /** - * Insert the method's description here. Creation date: (4/26/2001 3:49:05 PM) - * - * @return java.util.List - */ - protected java.util.List getOriginalNewCompilationUnits() { - if (originalNewCompilationUnits == null) - originalNewCompilationUnits = new ArrayList(); - return originalNewCompilationUnits; - } - - /** - * Return the IPackageFragment for the given ICompilationUnit. - */ - protected IPackageFragment getPackageFragment(ICompilationUnit cu) { - if (cu == null) - return null; - IJavaElement parent = cu; - int elementType = cu.getElementType(); - while (parent != null && elementType != IJavaElement.PACKAGE_FRAGMENT) { - parent = parent.getParent(); - if (parent != null) - elementType = parent.getElementType(); - else - elementType = -1; - } - return (IPackageFragment) parent; - } - - protected ISaveHandler getSaveHandler() { - return SaveHandlerRegister.getSaveHandler(); - } - - /** - * Returns the working copy remembered for the compilation unit. - * - * @param input - * ICompilationUnit - * @return the working copy of the compilation unit, or <code>null</code> if there is no - * remembered working copy for this compilation unit - */ - public ICompilationUnit getWorkingCopy(ICompilationUnit cu, boolean forNewCU) throws org.eclipse.core.runtime.CoreException { - if (cu == null || cu.isWorkingCopy()) - return cu; - ICompilationUnit newCU = getNewCompilationUnitWorkingCopy(cu); - if (newCU != null) - return newCU; - ICompilationUnit workingCopy = cu.getWorkingCopy(null); - addNewCompilationUnit(cu, workingCopy); - return workingCopy; - } - - /** - * Has a new compilation unit already been created. - */ - protected boolean hasNewCompilationUnit(ICompilationUnit cu) { - return getNewCompilationUnits().contains(cu); - } - - protected boolean isFailedWriteFileFailure(Exception ex) { - return SaveHandlerHeadless.isFailedWriteFileFailure(ex); - } - - protected void primAddDeletedCompilationUnit(ICompilationUnit cu) { - if (cu == null) - return; - Object[] info = new Object[2]; - info[0] = getPackageFragment(cu); - try { - info[1] = cu.getSource(); - } catch (JavaModelException e) { - info[1] = null; - } - getDeletedCompilationUnits().put(cu, info); - } - - // This is an internal delete call. - protected void primDelete(ICompilationUnit cu) { - try { - if (cu.exists()) - cu.delete(true, new org.eclipse.core.runtime.NullProgressMonitor()); - } catch (JavaModelException e) { - org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError(e); - //What to do here? - } - } - - protected void primDispose() { - discardOriginalNewCompilationUnits(); - reviveDeletedCompilationUnits(); - newCompilationUnits = null; - needsSavingCompilationUnits = null; - originalNewCompilationUnits = null; - deletedCompilationUnits = null; - } - - protected void primRevert() { - discardOriginalNewCompilationUnits(); - reviveDeletedCompilationUnits(); - newCompilationUnits = null; - needsSavingCompilationUnits = null; - originalNewCompilationUnits = null; - deletedCompilationUnits = null; - } - - /** - * Returns the working copy remembered for the compilation unit encoded in the given editor - * input. - * - * @param input - * ICompilationUnit - * @return the working copy of the compilation unit, or <code>null</code> if the input does - * not encode an editor input, or if there is no remembered working copy for this - * compilation unit - */ - protected ICompilationUnit primGetWorkingCopy(ICompilationUnit cu) throws CoreException { - return null; - } - - /** - * This will save all of the referenced CompilationUnits to be saved. - */ - protected void primSaveCompilationUnits(org.eclipse.core.runtime.IProgressMonitor monitor) { - saveNewCompilationUnits(monitor); - getDeletedCompilationUnits().clear(); - } - - /** - * This will save all of the new CompilationUnits to be saved. - */ - protected void primSaveOnlyNewCompilationUnits(org.eclipse.core.runtime.IProgressMonitor monitor) { - List cus = getNeedsSavingCompilationUnits(); - ICompilationUnit wc; - for (int i = 0; i < cus.size(); i++) { - wc = (ICompilationUnit) cus.get(i); - commitWorkingCopy(wc, monitor); - } - cus.clear(); - } - - protected void removeDeletedCompilationUnit(ICompilationUnit cu) { - if (getDeletedCompilationUnits().remove(cu) != null) { - if (cu.isWorkingCopy()) { - ICompilationUnit original, nextCU, testCU; - original = cu.getPrimary(); - Set cus = getDeletedCompilationUnits().keySet(); - Iterator it = cus.iterator(); - while (it.hasNext()) { - nextCU = (ICompilationUnit) it.next(); - testCU = nextCU.isWorkingCopy() ? (ICompilationUnit) nextCU.getPrimary() : nextCU; - if (testCU.equals(original)) { - cus.remove(nextCU); - return; - } - } - } - } - } - - protected void reviveDeletedCompilationUnit(ICompilationUnit cu, Object[] info, IProgressMonitor pm) { - if (info[0] != null && info[1] != null) { - String typeName = cu.getElementName(); - IPackageFragment pack = (IPackageFragment) info[0]; - String source = (String) info[1]; - try { - ICompilationUnit existingCU = pack.getCompilationUnit(typeName); - if (existingCU.exists() && getNewCompilationUnits().contains(existingCU)) - existingCU.delete(false, pm); - pack.createCompilationUnit(typeName, source, false, pm); - } catch (JavaModelException e) { - org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError(e); - } - } - } - - protected void reviveDeletedCompilationUnits() { - if (getDeletedCompilationUnits().isEmpty()) - return; - IProgressMonitor pm = new org.eclipse.core.runtime.NullProgressMonitor(); - Iterator it = getDeletedCompilationUnits().entrySet().iterator(); - Map.Entry entry; - ICompilationUnit cu; - Object[] info; - while (it.hasNext()) { - entry = (Map.Entry) it.next(); - cu = (ICompilationUnit) entry.getKey(); - info = (Object[]) entry.getValue(); - reviveDeletedCompilationUnit(cu, info, pm); - } - - } - - protected void runOperation(IWorkspaceRunnable aRunnable, IProgressMonitor monitor, boolean validate) { - primRunOperation(aRunnable, monitor); - - // TODO Break the validator depedency - // if (validate) - // primRunOperation(aRunnable, monitor); - // else { - // IProject proj = getValidationProject(); - // - // ValidatorManager mgr = ValidatorManager.getManager(); - // boolean disableValidators = proj != null; - // boolean wasSuspended = false; - // if (disableValidators) { - // wasSuspended = mgr.isSuspended(proj); - // if (!wasSuspended) - // mgr.suspendValidation(proj, true); - // } - // try { - // primRunOperation(aRunnable, monitor); - // } finally { - // if (disableValidators && !wasSuspended) - // mgr.suspendValidation(proj, false); - // } - // } - } - - protected void primRunOperation(IWorkspaceRunnable aRunnable, IProgressMonitor monitor) { - - if (aRunnable != null) { - //if (workspace.isTreeLocked()) - //Logger.getLogger().logTrace(ResourceHandler.getString("Cannot_run_J2EEUIWorkingCo_ERROR_")); - // //$NON-NLS-1$ = "Cannot run J2EEUIWorkingCopyManager operation because the Workspace - // tree is locked." - //else { - if (!WTPCommonPlugin.getWorkspace().isTreeLocked()) { - try { - WTPCommonPlugin.getWorkspace().run(aRunnable, monitor); - } catch (CoreException e) { - throw new SaveFailedException(e); - } - } - } - } - - /** - * This will save all of the referenced CompilationUnits to be saved. - */ - public void saveCompilationUnits(org.eclipse.core.runtime.IProgressMonitor monitor) { - getSaveHandler().access(); - try { - IWorkspaceRunnable runnable = new IWorkspaceRunnable() { - public void run(IProgressMonitor aMonitor) { - primSaveCompilationUnits(aMonitor); - } - }; - runOperation(runnable, monitor, true); - } catch (SaveFailedException ex) { - getSaveHandler().handleSaveFailed(ex, monitor); - } finally { - getSaveHandler().release(); - } - } - - /** - * This will save all of the referenced CompilationUnits to be saved. - */ - protected void saveNewCompilationUnits(IProgressMonitor monitor) { - primSaveOnlyNewCompilationUnits(monitor); - getOriginalNewCompilationUnits().clear(); - getNewCompilationUnits().clear(); - } - - /** - * This will save all of the new CompilationUnits to be saved. - */ - public void saveOnlyNewCompilationUnits(org.eclipse.core.runtime.IProgressMonitor monitor) { - getSaveHandler().access(); - try { - IWorkspaceRunnable runnable = new IWorkspaceRunnable() { - public void run(IProgressMonitor aMonitor) { - primSaveOnlyNewCompilationUnits(aMonitor); - } - }; - runOperation(runnable, monitor, false); - } catch (SaveFailedException ex) { - getSaveHandler().handleSaveFailed(ex, monitor); - } finally { - getSaveHandler().release(); - } - } - - protected boolean shouldSaveReadOnly(ICompilationUnit wc) { - IResource resource = null; - - resource = (IResource) wc.getPrimary().getAdapter(IRESOURCE_CLASS); - - if (resource == null || resource.getType() != IResource.FILE || !resource.getResourceAttributes().isReadOnly()) - return false; - - return getSaveHandler().shouldContinueAndMakeFileEditable((IFile) resource); - } - - /** - * @see com.ibm.etools.j2ee.workbench.IJ2EEWorkingCopyManager#hasWorkingCopies() - */ - public boolean hasWorkingCopies() { - return (deletedCompilationUnits != null && !deletedCompilationUnits.isEmpty()) || (needsSavingCompilationUnits != null && !needsSavingCompilationUnits.isEmpty()) || (newCompilationUnits != null && !newCompilationUnits.isEmpty()); - } - -} diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/WorkingCopyManager.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/WorkingCopyManager.java deleted file mode 100644 index 35ccc89fb..000000000 --- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/WorkingCopyManager.java +++ /dev/null @@ -1,49 +0,0 @@ -/******************************************************************************* - * 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 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.jst.common.jdt.internal.integration; - -import org.eclipse.core.runtime.IProgressMonitor; - - -/** - * @author Administrator - * - * - */ -public interface WorkingCopyManager extends WorkingCopyProvider { - - void dispose(); - - java.util.Set getAffectedFiles(); - - /** - * This will save all of the referenced CompilationUnits to be saved. - */ - void saveCompilationUnits(IProgressMonitor monitor); - - /** - * This will save all of the new CompilationUnits to be saved. - */ - void saveOnlyNewCompilationUnits(IProgressMonitor monitor); - - /** - * Method hasWorkingCopies. - * - * @return boolean - */ - boolean hasWorkingCopies(); - - /** - * Revert all working copies. - */ - void revert(); - -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/WorkingCopyManagerFactory.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/WorkingCopyManagerFactory.java deleted file mode 100644 index 9153f9e99..000000000 --- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/WorkingCopyManagerFactory.java +++ /dev/null @@ -1,57 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2005 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.jst.common.jdt.internal.integration; - -import org.eclipse.jem.util.UIContextDetermination; - - -/** - * @author mdelder - * - * - */ -public class WorkingCopyManagerFactory { - - // protected static Class workingCopyManagerClass; - - public static WorkingCopyManager newRegisteredInstance() { - return (WorkingCopyManager) UIContextDetermination.createInstance("workingCopyManager"); //$NON-NLS-1$ - } - - // public static IWorkingCopyManager createWorkingCopyManager() { - // if (getWorkingCopyManagerClass() != null) - // try { - // return (IWorkingCopyManager) getWorkingCopyManagerClass().newInstance(); - // } catch (InstantiationException e1) { - // } catch (IllegalAccessException e2) { - // } - // return null; - // } - // - // /** - // * Insert the method's description here. - // * Creation date: (4/26/2001 7:53:15 AM) - // * @return java.lang.Class - // */ - // public static java.lang.Class getWorkingCopyManagerClass() { - // return workingCopyManagerClass; - // } - // - // /** - // * Insert the method's description here. - // * Creation date: (4/26/2001 7:53:15 AM) - // * @param newWorkingCopyManagerClass java.lang.Class - // */ - // public static void setWorkingCopyManagerClass(java.lang.Class newWorkingCopyManagerClass) { - // workingCopyManagerClass = newWorkingCopyManagerClass; - // } - -} diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/WorkingCopyProvider.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/WorkingCopyProvider.java deleted file mode 100644 index 2696f5c54..000000000 --- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/jdt/internal/integration/WorkingCopyProvider.java +++ /dev/null @@ -1,60 +0,0 @@ -/******************************************************************************* - * 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 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.jst.common.jdt.internal.integration; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jdt.core.ICompilationUnit; - - -/** - * The user of the Java code generation framework must supply an implementation of this interface. - * The framework will obtain compilation working copies from this interface. The supplier of the - * implementation is responsible for committing the working copies when appropriate for the user's - * edit model. - */ -public interface WorkingCopyProvider { - - /** - * This will delete compilation unit from the workbench and fix the internal references for this - * working copy manager. - * - * @param cu - * the compilation unit to delete - * @param monitor - * the progress monitor to use for the delete - */ - void delete(ICompilationUnit cu, IProgressMonitor monitor); - - /** - * Returns the working copy remembered for the compilation unit. That is, the manager already - * has a working copy for this unit, it does not create a new working copy. Does not connect the - * edit model to the working copy. - * - * @param input - * the compilation unit - * @return the working copy of the compilation unit, or <code>null</code> it there is no - * remembered working copy for this compilation unit - */ - ICompilationUnit getExistingWorkingCopy(ICompilationUnit cu) throws CoreException; - - /** - * Returns the working copy remembered for the compilation unit or creates a new working copy - * for the compilation unit and returns it. If a working copy is passed in, it is returned. - * - * @param input - * the compilation unit - * @return the working copy of the compilation unit - * @exception CoreException - * if the working copy can not be created - */ - ICompilationUnit getWorkingCopy(ICompilationUnit cu, boolean forNewCU) throws CoreException; -}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/IJavaFacetInstallDataModelProperties.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/IJavaFacetInstallDataModelProperties.java deleted file mode 100644 index c7e564bca..000000000 --- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/IJavaFacetInstallDataModelProperties.java +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 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.jst.common.project.facet; - -import org.eclipse.wst.common.frameworks.datamodel.IDataModelProperties; - -public interface IJavaFacetInstallDataModelProperties extends IDataModelProperties { - - public static final String SOURCE_FOLDER_NAME = "IJavaFacetInstallDataModelProperties.SOURCE_FOLDER_NAME"; //$NON-NLS-1$ - public static final String DEFAULT_OUTPUT_FOLDER_NAME = "IJavaFacetInstallDataModelProperties.DEFAULT_OUTPUT_FOLDER_NAME"; //$NON-NLS-1$ -} diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetDefaultVersionProvider.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetDefaultVersionProvider.java deleted file mode 100644 index 4dd8501d6..000000000 --- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetDefaultVersionProvider.java +++ /dev/null @@ -1,34 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2006 BEA Systems, Inc. - * 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: - * Konstantin Komissarchik - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.common.project.facet; - -import org.eclipse.wst.common.project.facet.core.IDefaultVersionProvider; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; - -/** - * Defaults the java facet version to align with workspace java compiler - * level settings. - * - * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a> - */ - -public final class JavaFacetDefaultVersionProvider - - implements IDefaultVersionProvider - -{ - public IProjectFacetVersion getDefaultVersion() - { - final String compilerLevel = JavaFacetUtils.getCompilerLevel(); - return JavaFacetUtils.compilerLevelToFacet( compilerLevel ); - } -} diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetInstallDataModelProvider.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetInstallDataModelProvider.java deleted file mode 100644 index b42407017..000000000 --- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetInstallDataModelProvider.java +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 2007 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.jst.common.project.facet; - -import java.util.Hashtable; -import java.util.Set; - -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jst.common.frameworks.CommonFrameworksPlugin; -import org.eclipse.wst.common.componentcore.datamodel.FacetInstallDataModelProvider; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; - -public class JavaFacetInstallDataModelProvider extends FacetInstallDataModelProvider implements IJavaFacetInstallDataModelProperties { - - public JavaFacetInstallDataModelProvider() { - super(); - } - - public Set getPropertyNames() { - Set propertyNames = super.getPropertyNames(); - propertyNames.add(SOURCE_FOLDER_NAME); - propertyNames.add(DEFAULT_OUTPUT_FOLDER_NAME); - return propertyNames; - } - - public Object getDefaultProperty(String propertyName) { - if (FACET_ID.equals(propertyName)) { - return IModuleConstants.JST_JAVA; - } else if (FACET_VERSION.equals(propertyName)) { - Hashtable javaOptions = JavaCore.getOptions(); - String jdtVersion = (String)javaOptions.get(JavaCore.COMPILER_COMPLIANCE); - if(jdtVersion == null){ - jdtVersion = (String)JavaCore.getDefaultOptions().get(JavaCore.COMPILER_COMPLIANCE); - } - if (jdtVersion.startsWith("1.3")) { //$NON-NLS-1$ - return JavaFacetUtils.JAVA_13; - } else if (jdtVersion.startsWith("1.4")) { //$NON-NLS-1$ - return JavaFacetUtils.JAVA_14; - } - return JavaFacetUtils.JAVA_50; - - } else if (SOURCE_FOLDER_NAME.equals(propertyName)) { - return CommonFrameworksPlugin.getDefault().getPluginPreferences().getString(CommonFrameworksPlugin.DEFAULT_SOURCE_FOLDER); - } else if (DEFAULT_OUTPUT_FOLDER_NAME.equals(propertyName)) { - return CommonFrameworksPlugin.getDefault().getPluginPreferences().getString(CommonFrameworksPlugin.OUTPUT_FOLDER); - } - - return super.getDefaultProperty(propertyName); - } - -} diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetInstallDelegate.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetInstallDelegate.java deleted file mode 100644 index 8ecbf3fba..000000000 --- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetInstallDelegate.java +++ /dev/null @@ -1,119 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005 BEA Systems, Inc. - * 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: - * Konstantin Komissarchik - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.common.project.facet; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.wst.common.frameworks.datamodel.IDataModel; -import org.eclipse.wst.common.project.facet.core.IDelegate; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; - -/** - * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a> - */ - -public final class JavaFacetInstallDelegate implements IDelegate { - - public void execute(final IProject project, final IProjectFacetVersion fv, final Object cfg, final IProgressMonitor monitor) throws CoreException { - if (monitor != null) { - monitor.beginTask("", 1); //$NON-NLS-1$ - } - - try { - IDataModel model = (IDataModel) cfg; - - // Create the source and the output directories. - - final IWorkspace ws = ResourcesPlugin.getWorkspace(); - - final IPath pjpath = project.getFullPath(); - IJavaProject jproject = null; - if( project.exists()){ - jproject = JavaCore.create(project); - } - - if( !jproject.exists()){ - String srcFolderName = model.getStringProperty(IJavaFacetInstallDataModelProperties.SOURCE_FOLDER_NAME); - final IPath srcdir = pjpath.append(srcFolderName); - - if( ! srcdir.equals( pjpath ) ) - { - ws.getRoot().getFolder(srcdir).getLocation().toFile().mkdirs(); - } - - String outputFolderName = model.getStringProperty(IJavaFacetInstallDataModelProperties.DEFAULT_OUTPUT_FOLDER_NAME); - final IPath outdir = pjpath.append(outputFolderName); - - if( ! outdir.equals( pjpath ) ) - { - ws.getRoot().getFolder(outdir).getLocation().toFile().mkdirs(); - } - - project.refreshLocal(IResource.DEPTH_INFINITE, null); - - // Add the java nature. This will automatically add the builder. - - final IProjectDescription desc = project.getDescription(); - final String[] current = desc.getNatureIds(); - final String[] replacement = new String[current.length + 1]; - System.arraycopy(current, 0, replacement, 0, current.length); - replacement[current.length] = JavaCore.NATURE_ID; - desc.setNatureIds(replacement); - project.setDescription(desc, null); - - // Set up the sourcepath and the output directory. - - final IJavaProject jproj = JavaCore.create(project); - final IClasspathEntry[] cp = {JavaCore.newSourceEntry(srcdir)}; - - jproj.setRawClasspath(cp, outdir, null); - jproj.save(null, true); - - // Setup the classpath. - - JavaFacetUtils.resetClasspath( project, null, fv ); - } - - // Set the compiler comliance level for the project. Ignore whether - // this might already be set so at the workspace level in case - // workspace settings change later or the project is included in a - // different workspace. - String oldCompilerLevel = JavaFacetUtils.getCompilerLevel(project); - JavaFacetUtils.setCompilerLevel(project, fv); - - String newCompilerLevel = JavaFacetUtils.getCompilerLevel(project); - - // Schedule a full build of the project if the compiler level changed - // because we want classes in the project to be recompiled. - if(newCompilerLevel != null && !newCompilerLevel.equals(oldCompilerLevel)) - JavaFacetUtils.scheduleFullBuild(project); - - if (monitor != null) { - monitor.worked(1); - } - } finally { - if (monitor != null) { - monitor.done(); - } - } - } - -} diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetRuntimeChangedDelegate.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetRuntimeChangedDelegate.java deleted file mode 100644 index 216c3a3f1..000000000 --- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetRuntimeChangedDelegate.java +++ /dev/null @@ -1,60 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005 BEA Systems, Inc. - * 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: - * Konstantin Komissarchik - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.common.project.facet; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.wst.common.project.facet.core.IDelegate; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; - -/** - * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a> - */ - -public final class JavaFacetRuntimeChangedDelegate - - implements IDelegate - -{ - public void execute( final IProject project, - final IProjectFacetVersion fv, - final Object cfg, - final IProgressMonitor monitor ) - - throws CoreException - - { - if( monitor != null ) - { - monitor.beginTask( "", 1 ); //$NON-NLS-1$ - } - - try - { - JavaFacetUtils.resetClasspath( project, fv, fv ); - - if( monitor != null ) - { - monitor.worked( 1 ); - } - } - finally - { - if( monitor != null ) - { - monitor.done(); - } - } - } - -} diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetUtils.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetUtils.java deleted file mode 100644 index 78e24f239..000000000 --- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetUtils.java +++ /dev/null @@ -1,331 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005, 2006 BEA Systems, Inc. - * 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: - * Konstantin Komissarchik - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.common.project.facet; - -import java.util.Collections; -import java.util.Hashtable; -import java.util.List; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.IncrementalProjectBuilder; -import org.eclipse.core.resources.ProjectScope; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Status; -import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.core.runtime.jobs.Job; -import org.eclipse.core.runtime.preferences.IEclipsePreferences; -import org.eclipse.core.runtime.preferences.IScopeContext; -import org.eclipse.core.runtime.preferences.InstanceScope; -import org.eclipse.jdt.core.IClasspathEntry; -import org.eclipse.jdt.core.IJavaProject; -import org.eclipse.jdt.core.JavaCore; -import org.eclipse.jdt.launching.IVMInstall; -import org.eclipse.jdt.launching.JavaRuntime; -import org.eclipse.jst.common.project.facet.core.ClasspathHelper; -import org.eclipse.osgi.util.NLS; -import org.eclipse.wst.common.componentcore.internal.util.IModuleConstants; -import org.eclipse.wst.common.project.facet.core.IProjectFacet; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; -import org.osgi.service.prefs.BackingStoreException; - -/** - * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a> - */ - -public final class JavaFacetUtils -{ - public static final IProjectFacet JAVA_FACET - = ProjectFacetsManager.getProjectFacet( IModuleConstants.JST_JAVA ); - - public static final IProjectFacetVersion JAVA_13 - = JAVA_FACET.getVersion( "1.3" ); //$NON-NLS-1$ - - public static final IProjectFacetVersion JAVA_14 - = JAVA_FACET.getVersion( "1.4" ); //$NON-NLS-1$ - - public static final IProjectFacetVersion JAVA_50 - = JAVA_FACET.getVersion( "5.0" ); //$NON-NLS-1$ - - public static final IProjectFacetVersion JAVA_60 - = JAVA_FACET.getVersion( "6.0" ); //$NON-NLS-1$ - - public static String getCompilerLevel() - { - final IScopeContext context = new InstanceScope(); - final IEclipsePreferences prefs = context.getNode( JavaCore.PLUGIN_ID ); - String level = prefs.get( JavaCore.COMPILER_COMPLIANCE, null ); - - if( level == null ) - { - final Hashtable defaults = JavaCore.getDefaultOptions(); - level = (String) defaults.get( JavaCore.COMPILER_COMPLIANCE ); - } - - return level; - } - - public static String getCompilerLevel( final IProject project ) - { - final IScopeContext context = new ProjectScope( project ); - final IEclipsePreferences prefs = context.getNode( JavaCore.PLUGIN_ID ); - String level = prefs.get( JavaCore.COMPILER_COMPLIANCE, null ); - - if( level == null ) - { - level = getCompilerLevel(); - } - - return level; - } - - public static void setCompilerLevel( final IProject project, - final IProjectFacetVersion fv ) - - throws CoreException - - { - setCompilerLevel( project, facetToCompilerLevel( fv ) ); - } - - public static void setCompilerLevel( final IProject project, - final String level ) - - throws CoreException - - { - final IScopeContext context = new ProjectScope( project ); - - final IEclipsePreferences prefs - = context.getNode( JavaCore.PLUGIN_ID ); - - if( level.equals( JavaCore.VERSION_1_3 ) ) - { - prefs.put( JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_3 ); - prefs.put( JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_1 ); - prefs.put( JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3 ); - prefs.put( JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.IGNORE ); - prefs.put( JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.IGNORE ); - } - else if( level.equals( JavaCore.VERSION_1_4 ) ) - { - prefs.put( JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_4 ); - prefs.put( JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_2 ); - prefs.put( JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_3 ); - prefs.put( JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.WARNING ); - prefs.put( JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.WARNING ); - } - else if( level.equals( JavaCore.VERSION_1_5 ) ) - { - prefs.put( JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5 ); - prefs.put( JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5 ); - prefs.put( JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5 ); - prefs.put( JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR ); - prefs.put( JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR ); - } - else if( level.equals( JavaCore.VERSION_1_6 ) ) - { - prefs.put( JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_6 ); - prefs.put( JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_6 ); - prefs.put( JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_6 ); - prefs.put( JavaCore.COMPILER_PB_ASSERT_IDENTIFIER, JavaCore.ERROR ); - prefs.put( JavaCore.COMPILER_PB_ENUM_IDENTIFIER, JavaCore.ERROR ); - } - else - { - throw new IllegalStateException(); - } - - try - { - prefs.flush(); - } - catch( BackingStoreException e ) - { - // TODO: Handle this. - } - } - - public static void scheduleFullBuild( final IProject project ) - { - // This code is modeled after the code in - // org.eclipse.jdt.internal.ui.util.CoreUtility.getBuildJob() method. - - final IWorkspace ws = ResourcesPlugin.getWorkspace(); - - final String msg - = NLS.bind( Resources.buildingMsg, project.getName() ); - - final Job buildJob = new Job( msg ) - { - public IStatus run( final IProgressMonitor monitor ) - { - monitor.beginTask( msg, 2 ); - - try - { - project.build( IncrementalProjectBuilder.FULL_BUILD, - new SubProgressMonitor( monitor, 1 ) ); - - ws.build( IncrementalProjectBuilder.INCREMENTAL_BUILD, - new SubProgressMonitor( monitor, 1 ) ); - - } - catch( CoreException e ) - { - return e.getStatus(); - } - finally - { - monitor.done(); - } - - return Status.OK_STATUS; - } - - public boolean belongsTo( final Object family ) - { - return family == ResourcesPlugin.FAMILY_MANUAL_BUILD; - } - }; - - buildJob.setRule( ws.getRuleFactory().buildRule() ); - buildJob.schedule(); - } - - public static void resetClasspath( final IProject project, - final IProjectFacetVersion oldver, - final IProjectFacetVersion newver ) - - throws CoreException - - { - if( oldver != null ) - { - ClasspathHelper.removeClasspathEntries( project, oldver ); - } - - // If this was a java project before it became a faceted project or - // the JRE container has been added manually, the above method will not - // delete the old JRE container. Do it manually. - - removeJreContainer( project ); - - if( ! ClasspathHelper.addClasspathEntries( project, newver ) ) - { - final IVMInstall vm = JavaRuntime.getDefaultVMInstall(); - - if( vm != null ) - { - IPath path = new Path( JavaRuntime.JRE_CONTAINER ); - path = path.append( vm.getVMInstallType().getId() ); - path = path.append( vm.getName() ); - - final IClasspathEntry cpe - = JavaCore.newContainerEntry( path ); - - final List entries = Collections.singletonList( cpe ); - - ClasspathHelper.addClasspathEntries( project, newver, entries ); - } - } - } - - private static void removeJreContainer( final IProject proj ) - - throws CoreException - - { - final IJavaProject jproj = JavaCore.create( proj ); - final IClasspathEntry[] cp = jproj.getRawClasspath(); - - int pos = -1; - - for( int i = 0; i < cp.length; i++ ) - { - final IClasspathEntry cpe = cp[ i ]; - - if( cpe.getEntryKind() == IClasspathEntry.CPE_CONTAINER && - cpe.getPath().segment( 0 ).equals( JavaRuntime.JRE_CONTAINER ) ) - { - pos = i; - break; - } - } - - if( pos == -1 ) - { - return; - } - - final IClasspathEntry[] newcp - = new IClasspathEntry[ cp.length - 1 ]; - - System.arraycopy( cp, 0, newcp, 0, pos ); - System.arraycopy( cp, pos + 1, newcp, pos, newcp.length - pos ); - - jproj.setRawClasspath( newcp, null ); - } - - public static IProjectFacetVersion compilerLevelToFacet( final String ver ) - { - if( ver.equals( "1.5" ) ) //$NON-NLS-1$ - { - return JavaFacetUtils.JAVA_50; - } - else if( ver.equals( "1.6" ) ) //$NON-NLS-1$ - { - return JavaFacetUtils.JAVA_60; - } - else - { - return JavaFacetUtils.JAVA_FACET.getVersion( ver ); - } - } - - public static String facetToCompilerLevel( final IProjectFacetVersion fv ) - { - if( fv == JAVA_50 ) - { - return JavaCore.VERSION_1_5; - } - else if( fv == JAVA_60 ) - { - return JavaCore.VERSION_1_6; - } - else - { - return fv.getVersionString(); - } - } - - private static final class Resources - - extends NLS - - { - public static String buildingMsg; - - static - { - initializeMessages( JavaFacetUtils.class.getName(), - Resources.class ); - } - } - -} diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetUtils.properties b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetUtils.properties deleted file mode 100644 index fcdd9de4a..000000000 --- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetUtils.properties +++ /dev/null @@ -1,11 +0,0 @@ -############################################################################### -# Copyright (c) 2005, 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 -############################################################################### -buildingMsg = Building Project {0}
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetValidator.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetValidator.java deleted file mode 100644 index b675b77e2..000000000 --- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetValidator.java +++ /dev/null @@ -1,71 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005 BEA Systems, Inc. - * 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: - * Konstantin Komissarchik - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.common.project.facet; - -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.osgi.util.NLS; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.IFacetedProjectValidator; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; - -/** - * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a> - */ - -public final class JavaFacetValidator - - implements IFacetedProjectValidator - -{ - public static final String MARKER_ID - = "org.eclipse.jst.common.frameworks.javaVersionMismatch"; //$NON-NLS-1$ - - public static final String ATTR_FACET_VERSION = "facetVersion"; //$NON-NLS-1$ - public static final String ATTR_COMPILER_LEVEL = "compilerLevel"; //$NON-NLS-1$ - - public void validate( final IFacetedProject fproj ) - - throws CoreException - - { - final String level - = JavaFacetUtils.getCompilerLevel( fproj.getProject() ); - - final IProjectFacetVersion fv - = fproj.getInstalledVersion( JavaFacetUtils.JAVA_FACET ); - - if( JavaFacetUtils.compilerLevelToFacet( level ) != fv ) - { - final IMarker marker - = fproj.createErrorMarker( MARKER_ID, Resources.versionsDontMatch ); - - marker.setAttribute( ATTR_FACET_VERSION, fv.getVersionString() ); - marker.setAttribute( ATTR_COMPILER_LEVEL, level ); - } - } - - private static final class Resources - - extends NLS - - { - public static String versionsDontMatch; - - static - { - initializeMessages( JavaFacetValidator.class.getName(), - Resources.class ); - } - } - -} diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetValidator.properties b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetValidator.properties deleted file mode 100644 index b2971f475..000000000 --- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetValidator.properties +++ /dev/null @@ -1,11 +0,0 @@ -############################################################################### -# Copyright (c) 2005, 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 -############################################################################### -versionsDontMatch = Java compiler level does not match the version of the installed Java project facet.
\ No newline at end of file diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetVersionChangeDelegate.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetVersionChangeDelegate.java deleted file mode 100644 index 27fba51b6..000000000 --- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaFacetVersionChangeDelegate.java +++ /dev/null @@ -1,80 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005 BEA Systems, Inc. - * 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: - * Konstantin Komissarchik - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.common.project.facet; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.wst.common.project.facet.core.IDelegate; -import org.eclipse.wst.common.project.facet.core.IFacetedProject; -import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion; -import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager; - -/** - * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a> - */ - -public final class JavaFacetVersionChangeDelegate - - implements IDelegate - -{ - public void execute( final IProject project, - final IProjectFacetVersion fv, - final Object cfg, - final IProgressMonitor monitor ) - - throws CoreException - - { - if( monitor != null ) - { - monitor.beginTask( "", 1 ); //$NON-NLS-1$ - } - - try - { - // Find the version that's currently installed. - - final IFacetedProject fproj - = ProjectFacetsManager.create( project ); - - final IProjectFacetVersion oldver - = fproj.getInstalledVersion( fv.getProjectFacet() ); - - // Reset the classpath. - - JavaFacetUtils.resetClasspath( project, oldver, fv ); - - // Reset the compiler level. - - JavaFacetUtils.setCompilerLevel( project, fv ); - - // Schedule a full build of the project. - - JavaFacetUtils.scheduleFullBuild( project ); - - if( monitor != null ) - { - monitor.worked( 1 ); - } - } - finally - { - if( monitor != null ) - { - monitor.done(); - } - } - } - -} diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaProjectFacetCreationDataModelProvider.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaProjectFacetCreationDataModelProvider.java deleted file mode 100644 index cef5b2d24..000000000 --- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/JavaProjectFacetCreationDataModelProvider.java +++ /dev/null @@ -1,32 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2003, 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.jst.common.project.facet; - -import java.util.ArrayList; -import java.util.Collection; - -import org.eclipse.wst.common.componentcore.datamodel.FacetProjectCreationDataModelProvider; - -public class JavaProjectFacetCreationDataModelProvider extends FacetProjectCreationDataModelProvider { - - public JavaProjectFacetCreationDataModelProvider() { - super(); - } - - public void init() { - super.init(); - - Collection requiredFacets = new ArrayList(); - requiredFacets.add(JavaFacetUtils.JAVA_FACET); - setProperty(REQUIRED_FACETS_COLLECTION, requiredFacets); - } - -} diff --git a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/WtpUtils.java b/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/WtpUtils.java deleted file mode 100644 index 0d05c4b26..000000000 --- a/plugins/org.eclipse.jst.common.frameworks/src/org/eclipse/jst/common/project/facet/WtpUtils.java +++ /dev/null @@ -1,70 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2005 BEA Systems, Inc. - * 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: - * Konstantin Komissarchik - initial API and implementation - ******************************************************************************/ - -package org.eclipse.jst.common.project.facet; - -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.jem.util.emf.workbench.ProjectUtilities; - -/** - * @author <a href="mailto:kosta@bea.com">Konstantin Komissarchik</a> - */ - -public final class WtpUtils -{ - private WtpUtils() {} - - private static final String WTP_NATURE - = "org.eclipse.wst.common.modulecore.ModuleCoreNature"; //$NON-NLS-1$ - - private static final String JEM_NATURE - = "org.eclipse.jem.workbench.JavaEMFNature"; //$NON-NLS-1$ - - public static void addNatures( final IProject project ) - - throws CoreException - - { - final IProjectDescription desc = project.getDescription(); - final String[] current = desc.getNatureIds(); - final String[] replacement = new String[ current.length + 2 ]; - System.arraycopy( current, 0, replacement, 0, current.length ); - replacement[ current.length ] = WTP_NATURE; - replacement[ current.length + 1 ] = JEM_NATURE; - desc.setNatureIds( replacement ); - project.setDescription( desc, null ); - } - - public static void addNaturestoEAR( final IProject project ) - - throws CoreException - - { - final IProjectDescription desc = project.getDescription(); - final String[] current = desc.getNatureIds(); - final String[] replacement = new String[ current.length + 1 ]; - System.arraycopy( current, 0, replacement, 0, current.length ); - replacement[ current.length ] = WTP_NATURE; - desc.setNatureIds( replacement ); - project.setDescription( desc, null ); - } - - public static void removeNatures( final IProject project ) - - throws CoreException - - { - ProjectUtilities.removeNatureFromProject( project, WTP_NATURE ); - ProjectUtilities.removeNatureFromProject( project, JEM_NATURE ); - } -} |