felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dsav...@apache.org
Subject svn commit: r796467 [17/25] - in /felix/trunk/sigil: common/core.tests/src/org/apache/felix/sigil/core/ common/core/src/org/apache/felix/sigil/bnd/ common/core/src/org/apache/felix/sigil/config/ common/core/src/org/apache/felix/sigil/core/ common/core/...
Date Tue, 21 Jul 2009 18:51:41 GMT
Modified: felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/OverviewForm.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/OverviewForm.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/OverviewForm.java (original)
+++ felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/OverviewForm.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,7 @@
 
 package org.apache.felix.sigil.ui.eclipse.ui.editors.project;
 
+
 import org.apache.felix.sigil.eclipse.SigilCore;
 import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
 import org.apache.felix.sigil.ui.eclipse.ui.form.SigilPage;
@@ -30,27 +31,33 @@
 import org.eclipse.ui.forms.widgets.TableWrapData;
 import org.eclipse.ui.forms.widgets.TableWrapLayout;
 
+
 /**
  * @author dave
  *
  */
-public class OverviewForm extends SigilPage {
+public class OverviewForm extends SigilPage
+{
     public static final String PAGE_ID = "overview";
     private ISigilProjectModel sigil;
-    
-    public OverviewForm(SigilProjectEditorPart editor, ISigilProjectModel sigil) {
-        super(editor, PAGE_ID, "Overview");
+
+
+    public OverviewForm( SigilProjectEditorPart editor, ISigilProjectModel sigil )
+    {
+        super( editor, PAGE_ID, "Overview" );
         this.sigil = sigil;
     }
 
+
     @Override
-    protected void createFormContent(IManagedForm managedForm) {
+    protected void createFormContent( IManagedForm managedForm )
+    {
         FormToolkit toolkit = managedForm.getToolkit();
-        
+
         ScrolledForm form = managedForm.getForm();
         form.setText( "Overview" );
-        
-        Composite body = form.getBody();        
+
+        Composite body = form.getBody();
         TableWrapLayout layout = new TableWrapLayout();
         layout.bottomMargin = 10;
         layout.topMargin = 5;
@@ -58,39 +65,41 @@
         layout.rightMargin = 10;
         layout.numColumns = 2;
         layout.horizontalSpacing = 10;
-        body.setLayout(layout);
-        body.setLayoutData(new TableWrapData(TableWrapData.FILL));
-        
-        Composite left = toolkit.createComposite(body);
+        body.setLayout( layout );
+        body.setLayoutData( new TableWrapData( TableWrapData.FILL ) );
+
+        Composite left = toolkit.createComposite( body );
         layout = new TableWrapLayout();
         layout.verticalSpacing = 20;
-        left.setLayout(layout);
-        left.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
-        
-        Composite right = toolkit.createComposite(body);
+        left.setLayout( layout );
+        left.setLayoutData( new TableWrapData( TableWrapData.FILL_GRAB ) );
+
+        Composite right = toolkit.createComposite( body );
         layout = new TableWrapLayout();
         layout.verticalSpacing = 20;
-        right.setLayout(layout);
-        right.setLayoutData( new TableWrapData( TableWrapData.FILL_GRAB) );
-        
-        try {
-	        GeneralInfoSection general = new GeneralInfoSection(this, left, sigil);
-	        managedForm.addPart( general );
-	        
-	        ContentSummarySection content = new ContentSummarySection( this, right, sigil);
-	        managedForm.addPart( content );
-	        
-	        // XXX-FELIX
-	        // commented out due to removal of runtime newton integration
-	        // potential to bring back in medium term...
-	        //TestingSection testing = new TestingSection(this, right, newton);
-	        //managedForm.addPart(testing);
-	        
-	        ToolsSection tools = new ToolsSection(this, right, sigil);
-	        managedForm.addPart(tools);
+        right.setLayout( layout );
+        right.setLayoutData( new TableWrapData( TableWrapData.FILL_GRAB ) );
+
+        try
+        {
+            GeneralInfoSection general = new GeneralInfoSection( this, left, sigil );
+            managedForm.addPart( general );
+
+            ContentSummarySection content = new ContentSummarySection( this, right, sigil );
+            managedForm.addPart( content );
+
+            // XXX-FELIX
+            // commented out due to removal of runtime newton integration
+            // potential to bring back in medium term...
+            //TestingSection testing = new TestingSection(this, right, newton);
+            //managedForm.addPart(testing);
+
+            ToolsSection tools = new ToolsSection( this, right, sigil );
+            managedForm.addPart( tools );
         }
-        catch (CoreException e) {
-        	SigilCore.error( "Failed to create overview form", e );
+        catch ( CoreException e )
+        {
+            SigilCore.error( "Failed to create overview form", e );
         }
     }
 }

Modified: felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/PackageExportDialog.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/PackageExportDialog.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/PackageExportDialog.java (original)
+++ felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/PackageExportDialog.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,7 @@
 
 package org.apache.felix.sigil.ui.eclipse.ui.editors.project;
 
+
 import org.eclipse.jface.viewers.IContentProvider;
 import org.eclipse.jface.viewers.ViewerFilter;
 import org.eclipse.swt.SWT;
@@ -30,42 +31,58 @@
 import org.eclipse.swt.widgets.Text;
 import org.osgi.framework.Version;
 
-public class PackageExportDialog extends ResourceSelectDialog  {
 
-	private Text versionText;
-	private Version version;
-	
-	public PackageExportDialog(Shell parentShell, String title, IContentProvider content, ViewerFilter filter, Object scope ) {
-		super(parentShell, content, filter, scope, title, "Package Name:", true);
-	}
-	
-	@Override
-	protected void createCustom(Composite body) {
-		Label l = new Label( body, SWT.NONE );
-		l.setText( "Version:" );
-		versionText = new Text(body, SWT.BORDER);
-		versionText.addKeyListener(new KeyAdapter() {
-			@Override
-			public void keyReleased(KeyEvent e) {
-				try {
-					version = Version.parseVersion(versionText.getText());
-					setErrorMessage(null);
-				}
-				catch (IllegalArgumentException ex) {
-					setErrorMessage("Invalid version");
-				}
-			}			
-		});
-		if ( version != null ) {
-			versionText.setText( version.toString() );
-		}
-	}
-
-	public Version getVersion() {
-		return version;
-	}
-
-	public void setVersion(Version version) {
-		this.version = version;
-	}	
+public class PackageExportDialog extends ResourceSelectDialog
+{
+
+    private Text versionText;
+    private Version version;
+
+
+    public PackageExportDialog( Shell parentShell, String title, IContentProvider content, ViewerFilter filter,
+        Object scope )
+    {
+        super( parentShell, content, filter, scope, title, "Package Name:", true );
+    }
+
+
+    @Override
+    protected void createCustom( Composite body )
+    {
+        Label l = new Label( body, SWT.NONE );
+        l.setText( "Version:" );
+        versionText = new Text( body, SWT.BORDER );
+        versionText.addKeyListener( new KeyAdapter()
+        {
+            @Override
+            public void keyReleased( KeyEvent e )
+            {
+                try
+                {
+                    version = Version.parseVersion( versionText.getText() );
+                    setErrorMessage( null );
+                }
+                catch ( IllegalArgumentException ex )
+                {
+                    setErrorMessage( "Invalid version" );
+                }
+            }
+        } );
+        if ( version != null )
+        {
+            versionText.setText( version.toString() );
+        }
+    }
+
+
+    public Version getVersion()
+    {
+        return version;
+    }
+
+
+    public void setVersion( Version version )
+    {
+        this.version = version;
+    }
 }

Modified: felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/ProjectLabelProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/ProjectLabelProvider.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/ProjectLabelProvider.java (original)
+++ felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/ProjectLabelProvider.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,7 @@
 
 package org.apache.felix.sigil.ui.eclipse.ui.editors.project;
 
+
 import java.io.InputStream;
 
 import org.apache.felix.sigil.eclipse.SigilCore;
@@ -39,140 +40,186 @@
 import org.eclipse.swt.graphics.ImageData;
 import org.eclipse.swt.widgets.Widget;
 
-public class ProjectLabelProvider extends DefaultLabelProvider implements IBaseLabelProvider {
 
-	private final Widget parent;
-	private final ImageRegistry registry;
-	private final IDependencyChecker checker;
-	
-	public ProjectLabelProvider(Widget parent, ImageRegistry registry ) {
-		this(parent, registry, null);
-	}
-	
-	public ProjectLabelProvider(Widget parent, ImageRegistry registry, IDependencyChecker checker) {
-		this.parent = parent;
-		this.registry = registry;
-		this.checker = checker;
-	}
-
-	public Image getImage(Object element) {
-		Image result = null;
-		if ( element instanceof ISigilBundle || element instanceof IRequiredBundle || element instanceof IBundleModelElement) {
-			result = findBundle();
-		}
-		else if (element instanceof IPackageImport) {
-			if(checker != null) {
-				result = checker.isSatisfied((IPackageImport) element) ? findPackage() : findPackageError();
-			} else {
-				result = findPackage();
-			}
-		}
-		else if (element instanceof IPackageExport) {
-			result = findPackage();
-		}
-		else if ( element instanceof IPackageFragmentRoot ) {
-			IPackageFragmentRoot root = (IPackageFragmentRoot) element;
-			try {
-				if ( root.getKind() == IPackageFragmentRoot.K_SOURCE ) {
-					result = findPackage();
-				}
-				else {
-					result = findBundle();
-				}
-			} catch (JavaModelException e) {
-				SigilCore.error( "Failed to inspect package fragment root", e );
-			}
-		}
-		else if ( element instanceof IClasspathEntry ) {
-			result = findPackage();
-		}
-	
-		return result;
-	}
-
-	public String getText(Object element) {
-		if ( element instanceof ISigilBundle ) {
-			ISigilBundle bundle = (ISigilBundle) element;
-			return bundle.getBundleInfo().getSymbolicName(); 
-		}
-
-		if ( element instanceof IRequiredBundle ) {
-			IRequiredBundle req = (IRequiredBundle) element;
-			return req.getSymbolicName() + " " + req.getVersions();
-		}
-		
-		if ( element instanceof IPackageImport ) {
-			IPackageImport req = (IPackageImport) element;
-			return req.getPackageName() + " " + req.getVersions();
-		}
-		
-		if ( element instanceof IPackageExport ) {
-			IPackageExport pe = (IPackageExport) element;
-			return pe.getPackageName() + " " + pe.getVersion();
-		}
-		
-		if ( element instanceof IResource ) {
-			IResource resource = (IResource) element;
-			return resource.getName();
-		}
-		
-		if ( element instanceof IPackageFragment )  {
-			IPackageFragment f = (IPackageFragment) element;
-			return f.getElementName();
-		}
-		
-		if ( element instanceof IPackageFragmentRoot ) {
-			IPackageFragmentRoot f = (IPackageFragmentRoot) element;
-			try {
-				return f.getUnderlyingResource().getName();
-			} catch (JavaModelException e) {
-				return "unknown";
-			}
-		}
-		
-		if ( element instanceof IClasspathEntry ) {
-			IClasspathEntry cp = (IClasspathEntry) element;
-			return cp.getPath().toString();
-		}
-		
-		return element.toString();
-	}
-
-	private Image findPackage() {
-		Image image = registry.get( "package" );
-		
-		if ( image == null ) {
-			image = loadImage( "icons/package_obj.png" ); 
-			registry.put( "package", image);
-		}
-		
-		return image; 
-	}
-	
-	private Image findPackageError() {
-		Image image = registry.get("package_error");
-		if(image == null) {
-			image = loadImage("icons/package_obj_error.gif");
-			registry.put("package_error", image);
-		}
-		return image;
-	}
-
-	private Image findBundle() {
-		Image image = registry.get( "bundle" );
-		
-		if ( image == null ) {
-			image = loadImage( "icons/jar_obj.png" ); 
-			registry.put( "bundle", image);
-		}
-		
-		return image; 
-	}
-		
-	private Image loadImage(String resource) {
-		InputStream in = ProjectLabelProvider.class.getClassLoader().getResourceAsStream( resource );
-		ImageData data = new ImageData( in );
-		return new Image( parent.getDisplay(), data );
-	}
+public class ProjectLabelProvider extends DefaultLabelProvider implements IBaseLabelProvider
+{
+
+    private final Widget parent;
+    private final ImageRegistry registry;
+    private final IDependencyChecker checker;
+
+
+    public ProjectLabelProvider( Widget parent, ImageRegistry registry )
+    {
+        this( parent, registry, null );
+    }
+
+
+    public ProjectLabelProvider( Widget parent, ImageRegistry registry, IDependencyChecker checker )
+    {
+        this.parent = parent;
+        this.registry = registry;
+        this.checker = checker;
+    }
+
+
+    public Image getImage( Object element )
+    {
+        Image result = null;
+        if ( element instanceof ISigilBundle || element instanceof IRequiredBundle
+            || element instanceof IBundleModelElement )
+        {
+            result = findBundle();
+        }
+        else if ( element instanceof IPackageImport )
+        {
+            if ( checker != null )
+            {
+                result = checker.isSatisfied( ( IPackageImport ) element ) ? findPackage() : findPackageError();
+            }
+            else
+            {
+                result = findPackage();
+            }
+        }
+        else if ( element instanceof IPackageExport )
+        {
+            result = findPackage();
+        }
+        else if ( element instanceof IPackageFragmentRoot )
+        {
+            IPackageFragmentRoot root = ( IPackageFragmentRoot ) element;
+            try
+            {
+                if ( root.getKind() == IPackageFragmentRoot.K_SOURCE )
+                {
+                    result = findPackage();
+                }
+                else
+                {
+                    result = findBundle();
+                }
+            }
+            catch ( JavaModelException e )
+            {
+                SigilCore.error( "Failed to inspect package fragment root", e );
+            }
+        }
+        else if ( element instanceof IClasspathEntry )
+        {
+            result = findPackage();
+        }
+
+        return result;
+    }
+
+
+    public String getText( Object element )
+    {
+        if ( element instanceof ISigilBundle )
+        {
+            ISigilBundle bundle = ( ISigilBundle ) element;
+            return bundle.getBundleInfo().getSymbolicName();
+        }
+
+        if ( element instanceof IRequiredBundle )
+        {
+            IRequiredBundle req = ( IRequiredBundle ) element;
+            return req.getSymbolicName() + " " + req.getVersions();
+        }
+
+        if ( element instanceof IPackageImport )
+        {
+            IPackageImport req = ( IPackageImport ) element;
+            return req.getPackageName() + " " + req.getVersions();
+        }
+
+        if ( element instanceof IPackageExport )
+        {
+            IPackageExport pe = ( IPackageExport ) element;
+            return pe.getPackageName() + " " + pe.getVersion();
+        }
+
+        if ( element instanceof IResource )
+        {
+            IResource resource = ( IResource ) element;
+            return resource.getName();
+        }
+
+        if ( element instanceof IPackageFragment )
+        {
+            IPackageFragment f = ( IPackageFragment ) element;
+            return f.getElementName();
+        }
+
+        if ( element instanceof IPackageFragmentRoot )
+        {
+            IPackageFragmentRoot f = ( IPackageFragmentRoot ) element;
+            try
+            {
+                return f.getUnderlyingResource().getName();
+            }
+            catch ( JavaModelException e )
+            {
+                return "unknown";
+            }
+        }
+
+        if ( element instanceof IClasspathEntry )
+        {
+            IClasspathEntry cp = ( IClasspathEntry ) element;
+            return cp.getPath().toString();
+        }
+
+        return element.toString();
+    }
+
+
+    private Image findPackage()
+    {
+        Image image = registry.get( "package" );
+
+        if ( image == null )
+        {
+            image = loadImage( "icons/package_obj.png" );
+            registry.put( "package", image );
+        }
+
+        return image;
+    }
+
+
+    private Image findPackageError()
+    {
+        Image image = registry.get( "package_error" );
+        if ( image == null )
+        {
+            image = loadImage( "icons/package_obj_error.gif" );
+            registry.put( "package_error", image );
+        }
+        return image;
+    }
+
+
+    private Image findBundle()
+    {
+        Image image = registry.get( "bundle" );
+
+        if ( image == null )
+        {
+            image = loadImage( "icons/jar_obj.png" );
+            registry.put( "bundle", image );
+        }
+
+        return image;
+    }
+
+
+    private Image loadImage( String resource )
+    {
+        InputStream in = ProjectLabelProvider.class.getClassLoader().getResourceAsStream( resource );
+        ImageData data = new ImageData( in );
+        return new Image( parent.getDisplay(), data );
+    }
 
 }

Modified: felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/ProjectTableViewer.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/ProjectTableViewer.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/ProjectTableViewer.java (original)
+++ felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/ProjectTableViewer.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,7 @@
 
 package org.apache.felix.sigil.ui.eclipse.ui.editors.project;
 
+
 import java.util.Set;
 
 import org.apache.felix.sigil.model.IModelElement;
@@ -27,30 +28,39 @@
 import org.eclipse.jface.viewers.TableViewer;
 import org.eclipse.swt.widgets.Table;
 
-public class ProjectTableViewer extends TableViewer {
 
-	private ModelLabelProvider labelProvider;
+public class ProjectTableViewer extends TableViewer
+{
+
+    private ModelLabelProvider labelProvider;
+
+
+    public ProjectTableViewer( Table table )
+    {
+        super( table );
+        labelProvider = new ModelLabelProvider();
+        setLabelProvider( labelProvider );
+    }
+
+
+    @Override
+    public void setContentProvider( IContentProvider provider )
+    {
+        super.setContentProvider( provider );
+        setInput( getTable() );
+    }
+
+
+    public void setUnresolvedElements( Set<? extends IModelElement> elements )
+    {
+        labelProvider.setUnresolvedElements( elements );
+    }
+
+
+    @Override
+    public ModelLabelProvider getLabelProvider()
+    {
+        return labelProvider;
+    }
 
-	public ProjectTableViewer(Table table) {
-		super(table);
-		labelProvider = new ModelLabelProvider();
-		setLabelProvider(labelProvider);
-	}
-
-	@Override
-	public void setContentProvider(IContentProvider provider) {
-		super.setContentProvider(provider);
-		setInput(getTable());
-	}
-
-	public void setUnresolvedElements(Set<? extends IModelElement> elements) {
-		labelProvider.setUnresolvedElements(elements);
-	}
-
-	@Override
-	public ModelLabelProvider getLabelProvider() {
-		return labelProvider;
-	}
-	
-	
 }
\ No newline at end of file

Modified: felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/PropertiesForm.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/PropertiesForm.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/PropertiesForm.java (original)
+++ felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/PropertiesForm.java Tue Jul 21 18:51:33 2009
@@ -27,23 +27,30 @@
 import org.eclipse.jdt.ui.text.JavaTextTools;
 import org.eclipse.jface.preference.IPreferenceStore;
 
+
 @SuppressWarnings("restriction")
-public class PropertiesForm extends SigilSourcePage {
+public class PropertiesForm extends SigilSourcePage
+{
 
     public static final String PAGE_ID = "properties";
-    
-	public PropertiesForm(SigilProjectEditorPart editor, ISigilProjectModel project) {
-		super(PAGE_ID);
-		JavaTextTools textTools= JavaPlugin.getDefault().getJavaTextTools();
-		IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore();
-		setPreferenceStore(store);
-		setSourceViewerConfiguration(new PropertiesFileSourceViewerConfiguration(textTools.getColorManager(), store, this, IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING));
+
+
+    public PropertiesForm( SigilProjectEditorPart editor, ISigilProjectModel project )
+    {
+        super( PAGE_ID );
+        JavaTextTools textTools = JavaPlugin.getDefault().getJavaTextTools();
+        IPreferenceStore store = JavaPlugin.getDefault().getCombinedPreferenceStore();
+        setPreferenceStore( store );
+        setSourceViewerConfiguration( new PropertiesFileSourceViewerConfiguration( textTools.getColorManager(), store,
+            this, IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING ) );
         /*IFileEditorInput fileInput = (IFileEditorInput) editor.getEditorInput();
-		this.setDocumentProvider(fileInput);*/
-	}
+        this.setDocumentProvider(fileInput);*/
+    }
+
 
-	@Override
-	public boolean isSaveAsAllowed() {
-		return false;
-	}	
+    @Override
+    public boolean isSaveAsAllowed()
+    {
+        return false;
+    }
 }

Modified: felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/RequiresBundleSection.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/RequiresBundleSection.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/RequiresBundleSection.java (original)
+++ felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/RequiresBundleSection.java Tue Jul 21 18:51:33 2009
@@ -42,94 +42,127 @@
 import org.eclipse.swt.widgets.Label;
 import org.eclipse.ui.forms.widgets.FormToolkit;
 
-public class RequiresBundleSection extends BundleDependencySection {
-	
-	public RequiresBundleSection(SigilPage page, Composite parent, ISigilProjectModel project, Set<IModelElement> unresolvedElements) throws CoreException {
-		super( page, parent, project, unresolvedElements );
-	}
-	
-	@Override
-	protected String getTitle() {
-		return "Requires Bundles";
-	}
-	
-	@Override
-	protected Label createLabel(Composite parent, FormToolkit toolkit) {
-		return toolkit.createLabel( parent, "Specify which bundles this bundle depends on." );
-	}
-	
-	@Override
-	protected IContentProvider getContentProvider() {
-		return new DefaultTableProvider() {
-			public Object[] getElements(Object inputElement) {
-				return getBundle().getBundleInfo().getRequiredBundles().toArray();
-			}
-		};
-	}
-
-	protected ISigilBundle getBundle() {
-		return getProjectModel().getBundle();
-	}
-
-	@Override
-	protected void handleAdd() {
-		try {
-			NewResourceSelectionDialog<IBundleModelElement> dialog = ResourcesDialogHelper.createRequiredBundleDialog( getSection().getShell(), "Add Required Bundle", getProjectModel(), null, getBundle().getBundleInfo().getRequiredBundles() );
-			
-			if (dialog.open() == Window.OK) {
-				IRequiredBundle required = ModelElementFactory.getInstance().newModelElement( IRequiredBundle.class );
-				required.setSymbolicName(dialog.getSelectedName());
-				required.setVersions(dialog.getSelectedVersions());
-				required.setOptional(dialog.isOptional());
-				
-				getBundle().getBundleInfo().addRequiredBundle(required);
-				refresh();
-				markDirty();
-			}
-		}
-		catch (ModelElementFactoryException e) {
-			SigilCore.error( "Failed to build required bundle", e );
-		}
-	}
-
-	@SuppressWarnings("unchecked")
-	@Override
-	protected void handleEdit() {
-		IStructuredSelection selection = (IStructuredSelection) getSelection();
-		
-		boolean changed = false;
-		
-		if ( !selection.isEmpty() ) {
-			for ( Iterator<IRequiredBundle> i = selection.iterator(); i.hasNext(); ) {	
-				IRequiredBundle requiredBundle = i.next();
-				NewResourceSelectionDialog<IBundleModelElement> dialog = ResourcesDialogHelper.createRequiredBundleDialog(getSection().getShell(), "Edit Imported Package", getProjectModel(), requiredBundle, getBundle().getBundleInfo().getRequiredBundles() );
-				if ( dialog.open() == Window.OK ) {
-					changed = true;
-					requiredBundle.setSymbolicName(dialog.getSelectedName());
-					requiredBundle.setVersions(dialog.getSelectedVersions());
-					requiredBundle.setOptional(dialog.isOptional());
-				}
-			}					
-		}
-		
-		if ( changed ) {
-			refresh();
-			markDirty();
-		}
-	}
-	
-	@SuppressWarnings("unchecked")
-	@Override
-	protected void handleRemoved() {
-		IStructuredSelection selection = (IStructuredSelection) getSelection();
-
-		if ( !selection.isEmpty() ) {
-			for ( Iterator<IRequiredBundle> i = selection.iterator(); i.hasNext(); ) {			
-				getBundle().getBundleInfo().removeRequiredBundle( i.next() );
-			}		
-			
-			refresh();
-			markDirty();
-		}
-	}
+
+public class RequiresBundleSection extends BundleDependencySection
+{
+
+    public RequiresBundleSection( SigilPage page, Composite parent, ISigilProjectModel project,
+        Set<IModelElement> unresolvedElements ) throws CoreException
+    {
+        super( page, parent, project, unresolvedElements );
+    }
+
+
+    @Override
+    protected String getTitle()
+    {
+        return "Requires Bundles";
+    }
+
+
+    @Override
+    protected Label createLabel( Composite parent, FormToolkit toolkit )
+    {
+        return toolkit.createLabel( parent, "Specify which bundles this bundle depends on." );
+    }
+
+
+    @Override
+    protected IContentProvider getContentProvider()
+    {
+        return new DefaultTableProvider()
+        {
+            public Object[] getElements( Object inputElement )
+            {
+                return getBundle().getBundleInfo().getRequiredBundles().toArray();
+            }
+        };
+    }
+
+
+    protected ISigilBundle getBundle()
+    {
+        return getProjectModel().getBundle();
+    }
+
+
+    @Override
+    protected void handleAdd()
+    {
+        try
+        {
+            NewResourceSelectionDialog<IBundleModelElement> dialog = ResourcesDialogHelper.createRequiredBundleDialog(
+                getSection().getShell(), "Add Required Bundle", getProjectModel(), null, getBundle().getBundleInfo()
+                    .getRequiredBundles() );
+
+            if ( dialog.open() == Window.OK )
+            {
+                IRequiredBundle required = ModelElementFactory.getInstance().newModelElement( IRequiredBundle.class );
+                required.setSymbolicName( dialog.getSelectedName() );
+                required.setVersions( dialog.getSelectedVersions() );
+                required.setOptional( dialog.isOptional() );
+
+                getBundle().getBundleInfo().addRequiredBundle( required );
+                refresh();
+                markDirty();
+            }
+        }
+        catch ( ModelElementFactoryException e )
+        {
+            SigilCore.error( "Failed to build required bundle", e );
+        }
+    }
+
+
+    @SuppressWarnings("unchecked")
+    @Override
+    protected void handleEdit()
+    {
+        IStructuredSelection selection = ( IStructuredSelection ) getSelection();
+
+        boolean changed = false;
+
+        if ( !selection.isEmpty() )
+        {
+            for ( Iterator<IRequiredBundle> i = selection.iterator(); i.hasNext(); )
+            {
+                IRequiredBundle requiredBundle = i.next();
+                NewResourceSelectionDialog<IBundleModelElement> dialog = ResourcesDialogHelper
+                    .createRequiredBundleDialog( getSection().getShell(), "Edit Imported Package", getProjectModel(),
+                        requiredBundle, getBundle().getBundleInfo().getRequiredBundles() );
+                if ( dialog.open() == Window.OK )
+                {
+                    changed = true;
+                    requiredBundle.setSymbolicName( dialog.getSelectedName() );
+                    requiredBundle.setVersions( dialog.getSelectedVersions() );
+                    requiredBundle.setOptional( dialog.isOptional() );
+                }
+            }
+        }
+
+        if ( changed )
+        {
+            refresh();
+            markDirty();
+        }
+    }
+
+
+    @SuppressWarnings("unchecked")
+    @Override
+    protected void handleRemoved()
+    {
+        IStructuredSelection selection = ( IStructuredSelection ) getSelection();
+
+        if ( !selection.isEmpty() )
+        {
+            for ( Iterator<IRequiredBundle> i = selection.iterator(); i.hasNext(); )
+            {
+                getBundle().getBundleInfo().removeRequiredBundle( i.next() );
+            }
+
+            refresh();
+            markDirty();
+        }
+    }
 }

Modified: felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/ResourceBuildSection.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/ResourceBuildSection.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/ResourceBuildSection.java (original)
+++ felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/ResourceBuildSection.java Tue Jul 21 18:51:33 2009
@@ -20,7 +20,6 @@
 package org.apache.felix.sigil.ui.eclipse.ui.editors.project;
 
 
-
 import org.apache.felix.sigil.eclipse.SigilCore;
 import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
 import org.apache.felix.sigil.model.eclipse.ISigilBundle;
@@ -47,120 +46,151 @@
 import org.eclipse.ui.forms.widgets.Section;
 import org.eclipse.ui.forms.widgets.TableWrapData;
 
+
 /**
  * @author dave
  *
  */
-public class ResourceBuildSection extends AbstractResourceSection implements ICheckStateListener, IResourceChangeListener, IPropertyChangeListener {
+public class ResourceBuildSection extends AbstractResourceSection implements ICheckStateListener,
+    IResourceChangeListener, IPropertyChangeListener
+{
+
+    private ExcludedResourcesFilter resourcesFilter;
+
+
+    /**
+     * @param page
+     * @param parent
+     * @param project
+     * @throws CoreException 
+     */
+    public ResourceBuildSection( SigilPage page, Composite parent, ISigilProjectModel project ) throws CoreException
+    {
+        super( page, parent, project );
+    }
+
+
+    @Override
+    protected void createSection( Section section, FormToolkit toolkit )
+    {
+        setTitle( "Resources" );
 
-	private ExcludedResourcesFilter resourcesFilter;
-
-	/**
-	 * @param page
-	 * @param parent
-	 * @param project
-	 * @throws CoreException 
-	 */
-	public ResourceBuildSection(SigilPage page, Composite parent, ISigilProjectModel project) throws CoreException {
-		super( page, parent, project );
-	}
-
-	@Override
-	protected void createSection(Section section, FormToolkit toolkit) {
-		setTitle( "Resources" );
-		
-		Composite body = createTableWrapBody(1, toolkit);
+        Composite body = createTableWrapBody( 1, toolkit );
 
         toolkit.createLabel( body, "Specify which resources are included in the bundle." );
-		
-		tree = toolkit.createTree( body, SWT.CHECK | SWT.BORDER );
-		Link link = new Link(body, SWT.WRAP);
-		link.setText("Some resources may be filtered according to preferences. <a href=\"excludedResourcePrefs\">Click here</a> to edit the list of exclusions.");
-		
-		TableWrapData data = new TableWrapData( TableWrapData.FILL_GRAB);
-		data.heightHint = 200;
-		tree.setLayoutData( data );
-		
-		viewer = new CheckboxTreeViewer( tree );
-		IProject base = getProjectModel().getProject();
-		viewer.setContentProvider( new ContainerTreeProvider() );
-		viewer.setLabelProvider( new ModelLabelProvider() );
-		viewer.addCheckStateListener( this );
-		resourcesFilter = new ExcludedResourcesFilter();
-		viewer.addFilter(resourcesFilter);
-		viewer.setInput(base);
-		
-		link.addListener(SWT.Selection, new Listener() {
-			public void handleEvent(Event event) {
-				if("excludedResourcePrefs".equals(event.text)) {
-					PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(getPage().getEditorSite().getShell(), SigilCore.EXCLUDED_RESOURCES_PREFERENCES_ID, null, null);
-					dialog.open();
-				}
-			}
-		});
-		
-		SigilCore.getDefault().getPreferenceStore().addPropertyChangeListener(this);
-		
-		startWorkspaceListener(base.getWorkspace());
-	}
-
-	@Override
-	public void commit(boolean onSave) {
-		ISigilBundle bundle = getProjectModel().getBundle();
-		
-		bundle.clearSourcePaths();
-		
-		SigilUI.runInUISync( new Runnable() {
-			public void run() {
-				for ( Object o : viewer.getCheckedElements() ) {
-					if ( !viewer.getGrayed(o) ) {
-						IResource r = (IResource) o;
-						getProjectModel().getBundle().addSourcePath( r.getProjectRelativePath() );
-					}
-				}
-			}			
-		});
-		
-		super.commit(onSave);
-	}
-
-	@Override
-	protected void refreshSelections()  {
-		// zero the state
-		for ( IPath path : getProjectModel().getBundle().getSourcePaths() ) {
-			IResource r = findResource( path );
-			if ( r != null ) {
-				viewer.expandToLevel(r, 0);
-				viewer.setChecked( r, true );
-				viewer.setGrayed( r, false );
-				handleStateChanged(r, true, false, false);
-			}
-			else {
-				SigilCore.error( "Unknown path " + path );
-			}
-		}
-	}
-	
-	@Override
-	protected void syncResourceModel(IResource element, boolean checked) {
-		if ( checked ) {
-			getProjectModel().getBundle().addSourcePath( element.getProjectRelativePath() );
-		}
-		else {
-			getProjectModel().getBundle().removeSourcePath( element.getProjectRelativePath() );
-		}
-		
-		markDirty();
-	}
-	
-	@Override
-	public void dispose() {
-		super.dispose();
-		SigilCore.getDefault().getPreferenceStore().removePropertyChangeListener(this);
-	}
-
-	public void propertyChange(PropertyChangeEvent event) {
-		resourcesFilter.loadExclusions();
-		viewer.refresh();
-	}
+
+        tree = toolkit.createTree( body, SWT.CHECK | SWT.BORDER );
+        Link link = new Link( body, SWT.WRAP );
+        link
+            .setText( "Some resources may be filtered according to preferences. <a href=\"excludedResourcePrefs\">Click here</a> to edit the list of exclusions." );
+
+        TableWrapData data = new TableWrapData( TableWrapData.FILL_GRAB );
+        data.heightHint = 200;
+        tree.setLayoutData( data );
+
+        viewer = new CheckboxTreeViewer( tree );
+        IProject base = getProjectModel().getProject();
+        viewer.setContentProvider( new ContainerTreeProvider() );
+        viewer.setLabelProvider( new ModelLabelProvider() );
+        viewer.addCheckStateListener( this );
+        resourcesFilter = new ExcludedResourcesFilter();
+        viewer.addFilter( resourcesFilter );
+        viewer.setInput( base );
+
+        link.addListener( SWT.Selection, new Listener()
+        {
+            public void handleEvent( Event event )
+            {
+                if ( "excludedResourcePrefs".equals( event.text ) )
+                {
+                    PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn( getPage().getEditorSite()
+                        .getShell(), SigilCore.EXCLUDED_RESOURCES_PREFERENCES_ID, null, null );
+                    dialog.open();
+                }
+            }
+        } );
+
+        SigilCore.getDefault().getPreferenceStore().addPropertyChangeListener( this );
+
+        startWorkspaceListener( base.getWorkspace() );
+    }
+
+
+    @Override
+    public void commit( boolean onSave )
+    {
+        ISigilBundle bundle = getProjectModel().getBundle();
+
+        bundle.clearSourcePaths();
+
+        SigilUI.runInUISync( new Runnable()
+        {
+            public void run()
+            {
+                for ( Object o : viewer.getCheckedElements() )
+                {
+                    if ( !viewer.getGrayed( o ) )
+                    {
+                        IResource r = ( IResource ) o;
+                        getProjectModel().getBundle().addSourcePath( r.getProjectRelativePath() );
+                    }
+                }
+            }
+        } );
+
+        super.commit( onSave );
+    }
+
+
+    @Override
+    protected void refreshSelections()
+    {
+        // zero the state
+        for ( IPath path : getProjectModel().getBundle().getSourcePaths() )
+        {
+            IResource r = findResource( path );
+            if ( r != null )
+            {
+                viewer.expandToLevel( r, 0 );
+                viewer.setChecked( r, true );
+                viewer.setGrayed( r, false );
+                handleStateChanged( r, true, false, false );
+            }
+            else
+            {
+                SigilCore.error( "Unknown path " + path );
+            }
+        }
+    }
+
+
+    @Override
+    protected void syncResourceModel( IResource element, boolean checked )
+    {
+        if ( checked )
+        {
+            getProjectModel().getBundle().addSourcePath( element.getProjectRelativePath() );
+        }
+        else
+        {
+            getProjectModel().getBundle().removeSourcePath( element.getProjectRelativePath() );
+        }
+
+        markDirty();
+    }
+
+
+    @Override
+    public void dispose()
+    {
+        super.dispose();
+        SigilCore.getDefault().getPreferenceStore().removePropertyChangeListener( this );
+    }
+
+
+    public void propertyChange( PropertyChangeEvent event )
+    {
+        resourcesFilter.loadExclusions();
+        viewer.refresh();
+    }
 }

Modified: felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/ResourceImportDialog.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/ResourceImportDialog.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/ResourceImportDialog.java (original)
+++ felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/ResourceImportDialog.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,7 @@
 
 package org.apache.felix.sigil.ui.eclipse.ui.editors.project;
 
+
 import org.apache.felix.sigil.model.ModelElementFactory;
 import org.apache.felix.sigil.model.common.VersionRange;
 import org.apache.felix.sigil.model.osgi.IPackageImport;
@@ -30,60 +31,81 @@
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Shell;
 
-public class ResourceImportDialog extends ResourceSelectDialog implements VersionsChangeListener {
 
-	private VersionRangeComponent versions;
-	private VersionRange range;
-	
-	public ResourceImportDialog(Shell parentShell, String title, String label, IContentProvider content, ViewerFilter filter, Object scope ) {
-		super(parentShell, content, filter, scope, title, label, true);
-	}
-
-	public VersionRange getVersions() {
-		return range;
-	}
-
-	@Override
-	protected void createCustom(Composite body) {
-		versions = new VersionRangeComponent(body, SWT.BORDER );
-		versions.addVersionChangeListener(this);
-		versions.setVersions(range);
-		
-		GridData data = new GridData( SWT.LEFT, SWT.TOP, true, true );
-		data.horizontalSpan = 2;
-		data.widthHint = 300;
-		data.heightHint = 200;
-		versions.setLayoutData(data);
-	}
-
-	@Override
-	protected void selectionChanged(SelectionChangedEvent event) {
-		if ( event.getSelection().isEmpty() ) {
-			versions.setEnabled(false);
-		}
-		else {
-			versions.setEnabled(true);
-		}
-	}
-
-	public void versionsChanged(VersionRange range) {
-		this.range = range; 
-		if ( range == null ) {
-			setErrorMessage( "Invalid version" );
-		}
-		else {
-			setErrorMessage( null );
-		}
-	}
-
-	public void setVersions(VersionRange range) {
-		this.range = range;
-	}
-
-	public IPackageImport getImport() {
-		IPackageImport packageImport = ModelElementFactory.getInstance().newModelElement( IPackageImport.class );
-		packageImport.setPackageName( (String) getSelected()[0] );
-		packageImport.setVersions( getVersions() );
-		return packageImport;
-	}
+public class ResourceImportDialog extends ResourceSelectDialog implements VersionsChangeListener
+{
+
+    private VersionRangeComponent versions;
+    private VersionRange range;
+
+
+    public ResourceImportDialog( Shell parentShell, String title, String label, IContentProvider content,
+        ViewerFilter filter, Object scope )
+    {
+        super( parentShell, content, filter, scope, title, label, true );
+    }
+
+
+    public VersionRange getVersions()
+    {
+        return range;
+    }
+
+
+    @Override
+    protected void createCustom( Composite body )
+    {
+        versions = new VersionRangeComponent( body, SWT.BORDER );
+        versions.addVersionChangeListener( this );
+        versions.setVersions( range );
+
+        GridData data = new GridData( SWT.LEFT, SWT.TOP, true, true );
+        data.horizontalSpan = 2;
+        data.widthHint = 300;
+        data.heightHint = 200;
+        versions.setLayoutData( data );
+    }
+
+
+    @Override
+    protected void selectionChanged( SelectionChangedEvent event )
+    {
+        if ( event.getSelection().isEmpty() )
+        {
+            versions.setEnabled( false );
+        }
+        else
+        {
+            versions.setEnabled( true );
+        }
+    }
+
+
+    public void versionsChanged( VersionRange range )
+    {
+        this.range = range;
+        if ( range == null )
+        {
+            setErrorMessage( "Invalid version" );
+        }
+        else
+        {
+            setErrorMessage( null );
+        }
+    }
+
+
+    public void setVersions( VersionRange range )
+    {
+        this.range = range;
+    }
+
+
+    public IPackageImport getImport()
+    {
+        IPackageImport packageImport = ModelElementFactory.getInstance().newModelElement( IPackageImport.class );
+        packageImport.setPackageName( ( String ) getSelected()[0] );
+        packageImport.setVersions( getVersions() );
+        return packageImport;
+    }
 }

Modified: felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/ResourceSelectDialog.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/ResourceSelectDialog.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/ResourceSelectDialog.java (original)
+++ felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/ResourceSelectDialog.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,7 @@
 
 package org.apache.felix.sigil.ui.eclipse.ui.editors.project;
 
+
 import java.util.concurrent.Executors;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
@@ -57,316 +58,403 @@
 import org.eclipse.swt.widgets.Table;
 import org.eclipse.swt.widgets.Text;
 
-public class ResourceSelectDialog extends Dialog {
 
-	private AtomicInteger keyCheck = new AtomicInteger();
-	private ScheduledExecutorService background = Executors.newSingleThreadScheduledExecutor();
-	
-	private class UpdateViewerRunnable implements Runnable {
-		private int check;
-		public UpdateViewerRunnable(int check) {
-			this.check = check;
-		}
-
-		public void run() {
-			if ( check == keyCheck.get() ) {
-				try {
-					viewer.refresh();
-				}
-				catch (SWTException e) {
-					// discard
-				}
-			}
-		}
-	}
-
-	private static final ISelection EMPTY_SELECTION = new ISelection() {
-		public boolean isEmpty() {
-			return true;
-		}
-	};
-	
-	private Job job;
-	
-	private boolean isCombo;
-	private String title;
-	private String selectionText;
-
-	private StructuredViewer viewer;
-	private Combo resourceNameCombo;
-	private Table resourceNameTable;
-	private Text errorMessageText;
-	private String errorMessage;
-	
-	private ViewerFilter filter;
-	private Object[] selected;
-	
-	private Object scope;	
-	private IContentProvider content;
-	private ILabelProvider labelProvider;
-
-	public ResourceSelectDialog(Shell parentShell, IContentProvider content, ViewerFilter filter, Object scope, String title, String selectionText, boolean isCombo) {
-		super(parentShell);
-		this.title = title;
-		this.selectionText = selectionText;
-		this.content = content;
-		this.filter = filter;
-		this.scope = scope;
-		this.isCombo = isCombo;
-	}
-	
-	public void setJob(Job job) {
-		this.job = job;
-	}
-	
-	public void refreshResources() {
-		try {
-			getShell().getDisplay().asyncExec( new Runnable() {
-				public void run() {
-					try {
-						viewer.refresh();
-					}
-					catch (SWTException e) {
-						// attempt to exec after dialog closed - discard
-					}
-				}
-			});
-		}
-		catch (NullPointerException e) {
-			// attempt to exec after dialog closed - discard
-		}
-		catch (SWTException e) {
-			// attempt to exec after dialog closed - discard
-		}
-	}
+public class ResourceSelectDialog extends Dialog
+{
+
+    private AtomicInteger keyCheck = new AtomicInteger();
+    private ScheduledExecutorService background = Executors.newSingleThreadScheduledExecutor();
+
+    private class UpdateViewerRunnable implements Runnable
+    {
+        private int check;
+
+
+        public UpdateViewerRunnable( int check )
+        {
+            this.check = check;
+        }
+
+
+        public void run()
+        {
+            if ( check == keyCheck.get() )
+            {
+                try
+                {
+                    viewer.refresh();
+                }
+                catch ( SWTException e )
+                {
+                    // discard
+                }
+            }
+        }
+    }
+
+    private static final ISelection EMPTY_SELECTION = new ISelection()
+    {
+        public boolean isEmpty()
+        {
+            return true;
+        }
+    };
+
+    private Job job;
+
+    private boolean isCombo;
+    private String title;
+    private String selectionText;
+
+    private StructuredViewer viewer;
+    private Combo resourceNameCombo;
+    private Table resourceNameTable;
+    private Text errorMessageText;
+    private String errorMessage;
+
+    private ViewerFilter filter;
+    private Object[] selected;
+
+    private Object scope;
+    private IContentProvider content;
+    private ILabelProvider labelProvider;
+
+
+    public ResourceSelectDialog( Shell parentShell, IContentProvider content, ViewerFilter filter, Object scope,
+        String title, String selectionText, boolean isCombo )
+    {
+        super( parentShell );
+        this.title = title;
+        this.selectionText = selectionText;
+        this.content = content;
+        this.filter = filter;
+        this.scope = scope;
+        this.isCombo = isCombo;
+    }
+
 
-	/*
+    public void setJob( Job job )
+    {
+        this.job = job;
+    }
+
+
+    public void refreshResources()
+    {
+        try
+        {
+            getShell().getDisplay().asyncExec( new Runnable()
+            {
+                public void run()
+                {
+                    try
+                    {
+                        viewer.refresh();
+                    }
+                    catch ( SWTException e )
+                    {
+                        // attempt to exec after dialog closed - discard
+                    }
+                }
+            } );
+        }
+        catch ( NullPointerException e )
+        {
+            // attempt to exec after dialog closed - discard
+        }
+        catch ( SWTException e )
+        {
+            // attempt to exec after dialog closed - discard
+        }
+    }
+
+
+    /*
      * (non-Javadoc)
      * 
      * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
      */
-    protected void configureShell(Shell shell) {
-        super.configureShell(shell);
-        if (title != null) {
-			shell.setText(title);
-		}        
-    }
-
-	@Override
-	public void create() {
-		super.create();
-		if ( getItemCount() == 0 ) {
-			setErrorMessage( "No resources available" );
-			getButton(IDialogConstants.OK_ID).setEnabled(false);
-		}
-		else {
-			ISelection selection = selected == null ? EMPTY_SELECTION : new SingletonSelection( selected );
-			setSelected( new SelectionChangedEvent( viewer, selection ), true );
-		}
-		
-		if ( job != null ) {
-			job.schedule();
-		}
-	}
-
-	@Override
-	public boolean close() {
-		if ( job != null ) {
-			job.cancel();
-		}
-		background.shutdownNow();
-		return super.close();
-	}
-
-	private int getItemCount() {
-		if ( isCombo ) {
-			return resourceNameCombo.getItemCount();
-		}
-		else {
-			return resourceNameTable.getItemCount();
-		}
-	}
-
-	@Override
-	protected Control createDialogArea(Composite parent) {
-		Composite body = (Composite) super.createDialogArea(parent);
-		
-		GridLayout layout = (GridLayout) body.getLayout();
-		layout.numColumns = 2;
-		GridData data;
-		
-		labelProvider = new ModelLabelProvider();
-		
-		Label l = new Label( body, SWT.LEFT );
-		l.setText( selectionText );
-		data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
-		if ( !isCombo ) {
-			data.horizontalSpan = 2;
-		}
-		l.setLayoutData( data );
-	
-		if ( isCombo ) {
-			createCombo( body );
-		}
-		else {
-			createTable( body );
-		}
-		
-		viewer.addFilter( filter );
-		viewer.setContentProvider(content);
-		viewer.setLabelProvider( getLabelProvider() );
-		viewer.setComparator( new ViewerComparator() );
-		viewer.setInput( scope );
-		
-		viewer.addSelectionChangedListener( new ISelectionChangedListener() {
-			public void selectionChanged(SelectionChangedEvent event) {
-				setSelected(event, false);
-			}			
-		});
-	    createCustom( body );
-	    
-		errorMessageText = new Text(body, SWT.READ_ONLY | SWT.WRAP);
-		data = new GridData(GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL);
-		data.horizontalSpan = 2;
-	    errorMessageText.setLayoutData(data);
-	    errorMessageText.setBackground(errorMessageText.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
-	    setErrorMessage(errorMessage);
-	    
-		return body;
-	}
-	
-    protected void createCustom(Composite body) {
-	}
-
-	private void createCombo(Composite body) {
-		resourceNameCombo = new Combo( body, SWT.SINGLE | SWT.BORDER );
-		GridData data = new GridData( GridData.HORIZONTAL_ALIGN_END);
-		data.widthHint = 200;
-		resourceNameCombo.setLayoutData( data );
-		
-		viewer = new ComboViewer(resourceNameCombo);
-	}
-
-	private void createTable(Composite body) {
-		final Text txtFilter = new Text(body, SWT.BORDER);
-		GridData data = new GridData( GridData.HORIZONTAL_ALIGN_END);
-		data.horizontalSpan = 2;
-		data.widthHint = 400;
-		txtFilter.setLayoutData(data);
-		
-		resourceNameTable = new Table( body, SWT.MULTI | SWT.BORDER );
-		data = new GridData( GridData.HORIZONTAL_ALIGN_END);
-		data.widthHint = 400;
-		data.heightHint = 400;
-		resourceNameTable.setLayoutData( data );
-		
-		viewer = new TableViewer(resourceNameTable);
-
-		txtFilter.addKeyListener( new KeyAdapter() {
-			@Override
-			public void keyReleased(KeyEvent e) {
-				switch ( e.keyCode ) {
-				case SWT.ARROW_UP:
-					scrollTable(-1);
-					break;
-				case SWT.ARROW_DOWN:
-					scrollTable(+1);
-					break;
-				default:
-					Runnable r = new UpdateViewerRunnable(keyCheck.incrementAndGet());
-					background.schedule(r, 100, TimeUnit.MILLISECONDS);
-					break;
-				}
-			}
-		});
-		
-		ViewerFilter filter = new ViewerFilter() {
-			@Override
-			public boolean select(Viewer viewer, Object parentElement,
-					Object element) {
-				return getLabelProvider().getText(element).startsWith( txtFilter.getText() );
-			}
-		};
-		
-		viewer.addFilter(filter);
-	}
-	
-	private void scrollTable(int delta) {
-		int i = resourceNameTable.getSelectionIndex();
-		
-		if ( i == -1 ) {
-			if ( delta < 0 ) { 
-				i = resourceNameTable.getItemCount() - 1;
-			}
-			else {
-				i = 0;
-			}
-		}
-		else {
-			i+=delta;
-		}
-		
-		if ( i > -1 && i < resourceNameTable.getItemCount() ) {
-			Item item = resourceNameTable.getItem(i);
-			resourceNameTable.select(i);
-			selected = new Object[] { item.getData() };
-			ISelection selection = new SingletonSelection( selected );
-			selectionChanged(new SelectionChangedEvent(viewer, selection));
-			viewer.reveal(selected);
-		}
-	}
-
-	private void setSelected(SelectionChangedEvent event, boolean reveal) {
-		if ( event.getSelection().isEmpty() ) {
-			selected = null;
-			setErrorMessage( "No resource selected" );
-		}
-		else {
-			selected = ((IStructuredSelection) event.getSelection()).toArray();
-			setErrorMessage( null );
-		}
-		
-		selectionChanged(event);
-		
-		if ( reveal && !event.getSelection().isEmpty() ) {
-			if ( resourceNameCombo != null ) {
-				IStructuredSelection sel = (IStructuredSelection) event.getSelection();
-				resourceNameCombo.select(resourceNameCombo.indexOf((String) sel.getFirstElement()));
-			}
-			else {
-				viewer.setSelection(event.getSelection(), true);
-			}
-		}
-	}
-
-	protected ILabelProvider getLabelProvider() {
-		return labelProvider;
-	}
-
-	public Object[] getSelected() {
-    	return selected;
-    }
-	
-	public void setSelected(Object[] selected) {
-		this.selected = selected;
-	}
-	
-	protected void selectionChanged(SelectionChangedEvent event) {
-	}
-
-	public void setErrorMessage(String errorMessage) {
-		this.errorMessage = errorMessage;
-		if (errorMessageText != null && !errorMessageText.isDisposed()) {
-			errorMessageText.setText(errorMessage == null ? " \n " : errorMessage); 
-			boolean hasError = errorMessage != null && (StringConverter.removeWhiteSpaces(errorMessage)).length() > 0;
-			errorMessageText.setEnabled(hasError);
-			errorMessageText.setVisible(hasError);
-			errorMessageText.getParent().update();
-			Control ok = getButton(IDialogConstants.OK_ID);
-			if (ok != null) {
-				ok.setEnabled(!hasError);
-			}
-		}
-	}
+    protected void configureShell( Shell shell )
+    {
+        super.configureShell( shell );
+        if ( title != null )
+        {
+            shell.setText( title );
+        }
+    }
+
+
+    @Override
+    public void create()
+    {
+        super.create();
+        if ( getItemCount() == 0 )
+        {
+            setErrorMessage( "No resources available" );
+            getButton( IDialogConstants.OK_ID ).setEnabled( false );
+        }
+        else
+        {
+            ISelection selection = selected == null ? EMPTY_SELECTION : new SingletonSelection( selected );
+            setSelected( new SelectionChangedEvent( viewer, selection ), true );
+        }
+
+        if ( job != null )
+        {
+            job.schedule();
+        }
+    }
+
+
+    @Override
+    public boolean close()
+    {
+        if ( job != null )
+        {
+            job.cancel();
+        }
+        background.shutdownNow();
+        return super.close();
+    }
+
+
+    private int getItemCount()
+    {
+        if ( isCombo )
+        {
+            return resourceNameCombo.getItemCount();
+        }
+        else
+        {
+            return resourceNameTable.getItemCount();
+        }
+    }
+
+
+    @Override
+    protected Control createDialogArea( Composite parent )
+    {
+        Composite body = ( Composite ) super.createDialogArea( parent );
+
+        GridLayout layout = ( GridLayout ) body.getLayout();
+        layout.numColumns = 2;
+        GridData data;
+
+        labelProvider = new ModelLabelProvider();
+
+        Label l = new Label( body, SWT.LEFT );
+        l.setText( selectionText );
+        data = new GridData( GridData.HORIZONTAL_ALIGN_BEGINNING );
+        if ( !isCombo )
+        {
+            data.horizontalSpan = 2;
+        }
+        l.setLayoutData( data );
+
+        if ( isCombo )
+        {
+            createCombo( body );
+        }
+        else
+        {
+            createTable( body );
+        }
+
+        viewer.addFilter( filter );
+        viewer.setContentProvider( content );
+        viewer.setLabelProvider( getLabelProvider() );
+        viewer.setComparator( new ViewerComparator() );
+        viewer.setInput( scope );
+
+        viewer.addSelectionChangedListener( new ISelectionChangedListener()
+        {
+            public void selectionChanged( SelectionChangedEvent event )
+            {
+                setSelected( event, false );
+            }
+        } );
+        createCustom( body );
+
+        errorMessageText = new Text( body, SWT.READ_ONLY | SWT.WRAP );
+        data = new GridData( GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL );
+        data.horizontalSpan = 2;
+        errorMessageText.setLayoutData( data );
+        errorMessageText.setBackground( errorMessageText.getDisplay().getSystemColor( SWT.COLOR_WIDGET_BACKGROUND ) );
+        setErrorMessage( errorMessage );
+
+        return body;
+    }
+
+
+    protected void createCustom( Composite body )
+    {
+    }
+
+
+    private void createCombo( Composite body )
+    {
+        resourceNameCombo = new Combo( body, SWT.SINGLE | SWT.BORDER );
+        GridData data = new GridData( GridData.HORIZONTAL_ALIGN_END );
+        data.widthHint = 200;
+        resourceNameCombo.setLayoutData( data );
+
+        viewer = new ComboViewer( resourceNameCombo );
+    }
+
+
+    private void createTable( Composite body )
+    {
+        final Text txtFilter = new Text( body, SWT.BORDER );
+        GridData data = new GridData( GridData.HORIZONTAL_ALIGN_END );
+        data.horizontalSpan = 2;
+        data.widthHint = 400;
+        txtFilter.setLayoutData( data );
+
+        resourceNameTable = new Table( body, SWT.MULTI | SWT.BORDER );
+        data = new GridData( GridData.HORIZONTAL_ALIGN_END );
+        data.widthHint = 400;
+        data.heightHint = 400;
+        resourceNameTable.setLayoutData( data );
+
+        viewer = new TableViewer( resourceNameTable );
+
+        txtFilter.addKeyListener( new KeyAdapter()
+        {
+            @Override
+            public void keyReleased( KeyEvent e )
+            {
+                switch ( e.keyCode )
+                {
+                    case SWT.ARROW_UP:
+                        scrollTable( -1 );
+                        break;
+                    case SWT.ARROW_DOWN:
+                        scrollTable( +1 );
+                        break;
+                    default:
+                        Runnable r = new UpdateViewerRunnable( keyCheck.incrementAndGet() );
+                        background.schedule( r, 100, TimeUnit.MILLISECONDS );
+                        break;
+                }
+            }
+        } );
+
+        ViewerFilter filter = new ViewerFilter()
+        {
+            @Override
+            public boolean select( Viewer viewer, Object parentElement, Object element )
+            {
+                return getLabelProvider().getText( element ).startsWith( txtFilter.getText() );
+            }
+        };
+
+        viewer.addFilter( filter );
+    }
+
+
+    private void scrollTable( int delta )
+    {
+        int i = resourceNameTable.getSelectionIndex();
+
+        if ( i == -1 )
+        {
+            if ( delta < 0 )
+            {
+                i = resourceNameTable.getItemCount() - 1;
+            }
+            else
+            {
+                i = 0;
+            }
+        }
+        else
+        {
+            i += delta;
+        }
+
+        if ( i > -1 && i < resourceNameTable.getItemCount() )
+        {
+            Item item = resourceNameTable.getItem( i );
+            resourceNameTable.select( i );
+            selected = new Object[]
+                { item.getData() };
+            ISelection selection = new SingletonSelection( selected );
+            selectionChanged( new SelectionChangedEvent( viewer, selection ) );
+            viewer.reveal( selected );
+        }
+    }
+
+
+    private void setSelected( SelectionChangedEvent event, boolean reveal )
+    {
+        if ( event.getSelection().isEmpty() )
+        {
+            selected = null;
+            setErrorMessage( "No resource selected" );
+        }
+        else
+        {
+            selected = ( ( IStructuredSelection ) event.getSelection() ).toArray();
+            setErrorMessage( null );
+        }
+
+        selectionChanged( event );
+
+        if ( reveal && !event.getSelection().isEmpty() )
+        {
+            if ( resourceNameCombo != null )
+            {
+                IStructuredSelection sel = ( IStructuredSelection ) event.getSelection();
+                resourceNameCombo.select( resourceNameCombo.indexOf( ( String ) sel.getFirstElement() ) );
+            }
+            else
+            {
+                viewer.setSelection( event.getSelection(), true );
+            }
+        }
+    }
+
+
+    protected ILabelProvider getLabelProvider()
+    {
+        return labelProvider;
+    }
+
+
+    public Object[] getSelected()
+    {
+        return selected;
+    }
+
+
+    public void setSelected( Object[] selected )
+    {
+        this.selected = selected;
+    }
+
+
+    protected void selectionChanged( SelectionChangedEvent event )
+    {
+    }
+
+
+    public void setErrorMessage( String errorMessage )
+    {
+        this.errorMessage = errorMessage;
+        if ( errorMessageText != null && !errorMessageText.isDisposed() )
+        {
+            errorMessageText.setText( errorMessage == null ? " \n " : errorMessage );
+            boolean hasError = errorMessage != null
+                && ( StringConverter.removeWhiteSpaces( errorMessage ) ).length() > 0;
+            errorMessageText.setEnabled( hasError );
+            errorMessageText.setVisible( hasError );
+            errorMessageText.getParent().update();
+            Control ok = getButton( IDialogConstants.OK_ID );
+            if ( ok != null )
+            {
+                ok.setEnabled( !hasError );
+            }
+        }
+    }
 
 }
\ No newline at end of file

Modified: felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/SigilProjectEditorPart.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/SigilProjectEditorPart.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/SigilProjectEditorPart.java (original)
+++ felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/SigilProjectEditorPart.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,7 @@
 
 package org.apache.felix.sigil.ui.eclipse.ui.editors.project;
 
+
 import java.lang.reflect.InvocationTargetException;
 import java.util.Collections;
 import java.util.HashSet;
@@ -58,242 +59,324 @@
 import org.eclipse.ui.forms.editor.FormEditor;
 import org.eclipse.ui.forms.editor.IFormPage;
 
-public class SigilProjectEditorPart extends FormEditor implements IResourceChangeListener {
 
-	private final Set<IModelElement> unresolvedElements = Collections.synchronizedSet(new HashSet<IModelElement>());
-	private ISigilProjectModel project;
-	private volatile boolean saving = false;
-	private int dependenciesPageIndex;
-	
-	// XXX-FIXME-XXX
-	private Image errorImage = null; //SigilUI.imageDescriptorFromPlugin(SigilUI.PLUGIN_ID, "icons/error.gif").createImage();
-	private PropertiesForm textPage;
-	
-    public IProject getProject() {
-        IFileEditorInput fileInput = (IFileEditorInput) getEditorInput();
+public class SigilProjectEditorPart extends FormEditor implements IResourceChangeListener
+{
+
+    private final Set<IModelElement> unresolvedElements = Collections.synchronizedSet( new HashSet<IModelElement>() );
+    private ISigilProjectModel project;
+    private volatile boolean saving = false;
+    private int dependenciesPageIndex;
+
+    // XXX-FIXME-XXX
+    private Image errorImage = null; //SigilUI.imageDescriptorFromPlugin(SigilUI.PLUGIN_ID, "icons/error.gif").createImage();
+    private PropertiesForm textPage;
+
+
+    public IProject getProject()
+    {
+        IFileEditorInput fileInput = ( IFileEditorInput ) getEditorInput();
         return fileInput.getFile().getProject();
     }
-    
+
+
     /* (non-Javadoc)
      * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
      */
     @Override
-    public void doSave(IProgressMonitor monitor) {
-		monitor.beginTask("Saving", IProgressMonitor.UNKNOWN);
-		try {
-			saving = true;
-			new ProgressMonitorDialog(getSite().getShell()).run(true, true, new IRunnableWithProgress() {
-				public void run(final IProgressMonitor monitor) throws InvocationTargetException,
-						InterruptedException {
-					try {
-						if ( textPage.isDirty() ) {
-							SigilUI.runInUISync(new Runnable() {
-								public void run() {
-									textPage.doSave(monitor);
-								}								
-							});
-							project.setBundle(null);
-						}
-						else if ( isDirty() ) {
-							commitPages(true);
-							project.save(monitor);
-							SigilUI.runInUISync(new Runnable() {
-								public void run() {
-									editorDirtyStateChanged();
-								}								
-							});
-						}
-						
-						monitor.done();
-					} catch (CoreException e) {
-						throw new InvocationTargetException(e);
-					}
-				}
-			});
-		} catch (InvocationTargetException e) {
-			SigilCore.error("Failed to save " + project, e.getTargetException());
-		} catch (InterruptedException e) {
-			monitor.setCanceled(true);
-			return;
-		} finally {
-			saving = false;
-		}
-		monitor.done();		
+    public void doSave( IProgressMonitor monitor )
+    {
+        monitor.beginTask( "Saving", IProgressMonitor.UNKNOWN );
+        try
+        {
+            saving = true;
+            new ProgressMonitorDialog( getSite().getShell() ).run( true, true, new IRunnableWithProgress()
+            {
+                public void run( final IProgressMonitor monitor ) throws InvocationTargetException,
+                    InterruptedException
+                {
+                    try
+                    {
+                        if ( textPage.isDirty() )
+                        {
+                            SigilUI.runInUISync( new Runnable()
+                            {
+                                public void run()
+                                {
+                                    textPage.doSave( monitor );
+                                }
+                            } );
+                            project.setBundle( null );
+                        }
+                        else if ( isDirty() )
+                        {
+                            commitPages( true );
+                            project.save( monitor );
+                            SigilUI.runInUISync( new Runnable()
+                            {
+                                public void run()
+                                {
+                                    editorDirtyStateChanged();
+                                }
+                            } );
+                        }
+
+                        monitor.done();
+                    }
+                    catch ( CoreException e )
+                    {
+                        throw new InvocationTargetException( e );
+                    }
+                }
+            } );
+        }
+        catch ( InvocationTargetException e )
+        {
+            SigilCore.error( "Failed to save " + project, e.getTargetException() );
+        }
+        catch ( InterruptedException e )
+        {
+            monitor.setCanceled( true );
+            return;
+        }
+        finally
+        {
+            saving = false;
+        }
+        monitor.done();
     }
-    
-	/* (non-Javadoc)
+
+
+    /* (non-Javadoc)
      * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
      */
     @Override
-    protected void addPages() {
-        try {
-            addPage(new OverviewForm(this, project));
-			addPage(new ContentsForm(this, project));
-			dependenciesPageIndex = addPage(new DependenciesForm(this, project, unresolvedElements));
-			addPage(new ExportsForm(this, project));
-			textPage = new PropertiesForm(this, project);
-			addPage(textPage, getEditorInput());
-			setPartName(project.getSymbolicName());
-			
-			refreshTabImages();
-        }
-        catch (PartInitException e) {
-        	SigilCore.error( "Failed to build " + this, e );
-		}
-    }
-    
-    protected void refreshTabImages() {
-	    if(unresolvedElements.isEmpty()) {
-	    	setPageImage(dependenciesPageIndex, null);
-	    } else {
-	    	setPageImage(dependenciesPageIndex, errorImage);
-	    }
+    protected void addPages()
+    {
+        try
+        {
+            addPage( new OverviewForm( this, project ) );
+            addPage( new ContentsForm( this, project ) );
+            dependenciesPageIndex = addPage( new DependenciesForm( this, project, unresolvedElements ) );
+            addPage( new ExportsForm( this, project ) );
+            textPage = new PropertiesForm( this, project );
+            addPage( textPage, getEditorInput() );
+            setPartName( project.getSymbolicName() );
+
+            refreshTabImages();
+        }
+        catch ( PartInitException e )
+        {
+            SigilCore.error( "Failed to build " + this, e );
+        }
+    }
+
+
+    protected void refreshTabImages()
+    {
+        if ( unresolvedElements.isEmpty() )
+        {
+            setPageImage( dependenciesPageIndex, null );
+        }
+        else
+        {
+            setPageImage( dependenciesPageIndex, errorImage );
+        }
     }
-    
+
+
     /* (non-Javadoc)
      * @see org.eclipse.ui.part.EditorPart#doSaveAs()
      */
     @Override
-    public void doSaveAs() {
-    	// save as not allowed
+    public void doSaveAs()
+    {
+        // save as not allowed
     }
 
+
     /* (non-Javadoc)
      * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
      */
     @Override
-    public boolean isSaveAsAllowed() {
+    public boolean isSaveAsAllowed()
+    {
         return false;
     }
-    
+
+
     @Override
-    public void dispose() {
-    	ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
-    	errorImage.dispose();
-    	super.dispose();
-    }
-
-	public void resourceChanged(IResourceChangeEvent event) {
-		IResourceDelta delta = event.getDelta();
-		final IFile editorFile = ((IFileEditorInput) getEditorInput()).getFile();
-		try {
-			delta.accept(new IResourceDeltaVisitor() {
-				public boolean visit(IResourceDelta delta) throws CoreException {
-					int kind = delta.getKind();
-					IResource resource = delta.getResource();
-					if(resource instanceof IProject) {
-						if(!editorFile.getProject().equals(resource)) {
-							return false;
-						}
-						if(kind == IResourceDelta.CHANGED && (delta.getFlags() & IResourceDelta.MARKERS) > 0) {
-							loadUnresolvedDependencies();
-							refreshAllPages();
-						}
-						return true;
-					}
-					
-					if(resource instanceof IFile) {
-						IFile affectedFile = (IFile) resource;
-							if(affectedFile.equals(editorFile)) {
-							switch (kind) {
-							case IResourceDelta.REMOVED:
-								close(false);
-								break;
-							case IResourceDelta.CHANGED:
-								if(!saving) {
-									reload();
-								}
-								SigilUI.runInUISync( new Runnable() {
-									public void run() {
-										setPartName(project.getSymbolicName());								
-									} 									
-								} );
-								break;
-							}
-						}
-						// Recurse no more
-						return false;
-					}
-					
-					return true;
-				}
-			});
-		} catch (CoreException e) {
-			ErrorDialog.openError(getSite().getShell(), "Error", null, e.getStatus());
-		}
-	}
-	
-	protected void refreshAllPages() {
-		Runnable op = new Runnable() {
-			public void run() {
-				for(Iterator<?> iter = pages.iterator(); iter.hasNext(); ) {
-					IFormPage page = (IFormPage) iter.next();
-					if(page != null) {
-						IManagedForm managedForm = page.getManagedForm();
-						if(managedForm != null) {
-							managedForm.refresh();
-							IFormPart[] parts = managedForm.getParts();
-							for (IFormPart part : parts) {
-								part.refresh();
-							}
-						}
-					}
-				}
-				firePropertyChange(IEditorPart.PROP_DIRTY);
-				setPartName(project.getSymbolicName());
-				refreshTabImages();
-			}
-		};
-		getSite().getShell().getDisplay().syncExec(op);
-	}
-	
-	protected void reload() {
-		project.setBundle(null);
-		refreshAllPages();
-	}
-	
-	@Override
-	public void init(IEditorSite site, IEditorInput input) throws PartInitException {
-		super.init(site, input);
-		
-        try {
-			this.project = SigilCore.create(getProject());
-		} catch (CoreException e) {
-			throw new PartInitException("Error creating Sigil project", e);
-		}
-		
-    	ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE);
-		
-		if(input instanceof IFileEditorInput) {
-			try {
-				loadUnresolvedDependencies();
-			} catch (CoreException e) {
-				throw new PartInitException("Error retrieving dependency markers", e);
-			}
-		}
-	}
-
-	private void loadUnresolvedDependencies() throws CoreException {
-		ModelElementFactory factory = ModelElementFactory.getInstance();
-		IMarker[] markers = getProject().findMarkers(SigilCore.MARKER_UNRESOLVED_DEPENDENCY, true, IResource.DEPTH_ONE);
-		unresolvedElements.clear();
-		
-		for (IMarker marker : markers) {
-			String elementName = (String) marker.getAttribute("element");
-			String versionRangeStr = (String) marker.getAttribute("versionRange");
-			if(elementName != null && versionRangeStr != null) {
-				if(marker.getType().equals(SigilCore.MARKER_UNRESOLVED_IMPORT_PACKAGE)) {
-					IPackageImport pkgImport = factory.newModelElement(IPackageImport.class);
-					pkgImport.setPackageName(elementName);
-					pkgImport.setVersions(VersionRange.parseVersionRange(versionRangeStr));
-					unresolvedElements.add(pkgImport);
-				} else if(marker.getType().equals(SigilCore.MARKER_UNRESOLVED_REQUIRE_BUNDLE)) {
-					IRequiredBundle req = factory.newModelElement(IRequiredBundle.class);
-					req.setSymbolicName(elementName);
-					req.setVersions(VersionRange.parseVersionRange(versionRangeStr));
-					unresolvedElements.add(req);
-				}
-			}
-		}
-	}
+    public void dispose()
+    {
+        ResourcesPlugin.getWorkspace().removeResourceChangeListener( this );
+        errorImage.dispose();
+        super.dispose();
+    }
+
+
+    public void resourceChanged( IResourceChangeEvent event )
+    {
+        IResourceDelta delta = event.getDelta();
+        final IFile editorFile = ( ( IFileEditorInput ) getEditorInput() ).getFile();
+        try
+        {
+            delta.accept( new IResourceDeltaVisitor()
+            {
+                public boolean visit( IResourceDelta delta ) throws CoreException
+                {
+                    int kind = delta.getKind();
+                    IResource resource = delta.getResource();
+                    if ( resource instanceof IProject )
+                    {
+                        if ( !editorFile.getProject().equals( resource ) )
+                        {
+                            return false;
+                        }
+                        if ( kind == IResourceDelta.CHANGED && ( delta.getFlags() & IResourceDelta.MARKERS ) > 0 )
+                        {
+                            loadUnresolvedDependencies();
+                            refreshAllPages();
+                        }
+                        return true;
+                    }
+
+                    if ( resource instanceof IFile )
+                    {
+                        IFile affectedFile = ( IFile ) resource;
+                        if ( affectedFile.equals( editorFile ) )
+                        {
+                            switch ( kind )
+                            {
+                                case IResourceDelta.REMOVED:
+                                    close( false );
+                                    break;
+                                case IResourceDelta.CHANGED:
+                                    if ( !saving )
+                                    {
+                                        reload();
+                                    }
+                                    SigilUI.runInUISync( new Runnable()
+                                    {
+                                        public void run()
+                                        {
+                                            setPartName( project.getSymbolicName() );
+                                        }
+                                    } );
+                                    break;
+                            }
+                        }
+                        // Recurse no more
+                        return false;
+                    }
+
+                    return true;
+                }
+            } );
+        }
+        catch ( CoreException e )
+        {
+            ErrorDialog.openError( getSite().getShell(), "Error", null, e.getStatus() );
+        }
+    }
+
+
+    protected void refreshAllPages()
+    {
+        Runnable op = new Runnable()
+        {
+            public void run()
+            {
+                for ( Iterator<?> iter = pages.iterator(); iter.hasNext(); )
+                {
+                    IFormPage page = ( IFormPage ) iter.next();
+                    if ( page != null )
+                    {
+                        IManagedForm managedForm = page.getManagedForm();
+                        if ( managedForm != null )
+                        {
+                            managedForm.refresh();
+                            IFormPart[] parts = managedForm.getParts();
+                            for ( IFormPart part : parts )
+                            {
+                                part.refresh();
+                            }
+                        }
+                    }
+                }
+                firePropertyChange( IEditorPart.PROP_DIRTY );
+                setPartName( project.getSymbolicName() );
+                refreshTabImages();
+            }
+        };
+        getSite().getShell().getDisplay().syncExec( op );
+    }
+
+
+    protected void reload()
+    {
+        project.setBundle( null );
+        refreshAllPages();
+    }
+
+
+    @Override
+    public void init( IEditorSite site, IEditorInput input ) throws PartInitException
+    {
+        super.init( site, input );
+
+        try
+        {
+            this.project = SigilCore.create( getProject() );
+        }
+        catch ( CoreException e )
+        {
+            throw new PartInitException( "Error creating Sigil project", e );
+        }
+
+        ResourcesPlugin.getWorkspace().addResourceChangeListener( this, IResourceChangeEvent.POST_CHANGE );
+
+        if ( input instanceof IFileEditorInput )
+        {
+            try
+            {
+                loadUnresolvedDependencies();
+            }
+            catch ( CoreException e )
+            {
+                throw new PartInitException( "Error retrieving dependency markers", e );
+            }
+        }
+    }
+
+
+    private void loadUnresolvedDependencies() throws CoreException
+    {
+        ModelElementFactory factory = ModelElementFactory.getInstance();
+        IMarker[] markers = getProject()
+            .findMarkers( SigilCore.MARKER_UNRESOLVED_DEPENDENCY, true, IResource.DEPTH_ONE );
+        unresolvedElements.clear();
+
+        for ( IMarker marker : markers )
+        {
+            String elementName = ( String ) marker.getAttribute( "element" );
+            String versionRangeStr = ( String ) marker.getAttribute( "versionRange" );
+            if ( elementName != null && versionRangeStr != null )
+            {
+                if ( marker.getType().equals( SigilCore.MARKER_UNRESOLVED_IMPORT_PACKAGE ) )
+                {
+                    IPackageImport pkgImport = factory.newModelElement( IPackageImport.class );
+                    pkgImport.setPackageName( elementName );
+                    pkgImport.setVersions( VersionRange.parseVersionRange( versionRangeStr ) );
+                    unresolvedElements.add( pkgImport );
+                }
+                else if ( marker.getType().equals( SigilCore.MARKER_UNRESOLVED_REQUIRE_BUNDLE ) )
+                {
+                    IRequiredBundle req = factory.newModelElement( IRequiredBundle.class );
+                    req.setSymbolicName( elementName );
+                    req.setVersions( VersionRange.parseVersionRange( versionRangeStr ) );
+                    unresolvedElements.add( req );
+                }
+            }
+        }
+    }
 }

Modified: felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/SigilSourcePage.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/SigilSourcePage.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/SigilSourcePage.java (original)
+++ felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/editors/project/SigilSourcePage.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,7 @@
 
 package org.apache.felix.sigil.ui.eclipse.ui.editors.project;
 
+
 import org.eclipse.core.resources.IMarker;
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.jface.text.IDocument;
@@ -33,83 +34,117 @@
 import org.eclipse.ui.forms.editor.IFormPage;
 import org.eclipse.ui.ide.IDE;
 
-public class SigilSourcePage extends TextEditor implements IFormPage {
-	private final String id;
-	private int index;
-	private SigilProjectEditorPart editor;
-	private boolean active;
-	private Control control;
-	
-	public SigilSourcePage(String id) {
-		this.id = id;
-	}
-
-	@Override
-	public void createPartControl(Composite parent) {
-		super.createPartControl(parent);
-		Control[] children = parent.getChildren();
-		control = children[children.length - 1];
-		getSourceViewer().addTextListener( new ITextListener() {
-			public void textChanged(TextEvent event) {
-				if ( editor != null ) {
-					editor.refreshAllPages();
-				}
-			}
-		});
-		//PlatformUI.getWorkbench().getHelpSystem().setHelp(fControl, IHelpContextIds.MANIFEST_SOURCE_PAGE);
-	}
-
-	public void initialize(FormEditor editor) {
-		this.editor = (SigilProjectEditorPart) editor;
-	}
-
-	public FormEditor getEditor() {
-		return editor;
-	}
-
-	public String getId() {
-		return id;
-	}
-
-	public int getIndex() {
-		return index;
-	}
-	
-	public void setIndex(int index) {
-		this.index = index;
-	}	
-
-	public boolean isActive() {
-		return active;
-	}
-
-	public void setActive(boolean active) {
-		this.active = active;
-	}
-	
-	public Control getPartControl() {
-		return control;
-	}
-
-	public boolean selectReveal(Object object) {
-		if (object instanceof IMarker) {
-			IDE.gotoMarker(this, (IMarker) object);
-			return true;
-		}
-		return false;
-	}
-
-	// static impls
-	public boolean isEditor() {
-		return true;
-	}
-
-	public boolean canLeaveThePage() {
-		return true;
-	}
-
-	public IManagedForm getManagedForm() {
-		// this is not a form
-		return null;
-	}
+
+public class SigilSourcePage extends TextEditor implements IFormPage
+{
+    private final String id;
+    private int index;
+    private SigilProjectEditorPart editor;
+    private boolean active;
+    private Control control;
+
+
+    public SigilSourcePage( String id )
+    {
+        this.id = id;
+    }
+
+
+    @Override
+    public void createPartControl( Composite parent )
+    {
+        super.createPartControl( parent );
+        Control[] children = parent.getChildren();
+        control = children[children.length - 1];
+        getSourceViewer().addTextListener( new ITextListener()
+        {
+            public void textChanged( TextEvent event )
+            {
+                if ( editor != null )
+                {
+                    editor.refreshAllPages();
+                }
+            }
+        } );
+        //PlatformUI.getWorkbench().getHelpSystem().setHelp(fControl, IHelpContextIds.MANIFEST_SOURCE_PAGE);
+    }
+
+
+    public void initialize( FormEditor editor )
+    {
+        this.editor = ( SigilProjectEditorPart ) editor;
+    }
+
+
+    public FormEditor getEditor()
+    {
+        return editor;
+    }
+
+
+    public String getId()
+    {
+        return id;
+    }
+
+
+    public int getIndex()
+    {
+        return index;
+    }
+
+
+    public void setIndex( int index )
+    {
+        this.index = index;
+    }
+
+
+    public boolean isActive()
+    {
+        return active;
+    }
+
+
+    public void setActive( boolean active )
+    {
+        this.active = active;
+    }
+
+
+    public Control getPartControl()
+    {
+        return control;
+    }
+
+
+    public boolean selectReveal( Object object )
+    {
+        if ( object instanceof IMarker )
+        {
+            IDE.gotoMarker( this, ( IMarker ) object );
+            return true;
+        }
+        return false;
+    }
+
+
+    // static impls
+    public boolean isEditor()
+    {
+        return true;
+    }
+
+
+    public boolean canLeaveThePage()
+    {
+        return true;
+    }
+
+
+    public IManagedForm getManagedForm()
+    {
+        // this is not a form
+        return null;
+    }
 }



Mime
View raw message