You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2009/07/13 15:26:06 UTC

svn commit: r793581 [14/23] - in /felix/trunk/sigil: ./ bld-ivy/ bld-ivy/example/ bld-ivy/example/dependence/ bld-ivy/example/dependence/dependee/ bld-ivy/example/dependence/dependee/src/ bld-ivy/example/dependence/dependee/src/standalone/ bld-ivy/exam...

Added: felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/model/util/JavaHelper.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/model/util/JavaHelper.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/model/util/JavaHelper.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/model/util/JavaHelper.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,985 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.sigil.model.util;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+import java.util.regex.Pattern;
+
+import org.cauldron.sigil.SigilCore;
+import org.cauldron.sigil.model.IModelElement;
+import org.cauldron.sigil.model.IModelWalker;
+import org.cauldron.sigil.model.ModelElementFactory;
+import org.cauldron.sigil.model.common.VersionRange;
+import org.cauldron.sigil.model.common.VersionRangeBoundingRule;
+import org.cauldron.sigil.model.eclipse.ISCAComposite;
+import org.cauldron.sigil.model.eclipse.ISigilBundle;
+import org.cauldron.sigil.model.osgi.IPackageExport;
+import org.cauldron.sigil.model.osgi.IPackageImport;
+import org.cauldron.sigil.model.osgi.IRequiredBundle;
+import org.cauldron.sigil.model.project.ISigilProjectModel;
+import org.cauldron.sigil.repository.IRepositoryManager;
+import org.cauldron.sigil.repository.IResolution;
+import org.cauldron.sigil.repository.ResolutionConfig;
+import org.cauldron.sigil.repository.ResolutionException;
+import org.cauldron.sigil.repository.ResolutionMonitorAdapter;
+import org.eclipse.core.resources.IFile;
+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.Platform;
+import org.eclipse.core.runtime.content.IContentDescription;
+import org.eclipse.core.runtime.content.IContentType;
+import org.eclipse.core.runtime.content.IContentTypeManager;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jdt.core.IAccessRule;
+import org.eclipse.jdt.core.IAnnotation;
+import org.eclipse.jdt.core.IClassFile;
+import org.eclipse.jdt.core.IClasspathAttribute;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IField;
+import org.eclipse.jdt.core.IImportDeclaration;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.ILocalVariable;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.IParent;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.ITypeHierarchy;
+import org.eclipse.jdt.core.ITypeRoot;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.Signature;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.osgi.framework.Version;
+
+/**
+ * @author dave
+ *
+ */
+public class JavaHelper {
+	
+	public static final IAccessRule DENY_RULE = JavaCore.newAccessRule(
+			new Path("**"), IAccessRule.K_NON_ACCESSIBLE
+					| IAccessRule.IGNORE_IF_BETTER);
+
+	public static final IAccessRule ALLOW_ALL_RULE = JavaCore.newAccessRule(
+			new Path("**"), IAccessRule.K_ACCESSIBLE);
+	
+	private static Map<String, Collection<IClasspathEntry>> entryCache = new HashMap<String, Collection<IClasspathEntry>>();
+	
+	public static Collection<IClasspathEntry> findClasspathEntries(ISigilBundle bundle) {
+		LinkedList<IClasspathEntry> cp = new LinkedList<IClasspathEntry>();
+		
+		ISigilProjectModel sp = bundle.getAncestor(ISigilProjectModel.class);
+		
+		if ( sp != null ) {
+			IJavaProject p = sp.getJavaModel();
+			
+			for ( String enc : bundle.getClasspathEntrys() ) {
+				IClasspathEntry e = p.decodeClasspathEntry(enc);
+				if ( e != null ) {
+					cp.add( e );
+				}
+			}
+		}
+		
+		return cp;
+	}
+	
+	public static Collection<ICompilationUnit> findCompilationUnits(ISigilProjectModel project) throws JavaModelException {
+		LinkedList<ICompilationUnit> ret = new LinkedList<ICompilationUnit>();
+		
+		IJavaProject java = project.getJavaModel();
+		for ( IClasspathEntry cp : findClasspathEntries(project.getBundle()) ) {
+			IPackageFragmentRoot[] roots = java.findPackageFragmentRoots(cp);
+			for (IPackageFragmentRoot rt : roots ) {
+				for ( IJavaElement j : rt.getChildren() ) {
+					IPackageFragment p = (IPackageFragment) j;
+					ICompilationUnit[] units = p.getCompilationUnits();
+					for ( ICompilationUnit u : units ) {
+						ret.add( u );
+					}
+				}
+			}
+		}
+		
+		return ret;
+	}
+	
+	/**
+	 * @param project 
+	 * @param packageName
+	 * @return
+	 */
+	public static Collection<IPackageExport> findExportsForPackage(ISigilProjectModel project, final String packageName) {
+		final LinkedList<IPackageExport> results = new LinkedList<IPackageExport>();
+		
+		SigilCore.getRepositoryManager(project).visit(new IModelWalker() {
+			public boolean visit(IModelElement element) {
+				if ( element instanceof IPackageExport ) {
+					IPackageExport e = (IPackageExport) element;
+					if ( e.getPackageName().equals( packageName ) ) {
+						results.add( e );
+					}
+				}				
+				return true;
+			}
+		});
+
+		return results;
+	}
+	
+	public static String[] findUses(String packageName, ISigilProjectModel projectModel) throws CoreException {
+		ArrayList<String> uses = new ArrayList<String>();
+		
+		for ( final String dependency : findPackageDependencies( packageName, projectModel ) ) {
+			if ( !dependency.equals( packageName ) ) {
+				final boolean[] found = new boolean[1];
+				
+				projectModel.visit( new IModelWalker() {
+	
+					public boolean visit(IModelElement element) {
+						if ( element instanceof IPackageImport ) {
+							IPackageImport pi = (IPackageImport) element;
+							if ( pi.getPackageName().equals( dependency ) ) {
+								found[0] = true;
+							}
+						}
+						return !found[0];
+					}				
+				} );
+				
+				if ( found[0] ) {
+					uses.add( dependency );
+				}
+			}
+		}
+		
+		return uses.toArray( new String[uses.size()] );
+	}
+	
+	private static String[] findPackageDependencies(String packageName, ISigilProjectModel projectModel) throws CoreException {
+		HashSet<String> imports = new HashSet<String>();
+
+		IPackageFragment p = (IPackageFragment) projectModel.getJavaModel().findElement( new Path(packageName.replace('.', '/') ) );
+
+		if ( p == null ) {
+			throw SigilCore.newCoreException("Unknown package " + packageName, null);
+		}
+		for (ICompilationUnit cu : p.getCompilationUnits() ) {
+			scanImports(cu, imports);
+		}
+		for (IClassFile cf : p.getClassFiles() ) {
+			scanImports(cf, imports);
+		}
+		
+		return imports.toArray( new String[imports.size()] );		
+	}
+
+	/**
+	 * @param project
+	 * @param monitor
+	 * @return
+	 */
+	public static List<IPackageImport> findRequiredImports(ISigilProjectModel project, IProgressMonitor monitor) {
+		LinkedList<IPackageImport> imports = new LinkedList<IPackageImport>();
+		
+		for ( String packageName : findJavaImports(project, monitor)) {
+			if ( !ProfileManager.isBootDelegate(project, packageName) ) { // these must come from boot classloader
+				try {
+					if ( !project.isInClasspath(packageName, monitor) ) {
+						Collection<IPackageExport> exports = findExportsForPackage(project, packageName);
+						if ( !exports.isEmpty() ) {
+							imports.add( select( exports ) );
+						}
+					}
+				} catch (CoreException e) {
+					SigilCore.error( "Failed to check classpath", e );
+				}
+			}
+		}
+		
+		return imports;
+	}
+	
+	/**
+	 * @param project
+	 * @param monitor
+	 * @return
+	 */
+	public static Collection<IModelElement> findUnusedReferences(final ISigilProjectModel project, final IProgressMonitor monitor) {
+		final LinkedList<IModelElement> unused = new LinkedList<IModelElement>();
+		
+		final Set<String> packages = findJavaImports(project, monitor);
+		
+		project.visit( new IModelWalker() {
+			public boolean visit(IModelElement element) {
+				if ( element instanceof IPackageImport ) {
+					IPackageImport pi = (IPackageImport) element;
+					if ( !packages.contains( pi.getPackageName() ) ) {
+						unused.add( pi );
+					}
+				}
+				else if ( element instanceof IRequiredBundle ) {
+					IRequiredBundle rb = (IRequiredBundle) element;
+					IRepositoryManager manager = SigilCore.getRepositoryManager(project);
+					ResolutionConfig config = new ResolutionConfig(ResolutionConfig.INCLUDE_OPTIONAL | ResolutionConfig.IGNORE_ERRORS);
+					try {
+						IResolution r = manager.getBundleResolver().resolve(rb, config ,
+								new ResolutionMonitorAdapter(monitor) );
+						ISigilBundle bundle = r.getProvider(rb);
+						boolean found = false;
+						for ( IPackageExport pe : bundle.getBundleInfo().getExports() ) {
+							if ( packages.contains(pe.getPackageName() ) ) {
+								found = true;
+								break;
+							}
+						}
+						
+						if ( !found ) {
+							unused.add( rb );
+						}
+					} catch (ResolutionException e) {
+						SigilCore.error( "Failed to resolve " + rb, e );
+					}
+				}
+				return true;
+			}
+		});
+		
+		return unused;
+	}
+	
+	public static Collection<IClasspathEntry> resolveClasspathEntrys(ISigilProjectModel sigil, IProgressMonitor monitor)
+	throws CoreException {
+		if ( monitor == null ) {
+			monitor = Job.getJobManager().createProgressGroup();
+			monitor.beginTask("Resolving classpath for "
+					+ sigil.getSymbolicName(), 2);
+		}
+
+		ArrayList<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
+
+		ResolutionConfig config = new ResolutionConfig(ResolutionConfig.INCLUDE_OPTIONAL | ResolutionConfig.IGNORE_ERRORS | ResolutionConfig.INDEXED_ONLY | ResolutionConfig.LOCAL_ONLY);
+
+		IResolution resolution;
+		try {
+			resolution = SigilCore.getRepositoryManager(sigil).getBundleResolver().resolve(sigil, config, new ResolutionMonitorAdapter(monitor));
+		} catch (ResolutionException e) {
+			throw SigilCore.newCoreException("Failed to resolve dependencies", e);
+		}
+
+		monitor.worked(1);
+
+		for (ISigilBundle bundle : resolution.getBundles()) {
+			if (!bundle.getBundleInfo().getSymbolicName().equals(sigil.getSymbolicName())) { // discard self reference...
+				List<IModelElement> matched = resolution.getMatchedRequirements(bundle);
+				for (IClasspathEntry cpe : buildClassPathEntry(sigil, bundle, matched, monitor)) {
+					entries.add(cpe);
+				}
+			}
+		}
+
+		monitor.worked(1);
+		monitor.done();
+
+		return entries;
+	}
+
+	private static Collection<IClasspathEntry> buildClassPathEntry(ISigilProjectModel project, ISigilBundle provider, List<IModelElement> requirements, IProgressMonitor monitor) throws CoreException {
+		IAccessRule[] rules = buildAccessRules(project, provider, requirements);
+
+		ISigilProjectModel other = provider.getAncestor(ISigilProjectModel.class);
+
+		try {
+			if (other == null) {
+				provider.synchronize(monitor);
+				return newBundleEntry(provider, rules, null, false);
+			} else {
+				return newProjectEntry(other, rules, null, false);
+			}
+		} catch (IOException e) {
+			throw SigilCore.newCoreException("Failed to synchronize " + provider, e);
+		}
+	}
+
+	private static IAccessRule[] buildExportRules(ISigilBundle bundle) {
+		Set<IPackageExport> ex = bundle.getBundleInfo().getExports();
+		IAccessRule[] rules = new IAccessRule[ex.size() + 1];
+
+		Iterator<IPackageExport> iter = ex.iterator();
+		for (int i = 0; i < rules.length - 1; i++) {
+			IPackageExport p = iter.next();
+			rules[i] = JavaCore.newAccessRule(new Path(p.getPackageName()
+					.replace('.', '/')).append("*"), IAccessRule.K_ACCESSIBLE);
+		}
+
+		rules[rules.length - 1] = DENY_RULE;
+
+		return rules;
+	}
+
+	private static Collection<IClasspathEntry> newProjectEntry(
+			ISigilProjectModel n, IAccessRule[] rules,
+			IClasspathAttribute[] attributes, boolean export)
+			throws CoreException {
+		if (rules == null) {
+			rules = JavaHelper.buildExportRules(n.getBundle());
+		}
+
+		if (attributes == null) {
+			attributes = new IClasspathAttribute[] {};
+		}
+
+		ArrayList<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
+		entries.add(JavaCore.newProjectEntry(n.getProject().getFullPath(),
+				rules, false, attributes, export));
+		for (IClasspathEntry e : n.getJavaModel().getRawClasspath()) {
+			switch (e.getEntryKind()) {
+			case IClasspathEntry.CPE_LIBRARY:
+				entries.add(JavaCore.newLibraryEntry(e.getPath(), e
+						.getSourceAttachmentPath(), e
+						.getSourceAttachmentRootPath(), rules, attributes,
+						export));
+				break;
+			case IClasspathEntry.CPE_VARIABLE:
+				IPath path = JavaCore.getResolvedVariablePath(e.getPath());
+				if (path != null) {
+					entries.add(JavaCore.newLibraryEntry(path, e
+							.getSourceAttachmentPath(), e
+							.getSourceAttachmentRootPath(), rules, attributes,
+							export));
+				}
+				break;
+			}
+		}
+
+		return entries;
+	}
+
+	private static Collection<IClasspathEntry> newBundleEntry(
+			ISigilBundle bundle, IAccessRule[] rules,
+			IClasspathAttribute[] attributes, boolean exported)
+			throws CoreException {
+		String name = bundle.getBundleInfo().getSymbolicName();
+
+		if (rules == null) {
+			rules = JavaHelper.buildExportRules(bundle);
+		}
+
+		if (attributes == null) {
+			attributes = new IClasspathAttribute[] {};
+		}
+
+		if (bundle.getBundleInfo().getVersion() != null) {
+			name += "_version_" + bundle.getBundleInfo().getVersion();
+		}
+
+		String cacheName = name + rules.toString();
+
+		Collection<IClasspathEntry> entries = null;
+		
+		synchronized( entryCache ) {
+			entries = entryCache.get(cacheName);
+	
+			if (entries == null) {
+				IPath path = bundle.getLocation();
+	
+				if (path == null) {
+					SigilCore.error("Found null path for "
+							+ bundle.getBundleInfo().getSymbolicName());
+					entries = Collections.emptyList();
+				} else {
+					entries = buildEntries(path, name, bundle, rules, attributes,
+							exported);
+				}
+	
+				entryCache.put(cacheName, entries);
+			}
+		}
+		
+		return entries;
+	}
+
+	private static IPath bundleCache = SigilCore.getDefault().getStateLocation().append(
+			"bundle-cache");
+	
+	public static boolean isCachedBundle(String bp) {
+		return bp.startsWith(bundleCache.toOSString());
+	}
+
+	private static Collection<IClasspathEntry> buildEntries(IPath path,
+			String name, ISigilBundle bundle, IAccessRule[] rules,
+			IClasspathAttribute[] attributes, boolean exported)
+			throws CoreException {
+		if (path.toFile().isDirectory()) {
+			throw SigilCore.newCoreException("Bundle location cannot be a directory",
+					null);
+		} else {
+			// ok it's a jar could contain libs etc
+			try {
+				IPath cache = bundleCache.append(name);
+				Set<String> files = unpack(cache, bundle);
+				Set<String> classpath = filterClasspath(bundle.getBundleInfo().getClasspaths(), files);
+				ArrayList<IClasspathEntry> entries = new ArrayList<IClasspathEntry>(
+						classpath.size());
+
+				for (String cp : classpath) {
+					IPath p = ".".equals(cp) ? path : cache.append(cp);
+					IPath source = bundle.getSourcePathLocation();
+
+					if (source != null && !source.toFile().exists()) {
+						source = null;
+					}
+
+					IClasspathEntry e = JavaCore.newLibraryEntry(p, source,
+							bundle.getSourceRootPath(), rules, attributes,
+							exported);
+					entries.add(e);
+				}
+
+				return entries;
+			} catch (IOException e) {
+				throw SigilCore.newCoreException("Failed to unpack bundle", e);
+			}
+		}
+	}
+
+	private static Set<String> filterClasspath(Collection<String> classpaths,
+			Collection<String> files) {
+		HashSet<String> cp = new HashSet<String>(classpaths);
+		for (String c : cp) {
+			if (".".equals(c)) {
+				// ignore
+			} else {
+				if (!files.remove(c)) {
+					break;
+				}
+			}
+		}
+
+		if (files.isEmpty()) {
+			cp.remove(".");
+		}
+
+		return cp;
+	}
+
+	private static HashMap<IPath, Set<String>> unpacked = new HashMap<IPath, Set<String>>();
+	
+	private static synchronized Set<String> unpack(IPath cache,
+			ISigilBundle bundle) throws IOException {
+		Set<String> files = unpacked.get(cache);
+
+		if ( files == null ) {
+			files = new HashSet<String>();
+			File dir = createEmptyDir(cache);
+			JarInputStream in = new JarInputStream(new FileInputStream(bundle
+					.getLocation().toFile()));
+			JarEntry entry;
+			while ((entry = in.getNextJarEntry()) != null) {
+				File f = new File(dir, entry.getName());
+				if (entry.isDirectory()) {
+					createDir(f);
+				} else {
+					try {
+						File p = f.getParentFile();
+						createDir(p);
+						streamTo(in, f);
+						files.add(entry.getName());
+					}
+					catch (RuntimeException e) {
+						SigilCore.error("Failed to unpack " + entry, e);
+					}
+				}
+			}
+			
+			unpacked.put(cache, files);
+		}
+		return files;
+	}
+
+	private static void createDir(File p) throws IOException {
+		if (!p.exists()) {
+			if (!p.mkdirs())
+				throw new IOException("Failed to create directory " + p);
+		}
+	}
+
+	private static void streamTo(InputStream in, File f) throws IOException {
+		FileOutputStream fos = new FileOutputStream(f);
+		try {
+			byte[] buf = new byte[1024];
+			for (;;) {
+				int r = in.read(buf);
+
+				if (r == -1)
+					break;
+
+				fos.write(buf, 0, r);
+			}
+
+			fos.flush();
+		} finally {
+			try {
+				fos.close();
+			} catch (IOException e) {
+				SigilCore.error("Failed to close stream", e);
+			}
+		}
+	}
+
+	private static File createEmptyDir(IPath cache) {
+		File dir = cache.toFile();
+		if (dir.exists()) {
+			deleteAll(dir);
+		}
+
+		dir.mkdirs();
+		return dir;
+	}
+
+	private static void deleteAll(File file) {
+		File[] sub = file.listFiles();
+		if (sub != null) {
+			for (File f : sub) {
+				deleteAll(f);
+			}
+		}
+		file.delete();
+	}
+
+	private static IAccessRule[] buildAccessRules(ISigilProjectModel project, ISigilBundle bundle, List<IModelElement> requirements) throws JavaModelException {
+		ArrayList<IAccessRule> rules = new ArrayList<IAccessRule>();
+
+		for (IModelElement e : requirements) {
+			if (e instanceof IRequiredBundle) {
+				IRequiredBundle host = project.getBundle().getBundleInfo().getFragmentHost();
+				if ( host != null ) {
+					if ( host.equals(e) ) {
+						return new IAccessRule[] { ALLOW_ALL_RULE };
+					}
+					else {
+						return buildExportRules(bundle);
+					}
+				}
+				else {
+					return buildExportRules(bundle);
+				}
+			} else if (e instanceof IPackageImport) {
+				IPackageImport pi = (IPackageImport) e;
+				String pckg = pi.getPackageName();
+				HashSet<String> pckgs = new HashSet<String>();
+				pckgs.add(pckg);
+				//findIndirectReferences(pckgs, pckg, project.getJavaModel(), project.getJavaModel());
+				
+				for ( String p : pckgs ) {
+					rules.add(newPackageAccess(p));
+				}
+			}
+		}
+
+		rules.add(DENY_RULE);
+
+		return rules.toArray(new IAccessRule[rules.size()]);
+	}
+
+	/*
+	 * Searches for C (and D, E, etc) in case:
+	 * A extends B extends C where A, B and C are in different packages and A is in this bundle
+	 * and B and C are in one or more external bundles
+	 */
+	private static void findIndirectReferences(Set<String> indirect, String pckg, IParent parent, IJavaProject p) throws JavaModelException {
+		for  ( IJavaElement e : parent.getChildren() ) {
+			boolean skip = false;
+			switch ( e.getElementType() ) {
+			case IJavaElement.PACKAGE_FRAGMENT_ROOT:
+				IPackageFragmentRoot rt = (IPackageFragmentRoot) e;
+				IClasspathEntry ce = rt.getRawClasspathEntry();
+				IPath path = ce.getPath();
+				skip = "org.eclipse.jdt.launching.JRE_CONTAINER".equals(path.toString());
+				break;
+			case IJavaElement.CLASS_FILE:
+				IClassFile cf = (IClassFile) e;
+				if ( cf.getElementName().startsWith(pckg) ) {
+					findIndirectReferences(indirect, findPackage(cf.getType().getSuperclassName()), p, p);
+				}
+				break;
+			case IJavaElement.COMPILATION_UNIT:
+				ICompilationUnit cu = (ICompilationUnit) e;
+				break;
+			}
+			
+			if ( !skip && e instanceof IParent ) {
+				IParent newParent = (IParent) e;
+				findIndirectReferences(indirect, pckg, newParent, p);
+			}
+		}
+	}
+	
+	private static IAccessRule newPackageAccess(String packageName) {
+		return JavaCore.newAccessRule(new Path(packageName.replace('.', '/'))
+				.append("*"), IAccessRule.K_ACCESSIBLE);
+	}
+
+	private static Set<String> findJavaImports(ISigilProjectModel project, IProgressMonitor monitor) {
+		Set<String> imports = new HashSet<String>();
+		
+		findJavaModelImports(project, imports, monitor);
+		findSCAImports(project, imports, monitor);
+		findTextImports(project, imports, monitor);
+		
+		return imports;
+	}
+	
+	private static void findSCAImports(ISigilProjectModel project, Set<String> imports, IProgressMonitor monitor) {
+		for ( ISCAComposite sca : project.getBundle().getComposites() ) {
+			IFile f = project.getProject().getFile(sca.getLocation());
+			if ( f.exists() ) {
+				try {
+					// TODO for now just treats sca as text files - should build in richer model that is able to detect java elements
+					parseText( f, imports );
+				} catch (CoreException e) {
+					SigilCore.error( "Failed to parse sca file " + f, e );
+				}
+			}
+		}
+	}
+
+	private static void findTextImports(ISigilProjectModel project, Set<String> imports, IProgressMonitor monitor) {
+		IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
+		IContentType txt = contentTypeManager.getContentType("org.eclipse.core.runtime.text");
+		for ( IPath p : project.getBundle().getSourcePaths() ) {
+			IFile f = project.getProject().getFile(p);
+			if ( f.exists() ) {
+				try {
+					IContentDescription desc = f.getContentDescription();
+					if ( desc != null ) {
+						IContentType type = desc.getContentType();
+						if ( type != null ) {
+							if ( type.isKindOf( txt ) ) {
+								parseText( f, imports );
+							}
+						}
+					}
+				} catch (CoreException e) {
+					SigilCore.error( "Failed to parse text file " + f, e );
+				}
+			}
+		}
+	}
+
+	private static void findJavaModelImports(ISigilProjectModel project, Set<String> imports, IProgressMonitor monitor) {
+		try {
+			for ( IPackageFragment root : project.getJavaModel().getPackageFragments() ) {
+				IPackageFragmentRoot rt = (IPackageFragmentRoot) root.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
+				
+				if ( isInClassPath( project, rt ) ) {
+					for ( ICompilationUnit cu : root.getCompilationUnits() ) {
+						scanImports( cu, imports );
+					}
+					
+					for ( IClassFile cf : root.getClassFiles() ) {
+						scanImports( cf, imports );
+					}
+				}
+			}
+		} catch (JavaModelException e) {
+			SigilCore.error( "Failed to parse java model", e );
+		}
+	}
+
+	// matches word.word.word.word.Word
+	private static final Pattern JAVA_CLASS_PATTERN = Pattern.compile("((\\w*\\.\\w*)+?)\\.[A-Z]\\w*");
+	
+	private static void parseText(IFile f, Set<String> imports) throws CoreException {
+		for ( String result : Grep.grep( JAVA_CLASS_PATTERN, f) ) {
+			findImport(result, imports);
+		}
+	}
+
+	private static boolean isInClassPath(ISigilProjectModel project, IPackageFragmentRoot rt) throws JavaModelException {
+		String path = encode( project, rt.getRawClasspathEntry() );
+		return project.getBundle().getClasspathEntrys().contains( path );
+	}
+
+	private static String encode(ISigilProjectModel project, IClasspathEntry cp) {
+		return project.getJavaModel().encodeClasspathEntry(cp).trim();
+	}
+	
+	private static void scanImports(IParent parent, Set<String> imports) throws JavaModelException {
+		for ( IJavaElement e : parent.getChildren() ) {
+			switch ( e.getElementType() ) {
+			case IJavaElement.TYPE:
+				handleType( (IType) e, imports );
+				break;
+			case IJavaElement.IMPORT_DECLARATION:
+				handleImport( (IImportDeclaration) e, imports );
+				break;
+			case IJavaElement.FIELD:
+				handleField( (IField) e, imports );
+				break;
+			case IJavaElement.LOCAL_VARIABLE:
+				handleLocalVariable( (ILocalVariable) e, imports );
+				break;
+			case IJavaElement.ANNOTATION:
+				handleAnnotation( (IAnnotation) e, imports );
+				break;
+			case IJavaElement.METHOD:
+				handleMethod( (IMethod) e, imports );
+				break;
+			default:
+				// no action
+				break;
+			}
+			
+			if ( e instanceof IParent ) {
+				scanImports((IParent) e, imports);
+			}
+		}
+	}
+
+	private static void handleType(IType e, Set<String> imports) throws JavaModelException {
+		findImportFromType(e.getSuperclassTypeSignature(), imports);
+		for ( String sig : e.getSuperInterfaceTypeSignatures() ) {
+			findImportFromType(sig, imports);
+		}
+		//findImportsForSuperTypes(e, imports);
+	}
+	
+	/*private static void findImportsForSuperTypes(IType e, Set<String> imports) throws JavaModelException {
+		IJavaProject project = (IJavaProject) e.getAncestor(IJavaModel.JAVA_PROJECT);
+		LinkedList<String> types = new LinkedList<String>();
+		types.add( decodeSignature(e.getSuperclassTypeSignature()) );
+		for ( String sig : e.getSuperInterfaceTypeSignatures() ) {
+			types.add( decodeSignature(sig) );
+		}
+		
+		for ( IPackageFragmentRoot root : project.getPackageFragmentRoots() ) {
+			// only need to search binary files for inheritance as source will automatically be searched
+			if ( root.getKind() == IPackageFragmentRoot.K_BINARY ) {
+				for ( String t : types ) {
+					String pac = findPackage(t);
+					if ( pac != null ) {
+						IPackageFragment fragment = root.getPackageFragment(pac);
+						if ( fragment != null ) {
+							IClassFile c = fragment.getClassFile(findClass(t));
+							if ( c != null ) {
+								findImportsForSuperTypes(c.getType(), imports);
+							}
+						}
+					}
+				}
+			}
+		}
+	} */
+	
+	private static void handleMethod(IMethod e, Set<String> imports) throws JavaModelException {
+		findImportFromType(e.getReturnType(), imports);
+		
+		for ( String param : e.getParameterTypes() ) {
+			findImportFromType(param, imports);
+		}
+		
+		for ( String ex : e.getExceptionTypes() ) {
+			findImportFromType( ex, imports );
+		}
+	}
+
+	private static void handleAnnotation(IAnnotation e, Set<String> imports) {
+		findImport(e.getElementName(), imports);
+	}
+
+	private static void handleLocalVariable(ILocalVariable e, Set<String> imports) {
+		findImportFromType(e.getTypeSignature(), imports);
+	}
+
+	private static void handleField(IField e, Set<String> imports) throws IllegalArgumentException, JavaModelException {
+		findImportFromType(Signature.getElementType(e.getTypeSignature()), imports);
+	}
+
+	private static void handleImport(IImportDeclaration id, Set<String> imports) {
+		findImport( id.getElementName(), imports);
+	}
+
+	private static void findImportFromType(String type, Set<String> imports) {
+		String element = decodeSignature(type);
+		findImport(element, imports);
+	}
+
+	private static String decodeSignature(String type) {
+		return decodeSignature(type, false);
+	}
+	
+	private static String decodeSignature(String type, boolean resolve) {
+		if ( type == null ) {
+			return null;
+		}
+		
+		if ( type.length() > 0 ) {
+			switch ( type.charAt(0) ) {
+			case Signature.C_ARRAY:
+				return decodeSignature(type.substring(1) );
+			case Signature.C_UNRESOLVED:
+				return resolve ? resolve( type.substring(1, type.length() - 1) ) : null;
+			case Signature.C_RESOLVED:
+				return type.substring(1);
+			}
+		}
+		return type;
+	}
+
+	private static String resolve(String substring) {
+		// TODO Auto-generated method stub
+		return null;
+	}
+	
+	private static void findImport(String clazz, Set<String> imports) {
+		String packageName = findPackage(clazz);
+		if ( packageName != null ) {
+			imports.add(packageName);
+		}
+	}
+	
+	private static String findPackage(String clazz) {
+		if ( clazz == null ) return null;
+		int pos = clazz.lastIndexOf( '.' );
+		return pos == -1 ? null : clazz.substring(0, pos);
+	}
+
+	private static String findClass(String clazz) {
+		if ( clazz == null ) return null;
+		int pos = clazz.lastIndexOf( '.' );
+		return pos == -1 ? null : clazz.substring(pos + 1);
+	}
+	
+	private static IPackageImport select(Collection<IPackageExport> proposals) {
+		IPackageExport pe = null;
+		
+		for ( IPackageExport check : proposals ) {
+			if ( pe == null || check.getVersion().compareTo( pe.getVersion() ) > 0 ) {
+				pe = check;
+			}
+		}
+		
+		String packageName = pe.getPackageName();
+		
+		IPreferenceStore store = SigilCore.getDefault().getPreferenceStore();
+		VersionRangeBoundingRule lowerBoundRule = VersionRangeBoundingRule.valueOf(store.getString(SigilCore.DEFAULT_VERSION_LOWER_BOUND));
+		VersionRangeBoundingRule upperBoundRule = VersionRangeBoundingRule.valueOf(store.getString(SigilCore.DEFAULT_VERSION_UPPER_BOUND));
+
+		Version version = pe.getVersion();
+		VersionRange versions = VersionRange.newInstance(version, lowerBoundRule, upperBoundRule);
+		
+		IPackageImport pi = ModelElementFactory.getInstance().newModelElement(IPackageImport.class);
+		pi.setPackageName(packageName);
+		pi.setVersions(versions);
+		
+		return pi;
+	}
+
+	public static Iterable<IJavaElement> findTypes(IParent parent, int... type) throws JavaModelException {
+		LinkedList<IJavaElement> found = new LinkedList<IJavaElement>();
+		scanForElement(parent, type, found, false);
+		return found;
+	}
+	
+	public static IJavaElement findType(IParent parent, int... type) throws JavaModelException {
+		LinkedList<IJavaElement> found = new LinkedList<IJavaElement>();
+		scanForElement(parent, type, found, true);
+		return found.isEmpty() ? null : found.getFirst();
+	}
+
+	private static void scanForElement(IParent parent, int[] type, List<IJavaElement> roots, boolean thereCanBeOnlyOne) throws JavaModelException {
+		for ( IJavaElement e : parent.getChildren() ) {
+			if ( isType(type, e) ) {
+				roots.add( e );
+				if ( thereCanBeOnlyOne ) {
+					break;
+				}
+			}
+			else if ( e instanceof IParent ) {
+				scanForElement( (IParent) e, type, roots, thereCanBeOnlyOne );
+			}
+		}
+	}
+
+	private static boolean isType(int[] type, IJavaElement e) {
+		for ( int i : type ) {
+			if ( i == e.getElementType() ) {
+				return true;
+			}
+		}
+		return false;
+	}
+
+	public static boolean isAssignableTo(String ifaceOrParentClass, IType type) throws JavaModelException {
+		if ( ifaceOrParentClass == null ) return true;
+		
+		ITypeHierarchy h = type.newSupertypeHierarchy(null);
+		
+		for ( IType superType : h.getAllClasses() ) {
+			String name = superType.getFullyQualifiedName();
+			if ( name.equals( ifaceOrParentClass ) ) {
+				return true;
+			}
+		}
+		for ( IType ifaceType : h.getAllInterfaces() ) {
+			String name = ifaceType.getFullyQualifiedName();
+			if ( name.equals( ifaceOrParentClass ) ) {
+				return true;
+			}
+		}
+		
+		return false;
+	}
+
+	private static IType findType(ITypeRoot root) throws JavaModelException {
+		// TODO Auto-generated method stub
+		for ( IJavaElement child : root.getChildren() ) {
+			if ( child.getElementType() == IJavaElement.TYPE ) {
+				return (IType) child;
+			}
+		}
+		
+		throw new JavaModelException( new IllegalStateException( "Missing type for " + root) , IStatus.ERROR );
+	}
+}

