You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ds...@apache.org on 2009/07/21 20:51:41 UTC
svn commit: r796467 [12/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/...
Modified: felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/OSGiInstallRepository.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/OSGiInstallRepository.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/OSGiInstallRepository.java (original)
+++ felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/OSGiInstallRepository.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,7 @@
package org.apache.felix.sigil.eclipse.internal.repository.eclipse;
+
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -40,96 +41,130 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
-public class OSGiInstallRepository extends AbstractBundleRepository {
-
- private Map<String,List<ISigilBundle>> bundles;
-
- public OSGiInstallRepository(String id) {
- super(id);
- }
-
- public void refresh() {
- synchronized( this ) {
- bundles = null;
- }
-
- notifyChange();
- }
-
- @Override
- public void accept(IRepositoryVisitor visitor, int options) {
- IOSGiInstall install = SigilCore.getInstallManager().getDefaultInstall();
-
- if ( install != null ) {
- List<ISigilBundle> found = null;
-
- synchronized( this ) {
- found = bundles == null ? null : bundles.get( install.getId() );
- }
-
- if ( found == null ) {
- found = new ArrayList<ISigilBundle>();
- IPath source = install.getType().getSourceLocation();
-
- for ( IPath p : install.getType().getDefaultBundleLocations() ) {
- loadBundle( p, found, source );
- }
-
- synchronized( this ) {
- bundles = new HashMap<String, List<ISigilBundle>>();
- bundles.put( install.getId(), found );
- }
- }
-
- for ( ISigilBundle b : found ) {
- if ( !visitor.visit(b) ) {
- break;
- }
- }
- }
- }
-
- private void loadBundle(IPath p, List<ISigilBundle> bundles, IPath source) {
- File f = p.toFile();
- JarFile jar = null;
- try {
- jar = new JarFile(f);
- ISigilBundle bundle = buildBundle(jar.getManifest(), f );
- if ( bundle != null ) {
- bundle.setLocation(p);
- bundle.setSourcePathLocation( source );
- bundle.setSourceRootPath( new Path( "src" ) );
- bundles.add( bundle );
- }
- } catch (IOException e) {
- BldCore.error( "Failed to read jar file " + f, e );
- } catch (ModelElementFactoryException e) {
- BldCore.error( "Failed to build bundle " + f , e );
- } catch (RuntimeException e) {
- BldCore.error( "Failed to build bundle " + f , e );
- }
- finally {
- if ( jar != null ) {
- try {
- jar.close();
- } catch (IOException e) {
- BldCore.error( "Failed to close jar file", e );
- }
- }
- }
- }
-
- private ISigilBundle buildBundle(Manifest manifest, File f) {
- IBundleModelElement info = buildBundleModelElement( manifest );
-
- ISigilBundle bundle = null;
-
- if ( info != null ) {
- bundle = ModelElementFactory.getInstance().newModelElement( ISigilBundle.class );
- bundle.addChild(info);
- bundle.setLocation( new Path( f.getAbsolutePath() ) );
- }
- return bundle;
- }
+public class OSGiInstallRepository extends AbstractBundleRepository
+{
+
+ private Map<String, List<ISigilBundle>> bundles;
+
+
+ public OSGiInstallRepository( String id )
+ {
+ super( id );
+ }
+
+
+ public void refresh()
+ {
+ synchronized ( this )
+ {
+ bundles = null;
+ }
+
+ notifyChange();
+ }
+
+
+ @Override
+ public void accept( IRepositoryVisitor visitor, int options )
+ {
+ IOSGiInstall install = SigilCore.getInstallManager().getDefaultInstall();
+
+ if ( install != null )
+ {
+ List<ISigilBundle> found = null;
+
+ synchronized ( this )
+ {
+ found = bundles == null ? null : bundles.get( install.getId() );
+ }
+
+ if ( found == null )
+ {
+ found = new ArrayList<ISigilBundle>();
+ IPath source = install.getType().getSourceLocation();
+
+ for ( IPath p : install.getType().getDefaultBundleLocations() )
+ {
+ loadBundle( p, found, source );
+ }
+
+ synchronized ( this )
+ {
+ bundles = new HashMap<String, List<ISigilBundle>>();
+ bundles.put( install.getId(), found );
+ }
+ }
+
+ for ( ISigilBundle b : found )
+ {
+ if ( !visitor.visit( b ) )
+ {
+ break;
+ }
+ }
+ }
+ }
+
+
+ private void loadBundle( IPath p, List<ISigilBundle> bundles, IPath source )
+ {
+ File f = p.toFile();
+ JarFile jar = null;
+ try
+ {
+ jar = new JarFile( f );
+ ISigilBundle bundle = buildBundle( jar.getManifest(), f );
+ if ( bundle != null )
+ {
+ bundle.setLocation( p );
+ bundle.setSourcePathLocation( source );
+ bundle.setSourceRootPath( new Path( "src" ) );
+ bundles.add( bundle );
+ }
+ }
+ catch ( IOException e )
+ {
+ BldCore.error( "Failed to read jar file " + f, e );
+ }
+ catch ( ModelElementFactoryException e )
+ {
+ BldCore.error( "Failed to build bundle " + f, e );
+ }
+ catch ( RuntimeException e )
+ {
+ BldCore.error( "Failed to build bundle " + f, e );
+ }
+ finally
+ {
+ if ( jar != null )
+ {
+ try
+ {
+ jar.close();
+ }
+ catch ( IOException e )
+ {
+ BldCore.error( "Failed to close jar file", e );
+ }
+ }
+ }
+ }
+
+
+ private ISigilBundle buildBundle( Manifest manifest, File f )
+ {
+ IBundleModelElement info = buildBundleModelElement( manifest );
+
+ ISigilBundle bundle = null;
+
+ if ( info != null )
+ {
+ bundle = ModelElementFactory.getInstance().newModelElement( ISigilBundle.class );
+ bundle.addChild( info );
+ bundle.setLocation( new Path( f.getAbsolutePath() ) );
+ }
+
+ return bundle;
+ }
}
Modified: felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/OSGiInstallRepositoryProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/OSGiInstallRepositoryProvider.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/OSGiInstallRepositoryProvider.java (original)
+++ felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/OSGiInstallRepositoryProvider.java Tue Jul 21 18:51:33 2009
@@ -19,13 +19,17 @@
package org.apache.felix.sigil.eclipse.internal.repository.eclipse;
+
import java.util.Properties;
import org.apache.felix.sigil.repository.IBundleRepository;
import org.apache.felix.sigil.repository.IRepositoryProvider;
-public class OSGiInstallRepositoryProvider implements IRepositoryProvider {
- public IBundleRepository createRepository(String id, Properties preferences) {
- return new OSGiInstallRepository(id);
- }
+
+public class OSGiInstallRepositoryProvider implements IRepositoryProvider
+{
+ public IBundleRepository createRepository( String id, Properties preferences )
+ {
+ return new OSGiInstallRepository( id );
+ }
}
Modified: felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/SigilRepositoryManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/SigilRepositoryManager.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/SigilRepositoryManager.java (original)
+++ felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/SigilRepositoryManager.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,7 @@
package org.apache.felix.sigil.eclipse.internal.repository.eclipse;
+
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -47,146 +48,197 @@
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
-public class SigilRepositoryManager extends AbstractRepositoryManager implements IRepositoryManager, IPropertyChangeListener {
-
- private final String repositorySet;
-
- private HashMap<String, RepositoryCache> cachedRepositories = new HashMap<String, RepositoryCache>();
-
- class RepositoryCache {
- private final Properties pref;
- private final IBundleRepository repo;
-
- RepositoryCache(Properties pref, IBundleRepository repo) {
- this.pref = pref;
- this.repo = repo;
- }
- }
-
- public SigilRepositoryManager(String repositorySet) {
- this.repositorySet = repositorySet;
- }
-
- @Override
- public void initialise() {
- super.initialise();
- SigilCore.getDefault().getPreferenceStore().addPropertyChangeListener(this);
- }
-
- public void destroy() {
- IPreferenceStore prefs = SigilCore.getDefault().getPreferenceStore();
- if ( prefs != null ) {
- prefs.removePropertyChangeListener(this);
- }
- }
-
- @Override
- protected void loadRepositories() {
- IPreferenceStore prefs = SigilCore.getDefault().getPreferenceStore();
-
- ArrayList<IBundleRepository> repos = new ArrayList<IBundleRepository>();
- HashSet<String> ids = new HashSet<String>();
-
- for ( IRepositoryModel repo : findRepositories() ) {
- try {
- IRepositoryProvider provider = findProvider( repo.getType() );
- String id = repo.getId();
- IBundleRepository repoImpl = null;
- if ( repo.getType().isDynamic() ) {
- String instance = "repository." + repo.getType().getId() + "." + id;
- String loc = prefs.getString( instance + ".loc" );
- Properties pref = loadPreferences(loc);
- repoImpl = loadRepository(id, pref, provider);
- }
- else {
- repoImpl = loadRepository(id, null, provider);
- }
-
- repos.add( repoImpl );
- ids.add( id );
- } catch (Exception e) {
- SigilCore.error( "Failed to load repository for " + repo, e);
- }
- }
-
- setRepositories(repos.toArray( new IBundleRepository[repos.size()] ) );
-
- for ( Iterator<String> i = cachedRepositories.keySet().iterator(); i.hasNext(); ) {
- if ( !ids.contains(i.next()) ) {
- i.remove();
- }
- }
- }
-
- private IRepositoryProvider findProvider(IRepositoryType repositoryType) throws CoreException {
- String id = repositoryType.getId();
-
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint p = registry.getExtensionPoint(SigilCore.REPOSITORY_PROVIDER_EXTENSION_POINT_ID);
-
- for ( IExtension e : p.getExtensions() ) {
- for ( IConfigurationElement c : e.getConfigurationElements() ) {
- if ( id.equals( c.getAttribute("id") ) ) {
- IRepositoryProvider provider = (IRepositoryProvider) c.createExecutableExtension("class");
- return provider;
- }
- }
- }
-
- return null;
- }
-
- protected IRepositoryModel[] findRepositories() {
- if ( repositorySet == null ) {
- return SigilCore.getRepositoryConfiguration().getDefaultRepositorySet().getRepositories();
- }
- else {
- IRepositorySet set = SigilCore.getRepositoryConfiguration().getRepositorySet(repositorySet);
- return set.getRepositories();
- }
- }
-
- private IBundleRepository loadRepository(String id, Properties pref, IRepositoryProvider provider) throws RepositoryException {
- try {
- if ( pref == null ) {
- pref = new Properties();
- }
-
- RepositoryCache cache = cachedRepositories.get(id);
-
- if ( cache == null || !cache.pref.equals(pref) ) {
- IBundleRepository repo = provider.createRepository(id, pref);
- cache = new RepositoryCache(pref, repo);
- cachedRepositories.put( id, cache );
- }
-
- return cache.repo;
- } catch (RuntimeException e) {
- throw new RepositoryException( "Failed to build repositories", e);
- }
- }
-
- private Properties loadPreferences(String loc) throws FileNotFoundException, IOException {
- FileInputStream in = null;
- try {
- Properties pref = new Properties();
- pref.load(new FileInputStream(loc));
- return pref;
- }
- finally {
- if ( in != null ) {
- try {
- in.close();
- } catch (IOException e) {
- SigilCore.error( "Failed to close file", e );
- }
- }
- }
- }
-
- public void propertyChange(PropertyChangeEvent event) {
- if ( event.getProperty().equals( "repository.timestamp" ) ) {
- loadRepositories();
- }
- }
+
+public class SigilRepositoryManager extends AbstractRepositoryManager implements IRepositoryManager,
+ IPropertyChangeListener
+{
+
+ private final String repositorySet;
+
+ private HashMap<String, RepositoryCache> cachedRepositories = new HashMap<String, RepositoryCache>();
+
+ class RepositoryCache
+ {
+ private final Properties pref;
+ private final IBundleRepository repo;
+
+
+ RepositoryCache( Properties pref, IBundleRepository repo )
+ {
+ this.pref = pref;
+ this.repo = repo;
+ }
+ }
+
+
+ public SigilRepositoryManager( String repositorySet )
+ {
+ this.repositorySet = repositorySet;
+ }
+
+
+ @Override
+ public void initialise()
+ {
+ super.initialise();
+ SigilCore.getDefault().getPreferenceStore().addPropertyChangeListener( this );
+ }
+
+
+ public void destroy()
+ {
+ IPreferenceStore prefs = SigilCore.getDefault().getPreferenceStore();
+ if ( prefs != null )
+ {
+ prefs.removePropertyChangeListener( this );
+ }
+ }
+
+
+ @Override
+ protected void loadRepositories()
+ {
+ IPreferenceStore prefs = SigilCore.getDefault().getPreferenceStore();
+
+ ArrayList<IBundleRepository> repos = new ArrayList<IBundleRepository>();
+ HashSet<String> ids = new HashSet<String>();
+
+ for ( IRepositoryModel repo : findRepositories() )
+ {
+ try
+ {
+ IRepositoryProvider provider = findProvider( repo.getType() );
+ String id = repo.getId();
+ IBundleRepository repoImpl = null;
+ if ( repo.getType().isDynamic() )
+ {
+ String instance = "repository." + repo.getType().getId() + "." + id;
+ String loc = prefs.getString( instance + ".loc" );
+ Properties pref = loadPreferences( loc );
+ repoImpl = loadRepository( id, pref, provider );
+ }
+ else
+ {
+ repoImpl = loadRepository( id, null, provider );
+ }
+
+ repos.add( repoImpl );
+ ids.add( id );
+ }
+ catch ( Exception e )
+ {
+ SigilCore.error( "Failed to load repository for " + repo, e );
+ }
+ }
+
+ setRepositories( repos.toArray( new IBundleRepository[repos.size()] ) );
+
+ for ( Iterator<String> i = cachedRepositories.keySet().iterator(); i.hasNext(); )
+ {
+ if ( !ids.contains( i.next() ) )
+ {
+ i.remove();
+ }
+ }
+ }
+
+
+ private IRepositoryProvider findProvider( IRepositoryType repositoryType ) throws CoreException
+ {
+ String id = repositoryType.getId();
+
+ IExtensionRegistry registry = Platform.getExtensionRegistry();
+ IExtensionPoint p = registry.getExtensionPoint( SigilCore.REPOSITORY_PROVIDER_EXTENSION_POINT_ID );
+
+ for ( IExtension e : p.getExtensions() )
+ {
+ for ( IConfigurationElement c : e.getConfigurationElements() )
+ {
+ if ( id.equals( c.getAttribute( "id" ) ) )
+ {
+ IRepositoryProvider provider = ( IRepositoryProvider ) c.createExecutableExtension( "class" );
+ return provider;
+ }
+ }
+ }
+
+ return null;
+ }
+
+
+ protected IRepositoryModel[] findRepositories()
+ {
+ if ( repositorySet == null )
+ {
+ return SigilCore.getRepositoryConfiguration().getDefaultRepositorySet().getRepositories();
+ }
+ else
+ {
+ IRepositorySet set = SigilCore.getRepositoryConfiguration().getRepositorySet( repositorySet );
+ return set.getRepositories();
+ }
+ }
+
+
+ private IBundleRepository loadRepository( String id, Properties pref, IRepositoryProvider provider )
+ throws RepositoryException
+ {
+ try
+ {
+ if ( pref == null )
+ {
+ pref = new Properties();
+ }
+
+ RepositoryCache cache = cachedRepositories.get( id );
+
+ if ( cache == null || !cache.pref.equals( pref ) )
+ {
+ IBundleRepository repo = provider.createRepository( id, pref );
+ cache = new RepositoryCache( pref, repo );
+ cachedRepositories.put( id, cache );
+ }
+
+ return cache.repo;
+ }
+ catch ( RuntimeException e )
+ {
+ throw new RepositoryException( "Failed to build repositories", e );
+ }
+ }
+
+
+ private Properties loadPreferences( String loc ) throws FileNotFoundException, IOException
+ {
+ FileInputStream in = null;
+ try
+ {
+ Properties pref = new Properties();
+ pref.load( new FileInputStream( loc ) );
+ return pref;
+ }
+ finally
+ {
+ if ( in != null )
+ {
+ try
+ {
+ in.close();
+ }
+ catch ( IOException e )
+ {
+ SigilCore.error( "Failed to close file", e );
+ }
+ }
+ }
+ }
+
+
+ public void propertyChange( PropertyChangeEvent event )
+ {
+ if ( event.getProperty().equals( "repository.timestamp" ) )
+ {
+ loadRepositories();
+ }
+ }
}
Modified: felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/WorkspaceRepository.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/WorkspaceRepository.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/WorkspaceRepository.java (original)
+++ felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/WorkspaceRepository.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,7 @@
package org.apache.felix.sigil.eclipse.internal.repository.eclipse;
+
import java.util.ArrayList;
import java.util.List;
@@ -36,91 +37,126 @@
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.runtime.CoreException;
-public class WorkspaceRepository extends AbstractBundleRepository implements IResourceChangeListener {
-
- private static final int UPDATE_MASK = IResourceDelta.CONTENT | IResourceDelta.DESCRIPTION | IResourceDelta.OPEN;
- private ISigilBundle[] bundles;
-
- public WorkspaceRepository(String id) {
- super(id);
- }
-
- @Override
- public void accept(IRepositoryVisitor visitor, int options) {
- synchronized( this ) {
- if ( bundles == null ) {
- List<ISigilProjectModel> models = SigilCore.getRoot().getProjects();
- ArrayList<ISigilBundle> tmp = new ArrayList<ISigilBundle>(models.size());
- for ( ISigilProjectModel n : models ) {
- ISigilBundle b = n.getBundle();
- tmp.add(b);
- }
- bundles = tmp.toArray( new ISigilBundle[tmp.size()] );
- }
- }
-
- for ( ISigilBundle b : bundles ) {
- visitor.visit(b);
- }
- }
-
- public void refresh() {
- synchronized(this) {
- bundles = null;
- }
- }
-
- @Override
- protected void notifyChange() {
- refresh();
- super.notifyChange();
- }
-
- public void resourceChanged(IResourceChangeEvent event) {
- try {
- event.getDelta().accept( new IResourceDeltaVisitor() {
- public boolean visit(IResourceDelta delta) throws CoreException {
- boolean result;
-
- IResource resource = delta.getResource();
- if(resource instanceof IWorkspaceRoot) {
- result = true;
- } else if(resource instanceof IProject) {
- IProject project = (IProject) resource;
- if ( SigilCore.isSigilProject(project) ) {
- switch (delta.getKind()) {
- case IResourceDelta.CHANGED:
- if ( (delta.getFlags() & UPDATE_MASK) == 0 ) {
- break;
- }
- // else
- // fall through on purpose
- case IResourceDelta.ADDED: // fall through on purpose
- case IResourceDelta.REMOVED: // fall through on purpose
- notifyChange();
- break;
- }
- result = true;
- } else {
- result = false;
- }
- } else if(resource.getName().equals(SigilCore.SIGIL_PROJECT_FILE)) {
- switch(delta.getKind()) {
- case IResourceDelta.CHANGED:
- case IResourceDelta.ADDED:
- case IResourceDelta.REMOVED:
- notifyChange();
- }
- result = false;
- } else {
- result = false;
- }
- return result;
- }
- });
- } catch (CoreException e) {
- SigilCore.error( "Workspace repository update failed", e );
- }
- }
+
+public class WorkspaceRepository extends AbstractBundleRepository implements IResourceChangeListener
+{
+
+ private static final int UPDATE_MASK = IResourceDelta.CONTENT | IResourceDelta.DESCRIPTION | IResourceDelta.OPEN;
+ private ISigilBundle[] bundles;
+
+
+ public WorkspaceRepository( String id )
+ {
+ super( id );
+ }
+
+
+ @Override
+ public void accept( IRepositoryVisitor visitor, int options )
+ {
+ synchronized ( this )
+ {
+ if ( bundles == null )
+ {
+ List<ISigilProjectModel> models = SigilCore.getRoot().getProjects();
+ ArrayList<ISigilBundle> tmp = new ArrayList<ISigilBundle>( models.size() );
+ for ( ISigilProjectModel n : models )
+ {
+ ISigilBundle b = n.getBundle();
+ tmp.add( b );
+ }
+ bundles = tmp.toArray( new ISigilBundle[tmp.size()] );
+ }
+ }
+
+ for ( ISigilBundle b : bundles )
+ {
+ visitor.visit( b );
+ }
+ }
+
+
+ public void refresh()
+ {
+ synchronized ( this )
+ {
+ bundles = null;
+ }
+ }
+
+
+ @Override
+ protected void notifyChange()
+ {
+ refresh();
+ super.notifyChange();
+ }
+
+
+ public void resourceChanged( IResourceChangeEvent event )
+ {
+ try
+ {
+ event.getDelta().accept( new IResourceDeltaVisitor()
+ {
+ public boolean visit( IResourceDelta delta ) throws CoreException
+ {
+ boolean result;
+
+ IResource resource = delta.getResource();
+ if ( resource instanceof IWorkspaceRoot )
+ {
+ result = true;
+ }
+ else if ( resource instanceof IProject )
+ {
+ IProject project = ( IProject ) resource;
+ if ( SigilCore.isSigilProject( project ) )
+ {
+ switch ( delta.getKind() )
+ {
+ case IResourceDelta.CHANGED:
+ if ( ( delta.getFlags() & UPDATE_MASK ) == 0 )
+ {
+ break;
+ }
+ // else
+ // fall through on purpose
+ case IResourceDelta.ADDED: // fall through on purpose
+ case IResourceDelta.REMOVED: // fall through on purpose
+ notifyChange();
+ break;
+ }
+ result = true;
+ }
+ else
+ {
+ result = false;
+ }
+ }
+ else if ( resource.getName().equals( SigilCore.SIGIL_PROJECT_FILE ) )
+ {
+ switch ( delta.getKind() )
+ {
+ case IResourceDelta.CHANGED:
+ case IResourceDelta.ADDED:
+ case IResourceDelta.REMOVED:
+ notifyChange();
+ }
+ result = false;
+ }
+ else
+ {
+ result = false;
+ }
+ return result;
+ }
+ } );
+ }
+ catch ( CoreException e )
+ {
+ SigilCore.error( "Workspace repository update failed", e );
+ }
+ }
}
Modified: felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/WorkspaceRepositoryProvider.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/WorkspaceRepositoryProvider.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/WorkspaceRepositoryProvider.java (original)
+++ felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/WorkspaceRepositoryProvider.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,7 @@
package org.apache.felix.sigil.eclipse.internal.repository.eclipse;
+
import java.util.Properties;
import org.apache.felix.sigil.repository.IBundleRepository;
@@ -26,18 +27,25 @@
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.ResourcesPlugin;
-public class WorkspaceRepositoryProvider implements IRepositoryProvider {
- private static WorkspaceRepository repository;
-
- public static WorkspaceRepository getWorkspaceRepository() {
- return repository;
- }
-
- public IBundleRepository createRepository(String id, Properties preferences) {
- if ( repository == null ) {
- repository = new WorkspaceRepository(id);
- ResourcesPlugin.getWorkspace().addResourceChangeListener(repository, IResourceChangeEvent.POST_CHANGE);
- }
- return repository;
- }
+
+public class WorkspaceRepositoryProvider implements IRepositoryProvider
+{
+ private static WorkspaceRepository repository;
+
+
+ public static WorkspaceRepository getWorkspaceRepository()
+ {
+ return repository;
+ }
+
+
+ public IBundleRepository createRepository( String id, Properties preferences )
+ {
+ if ( repository == null )
+ {
+ repository = new WorkspaceRepository( id );
+ ResourcesPlugin.getWorkspace().addResourceChangeListener( repository, IResourceChangeEvent.POST_CHANGE );
+ }
+ return repository;
+ }
}
Modified: felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/job/ResolveProjectsJob.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/job/ResolveProjectsJob.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/job/ResolveProjectsJob.java (original)
+++ felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/job/ResolveProjectsJob.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,7 @@
package org.apache.felix.sigil.eclipse.job;
+
import java.util.Collection;
import java.util.Collections;
import java.util.Set;
@@ -45,101 +46,134 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
-public class ResolveProjectsJob extends Job {
-
- private final IWorkspace workspace;
- private final IProject project;
-
- public ResolveProjectsJob(IWorkspace workspace) {
- super("Resolving Sigil projects");
- this.workspace = workspace;
- this.project = null;
- setRule(ResourcesPlugin.getWorkspace().getRoot());
- }
-
- public ResolveProjectsJob(IProject project) {
- super("Resolving Sigil project");
- this.workspace = null;
- this.project = project;
- setRule(project.getFile(SigilCore.SIGIL_PROJECT_FILE));
- }
-
- @Override
- protected IStatus run(IProgressMonitor monitor) {
- MultiStatus status = new MultiStatus(SigilCore.PLUGIN_ID, 0, "Error resolving Sigil projects", null);
-
- Collection<ISigilProjectModel> sigilProjects = null;
-
- if(workspace != null) {
- sigilProjects = SigilCore.getRoot().getProjects();
- } else if(project != null) {
- try {
- ISigilProjectModel sigilProject = SigilCore.create(project);
- sigilProjects = Collections.singleton(sigilProject);
- } catch (CoreException e) {
- status.add(e.getStatus());
- }
- }
-
- if ( sigilProjects != null ) {
- for (ISigilProjectModel sigilProject : sigilProjects) {
- try {
- // Delete existing dependency markers on project
- sigilProject.getProject().deleteMarkers(SigilCore.MARKER_UNRESOLVED_DEPENDENCY, true, IResource.DEPTH_ONE);
-
- IRepositoryManager repository = SigilCore.getRepositoryManager(sigilProject);
- ResolutionMonitorAdapter resolutionMonitor = new ResolutionMonitorAdapter(monitor);
-
- IBundleResolver resolver = repository.getBundleResolver();
- ResolutionConfig config = new ResolutionConfig(ResolutionConfig.IGNORE_ERRORS);
-
- // Execute resolver
- IResolution resolution = resolver.resolve(sigilProject, config, resolutionMonitor);
-
- // Find missing imports
- Set<IPackageImport> imports = sigilProject.getBundle().getBundleInfo().getImports();
- for (IPackageImport pkgImport : imports) {
- if(resolution.getProvider(pkgImport) == null) {
- markMissingImport(pkgImport, sigilProject.getProject());
- }
- }
-
- // Find missing required bundles
- Set<IRequiredBundle> requiredBundles = sigilProject.getBundle().getBundleInfo().getRequiredBundles();
- for (IRequiredBundle requiredBundle : requiredBundles) {
- if(resolution.getProvider(requiredBundle) == null) {
- markMissingRequiredBundle(requiredBundle, sigilProject.getProject());
- }
- }
- } catch (ResolutionException e) {
- status.add(new Status(IStatus.ERROR, SigilCore.PLUGIN_ID, 0, "Error resolving project " + sigilProject.getProject().getName(), e));
- } catch (CoreException e) {
- status.add(e.getStatus());
- }
- }
- }
-
- return status;
- }
-
- private static void markMissingImport(IPackageImport pkgImport, IProject project) throws CoreException {
- IMarker marker = project.getProject().createMarker(SigilCore.MARKER_UNRESOLVED_IMPORT_PACKAGE);
- marker.setAttribute("element", pkgImport.getPackageName());
- marker.setAttribute("versionRange", pkgImport.getVersions().toString());
- marker.setAttribute(IMarker.MESSAGE, "Cannot resolve imported package \"" + pkgImport.getPackageName() + "\" with version range " + pkgImport.getVersions());
- marker.setAttribute(IMarker.SEVERITY, pkgImport.isOptional() ? IMarker.SEVERITY_WARNING : IMarker.SEVERITY_ERROR);
- marker.setAttribute(IMarker.PRIORITY, IMarker.PRIORITY_HIGH);
- }
-
- private static void markMissingRequiredBundle(IRequiredBundle req, IProject project) throws CoreException {
- IMarker marker = project.getProject().createMarker(SigilCore.MARKER_UNRESOLVED_REQUIRE_BUNDLE);
- marker.setAttribute("element", req.getSymbolicName());
- marker.setAttribute("versionRange", req.getVersions().toString());
- marker.setAttribute(IMarker.MESSAGE, "Cannot resolve required bundle \"" + req.getSymbolicName() + "\" with version range " + req.getVersions());
- marker.setAttribute(IMarker.SEVERITY, req.isOptional() ? IMarker.SEVERITY_WARNING : IMarker.SEVERITY_ERROR);
- marker.setAttribute(IMarker.PRIORITY, IMarker.PRIORITY_HIGH);
- }
-
-
+
+public class ResolveProjectsJob extends Job
+{
+
+ private final IWorkspace workspace;
+ private final IProject project;
+
+
+ public ResolveProjectsJob( IWorkspace workspace )
+ {
+ super( "Resolving Sigil projects" );
+ this.workspace = workspace;
+ this.project = null;
+ setRule( ResourcesPlugin.getWorkspace().getRoot() );
+ }
+
+
+ public ResolveProjectsJob( IProject project )
+ {
+ super( "Resolving Sigil project" );
+ this.workspace = null;
+ this.project = project;
+ setRule( project.getFile( SigilCore.SIGIL_PROJECT_FILE ) );
+ }
+
+
+ @Override
+ protected IStatus run( IProgressMonitor monitor )
+ {
+ MultiStatus status = new MultiStatus( SigilCore.PLUGIN_ID, 0, "Error resolving Sigil projects", null );
+
+ Collection<ISigilProjectModel> sigilProjects = null;
+
+ if ( workspace != null )
+ {
+ sigilProjects = SigilCore.getRoot().getProjects();
+ }
+ else if ( project != null )
+ {
+ try
+ {
+ ISigilProjectModel sigilProject = SigilCore.create( project );
+ sigilProjects = Collections.singleton( sigilProject );
+ }
+ catch ( CoreException e )
+ {
+ status.add( e.getStatus() );
+ }
+ }
+
+ if ( sigilProjects != null )
+ {
+ for ( ISigilProjectModel sigilProject : sigilProjects )
+ {
+ try
+ {
+ // Delete existing dependency markers on project
+ sigilProject.getProject().deleteMarkers( SigilCore.MARKER_UNRESOLVED_DEPENDENCY, true,
+ IResource.DEPTH_ONE );
+
+ IRepositoryManager repository = SigilCore.getRepositoryManager( sigilProject );
+ ResolutionMonitorAdapter resolutionMonitor = new ResolutionMonitorAdapter( monitor );
+
+ IBundleResolver resolver = repository.getBundleResolver();
+ ResolutionConfig config = new ResolutionConfig( ResolutionConfig.IGNORE_ERRORS );
+
+ // Execute resolver
+ IResolution resolution = resolver.resolve( sigilProject, config, resolutionMonitor );
+
+ // Find missing imports
+ Set<IPackageImport> imports = sigilProject.getBundle().getBundleInfo().getImports();
+ for ( IPackageImport pkgImport : imports )
+ {
+ if ( resolution.getProvider( pkgImport ) == null )
+ {
+ markMissingImport( pkgImport, sigilProject.getProject() );
+ }
+ }
+
+ // Find missing required bundles
+ Set<IRequiredBundle> requiredBundles = sigilProject.getBundle().getBundleInfo()
+ .getRequiredBundles();
+ for ( IRequiredBundle requiredBundle : requiredBundles )
+ {
+ if ( resolution.getProvider( requiredBundle ) == null )
+ {
+ markMissingRequiredBundle( requiredBundle, sigilProject.getProject() );
+ }
+ }
+ }
+ catch ( ResolutionException e )
+ {
+ status.add( new Status( IStatus.ERROR, SigilCore.PLUGIN_ID, 0, "Error resolving project "
+ + sigilProject.getProject().getName(), e ) );
+ }
+ catch ( CoreException e )
+ {
+ status.add( e.getStatus() );
+ }
+ }
+ }
+
+ return status;
+ }
+
+
+ private static void markMissingImport( IPackageImport pkgImport, IProject project ) throws CoreException
+ {
+ IMarker marker = project.getProject().createMarker( SigilCore.MARKER_UNRESOLVED_IMPORT_PACKAGE );
+ marker.setAttribute( "element", pkgImport.getPackageName() );
+ marker.setAttribute( "versionRange", pkgImport.getVersions().toString() );
+ marker.setAttribute( IMarker.MESSAGE, "Cannot resolve imported package \"" + pkgImport.getPackageName()
+ + "\" with version range " + pkgImport.getVersions() );
+ marker.setAttribute( IMarker.SEVERITY, pkgImport.isOptional() ? IMarker.SEVERITY_WARNING
+ : IMarker.SEVERITY_ERROR );
+ marker.setAttribute( IMarker.PRIORITY, IMarker.PRIORITY_HIGH );
+ }
+
+
+ private static void markMissingRequiredBundle( IRequiredBundle req, IProject project ) throws CoreException
+ {
+ IMarker marker = project.getProject().createMarker( SigilCore.MARKER_UNRESOLVED_REQUIRE_BUNDLE );
+ marker.setAttribute( "element", req.getSymbolicName() );
+ marker.setAttribute( "versionRange", req.getVersions().toString() );
+ marker.setAttribute( IMarker.MESSAGE, "Cannot resolve required bundle \"" + req.getSymbolicName()
+ + "\" with version range " + req.getVersions() );
+ marker.setAttribute( IMarker.SEVERITY, req.isOptional() ? IMarker.SEVERITY_WARNING : IMarker.SEVERITY_ERROR );
+ marker.setAttribute( IMarker.PRIORITY, IMarker.PRIORITY_HIGH );
+ }
}
Modified: felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/job/ThreadProgressMonitor.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/job/ThreadProgressMonitor.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/job/ThreadProgressMonitor.java (original)
+++ felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/job/ThreadProgressMonitor.java Tue Jul 21 18:51:33 2009
@@ -19,16 +19,23 @@
package org.apache.felix.sigil.eclipse.job;
+
import org.eclipse.core.runtime.IProgressMonitor;
-public class ThreadProgressMonitor {
- private static ThreadLocal<IProgressMonitor> local = new ThreadLocal<IProgressMonitor>();
-
- public static void setProgressMonitor(IProgressMonitor monitor) {
- local.set(monitor);
- }
-
- public static IProgressMonitor getProgressMonitor() {
- return local.get();
- }
+
+public class ThreadProgressMonitor
+{
+ private static ThreadLocal<IProgressMonitor> local = new ThreadLocal<IProgressMonitor>();
+
+
+ public static void setProgressMonitor( IProgressMonitor monitor )
+ {
+ local.set( monitor );
+ }
+
+
+ public static IProgressMonitor getProgressMonitor()
+ {
+ return local.get();
+ }
}
Modified: felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/project/ISigilModelRoot.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/project/ISigilModelRoot.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/project/ISigilModelRoot.java (original)
+++ felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/project/ISigilModelRoot.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,7 @@
package org.apache.felix.sigil.eclipse.model.project;
+
import java.util.Collection;
import java.util.List;
@@ -27,10 +28,15 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-public interface ISigilModelRoot {
- List<ISigilProjectModel> getProjects();
-
- Collection<ISigilProjectModel> resolveDependentProjects(ISigilProjectModel sigil, IProgressMonitor monitor);
- Collection<ISigilBundle> resolveBundles(ISigilProjectModel sigil, IModelElement element, boolean includeOptional, IProgressMonitor monitor) throws CoreException;
+public interface ISigilModelRoot
+{
+ List<ISigilProjectModel> getProjects();
+
+
+ Collection<ISigilProjectModel> resolveDependentProjects( ISigilProjectModel sigil, IProgressMonitor monitor );
+
+
+ Collection<ISigilBundle> resolveBundles( ISigilProjectModel sigil, IModelElement element, boolean includeOptional,
+ IProgressMonitor monitor ) throws CoreException;
}
Modified: felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/project/ISigilProjectModel.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/project/ISigilProjectModel.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/project/ISigilProjectModel.java (original)
+++ felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/project/ISigilProjectModel.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,7 @@
package org.apache.felix.sigil.eclipse.model.project;
+
import java.util.Collection;
import org.apache.felix.sigil.config.IBldProject;
@@ -37,6 +38,7 @@
import org.osgi.framework.Version;
import org.osgi.service.prefs.Preferences;
+
/**
* Represents a sigil project. To get a reference to a ISigilProjectModel you can use the
* helper method {@link BldCore#create(IProject)}.
@@ -44,62 +46,81 @@
* @author dave
*
*/
-public interface ISigilProjectModel extends ICompoundModelElement {
-
+public interface ISigilProjectModel extends ICompoundModelElement
+{
+
/**
* @return
*/
IProject getProject();
-
- // shortcut to getProject().getName()
- String getName();
-
- Preferences getPreferences();
-
+
+
+ // shortcut to getProject().getName()
+ String getName();
+
+
+ Preferences getPreferences();
+
+
+ /**
+ *
+ * @param monitor
+ * The progress monitor to use for reporting progress to the
+ * user. It is the caller's responsibility to call done() on the
+ * given monitor. Accepts null, indicating that no progress
+ * should be reported and that the operation cannot be cancelled
+ * @throws CoreException
+ */
+ void save( IProgressMonitor monitor ) throws CoreException;
+
+
+ /**
+ * @return
+ */
+ Version getVersion();
+
+
+ String getSymbolicName();
+
+
+ ISigilBundle getBundle();
+
+
+ void setBundle( ISigilBundle bundle );
+
+
/**
- *
- * @param monitor
- * The progress monitor to use for reporting progress to the
- * user. It is the caller's responsibility to call done() on the
- * given monitor. Accepts null, indicating that no progress
- * should be reported and that the operation cannot be cancelled
- * @throws CoreException
- */
- void save(IProgressMonitor monitor) throws CoreException;
-
- /**
- * @return
- */
- Version getVersion();
-
- String getSymbolicName();
-
- ISigilBundle getBundle();
-
- void setBundle(ISigilBundle bundle);
-
- /**
- * @return
- */
- IJavaProject getJavaModel();
-
- Collection<ISigilProjectModel> findDependentProjects(IProgressMonitor monitor);
-
- void resetClasspath(IProgressMonitor monitor) throws CoreException;
-
- IPath findBundleLocation() throws CoreException;
-
- IModelElement findImport(String packageName, IProgressMonitor monitor);
-
- boolean isInClasspath(String packageName, IProgressMonitor monitor) throws CoreException;
-
- boolean isInClasspath(ISigilBundle bundle);
-
- boolean isInBundleClasspath(IPackageFragmentRoot root) throws JavaModelException;
-
- IPath findOutputLocation() throws CoreException;
+ * @return
+ */
+ IJavaProject getJavaModel();
+
+
+ Collection<ISigilProjectModel> findDependentProjects( IProgressMonitor monitor );
+
+
+ void resetClasspath( IProgressMonitor monitor ) throws CoreException;
+
+
+ IPath findBundleLocation() throws CoreException;
+
+
+ IModelElement findImport( String packageName, IProgressMonitor monitor );
+
+
+ boolean isInClasspath( String packageName, IProgressMonitor monitor ) throws CoreException;
+
+
+ boolean isInClasspath( ISigilBundle bundle );
+
+
+ boolean isInBundleClasspath( IPackageFragmentRoot root ) throws JavaModelException;
+
+
+ IPath findOutputLocation() throws CoreException;
+
+
+ IBldProject getBldProject() throws CoreException;
- IBldProject getBldProject() throws CoreException;
- Collection<IClasspathEntry> findExternalClasspath(IProgressMonitor monitor) throws CoreException;
+ Collection<IClasspathEntry> findExternalClasspath( IProgressMonitor monitor ) throws CoreException;
}
Modified: felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryConfiguration.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryConfiguration.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryConfiguration.java (original)
+++ felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryConfiguration.java Tue Jul 21 18:51:33 2009
@@ -19,31 +19,43 @@
package org.apache.felix.sigil.eclipse.model.repository;
+
import java.util.List;
import java.util.Map;
import org.apache.felix.sigil.eclipse.internal.model.repository.RepositoryType;
import org.eclipse.core.runtime.CoreException;
-public interface IRepositoryConfiguration {
- List<IRepositoryModel> loadRepositories();
-
- IRepositoryModel findRepository(String id);
-
- void saveRepositories(List<IRepositoryModel> repositories) throws CoreException;
-
- List<RepositoryType> loadRepositoryTypes();
-
- IRepositoryModel newRepositoryElement(IRepositoryType type);
-
- IRepositorySet getDefaultRepositorySet();
-
- void setDefaultRepositorySet(IRepositorySet defaultSet);
-
- IRepositorySet getRepositorySet(String name);
-
- Map<String, IRepositorySet> loadRepositorySets();
-
- void saveRepositorySets(Map<String, IRepositorySet> sets);
+public interface IRepositoryConfiguration
+{
+
+ List<IRepositoryModel> loadRepositories();
+
+
+ IRepositoryModel findRepository( String id );
+
+
+ void saveRepositories( List<IRepositoryModel> repositories ) throws CoreException;
+
+
+ List<RepositoryType> loadRepositoryTypes();
+
+
+ IRepositoryModel newRepositoryElement( IRepositoryType type );
+
+
+ IRepositorySet getDefaultRepositorySet();
+
+
+ void setDefaultRepositorySet( IRepositorySet defaultSet );
+
+
+ IRepositorySet getRepositorySet( String name );
+
+
+ Map<String, IRepositorySet> loadRepositorySets();
+
+
+ void saveRepositorySets( Map<String, IRepositorySet> sets );
}
\ No newline at end of file
Modified: felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryModel.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryModel.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryModel.java (original)
+++ felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryModel.java Tue Jul 21 18:51:33 2009
@@ -19,17 +19,24 @@
package org.apache.felix.sigil.eclipse.model.repository;
+
import org.eclipse.jface.preference.PreferenceStore;
-public interface IRepositoryModel {
- String getId();
+public interface IRepositoryModel
+{
+
+ String getId();
+
+
+ void setName( String stringValue );
+
+
+ String getName();
+
- void setName(String stringValue);
-
- String getName();
+ PreferenceStore getPreferences();
- PreferenceStore getPreferences();
- IRepositoryType getType();
+ IRepositoryType getType();
}
\ No newline at end of file
Modified: felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositorySet.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositorySet.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositorySet.java (original)
+++ felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositorySet.java Tue Jul 21 18:51:33 2009
@@ -19,9 +19,17 @@
package org.apache.felix.sigil.eclipse.model.repository;
-public interface IRepositorySet {
- void setRepository(IRepositoryModel id, int position);
- void removeRepository(IRepositoryModel id);
- IRepositoryModel[] getRepositories();
- void setRepositories(IRepositoryModel[] repositories);
+
+public interface IRepositorySet
+{
+ void setRepository( IRepositoryModel id, int position );
+
+
+ void removeRepository( IRepositoryModel id );
+
+
+ IRepositoryModel[] getRepositories();
+
+
+ void setRepositories( IRepositoryModel[] repositories );
}
Modified: felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryType.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryType.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryType.java (original)
+++ felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryType.java Tue Jul 21 18:51:33 2009
@@ -19,16 +19,22 @@
package org.apache.felix.sigil.eclipse.model.repository;
+
import org.eclipse.swt.graphics.Image;
-public interface IRepositoryType {
- String getType();
+public interface IRepositoryType
+{
+
+ String getType();
+
+
+ String getId();
+
- String getId();
+ Image getIcon();
- Image getIcon();
- boolean isDynamic();
+ boolean isDynamic();
}
\ No newline at end of file
Modified: felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/RepositorySet.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/RepositorySet.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/RepositorySet.java (original)
+++ felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/RepositorySet.java Tue Jul 21 18:51:33 2009
@@ -19,45 +19,62 @@
package org.apache.felix.sigil.eclipse.model.repository;
+
import java.util.ArrayList;
import java.util.Collection;
-public class RepositorySet implements IRepositorySet {
- private static final IRepositoryModel[] EMPTY = new IRepositoryModel[0];
-
- private IRepositoryModel[] reps;
-
- public RepositorySet() {
- this( EMPTY );
- }
-
- public RepositorySet(Collection<IRepositoryModel> reps) {
- this( reps.toArray( new IRepositoryModel[reps.size()] ) );
- }
-
- public RepositorySet(IRepositoryModel[] repositories) {
- this.reps = repositories;
- }
-
- public void setRepository(IRepositoryModel id, int position) {
- ArrayList<IRepositoryModel> tmp = new ArrayList<IRepositoryModel>(reps.length + 1);
- tmp.remove(id);
- tmp.add(position, id);
- reps = tmp.toArray( new IRepositoryModel[tmp.size()] );
- }
-
- public IRepositoryModel[] getRepositories() {
- return reps;
- }
-
- public void removeRepository(IRepositoryModel id) {
- ArrayList<IRepositoryModel> tmp = new ArrayList<IRepositoryModel>(reps.length + 1);
- tmp.remove(id);
- reps = tmp.toArray( new IRepositoryModel[tmp.size()] );
- }
-
- public void setRepositories(IRepositoryModel[] repositories) {
- reps = repositories == null ? EMPTY : repositories;
- }
+public class RepositorySet implements IRepositorySet
+{
+
+ private static final IRepositoryModel[] EMPTY = new IRepositoryModel[0];
+
+ private IRepositoryModel[] reps;
+
+
+ public RepositorySet()
+ {
+ this( EMPTY );
+ }
+
+
+ public RepositorySet( Collection<IRepositoryModel> reps )
+ {
+ this( reps.toArray( new IRepositoryModel[reps.size()] ) );
+ }
+
+
+ public RepositorySet( IRepositoryModel[] repositories )
+ {
+ this.reps = repositories;
+ }
+
+
+ public void setRepository( IRepositoryModel id, int position )
+ {
+ ArrayList<IRepositoryModel> tmp = new ArrayList<IRepositoryModel>( reps.length + 1 );
+ tmp.remove( id );
+ tmp.add( position, id );
+ reps = tmp.toArray( new IRepositoryModel[tmp.size()] );
+ }
+
+
+ public IRepositoryModel[] getRepositories()
+ {
+ return reps;
+ }
+
+
+ public void removeRepository( IRepositoryModel id )
+ {
+ ArrayList<IRepositoryModel> tmp = new ArrayList<IRepositoryModel>( reps.length + 1 );
+ tmp.remove( id );
+ reps = tmp.toArray( new IRepositoryModel[tmp.size()] );
+ }
+
+
+ public void setRepositories( IRepositoryModel[] repositories )
+ {
+ reps = repositories == null ? EMPTY : repositories;
+ }
}
Modified: felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/Grep.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/Grep.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/Grep.java (original)
+++ felix/trunk/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/Grep.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,7 @@
package org.apache.felix.sigil.eclipse.model.util;
+
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.CharBuffer;
@@ -34,75 +35,92 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
-public class Grep {
- // Pattern used to parse lines
- private static Pattern linePattern = Pattern.compile(".*\r?\n");
-
- // The input pattern that we're looking for
- private Pattern pattern;
-
- private CharBuffer cb;
-
- private FileChannel fc;
-
- private Grep(IFile f, Pattern pattern) throws IOException, CoreException {
- this.pattern = pattern;
- cb = openBuffer(f);
- }
-
- private CharBuffer openBuffer(IFile f) throws IOException, CoreException {
- Charset charset = Charset.forName(f.getCharset());
- CharsetDecoder decoder = charset.newDecoder();
- // Open the file and then get a channel from the stream
- FileInputStream fis = new FileInputStream(f.getLocation().toFile());
- fc = fis.getChannel();
-
- // Get the file's size and then map it into memory
- int sz = (int) fc.size();
- MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, sz);
-
- // Decode the file into a char buffer
- return decoder.decode(bb);
- }
-
- public static String[] grep(Pattern pattern, IFile...files) throws CoreException {
- LinkedList<String> matches = new LinkedList<String>();
- for ( IFile f : files ) {
- try {
- Grep g = new Grep( f, pattern );
- g.grep(matches);
- g.close();
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- return matches.toArray( new String[matches.size()]);
- }
-
- private void close() throws IOException {
- fc.close();
- }
-
- // Use the linePattern to break the given CharBuffer into lines, applying
- // the input pattern to each line to see if we have a match
- //
- private void grep(List<String> matches) {
- Matcher lm = linePattern.matcher(cb); // Line matcher
- Matcher pm = null; // Pattern matcher
- int lines = 0;
- while (lm.find()) {
- lines++;
- CharSequence cs = lm.group(); // The current line
- if (pm == null)
- pm = pattern.matcher(cs);
- else
- pm.reset(cs);
- if (pm.find())
- matches.add(pm.group());
- if (lm.end() == cb.limit())
- break;
- }
- }
+public class Grep
+{
+
+ // Pattern used to parse lines
+ private static Pattern linePattern = Pattern.compile( ".*\r?\n" );
+
+ // The input pattern that we're looking for
+ private Pattern pattern;
+
+ private CharBuffer cb;
+
+ private FileChannel fc;
+
+
+ private Grep( IFile f, Pattern pattern ) throws IOException, CoreException
+ {
+ this.pattern = pattern;
+ cb = openBuffer( f );
+ }
+
+
+ private CharBuffer openBuffer( IFile f ) throws IOException, CoreException
+ {
+ Charset charset = Charset.forName( f.getCharset() );
+ CharsetDecoder decoder = charset.newDecoder();
+ // Open the file and then get a channel from the stream
+ FileInputStream fis = new FileInputStream( f.getLocation().toFile() );
+ fc = fis.getChannel();
+
+ // Get the file's size and then map it into memory
+ int sz = ( int ) fc.size();
+ MappedByteBuffer bb = fc.map( FileChannel.MapMode.READ_ONLY, 0, sz );
+
+ // Decode the file into a char buffer
+ return decoder.decode( bb );
+ }
+
+
+ public static String[] grep( Pattern pattern, IFile... files ) throws CoreException
+ {
+ LinkedList<String> matches = new LinkedList<String>();
+ for ( IFile f : files )
+ {
+ try
+ {
+ Grep g = new Grep( f, pattern );
+ g.grep( matches );
+ g.close();
+ }
+ catch ( IOException e )
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ return matches.toArray( new String[matches.size()] );
+ }
+
+
+ private void close() throws IOException
+ {
+ fc.close();
+ }
+
+
+ // Use the linePattern to break the given CharBuffer into lines, applying
+ // the input pattern to each line to see if we have a match
+ //
+ private void grep( List<String> matches )
+ {
+ Matcher lm = linePattern.matcher( cb ); // Line matcher
+ Matcher pm = null; // Pattern matcher
+ int lines = 0;
+ while ( lm.find() )
+ {
+ lines++;
+ CharSequence cs = lm.group(); // The current line
+ if ( pm == null )
+ pm = pattern.matcher( cs );
+ else
+ pm.reset( cs );
+ if ( pm.find() )
+ matches.add( pm.group() );
+ if ( lm.end() == cb.limit() )
+ break;
+ }
+ }
}