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 [16/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.ui/schema/org.cauldron.sigil.ui.repositorywizard.exsd
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/schema/org.cauldron.sigil.ui.repositorywizard.exsd?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/schema/org.cauldron.sigil.ui.repositorywizard.exsd (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/schema/org.cauldron.sigil.ui.repositorywizard.exsd 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.
+-->
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.cauldron.sigil.ui" xmlns="http://www.w3.org/2001/XMLSchema">
+<annotation>
+      <appinfo>
+         <meta.schema plugin="org.cauldron.sigil.ui" id="org.cauldron.sigil.ui.repositorywizard" name="Repository Wizard"/>
+      </appinfo>
+      <documentation>
+         [Enter description of this extension point.]
+      </documentation>
+   </annotation>
+
+   <element name="extension">
+      <annotation>
+         <appinfo>
+            <meta.element />
+         </appinfo>
+      </annotation>
+      <complexType>
+         <sequence minOccurs="0" maxOccurs="unbounded">
+            <element ref="wizard"/>
+         </sequence>
+         <attribute name="point" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="id" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+         <attribute name="name" type="string">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute translatable="true"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <element name="wizard">
+      <complexType>
+         <attribute name="class" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+               <appinfo>
+                  <meta.attribute kind="java" basedOn="org.cauldron.sigil.ui.wizard.repository.RepositoryWizard:"/>
+               </appinfo>
+            </annotation>
+         </attribute>
+         <attribute name="repository" type="string" use="required">
+            <annotation>
+               <documentation>
+                  
+               </documentation>
+            </annotation>
+         </attribute>
+      </complexType>
+   </element>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="since"/>
+      </appinfo>
+      <documentation>
+         [Enter the first release in which this extension point appears.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="examples"/>
+      </appinfo>
+      <documentation>
+         [Enter extension point usage example here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="apiinfo"/>
+      </appinfo>
+      <documentation>
+         [Enter API information here.]
+      </documentation>
+   </annotation>
+
+   <annotation>
+      <appinfo>
+         <meta.section type="implementation"/>
+      </appinfo>
+      <documentation>
+         [Enter information about supplied implementation of this extension point.]
+      </documentation>
+   </annotation>
+
+
+</schema>

Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/actions/DisplayAction.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/actions/DisplayAction.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/actions/DisplayAction.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/actions/DisplayAction.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,68 @@
+/*
+ * 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.actions;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+
+public abstract class DisplayAction extends Action {
+
+	public DisplayAction() {
+		super();
+	}
+
+	public DisplayAction(String text) {
+		super(text);
+	}
+
+	public DisplayAction(String text, ImageDescriptor image) {
+		super(text, image);
+	}
+
+	public DisplayAction(String text, int style) {
+		super(text, style);
+	}
+
+	protected Display findDisplay() {
+		Display d = Display.getCurrent();
+		
+		if ( d == null ) {
+			d = Display.getDefault();
+		}
+		
+		return d;
+	}
+
+	protected void runInUI(final Shell shell, final WorkspaceModifyOperation op) {
+	}
+
+	protected void info(final Shell shell, final String msg) {
+		shell.getDisplay().asyncExec( new Runnable() {
+			public void run() {
+				MessageDialog.openInformation(shell, "Information", msg );
+			}
+		} );
+	}
+
+}
\ No newline at end of file

Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/actions/PruneProjectDependenciesAction.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/actions/PruneProjectDependenciesAction.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/actions/PruneProjectDependenciesAction.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/actions/PruneProjectDependenciesAction.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,96 @@
+/*
+ * 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.actions;
+
+import java.util.Collection;
+
+import org.cauldron.sigil.SigilCore;
+import org.cauldron.sigil.model.IModelElement;
+import org.cauldron.sigil.model.project.ISigilProjectModel;
+import org.cauldron.sigil.model.util.JavaHelper;
+import org.cauldron.sigil.ui.SigilUI;
+import org.cauldron.sigil.ui.util.ResourceReviewDialog;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.progress.IProgressService;
+
+public class PruneProjectDependenciesAction extends DisplayAction {
+	
+	private ISigilProjectModel project;
+	
+	public PruneProjectDependenciesAction(ISigilProjectModel project) {
+		this.project = project;
+	}
+
+	@Override
+	public void run() {
+ 		final Shell shell = findDisplay().getActiveShell();
+ 		
+		Job job = new Job("Resolving imports") {
+
+			@Override
+			protected IStatus run(IProgressMonitor monitor) {
+				Collection<IModelElement> unused = JavaHelper.findUnusedReferences(project, monitor);
+				
+				if ( unused.isEmpty() ) {
+					info( shell, "No unused references found" );
+				}
+				else {
+					final ResourceReviewDialog<IModelElement> dialog = new ResourceReviewDialog<IModelElement>(shell, "Review Unused Imports", unused);
+					
+					shell.getDisplay().asyncExec( new Runnable() {
+						public void run() {
+							if ( dialog.open() == Window.OK ) {
+								WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
+									@Override
+									protected void execute(IProgressMonitor monitor) throws CoreException {
+										for ( IModelElement e : dialog.getResources() ) {
+											if ( !project.getBundle().getBundleInfo().removeChild(e) ) {
+												SigilCore.error( "Failed to remove " + e );
+											}
+										}
+										
+										project.save(monitor);
+									}			
+								};
+								
+								SigilUI.runWorkspaceOperation(op, shell);
+							}
+						}
+					});
+				}
+				
+				return Status.OK_STATUS;
+			}
+		};
+		
+		job.schedule();
+		
+		IProgressService p = PlatformUI.getWorkbench().getProgressService();
+		p.showInDialog(shell, job);				
+	}	
+}

Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/actions/RefreshRepositoryAction.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/actions/RefreshRepositoryAction.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/actions/RefreshRepositoryAction.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/actions/RefreshRepositoryAction.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,74 @@
+/*
+ * 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.actions;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.List;
+
+import org.cauldron.sigil.SigilCore;
+import org.cauldron.sigil.model.project.ISigilProjectModel;
+import org.cauldron.sigil.model.repository.IRepositoryModel;
+import org.cauldron.sigil.repository.IBundleRepository;
+import org.cauldron.sigil.ui.SigilUI;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubMonitor;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+
+public class RefreshRepositoryAction extends DisplayAction {
+	private final IRepositoryModel[] model;
+
+	public RefreshRepositoryAction(IRepositoryModel... model) {
+		super( "Refresh repository");
+		this.model = model;
+	}
+	
+	@Override
+	public void run() {
+		WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
+
+			@Override
+			protected void execute(IProgressMonitor monitor)
+					throws CoreException, InvocationTargetException,
+					InterruptedException {
+				boolean changed = false;
+				
+				for ( IBundleRepository b : SigilCore.getGlobalRepositoryManager().getRepositories() ) {
+					for ( IRepositoryModel m : model ) {
+						if ( b.getId().equals( m.getId() ) ) {
+							b.refresh();
+							changed = true;
+						}
+					}
+				}
+				
+				if ( changed ) {
+					List<ISigilProjectModel> projects = SigilCore.getRoot().getProjects();
+					SubMonitor sub = SubMonitor.convert(monitor, projects.size() * 10);
+					for ( ISigilProjectModel p : projects ) {
+						p.resetClasspath(sub.newChild(10));
+					}
+				}
+			}
+		};
+		
+		SigilUI.runWorkspaceOperation(op, null);
+	}
+}

Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/actions/ResolveProjectDependenciesAction.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/actions/ResolveProjectDependenciesAction.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/actions/ResolveProjectDependenciesAction.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/actions/ResolveProjectDependenciesAction.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,111 @@
+/*
+ * 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.actions;
+
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.cauldron.sigil.model.osgi.IPackageImport;
+import org.cauldron.sigil.model.project.ISigilProjectModel;
+import org.cauldron.sigil.model.util.JavaHelper;
+import org.cauldron.sigil.ui.SigilUI;
+import org.cauldron.sigil.ui.util.ResourceReviewDialog;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.progress.IProgressService;
+
+public class ResolveProjectDependenciesAction extends DisplayAction {
+
+	private ISigilProjectModel project;
+	private boolean review;
+
+	public ResolveProjectDependenciesAction(ISigilProjectModel project, boolean review) {
+		this.project = project;
+		this.review = review;
+	}
+	
+	public void run() {
+		final Shell shell = findDisplay().getActiveShell();
+		
+		Job job = new Job("Resolving dependencies" ) {
+			@Override
+			protected IStatus run(IProgressMonitor monitor) {
+				monitor.beginTask("", IProgressMonitor.UNKNOWN);
+				
+				List<IPackageImport> imports = JavaHelper.findRequiredImports(project, monitor);
+				
+				if ( imports.isEmpty() ) {
+					info( shell, "No new dependencies found" );
+				}
+				else {
+					Collections.sort(imports, new Comparator<IPackageImport>() {
+						public int compare(IPackageImport o1, IPackageImport o2) {
+							int i = o1.getPackageName().compareTo(o2.getPackageName());
+
+							// shouldn't get more than one import for same package
+							// but may as well sort if do...
+							if ( i == 0 ) {
+								i = o1.getVersions().getFloor().compareTo(o2.getVersions().getFloor() );
+							}
+							
+							return i;
+						}
+					});
+					
+					final ResourceReviewDialog<IPackageImport> dialog = new ResourceReviewDialog<IPackageImport>(shell, "Review New Dependencies", imports);					
+					shell.getDisplay().asyncExec( new Runnable() {
+						public void run() {
+							if ( !review || dialog.open() == Window.OK ) {
+								WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
+									@Override
+									protected void execute(IProgressMonitor monitor) throws CoreException {
+										for ( IPackageImport pi : dialog.getResources() ) {
+											project.getBundle().getBundleInfo().addImport(pi);
+										}
+										
+										project.save(monitor);
+									}			
+								};
+								
+								SigilUI.runWorkspaceOperation(op, shell);
+							}
+						}
+					} );
+				}
+				
+				return Status.OK_STATUS;
+			}
+		};
+		
+		job.schedule();
+		
+		IProgressService p = PlatformUI.getWorkbench().getProgressService();
+		p.showInDialog(shell, job);
+	}
+
+}

Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/classpath/SigilClassPathContainer.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/classpath/SigilClassPathContainer.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/classpath/SigilClassPathContainer.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/classpath/SigilClassPathContainer.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,95 @@
+/*
+ * 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.classpath;
+
+import org.cauldron.sigil.SigilCore;
+import org.cauldron.sigil.job.ThreadProgressMonitor;
+import org.cauldron.sigil.model.project.ISigilProjectModel;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClasspathContainer;
+import org.eclipse.jdt.core.IClasspathEntry;
+
+/**
+ * @author dave
+ *
+ */
+public class SigilClassPathContainer implements IClasspathContainer {
+
+    private IClasspathEntry[] entries;
+    private ISigilProjectModel sigil;
+
+    public SigilClassPathContainer(ISigilProjectModel sigil) {
+    	this.sigil = sigil;
+	}
+
+	/* (non-Javadoc)
+     * @see org.eclipse.jdt.core.IClasspathContainer#getClasspathEntries()
+     */
+    public IClasspathEntry[] getClasspathEntries() {
+        if ( entries == null ) {
+        	buildClassPathEntries();
+        }
+        
+        return entries;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jdt.core.IClasspathContainer#getDescription()
+     */
+    public String getDescription() {
+        return "Bundle Context Classpath";
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jdt.core.IClasspathContainer#getKind()
+     */
+    public int getKind() {
+        return K_SYSTEM;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jdt.core.IClasspathContainer#getPath()
+     */
+    public IPath getPath() {
+        return new Path( SigilCore.CLASSPATH_CONTAINER_PATH );
+    }
+
+    /**
+     * @return
+     * @throws CoreException 
+     * @throws CoreException 
+     */
+    private void buildClassPathEntries() {
+		try {
+			IProgressMonitor monitor = ThreadProgressMonitor.getProgressMonitor();
+			entries = sigil.findExternalClasspath(monitor).toArray( new IClasspathEntry[0] );
+		} catch (CoreException e) {
+    		SigilCore.error( "Failed to build classpath entries", e);
+		}
+		finally {
+			if ( entries == null ) {
+	    		entries = new IClasspathEntry[] {};
+			}
+		}
+    }
+}

Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/classpath/SigilClasspathContainerInitializer.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/classpath/SigilClasspathContainerInitializer.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/classpath/SigilClasspathContainerInitializer.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/classpath/SigilClasspathContainerInitializer.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,82 @@
+/*
+ * 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.classpath;
+
+import org.cauldron.sigil.SigilCore;
+import org.cauldron.sigil.model.project.ISigilProjectModel;
+import org.cauldron.sigil.job.*;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jdt.core.ClasspathContainerInitializer;
+import org.eclipse.jdt.core.IClasspathContainer;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+
+public class SigilClasspathContainerInitializer extends ClasspathContainerInitializer {
+
+	public SigilClasspathContainerInitializer() {
+		// TODO Auto-generated constructor stub
+	}
+
+	@Override
+	public boolean canUpdateClasspathContainer(IPath containerPath,
+			IJavaProject project) {
+		return true;
+	}
+
+	@Override
+	public void requestClasspathContainerUpdate(IPath containerPath, IJavaProject project, IClasspathContainer containerSuggestion)
+			throws CoreException {
+		ISigilProjectModel sigil = SigilCore.create(project.getProject());
+		
+        IClasspathContainer sigilContainer = new SigilClassPathContainer(sigil);
+		
+		IJavaProject[] affectedProjects = new IJavaProject[] { project };
+        
+        IClasspathContainer[] respectiveContainers = new IClasspathContainer[] { sigilContainer };
+        
+        IProgressMonitor monitor = ThreadProgressMonitor.getProgressMonitor();
+        
+        if ( monitor == null ) { 
+        	monitor = Job.getJobManager().createProgressGroup();
+        }
+
+        JavaCore.setClasspathContainer(containerPath, affectedProjects, respectiveContainers , monitor);
+	}
+
+	@Override
+	public void initialize(IPath containerPath, IJavaProject project)
+			throws CoreException {
+		ISigilProjectModel sigil = SigilCore.create(project.getProject());
+		
+        IClasspathContainer sigilContainer = new SigilClassPathContainer(sigil);
+		
+		IJavaProject[] affectedProjects = new IJavaProject[] { project };
+        
+        IClasspathContainer[] respectiveContainers = new IClasspathContainer[] { sigilContainer };
+        
+        IProgressMonitor monitor = Job.getJobManager().createProgressGroup();
+
+        JavaCore.setClasspathContainer(containerPath, affectedProjects, respectiveContainers , monitor);
+	}
+
+}

Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/classpath/SigilLibraryPage.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/classpath/SigilLibraryPage.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/classpath/SigilLibraryPage.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/classpath/SigilLibraryPage.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,67 @@
+/*
+ * 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.classpath;
+
+import org.cauldron.sigil.SigilCore;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.ui.wizards.IClasspathContainerPage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+public class SigilLibraryPage extends WizardPage implements IClasspathContainerPage {
+
+    private IClasspathEntry classpathEntry;
+
+    public SigilLibraryPage() {
+        super( "Sigil" );
+    }
+    
+    public void createControl(Composite parent) {
+        setTitle("Sigil Library");
+
+        Label label = new Label(parent, SWT.NONE);
+        label.setText("Press Finish to add the Sigil Library");
+        label.setFont(parent.getFont());
+
+        setControl(label);
+    }
+
+    public boolean finish() {
+        classpathEntry = JavaCore.newContainerEntry(new Path(SigilCore.CLASSPATH_CONTAINER_PATH));
+        return true;
+    }
+
+    public boolean isPageComplete() {
+        return true;
+    }
+
+    public IClasspathEntry getSelection() {
+        return classpathEntry;
+    }
+
+    public void setSelection(IClasspathEntry containerEntry) {
+        this.classpathEntry = containerEntry;
+    }
+
+}

Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/AbstractResourceCommandHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/AbstractResourceCommandHandler.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/AbstractResourceCommandHandler.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/AbstractResourceCommandHandler.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,28 @@
+/*
+ * 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.handlers;
+
+import org.eclipse.core.commands.AbstractHandler;
+
+public abstract class AbstractResourceCommandHandler extends AbstractHandler {
+
+	protected abstract IResourceCommandHandler getResourceCommandHandler();
+
+}

Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/EditorResourceCommandHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/EditorResourceCommandHandler.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/EditorResourceCommandHandler.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/EditorResourceCommandHandler.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,79 @@
+/*
+ * 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.handlers;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+public abstract class EditorResourceCommandHandler extends AbstractResourceCommandHandler {
+	
+	public Object execute(ExecutionEvent event) throws ExecutionException {
+		final Shell shell = HandlerUtil.getActiveShell(event);
+		final IEditorPart editorPart = HandlerUtil.getActiveEditor(event);
+		if ( editorPart != null ) {
+			IEditorInput editorInput = editorPart.getEditorInput();
+			
+			if(!(editorInput instanceof IFileEditorInput)) {
+				throw new ExecutionException("Editor input must be a file");
+			}
+			IFileEditorInput fileInput = (IFileEditorInput) editorInput;
+			
+			try {
+				// Save the editor content (if dirty)
+				IRunnableWithProgress saveOperation = new IRunnableWithProgress() {
+					public void run(IProgressMonitor monitor) throws InvocationTargetException,
+					InterruptedException {
+						if(editorPart.isDirty()) {
+							if(MessageDialog.openQuestion(shell, "Save File", "The file contents must be saved before the command can be executed. Do you wish to save now?")) {
+								editorPart.doSave(monitor);
+							} else {
+								throw new InterruptedException();
+							}
+						}
+					}
+				};
+				new ProgressMonitorDialog(shell).run(false, true, saveOperation);
+	
+				// Execute on the file
+				IFile file = fileInput.getFile();
+				getResourceCommandHandler().execute(new IResource[] { file }, event);
+			} catch (InvocationTargetException e) {
+				throw new ExecutionException("Error saving file", e.getTargetException());
+			} catch (InterruptedException e) {
+				// Exit the command silently
+			}
+		}			
+		return null;
+	}
+
+}

Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/IResourceCommandHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/IResourceCommandHandler.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/IResourceCommandHandler.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/IResourceCommandHandler.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,30 @@
+/*
+ * 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.handlers;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IResource;
+
+public interface IResourceCommandHandler {
+	
+	Object execute(IResource[] resources, ExecutionEvent event) throws ExecutionException;
+	
+}

Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/SelectionResourceCommandHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/SelectionResourceCommandHandler.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/SelectionResourceCommandHandler.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/SelectionResourceCommandHandler.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,41 @@
+/*
+ * 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.handlers;
+
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.handlers.HandlerUtil;
+
+public abstract class SelectionResourceCommandHandler extends AbstractResourceCommandHandler {
+	
+	public final Object execute(ExecutionEvent event) throws ExecutionException {
+		ISelection selection = HandlerUtil.getCurrentSelection(event);
+		
+		Object[] objectArray = ((IStructuredSelection) selection).toArray();
+		IResource[] resourceArray = new IResource[objectArray.length];
+		System.arraycopy(objectArray, 0, resourceArray, 0, objectArray.length);
+		
+		return getResourceCommandHandler().execute(resourceArray, event);
+	}
+
+}

Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/project/ConvertProjectCommandHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/project/ConvertProjectCommandHandler.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/project/ConvertProjectCommandHandler.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/project/ConvertProjectCommandHandler.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,69 @@
+/*
+ * 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.handlers.project;
+
+import org.cauldron.sigil.SigilCore;
+import org.cauldron.sigil.handlers.IResourceCommandHandler;
+import org.cauldron.sigil.model.project.ISigilProjectModel;
+import org.cauldron.sigil.ui.SigilUI;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+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.ui.actions.WorkspaceModifyOperation;
+
+public class ConvertProjectCommandHandler implements IResourceCommandHandler {
+
+	public Object execute(IResource[] resources, ExecutionEvent event)
+			throws ExecutionException {
+		for ( IResource r : resources ) {
+			final IProject project = (IProject) r;
+			if ( project != null ) {
+				WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
+					@Override
+					protected void execute(IProgressMonitor monitor)
+							throws CoreException {
+						SigilCore.makeSigilProject(project, monitor);
+						IJavaProject java = JavaCore.create(project);
+						ISigilProjectModel sigil = SigilCore.create(project);
+						IClasspathEntry[] entries = java.getRawClasspath();
+						for (int i = 0; i < entries.length; i++) {
+							IClasspathEntry entry = entries[i];
+							if(entry.getEntryKind()==IClasspathEntry.CPE_SOURCE) {
+								String encodedClasspath = sigil.getJavaModel().encodeClasspathEntry( entry );
+								sigil.getBundle().addClasspathEntry(encodedClasspath);
+							}
+						}
+						sigil.save(monitor);
+					}				
+				};
+				SigilUI.runWorkspaceOperation(op, null);
+			}
+		}
+		
+		return null;
+	}
+
+}

Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/project/ConvertProjectHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/project/ConvertProjectHandler.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/project/ConvertProjectHandler.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/project/ConvertProjectHandler.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,32 @@
+/*
+ * 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.handlers.project;
+
+import org.cauldron.sigil.handlers.IResourceCommandHandler;
+import org.cauldron.sigil.handlers.SelectionResourceCommandHandler;
+
+public class ConvertProjectHandler extends SelectionResourceCommandHandler {
+
+	@Override
+	protected IResourceCommandHandler getResourceCommandHandler() {
+		return new ConvertProjectCommandHandler();
+	}
+
+}

Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/project/RefreshSigilClasspathCommandHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/project/RefreshSigilClasspathCommandHandler.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/project/RefreshSigilClasspathCommandHandler.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/project/RefreshSigilClasspathCommandHandler.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,63 @@
+/*
+ * 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.handlers.project;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.cauldron.sigil.SigilCore;
+import org.cauldron.sigil.handlers.IResourceCommandHandler;
+import org.cauldron.sigil.model.project.ISigilProjectModel;
+import org.cauldron.sigil.ui.SigilUI;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+
+public class RefreshSigilClasspathCommandHandler implements
+		IResourceCommandHandler {
+
+	public Object execute(IResource[] resources, ExecutionEvent event)
+			throws ExecutionException {
+		try {
+			for ( IResource res : resources ) {
+				IProject p = (IProject) res;
+				final ISigilProjectModel model = SigilCore.create(p);
+				
+				WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
+					@Override
+					protected void execute(IProgressMonitor monitor)
+							throws CoreException, InvocationTargetException,
+							InterruptedException {
+						model.resetClasspath(monitor);
+					}
+				};
+				
+				SigilUI.runWorkspaceOperation(op, null);
+			}
+		} catch (CoreException e) {
+			SigilCore.error( "Failed to create sigil project for refresh action", e );
+		}
+		return null;
+	}
+
+}

Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/project/RefreshSigilClasspathHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/project/RefreshSigilClasspathHandler.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/project/RefreshSigilClasspathHandler.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/handlers/project/RefreshSigilClasspathHandler.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,32 @@
+/*
+ * 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.handlers.project;
+
+import org.cauldron.sigil.handlers.IResourceCommandHandler;
+import org.cauldron.sigil.handlers.SelectionResourceCommandHandler;
+
+public class RefreshSigilClasspathHandler extends SelectionResourceCommandHandler {
+
+	@Override
+	protected IResourceCommandHandler getResourceCommandHandler() {
+		return new RefreshSigilClasspathCommandHandler();
+	}
+
+}

Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/startup/SigilStartup.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/startup/SigilStartup.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/startup/SigilStartup.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/startup/SigilStartup.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,53 @@
+/*
+ * 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.startup;
+
+import org.cauldron.sigil.SigilCore;
+import org.cauldron.sigil.job.ResolveProjectsJob;
+import org.cauldron.sigil.repository.IRepositoryChangeListener;
+import org.cauldron.sigil.repository.RepositoryChangeEvent;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.ui.IStartup;
+
+public class SigilStartup implements IStartup {
+
+	public void earlyStartup() {
+		// Create a task to run the resolver
+		final Runnable resolver = new Runnable() {
+			public void run() {
+				IWorkspace workspace = ResourcesPlugin.getWorkspace();
+				ResolveProjectsJob job = new ResolveProjectsJob(workspace);
+				job.setSystem(true);
+				job.schedule();
+			}
+		};
+		
+		// Register a repository change listener to re-run the resolver when repository changes
+		SigilCore.getGlobalRepositoryManager().addRepositoryChangeListener(new IRepositoryChangeListener() {
+			public void repositoryChanged(RepositoryChangeEvent event) {
+				resolver.run();
+			}
+		});
+
+		// Run the resolver now
+		resolver.run();
+	}
+}

Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/SigilUI.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/SigilUI.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/SigilUI.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/SigilUI.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,181 @@
+/*
+ * 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.ui;
+
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+import org.cauldron.sigil.SigilCore;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.ImageData;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class SigilUI extends AbstractUIPlugin {
+
+	// The plug-in ID
+	public static final String PLUGIN_ID = "org.cauldron.sigil.ui";
+
+	public static final String REPOSITORY_WIZARD_EXTENSION_POINT_ID = "org.cauldron.sigil.ui.repositorywizard";
+
+	public static final String PREF_NOPROMPT_INSTALL_COMPOSITE_WITH_ERRORS = "nopromptInstallCompositeError";
+	public static final String PREF_INSTALL_COMPOSITE_WITH_ERRORS_ANSWER = "answerInstallCompositeError";
+
+	public static final String ID_REPOSITORY_VIEW = "org.cauldron.sigil.ui.repositoryBrowser";
+	public static final String ID_DEPENDENCY_VIEW = "org.cauldron.sigil.ui.bundleDependencyView";
+	public static final String ID_INSTANCES_VIEW = "org.cauldron.sigil.runtime.newtonInstancesView";
+
+	// The shared instance
+	private static SigilUI plugin;
+	
+	/**
+	 * The constructor
+	 */
+	public SigilUI() {
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+	 */
+	public void start(BundleContext context) throws Exception {
+		super.start(context);
+		SigilCore.getDefault();
+		plugin = this;
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+	 */
+	public void stop(BundleContext context) throws Exception {
+		plugin = null;
+		super.stop(context);
+	}
+
+	/**
+	 * Returns the shared instance
+	 *
+	 * @return the shared instance
+	 */
+	public static SigilUI getDefault() {
+		return plugin;
+	}
+
+	public static ResourceBundle getResourceBundle() {
+		return ResourceBundle.getBundle( "resources." + SigilUI.class.getName(), Locale.getDefault(), SigilUI.class.getClassLoader() );
+	}
+
+	public static void runWorkspaceOperation(IRunnableWithProgress op, Shell shell) {
+		if ( shell == null ) {
+			shell = getActiveWorkbenchShell();
+		}
+		try {
+			new ProgressMonitorDialog(shell).run(true, true, op);
+		} catch (InvocationTargetException e) {
+			SigilCore.error( "Workspace operation failed", e);
+		} catch (InterruptedException e1) {
+			SigilCore.log( "Workspace operation interrupted");
+		}
+	}
+	
+	public static void runWorkspaceOperationSync(IRunnableWithProgress op, Shell shell) throws Throwable {
+		if ( shell == null ) {
+			shell = getActiveWorkbenchShell();
+		}
+		try {
+			new ProgressMonitorDialog(shell).run(false, true, op);
+		} catch (InvocationTargetException e) {
+			throw e.getCause();
+		} catch (InterruptedException e1) {
+			SigilCore.log( "Workspace operation interrupted");
+		}
+	}
+	public static IWorkbenchWindow getActiveWorkbenchWindow() {
+		return getDefault().getWorkbench().getActiveWorkbenchWindow();
+	}
+	
+	public static Shell getActiveWorkbenchShell() {
+		final Shell[] shell = new Shell[1];
+		runInUISync( new Runnable() {
+			public void run() {
+				shell[0] = getActiveDisplay().getActiveShell();
+			}
+		});
+		return shell[0];
+	}
+
+	public static Display getActiveDisplay() {
+		Display d = Display.getCurrent();
+		
+		if ( d == null ) {
+			d = Display.getDefault();
+		}
+
+		return d;
+	}
+
+	public static void runInUI(Runnable runnable) {
+		getActiveDisplay().asyncExec(runnable);
+	}
+
+	public static void runInUISync(Runnable runnable) {
+		getActiveDisplay().syncExec(runnable);
+	}
+	
+	public static Image cacheImage(String path, ClassLoader classLoader) {
+		ImageRegistry registry = SigilUI.getDefault().getImageRegistry();
+		
+		Image image = registry.get( path );
+		
+		if ( image == null ) {
+			image = loadImage( path, classLoader );
+			// XXX-FIXME-XXX add null image
+			if ( image != null ) {
+				registry.put( path, image);
+			}
+		}
+		
+		return image; 
+	}
+
+	private static Image loadImage(String resource, ClassLoader loader) {
+		InputStream in = loader.getResourceAsStream( resource );
+		if ( in != null ) {
+			ImageData data = new ImageData( in );
+			return new Image( SigilUI.getActiveDisplay(), data );
+		}
+		else {
+			return null;
+		}
+	}
+}

Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/completion/CompletionProposal.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/completion/CompletionProposal.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/completion/CompletionProposal.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/completion/CompletionProposal.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,125 @@
+/*
+ * 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.ui.editors.completion;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+
+class CompletionProposal implements ICompletionProposal {
+
+	private int fReplacementOffset;
+	private int fReplacementLength;
+	private int fCursorPosition;
+	private String fReplacementString;
+	private String fAdditionalProposalInfo;
+	private IContextInformation fContextInformation;
+	private String fDisplayString;
+	private Image fImage;
+	
+	/**
+	 * Creates a new completion proposal based on the provided information. The replacement string is
+	 * considered being the display string too. All remaining fields are set to <code>null</code>.
+	 *
+	 * @param replacementString the actual string to be inserted into the document
+	 * @param replacementOffset the offset of the text to be replaced
+	 * @param replacementLength the length of the text to be replaced
+	 * @param cursorPosition the position of the cursor following the insert relative to replacementOffset
+	 */
+	public CompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition) {
+		this(replacementString, replacementOffset, replacementLength, cursorPosition, null, null, null, null);
+	}
+
+	/**
+	 * Creates a new completion proposal. All fields are initialized based on the provided information.
+	 *
+	 * @param replacementString the actual string to be inserted into the document
+	 * @param replacementOffset the offset of the text to be replaced
+	 * @param replacementLength the length of the text to be replaced
+	 * @param cursorPosition the position of the cursor following the insert relative to replacementOffset
+	 * @param image the image to display for this proposal
+	 * @param displayString the string to be displayed for the proposal
+	 * @param contextInformation the context information associated with this proposal
+	 * @param additionalProposalInfo the additional information associated with this proposal
+	 */
+	public CompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image, String displayString, IContextInformation contextInformation, String additionalProposalInfo) {
+		fReplacementString= replacementString;
+		fReplacementOffset= replacementOffset;
+		fReplacementLength= replacementLength;
+		fCursorPosition= cursorPosition;
+		fImage= image;
+		fDisplayString= displayString;
+		fContextInformation= contextInformation;
+		fAdditionalProposalInfo= additionalProposalInfo;
+	}
+	
+	
+	/* (non-Javadoc)
+	 * @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument)
+	 */
+	public void apply( IDocument document ) {
+		try {
+			document.replace(fReplacementOffset, fReplacementLength, fReplacementString);
+		} catch (BadLocationException x) {
+			// ignore
+		}
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo()
+	 */
+	public String getAdditionalProposalInfo() {
+		return fAdditionalProposalInfo;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getContextInformation()
+	 */
+	public IContextInformation getContextInformation() {
+		return fContextInformation;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString()
+	 */
+	public String getDisplayString() {
+		if (fDisplayString != null)
+			return fDisplayString;
+		return fReplacementString;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage()
+	 */
+	public Image getImage() {
+		return fImage;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getSelection(org.eclipse.jface.text.IDocument)
+	 */
+	public Point getSelection( IDocument document ) {
+		return new Point(fReplacementOffset + fCursorPosition, 0);
+	}
+	
+}
\ No newline at end of file

Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/AbstractResourceSection.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/AbstractResourceSection.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/AbstractResourceSection.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/AbstractResourceSection.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,175 @@
+/*
+ * 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.ui.editors.project;
+
+import java.io.File;
+
+import org.cauldron.sigil.SigilCore;
+import org.cauldron.sigil.model.project.ISigilProjectModel;
+import org.cauldron.sigil.ui.form.SigilPage;
+import org.cauldron.sigil.ui.form.SigilSection;
+import org.eclipse.core.resources.IContainer;
+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.IResourceVisitor;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTreeViewer;
+import org.eclipse.jface.viewers.ICheckStateListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.forms.IManagedForm;
+
+public abstract class AbstractResourceSection extends SigilSection implements IResourceChangeListener, ICheckStateListener  {
+
+	protected static final Object[] EMPTY = new Object[]{};
+	protected Tree tree;
+	protected CheckboxTreeViewer viewer;
+	private IWorkspace workspace;
+
+	public AbstractResourceSection(SigilPage page, Composite parent,
+			ISigilProjectModel project) throws CoreException {
+		super(page, parent, project);
+	}
+
+	@Override
+	public void initialize(IManagedForm form) {
+		super.initialize(form);
+		viewer.setAllChecked(false);
+		viewer.setGrayedElements( EMPTY );
+		refreshSelections();
+		viewer.refresh();		
+	}
+	
+	@Override
+	public void refresh() {
+		refreshSelections();
+		super.refresh();
+	}
+
+	public void checkStateChanged(CheckStateChangedEvent event) {
+		handleStateChanged( (IResource) event.getElement(), event.getChecked(), true, true );
+	}
+
+	public void resourceChanged(IResourceChangeEvent event) {
+		if ( !getSection().getDisplay().isDisposed() ) {
+			getSection().getDisplay().asyncExec( new Runnable() {
+				public void run() {
+					if ( getSection().isVisible() ) {
+						viewer.refresh();
+					}
+				}			
+			});
+		}
+	}
+	
+	protected void startWorkspaceListener(IWorkspace workspace) {
+		this.workspace = workspace;
+		workspace.addResourceChangeListener(this);
+	}
+	
+	@Override
+	public void dispose() {
+		workspace.removeResourceChangeListener(this);
+	}
+
+	protected abstract void refreshSelections();
+	
+	protected abstract void syncResourceModel(IResource element, boolean checked);
+
+	protected IResource findResource(IPath path) {
+		IProject project2 = getProjectModel().getProject();
+		File f = project2.getLocation().append(path).toFile();
+		
+		if ( f.exists() ) {
+			try {
+				if ( f.isFile() ) {
+					return project2.getFile(path);
+				}
+				else {
+					return project2.getFolder(path);
+				}
+			}
+			catch (IllegalArgumentException e) {
+				SigilCore.error( "Unknown path " + path );
+				return null;
+			}
+		}
+		else {
+			SigilCore.error( "Unknown file " + f );
+			return null;
+		}
+	}	
+	
+
+	protected void handleStateChanged(IResource element, boolean checked, boolean recurse,
+			boolean sync) {
+				if ( element instanceof IContainer ) {
+					setParentsGrayChecked(element, checked);
+					if ( recurse ) {
+						recursiveCheck( (IContainer) element, checked, sync );
+					}
+				}
+				else {
+					setParentsGrayChecked(element, checked);
+				}
+				
+				if ( sync ) {
+					syncResourceModel( element, checked );
+				}
+			}
+
+	private void recursiveCheck(IContainer element, final boolean checked, final boolean sync) {
+		try {
+			element.accept( new IResourceVisitor() {
+				public boolean visit(IResource resource) throws CoreException {
+					viewer.setChecked(resource, checked);
+					if ( sync ) {
+						syncResourceModel(resource, checked);
+					}
+					return true;
+				}
+			} );
+		}
+		catch ( CoreException e ) {
+			DebugPlugin.log( e.getStatus() );
+		}
+	}
+
+	private void setParentsGrayChecked(IResource r, boolean checked) {
+		while ( r.getParent() != null ) {
+			r = r.getParent();
+			if ( (viewer.getGrayed(r) && viewer.getChecked(r)) == checked) {
+				break;
+			}
+			if ( viewer.getChecked(r) == checked ) {
+				viewer.setGrayed( r, !checked );
+			}
+			else {
+				viewer.setGrayChecked(r, checked);
+			}
+		}
+	}
+}
\ No newline at end of file

Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/BundleDependencySection.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/BundleDependencySection.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/BundleDependencySection.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/BundleDependencySection.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,162 @@
+/*
+ * 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.ui.editors.project;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.cauldron.sigil.model.IModelElement;
+import org.cauldron.sigil.model.project.ISigilProjectModel;
+import org.cauldron.sigil.ui.form.SigilPage;
+import org.cauldron.sigil.ui.form.SigilSection;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.forms.widgets.TableWrapData;
+import org.eclipse.ui.forms.widgets.TableWrapLayout;
+
+public abstract class BundleDependencySection extends SigilSection {
+
+	private Set<? extends IModelElement> unresolvedElements;
+	
+	protected ProjectTableViewer viewer;
+	private Button add;
+	private Button edit;
+	private Button remove;
+
+	public BundleDependencySection(SigilPage page, Composite parent, ISigilProjectModel project, Set<IModelElement> unresolvedElements) throws CoreException {
+		super(page, parent, project);
+		viewer.setUnresolvedElements(unresolvedElements);
+	}
+	
+	public BundleDependencySection(SigilPage page, Composite parent, ISigilProjectModel project) throws CoreException {
+		this(page, parent, project, null);
+	}
+	
+	protected abstract String getTitle();
+	
+	protected abstract Label createLabel(Composite parent, FormToolkit toolkit);
+	
+	protected abstract IContentProvider getContentProvider();
+
+	protected abstract void handleAdd();
+	
+	protected abstract void handleEdit();
+	
+	protected abstract void handleRemoved();
+	
+	@Override
+	public void refresh() {
+		super.refresh();
+		viewer.refresh();
+	}
+	
+	protected ISelection getSelection() {
+		return viewer.getSelection();
+	}
+
+	@Override
+	protected void createSection(Section section, FormToolkit toolkit) {
+		setTitle( getTitle() );
+		
+		Composite body = createGridBody(2, false, toolkit);
+		
+        Label label = createLabel(body, toolkit);
+        
+        label.setLayoutData( new GridData(SWT.LEFT, SWT.CENTER, true, true, 2, 1 ) );
+        
+		Table bundleTable = toolkit.createTable(body, SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL | SWT.BORDER);
+		GridData data = new GridData( GridData.FILL_BOTH );
+		data.heightHint = 600;
+        bundleTable.setLayoutData( data );
+        bundleTable.setLinesVisible(false);        
+        createButtons(body, toolkit);        
+        createViewer( bundleTable );
+	}
+	
+	protected void createButtons(Composite body, FormToolkit toolkit) {
+	    Composite buttons = toolkit.createComposite(body);
+	    TableWrapLayout layout = new TableWrapLayout();
+	    layout.numColumns = 1;
+	    layout.topMargin = 0;
+	    layout.leftMargin = 0;
+	    layout.rightMargin = 0;
+	    layout.bottomMargin = 0;
+	    buttons.setLayout( layout );
+	    GridData data = new GridData();
+	    data.verticalAlignment = SWT.TOP;
+	    buttons.setLayoutData(data);
+	    
+	    add = toolkit.createButton(buttons, "Add", SWT.NULL);
+	    add.setLayoutData( new TableWrapData( TableWrapData.FILL ) );
+	    add.addSelectionListener( new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent e) {
+				handleAdd();
+			}        	
+	    } );
+	    
+	    edit = toolkit.createButton(buttons, "Edit", SWT.NULL);
+	    edit.setLayoutData( new TableWrapData( TableWrapData.FILL ) );
+	    edit.addSelectionListener( new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent e) {
+				handleEdit();
+			}        	
+	    } );
+	    
+	    remove = toolkit.createButton(buttons, "Remove", SWT.NULL);
+	    remove.setLayoutData( new TableWrapData( TableWrapData.FILL ) );
+	    remove.addSelectionListener( new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent e) {
+				handleRemoved();
+			}
+	    } );
+	    
+	    setSelected(false);
+	}
+
+	protected void createViewer(Table bundleTable) {
+	    viewer = new ProjectTableViewer(bundleTable);
+	    viewer.setContentProvider(getContentProvider());  
+	    viewer.addSelectionChangedListener( new ISelectionChangedListener() {
+			public void selectionChanged(SelectionChangedEvent event) {
+				setSelected(!event.getSelection().isEmpty());
+			}
+	    });
+	}
+
+	private void setSelected(boolean selected) {
+		edit.setEnabled(selected);
+		remove.setEnabled(selected);
+	}
+
+}
\ No newline at end of file

Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ClasspathSection.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ClasspathSection.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ClasspathSection.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ClasspathSection.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,240 @@
+/*
+ * 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.ui.editors.project;
+
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+
+import org.cauldron.sigil.model.eclipse.ISigilBundle;
+import org.cauldron.sigil.model.project.ISigilProjectModel;
+import org.cauldron.sigil.model.util.JavaHelper;
+import org.cauldron.sigil.ui.form.SigilPage;
+import org.cauldron.sigil.ui.form.SigilSection;
+import org.cauldron.sigil.ui.util.BackgroundLoadingSelectionDialog;
+import org.cauldron.sigil.ui.util.DefaultTableProvider;
+import org.cauldron.sigil.ui.util.IFilter;
+import org.cauldron.sigil.ui.util.ModelLabelProvider;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ViewerComparator;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.Section;
+import org.eclipse.ui.forms.widgets.TableWrapData;
+import org.eclipse.ui.forms.widgets.TableWrapLayout;
+
+public class ClasspathSection extends SigilSection {
+
+	private ProjectTableViewer viewer;
+	private final Comparator<IClasspathEntry> CLASSPATH_COMPARATOR = new Comparator<IClasspathEntry>() {
+		public int compare(IClasspathEntry o1, IClasspathEntry o2) {
+			return compareClasspaths(o1, o2);
+		}
+	};
+
+	public ClasspathSection(SigilPage page, Composite parent, ISigilProjectModel project) throws CoreException {
+		super( page, parent, project );
+	}
+	
+	@Override
+	protected void createSection(Section section, FormToolkit toolkit) {
+		setTitle( "Classpath");
+		
+		Composite body = createGridBody(2, false, toolkit);
+		
+        Label label = toolkit.createLabel( body, "Specify the internal classpath of this bundle." );
+        label.setLayoutData( new GridData(SWT.LEFT, SWT.CENTER, true, true, 2, 1 ) );
+		
+		Table bundleTable = toolkit.createTable(body, SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL | SWT.BORDER);
+		GridData tableLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
+		tableLayoutData.heightHint = 150;
+        bundleTable.setLayoutData(tableLayoutData);
+        
+        createButtons(body, toolkit);
+        createViewer( bundleTable );
+	}
+
+	private void createButtons(Composite body, FormToolkit toolkit) {
+        Composite buttons = toolkit.createComposite(body);
+        TableWrapLayout layout = new TableWrapLayout();
+        layout.numColumns = 1;
+        layout.topMargin = 0;
+        layout.leftMargin = 0;
+        layout.rightMargin = 0;
+        layout.bottomMargin = 0;
+        buttons.setLayout( layout );
+        
+        Button add = toolkit.createButton(buttons, "Add", SWT.NULL);
+        add.setLayoutData( new TableWrapData( TableWrapData.FILL ) );
+        add.addSelectionListener( new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent e) {
+				handleAdd();
+			}        	
+        } );
+        
+        Button remove = toolkit.createButton(buttons, "Remove", SWT.NULL);
+        remove.setLayoutData( new TableWrapData( TableWrapData.FILL ) );
+        remove.addSelectionListener( new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent e) {
+				handleRemoved();
+			}
+        } );
+	}
+
+	private void createViewer(Table bundleTable) {
+        viewer = new ProjectTableViewer(bundleTable);
+        viewer.setContentProvider( new DefaultTableProvider() {
+			public Object[] getElements(Object inputElement) {
+				ArrayList<IClasspathEntry> cp = new ArrayList<IClasspathEntry>();
+				for (IClasspathEntry cpe : JavaHelper.findClasspathEntries(getBundle())) {
+					cp.add(cpe);
+				}
+				
+				Collections.sort(cp, new Comparator<IClasspathEntry>() {
+					public int compare(IClasspathEntry o1, IClasspathEntry o2) {
+						return o1.toString().compareTo(o2.toString());
+					}
+				});
+				return cp.toArray();
+			}
+        });    
+        viewer.setComparator(new ViewerComparator() {
+			@Override
+			public int category(Object element) {
+				return index((IClasspathEntry) element);
+			}
+        });
+	}
+	
+	protected ISigilBundle getBundle() {
+		return getProjectModel().getBundle();
+	}
+
+	private void handleAdd() {
+		try {
+			BackgroundLoadingSelectionDialog<IClasspathEntry> dialog = new BackgroundLoadingSelectionDialog<IClasspathEntry>(getSection().getShell(), "Classpath Entry:", true);
+			
+			dialog.setDescriptor(new IElementDescriptor<IClasspathEntry>() {
+				public String getName(IClasspathEntry element) {
+					return element.getPath().toString();
+				}
+			
+				public String getLabel(IClasspathEntry element) {
+					return getName(element);
+				}
+			});
+			
+			dialog.setLabelProvider(new ModelLabelProvider());
+			
+			dialog.setFilter(new IFilter<IClasspathEntry>() {
+				public boolean select(IClasspathEntry cp) {
+					switch ( cp.getEntryKind() ) {
+					case IClasspathEntry.CPE_LIBRARY:
+					case IClasspathEntry.CPE_VARIABLE:
+					case IClasspathEntry.CPE_SOURCE:
+						return !getBundle().getClasspathEntrys().contains(encode(cp));
+					default:
+						return false;
+					}
+				}
+			});
+			
+			dialog.setComparator(CLASSPATH_COMPARATOR);
+			
+			IClasspathEntry[] classpath = getProjectModel().getJavaModel().getRawClasspath();
+			dialog.addElements(Arrays.asList(classpath));
+			if ( dialog.open() == Window.OK ) {
+				List<IClasspathEntry> selectedElements = dialog.getSelectedElements();
+				
+				Object[] added = selectedElements.toArray();
+				for (IClasspathEntry entry : selectedElements) {
+					getBundle().addClasspathEntry(encode(entry));
+				}
+				viewer.add(added);
+				viewer.refresh();
+				markDirty();
+			}
+		} catch (JavaModelException e) {
+			ErrorDialog.openError(getSection().getShell(), "Error", null, e.getStatus());
+		}
+	}
+
+	private int compareClasspaths(IClasspathEntry o1, IClasspathEntry o2) {
+		if ( o1.getEntryKind() == o2.getEntryKind() ) {
+			ModelLabelProvider mlp = viewer.getLabelProvider();
+			return mlp.getText(o1).compareTo(mlp.getText(o2));
+		}
+		else {
+			int i1 = index(o1);
+			int i2 = index(o2);
+			
+			if ( i1 < i2 ) {
+				return -1;
+			}
+			else {
+				return 1;
+			}
+		}
+	}
+
+	private static int index(IClasspathEntry o1) {
+		switch ( o1.getEntryKind() ) {
+		case IClasspathEntry.CPE_SOURCE: return 0;
+		case IClasspathEntry.CPE_PROJECT: return 1;
+		case IClasspathEntry.CPE_LIBRARY: return 2;
+		case IClasspathEntry.CPE_VARIABLE: return 3;
+		case IClasspathEntry.CPE_CONTAINER: return 4;
+		default: throw new IllegalStateException( "Unknown classpath entry type " + o1);
+		}
+	}
+
+	private String encode(IClasspathEntry cp) {
+		return getProjectModel().getJavaModel().encodeClasspathEntry(cp).trim();
+	}
+
+	@SuppressWarnings("unchecked")
+	private void handleRemoved() {
+		IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
+
+		if ( !selection.isEmpty() ) {
+			for ( Iterator<IClasspathEntry> i = selection.iterator(); i.hasNext(); ) {			
+				getBundle().removeClasspathEntry(getProjectModel().getJavaModel().encodeClasspathEntry(i.next()).trim());
+			}		
+			viewer.remove(selection.toArray());
+			markDirty();
+		}
+	}
+}

Added: felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ContainerTreeProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ContainerTreeProvider.java?rev=793581&view=auto
==============================================================================
--- felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ContainerTreeProvider.java (added)
+++ felix/trunk/sigil/org.cauldron.sigil.ui/src/org/cauldron/sigil/ui/editors/project/ContainerTreeProvider.java Mon Jul 13 13:25:46 2009
@@ -0,0 +1,63 @@
+/*
+ * 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.ui.editors.project;
+
+import org.cauldron.sigil.ui.util.DefaultTreeContentProvider;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugPlugin;
+
+public class ContainerTreeProvider extends DefaultTreeContentProvider {
+
+	private static final Object[] EMPTY = new Object[] {};
+	
+	public Object[] getChildren(Object parentElement) {
+		if ( parentElement instanceof IContainer ) {
+			IContainer f = (IContainer) parentElement;
+			try {
+				return f.members();
+			} catch (CoreException e) {
+				DebugPlugin.log( e.getStatus() );
+			}
+		}
+		return EMPTY;	
+	}
+
+	public Object getParent(Object element) {
+		IResource r = (IResource) element;
+		return r.getParent();
+	}
+
+	public boolean hasChildren(Object element) {
+		if ( element instanceof IContainer ) {
+			return true;
+		}
+		else {
+			return false;
+		}
+	}
+
+	public Object[] getElements(Object inputElement) {
+		IContainer container = (IContainer) inputElement;
+		return getChildren(container);
+	}
+
+}