Added: felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/model/util/ModelHelper.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/model/util/ModelHelper.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/model/util/ModelHelper.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/model/util/ModelHelper.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.sigil.model.util;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import org.cauldron.sigil.SigilCore;
+import org.cauldron.sigil.model.ICompoundModelElement;
+import org.cauldron.sigil.model.IModelElement;
+import org.cauldron.sigil.model.IModelWalker;
+import org.cauldron.sigil.model.osgi.IBundleModelElement;
+import org.cauldron.sigil.model.osgi.IPackageExport;
+import org.cauldron.sigil.model.osgi.IPackageImport;
+import org.cauldron.sigil.model.osgi.IRequiredBundle;
+
+public class ModelHelper {
+	public static List<IModelElement> findUsers(IModelElement e) {
+		LinkedList<IModelElement> users = new LinkedList<IModelElement>();
+		
+		findUsers(e, users);
+		
+		return users;
+	}
+
+	private static void findUsers(IModelElement e, final LinkedList<IModelElement> users) {
+		if ( e instanceof IPackageExport ) {
+			final IPackageExport pe = (IPackageExport) e;
+			SigilCore.getGlobalRepositoryManager().visit( new IModelWalker() {
+				public boolean visit(IModelElement element) {
+					if ( element instanceof IPackageImport ) {
+						IPackageImport pi = (IPackageImport) element;
+						if ( pi.accepts( pe ) ) {
+							users.add( pi );
+						}
+						return false;
+					}
+					
+					return true;
+				} 
+			} );
+		}
+		else if ( e instanceof IBundleModelElement ) {
+			final IBundleModelElement bndl = (IBundleModelElement) e;
+			
+			SigilCore.getGlobalRepositoryManager().visit( new IModelWalker() {
+				public boolean visit(IModelElement element) {
+					if ( element instanceof IRequiredBundle ) {
+						IRequiredBundle req = (IRequiredBundle) element;
+						if ( req.accepts( bndl ) ) {
+							users.add( req );
+						}
+						return false;
+					}
+					return true;
+				} 
+			} );
+		}
+		
+		if ( e instanceof ICompoundModelElement ) {
+			ICompoundModelElement c = (ICompoundModelElement) e;
+			IModelElement[] ch = c.children();
+			for ( IModelElement ee : ch ) {
+				findUsers( ee, users );
+			}
+		}
+	}
+
+}

Added: felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/model/util/ProfileManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/model/util/ProfileManager.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/model/util/ProfileManager.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/model/util/ProfileManager.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,161 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.sigil.model.util;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.regex.Pattern;
+
+import org.cauldron.sigil.SigilCore;
+import org.cauldron.sigil.model.project.ISigilProjectModel;
+import org.cauldron.sigil.utils.GlobCompiler;
+import org.eclipse.core.runtime.Platform;
+import org.osgi.framework.Bundle;
+
+public class ProfileManager {
+	private static final Pattern[] BOOT_DELEGATION_PATTERNS = new Pattern[] {
+		GlobCompiler.compile("org.ietf.jgss"),
+		GlobCompiler.compile("org.omg.*"),
+		GlobCompiler.compile("org.w3c.*"),
+		GlobCompiler.compile("org.xml.*"),
+		GlobCompiler.compile("sun.*"),
+		GlobCompiler.compile("com.sun.*"),
+	};
+	
+	private static HashMap<String, Properties> profiles;
+
+	public static boolean isBootDelegate(ISigilProjectModel project, String packageName) {
+		if ( packageName.startsWith( "java." ) ) {
+			return true;
+		}
+		
+		for ( Pattern p : BOOT_DELEGATION_PATTERNS ) {
+			if ( p.matcher(packageName).matches()) {
+				return true;
+			}
+		}
+		return false;
+	}
+	
+	public static Properties findProfileForVersion(String javaVersion) {
+		Map<String, Properties> profiles = loadProfiles();
+		
+		if ( "1.5.0".equals( javaVersion ) ) {
+			return profiles.get( "J2SE-1.5" );
+		}
+		else if ( "1.6.0".equals( javaVersion ) ) {
+			return profiles.get( "J2SE-1.6" );
+		}
+		
+		return null;
+	}
+	
+	private synchronized static Map<String, Properties> loadProfiles() {
+		if ( profiles == null ) {
+			profiles = new HashMap<String, Properties>();
+			
+			Bundle b = Platform.getBundle("org.eclipse.osgi");
+			
+			for ( String profile : loadProfiles( b )) {
+				if ( profile.trim().length() > 0 ) {
+					URL url = findURL(profile, b);
+					if ( url != null ) {
+						try {
+							Properties p = loadProperties(url);
+							String name = p.getProperty("osgi.java.profile.name");
+							if ( name != null ) {
+								profiles.put(name, p);
+							}
+							else {
+								SigilCore.error( "Invalid profile definition, no name specified: " + url);
+							}
+						} catch (IOException e) {
+							SigilCore.error( "Failed to load java profile", e );
+						}
+					}
+					else {
+						SigilCore.error( "Unknown profile **" + profile + "**" );
+					}
+				}
+				// else ignore empty values
+			}
+		}
+		return profiles;
+	}
+
+	private static String[] loadProfiles(Bundle b) {
+		URL url = findURL("profile.list", b);
+
+		if ( url != null ) {
+			try {
+				Properties p = loadProperties(url);
+				String s = p.getProperty("java.profiles");
+				return s == null ? new String[] {} : s.split(",");
+			} catch (IOException e) {
+				SigilCore.error( "Failed to load java profile list", e );
+			}
+		}
+		else {
+			SigilCore.error( "Failed to find java profile list" );
+		}
+		
+		// fine no properties found
+		return new String[] {};
+	}
+
+	@SuppressWarnings("unchecked")
+	private static URL findURL(String file, Bundle b) {
+		Enumeration e = b.findEntries("/", file, false);
+		return e == null ? null : (URL) (e.hasMoreElements() ? e.nextElement() : null);
+	}
+
+
+	private static Properties loadProperties(URL url) throws IOException {
+		Properties p = new Properties();
+		
+		InputStream in = null;
+		
+		try {
+			in = url.openStream();
+			p.load(in);
+		}
+		finally {
+			if ( in != null ) {
+				try {
+					in.close();
+				} catch (IOException e) {
+					// TODO Auto-generated catch block
+					e.printStackTrace();
+				}
+			}
+		}
+		
+		return p;
+	}
+
+
+
+
+}

Added: felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/nature/SigilProjectNature.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/nature/SigilProjectNature.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/nature/SigilProjectNature.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/nature/SigilProjectNature.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,46 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.sigil.nature;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectNature;
+import org.eclipse.core.runtime.CoreException;
+
+public class SigilProjectNature implements IProjectNature {
+
+    private IProject project;
+    
+    public void configure() throws CoreException {
+        // TODO configure project builder
+
+    }
+
+    public void deconfigure() throws CoreException {
+    }
+
+    public IProject getProject() {
+        return project;
+    }
+
+    public void setProject(IProject project) {
+        this.project = project;
+    }
+
+}

Added: felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/preferences/PrefsUtils.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/preferences/PrefsUtils.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/preferences/PrefsUtils.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/preferences/PrefsUtils.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.sigil.preferences;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang.text.StrTokenizer;
+
+public class PrefsUtils {
+
+	private PrefsUtils() {
+	}
+
+	public static final String arrayToString(String[] array) {
+		StringBuilder builder = new StringBuilder();
+
+		for (int i = 0; i < array.length; i++) {
+			if (i > 0)
+				builder.append(',');
+			builder.append(StringEscapeUtils.escapeCsv(array[i]));
+		}
+
+		return builder.toString();
+	}
+
+	public static final String[] stringToArray(String string) {
+		StrTokenizer tokenizer = new StrTokenizer(string, ',', '"');
+		String[] array = new String[tokenizer.size()];
+
+		for (int i = 0; i < array.length; i++) {
+			array[i] = tokenizer.nextToken();
+		}
+
+		return array;
+	}
+
+	public static String listToString(List<String> names) {
+		return arrayToString(names.toArray( new String[names.size()]));
+	}
+
+	public static List<String> stringToList(String string) {
+		return new ArrayList<String>(Arrays.asList(stringToArray(string)));
+	}
+}

Added: felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/preferences/PromptablePreference.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/preferences/PromptablePreference.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/preferences/PromptablePreference.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/preferences/PromptablePreference.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.sigil.preferences;
+
+public enum PromptablePreference {
+	Always, Prompt, Never
+}

Added: felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/preferences/SigilPreferencesInitializer.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/preferences/SigilPreferencesInitializer.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/preferences/SigilPreferencesInitializer.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/preferences/SigilPreferencesInitializer.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.sigil.preferences;
+
+
+import org.cauldron.sigil.SigilCore;
+import org.cauldron.sigil.internal.model.repository.RepositoryConfiguration;
+import org.cauldron.sigil.model.common.VersionRangeBoundingRule;
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.jface.preference.IPreferenceStore;
+
+public class SigilPreferencesInitializer extends AbstractPreferenceInitializer {
+	
+	public static final String[] EXCLUDED_RESOURCES = new String[] {
+		".project", ".classpath", ".settings"
+	};
+	
+	@Override
+	public void initializeDefaultPreferences() {
+		IPreferenceStore store = SigilCore.getDefault().getPreferenceStore();
+
+		store.setDefault(SigilCore.OSGI_INSTALL_CHECK_PREFERENCE, true);
+
+		store.setDefault(SigilCore.DEFAULT_VERSION_LOWER_BOUND, VersionRangeBoundingRule.Micro.name());
+		store.setDefault(SigilCore.DEFAULT_VERSION_UPPER_BOUND, VersionRangeBoundingRule.Any.name());
+
+		store.setDefault(SigilCore.DEFAULT_EXCLUDED_RESOURCES, PrefsUtils.arrayToString(EXCLUDED_RESOURCES));
+		
+		store.setDefault(SigilCore.PREFERENCES_NOASK_OSGI_INSTALL, false);
+		
+		store.setDefault(SigilCore.PREFERENCES_ADD_IMPORT_FOR_EXPORT, PromptablePreference.Prompt.name());
+		
+		store.setDefault(SigilCore.PREFERENCES_REBUILD_PROJECTS, PromptablePreference.Prompt.name() );
+		
+		store.setDefault(RepositoryConfiguration.REPOSITORY_DEFAULT_SET, "org.cauldron.sigil.core.workspaceprovider" );
+	}
+}

Added: felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/property/SigilPropertyTester.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/property/SigilPropertyTester.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/property/SigilPropertyTester.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.core/src/org/cauldron/sigil/property/SigilPropertyTester.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.cauldron.sigil.property;
+
+import org.cauldron.sigil.SigilCore;
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+
+public class SigilPropertyTester extends PropertyTester {
+
+	public SigilPropertyTester() {
+	}
+
+	public boolean test( Object receiver, String property, Object[] args, Object expectedValue ) {
+		IResource resource = (IResource) receiver;
+		if ( "isSigilProject".equals( property ) ) {
+			return expectedValue.equals( isSigilProjectLikeResource( resource ) );
+		}
+		return false;
+	}
+
+	/**
+	 * @param resource
+	 * @return
+	 */
+	private static boolean isSigilProjectLikeResource(IResource resource) {
+		if ( resource instanceof IProject ) {
+			IProject p = (IProject) resource;
+			return SigilCore.isSigilProject(p);
+		}
+		else {
+			return resource.getName().equals( SigilCore.SIGIL_PROJECT_FILE );
+		}
+	}
+
+}

Added: felix/trunk/sigil/org.cauldron.sigil.feature/.project
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.feature/.project?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.feature/.project (added)
+++ felix/trunk/sigil/org.cauldron.sigil.feature/.project Mon Jul 13 13:25:46 2009
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.cauldron.sigil.feature</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.pde.FeatureBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.FeatureNature</nature>
+	</natures>
+</projectDescription>

Added: felix/trunk/sigil/org.cauldron.sigil.feature/build.properties
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.feature/build.properties?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.feature/build.properties (added)
+++ felix/trunk/sigil/org.cauldron.sigil.feature/build.properties Mon Jul 13 13:25:46 2009
@@ -0,0 +1 @@
+bin.includes = feature.xml

Added: felix/trunk/sigil/org.cauldron.sigil.feature/feature.xml
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.feature/feature.xml?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.feature/feature.xml (added)
+++ felix/trunk/sigil/org.cauldron.sigil.feature/feature.xml Mon Jul 13 13:25:46 2009
@@ -0,0 +1,127 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+  
+    http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<feature
+      id="org.cauldron.sigil.feature"
+      label="Sigil SDK"
+      version="0.8.0.qualifier"
+      provider-name="Paremus Ltd">
+
+   <description>
+      Sigil plugin, allow developers to build OSGi applications for deployment in newton within eclipse.
+   </description>
+
+   <copyright>
+      Copyright 2009 Paremus Limited, London, United Kingdom
+   </copyright>
+
+   <license url="http://www.apache.org/licenses/LICENSE-2.0">
+      Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+http://www.apache.org/licenses/LICENSE-2.0
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+or implied.
+See the License for the specific language governing permissions
+and
+limitations under the License.
+   </license>
+
+   <url>
+      <update url="http://replace.with.real.url"/>
+   </url>
+
+   <requires>
+      <import plugin="org.eclipse.ant.core"/>
+      <import plugin="org.eclipse.core.expressions"/>
+      <import plugin="org.eclipse.core.runtime"/>
+      <import plugin="org.eclipse.debug.ui"/>
+      <import plugin="org.eclipse.jdt.core"/>
+      <import plugin="org.eclipse.jdt.ui"/>
+      <import plugin="org.eclipse.jface.text"/>
+      <import plugin="org.eclipse.pde.ui"/>
+      <import plugin="org.eclipse.ui.editors"/>
+      <import plugin="org.eclipse.ui.forms"/>
+      <import plugin="org.eclipse.ui.ide"/>
+      <import plugin="org.eclipse.ui.workbench.texteditor"/>
+      <import plugin="org.eclipse.ui"/>
+      <import plugin="org.eclipse.osgi"/>
+      <import plugin="org.eclipse.jdt.launching"/>
+      <import plugin="org.eclipse.ui.console"/>
+      <import plugin="org.eclipse.jdt.debug.ui"/>
+      <import plugin="org.eclipse.ui.editors" version="3.4.0" match="greaterOrEqual"/>
+      <import plugin="org.eclipse.jface.text" version="3.4.0" match="greaterOrEqual"/>
+      <import plugin="org.eclipse.ui.ide" version="3.4.0" match="greaterOrEqual"/>
+      <import plugin="org.eclipse.help"/>
+      <import plugin="org.eclipse.zest.core" version="1.0.0" match="compatible"/>
+      <import plugin="org.eclipse.zest.layouts" version="1.0.0" match="compatible"/>
+      <import plugin="org.eclipse.ltk.core.refactoring"/>
+      <import plugin="org.eclipse.help" version="3.3.1" match="greaterOrEqual"/>
+      <import plugin="org.eclipse.ui.cheatsheets" version="3.3.100" match="greaterOrEqual"/>
+      <import plugin="org.eclipse.core.resources"/>
+      <import plugin="org.eclipse.equinox.common" version="3.4.0" match="greaterOrEqual"/>
+      <import plugin="org.cauldron.sigil.ui" version="0.5.5" match="greaterOrEqual"/>
+      <import plugin="org.cauldron.sigil.core" version="0.5.5" match="greaterOrEqual"/>
+   </requires>
+
+   <plugin
+         id="org.cauldron.sigil.core"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.cauldron.sigil.ui"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.cauldron.sigil.help"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.cauldron.sigil.utils"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.cauldron.bld.core"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+   <plugin
+         id="org.cauldron.sigil.search"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
+</feature>

Added: felix/trunk/sigil/org.cauldron.sigil.help/.classpath
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.help/.classpath?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.help/.classpath (added)
+++ felix/trunk/sigil/org.cauldron.sigil.help/.classpath Mon Jul 13 13:25:46 2009
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="src" path="src"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Added: felix/trunk/sigil/org.cauldron.sigil.help/.project
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.help/.project?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.help/.project (added)
+++ felix/trunk/sigil/org.cauldron.sigil.help/.project Mon Jul 13 13:25:46 2009
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>org.cauldron.sigil.help</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: felix/trunk/sigil/org.cauldron.sigil.help/.settings/org.eclipse.jdt.core.prefs
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.help/.settings/org.eclipse.jdt.core.prefs?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.help/.settings/org.eclipse.jdt.core.prefs (added)
+++ felix/trunk/sigil/org.cauldron.sigil.help/.settings/org.eclipse.jdt.core.prefs Mon Jul 13 13:25:46 2009
@@ -0,0 +1,7 @@
+#Fri Aug 01 14:46:19 BST 2008
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5

Added: felix/trunk/sigil/org.cauldron.sigil.help/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.help/META-INF/MANIFEST.MF?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.help/META-INF/MANIFEST.MF (added)
+++ felix/trunk/sigil/org.cauldron.sigil.help/META-INF/MANIFEST.MF Mon Jul 13 13:25:46 2009
@@ -0,0 +1,18 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Sigil Help Plug-in
+Bundle-SymbolicName: org.cauldron.sigil.help;singleton:=true
+Bundle-Version: 0.8.0.qualifier
+Bundle-Activator: org.cauldron.sigil.help.Activator
+Bundle-Vendor: Paremus Ltd
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.help;bundle-version="3.3.1",
+ org.eclipse.ui.cheatsheets;bundle-version="3.3.100",
+ org.cauldron.sigil.ui;bundle-version="0.5.5",
+ org.eclipse.ui.ide;bundle-version="3.4.0",
+ org.cauldron.sigil.core;bundle-version="0.5.5"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
+Import-Package: org.cauldron.sigil.model.eclipse,
+ org.eclipse.core.resources

Added: felix/trunk/sigil/org.cauldron.sigil.help/build.properties
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.help/build.properties?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.help/build.properties (added)
+++ felix/trunk/sigil/org.cauldron.sigil.help/build.properties Mon Jul 13 13:25:46 2009
@@ -0,0 +1,9 @@
+source.. = src/
+output.. = bin/
+bin.includes = META-INF/,\
+               .,\
+               plugin.xml,\
+               html/,\
+               toc.xml,\
+               cheatsheets/,\
+               archive/

Added: felix/trunk/sigil/org.cauldron.sigil.help/cheatsheets/HelloWorld.xml
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.help/cheatsheets/HelloWorld.xml?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.help/cheatsheets/HelloWorld.xml (added)
+++ felix/trunk/sigil/org.cauldron.sigil.help/cheatsheets/HelloWorld.xml Mon Jul 13 13:25:46 2009
@@ -0,0 +1,218 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+  
+    http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<cheatsheet title="Create a Hello World composite application">
+	<intro>
+		<description>This cheat sheet shows you how to create a simple hello world composite application using Sigil.</description>
+	</intro>
+	
+	<item title="Create an empty Newton project" href="/org.cauldron.sigil.help/html/tasks/new_project.html" dialog="true" skip="true">
+		<description>
+		First, you must create a new &quot;org.example.helloworld&quot; empty Newton project to house the java classes and SCA composites.
+		</description>
+
+		<subitem label="Select &quot;File &gt;New &gt;Project...&quot;. Expand &quot;Sigil&quot;, select &quot;Newton Project&quot; and click &quot;Next&quot;." skip="true">
+			<action
+				pluginId="org.cauldron.sigil.help"
+				class="org.cauldron.sigil.cheatsheets.actions.OpenEmptyNewtonProjectWizardAction"
+				param1="org.example.helloworld"  
+				translate="" />
+		</subitem>
+
+		<subitem label="Enter &quot;org.example.helloworld&quot; as the &quot;Project name&quot;, then click &quot;Finish&quot;." skip="false" />
+	</item>
+	
+	<item title="Create The Java Interfaces and Classes" skip="true">
+		<description>
+		Create a new &quot;org.example.helloworld.api&quot; package and add a HelloWorld interface to this package. 
+		Then create a new &quot;org.example.helloworld.impl&quot; package and add a HelloWorldImpl class which implements HelloWorld to the impl package.
+		Finally create a new &quot;org.example.helloworld.cli&quot; package and add a HelloWorldCli class which references the HelloWorld api to the cli package.
+		</description>
+
+		<subitem label="Create the HelloWorld API" skip="true">
+			<action
+				pluginId="org.cauldron.sigil.help"
+				class="org.cauldron.sigil.cheatsheets.actions.CopyResourceFromPlugin"
+				param1="org.example.helloworld"  
+				param2="src/org/example/helloworld/api"
+				param3="org.cauldron.sigil.help"
+				param4="archive/java/HelloWorld.java"
+				param5="org.eclipse.jdt.ui.CompilationUnitEditor"
+				translate="" />
+		</subitem>
+		<subitem label="Create the HelloWorld Impl" skip="true">
+			<action
+				pluginId="org.cauldron.sigil.help"
+				class="org.cauldron.sigil.cheatsheets.actions.CopyResourceFromPlugin"
+				param1="org.example.helloworld"  
+				param2="src/org/example/helloworld/impl"
+				param3="org.cauldron.sigil.help"
+				param4="archive/java/HelloWorldImpl.java"   
+				param5="org.eclipse.jdt.ui.CompilationUnitEditor"
+				translate="" />
+		</subitem>
+		<subitem label="Create the HelloWorld CLI" skip="true">
+			<action
+				pluginId="org.cauldron.sigil.help"
+				class="org.cauldron.sigil.cheatsheets.actions.CopyResourceFromPlugin"
+				param1="org.example.helloworld"  
+				param2="src/org/example/helloworld/cli"
+				param3="org.cauldron.sigil.help"
+				param4="archive/java/HelloWorldCli.java"   
+				param5="org.eclipse.jdt.ui.CompilationUnitEditor"
+				translate="" />
+		</subitem>
+	</item>
+   <item
+         title="Add OSGi Package Imports To The HelloWorld Project">
+      <description>
+         The HelloWorldCli class references classes which are exported from other OSGi bundles. In order to satisfy the OSGi classloading rules the HelloWorld project must import the required packages.
+      </description>
+      <subitem
+            label="Open the &quot;org.example.helloworld&quot; project editor by double-clicking on the &quot;sigil.properties&quot; file in the project directory."
+            skip="false">
+      </subitem>
+      <subitem
+            label="Select the &quot;Overview&quot; tab.">
+      </subitem>
+      <subitem
+            label="Click on the &quot;Resolve missing dependencies&quot; link in the &quot;Tools&quot; section.">
+      </subitem>
+      <subitem
+            label="Wait for the background task to complete. When the &quot;Review New Imports&quot; dialog appears, click &quot;OK&quot;.">
+      </subitem>
+   </item>
+  
+	
+	<item title="Create The SCA Composites That Describe The Java Resources" skip="true">
+		<description>
+		Create a new HelloWorld service composite that exports the HelloWorldImpl class using the HelloWorld interface. 
+		Then create a new HelloWorld cli composite that imports the HelloWorld interface and exports a ConsoleCommandHandler 
+		service to allow user interaction via the command handler.
+		</description>
+
+		<subitem label="Create the HelloWorld Service" skip="true">
+			<action
+				pluginId="org.cauldron.sigil.help"
+				class="org.cauldron.sigil.cheatsheets.actions.CopyResourceFromPlugin"
+				param1="org.example.helloworld"
+				param2="sca"
+				param3="org.cauldron.sigil.help"
+				param4="archive/sca/org.example.helloworld.service.composite"
+				param5="org.cauldron.sigil.editors.SCACompositeEditor"   
+				translate="" />
+		</subitem>
+		<subitem label="Create the HelloWorld Command Line" skip="true">
+			<action
+				pluginId="org.cauldron.sigil.help"
+				class="org.cauldron.sigil.cheatsheets.actions.CopyResourceFromPlugin"
+				param1="org.example.helloworld"
+				param2="sca"
+				param3="org.cauldron.sigil.help"
+				param4="archive/sca/org.example.helloworld.cli.composite"   
+				param5="org.cauldron.sigil.editors.SCACompositeEditor"   
+				translate="" />
+		</subitem>
+	</item>
+	
+   <item
+         title="Add The SCA Composites To The HelloWorld Bundle">
+      <description>
+         In order to load a composite in a Newton container it needs to be associated with an OSGi bundle that will act as the classpath for that bundle.
+      </description>
+      <subitem
+            label="Open the &quot;org.example.helloworld&quot; project editor by double-clicking on the &quot;sigil.properties&quot; file in the project directory.">
+      </subitem>
+      <subitem
+            label="Select the &quot;Exports&quot; tab.">
+      </subitem>
+      <subitem
+            label="Click on the &quot;Add&quot; button in the Composites section.">
+      </subitem>
+      <subitem
+            label="Add the &quot;org.example.helloworld.service&quot; and &quot;org.example.helloworld.cli&quot; composites to the OSGi bundle.">
+      </subitem>
+      <subitem
+            label="Save the &quot;org.example.helloworld&quot; project editor.">
+      </subitem>
+   </item>
+	
+ <item
+       title="Launch A Newton Container">
+    <description>
+       Launch a Newton enabled JVM in which to host the SCA composites you have just created.
+    </description>
+    <subitem
+          label="Make sure that the the &quot;org.example.helloworld&quot; project editor is open.">
+    </subitem>
+    <subitem
+          label="Select the &quot;Overview&quot; tab.">
+    </subitem>
+    <subitem
+          label="Click on the &quot;Launch a newton container&quot; link in the &quot;Testing&quot; section.">
+    </subitem>
+    <subitem
+          label="Wait for the newton container to finish launching. This is signified by the console message: &quot;Boot complete&quot;">
+    </subitem>
+ </item>
+
+ <item
+       title="Install The HelloWorld Composites In The Newton Container">
+    <description>
+       We will now install the two composites in the Newton container we just launched using the short-cut menu items in the eclipse navigation bar.
+    </description>
+    <subitem
+          label="Open the &quot;org.example.helloworld.service.composite&quot; document using the Sigil &quot;SCA Composite Editor&quot;.">
+    </subitem>
+    <subitem
+          label="Click on the &quot;Install Composite&quot; short-cut menu item in the navigation bar.">
+    </subitem>
+    <subitem
+          label="Select the &quot;org.example.helloworld&quot; instance and click ok">
+    </subitem>
+    <subitem
+          label="Open the &quot;org.example.helloworld.cli.composite&quot; document using the Sigil &quot;SCA Composite Editor&quot;.">
+    </subitem>
+    <subitem
+          label="Again, click on the &quot;Install Composite&quot; short-cut menu item in the navigation bar and install into the &quot;org.example.helloworld&quot; Newton instance.">
+    </subitem>
+ </item>
+	
+	<item title="Type &quot;sayhello&quot; on the Newton console" skip="false">
+		<description>
+		
+		</description>
+  <subitem
+        label="Select the Newton console.">
+        <action
+				pluginId="org.cauldron.sigil.help"
+				class="org.cauldron.sigil.cheatsheets.actions.ShowViewAction"
+				param1="org.eclipse.ui.console.ConsoleView"
+				translate="" />
+        
+  </subitem>
+  <subitem
+        label="Type &quot;sayhello&quot;. You should see the response:&lt;br/&gt;Hello World">
+  </subitem>	
+	</item>	
+	
+	<onCompletion>Congratulations you have created your first composite application using Sigil.</onCompletion>
+	
+	
+</cheatsheet>

Added: felix/trunk/sigil/org.cauldron.sigil.help/html/book.html
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.help/html/book.html?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.help/html/book.html (added)
+++ felix/trunk/sigil/org.cauldron.sigil.help/html/book.html Mon Jul 13 13:25:46 2009
@@ -0,0 +1,45 @@
+<html>
+<header>
+<title>Sigil - Newton Development Plugin</title>
+</header>
+<body bgcolor="#ffffff">
+<table width="100%">
+	<tr>
+		<td valign="bottom"><h1>Sigil - Newton Development Plugin</h1></td><td align="right"><img src="images/sigil.gif" /></td>
+	</tr>
+	<tr><td colspan="2">
+<p>Sigil is an eclipse plugin that helps developers build and test code to be deployed on the Newton platform</p>
+
+<p>Features:<br/>
+<ul>
+    <li>New (Newton Project, Composite, System)</li>
+    <li>Syntax highlighting and code completion for SCA/System docs</li>
+    <li>Launch Newton in Debug/Standard vm from Eclipse</li>
+    <li>Full debug support - break points/source code/step through etc</li>
+    <li>Install Composites into running newton from Eclipse</li>
+    <li>Log integration</li>
+</ul>
+</p>
+
+<div id="footer">
+<table cellpadding="4" cellspacing="0" border="0">
+<tr>
+<td><a href="http://www.paremus.com/License">
+          Copyright &copy; 2003-2007 Paremus Limited.</a>
+      All rights reserved.
+            <br>
+
+<script type="text/javascript" language="JavaScript"><!--
+              document.write(" - "+"Last Published: " + document.lastModified);
+              //  --></script>
+<div id="feedback">
+    Send feedback about the website to:
+  <a id="feedbackto" href="mailto:webmaster@paremus.com?subject=Feedback%C2%A0common/eclipse/UsingEclipsePlugin.html">webmaster@paremus.com</a>
+</div>
+</td><td nowrap class="footerLogos"></td>
+</tr>
+</table>
+</td></tr>
+</table>
+</body>
+</html>
\ No newline at end of file

Added: felix/trunk/sigil/org.cauldron.sigil.help/html/tasks/container_log.html
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.help/html/tasks/container_log.html?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.help/html/tasks/container_log.html (added)
+++ felix/trunk/sigil/org.cauldron.sigil.help/html/tasks/container_log.html Mon Jul 13 13:25:46 2009
@@ -0,0 +1,31 @@
+<html>
+<header>
+<title>Viewing The Newton Log</title>
+</header>
+<body bgcolor="#ffffff">
+<table width="100%">
+	<tr>
+		<td valign="bottom"><h1>Viewing The Newton Log</h1></td><td align="right"><img src="../images/sigil.gif" /></td>
+	</tr>
+	<tr><td colspan="2">
+<div id="footer">
+<table cellpadding="4" cellspacing="0" border="0">
+<tr>
+<td><a href="http://www.paremus.com/License">
+          Copyright &copy; 2003-2007 Paremus Limited.</a>
+      All rights reserved.
+            <br>
+
+<script type="text/javascript" language="JavaScript"><!--
+              document.write(" - "+"Last Published: " + document.lastModified);
+              //  --></script>
+<div id="feedback">
+    Send feedback about the website to:
+  <a id="feedbackto" href="mailto:webmaster@paremus.com?subject=Feedback%C2%A0common/eclipse/UsingEclipsePlugin.html">webmaster@paremus.com</a>
+</div>
+</td><td nowrap class="footerLogos"></td>
+</tr>
+</table>
+</td></tr></table>
+</body>
+</html>
\ No newline at end of file

Added: felix/trunk/sigil/org.cauldron.sigil.help/html/tasks/debug_composite.html
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.help/html/tasks/debug_composite.html?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.help/html/tasks/debug_composite.html (added)
+++ felix/trunk/sigil/org.cauldron.sigil.help/html/tasks/debug_composite.html Mon Jul 13 13:25:46 2009
@@ -0,0 +1,66 @@
+<html>
+<header>
+<title>Debugging A Composite</title>
+</header>
+<body bgcolor="#ffffff">
+<table width="100%">
+	<tr>
+		<td valign="bottom"><h1>Debugging A Composite</h1></td><td align="right"><img src="../images/sigil.gif" /></td>
+	</tr>
+	<tr><td colspan="2">
+<p>In order to debug composite applications using the Newton Eclipse
+      plugin, use the runtime configuration you created in above, and start it
+      using a debug session. This will launch a newton container as a separate
+      process to the Eclipse IDE environment but which can be controlled from
+      the IDE</p>
+
+      
+<div align="center">
+<img class="figure" alt="Debug" src="my-images/debug.png"></div>
+      
+<p>Install your composite into this container using the Newton context
+      menu in the package view as documented above. In this example we have
+      installed the gui.composite component from the fractal render demo into
+      a Newton debug container.</p>
+
+      
+<div align="center">
+<img class="figure" alt="Fractal GUI Debug" src="my-images/demo-gui.png"></div>      
+
+<p>You can now add break points within your code to allow you to get a
+      better idea of what is going on within your application. In this example
+      we have added a break point to the FractalViewFrame of the fractal
+      render demo to break out into an interactive debug session when any of
+      the buttons <em>draw</em>, <em>save</em>, <em>cancel</em> are pressed on
+      the gui window.</p>
+
+      
+<div align="center">
+<img class="figure" alt="Add a breakpoint" src="my-images/breakpoint.png"></div>
+      
+<p>You can then inspect variable values in top-right-hand corner as per
+      normal debugging in the Eclipse IDE.</p>
+      
+<div align="center">
+<img class="figure" alt="Debug breakpoint" src="my-images/debug-breakpoint.png"></div>
+<div id="footer">
+<table cellpadding="4" cellspacing="0" border="0">
+<tr>
+<td><a href="http://www.paremus.com/License">
+          Copyright &copy; 2003-2007 Paremus Limited.</a>
+      All rights reserved.
+            <br>
+
+<script type="text/javascript" language="JavaScript"><!--
+              document.write(" - "+"Last Published: " + document.lastModified);
+              //  --></script>
+<div id="feedback">
+    Send feedback about the website to:
+  <a id="feedbackto" href="mailto:webmaster@paremus.com?subject=Feedback%C2%A0common/eclipse/UsingEclipsePlugin.html">webmaster@paremus.com</a>
+</div>
+</td><td nowrap class="footerLogos"></td>
+</tr>
+</table>
+</td></tr></table>
+</body>
+</html>
\ No newline at end of file

Added: felix/trunk/sigil/org.cauldron.sigil.help/html/tasks/install_composite.html
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.help/html/tasks/install_composite.html?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.help/html/tasks/install_composite.html (added)
+++ felix/trunk/sigil/org.cauldron.sigil.help/html/tasks/install_composite.html Mon Jul 13 13:25:46 2009
@@ -0,0 +1,41 @@
+<html>
+<header>
+<title>Installing A Composite</title>
+</header>
+<body bgcolor="#ffffff">
+<table width="100%">
+	<tr>
+		<td valign="bottom"><h1>Installing A Composite</h1></td><td align="right"><img src="../images/sigil.gif" /></td>
+	</tr>
+	<tr><td colspan="2">
+<p>To install a composite into a Infiniflow Service Fabric container, you require a running
+      container instance on your machine. This can either be an external
+      process which you have launched using the bin/container script or the
+      container can be launched via an Eclipse runtime configuration as per
+      the instructions <a href="launch_newton.html" alt="Launching Newton">here</a>.</p> 
+      
+<p>You can then select your .composite file in the
+      package view and select Newton-&gt;Install Composite using the context
+      menu.</p>
+
+      
+<div id="footer">
+<table cellpadding="4" cellspacing="0" border="0">
+<tr>
+<td><a href="http://www.paremus.com/License">
+          Copyright &copy; 2003-2008 Paremus Limited.</a>
+      All rights reserved.
+            <br>
+
+<script type="text/javascript" language="JavaScript"><!--
+              document.write(" - "+"Last Published: " + document.lastModified);
+              //  --></script>
+<div id="feedback">
+    Send feedback about the website to:
+  <a id="feedbackto" href="mailto:webmaster@paremus.com?subject=Feedback%C2%A0common/eclipse/UsingEclipsePlugin.html">webmaster@paremus.com</a>
+</div>
+</td><td nowrap class="footerLogos"></td>
+</tr>
+</table>
+</body>
+</html>
\ No newline at end of file

Added: felix/trunk/sigil/org.cauldron.sigil.help/html/tasks/launch_newton.html
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.help/html/tasks/launch_newton.html?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.help/html/tasks/launch_newton.html (added)
+++ felix/trunk/sigil/org.cauldron.sigil.help/html/tasks/launch_newton.html Mon Jul 13 13:25:46 2009
@@ -0,0 +1,55 @@
+<html>
+<header>
+<title>Launching Newton</title>
+</header>
+<table width="100%">
+	<tr>
+		<td valign="bottom"><h1>Launching Newton</h1></td><td align="right"><img src="../images/sigil.gif" /></td>
+	</tr>
+	<tr><td colspan="2">
+	<h2>Runtime Configuration</h2>
+	<p>To run a Infiniflow Service Fabric container within Eclipse you first need to configure
+      its runtime options in the IDE.</p>
+      
+	<p>Open the Run configuration dialog by selecting the Run &rarr; Run&hellip; option
+      from the menu bar.</p>
+
+	<div align="center"><img class="figure" alt="Run Menu" src="my-images/run-menu.png"></div>
+
+	<p>Create a new Newton configuration by right-clicking on the Newton
+      configuration group and selecting <em>New</em>. Type in a name for your
+      configuration, the other default options should be sufficient for most
+      users.</p>
+
+      
+	<div align="center"><img class="figure" alt="Run Dialog" src="my-images/run.png"></div>
+
+	<h2>Launch Newton</h2>      
+	<p>Click the <em>Run</em> button to start the container, you will see
+      the container output appear in the console tab. Wait until the <em>Boot
+      Complete</em> line appears, as below.</p>
+
+      
+	<div align="center"><img class="figure" alt="Boot Complete" src="my-images/run-complete.png"></div>
+        
+<div id="footer">
+<table cellpadding="4" cellspacing="0" border="0">
+<tr>
+<td><a href="http://www.paremus.com/License">
+          Copyright &copy; 2003-2007 Paremus Limited.</a>
+      All rights reserved.
+            <br>
+
+<script type="text/javascript" language="JavaScript"><!--
+              document.write(" - "+"Last Published: " + document.lastModified);
+              //  --></script>
+<div id="feedback">
+    Send feedback about the website to:
+  <a id="feedbackto" href="mailto:webmaster@paremus.com?subject=Feedback%C2%A0common/eclipse/UsingEclipsePlugin.html">webmaster@paremus.com</a>
+</div>
+</td><td nowrap class="footerLogos"></td>
+</tr>
+</table>
+</td></tr></table>
+</body>
+</html>
\ No newline at end of file

Added: felix/trunk/sigil/org.cauldron.sigil.help/html/tasks/new_composite.html
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.help/html/tasks/new_composite.html?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.help/html/tasks/new_composite.html (added)
+++ felix/trunk/sigil/org.cauldron.sigil.help/html/tasks/new_composite.html Mon Jul 13 13:25:46 2009
@@ -0,0 +1,41 @@
+<html>
+<header>
+<title>Creating SCA Composites</title>
+</header>
+<body bgcolor="#ffffff">
+<table width="100%">
+	<tr>
+		<td valign="bottom"><h1>Creating SCA Composites</h1></td><td align="right"><img src="../images/sigil.gif" /></td>
+	</tr>
+	<tr><td colspan="2">
+	<p>
+	Create a new sca composite document using the <em>New->Other</em> menu option.<br/>
+	Page 1:<br/>
+	<img src="../images/new_composite_page1.png" alt="New Composite Page 1" /><br/>
+	Page 2:<br/>
+	<img src="../images/new_composite_page2.png" alt="New Composite Page 2" />
+	</p>
+	<p>There is basic support for context sensitive text completion in sca documents. Press <em>Ctrl+Space</em> to see a list of valid elements at the current cursor location.<br/>
+	<img src="../images/composite_suggest_text.png" alt="New Composite Page 2" />
+	</p>
+<div id="footer">
+<table cellpadding="4" cellspacing="0" border="0">
+<tr>
+<td><a href="http://www.paremus.com/License">
+          Copyright &copy; 2003-2007 Paremus Limited.</a>
+      All rights reserved.
+            <br>
+
+<script type="text/javascript" language="JavaScript"><!--
+              document.write(" - "+"Last Published: " + document.lastModified);
+              //  --></script>
+<div id="feedback">
+    Send feedback about the website to:
+  <a id="feedbackto" href="mailto:webmaster@paremus.com?subject=Feedback%C2%A0common/eclipse/UsingEclipsePlugin.html">webmaster@paremus.com</a>
+</div>
+</td><td nowrap class="footerLogos"></td>
+</tr>
+</table>
+</td></tr></table>
+</body>
+</html>
\ No newline at end of file

Added: felix/trunk/sigil/org.cauldron.sigil.help/html/tasks/new_project.html
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.help/html/tasks/new_project.html?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.help/html/tasks/new_project.html (added)
+++ felix/trunk/sigil/org.cauldron.sigil.help/html/tasks/new_project.html Mon Jul 13 13:25:46 2009
@@ -0,0 +1,31 @@
+<html>
+<header>
+<title>Creating A Newton Project</title>
+</header>
+<body bgcolor="#ffffff">
+<table width="100%">
+	<tr>
+		<td valign="bottom"><h1>Creating A Newton Project</h1></td><td align="right"><img src="../images/sigil.gif" /></td>
+	</tr>
+	<tr><td colspan="2">
+<div id="footer">
+<table cellpadding="4" cellspacing="0" border="0">
+<tr>
+<td><a href="http://www.paremus.com/License">
+          Copyright &copy; 2003-2007 Paremus Limited.</a>
+      All rights reserved.
+            <br>
+
+<script type="text/javascript" language="JavaScript"><!--
+              document.write(" - "+"Last Published: " + document.lastModified);
+              //  --></script>
+<div id="feedback">
+    Send feedback about the website to:
+  <a id="feedbackto" href="mailto:webmaster@paremus.com?subject=Feedback%C2%A0common/eclipse/UsingEclipsePlugin.html">webmaster@paremus.com</a>
+</div>
+</td><td nowrap class="footerLogos"></td>
+</tr>
+</table>
+</td></tr></table>
+</body>
+</html>
\ No newline at end of file