reformat code using updated code template (FELIX-1613)
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@981604 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/sigil/common/core.tests/src/org/apache/felix/sigil/common/core/BundleModelElementTest.java b/sigil/common/core.tests/src/org/apache/felix/sigil/common/core/BundleModelElementTest.java
index 6ca045f..6aac51c 100644
--- a/sigil/common/core.tests/src/org/apache/felix/sigil/common/core/BundleModelElementTest.java
+++ b/sigil/common/core.tests/src/org/apache/felix/sigil/common/core/BundleModelElementTest.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.core;
-
import java.util.Arrays;
import org.apache.felix.sigil.common.core.internal.model.osgi.BundleModelElement;
@@ -29,82 +28,76 @@
import junit.framework.TestCase;
-
public class BundleModelElementTest extends TestCase
{
- public BundleModelElementTest( String name )
+ public BundleModelElementTest(String name)
{
- super( name );
+ super(name);
}
-
public void testAddRequires()
{
BundleModelElement element = new BundleModelElement();
- checkRequires( element );
+ checkRequires(element);
}
-
public void testAddImports()
{
BundleModelElement element = new BundleModelElement();
- checkImports( element );
+ checkImports(element);
}
-
public void testAddImportsAndRequires()
{
BundleModelElement element = new BundleModelElement();
- checkImports( element );
- checkRequires( element );
+ checkImports(element);
+ checkRequires(element);
element = new BundleModelElement();
- checkRequires( element );
- checkImports( element );
+ checkRequires(element);
+ checkImports(element);
}
-
- private void checkImports( BundleModelElement element )
+ private void checkImports(BundleModelElement element)
{
PackageImport foo = new PackageImport();
- foo.setPackageName( "foo" );
- foo.setVersions( VersionRange.parseVersionRange( "1.0.0" ) );
+ foo.setPackageName("foo");
+ foo.setVersions(VersionRange.parseVersionRange("1.0.0"));
PackageImport bar = new PackageImport();
- bar.setPackageName( "bar" );
- bar.setVersions( VersionRange.parseVersionRange( "[2.2.2, 3.3.3]" ) );
+ bar.setPackageName("bar");
+ bar.setVersions(VersionRange.parseVersionRange("[2.2.2, 3.3.3]"));
PackageImport baz = new PackageImport();
- baz.setPackageName( "baz" );
- baz.setVersions( VersionRange.parseVersionRange( "[3.0.0, 4.0.0)" ) );
+ baz.setPackageName("baz");
+ baz.setVersions(VersionRange.parseVersionRange("[3.0.0, 4.0.0)"));
- element.addChild( foo.clone() );
- element.addChild( bar.clone() );
- element.addChild( baz.clone() );
+ element.addChild(foo.clone());
+ element.addChild(bar.clone());
+ element.addChild(baz.clone());
- assertTrue( Arrays.asList( element.children() ).contains( foo ) );
- assertTrue( Arrays.asList( element.children() ).contains( bar ) );
- assertTrue( Arrays.asList( element.children() ).contains( baz ) );
+ assertTrue(Arrays.asList(element.children()).contains(foo));
+ assertTrue(Arrays.asList(element.children()).contains(bar));
+ assertTrue(Arrays.asList(element.children()).contains(baz));
}
-
- private void checkRequires( BundleModelElement element )
+ private void checkRequires(BundleModelElement element)
{
RequiredBundle foo = new RequiredBundle();
- foo.setSymbolicName( "foo" );
- foo.setVersions( VersionRange.parseVersionRange( "1.0.0" ) );
+ foo.setSymbolicName("foo");
+ foo.setVersions(VersionRange.parseVersionRange("1.0.0"));
RequiredBundle bar = new RequiredBundle();
- bar.setSymbolicName( "bar" );
- bar.setVersions( VersionRange.parseVersionRange( "[2.2.2, 3.3.3]" ) );
+ bar.setSymbolicName("bar");
+ bar.setVersions(VersionRange.parseVersionRange("[2.2.2, 3.3.3]"));
RequiredBundle baz = new RequiredBundle();
- baz.setSymbolicName( "baz" );
- baz.setVersions( VersionRange.parseVersionRange( "[3.0.0, 4.0.0)" ) );
+ baz.setSymbolicName("baz");
+ baz.setVersions(VersionRange.parseVersionRange("[3.0.0, 4.0.0)"));
- element.addChild( foo.clone() );
- element.addChild( bar.clone() );
- element.addChild( baz.clone() );
+ element.addChild(foo.clone());
+ element.addChild(bar.clone());
+ element.addChild(baz.clone());
- assertTrue( Arrays.asList( element.children() ).contains( foo ) );
- assertTrue( Arrays.asList( element.children() ).contains( bar ) );
- assertTrue( Arrays.asList( element.children() ).contains( baz ) );
+ assertTrue(Arrays.asList(element.children()).contains(foo));
+ assertTrue(Arrays.asList(element.children()).contains(bar));
+ assertTrue(Arrays.asList(element.children()).contains(baz));
}
}
diff --git a/sigil/common/core.tests/src/org/apache/felix/sigil/common/core/ConfigTest.java b/sigil/common/core.tests/src/org/apache/felix/sigil/common/core/ConfigTest.java
index ded87b1..35ece3e 100644
--- a/sigil/common/core.tests/src/org/apache/felix/sigil/common/core/ConfigTest.java
+++ b/sigil/common/core.tests/src/org/apache/felix/sigil/common/core/ConfigTest.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.core;
-
import java.io.IOException;
import java.net.URI;
import java.util.Collection;
@@ -34,70 +33,70 @@
import org.apache.felix.sigil.common.model.osgi.IPackageImport;
import org.apache.felix.sigil.common.osgi.VersionRange;
-
public class ConfigTest extends TestCase
{
- static final URI base = URI.create( "test/ConfigTest/sigil.properties" );
+ static final URI base = URI.create("test/ConfigTest/sigil.properties");
- static {
- System.setProperty( "bar.version", "2.0.0" );
- }
-
- public ConfigTest( String name )
+ static
{
- super( name );
+ System.setProperty("bar.version", "2.0.0");
}
+ public ConfigTest(String name)
+ {
+ super(name);
+ }
public void testSimple() throws IOException
{
- IBldProject project = BldFactory.getProject( base.resolve( "test1.properties" ) );
+ IBldProject project = BldFactory.getProject(base.resolve("test1.properties"));
ISigilBundle bundle = project.getDefaultBundle();
IBundleModelElement info = bundle.getBundleInfo();
PackageImport foo = new PackageImport();
- foo.setPackageName( "foo" );
- foo.setVersions( VersionRange.parseVersionRange( "1.0.0" ) );
+ foo.setPackageName("foo");
+ foo.setVersions(VersionRange.parseVersionRange("1.0.0"));
PackageImport bar = new PackageImport();
- bar.setPackageName( "bar" );
- bar.setVersions( VersionRange.parseVersionRange( "[2.2.2, 3.3.3]" ) );
+ bar.setPackageName("bar");
+ bar.setVersions(VersionRange.parseVersionRange("[2.2.2, 3.3.3]"));
PackageImport baz = new PackageImport();
- baz.setPackageName( "baz" );
- baz.setVersions( VersionRange.parseVersionRange( "[3.0.0, 4.0.0)" ) );
+ baz.setPackageName("baz");
+ baz.setVersions(VersionRange.parseVersionRange("[3.0.0, 4.0.0)"));
Collection<IPackageImport> imports = info.getImports();
-
- assertTrue( foo.toString(), imports.contains( foo ) );
- assertTrue( bar.toString(), imports.contains( bar ) );
- assertTrue( baz.toString(), imports.contains( baz ) );
+
+ assertTrue(foo.toString(), imports.contains(foo));
+ assertTrue(bar.toString(), imports.contains(bar));
+ assertTrue(baz.toString(), imports.contains(baz));
//IBundleModelElement requirements = project.getRequirements();
}
-
- public void testInherited() throws IOException {
-
- IBldProject project = BldFactory.getProject( base.resolve( "inheritance/foo/sigil.properties" ) );
+
+ public void testInherited() throws IOException
+ {
+
+ IBldProject project = BldFactory.getProject(base.resolve("inheritance/foo/sigil.properties"));
ISigilBundle bundle = project.getDefaultBundle();
IBundleModelElement info = bundle.getBundleInfo();
Collection<IPackageImport> imports = info.getImports();
- assertEquals( 1, imports.size() );
+ assertEquals(1, imports.size());
IPackageImport i = imports.iterator().next();
- assertEquals( "org.bar", i.getPackageName() );
- assertEquals( VersionRange.parseVersionRange("2.0.0"), i.getVersions() );
-
-// project = BldFactory.getProject( base.resolve( "inheritance/foo/sigil.properties" ), true );
-//
-// bundle = project.getDefaultBundle();
-// info = bundle.getBundleInfo();
-//
-// imports = info.getImports();
-// assertEquals( 1, imports.size() );
-// i = imports.iterator().next();
-// assertEquals( "org.bar", i.getPackageName() );
-// assertEquals( VersionRange.parseVersionRange("2.0.0"), i.getVersions() );
+ assertEquals("org.bar", i.getPackageName());
+ assertEquals(VersionRange.parseVersionRange("2.0.0"), i.getVersions());
+
+ // project = BldFactory.getProject( base.resolve( "inheritance/foo/sigil.properties" ), true );
+ //
+ // bundle = project.getDefaultBundle();
+ // info = bundle.getBundleInfo();
+ //
+ // imports = info.getImports();
+ // assertEquals( 1, imports.size() );
+ // i = imports.iterator().next();
+ // assertEquals( "org.bar", i.getPackageName() );
+ // assertEquals( VersionRange.parseVersionRange("2.0.0"), i.getVersions() );
}
}
diff --git a/sigil/common/core.tests/src/org/apache/felix/sigil/common/core/internal/model/osgi/PackageExportTest.java b/sigil/common/core.tests/src/org/apache/felix/sigil/common/core/internal/model/osgi/PackageExportTest.java
index 80bda89..df8a908 100644
--- a/sigil/common/core.tests/src/org/apache/felix/sigil/common/core/internal/model/osgi/PackageExportTest.java
+++ b/sigil/common/core.tests/src/org/apache/felix/sigil/common/core/internal/model/osgi/PackageExportTest.java
@@ -25,38 +25,39 @@
public class PackageExportTest extends TestCase
{
- public PackageExportTest( String name )
+ public PackageExportTest(String name)
{
- super( name );
+ super(name);
}
- public void testEquals() {
+ public void testEquals()
+ {
PackageExport p1 = new PackageExport();
p1.setPackageName("foo");
p1.setVersion(Version.parseVersion("1.0.0"));
-
+
PackageExport p2 = new PackageExport();
p2.setPackageName("foo");
p2.setVersion(Version.parseVersion("1.0.0"));
-
- assertTrue( p1.equals( p2 ) );
- assertTrue( p2.equals( p1 ) );
-
+
+ assertTrue(p1.equals(p2));
+ assertTrue(p2.equals(p1));
+
PackageExport p3 = new PackageExport();
p3.setPackageName("foo");
- assertFalse( p1.equals( p3 ) );
- assertFalse( p3.equals( p1 ) );
-
+ assertFalse(p1.equals(p3));
+ assertFalse(p3.equals(p1));
+
PackageExport p4 = new PackageExport();
p4.setVersion(Version.parseVersion("1.0.0"));
- assertFalse( p1.equals( p4 ) );
- assertFalse( p4.equals( p1 ) );
-
+ assertFalse(p1.equals(p4));
+ assertFalse(p4.equals(p1));
+
PackageExport p5 = new PackageExport();
- assertFalse( p1.equals( p5 ) );
- assertFalse( p5.equals( p1 ) );
-
+ assertFalse(p1.equals(p5));
+ assertFalse(p5.equals(p1));
+
}
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/bnd/BundleBuilder.java b/sigil/common/core/src/org/apache/felix/sigil/common/bnd/BundleBuilder.java
index 199c477..f798037 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/bnd/BundleBuilder.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/bnd/BundleBuilder.java
@@ -179,7 +179,8 @@
if (bracket >= 0)
{
String token = dest.substring(bracket);
- throw new Exception("destPattern: expected [id], [name] or [revision]: " + token);
+ throw new Exception("destPattern: expected [id], [name] or [revision]: "
+ + token);
}
errors.clear();
@@ -191,7 +192,8 @@
{
log.verbose("Generated " + bundle.getSymbolicName());
log.verbose("-----------------------------");
- for(Map.Entry<Object, Object> e : spec.entrySet()) {
+ for (Map.Entry<Object, Object> e : spec.entrySet())
+ {
log.verbose(e.getKey() + "=" + e.getValue());
log.verbose("-----------------------------");
}
@@ -210,7 +212,7 @@
convertErrors("BND: ", builder.getErrors());
convertWarnings("BND: ", builder.getWarnings());
-
+
Attributes main = jar.getManifest().getMainAttributes();
String expHeader = main.getValue(Constants.EXPORT_PACKAGE);
log.verbose("BND exports: " + expHeader);
@@ -455,7 +457,7 @@
addVersions(fh.getVersions(), sb);
spec.setProperty(Constants.FRAGMENT_HOST, sb.toString());
}
-
+
return spec;
}
@@ -553,7 +555,7 @@
{
if (sb.length() > 0)
sb.append(",");
-
+
sb.append(bPath.toBNDInstruction(classpath));
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/config/BldAttr.java b/sigil/common/core/src/org/apache/felix/sigil/common/config/BldAttr.java
index 76f8444..930fd72 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/config/BldAttr.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/config/BldAttr.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.config;
-
public class BldAttr
{
// Sigil attributes
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/config/BldConverter.java b/sigil/common/core/src/org/apache/felix/sigil/common/config/BldConverter.java
index e375c3c..84477c5 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/config/BldConverter.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/config/BldConverter.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.config;
-
import java.net.URI;
import java.util.ArrayList;
import java.util.Collections;
@@ -45,7 +44,6 @@
import aQute.lib.osgi.Constants;
-
public class BldConverter
{
private static final String classpathFormat = "<classpathentry kind=\"%s\" path=\"%s\"/>";
@@ -53,184 +51,180 @@
private Properties packageDefaults;
private TreeSet<String> packageWildDefaults;
-
- public BldConverter( BldConfig config )
+ public BldConverter(BldConfig config)
{
this.config = config;
}
-
/**
* converts to an ISigilBundle.
* @param id
* @param bundle
* @return
*/
- public ISigilBundle getBundle( String id, IBldBundle bundle )
+ public ISigilBundle getBundle(String id, IBldBundle bundle)
{
ISigilBundle sigilBundle = new SigilBundle();
IBundleModelElement info = new BundleModelElement();
- sigilBundle.setBundleInfo( info );
+ sigilBundle.setBundleInfo(info);
// exports
// FIXME: UI doesn't understand export wildcard packages
- for ( IPackageExport export : bundle.getExports() )
+ for (IPackageExport export : bundle.getExports())
{
- IPackageExport clone = ( IPackageExport ) export.clone();
- clone.setParent( null );
- info.addExport( clone );
+ IPackageExport clone = (IPackageExport) export.clone();
+ clone.setParent(null);
+ info.addExport(clone);
}
// imports
- for ( IPackageImport import1 : bundle.getImports() )
+ for (IPackageImport import1 : bundle.getImports())
{
- IPackageImport clone = ( IPackageImport ) import1.clone();
- clone.setParent( null );
- info.addImport( clone );
+ IPackageImport clone = (IPackageImport) import1.clone();
+ clone.setParent(null);
+ info.addImport(clone);
}
// requires
- for ( IRequiredBundle require : bundle.getRequires() )
+ for (IRequiredBundle require : bundle.getRequires())
{
- IRequiredBundle clone = ( IRequiredBundle ) require.clone();
- clone.setParent( null );
- info.addRequiredBundle( clone );
+ IRequiredBundle clone = (IRequiredBundle) require.clone();
+ clone.setParent(null);
+ info.addRequiredBundle(clone);
}
// fragment
IRequiredBundle fragment = bundle.getFragmentHost();
- if ( fragment != null )
+ if (fragment != null)
{
- info.setFragmentHost( fragment );
+ info.setFragmentHost(fragment);
}
// contents
- for ( String pkg : bundle.getContents() )
+ for (String pkg : bundle.getContents())
{
- sigilBundle.addPackage( pkg );
+ sigilBundle.addPackage(pkg);
}
// sources
- for ( String source : config.getList( null, BldConfig.L_SRC_CONTENTS ) )
+ for (String source : config.getList(null, BldConfig.L_SRC_CONTENTS))
{
- sigilBundle.addClasspathEntry( String.format( classpathFormat, "src", source ) );
+ sigilBundle.addClasspathEntry(String.format(classpathFormat, "src", source));
}
// libs
Map<String, Map<String, String>> libs = bundle.getLibs();
- for ( String path : libs.keySet() )
+ for (String path : libs.keySet())
{
- Map<String, String> attr = libs.get( path );
- String kind = attr.get( BldAttr.KIND_ATTRIBUTE );
-
- if ( "classpath".equals( kind ) )
+ Map<String, String> attr = libs.get(path);
+ String kind = attr.get(BldAttr.KIND_ATTRIBUTE);
+
+ if ("classpath".equals(kind))
{
- sigilBundle.addClasspathEntry( String.format( classpathFormat, "lib", path ) );
+ sigilBundle.addClasspathEntry(String.format(classpathFormat, "lib", path));
}
else
{
- BldCore.error( "Can't convert -libs kind=" + kind );
+ BldCore.error("Can't convert -libs kind=" + kind);
}
}
// resources
// FIXME: UI doesn't support -resources: path1=path2
List<Resource> resources = bundle.getResources();
- for ( Resource resource : resources )
+ for (Resource resource : resources)
{
- sigilBundle.addSourcePath( resource );
+ sigilBundle.addSourcePath(resource);
}
////////////////////
// simple headers
- info.setSymbolicName( bundle.getSymbolicName() );
+ info.setSymbolicName(bundle.getSymbolicName());
- info.setVersion( VersionTable.getVersion( bundle.getVersion() ) );
+ info.setVersion(VersionTable.getVersion(bundle.getVersion()));
String activator = bundle.getActivator();
- if ( activator != null )
- info.setActivator( activator );
+ if (activator != null)
+ info.setActivator(activator);
- Properties headers = config.getProps( id, BldConfig.P_HEADER );
+ Properties headers = config.getProps(id, BldConfig.P_HEADER);
String header;
- header = headers.getProperty( "CATEGORY" );
- if ( header != null )
- info.setCategory( header );
+ header = headers.getProperty("CATEGORY");
+ if (header != null)
+ info.setCategory(header);
- header = headers.getProperty( Constants.BUNDLE_CONTACTADDRESS );
- if ( header != null )
- info.setContactAddress( header );
+ header = headers.getProperty(Constants.BUNDLE_CONTACTADDRESS);
+ if (header != null)
+ info.setContactAddress(header);
- header = headers.getProperty( Constants.BUNDLE_COPYRIGHT );
- if ( header != null )
- info.setCopyright( header );
+ header = headers.getProperty(Constants.BUNDLE_COPYRIGHT);
+ if (header != null)
+ info.setCopyright(header);
- header = headers.getProperty( Constants.BUNDLE_DESCRIPTION );
- if ( header != null )
- info.setDescription( header );
+ header = headers.getProperty(Constants.BUNDLE_DESCRIPTION);
+ if (header != null)
+ info.setDescription(header);
- header = headers.getProperty( Constants.BUNDLE_VENDOR );
- if ( header != null )
- info.setVendor( header );
+ header = headers.getProperty(Constants.BUNDLE_VENDOR);
+ if (header != null)
+ info.setVendor(header);
- header = headers.getProperty( Constants.BUNDLE_NAME );
- if ( header != null )
- info.setName( header );
+ header = headers.getProperty(Constants.BUNDLE_NAME);
+ if (header != null)
+ info.setName(header);
- header = headers.getProperty( Constants.BUNDLE_DOCURL );
- if ( header != null )
- info.setDocURI( URI.create( header ) );
+ header = headers.getProperty(Constants.BUNDLE_DOCURL);
+ if (header != null)
+ info.setDocURI(URI.create(header));
- header = headers.getProperty( Constants.BUNDLE_LICENSE );
- if ( header != null )
- info.setDocURI( URI.create( header ) );
+ header = headers.getProperty(Constants.BUNDLE_LICENSE);
+ if (header != null)
+ info.setDocURI(URI.create(header));
return sigilBundle;
}
-
- private VersionRange defaultVersion( VersionRange current, String defaultRange )
+ private VersionRange defaultVersion(VersionRange current, String defaultRange)
{
- if ( current.equals( VersionRange.ANY_VERSION )
- || current.equals( VersionRange.parseVersionRange( defaultRange ) ) )
+ if (current.equals(VersionRange.ANY_VERSION)
+ || current.equals(VersionRange.parseVersionRange(defaultRange)))
{
return null;
}
return current;
}
-
// FIXME - copied from BldProject
- private String getDefaultPackageVersion( String name )
+ private String getDefaultPackageVersion(String name)
{
- if ( packageDefaults == null )
+ if (packageDefaults == null)
{
- packageDefaults = config.getProps( null, BldConfig.P_PACKAGE_VERSION );
+ packageDefaults = config.getProps(null, BldConfig.P_PACKAGE_VERSION);
packageWildDefaults = new TreeSet<String>();
- for ( Object key : packageDefaults.keySet() )
+ for (Object key : packageDefaults.keySet())
{
- String pkg = ( String ) key;
- if ( pkg.endsWith( "*" ) )
+ String pkg = (String) key;
+ if (pkg.endsWith("*"))
{
- packageWildDefaults.add( pkg.substring( 0, pkg.length() - 1 ) );
+ packageWildDefaults.add(pkg.substring(0, pkg.length() - 1));
}
}
}
- String version = packageDefaults.getProperty( name );
+ String version = packageDefaults.getProperty(name);
- if ( version == null )
+ if (version == null)
{
- for ( String pkg : packageWildDefaults )
+ for (String pkg : packageWildDefaults)
{
- if ( name.startsWith( pkg ) )
+ if (name.startsWith(pkg))
{
- version = packageDefaults.getProperty( pkg + "*" );
+ version = packageDefaults.getProperty(pkg + "*");
// break; -- don't break, as we want the longest match
}
}
@@ -239,240 +233,238 @@
return version;
}
-
/**
* converts from an ISigilBundle.
*
* @param id
* @param bundle
*/
- public void setBundle( String id, ISigilBundle bundle )
+ public void setBundle(String id, ISigilBundle bundle)
{
IBundleModelElement info = bundle.getBundleInfo();
- String bundleVersion = config.getString( id, BldConfig.S_VERSION );
+ String bundleVersion = config.getString(id, BldConfig.S_VERSION);
Map<String, Map<String, String>> exports = new TreeMap<String, Map<String, String>>();
-
+
setSimpleHeaders(id, info);
setExports(id, bundleVersion, info, exports);
-
+
// -imports and -requires are global to all bundles
setImports(null, bundleVersion, info, exports);
setRequires(null, bundleVersion, info);
-
+
setFragments(id, info);
setContents(id, info, bundle);
setLibraries(id, info, bundle);
setResources(id, info, bundle);
- if ( info.getSourceLocation() != null )
+ if (info.getSourceLocation() != null)
{
- BldCore.error( "SourceLocation conversion not yet implemented." );
+ BldCore.error("SourceLocation conversion not yet implemented.");
}
- if ( !info.getLibraryImports().isEmpty() )
+ if (!info.getLibraryImports().isEmpty())
{
- BldCore.error( "LibraryImports conversion not yet implemented." );
+ BldCore.error("LibraryImports conversion not yet implemented.");
}
}
-
/**
* @param id
* @param info
*/
- private void setSimpleHeaders( String id, IBundleModelElement info )
+ private void setSimpleHeaders(String id, IBundleModelElement info)
{
- List<String> ids = config.getList( null, BldConfig.C_BUNDLES );
- String idBsn = id != null ? id : ids.get( 0 );
- String oldBsn = config.getString( id, BldConfig.S_SYM_NAME );
+ List<String> ids = config.getList(null, BldConfig.C_BUNDLES);
+ String idBsn = id != null ? id : ids.get(0);
+ String oldBsn = config.getString(id, BldConfig.S_SYM_NAME);
String bsn = info.getSymbolicName();
- if ( !bsn.equals( idBsn ) || oldBsn != null )
- config.setString( id, BldConfig.S_SYM_NAME, bsn );
+ if (!bsn.equals(idBsn) || oldBsn != null)
+ config.setString(id, BldConfig.S_SYM_NAME, bsn);
String version = info.getVersion().toString();
- if ( version != null )
- config.setString( id, BldConfig.S_VERSION, version );
+ if (version != null)
+ config.setString(id, BldConfig.S_VERSION, version);
String activator = info.getActivator();
- if ( activator != null )
- config.setString( id, BldConfig.S_ACTIVATOR, activator );
+ if (activator != null)
+ config.setString(id, BldConfig.S_ACTIVATOR, activator);
- Properties headers = config.getProps( null, BldConfig.P_HEADER );
+ Properties headers = config.getProps(null, BldConfig.P_HEADER);
- setHeader( headers, id, "CATEGORY", info.getCategory() );
- setHeader( headers, id, Constants.BUNDLE_CONTACTADDRESS, info.getContactAddress() );
- setHeader( headers, id, Constants.BUNDLE_COPYRIGHT, info.getCopyright() );
- setHeader( headers, id, Constants.BUNDLE_DESCRIPTION, info.getDescription() );
- setHeader( headers, id, Constants.BUNDLE_VENDOR, info.getVendor() );
- setHeader( headers, id, Constants.BUNDLE_NAME, info.getName() );
+ setHeader(headers, id, "CATEGORY", info.getCategory());
+ setHeader(headers, id, Constants.BUNDLE_CONTACTADDRESS, info.getContactAddress());
+ setHeader(headers, id, Constants.BUNDLE_COPYRIGHT, info.getCopyright());
+ setHeader(headers, id, Constants.BUNDLE_DESCRIPTION, info.getDescription());
+ setHeader(headers, id, Constants.BUNDLE_VENDOR, info.getVendor());
+ setHeader(headers, id, Constants.BUNDLE_NAME, info.getName());
- if ( info.getDocURI() != null )
- config.setProp( id, BldConfig.P_HEADER, Constants.BUNDLE_DOCURL, info.getDocURI().toString() );
+ if (info.getDocURI() != null)
+ config.setProp(id, BldConfig.P_HEADER, Constants.BUNDLE_DOCURL,
+ info.getDocURI().toString());
- if ( info.getLicenseURI() != null )
- config.setProp( id, BldConfig.P_HEADER, Constants.BUNDLE_LICENSE, info.getLicenseURI().toString() );
+ if (info.getLicenseURI() != null)
+ config.setProp(id, BldConfig.P_HEADER, Constants.BUNDLE_LICENSE,
+ info.getLicenseURI().toString());
}
-
/**
* @param id
* @param info
* @param bundle
*/
- private void setResources( String id, IBundleModelElement info, ISigilBundle bundle )
+ private void setResources(String id, IBundleModelElement info, ISigilBundle bundle)
{
// resources
ArrayList<String> resources = new ArrayList<String>();
- for ( Resource ipath : bundle.getSourcePaths() )
+ for (Resource ipath : bundle.getSourcePaths())
{
- resources.add( ipath.toString() );
+ resources.add(ipath.toString());
}
- if ( !resources.isEmpty() || !config.getList( id, BldConfig.L_RESOURCES ).isEmpty() )
+ if (!resources.isEmpty() || !config.getList(id, BldConfig.L_RESOURCES).isEmpty())
{
- Collections.sort( resources );
- config.setList( id, BldConfig.L_RESOURCES, resources );
+ Collections.sort(resources);
+ config.setList(id, BldConfig.L_RESOURCES, resources);
}
}
-
/**
* @param id
* @param info
* @param bundle
*/
- private void setLibraries( String id, IBundleModelElement info, ISigilBundle bundle )
+ private void setLibraries(String id, IBundleModelElement info, ISigilBundle bundle)
{
// libs
Map<String, Map<String, String>> libs = new TreeMap<String, Map<String, String>>();
List<String> sources = new ArrayList<String>();
// classpathEntries map to -libs or -sources
- for ( String entry : bundle.getClasspathEntrys() )
+ for (String entry : bundle.getClasspathEntrys())
{
// <classpathentry kind="lib" path="lib/dependee.jar"/>
// <classpathentry kind="src" path="src"/>
final String regex = ".* kind=\"([^\"]+)\" path=\"([^\"]+)\".*";
- Pattern pattern = Pattern.compile( regex );
- Matcher matcher = pattern.matcher( entry );
- if ( matcher.matches() )
+ Pattern pattern = Pattern.compile(regex);
+ Matcher matcher = pattern.matcher(entry);
+ if (matcher.matches())
{
- String kind = matcher.group( 1 );
- String path = matcher.group( 2 );
- if ( kind.equals( "lib" ) )
+ String kind = matcher.group(1);
+ String path = matcher.group(2);
+ if (kind.equals("lib"))
{
Map<String, String> map2 = new TreeMap<String, String>();
- map2.put( BldAttr.KIND_ATTRIBUTE, "classpath" );
- libs.put( path, map2 );
+ map2.put(BldAttr.KIND_ATTRIBUTE, "classpath");
+ libs.put(path, map2);
}
- else if ( kind.equals( "src" ) )
+ else if (kind.equals("src"))
{
- sources.add( path );
+ sources.add(path);
}
else
{
- BldCore.error( "unknown classpathentry kind=" + kind );
+ BldCore.error("unknown classpathentry kind=" + kind);
}
}
else
{
- BldCore.error( "can't match classpathEntry in: " + entry );
+ BldCore.error("can't match classpathEntry in: " + entry);
}
}
- if ( !libs.isEmpty() || !config.getMap( id, BldConfig.M_LIBS ).isEmpty() )
+ if (!libs.isEmpty() || !config.getMap(id, BldConfig.M_LIBS).isEmpty())
{
- config.setMap( id, BldConfig.M_LIBS, libs );
+ config.setMap(id, BldConfig.M_LIBS, libs);
}
// -sourcedirs is global to all bundles
- if ( !sources.isEmpty() || !config.getList( null, BldConfig.L_SRC_CONTENTS ).isEmpty() )
+ if (!sources.isEmpty()
+ || !config.getList(null, BldConfig.L_SRC_CONTENTS).isEmpty())
{
- config.setList( null, BldConfig.L_SRC_CONTENTS, sources );
+ config.setList(null, BldConfig.L_SRC_CONTENTS, sources);
}
}
-
/**
* @param id
* @param info
* @param bundle
*/
- private void setContents( String id, IBundleModelElement info, ISigilBundle bundle )
+ private void setContents(String id, IBundleModelElement info, ISigilBundle bundle)
{
// contents
List<String> contents = new ArrayList<String>();
- for ( String pkg : bundle.getPackages() )
+ for (String pkg : bundle.getPackages())
{
- contents.add( pkg );
+ contents.add(pkg);
}
- if ( !contents.isEmpty() || !config.getList( id, BldConfig.L_CONTENTS ).isEmpty() )
+ if (!contents.isEmpty() || !config.getList(id, BldConfig.L_CONTENTS).isEmpty())
{
- config.setList( id, BldConfig.L_CONTENTS, contents );
+ config.setList(id, BldConfig.L_CONTENTS, contents);
}
}
-
/**
* @param id
* @param info
*/
- private void setFragments( String id, IBundleModelElement info )
+ private void setFragments(String id, IBundleModelElement info)
{
- Properties defaultBundles = config.getProps( null, BldConfig.P_BUNDLE_VERSION );
+ Properties defaultBundles = config.getProps(null, BldConfig.P_BUNDLE_VERSION);
Map<String, Map<String, String>> fragments = new TreeMap<String, Map<String, String>>();
IRequiredBundle fragment = info.getFragmentHost();
- if ( fragment != null )
+ if (fragment != null)
{
Map<String, String> map2 = new TreeMap<String, String>();
String name = fragment.getSymbolicName();
- VersionRange versions = defaultVersion( fragment.getVersions(), defaultBundles.getProperty( name ) );
- if ( versions != null )
- map2.put( BldAttr.VERSION_ATTRIBUTE, versions.toString() );
- fragments.put( name, map2 );
+ VersionRange versions = defaultVersion(fragment.getVersions(),
+ defaultBundles.getProperty(name));
+ if (versions != null)
+ map2.put(BldAttr.VERSION_ATTRIBUTE, versions.toString());
+ fragments.put(name, map2);
}
- if ( !fragments.isEmpty() || !config.getMap( id, BldConfig.M_FRAGMENT ).isEmpty() )
+ if (!fragments.isEmpty() || !config.getMap(id, BldConfig.M_FRAGMENT).isEmpty())
{
- config.setMap( id, BldConfig.M_FRAGMENT, fragments );
+ config.setMap(id, BldConfig.M_FRAGMENT, fragments);
}
}
-
/**
* @param id
* @param bundleVersion
* @param info
*/
- private void setRequires( String id, String bundleVersion, IBundleModelElement info )
+ private void setRequires(String id, String bundleVersion, IBundleModelElement info)
{
// requires
- Properties defaultBundles = config.getProps( null, BldConfig.P_BUNDLE_VERSION );
+ Properties defaultBundles = config.getProps(null, BldConfig.P_BUNDLE_VERSION);
Map<String, Map<String, String>> requires = new TreeMap<String, Map<String, String>>();
- for ( IRequiredBundle require : info.getRequiredBundles() )
+ for (IRequiredBundle require : info.getRequiredBundles())
{
Map<String, String> map2 = new TreeMap<String, String>();
String name = require.getSymbolicName();
- VersionRange versions = defaultVersion( require.getVersions(), defaultBundles.getProperty( name ) );
- if ( versions != null )
- map2.put( BldAttr.VERSION_ATTRIBUTE, versions.toString() );
- requires.put( name, map2 );
+ VersionRange versions = defaultVersion(require.getVersions(),
+ defaultBundles.getProperty(name));
+ if (versions != null)
+ map2.put(BldAttr.VERSION_ATTRIBUTE, versions.toString());
+ requires.put(name, map2);
}
- if ( !requires.isEmpty() || !config.getMap( id, BldConfig.M_REQUIRES ).isEmpty() )
+ if (!requires.isEmpty() || !config.getMap(id, BldConfig.M_REQUIRES).isEmpty())
{
- config.setMap( id, BldConfig.M_REQUIRES, requires );
+ config.setMap(id, BldConfig.M_REQUIRES, requires);
}
}
-
/**
* @param bundleVersion
* @param info
* @param exports
*/
- private void setImports( String id, String bundleVersion, IBundleModelElement info, Map<String, Map<String, String>> exports )
+ private void setImports(String id, String bundleVersion, IBundleModelElement info,
+ Map<String, Map<String, String>> exports)
{
// imports
Map<String, Map<String, String>> imports = new TreeMap<String, Map<String, String>>();
@@ -481,57 +473,57 @@
// if the version to be saved is the same as the default version,
// then we should _remove_ the version from the value being saved,
// since config.getMap() does not apply default versions.
- for ( IPackageImport import1 : info.getImports() )
+ for (IPackageImport import1 : info.getImports())
{
Map<String, String> map2 = new TreeMap<String, String>();
String name = import1.getPackageName();
- VersionRange versions = defaultVersion( import1.getVersions(), getDefaultPackageVersion( name ) );
+ VersionRange versions = defaultVersion(import1.getVersions(),
+ getDefaultPackageVersion(name));
boolean isDependency = import1.isDependency();
- Map<String, String> selfImport = exports.get( name );
+ Map<String, String> selfImport = exports.get(name);
- if ( selfImport != null )
+ if (selfImport != null)
{
// avoid saving self-import attributes, e.g.
// org.cauldron.newton.example.fractal.engine;resolve=auto;version=1.0.0
isDependency = true;
- if ( versions != null )
+ if (versions != null)
{
- String exportVersion = selfImport.get( BldAttr.VERSION_ATTRIBUTE );
- if ( exportVersion == null )
+ String exportVersion = selfImport.get(BldAttr.VERSION_ATTRIBUTE);
+ if (exportVersion == null)
exportVersion = bundleVersion;
- if ( exportVersion.equals( versions.toString() ) )
+ if (exportVersion.equals(versions.toString()))
{
versions = null;
}
}
}
- if ( versions != null )
+ if (versions != null)
{
- map2.put( BldAttr.VERSION_ATTRIBUTE, versions.toString() );
+ map2.put(BldAttr.VERSION_ATTRIBUTE, versions.toString());
}
- if ( import1.isOptional() )
+ if (import1.isOptional())
{
- map2.put( BldAttr.RESOLUTION_ATTRIBUTE, BldAttr.RESOLUTION_OPTIONAL );
+ map2.put(BldAttr.RESOLUTION_ATTRIBUTE, BldAttr.RESOLUTION_OPTIONAL);
}
- String resolve = BldProject.getResolve( import1, isDependency );
- if ( resolve != null )
- map2.put( BldAttr.RESOLVE_ATTRIBUTE, resolve );
+ String resolve = BldProject.getResolve(import1, isDependency);
+ if (resolve != null)
+ map2.put(BldAttr.RESOLVE_ATTRIBUTE, resolve);
- imports.put( name, map2 );
+ imports.put(name, map2);
}
- if ( !imports.isEmpty() || !config.getMap( id, BldConfig.M_IMPORTS ).isEmpty() )
+ if (!imports.isEmpty() || !config.getMap(id, BldConfig.M_IMPORTS).isEmpty())
{
- config.setMap( id, BldConfig.M_IMPORTS, imports );
+ config.setMap(id, BldConfig.M_IMPORTS, imports);
}
}
-
/**
* @param id
* @param info
@@ -539,29 +531,29 @@
* @param exports
*
*/
- private void setExports(String id, String bundleVersion, IBundleModelElement info, Map<String, Map<String, String>> exports)
+ private void setExports(String id, String bundleVersion, IBundleModelElement info,
+ Map<String, Map<String, String>> exports)
{
- for ( IPackageExport export : info.getExports() )
+ for (IPackageExport export : info.getExports())
{
Map<String, String> map2 = new TreeMap<String, String>();
String version = export.getVersion().toString();
- if ( !version.equals( bundleVersion ) )
- map2.put( BldAttr.VERSION_ATTRIBUTE, version );
- exports.put( export.getPackageName(), map2 );
+ if (!version.equals(bundleVersion))
+ map2.put(BldAttr.VERSION_ATTRIBUTE, version);
+ exports.put(export.getPackageName(), map2);
}
- if ( !exports.isEmpty() || !config.getMap( id, BldConfig.M_EXPORTS ).isEmpty() )
+ if (!exports.isEmpty() || !config.getMap(id, BldConfig.M_EXPORTS).isEmpty())
{
- config.setMap( id, BldConfig.M_EXPORTS, exports );
+ config.setMap(id, BldConfig.M_EXPORTS, exports);
}
}
-
- private void setHeader( Properties headers, String id, String key, String value )
+ private void setHeader(Properties headers, String id, String key, String value)
{
- if ( value == null )
+ if (value == null)
value = "";
- if ( !value.equals( headers.getProperty( key, "" ) ) )
- config.setProp( id, BldConfig.P_HEADER, key, value );
+ if (!value.equals(headers.getProperty(key, "")))
+ config.setProp(id, BldConfig.P_HEADER, key, value);
}
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/config/BldFactory.java b/sigil/common/core/src/org/apache/felix/sigil/common/config/BldFactory.java
index 80eb432..3a9bff8 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/config/BldFactory.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/config/BldFactory.java
@@ -35,7 +35,8 @@
return load(uri, false, null);
}
- public static IBldProject getProject(URI uri, Properties overrides) throws IOException
+ public static IBldProject getProject(URI uri, Properties overrides)
+ throws IOException
{
return load(uri, false, overrides);
}
@@ -67,7 +68,8 @@
return project;
}
- private synchronized static BldProject load(URI uri, boolean ignoreCache, Properties overrides) throws IOException
+ private synchronized static BldProject load(URI uri, boolean ignoreCache,
+ Properties overrides) throws IOException
{
BldProject p = null;
if (!ignoreCache)
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/config/BldProject.java b/sigil/common/core/src/org/apache/felix/sigil/common/config/BldProject.java
index 7511258..705b2b9 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/config/BldProject.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/config/BldProject.java
@@ -180,11 +180,12 @@
try
{
File file = new File(defaults);
- if (!file.isAbsolute()) {
+ if (!file.isAbsolute())
+ {
file = new File(base, defaults);
}
file = file.getCanonicalFile();
-
+
URL url = file.toURI().toURL();
BldProperties bp = new BldProperties(file.getParentFile(), bldOverrides);
@@ -289,23 +290,27 @@
}
return file;
}
-
- public Resource newResource(String location) {
+
+ public Resource newResource(String location)
+ {
String[] paths = location.split("=", 2);
String bPath = paths[0];
String fsPath = (paths.length > 1 ? paths[1] : null);
- if (bPath.startsWith("@")) {
+ if (bPath.startsWith("@"))
+ {
bPath = bPath.substring(1);
return new InlineResource(BldProject.this, bPath);
}
- else if (bPath.startsWith("{")) {
- bPath = bPath.substring(1, bPath.length() -1);
+ else if (bPath.startsWith("{"))
+ {
+ bPath = bPath.substring(1, bPath.length() - 1);
return new PreprocessedResource(BldProject.this, bPath, fsPath);
}
- else {
+ else
+ {
return new StandardResource(BldProject.this, bPath, fsPath);
}
- }
+ }
public String getVersion()
{
@@ -359,9 +364,9 @@
* set internal OSGiImport and isDependency flags, based on external
* resolve= attribute.
*/
- // OSGiImport: AUTO ALWAYS NEVER
- // dependency: default - compile
- // !dependency: auto runtime ignore
+ // OSGiImport: AUTO ALWAYS NEVER
+ // dependency: default - compile
+ // !dependency: auto runtime ignore
private void setResolve(IPackageImport pi, String resolve) throws IOException
{
@@ -982,10 +987,11 @@
public List<Resource> getResources()
{
List<String> resources = getList(BldConfig.L_RESOURCES);
- if (resources == null) {
+ if (resources == null)
+ {
return Collections.emptyList();
}
-
+
List<Resource> ret = new ArrayList<Resource>(resources.size());
for (String resource : resources)
{
@@ -993,7 +999,7 @@
}
return ret;
}
-
+
public Properties getHeaders()
{
Properties headers = config.getProps(id, BldConfig.P_HEADER);
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/config/BldProperties.java b/sigil/common/core/src/org/apache/felix/sigil/common/config/BldProperties.java
index 1ff11e5..a923f31 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/config/BldProperties.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/config/BldProperties.java
@@ -39,16 +39,16 @@
}
private final Properties mySysEnv;
-
+
BldProperties(File baseDir, Properties overrides)
{
mySysEnv = new Properties(sysEnv);
-
+
if (overrides != null)
{
mySysEnv.putAll(overrides);
}
-
+
try
{
if (baseDir != null)
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/config/IBldProject.java b/sigil/common/core/src/org/apache/felix/sigil/common/config/IBldProject.java
index d766fae..5db4c5f 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/config/IBldProject.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/config/IBldProject.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.config;
-
import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
@@ -33,54 +32,44 @@
import org.apache.felix.sigil.common.model.osgi.IPackageImport;
import org.apache.felix.sigil.common.model.osgi.IRequiredBundle;
-
public interface IBldProject
{
static final String PROJECT_FILE = "sigil.properties";
static final String PROJECT_DEFAULTS = "../sigil-defaults.properties";
-
void save() throws IOException;
+ void saveAs(File path) throws IOException;
- void saveAs( File path ) throws IOException;
-
-
- void saveTo( OutputStream out ) throws IOException;
-
+ void saveTo(OutputStream out) throws IOException;
/**
* gets default package version ranges.
*/
Properties getDefaultPackageVersions();
-
/**
* gets default package version range for named package.
* Also handles wildcards in defaults.
*/
- String getDefaultPackageVersion( String name );
-
+ String getDefaultPackageVersion(String name);
/**
* get project options.
*/
Properties getOptions();
-
/**
* get project version.
*/
String getVersion();
-
/**
* gets dependencies (Package-Import and Require-Bundle) needed to compile.
*/
IBundleModelElement getDependencies();
-
/**
* gets project source directories.
* This is a convenient way to specify bundle contents
@@ -88,55 +77,47 @@
*/
List<String> getSourceDirs();
-
/**
* gets the list of packages represented by getSourceDirs().
* @throws IOException
*/
List<String> getSourcePkgs();
-
/**
* gets bundle ids.
*/
List<String> getBundleIds();
-
/**
* gets bundles.
*/
List<IBldBundle> getBundles();
-
/**
* convert specified bundle to SigilBundle.
*/
- ISigilBundle getSigilBundle( String id );
-
+ ISigilBundle getSigilBundle(String id);
/**
* convert SigilBundle to specified bundle.
*/
- void setSigilBundle( String id, ISigilBundle sb );
-
+ void setSigilBundle(String id, ISigilBundle sb);
/**
* converts default bundle to SigilBundle.
*/
ISigilBundle getDefaultBundle();
-
/**
* converts SigilBundle to default bundle.
*/
- void setDefaultBundle( ISigilBundle sb );
-
+ void setDefaultBundle(ISigilBundle sb);
/**
* resolves a relative path against the project file location.
*/
- File resolve( String path );
-
+ File resolve(String path);
+
/**
* Creates a new resource for this bundle
* @param location
@@ -144,7 +125,6 @@
*/
Resource newResource(String location);
-
/**
* gets the last modification date of the project file.
*/
@@ -157,80 +137,68 @@
*/
String getActivator();
-
/**
* gets bundle id within project.
*/
String getId();
-
/**
* gets bundle version.
*/
String getVersion();
-
/**
* gets the Bundle-SymbolicName.
*/
String getSymbolicName();
-
/**
* gets bundles export-packages.
*/
List<IPackageExport> getExports();
-
/**
* gets project import-packages.
*/
List<IPackageImport> getImports();
-
/**
* gets project require-bundles.
*/
List<IRequiredBundle> getRequires();
-
/**
* get bundle fragment-host.
*/
IRequiredBundle getFragmentHost();
-
/**
* gets bundle libs.
*/
Map<String, Map<String, String>> getLibs();
-
/**
* gets the bundle contents
* @return list of package patterns.
*/
List<String> getContents();
-
/**
* gets the additional resources.
* @return map with key as path in bundle, value as path in file system.
* Paths are resolved relative to location of project file and also from classpath.
*/
List<Resource> getResources();
-
+
/**
* gets additional bundle headers.
*/
Properties getHeaders();
-
/**
* resolves a relative path against the project file location.
*/
- File resolve( String path );
-
+ File resolve(String path);
/**
* @return
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/config/IRepositoryConfig.java b/sigil/common/core/src/org/apache/felix/sigil/common/config/IRepositoryConfig.java
index 266bce3..39beab2 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/config/IRepositoryConfig.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/config/IRepositoryConfig.java
@@ -19,17 +19,14 @@
package org.apache.felix.sigil.common.config;
-
import java.util.Map;
import java.util.Properties;
-
public interface IRepositoryConfig
{
static final String REPOSITORY_PROVIDER = "provider";
static final String REPOSITORY_LEVEL = "level";
-
/**
* get properties with which to instantiate repositories.
* The key REPOSITORY_PROVIDER will be set to the fully qualified class name of the IRepositoryProvider.
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/config/Resource.java b/sigil/common/core/src/org/apache/felix/sigil/common/config/Resource.java
index c0e8b9d..19183a6 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/config/Resource.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/config/Resource.java
@@ -26,7 +26,7 @@
*
*/
public interface Resource
-{
+{
String toBNDInstruction(File[] classpath);
/**
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/AbstractResource.java b/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/AbstractResource.java
index 21e2305..40d9dba 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/AbstractResource.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/AbstractResource.java
@@ -32,18 +32,19 @@
{
protected final String bPath;
protected final IBldProject project;
-
- protected AbstractResource(IBldProject project, String bPath) {
- if (bPath == null)
+
+ protected AbstractResource(IBldProject project, String bPath)
+ {
+ if (bPath == null)
throw new NullPointerException();
-
- if(project == null)
+
+ if (project == null)
throw new NullPointerException();
-
+
this.bPath = bPath;
this.project = project;
}
-
+
protected String findFileSystemPath(String fsPath, File[] classpath)
{
File resolved = project.resolve(fsPath);
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/InlineResource.java b/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/InlineResource.java
index 12d9755..7d23bf5 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/InlineResource.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/InlineResource.java
@@ -45,8 +45,9 @@
{
return bPath;
}
-
- public String toString() {
+
+ public String toString()
+ {
return '@' + bPath;
}
@@ -57,7 +58,7 @@
{
StringBuilder sb = new StringBuilder();
sb.append('@');
-
+
File f = project.resolve(bPath);
if (f.exists())
@@ -66,7 +67,7 @@
}
else
sb.append(bPath);
-
+
return sb.toString();
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/PreprocessedResource.java b/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/PreprocessedResource.java
index 358b1c3..c4672a5 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/PreprocessedResource.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/PreprocessedResource.java
@@ -30,7 +30,7 @@
public class PreprocessedResource extends AbstractResource
{
private final String fsPath;
-
+
public PreprocessedResource(IBldProject project, String bPath, String fsPath)
{
super(project, bPath);
@@ -44,13 +44,15 @@
{
return fsPath == null ? bPath : fsPath;
}
-
+
@Override
- public String toString() {
+ public String toString()
+ {
StringBuilder sb = new StringBuilder();
sb.append('{');
sb.append(bPath);
- if (fsPath != null) {
+ if (fsPath != null)
+ {
sb.append('=');
sb.append(fsPath);
}
@@ -75,7 +77,7 @@
sb.append('=');
sb.append(fsp);
sb.append('}');
-
+
return sb.toString();
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/StandardResource.java b/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/StandardResource.java
index 778f4b9..39c6130 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/StandardResource.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/config/internal/StandardResource.java
@@ -49,12 +49,14 @@
{
return fsPath == null ? bPath : fsPath;
}
-
+
@Override
- public String toString() {
+ public String toString()
+ {
StringBuilder sb = new StringBuilder();
sb.append(bPath);
- if (fsPath != null) {
+ if (fsPath != null)
+ {
sb.append('=');
sb.append(fsPath);
}
@@ -76,7 +78,7 @@
sb.append(bPath);
sb.append('=');
sb.append(fsp);
-
+
return sb.toString();
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/BldCore.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/BldCore.java
index e80f8d4..d8d6013 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/BldCore.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/BldCore.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.core;
-
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -43,61 +42,56 @@
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
-
public class BldCore implements BundleActivator
{
private static LicenseManager licenceManager = new LicenseManager();
- private static final Logger log = Logger.getLogger( BldCore.class.getName() );
+ private static final Logger log = Logger.getLogger(BldCore.class.getName());
-
- public static void error( String string, Throwable e )
+ public static void error(String string, Throwable e)
{
// TODO
- log.log( Level.WARNING, string, e );
+ log.log(Level.WARNING, string, e);
}
-
- public static void error( String string )
+ public static void error(String string)
{
- log.log( Level.WARNING, string );
+ log.log(Level.WARNING, string);
}
-
public static ILicenseManager getLicenseManager()
{
return licenceManager;
}
-
- public void start( BundleContext context ) throws Exception
+ public void start(BundleContext context) throws Exception
{
init();
}
-
public static void init() throws Exception
{
- ModelElementFactory.getInstance().register( ISigilBundle.class, SigilBundle.class, "bundle", "sigil", null );
- ModelElementFactory.getInstance().register( ILibrary.class, Library.class, "library", "sigil", null );
- ModelElementFactory.getInstance().register( ILibraryImport.class, LibraryImport.class, "library-import",
- "sigil", null );
+ ModelElementFactory.getInstance().register(ISigilBundle.class, SigilBundle.class,
+ "bundle", "sigil", null);
+ ModelElementFactory.getInstance().register(ILibrary.class, Library.class,
+ "library", "sigil", null);
+ ModelElementFactory.getInstance().register(ILibraryImport.class,
+ LibraryImport.class, "library-import", "sigil", null);
// osgi elements
- ModelElementFactory.getInstance().register( IBundleModelElement.class, BundleModelElement.class, "bundle",
- null, null );
- ModelElementFactory.getInstance().register( IPackageExport.class, PackageExport.class, "package.export", null,
- null );
- ModelElementFactory.getInstance().register( IPackageImport.class, PackageImport.class, "package.import", null,
- null );
- ModelElementFactory.getInstance().register( IRequiredBundle.class, RequiredBundle.class, "required.bundle",
- null, null );
+ ModelElementFactory.getInstance().register(IBundleModelElement.class,
+ BundleModelElement.class, "bundle", null, null);
+ ModelElementFactory.getInstance().register(IPackageExport.class,
+ PackageExport.class, "package.export", null, null);
+ ModelElementFactory.getInstance().register(IPackageImport.class,
+ PackageImport.class, "package.import", null, null);
+ ModelElementFactory.getInstance().register(IRequiredBundle.class,
+ RequiredBundle.class, "required.bundle", null, null);
}
-
- public void stop( BundleContext context ) throws Exception
+ public void stop(BundleContext context) throws Exception
{
// TODO Auto-generated method stub
- }
+ }
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/license/LicenseManager.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/license/LicenseManager.java
index 7c4ba06..0d6b444 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/license/LicenseManager.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/license/LicenseManager.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.core.internal.license;
-
import java.util.Collections;
import java.util.HashMap;
import java.util.Set;
@@ -28,39 +27,33 @@
import org.apache.felix.sigil.common.core.licence.ILicenseManager;
import org.apache.felix.sigil.common.core.licence.ILicensePolicy;
-
public class LicenseManager implements ILicenseManager
{
private HashMap<String, Pattern> licenses = new HashMap<String, Pattern>();
private HashMap<String, LicensePolicy> policies = new HashMap<String, LicensePolicy>();
- private LicensePolicy defaultPolicy = new LicensePolicy( this );
+ private LicensePolicy defaultPolicy = new LicensePolicy(this);
-
- public void addLicense( String name, Pattern pattern )
+ public void addLicense(String name, Pattern pattern)
{
- licenses.put( name, pattern );
+ licenses.put(name, pattern);
}
-
- public void removeLicense( String name )
+ public void removeLicense(String name)
{
- licenses.remove( name );
+ licenses.remove(name);
}
-
public Set<String> getLicenseNames()
{
- return Collections.unmodifiableSet( licenses.keySet() );
+ return Collections.unmodifiableSet(licenses.keySet());
}
-
- public Pattern getLicensePattern( String name )
+ public Pattern getLicensePattern(String name)
{
- return licenses.get( name );
+ return licenses.get(name);
}
-
public ILicensePolicy getDefaultPolicy()
{
return defaultPolicy;
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/license/LicensePolicy.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/license/LicensePolicy.java
index 1b3ce5f..d393b0a 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/license/LicensePolicy.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/license/LicensePolicy.java
@@ -19,45 +19,38 @@
package org.apache.felix.sigil.common.core.internal.license;
-
import org.apache.felix.sigil.common.core.licence.ILicensePolicy;
import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
import org.eclipse.core.runtime.IProgressMonitor;
-
public class LicensePolicy implements ILicensePolicy
{
private LicenseManager licenseManager;
-
- public LicensePolicy( LicenseManager licenseManager )
+ public LicensePolicy(LicenseManager licenseManager)
{
this.licenseManager = licenseManager;
}
-
- public boolean accept( ISigilBundle bundle )
+ public boolean accept(ISigilBundle bundle)
{
return true;
}
-
- public void addAllowed( String licenseName )
+ public void addAllowed(String licenseName)
{
// TODO Auto-generated method stub
}
-
- public void removeAllowed( String licenseName )
+ public void removeAllowed(String licenseName)
{
// TODO Auto-generated method stub
}
-
- public void save( IProgressMonitor monitor )
+ public void save(IProgressMonitor monitor)
{
// TODO Auto-generated method stub
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/BundleCapability.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/BundleCapability.java
index eb373de..a97d1d2 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/BundleCapability.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/BundleCapability.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
- package org.apache.felix.sigil.common.core.internal.model.eclipse;
+package org.apache.felix.sigil.common.core.internal.model.eclipse;
import org.apache.felix.sigil.common.model.AbstractModelElement;
import org.apache.felix.sigil.common.model.eclipse.IBundleCapability;
@@ -50,15 +50,19 @@
@Override
public boolean equals(Object obj)
{
- if ( obj == this ) return true;
- if ( obj == null ) return false;
+ if (obj == this)
+ return true;
+ if (obj == null)
+ return false;
- if ( obj instanceof BundleCapability ) {
+ if (obj instanceof BundleCapability)
+ {
BundleCapability bc = (BundleCapability) obj;
- return (bsn == null ? bc.bsn == null : bsn.equals(bc.bsn)) &&
- (version == null ? bc.version == null : version.equals(bc.version));
+ return (bsn == null ? bc.bsn == null : bsn.equals(bc.bsn))
+ && (version == null ? bc.version == null : version.equals(bc.version));
}
- else {
+ else
+ {
return false;
}
}
@@ -67,12 +71,14 @@
public int hashCode()
{
int hc = 11;
-
- if ( bsn!= null ) {
+
+ if (bsn != null)
+ {
hc *= bsn.hashCode();
}
-
- if ( version != null ) {
+
+ if (version != null)
+ {
hc *= version.hashCode();
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/Library.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/Library.java
index 163eaa9..0e16bc5 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/Library.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/Library.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.core.internal.model.eclipse;
-
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
@@ -30,7 +29,6 @@
import org.apache.felix.sigil.common.model.osgi.IRequiredBundle;
import org.osgi.framework.Version;
-
public class Library extends AbstractCompoundModelElement implements ILibrary
{
@@ -41,70 +39,59 @@
private Set<IRequiredBundle> bundles;
private Set<IPackageImport> imports;
-
public Library()
{
- super( "Library" );
+ super("Library");
bundles = new HashSet<IRequiredBundle>();
imports = new HashSet<IPackageImport>();
}
-
- public void addBundle( IRequiredBundle bundle )
+ public void addBundle(IRequiredBundle bundle)
{
- bundles.add( bundle );
+ bundles.add(bundle);
}
-
- public void addImport( IPackageImport pi )
+ public void addImport(IPackageImport pi)
{
- imports.add( pi );
+ imports.add(pi);
}
-
public Collection<IRequiredBundle> getBundles()
{
return bundles;
}
-
public Collection<IPackageImport> getImports()
{
return imports;
}
-
public String getName()
{
return name;
}
-
public Version getVersion()
{
return version;
}
-
- public void removeBundle( IRequiredBundle bundle )
+ public void removeBundle(IRequiredBundle bundle)
{
- bundles.remove( bundle );
+ bundles.remove(bundle);
}
-
- public void removeImport( IPackageImport pi )
+ public void removeImport(IPackageImport pi)
{
- imports.remove( pi );
+ imports.remove(pi);
}
-
- public void setName( String name )
+ public void setName(String name)
{
this.name = name;
}
-
- public void setVersion( Version version )
+ public void setVersion(Version version)
{
this.version = version;
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/LibraryImport.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/LibraryImport.java
index f362a2d..9f2e863 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/LibraryImport.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/LibraryImport.java
@@ -19,46 +19,39 @@
package org.apache.felix.sigil.common.core.internal.model.eclipse;
-
import org.apache.felix.sigil.common.model.AbstractModelElement;
import org.apache.felix.sigil.common.model.eclipse.ILibraryImport;
import org.apache.felix.sigil.common.osgi.VersionRange;
-
public class LibraryImport extends AbstractModelElement implements ILibraryImport
{
private static final long serialVersionUID = 1L;
-
public LibraryImport()
{
- super( "Library Import" );
+ super("Library Import");
}
private String libraryName;
private VersionRange range = VersionRange.ANY_VERSION;
-
public String getLibraryName()
{
return libraryName;
}
-
public VersionRange getVersions()
{
return range;
}
-
- public void setLibraryName( String name )
+ public void setLibraryName(String name)
{
this.libraryName = name;
}
-
- public void setVersions( VersionRange range )
+ public void setVersions(VersionRange range)
{
this.range = range;
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/SigilBundle.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/SigilBundle.java
index 36fb461..98d1146 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/SigilBundle.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/eclipse/SigilBundle.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.core.internal.model.eclipse;
-
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
@@ -48,7 +47,6 @@
import org.eclipse.core.runtime.SubMonitor;
import org.osgi.framework.Version;
-
/**
* @author dave
*
@@ -70,106 +68,109 @@
public SigilBundle()
{
- super( "Sigil Bundle" );
+ super("Sigil Bundle");
sourcePaths = new Resource[0];
classpath = new String[0];
packages = new String[0];
}
-
- public void synchronize( IProgressMonitor monitor ) throws IOException
+ public void synchronize(IProgressMonitor monitor) throws IOException
{
- SubMonitor progress = SubMonitor.convert( monitor, 100 );
- progress.subTask( "Synchronizing " + bundle.getSymbolicName() + " binary" );
- sync( location, bundle.getUpdateLocation(), progress.newChild( 45 ) );
-
- if ( bundle.getSourceLocation() != null ) {
+ SubMonitor progress = SubMonitor.convert(monitor, 100);
+ progress.subTask("Synchronizing " + bundle.getSymbolicName() + " binary");
+ sync(location, bundle.getUpdateLocation(), progress.newChild(45));
+
+ if (bundle.getSourceLocation() != null)
+ {
try
{
- progress.subTask( "Synchronizing " + bundle.getSymbolicName() + " source" );
- sync( sourcePathLocation, bundle.getSourceLocation(), progress.newChild( 45 ) );
+ progress.subTask("Synchronizing " + bundle.getSymbolicName() + " source");
+ sync(sourcePathLocation, bundle.getSourceLocation(),
+ progress.newChild(45));
}
- catch ( IOException e )
+ catch (IOException e)
{
- BldCore.error( "Failed to download source for " + bundle.getSymbolicName() + " " + bundle.getVersion(), e
- .getCause() );
+ BldCore.error("Failed to download source for " + bundle.getSymbolicName()
+ + " " + bundle.getVersion(), e.getCause());
}
}
-
- if ( bundle.getLicenseURI() != null ) {
+
+ if (bundle.getLicenseURI() != null)
+ {
try
{
- progress.subTask( "Synchronizing " + bundle.getSymbolicName() + " licence" );
- sync( licencePathLocation, bundle.getLicenseURI(), progress.newChild( 10 ) );
+ progress.subTask("Synchronizing " + bundle.getSymbolicName() + " licence");
+ sync(licencePathLocation, bundle.getLicenseURI(), progress.newChild(10));
}
- catch ( IOException e )
+ catch (IOException e)
{
- BldCore.error( "Failed to download licence for " + bundle.getSymbolicName() + " " + bundle.getVersion(), e
- .getCause() );
+ BldCore.error("Failed to download licence for "
+ + bundle.getSymbolicName() + " " + bundle.getVersion(), e.getCause());
}
}
-
+
updateManifest(location);
}
-
private void updateManifest(File location) throws IOException
{
- if ( location != null ) {
+ if (location != null)
+ {
JarFile f = new JarFile(location);
- try {
+ try
+ {
setBundleInfo(ManifestUtil.buildBundleModelElement(f.getManifest()));
}
- finally {
+ finally
+ {
f.close();
}
}
}
-
public boolean isSynchronized()
{
return location == null || location.exists();
}
-
- private static void sync( File local, URI remote, IProgressMonitor monitor ) throws IOException
+ private static void sync(File local, URI remote, IProgressMonitor monitor)
+ throws IOException
{
try
{
- if ( remote != null )
+ if (remote != null)
{
- if ( local != null && !local.exists() )
+ if (local != null && !local.exists())
{
URL url = remote.toURL();
URLConnection connection = url.openConnection();
int contentLength = connection.getContentLength();
- monitor.beginTask( "Downloading from " + url.getHost(), contentLength );
+ monitor.beginTask("Downloading from " + url.getHost(), contentLength);
InputStream in = null;
OutputStream out = null;
try
{
URLConnection conn = url.openConnection();
- if ( conn instanceof HttpURLConnection )
+ if (conn instanceof HttpURLConnection)
{
- HttpURLConnection http = ( HttpURLConnection ) conn;
- http.setConnectTimeout( 10000 );
- http.setReadTimeout( 5000 );
+ HttpURLConnection http = (HttpURLConnection) conn;
+ http.setConnectTimeout(10000);
+ http.setReadTimeout(5000);
}
in = conn.getInputStream();
local.getParentFile().mkdirs();
- out = new FileOutputStream( local );
- stream( in, out, monitor );
+ out = new FileOutputStream(local);
+ stream(in, out, monitor);
}
finally
{
- if ( in != null )
+ if (in != null)
{
in.close();
}
- if ( out != null )
+ if (out != null)
{
out.close();
}
@@ -178,152 +179,137 @@
}
}
}
- catch ( IOException e )
+ catch (IOException e)
{
local.delete();
throw e;
}
}
-
- private static void stream( InputStream in, OutputStream out, IProgressMonitor monitor ) throws IOException
+ private static void stream(InputStream in, OutputStream out, IProgressMonitor monitor)
+ throws IOException
{
byte[] b = new byte[1024];
- for ( ;; )
+ for (;;)
{
- if ( monitor.isCanceled() )
+ if (monitor.isCanceled())
{
- throw new InterruptedIOException( "User canceled download" );
+ throw new InterruptedIOException("User canceled download");
}
- int r = in.read( b );
- if ( r == -1 )
+ int r = in.read(b);
+ if (r == -1)
break;
- out.write( b, 0, r );
- monitor.worked( r );
+ out.write(b, 0, r);
+ monitor.worked(r);
}
out.flush();
}
-
public IBundleModelElement getBundleInfo()
{
return bundle;
}
-
- public void setBundleInfo( IBundleModelElement bundle )
+ public void setBundleInfo(IBundleModelElement bundle)
{
- if ( bundle == null )
+ if (bundle == null)
{
- if ( this.bundle != null )
+ if (this.bundle != null)
{
- this.bundle.setParent( null );
+ this.bundle.setParent(null);
}
}
else
{
- bundle.setParent( this );
+ bundle.setParent(this);
}
this.bundle = bundle;
}
-
- public void addSourcePath( Resource path )
+ public void addSourcePath(Resource path)
{
ArrayList<Resource> tmp = new ArrayList<Resource>(getSourcePaths());
tmp.add(path);
- sourcePaths = tmp.toArray( new Resource[tmp.size()] );
+ sourcePaths = tmp.toArray(new Resource[tmp.size()]);
}
-
- public void removeSourcePath( Resource path )
+ public void removeSourcePath(Resource path)
{
ArrayList<Resource> tmp = new ArrayList<Resource>(getSourcePaths());
- if ( tmp.remove(path) ) {
- sourcePaths = tmp.toArray( new Resource[tmp.size()] );
+ if (tmp.remove(path))
+ {
+ sourcePaths = tmp.toArray(new Resource[tmp.size()]);
}
}
-
public Collection<Resource> getSourcePaths()
{
return Arrays.asList(sourcePaths);
}
-
public void clearSourcePaths()
{
sourcePaths = new Resource[0];
}
-
- public void addClasspathEntry( String encodedClasspath )
+ public void addClasspathEntry(String encodedClasspath)
{
ArrayList<String> tmp = new ArrayList<String>(getClasspathEntrys());
tmp.add(encodedClasspath.trim());
- classpath = tmp.toArray( new String[tmp.size()] );
+ classpath = tmp.toArray(new String[tmp.size()]);
}
-
public Collection<String> getClasspathEntrys()
{
return Arrays.asList(classpath);
}
-
- public void removeClasspathEntry( String encodedClasspath )
+ public void removeClasspathEntry(String encodedClasspath)
{
ArrayList<String> tmp = new ArrayList<String>(getClasspathEntrys());
- if ( tmp.remove( encodedClasspath.trim() ) ) {
- classpath = tmp.toArray( new String[tmp.size()] );
+ if (tmp.remove(encodedClasspath.trim()))
+ {
+ classpath = tmp.toArray(new String[tmp.size()]);
}
}
-
public File getLocation()
{
return location;
}
-
- public void setLocation( File location )
+ public void setLocation(File location)
{
this.location = location;
}
-
public File getSourcePathLocation()
{
return sourcePathLocation;
}
-
- public void setSourcePathLocation( File location )
+ public void setSourcePathLocation(File location)
{
this.sourcePathLocation = location;
}
-
public String getSourceRootPath()
{
return sourceRootPath;
}
-
- public void setSourceRootPath( String location )
+ public void setSourceRootPath(String location)
{
this.sourceRootPath = location;
}
-
public File getLicencePathLocation()
{
return licencePathLocation;
}
-
- public void setLicencePathLocation( File licencePathLocation )
+ public void setLicencePathLocation(File licencePathLocation)
{
this.licencePathLocation = licencePathLocation;
}
@@ -333,57 +319,52 @@
return bundle.getSymbolicName();
}
-
public Version getVersion()
{
return bundle.getVersion();
}
-
- public void setVersion( Version version )
+ public void setVersion(Version version)
{
- this.bundle.setVersion( version );
+ this.bundle.setVersion(version);
}
-
public String getSymbolicName()
{
return bundle.getSymbolicName();
}
-
public Collection<String> getPackages()
{
return Arrays.asList(packages);
}
-
- public void addPackage( String pkg )
+ public void addPackage(String pkg)
{
ArrayList<String> tmp = new ArrayList<String>(getClasspathEntrys());
tmp.add(pkg);
- packages = tmp.toArray( new String[tmp.size()] );
+ packages = tmp.toArray(new String[tmp.size()]);
}
-
- public boolean removePackage( String pkg )
+ public boolean removePackage(String pkg)
{
ArrayList<String> tmp = new ArrayList<String>(getClasspathEntrys());
- if ( tmp.remove(pkg) ) {
- packages = tmp.toArray( new String[tmp.size()] );
+ if (tmp.remove(pkg))
+ {
+ packages = tmp.toArray(new String[tmp.size()]);
return true;
}
- else {
+ else
+ {
return false;
}
}
-
- public IPackageExport findExport( String packageName )
+ public IPackageExport findExport(String packageName)
{
- for ( IPackageExport e : bundle.getExports() )
+ for (IPackageExport e : bundle.getExports())
{
- if ( packageName.equals( e.getPackageName() ) )
+ if (packageName.equals(e.getPackageName()))
{
return e;
}
@@ -391,45 +372,43 @@
return null;
}
-
- public IPackageImport findImport( String packageName )
+ public IPackageImport findImport(String packageName)
{
- for ( IPackageImport i : bundle.getImports() )
+ for (IPackageImport i : bundle.getImports())
{
- if ( packageName.equals( i.getPackageName() ) )
+ if (packageName.equals(i.getPackageName()))
{
return i;
}
}
return null;
}
-
+
@Override
public String toString()
{
return "SigilBundle["
- + ( getBundleInfo() == null ? null : ( getBundleInfo().getSymbolicName() + ":" + getBundleInfo()
- .getVersion() ) ) + "]";
+ + (getBundleInfo() == null ? null
+ : (getBundleInfo().getSymbolicName() + ":" + getBundleInfo().getVersion()))
+ + "]";
}
-
@Override
- public boolean equals( Object obj )
+ public boolean equals(Object obj)
{
- if ( obj == null )
+ if (obj == null)
return false;
- if ( obj == this )
+ if (obj == this)
return true;
- if ( obj instanceof SigilBundle )
+ if (obj instanceof SigilBundle)
{
- return obj.toString().equals( toString() );
+ return obj.toString().equals(toString());
}
return false;
}
-
@Override
public int hashCode()
{
@@ -441,15 +420,15 @@
{
SigilBundle b = (SigilBundle) super.clone();
b.bundle = (IBundleModelElement) b.bundle.clone();
-
+
Resource[] newPaths = new Resource[b.sourcePaths.length];
System.arraycopy(b.sourcePaths, 0, newPaths, 0, b.sourcePaths.length);
b.sourcePaths = newPaths;
-
+
String[] tmp = new String[classpath.length];
System.arraycopy(b.classpath, 0, tmp, 0, b.classpath.length);
b.classpath = tmp;
-
+
tmp = new String[packages.length];
System.arraycopy(b.packages, 0, tmp, 0, b.packages.length);
b.packages = tmp;
@@ -457,9 +436,8 @@
return b;
}
-
public IBundleCapability getBundleCapability()
{
return new BundleCapability(bundle);
- }
+ }
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/BundleModelElement.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/BundleModelElement.java
index c3febc7..de31c2d 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/BundleModelElement.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/BundleModelElement.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.core.internal.model.osgi;
-
import java.net.URI;
import java.util.Arrays;
import java.util.Collection;
@@ -36,7 +35,6 @@
import org.apache.felix.sigil.common.model.osgi.IRequiredBundle;
import org.osgi.framework.Version;
-
public class BundleModelElement extends AbstractCompoundModelElement implements IBundleModelElement
{
/**
@@ -68,10 +66,9 @@
private String activator;
private Set<ILibraryImport> libraries;
-
public BundleModelElement()
{
- super( "OSGi Bundle" );
+ super("OSGi Bundle");
this.imports = new IPackageImport[0];
this.exports = new IPackageExport[0];
this.requires = new IRequiredBundle[0];
@@ -79,337 +76,301 @@
this.libraries = new HashSet<ILibraryImport>();
}
-
public String getActivator()
{
return activator;
}
-
- public void setActivator( String activator )
+ public void setActivator(String activator)
{
this.activator = activator;
}
-
- public void addLibraryImport( ILibraryImport library )
+ public void addLibraryImport(ILibraryImport library)
{
- libraries.add( library );
+ libraries.add(library);
}
-
public Set<ILibraryImport> getLibraryImports()
{
return libraries;
}
-
- public void removeLibraryImport( ILibraryImport library )
+ public void removeLibraryImport(ILibraryImport library)
{
- libraries.remove( library );
+ libraries.remove(library);
}
-
public String getCategory()
{
return category;
}
-
- public void setCategory( String category )
+ public void setCategory(String category)
{
this.category = category;
}
-
public String getContactAddress()
{
return contactAddress;
}
-
- public void setContactAddress( String contactAddress )
+ public void setContactAddress(String contactAddress)
{
this.contactAddress = contactAddress;
}
-
public String getCopyright()
{
return copyright;
}
-
- public void setCopyright( String copyright )
+ public void setCopyright(String copyright)
{
this.copyright = copyright;
}
-
public URI getDocURI()
{
return docURI;
}
-
- public void setDocURI( URI docURI )
+ public void setDocURI(URI docURI)
{
this.docURI = docURI;
}
-
public Collection<IPackageExport> getExports()
{
return Arrays.asList(exports);
}
-
- public void addExport( IPackageExport packageExport )
+ public void addExport(IPackageExport packageExport)
{
HashSet<IPackageExport> tmp = new HashSet<IPackageExport>(getExports());
- if ( tmp.add(packageExport) ) {
- exports = tmp.toArray( new IPackageExport[tmp.size()] );
- packageExport.setParent( this );
+ if (tmp.add(packageExport))
+ {
+ exports = tmp.toArray(new IPackageExport[tmp.size()]);
+ packageExport.setParent(this);
}
}
- public void removeExport( IPackageExport packageExport )
+ public void removeExport(IPackageExport packageExport)
{
HashSet<IPackageExport> tmp = new HashSet<IPackageExport>(getExports());
- if ( tmp.remove(packageExport) ) {
- exports = tmp.toArray( new IPackageExport[tmp.size()] );
- packageExport.setParent( null );
+ if (tmp.remove(packageExport))
+ {
+ exports = tmp.toArray(new IPackageExport[tmp.size()]);
+ packageExport.setParent(null);
}
}
-
public Collection<IPackageImport> getImports()
{
return Arrays.asList(imports);
}
-
- public void addImport( IPackageImport packageImport )
+ public void addImport(IPackageImport packageImport)
{
HashSet<IPackageImport> tmp = new HashSet<IPackageImport>(getImports());
- if ( tmp.add(packageImport) ) {
- imports = tmp.toArray( new IPackageImport[tmp.size()] );
- packageImport.setParent( this );
+ if (tmp.add(packageImport))
+ {
+ imports = tmp.toArray(new IPackageImport[tmp.size()]);
+ packageImport.setParent(this);
}
}
-
- public void removeImport( IPackageImport packageImport )
+ public void removeImport(IPackageImport packageImport)
{
HashSet<IPackageImport> tmp = new HashSet<IPackageImport>(getImports());
- if ( tmp.remove(packageImport) ) {
- imports = tmp.toArray( new IPackageImport[tmp.size()] );
- packageImport.setParent( null );
+ if (tmp.remove(packageImport))
+ {
+ imports = tmp.toArray(new IPackageImport[tmp.size()]);
+ packageImport.setParent(null);
}
}
-
public Collection<IRequiredBundle> getRequiredBundles()
{
return Arrays.asList(requires);
}
-
- public void addRequiredBundle( IRequiredBundle bundle )
+ public void addRequiredBundle(IRequiredBundle bundle)
{
HashSet<IRequiredBundle> tmp = new HashSet<IRequiredBundle>(getRequiredBundles());
- if ( tmp.add(bundle) ) {
- requires = tmp.toArray( new IRequiredBundle[tmp.size()] );
- bundle.setParent( this );
+ if (tmp.add(bundle))
+ {
+ requires = tmp.toArray(new IRequiredBundle[tmp.size()]);
+ bundle.setParent(this);
}
}
-
- public void removeRequiredBundle( IRequiredBundle bundle )
+ public void removeRequiredBundle(IRequiredBundle bundle)
{
HashSet<IRequiredBundle> tmp = new HashSet<IRequiredBundle>(getRequiredBundles());
- if ( tmp.remove(bundle) ) {
- requires = tmp.toArray( new IRequiredBundle[tmp.size()] );
- bundle.setParent( null );
+ if (tmp.remove(bundle))
+ {
+ requires = tmp.toArray(new IRequiredBundle[tmp.size()]);
+ bundle.setParent(null);
}
}
-
public URI getLicenseURI()
{
return licenseURI;
}
-
- public void setLicenseURI( URI licenseURI )
+ public void setLicenseURI(URI licenseURI)
{
this.licenseURI = licenseURI;
}
-
public URI getSourceLocation()
{
return sourceLocation;
}
-
- public void setSourceLocation( URI sourceLocation )
+ public void setSourceLocation(URI sourceLocation)
{
this.sourceLocation = sourceLocation;
}
-
public String getSymbolicName()
{
return symbolicName;
}
-
- public void setSymbolicName( String symbolicName )
+ public void setSymbolicName(String symbolicName)
{
this.symbolicName = symbolicName == null ? null : symbolicName.intern();
}
-
public URI getUpdateLocation()
{
return updateLocation;
}
-
- public void setUpdateLocation( URI updateLocation )
+ public void setUpdateLocation(URI updateLocation)
{
this.updateLocation = updateLocation;
}
-
public String getVendor()
{
return vendor;
}
-
- public void setVendor( String vendor )
+ public void setVendor(String vendor)
{
this.vendor = vendor;
}
-
public Version getVersion()
{
return version;
}
-
- public void setVersion( Version version )
+ public void setVersion(Version version)
{
this.version = version == null ? Version.emptyVersion : version;
}
-
public void checkValid() throws InvalidModelException
{
- if ( symbolicName == null )
- throw new InvalidModelException( this, "Bundle symbolic name not set" );
+ if (symbolicName == null)
+ throw new InvalidModelException(this, "Bundle symbolic name not set");
}
-
public BundleModelElement clone()
{
- BundleModelElement bd = ( BundleModelElement ) super.clone();
+ BundleModelElement bd = (BundleModelElement) super.clone();
bd.imports = new IPackageImport[imports.length];
bd.exports = new IPackageExport[exports.length];
bd.requires = new IRequiredBundle[requires.length];
- for ( int i = 0; i < imports.length; i++ )
+ for (int i = 0; i < imports.length; i++)
{
bd.imports[i] = (IPackageImport) imports[i].clone();
}
- for ( int i = 0; i < exports.length; i++ )
+ for (int i = 0; i < exports.length; i++)
{
- bd.exports[i] = ( IPackageExport ) exports[i].clone();
+ bd.exports[i] = (IPackageExport) exports[i].clone();
}
- for ( int i = 0; i < requires.length; i++ )
+ for (int i = 0; i < requires.length; i++)
{
- bd.requires[i] = ( IRequiredBundle ) requires[i].clone();
+ bd.requires[i] = (IRequiredBundle) requires[i].clone();
}
return bd;
}
-
public String toString()
{
StringBuffer buf = new StringBuffer();
- buf.append( "BundleModelElement[" );
- buf.append( symbolicName );
- buf.append( ", " );
- buf.append( version );
- buf.append( "]" );
+ buf.append("BundleModelElement[");
+ buf.append(symbolicName);
+ buf.append(", ");
+ buf.append(version);
+ buf.append("]");
return buf.toString();
}
-
public String getName()
{
return name;
}
-
- public void setName( String name )
+ public void setName(String name)
{
this.name = name;
}
-
public String getDescription()
{
return description;
}
-
- public void setDescription( String description )
+ public void setDescription(String description)
{
this.description = description;
}
-
- public void addClasspath( String path )
+ public void addClasspath(String path)
{
HashSet<String> tmp = new HashSet<String>(Arrays.asList(classpathElements));
- if ( tmp.add(path) ) {
- classpathElements = tmp.toArray( new String[tmp.size()] );
+ if (tmp.add(path))
+ {
+ classpathElements = tmp.toArray(new String[tmp.size()]);
}
}
-
public Collection<String> getClasspaths()
{
- return classpathElements.length == 0 ? Collections.singleton( "." ) : Arrays.asList(classpathElements);
+ return classpathElements.length == 0 ? Collections.singleton(".")
+ : Arrays.asList(classpathElements);
}
-
- public void removeClasspath( String path )
+ public void removeClasspath(String path)
{
HashSet<String> tmp = new HashSet<String>(Arrays.asList(classpathElements));
- if ( tmp.remove(path) ) {
- classpathElements = tmp.toArray( new String[tmp.size()] );
+ if (tmp.remove(path))
+ {
+ classpathElements = tmp.toArray(new String[tmp.size()]);
}
}
-
public IRequiredBundle getFragmentHost()
{
return fragmentHost;
}
-
- public void setFragmentHost( IRequiredBundle fragmentHost )
+ public void setFragmentHost(IRequiredBundle fragmentHost)
{
this.fragmentHost = fragmentHost;
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/PackageExport.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/PackageExport.java
index 8b70562..88efb5e 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/PackageExport.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/PackageExport.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.core.internal.model.osgi;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -29,7 +28,6 @@
import org.apache.felix.sigil.common.model.osgi.IPackageExport;
import org.osgi.framework.Version;
-
public class PackageExport extends AbstractModelElement implements IPackageExport
{
@@ -41,33 +39,30 @@
public PackageExport()
{
- super( "OSGi Package Export" );
+ super("OSGi Package Export");
}
-
public String getPackageName()
{
return name;
}
-
- public void setPackageName( String packageName )
+ public void setPackageName(String packageName)
{
this.name = packageName;
}
-
public Version getVersion()
{
Version result;
- if ( version != null )
+ if (version != null)
{
result = version;
}
else
{
- ISigilBundle owningBundle = getAncestor( ISigilBundle.class );
- if ( owningBundle == null )
+ ISigilBundle owningBundle = getAncestor(ISigilBundle.class);
+ if (owningBundle == null)
{
result = Version.emptyVersion;
}
@@ -79,73 +74,64 @@
return result;
}
-
public Version getRawVersion()
{
return version;
}
-
- public void setVersion( Version version )
+ public void setVersion(Version version)
{
this.version = version; // == null ? Version.emptyVersion : version;
}
-
- public void addUse( String use )
+ public void addUse(String use)
{
ArrayList<String> tmp = new ArrayList<String>(getUses());
tmp.add(use);
- uses = tmp.toArray( new String[tmp.size()] );
+ uses = tmp.toArray(new String[tmp.size()]);
}
-
public Collection<String> getUses()
{
return Arrays.asList(uses);
}
-
- public void removeUse( String use )
+ public void removeUse(String use)
{
ArrayList<String> tmp = new ArrayList<String>(getUses());
tmp.remove(use);
- uses = tmp.toArray( new String[tmp.size()] );
+ uses = tmp.toArray(new String[tmp.size()]);
}
-
@Override
public String toString()
{
return "PackageExport[" + name + ":" + version + ":uses=" + uses + "]";
}
-
- public void setUses( Collection<String> uses )
+ public void setUses(Collection<String> uses)
{
ArrayList<String> tmp = new ArrayList<String>(uses);
- this.uses = tmp.toArray( new String[tmp.size()] );
+ this.uses = tmp.toArray(new String[tmp.size()]);
}
-
- public int compareTo( IPackageExport o )
+ public int compareTo(IPackageExport o)
{
- int i = name.compareTo( o.getPackageName() );
+ int i = name.compareTo(o.getPackageName());
- if ( i == 0 )
+ if (i == 0)
{
- i = compareVersion( o.getVersion() );
+ i = compareVersion(o.getVersion());
}
return i;
}
-
- private int compareVersion( Version other )
+ private int compareVersion(Version other)
{
- if ( version == null )
+ if (version == null)
{
- if ( other == null )
+ if (other == null)
{
return 0;
}
@@ -156,44 +142,45 @@
}
else
{
- if ( other == null )
+ if (other == null)
{
return -1;
}
else
{
- return version.compareTo( other );
+ return version.compareTo(other);
}
}
}
-
@Override
public boolean equals(Object obj)
{
- if ( obj == this ) return true;
- if ( obj == null ) return false;
-
- if ( obj instanceof PackageExport )
+ if (obj == this)
+ return true;
+ if (obj == null)
+ return false;
+
+ if (obj instanceof PackageExport)
{
PackageExport e = (PackageExport) obj;
- return (name == null ? e.name == null : name.equals( e.name )) &&
- (version == null ? e.version == null : version.equals( e.version ));
+ return (name == null ? e.name == null : name.equals(e.name))
+ && (version == null ? e.version == null : version.equals(e.version));
}
- else
+ else
{
return false;
}
}
-
@Override
public int hashCode()
{
int hc = name.hashCode();
-
- if ( version != null ) hc *= version.hashCode();
-
+
+ if (version != null)
+ hc *= version.hashCode();
+
return hc;
}
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/PackageImport.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/PackageImport.java
index 5d988de..4d5ea93 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/PackageImport.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/PackageImport.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.core.internal.model.osgi;
-
import org.apache.felix.sigil.common.model.AbstractModelElement;
import org.apache.felix.sigil.common.model.ICapabilityModelElement;
import org.apache.felix.sigil.common.model.InvalidModelException;
@@ -27,7 +26,6 @@
import org.apache.felix.sigil.common.model.osgi.IPackageImport;
import org.apache.felix.sigil.common.osgi.VersionRange;
-
public class PackageImport extends AbstractModelElement implements IPackageImport
{
@@ -41,102 +39,90 @@
private boolean dependency = true;
private OSGiImport osgiImport = OSGiImport.AUTO;
-
public PackageImport()
{
- super( "OSGi Package Import" );
+ super("OSGi Package Import");
}
-
@Override
public void checkValid() throws InvalidModelException
{
- if ( name == null )
+ if (name == null)
{
- throw new InvalidModelException( this, "Package name must be set" );
+ throw new InvalidModelException(this, "Package name must be set");
}
}
-
public boolean isOptional()
{
return optional;
}
-
- public void setOptional( boolean optional )
+ public void setOptional(boolean optional)
{
this.optional = optional;
}
-
public boolean isDependency()
{
return dependency;
}
-
- public void setDependency( boolean dependency )
+ public void setDependency(boolean dependency)
{
this.dependency = dependency;
}
-
public OSGiImport getOSGiImport()
{
return osgiImport;
}
-
- public void setOSGiImport( OSGiImport osgiHeader )
+ public void setOSGiImport(OSGiImport osgiHeader)
{
this.osgiImport = osgiHeader;
}
-
public String getPackageName()
{
return name;
}
-
- public void setPackageName( String name )
+ public void setPackageName(String name)
{
this.name = name;
}
-
public VersionRange getVersions()
{
return versions;
}
-
- public void setVersions( VersionRange versions )
+ public void setVersions(VersionRange versions)
{
this.versions = versions == null ? VersionRange.ANY_VERSION : versions;
}
-
@Override
public String toString()
{
- return "Package-Import[" + name + ":" + versions + ":" + ( optional ? "optional" : "mandatory" ) + "]";
+ return "Package-Import[" + name + ":" + versions + ":"
+ + (optional ? "optional" : "mandatory") + "]";
}
-
@Override
- public boolean equals( Object obj )
+ public boolean equals(Object obj)
{
- if ( this == obj )
+ if (this == obj)
return true;
- if ( obj == null )
+ if (obj == null)
return false;
- if ( obj instanceof PackageImport )
+ if (obj instanceof PackageImport)
{
- PackageImport pi = ( PackageImport ) obj;
- return name.equals( pi.name ) && versions.equals( pi.versions ) && optional == pi.optional;
+ PackageImport pi = (PackageImport) obj;
+ return name.equals(pi.name) && versions.equals(pi.versions)
+ && optional == pi.optional;
}
else
{
@@ -144,13 +130,12 @@
}
}
-
@Override
public int hashCode()
{
int hc = name.hashCode() * versions.hashCode();
- if ( optional )
+ if (optional)
{
hc *= -1;
}
@@ -158,13 +143,12 @@
return hc;
}
-
- public boolean accepts( ICapabilityModelElement provider )
+ public boolean accepts(ICapabilityModelElement provider)
{
- if ( provider instanceof IPackageExport )
+ if (provider instanceof IPackageExport)
{
- IPackageExport pe = ( IPackageExport ) provider;
- return pe.getPackageName().equals( name ) && versions.contains( pe.getVersion() );
+ IPackageExport pe = (IPackageExport) provider;
+ return pe.getPackageName().equals(name) && versions.contains(pe.getVersion());
}
else
{
@@ -172,25 +156,23 @@
}
}
-
- public int compareTo( IPackageImport o )
+ public int compareTo(IPackageImport o)
{
- int i = name.compareTo( o.getPackageName() );
+ int i = name.compareTo(o.getPackageName());
- if ( i == 0 )
+ if (i == 0)
{
- i = compareVersion( o.getVersions() );
+ i = compareVersion(o.getVersions());
}
return i;
}
-
- private int compareVersion( VersionRange range )
+ private int compareVersion(VersionRange range)
{
- if ( versions == null )
+ if (versions == null)
{
- if ( range == null )
+ if (range == null)
{
return 0;
}
@@ -201,13 +183,13 @@
}
else
{
- if ( range == null )
+ if (range == null)
{
return -1;
}
else
{
- return versions.getCeiling().compareTo( range.getCeiling() );
+ return versions.getCeiling().compareTo(range.getCeiling());
}
}
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/RequiredBundle.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/RequiredBundle.java
index e64c284a..187e040 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/RequiredBundle.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/internal/model/osgi/RequiredBundle.java
@@ -19,14 +19,12 @@
package org.apache.felix.sigil.common.core.internal.model.osgi;
-
import org.apache.felix.sigil.common.model.AbstractModelElement;
import org.apache.felix.sigil.common.model.ICapabilityModelElement;
import org.apache.felix.sigil.common.model.eclipse.IBundleCapability;
import org.apache.felix.sigil.common.model.osgi.IRequiredBundle;
import org.apache.felix.sigil.common.osgi.VersionRange;
-
public class RequiredBundle extends AbstractModelElement implements IRequiredBundle
{
private static final long serialVersionUID = 1L;
@@ -35,68 +33,61 @@
private VersionRange versions = VersionRange.ANY_VERSION;
private boolean optional;
-
public RequiredBundle()
{
- super( "OSGi Bundle Requirement" );
+ super("OSGi Bundle Requirement");
}
-
public String getSymbolicName()
{
return symbolicName;
}
-
- public void setSymbolicName( String symbolicName )
+ public void setSymbolicName(String symbolicName)
{
this.symbolicName = symbolicName == null ? null : symbolicName.intern();
}
-
public VersionRange getVersions()
{
return versions;
}
-
- public void setVersions( VersionRange versions )
+ public void setVersions(VersionRange versions)
{
this.versions = versions == null ? VersionRange.ANY_VERSION : versions;
}
-
public boolean isOptional()
{
return optional;
}
-
- public void setOptional( boolean optional )
+ public void setOptional(boolean optional)
{
this.optional = optional;
}
-
@Override
public String toString()
{
- return "RequiredBundle[" + symbolicName + ":" + versions + ":" + ( optional ? "optional" : "mandatory" ) + "]";
+ return "RequiredBundle[" + symbolicName + ":" + versions + ":"
+ + (optional ? "optional" : "mandatory") + "]";
}
-
@Override
- public boolean equals( Object obj )
+ public boolean equals(Object obj)
{
- if ( this == obj )
+ if (this == obj)
return true;
- if ( obj == null )
+ if (obj == null)
return false;
- if ( obj instanceof RequiredBundle )
+ if (obj instanceof RequiredBundle)
{
- RequiredBundle rb = ( RequiredBundle ) obj;
- return symbolicName.equals( rb.symbolicName ) && versions.equals( rb.versions ) && optional == rb.optional;
+ RequiredBundle rb = (RequiredBundle) obj;
+ return symbolicName.equals(rb.symbolicName) && versions.equals(rb.versions)
+ && optional == rb.optional;
}
else
{
@@ -104,13 +95,12 @@
}
}
-
@Override
public int hashCode()
{
int hc = symbolicName.hashCode() * versions.hashCode();
- if ( optional )
+ if (optional)
{
hc *= -1;
}
@@ -118,13 +108,13 @@
return hc;
}
-
- public boolean accepts( ICapabilityModelElement provider )
+ public boolean accepts(ICapabilityModelElement provider)
{
- if ( provider instanceof IBundleCapability )
+ if (provider instanceof IBundleCapability)
{
- IBundleCapability bndl = ( IBundleCapability ) provider;
- return symbolicName.equals( bndl.getSymbolicName() ) && versions.contains( bndl.getVersion() );
+ IBundleCapability bndl = (IBundleCapability) provider;
+ return symbolicName.equals(bndl.getSymbolicName())
+ && versions.contains(bndl.getVersion());
}
else
{
@@ -132,25 +122,23 @@
}
}
-
- public int compareTo( IRequiredBundle o )
+ public int compareTo(IRequiredBundle o)
{
- int i = symbolicName.compareTo( o.getSymbolicName() );
+ int i = symbolicName.compareTo(o.getSymbolicName());
- if ( i == 0 )
+ if (i == 0)
{
- i = compareVersion( o.getVersions() );
+ i = compareVersion(o.getVersions());
}
return i;
}
-
- private int compareVersion( VersionRange range )
+ private int compareVersion(VersionRange range)
{
- if ( versions == null )
+ if (versions == null)
{
- if ( range == null )
+ if (range == null)
{
return 0;
}
@@ -161,13 +149,13 @@
}
else
{
- if ( range == null )
+ if (range == null)
{
return -1;
}
else
{
- return versions.getCeiling().compareTo( range.getCeiling() );
+ return versions.getCeiling().compareTo(range.getCeiling());
}
}
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/licence/ILicenseManager.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/licence/ILicenseManager.java
index cd615d4..ecc57a9 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/licence/ILicenseManager.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/licence/ILicenseManager.java
@@ -19,24 +19,18 @@
package org.apache.felix.sigil.common.core.licence;
-
import java.util.Set;
import java.util.regex.Pattern;
-
public interface ILicenseManager
{
- void addLicense( String name, Pattern pattern );
+ void addLicense(String name, Pattern pattern);
-
- void removeLicense( String name );
-
+ void removeLicense(String name);
Set<String> getLicenseNames();
-
- Pattern getLicensePattern( String name );
-
+ Pattern getLicensePattern(String name);
ILicensePolicy getDefaultPolicy();
//ILicensePolicy getPolicy(ISigilProjectModel project);
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/licence/ILicensePolicy.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/licence/ILicensePolicy.java
index ba2d931..eefef3c 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/licence/ILicensePolicy.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/licence/ILicensePolicy.java
@@ -19,21 +19,16 @@
package org.apache.felix.sigil.common.core.licence;
-
import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
import org.eclipse.core.runtime.IProgressMonitor;
-
public interface ILicensePolicy
{
- void addAllowed( String licenseName );
+ void addAllowed(String licenseName);
+ void removeAllowed(String licenseName);
- void removeAllowed( String licenseName );
+ boolean accept(ISigilBundle bundle);
-
- boolean accept( ISigilBundle bundle );
-
-
- void save( IProgressMonitor monitor );
+ void save(IProgressMonitor monitor);
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/BundleResolver.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/BundleResolver.java
index b8452ca..e75d258 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/BundleResolver.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/BundleResolver.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.core.repository;
-
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
@@ -55,7 +54,6 @@
import org.eclipse.core.runtime.SubMonitor;
import org.osgi.framework.Version;
-
public class BundleResolver implements IBundleResolver
{
@@ -63,36 +61,33 @@
{
private IModelElement requirement;
-
- public BundleOrderComparator( IModelElement requirement )
+ public BundleOrderComparator(IModelElement requirement)
{
this.requirement = requirement;
}
-
- public int compare( ISigilBundle o1, ISigilBundle o2 )
+ public int compare(ISigilBundle o1, ISigilBundle o2)
{
- int c = compareVersions( o1, o2 );
+ int c = compareVersions(o1, o2);
- if ( c == 0 )
+ if (c == 0)
{
- c = compareImports( o1, o2 );
+ c = compareImports(o1, o2);
}
return c;
}
-
- private int compareImports( ISigilBundle o1, ISigilBundle o2 )
+ private int compareImports(ISigilBundle o1, ISigilBundle o2)
{
int c1 = o1.getBundleInfo().getImports().size();
int c2 = o2.getBundleInfo().getImports().size();
- if ( c1 < c2 )
+ if (c1 < c2)
{
return -1;
}
- else if ( c2 > c1 )
+ else if (c2 > c1)
{
return 1;
}
@@ -102,25 +97,24 @@
}
}
-
- private int compareVersions( ISigilBundle o1, ISigilBundle o2 )
+ private int compareVersions(ISigilBundle o1, ISigilBundle o2)
{
Version v1 = null;
Version v2 = null;
- if ( requirement instanceof IPackageImport )
+ if (requirement instanceof IPackageImport)
{
- v1 = findExportVersion( ( IPackageImport ) requirement, o1 );
- v2 = findExportVersion( ( IPackageImport ) requirement, o2 );
+ v1 = findExportVersion((IPackageImport) requirement, o1);
+ v2 = findExportVersion((IPackageImport) requirement, o2);
}
- else if ( requirement instanceof IRequiredBundle )
+ else if (requirement instanceof IRequiredBundle)
{
v1 = o1.getBundleInfo().getVersion();
v2 = o1.getBundleInfo().getVersion();
}
- if ( v1 == null )
+ if (v1 == null)
{
- if ( v2 == null )
+ if (v2 == null)
{
return 0;
}
@@ -131,23 +125,22 @@
}
else
{
- if ( v2 == null )
+ if (v2 == null)
{
return -1;
}
else
{
- return v2.compareTo( v1 );
+ return v2.compareTo(v1);
}
}
}
-
- private Version findExportVersion( IPackageImport pi, ISigilBundle o1 )
+ private Version findExportVersion(IPackageImport pi, ISigilBundle o1)
{
- for ( IPackageExport pe : o1.getBundleInfo().getExports() )
+ for (IPackageExport pe : o1.getBundleInfo().getExports())
{
- if ( pi.getPackageName().equals( pi.getPackageName() ) )
+ if (pi.getPackageName().equals(pi.getPackageName()))
{
return pe.getVersion();
}
@@ -168,72 +161,64 @@
private final Set<IModelElement> parsed = new HashSet<IModelElement>();
private final LinkedList<IModelElement> requirements = new LinkedList<IModelElement>();
-
- public ResolutionContext( IModelElement root, ResolutionConfig config, IResolutionMonitor monitor )
+ public ResolutionContext(IModelElement root, ResolutionConfig config, IResolutionMonitor monitor)
{
this.root = root;
this.config = config;
this.monitor = monitor;
}
-
- public void enterModelElement( IModelElement element )
+ public void enterModelElement(IModelElement element)
{
- parsed.add( element );
+ parsed.add(element);
}
-
- public void exitModelElement( IModelElement element )
+ public void exitModelElement(IModelElement element)
{
- parsed.remove( element );
+ parsed.remove(element);
}
-
- public boolean isNewModelElement( IModelElement element )
+ public boolean isNewModelElement(IModelElement element)
{
- return !parsed.contains( element );
+ return !parsed.contains(element);
}
-
public boolean isValid()
{
return resolution.isSuccess();
}
-
- public void setValid( boolean valid )
+ public void setValid(boolean valid)
{
- resolution.setSuccess( valid );
+ resolution.setSuccess(valid);
}
-
public ResolutionException newResolutionException()
{
- return new ResolutionException( root, requirements.toArray( new IModelElement[requirements.size()] ) );
+ return new ResolutionException(root,
+ requirements.toArray(new IModelElement[requirements.size()]));
}
-
- public void startRequirement( IRequirementModelElement element )
+ public void startRequirement(IRequirementModelElement element)
{
- requirements.add( element );
- monitor.startResolution( element );
+ requirements.add(element);
+ monitor.startResolution(element);
}
-
- public void endRequirement( IRequirementModelElement element )
+ public void endRequirement(IRequirementModelElement element)
{
- ISigilBundle provider = resolution.getProvider( element );
+ ISigilBundle provider = resolution.getProvider(element);
- setValid( provider != null || element.isOptional() || config.isIgnoreErrors() );
+ setValid(provider != null || element.isOptional() || config.isIgnoreErrors());
- if ( isValid() )
+ if (isValid())
{
// only clear stack if valid
// else use it as an aid to trace errors
- requirements.remove( element );
+ requirements.remove(element);
}
- monitor.endResolution( element, provider );
+ monitor.endResolution(element, provider);
}
}
@@ -243,74 +228,66 @@
private Map<IModelElement, ISigilBundle> providers = new HashMap<IModelElement, ISigilBundle>();
private boolean success = true; // assume success
-
- boolean addProvider( IModelElement element, ISigilBundle provider )
+ boolean addProvider(IModelElement element, ISigilBundle provider)
{
- providers.put( element, provider );
+ providers.put(element, provider);
- List<IModelElement> requirements = providees.get( provider );
+ List<IModelElement> requirements = providees.get(provider);
boolean isNewProvider = requirements == null;
- if ( isNewProvider )
+ if (isNewProvider)
{
requirements = new ArrayList<IModelElement>();
- providees.put( provider, requirements );
+ providees.put(provider, requirements);
}
- requirements.add( element );
+ requirements.add(element);
return isNewProvider;
}
-
- void removeProvider( IModelElement element, ISigilBundle provider )
+ void removeProvider(IModelElement element, ISigilBundle provider)
{
- providers.remove( element );
- List<IModelElement> e = providees.get( provider );
- e.remove( element );
- if ( e.isEmpty() )
+ providers.remove(element);
+ List<IModelElement> e = providees.get(provider);
+ e.remove(element);
+ if (e.isEmpty())
{
- providees.remove( provider );
+ providees.remove(provider);
}
}
-
- void setSuccess( boolean success )
+ void setSuccess(boolean success)
{
this.success = success;
}
-
public boolean isSuccess()
{
return success;
}
-
- public ISigilBundle getProvider( IModelElement requirement )
+ public ISigilBundle getProvider(IModelElement requirement)
{
- return providers.get( requirement );
+ return providers.get(requirement);
}
-
public Set<ISigilBundle> getBundles()
{
return providees.keySet();
}
-
- public List<IModelElement> getMatchedRequirements( ISigilBundle bundle )
+ public List<IModelElement> getMatchedRequirements(ISigilBundle bundle)
{
- return providees.get( bundle );
+ return providees.get(bundle);
}
-
public boolean isSynchronized()
{
- for ( ISigilBundle b : getBundles() )
+ for (ISigilBundle b : getBundles())
{
- if ( !b.isSynchronized() )
+ if (!b.isSynchronized())
{
return false;
}
@@ -319,26 +296,25 @@
return true;
}
-
- public void synchronize( IProgressMonitor monitor )
+ public void synchronize(IProgressMonitor monitor)
{
Set<ISigilBundle> bundles = getBundles();
- SubMonitor progress = SubMonitor.convert( monitor, bundles.size() );
+ SubMonitor progress = SubMonitor.convert(monitor, bundles.size());
- for ( ISigilBundle b : bundles )
+ for (ISigilBundle b : bundles)
{
- if ( monitor.isCanceled() )
+ if (monitor.isCanceled())
{
break;
}
try
{
- b.synchronize( progress.newChild( 1 ) );
+ b.synchronize(progress.newChild(1));
}
- catch ( IOException e )
+ catch (IOException e)
{
- BldCore.error( "Failed to synchronize " + b, e );
+ BldCore.error("Failed to synchronize " + b, e);
}
}
}
@@ -346,18 +322,16 @@
private static final IResolutionMonitor NULL_MONITOR = new IResolutionMonitor()
{
- public void endResolution( IModelElement requirement, ISigilBundle sigilBundle )
+ public void endResolution(IModelElement requirement, ISigilBundle sigilBundle)
{
}
-
public boolean isCanceled()
{
return false;
}
-
- public void startResolution( IModelElement requirement )
+ public void startResolution(IModelElement requirement)
{
}
};
@@ -366,20 +340,26 @@
{
public int compare(IRequirementModelElement o1, IRequirementModelElement o2)
{
- if ( o1 instanceof IPackageImport ) {
- if (o2 instanceof IPackageImport ) {
+ if (o1 instanceof IPackageImport)
+ {
+ if (o2 instanceof IPackageImport)
+ {
return 0;
}
- else {
+ else
+ {
return -1;
}
}
- else // assumes only alternative is IRequiredBundle
+ else
+ // assumes only alternative is IRequiredBundle
{
- if ( o2 instanceof IRequiredBundle) {
+ if (o2 instanceof IRequiredBundle)
+ {
return 0;
}
- else {
+ else
+ {
return 1;
}
}
@@ -388,25 +368,23 @@
private IRepositoryManager repositoryManager;
-
- public BundleResolver( IRepositoryManager repositoryManager )
+ public BundleResolver(IRepositoryManager repositoryManager)
{
this.repositoryManager = repositoryManager;
}
-
- public IResolution resolve( IModelElement element, ResolutionConfig config, IResolutionMonitor monitor )
- throws ResolutionException
+ public IResolution resolve(IModelElement element, ResolutionConfig config,
+ IResolutionMonitor monitor) throws ResolutionException
{
- if ( monitor == null )
+ if (monitor == null)
{
monitor = NULL_MONITOR;
}
- ResolutionContext ctx = new ResolutionContext( element, config, monitor );
+ ResolutionContext ctx = new ResolutionContext(element, config, monitor);
- resolveElement( element, ctx );
+ resolveElement(element, ctx);
- if ( !ctx.isValid() )
+ if (!ctx.isValid())
{
throw ctx.newResolutionException();
}
@@ -414,22 +392,25 @@
return ctx.resolution;
}
- private void resolveElement( IModelElement element, ResolutionContext ctx ) throws ResolutionException
+ private void resolveElement(IModelElement element, ResolutionContext ctx)
+ throws ResolutionException
{
- if ( ctx.isValid() ) {
- for (IRequirementModelElement req : findRequirements(element, ctx)) {
- if ( ctx.monitor.isCanceled())
+ if (ctx.isValid())
+ {
+ for (IRequirementModelElement req : findRequirements(element, ctx))
+ {
+ if (ctx.monitor.isCanceled())
break;
resolveRequirement(req, ctx);
}
}
}
-
+
private List<IRequirementModelElement> findRequirements(IModelElement element,
final ResolutionContext ctx)
{
final LinkedList<IRequirementModelElement> reqs = new LinkedList<IRequirementModelElement>();
-
+
if (element instanceof IRequirementModelElement)
{
reqs.add((IRequirementModelElement) element);
@@ -445,102 +426,106 @@
{
reqs.add((IRequirementModelElement) element);
}
- else if ( element instanceof ILibrary ) {
- ILibrary lib = repositoryManager.resolveLibrary( ( ILibraryImport ) element );
- reqs.addAll( lib.getImports() );
+ else if (element instanceof ILibrary)
+ {
+ ILibrary lib = repositoryManager.resolveLibrary((ILibraryImport) element);
+ reqs.addAll(lib.getImports());
}
-
+
return !ctx.monitor.isCanceled();
}
});
}
- if ( !ctx.monitor.isCanceled() ) {
+ if (!ctx.monitor.isCanceled())
+ {
Collections.sort(reqs, REQUIREMENT_COMPARATOR);
- }
+ }
return reqs;
}
- private void resolveRequirement( IRequirementModelElement requirement, ResolutionContext ctx ) throws ResolutionException
+ private void resolveRequirement(IRequirementModelElement requirement,
+ ResolutionContext ctx) throws ResolutionException
{
- if ( ctx.config.isOptional() || !requirement.isOptional() )
+ if (ctx.config.isOptional() || !requirement.isOptional())
{
- ctx.startRequirement( requirement );
+ ctx.startRequirement(requirement);
try
{
- if ( !findInContext( requirement, ctx ) )
+ if (!findInContext(requirement, ctx))
{
- findInRepositories( requirement, ctx );
+ findInRepositories(requirement, ctx);
}
}
finally
{
- ctx.endRequirement( requirement );
+ ctx.endRequirement(requirement);
}
}
}
-
private boolean findInContext(final IRequirementModelElement requirement,
final ResolutionContext ctx)
{
- for ( final ISigilBundle b : ctx.resolution.providees.keySet() )
+ for (final ISigilBundle b : ctx.resolution.providees.keySet())
{
- b.visit( new IModelWalker()
+ b.visit(new IModelWalker()
{
public boolean visit(IModelElement element)
{
- if ( element instanceof ICapabilityModelElement ) {
- if ( requirement.accepts((ICapabilityModelElement) element) ) {
- ctx.resolution.addProvider( requirement, b );
+ if (element instanceof ICapabilityModelElement)
+ {
+ if (requirement.accepts((ICapabilityModelElement) element))
+ {
+ ctx.resolution.addProvider(requirement, b);
return false;
}
}
return !ctx.monitor.isCanceled();
}
-
+
});
}
-
+
return ctx.resolution.getProvider(requirement) != null;
}
-
private void findInRepositories(IRequirementModelElement requirement,
ResolutionContext ctx) throws ResolutionException
{
int[] priorities = repositoryManager.getPriorityLevels();
- outer: for ( int i = 0; i < priorities.length; i++ )
+ outer: for (int i = 0; i < priorities.length; i++)
{
- List<ISigilBundle> providers = findProvidersAtPriority( priorities[i], requirement, ctx );
+ List<ISigilBundle> providers = findProvidersAtPriority(priorities[i],
+ requirement, ctx);
- if ( !providers.isEmpty() && !ctx.monitor.isCanceled() )
+ if (!providers.isEmpty() && !ctx.monitor.isCanceled())
{
- if ( providers.size() > 1 )
+ if (providers.size() > 1)
{
- Collections.sort( providers, new BundleOrderComparator( requirement ) );
+ Collections.sort(providers, new BundleOrderComparator(requirement));
}
- for ( ISigilBundle provider : providers )
+ for (ISigilBundle provider : providers)
{
// reset validity - if there's another provider it can still be solved
- ctx.setValid( true );
- if ( ctx.resolution.addProvider( requirement, provider ) )
+ ctx.setValid(true);
+ if (ctx.resolution.addProvider(requirement, provider))
{
- if ( ctx.config.isDependents() )
+ if (ctx.config.isDependents())
{
- resolveElement( provider, ctx );
+ resolveElement(provider, ctx);
}
- if ( ctx.isValid() )
+ if (ctx.isValid())
{
break outer;
}
else
{
- ctx.resolution.removeProvider( requirement, provider );
+ ctx.resolution.removeProvider(requirement, provider);
}
}
else
@@ -552,45 +537,44 @@
}
}
-
- private List<ISigilBundle> findProvidersAtPriority( int i, IRequirementModelElement requirement, ResolutionContext ctx )
+ private List<ISigilBundle> findProvidersAtPriority(int i,
+ IRequirementModelElement requirement, ResolutionContext ctx)
throws ResolutionException
{
ArrayList<ISigilBundle> providers = new ArrayList<ISigilBundle>();
- for ( IBundleRepository rep : repositoryManager.getRepositories( i ) )
+ for (IBundleRepository rep : repositoryManager.getRepositories(i))
{
- if ( ctx.monitor.isCanceled() )
+ if (ctx.monitor.isCanceled())
{
break;
}
- providers.addAll( findProviders( requirement, ctx.config, rep ) );
+ providers.addAll(findProviders(requirement, ctx.config, rep));
}
return providers;
}
-
- private Collection<ISigilBundle> findProviders( IRequirementModelElement requirement, ResolutionConfig config,
- IBundleRepository rep ) throws ResolutionException
+ private Collection<ISigilBundle> findProviders(IRequirementModelElement requirement,
+ ResolutionConfig config, IBundleRepository rep) throws ResolutionException
{
ArrayList<ISigilBundle> found = new ArrayList<ISigilBundle>();
- if ( requirement instanceof IPackageImport )
+ if (requirement instanceof IPackageImport)
{
- IPackageImport pi = ( IPackageImport ) requirement;
- found.addAll( rep.findAllProviders( pi, config.getOptions() ) );
+ IPackageImport pi = (IPackageImport) requirement;
+ found.addAll(rep.findAllProviders(pi, config.getOptions()));
}
- else if ( requirement instanceof IRequiredBundle )
+ else if (requirement instanceof IRequiredBundle)
{
- IRequiredBundle rb = ( IRequiredBundle ) requirement;
- found.addAll( rep.findAllProviders( rb, config.getOptions() ) );
+ IRequiredBundle rb = (IRequiredBundle) requirement;
+ found.addAll(rep.findAllProviders(rb, config.getOptions()));
}
else
{
// shouldn't get here - developer error if do
// use isRequirement before getting anywhere near this logic...
- throw new IllegalStateException( "Invalid requirement type " + requirement );
+ throw new IllegalStateException("Invalid requirement type " + requirement);
}
return found;
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/DirectoryHelper.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/DirectoryHelper.java
index 05b712e..4eaaea1 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/DirectoryHelper.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/DirectoryHelper.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.core.repository;
-
import java.io.File;
import java.io.IOException;
import java.util.List;
@@ -33,61 +32,61 @@
import org.apache.felix.sigil.common.model.osgi.IBundleModelElement;
import org.apache.felix.sigil.common.repository.AbstractBundleRepository;
-
public class DirectoryHelper
{
- public static void scanBundles( AbstractBundleRepository repository, List<ISigilBundle> bundles, File dir,
- File source, boolean recursive )
+ public static void scanBundles(AbstractBundleRepository repository,
+ List<ISigilBundle> bundles, File dir, File source, boolean recursive)
{
- if ( dir.exists() )
+ if (dir.exists())
{
- for ( File f : dir.listFiles() )
+ for (File f : dir.listFiles())
{
- if ( f.isDirectory() )
+ if (f.isDirectory())
{
- if ( recursive )
+ if (recursive)
{
- scanBundles( repository, bundles, f, source, recursive );
+ scanBundles(repository, bundles, f, source, recursive);
}
}
- else if ( f.isFile() && f.getName().endsWith( ".jar" ) )
+ else if (f.isFile() && f.getName().endsWith(".jar"))
{
JarFile jar = null;
try
{
- jar = new JarFile( f, false );
- ISigilBundle bundle = buildBundle( repository, jar.getManifest(), f );
- if ( bundle != null )
+ jar = new JarFile(f, false);
+ ISigilBundle bundle = buildBundle(repository, jar.getManifest(),
+ f);
+ if (bundle != null)
{
- bundle.setSourcePathLocation( source );
+ bundle.setSourcePathLocation(source);
// TODO shouldn't be hard coded
- bundle.setSourceRootPath( "src" );
- bundles.add( bundle );
+ bundle.setSourceRootPath("src");
+ bundles.add(bundle);
}
}
- catch ( IOException e )
+ catch (IOException e)
{
- BldCore.error( "Failed to read jar file " + f, e );
+ BldCore.error("Failed to read jar file " + f, e);
}
- catch ( ModelElementFactoryException e )
+ catch (ModelElementFactoryException e)
{
- BldCore.error( "Failed to build bundle " + f, e );
+ BldCore.error("Failed to build bundle " + f, e);
}
- catch ( RuntimeException e )
+ catch (RuntimeException e)
{
- BldCore.error( "Failed to build bundle " + f, e );
+ BldCore.error("Failed to build bundle " + f, e);
}
finally
{
- if ( jar != null )
+ if (jar != null)
{
try
{
jar.close();
}
- catch ( IOException e )
+ catch (IOException e)
{
- BldCore.error( "Failed to close jar file", e );
+ BldCore.error("Failed to close jar file", e);
}
}
}
@@ -96,18 +95,18 @@
}
}
-
- private static ISigilBundle buildBundle( AbstractBundleRepository repository, Manifest manifest, File f )
+ private static ISigilBundle buildBundle(AbstractBundleRepository repository,
+ Manifest manifest, File f)
{
- IBundleModelElement info = repository.buildBundleModelElement( manifest );
+ IBundleModelElement info = repository.buildBundleModelElement(manifest);
ISigilBundle bundle = null;
- if ( info != null )
+ if (info != null)
{
- bundle = ModelElementFactory.getInstance().newModelElement( ISigilBundle.class );
- bundle.addChild( info );
- bundle.setLocation( f );
+ bundle = ModelElementFactory.getInstance().newModelElement(ISigilBundle.class);
+ bundle.addChild(info);
+ bundle.setLocation(f);
}
return bundle;
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/FileSystemRepository.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/FileSystemRepository.java
index ef46fab..b20c32c 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/FileSystemRepository.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/FileSystemRepository.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.core.repository;
-
import java.io.File;
import java.util.ArrayList;
@@ -27,7 +26,6 @@
import org.apache.felix.sigil.common.repository.AbstractBundleRepository;
import org.apache.felix.sigil.common.repository.IRepositoryVisitor;
-
public class FileSystemRepository extends AbstractBundleRepository
{
@@ -35,40 +33,37 @@
private File dir;
private boolean recurse;
-
- public FileSystemRepository( String id, File dir, boolean recurse )
+ public FileSystemRepository(String id, File dir, boolean recurse)
{
- super( id );
+ super(id);
this.dir = dir;
this.recurse = recurse;
}
-
@Override
- public void accept( IRepositoryVisitor visitor, int options )
+ public void accept(IRepositoryVisitor visitor, int options)
{
- synchronized ( this )
+ synchronized (this)
{
- if ( bundles == null )
+ if (bundles == null)
{
bundles = new ArrayList<ISigilBundle>();
- DirectoryHelper.scanBundles( this, bundles, dir, null, recurse );
+ DirectoryHelper.scanBundles(this, bundles, dir, null, recurse);
}
}
- for ( ISigilBundle b : bundles )
+ for (ISigilBundle b : bundles)
{
- if ( !visitor.visit( b ) )
+ if (!visitor.visit(b))
{
break;
}
}
}
-
public void refresh()
{
- synchronized ( this )
+ synchronized (this)
{
bundles = null;
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/FileSystemRepositoryProvider.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/FileSystemRepositoryProvider.java
index d1c9227..0926558 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/FileSystemRepositoryProvider.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/FileSystemRepositoryProvider.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.core.repository;
-
import java.io.File;
import java.util.Properties;
@@ -27,20 +26,20 @@
import org.apache.felix.sigil.common.repository.IRepositoryProvider;
import org.apache.felix.sigil.common.repository.RepositoryException;
-
public class FileSystemRepositoryProvider implements IRepositoryProvider
{
- public IBundleRepository createRepository( String id, Properties preferences ) throws RepositoryException
+ public IBundleRepository createRepository(String id, Properties preferences)
+ throws RepositoryException
{
- String dirStr = preferences.getProperty( "dir" );
- File dir = new File( dirStr );
- if ( !dir.isDirectory() )
+ String dirStr = preferences.getProperty("dir");
+ File dir = new File(dirStr);
+ if (!dir.isDirectory())
{
- throw new RepositoryException( "directory '" + dir + "' does not exist." );
+ throw new RepositoryException("directory '" + dir + "' does not exist.");
}
- boolean recurse = Boolean.valueOf( preferences.getProperty( "recurse" ) );
- return new FileSystemRepository( id, dir, recurse );
+ boolean recurse = Boolean.valueOf(preferences.getProperty("recurse"));
+ return new FileSystemRepository(id, dir, recurse);
}
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/ProgressWrapper.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/ProgressWrapper.java
index 2cb307a..e1db339 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/ProgressWrapper.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/ProgressWrapper.java
@@ -19,72 +19,61 @@
package org.apache.felix.sigil.common.core.repository;
-
import org.eclipse.core.runtime.IProgressMonitor;
import org.apache.felix.sigil.common.repository.IResolutionMonitor;
-
public class ProgressWrapper implements IProgressMonitor
{
private IResolutionMonitor monitor;
-
- public ProgressWrapper( IResolutionMonitor monitor )
+ public ProgressWrapper(IResolutionMonitor monitor)
{
this.monitor = monitor;
}
-
public boolean isCanceled()
{
return monitor.isCanceled();
}
-
- public void beginTask( String name, int totalWork )
+ public void beginTask(String name, int totalWork)
{
// TODO Auto-generated method stub
}
-
public void done()
{
// TODO Auto-generated method stub
}
-
- public void internalWorked( double work )
+ public void internalWorked(double work)
{
// TODO Auto-generated method stub
}
-
- public void setCanceled( boolean value )
+ public void setCanceled(boolean value)
{
// TODO Auto-generated method stub
}
-
- public void setTaskName( String name )
+ public void setTaskName(String name)
{
// TODO Auto-generated method stub
}
-
- public void subTask( String name )
+ public void subTask(String name)
{
// TODO Auto-generated method stub
}
-
- public void worked( int work )
+ public void worked(int work)
{
// TODO Auto-generated method stub
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/SystemRepository.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/SystemRepository.java
index 00503f4..cfd0b77 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/SystemRepository.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/SystemRepository.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.core.repository;
-
import java.io.File;
import java.io.IOException;
import java.util.jar.JarFile;
@@ -33,87 +32,85 @@
import org.apache.felix.sigil.common.repository.AbstractBundleRepository;
import org.apache.felix.sigil.common.repository.IRepositoryVisitor;
-
public class SystemRepository extends AbstractBundleRepository
{
private final String packages;
private final File frameworkPath;
-
- public SystemRepository( String id, File frameworkPath, String packages )
+ public SystemRepository(String id, File frameworkPath, String packages)
{
- super( id );
+ super(id);
this.frameworkPath = frameworkPath;
this.packages = packages;
}
private static ISigilBundle systemBundle;
-
@Override
- public void accept( IRepositoryVisitor visitor, int options )
+ public void accept(IRepositoryVisitor visitor, int options)
{
ISigilBundle bundle = loadSystemBundle();
- if ( bundle != null )
+ if (bundle != null)
{
- visitor.visit( bundle );
+ visitor.visit(bundle);
}
}
-
private synchronized ISigilBundle loadSystemBundle()
{
- if ( systemBundle == null )
+ if (systemBundle == null)
{
- systemBundle = ModelElementFactory.getInstance().newModelElement( ISigilBundle.class );
+ systemBundle = ModelElementFactory.getInstance().newModelElement(
+ ISigilBundle.class);
JarFile jar = null;
try
{
final IBundleModelElement info;
- if ( frameworkPath != null )
+ if (frameworkPath != null)
{
- systemBundle.setLocation( frameworkPath );
+ systemBundle.setLocation(frameworkPath);
jar = new JarFile(frameworkPath);
- info = buildBundleModelElement( jar.getManifest() );
+ info = buildBundleModelElement(jar.getManifest());
}
else
{
- info = ModelElementFactory.getInstance().newModelElement( IBundleModelElement.class );
+ info = ModelElementFactory.getInstance().newModelElement(
+ IBundleModelElement.class);
}
info.setSymbolicName("system bundle");
info.setName("Sigil system bundle");
-
- applyProfile( info );
- systemBundle.addChild( info );
+
+ applyProfile(info);
+ systemBundle.addChild(info);
}
- catch ( IOException e )
+ catch (IOException e)
{
- BldCore.error( "Failed to read jar file " + frameworkPath, e );
+ BldCore.error("Failed to read jar file " + frameworkPath, e);
}
- catch ( ModelElementFactoryException e )
+ catch (ModelElementFactoryException e)
{
- BldCore.error( "Failed to build bundle " + frameworkPath, e );
+ BldCore.error("Failed to build bundle " + frameworkPath, e);
}
- catch ( RuntimeException e )
+ catch (RuntimeException e)
{
- BldCore.error( "Failed to build bundle " + frameworkPath, e );
+ BldCore.error("Failed to build bundle " + frameworkPath, e);
}
finally
{
- if ( jar != null )
+ if (jar != null)
{
try
{
jar.close();
}
- catch ( IOException e )
+ catch (IOException e)
{
- BldCore.error( "Failed to close jar file", e );
+ BldCore.error("Failed to close jar file", e);
}
}
}
@@ -122,21 +119,20 @@
return systemBundle;
}
-
- private void applyProfile( IBundleModelElement info )
+ private void applyProfile(IBundleModelElement info)
{
- if ( packages != null )
+ if (packages != null)
{
- for ( String name : packages.split( ",\\s*" ) )
+ for (String name : packages.split(",\\s*"))
{
- IPackageExport pe = ModelElementFactory.getInstance().newModelElement( IPackageExport.class );
- pe.setPackageName( name );
- info.addExport( pe );
+ IPackageExport pe = ModelElementFactory.getInstance().newModelElement(
+ IPackageExport.class);
+ pe.setPackageName(name);
+ info.addExport(pe);
}
}
}
-
public synchronized void refresh()
{
systemBundle = null;
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/SystemRepositoryProvider.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/SystemRepositoryProvider.java
index 47a72f3..0d19199 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/SystemRepositoryProvider.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/repository/SystemRepositoryProvider.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.core.repository;
-
import java.io.File;
import java.io.IOException;
@@ -33,44 +32,46 @@
public class SystemRepositoryProvider implements IRepositoryProvider
{
- public IBundleRepository createRepository( String id, Properties properties ) throws RepositoryException
+ public IBundleRepository createRepository(String id, Properties properties)
+ throws RepositoryException
{
- String fw = properties.getProperty( "framework" );
- File frameworkPath = fw == null ? null : new File( fw );
- String extraPkgs = properties.getProperty( "packages" );
- String profile = properties.getProperty( "profile" );
-
+ String fw = properties.getProperty("framework");
+ File frameworkPath = fw == null ? null : new File(fw);
+ String extraPkgs = properties.getProperty("packages");
+ String profile = properties.getProperty("profile");
+
try
{
- Properties p = readProfile( profile );
- String pkgs = p.getProperty( "org.osgi.framework.system.packages" ) + "," + extraPkgs;
- return new SystemRepository( id, frameworkPath, pkgs );
+ Properties p = readProfile(profile);
+ String pkgs = p.getProperty("org.osgi.framework.system.packages") + ","
+ + extraPkgs;
+ return new SystemRepository(id, frameworkPath, pkgs);
}
- catch ( IOException e )
+ catch (IOException e)
{
- throw new RepositoryException( "Failed to load profile", e );
+ throw new RepositoryException("Failed to load profile", e);
}
}
-
- public static Properties readProfile( String name ) throws IOException
+ public static Properties readProfile(String name) throws IOException
{
- if ( name == null )
+ if (name == null)
{
- String version = System.getProperty( "java.specification.version" );
- String[] split = version.split( "\\." );
- String prefix = ( "6".compareTo( split[1] ) <= 0 ) ? "JavaSE-" : "J2SE-";
+ String version = System.getProperty("java.specification.version");
+ String[] split = version.split("\\.");
+ String prefix = ("6".compareTo(split[1]) <= 0) ? "JavaSE-" : "J2SE-";
name = prefix + version;
}
String profilePath = "profiles/" + name + ".profile";
- InputStream in = SystemRepositoryProvider.class.getClassLoader().getResourceAsStream( profilePath );
+ InputStream in = SystemRepositoryProvider.class.getClassLoader().getResourceAsStream(
+ profilePath);
- if ( in == null )
- throw new IOException( "No such profile: " + profilePath );
+ if (in == null)
+ throw new IOException("No such profile: " + profilePath);
Properties p = new Properties();
- p.load( in );
+ p.load(in);
return p;
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/util/ManifestUtil.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/util/ManifestUtil.java
index d08388c..750c426 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/util/ManifestUtil.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/util/ManifestUtil.java
@@ -18,65 +18,66 @@
public class ManifestUtil
{
- public static IBundleModelElement buildBundleModelElement( Manifest mf )
+ public static IBundleModelElement buildBundleModelElement(Manifest mf)
{
IBundleModelElement info = null;
- if ( mf != null )
+ if (mf != null)
{
Attributes attrs = mf.getMainAttributes();
- String name = attrs.getValue( "Bundle-SymbolicName" );
- if ( name == null )
+ String name = attrs.getValue("Bundle-SymbolicName");
+ if (name == null)
{
// framework.jar doesn't have Bundle-SymbolicName!
- name = attrs.getValue( "Bundle-Name" );
+ name = attrs.getValue("Bundle-Name");
}
- if ( name != null )
+ if (name != null)
{
try
{
- info = ModelElementFactory.getInstance().newModelElement( IBundleModelElement.class );
- info.setSymbolicName( name.split( ";" )[0] );
- info.setVersion( VersionTable.getVersion( attrs.getValue( "Bundle-Version" ) ) );
- info.setName( attrs.getValue( "Bundle-Name" ) );
- info.setDescription( attrs.getValue( "Bundle-Description" ) );
- info.setVendor( attrs.getValue( "Bundle-Vendor" ) );
+ info = ModelElementFactory.getInstance().newModelElement(
+ IBundleModelElement.class);
+ info.setSymbolicName(name.split(";")[0]);
+ info.setVersion(VersionTable.getVersion(attrs.getValue("Bundle-Version")));
+ info.setName(attrs.getValue("Bundle-Name"));
+ info.setDescription(attrs.getValue("Bundle-Description"));
+ info.setVendor(attrs.getValue("Bundle-Vendor"));
- String str = attrs.getValue( "Import-Package" );
- if ( str != null )
+ String str = attrs.getValue("Import-Package");
+ if (str != null)
{
- addImports( info, str );
+ addImports(info, str);
}
- str = attrs.getValue( "Export-Package" );
- if ( str != null )
+ str = attrs.getValue("Export-Package");
+ if (str != null)
{
- addExports( info, str );
+ addExports(info, str);
}
- str = attrs.getValue( "Require-Bundle" );
- if ( str != null )
+ str = attrs.getValue("Require-Bundle");
+ if (str != null)
{
- addRequires( info, str );
+ addRequires(info, str);
}
- str = attrs.getValue( "Bundle-Classpath" );
+ str = attrs.getValue("Bundle-Classpath");
- if ( str != null )
+ if (str != null)
{
- addClasspath( info, str );
+ addClasspath(info, str);
}
- str = attrs.getValue( "Fragment-Host" );
- if ( str != null )
+ str = attrs.getValue("Fragment-Host");
+ if (str != null)
{
- addHost( info, str );
+ addHost(info, str);
}
}
- catch ( RuntimeException e )
+ catch (RuntimeException e)
{
- BldCore.error( "Failed to read info from bundle " + name, e );
+ BldCore.error("Failed to read info from bundle " + name, e);
// clear elements as clearly got garbage
info = null;
}
@@ -85,151 +86,152 @@
return info;
}
- private static void addClasspath( IBundleModelElement info, String cpStr )
+
+ private static void addClasspath(IBundleModelElement info, String cpStr)
{
- for ( String cp : cpStr.split( "\\s*,\\s*" ) )
+ for (String cp : cpStr.split("\\s*,\\s*"))
{
- info.addClasspath( cp );
+ info.addClasspath(cp);
}
}
-
- private static void addExports( IBundleModelElement info, String exportStr ) throws ModelElementFactoryException
+ private static void addExports(IBundleModelElement info, String exportStr)
+ throws ModelElementFactoryException
{
- for ( String exp : QuoteUtil.split( exportStr ) )
+ for (String exp : QuoteUtil.split(exportStr))
{
try
{
- String[] parts = exp.split( ";" );
- IPackageExport pe = ModelElementFactory.getInstance().newModelElement( IPackageExport.class );
- pe.setPackageName( parts[0].trim() );
+ String[] parts = exp.split(";");
+ IPackageExport pe = ModelElementFactory.getInstance().newModelElement(
+ IPackageExport.class);
+ pe.setPackageName(parts[0].trim());
- if ( parts.length > 1 )
+ if (parts.length > 1)
{
- for ( int i = 1; i < parts.length; i++ )
+ for (int i = 1; i < parts.length; i++)
{
String check = parts[i];
- if ( check.toLowerCase().startsWith( "version=" ) )
+ if (check.toLowerCase().startsWith("version="))
{
- pe.setVersion( parseVersion( check.substring( "version=".length() ) ) );
+ pe.setVersion(parseVersion(check.substring("version=".length())));
}
- else if ( check.toLowerCase().startsWith( "specification-version=" ) )
+ else if (check.toLowerCase().startsWith("specification-version="))
{
- pe.setVersion( parseVersion( check.substring( "specification-version=".length() ) ) );
+ pe.setVersion(parseVersion(check.substring("specification-version=".length())));
}
- else if ( check.toLowerCase().startsWith( "uses:=" ) )
+ else if (check.toLowerCase().startsWith("uses:="))
{
- for ( String use : parseUses( check.substring( "uses:=".length() ) ) )
+ for (String use : parseUses(check.substring("uses:=".length())))
{
- pe.addUse( use );
+ pe.addUse(use);
}
}
}
}
- info.addExport( pe );
+ info.addExport(pe);
}
- catch ( RuntimeException e )
+ catch (RuntimeException e)
{
e.printStackTrace();
}
}
}
-
- private static Collection<String> parseUses( String uses )
+ private static Collection<String> parseUses(String uses)
{
- if ( uses.startsWith( "\"" ) )
+ if (uses.startsWith("\""))
{
- uses = uses.substring( 1, uses.length() - 2 );
+ uses = uses.substring(1, uses.length() - 2);
}
- return Arrays.asList( uses.split( "," ) );
+ return Arrays.asList(uses.split(","));
}
-
- private static Version parseVersion( String val )
+ private static Version parseVersion(String val)
{
- val = val.replaceAll( "\"", "" );
- return VersionTable.getVersion( val );
+ val = val.replaceAll("\"", "");
+ return VersionTable.getVersion(val);
}
-
- private static void addImports( IBundleModelElement info, String importStr ) throws ModelElementFactoryException
+ private static void addImports(IBundleModelElement info, String importStr)
+ throws ModelElementFactoryException
{
- for ( String imp : QuoteUtil.split( importStr ) )
+ for (String imp : QuoteUtil.split(importStr))
{
- String[] parts = imp.split( ";" );
- IPackageImport pi = ModelElementFactory.getInstance().newModelElement( IPackageImport.class );
- pi.setPackageName( parts[0].trim() );
+ String[] parts = imp.split(";");
+ IPackageImport pi = ModelElementFactory.getInstance().newModelElement(
+ IPackageImport.class);
+ pi.setPackageName(parts[0].trim());
- if ( parts.length > 1 )
+ if (parts.length > 1)
{
- for ( int i = 1; i < parts.length; i++ )
+ for (int i = 1; i < parts.length; i++)
{
String p = parts[i];
- if ( p.toLowerCase().startsWith( "version=" ) )
+ if (p.toLowerCase().startsWith("version="))
{
- pi.setVersions( VersionRange.parseVersionRange( p.substring( "version=".length() ) ) );
+ pi.setVersions(VersionRange.parseVersionRange(p.substring("version=".length())));
}
- else if ( p.toLowerCase().startsWith( "specification-version=" ) )
+ else if (p.toLowerCase().startsWith("specification-version="))
{
- pi.setVersions( VersionRange
- .parseVersionRange( p.substring( "specification-version=".length() ) ) );
+ pi.setVersions(VersionRange.parseVersionRange(p.substring("specification-version=".length())));
}
- else if ( p.toLowerCase().startsWith( "resolution:=" ) )
+ else if (p.toLowerCase().startsWith("resolution:="))
{
- pi.setOptional( p.toLowerCase().substring( "resolution:=".length() ).equals( "optional" ) );
+ pi.setOptional(p.toLowerCase().substring("resolution:=".length()).equals(
+ "optional"));
}
}
}
- info.addImport( pi );
+ info.addImport(pi);
}
}
-
- private static void addRequires( IBundleModelElement info, String reqStr ) throws ModelElementFactoryException
+ private static void addRequires(IBundleModelElement info, String reqStr)
+ throws ModelElementFactoryException
{
- for ( String imp : QuoteUtil.split( reqStr ) )
+ for (String imp : QuoteUtil.split(reqStr))
{
- String[] parts = imp.split( ";" );
- IRequiredBundle req = ModelElementFactory.getInstance().newModelElement( IRequiredBundle.class );
- req.setSymbolicName( parts[0] );
+ String[] parts = imp.split(";");
+ IRequiredBundle req = ModelElementFactory.getInstance().newModelElement(
+ IRequiredBundle.class);
+ req.setSymbolicName(parts[0]);
- if ( parts.length > 1 )
+ if (parts.length > 1)
{
- if ( parts[1].toLowerCase().startsWith( "version=" ) )
+ if (parts[1].toLowerCase().startsWith("version="))
{
- req.setVersions( VersionRange.parseVersionRange( parts[1].substring( "version=".length() ) ) );
+ req.setVersions(VersionRange.parseVersionRange(parts[1].substring("version=".length())));
}
- else if ( parts[1].toLowerCase().startsWith( "specification-version=" ) )
+ else if (parts[1].toLowerCase().startsWith("specification-version="))
{
- req.setVersions( VersionRange.parseVersionRange( parts[1].substring( "specification-version="
- .length() ) ) );
+ req.setVersions(VersionRange.parseVersionRange(parts[1].substring("specification-version=".length())));
}
}
- info.addRequiredBundle( req );
+ info.addRequiredBundle(req);
}
}
-
/**
* @param info
* @param str
*/
- private static void addHost( IBundleModelElement info, String str )
+ private static void addHost(IBundleModelElement info, String str)
{
- String[] parts = str.split( ";" );
- IRequiredBundle req = ModelElementFactory.getInstance().newModelElement( IRequiredBundle.class );
- req.setSymbolicName( parts[0].trim() );
+ String[] parts = str.split(";");
+ IRequiredBundle req = ModelElementFactory.getInstance().newModelElement(
+ IRequiredBundle.class);
+ req.setSymbolicName(parts[0].trim());
- if ( parts.length > 1 )
+ if (parts.length > 1)
{
String part = parts[1].toLowerCase().trim();
- if ( part.startsWith( "bundle-version=" ) )
+ if (part.startsWith("bundle-version="))
{
- req.setVersions( VersionRange.parseVersionRange( part.substring( "bundle-version=".length() ) ) );
+ req.setVersions(VersionRange.parseVersionRange(part.substring("bundle-version=".length())));
}
}
- info.setFragmentHost( req );
+ info.setFragmentHost(req);
}
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/core/util/QuoteUtil.java b/sigil/common/core/src/org/apache/felix/sigil/common/core/util/QuoteUtil.java
index 609463e..dc88889 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/core/util/QuoteUtil.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/core/util/QuoteUtil.java
@@ -19,43 +19,41 @@
package org.apache.felix.sigil.common.core.util;
-
import java.util.ArrayList;
-
public class QuoteUtil
{
- public static String[] split( String str )
+ public static String[] split(String str)
{
ArrayList<String> split = new ArrayList<String>();
boolean quote = false;
- StringBuffer buf = new StringBuffer( str.length() );
+ StringBuffer buf = new StringBuffer(str.length());
- for ( int i = 0; i < str.length(); i++ )
+ for (int i = 0; i < str.length(); i++)
{
- char c = str.charAt( i );
- switch ( c )
+ char c = str.charAt(i);
+ switch (c)
{
case '"':
quote = !quote;
break;
case ',':
- if ( !quote )
+ if (!quote)
{
- split.add( buf.toString().trim() );
- buf.setLength( 0 );
+ split.add(buf.toString().trim());
+ buf.setLength(0);
break;
}
// else fall through on purpose
default:
- buf.append( c );
+ buf.append(c);
}
}
- if ( buf.length() > 0 )
+ if (buf.length() > 0)
{
- split.add( buf.toString().trim() );
+ split.add(buf.toString().trim());
}
- return split.toArray( new String[split.size()] );
+ return split.toArray(new String[split.size()]);
}
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/AbstractCompoundModelElement.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/AbstractCompoundModelElement.java
index 8343eda..2bbf575 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/AbstractCompoundModelElement.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/AbstractCompoundModelElement.java
@@ -19,37 +19,31 @@
package org.apache.felix.sigil.common.model;
-
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-
public abstract class AbstractCompoundModelElement extends AbstractModelElement implements ICompoundModelElement
{
private static final long serialVersionUID = 1L;
-
- public AbstractCompoundModelElement( String description )
+ public AbstractCompoundModelElement(String description)
{
- super( description );
+ super(description);
}
-
- public boolean addChild( IModelElement child ) throws InvalidModelException
+ public boolean addChild(IModelElement child) throws InvalidModelException
{
- return support.addChild( child );
+ return support.addChild(child);
}
-
- public boolean removeChild( IModelElement child )
+ public boolean removeChild(IModelElement child)
{
- return support.removeChild( child );
+ return support.removeChild(child);
}
-
public IModelElement[] children()
{
return support.children();
@@ -57,85 +51,80 @@
private static final ThreadLocal<Map<IModelWalker, Set<IModelElement>>> walkedLocal = new ThreadLocal<Map<IModelWalker, Set<IModelElement>>>();
-
- public void visit( IModelWalker walker )
+ public void visit(IModelWalker walker)
{
- if ( walker.visit( this ) )
+ if (walker.visit(this))
{
Map<IModelWalker, Set<IModelElement>> walked = walkedLocal.get();
boolean delete = false;
- if ( walked == null )
+ if (walked == null)
{
walked = new HashMap<IModelWalker, Set<IModelElement>>();
- walkedLocal.set( walked );
+ walkedLocal.set(walked);
}
- Set<IModelElement> check = walked.get( walker );
+ Set<IModelElement> check = walked.get(walker);
- if ( check == null )
+ if (check == null)
{
delete = true;
check = new HashSet<IModelElement>();
}
- check.add( this );
+ check.add(this);
try
{
- for ( IModelElement e : children() )
+ for (IModelElement e : children())
{
- if ( !check.contains( e ) && walker.visit( e ) )
+ if (!check.contains(e) && walker.visit(e))
{
- check.add( e );
- if ( e instanceof ICompoundModelElement )
+ check.add(e);
+ if (e instanceof ICompoundModelElement)
{
- ICompoundModelElement c = ( ICompoundModelElement ) e;
- c.visit( walker );
+ ICompoundModelElement c = (ICompoundModelElement) e;
+ c.visit(walker);
}
}
}
}
finally
{
- if ( delete )
+ if (delete)
{
- walked.remove( walker );
+ walked.remove(walker);
- if ( walked.isEmpty() )
+ if (walked.isEmpty())
{
- walkedLocal.set( null );
+ walkedLocal.set(null);
}
}
}
}
}
-
public Set<Class<? extends IModelElement>> getOptionalChildren()
{
- return support.getChildrenTypes( false );
+ return support.getChildrenTypes(false);
}
-
public Set<Class<? extends IModelElement>> getRequiredChildren()
{
- return support.getChildrenTypes( true );
+ return support.getChildrenTypes(true);
}
-
- public <T extends IModelElement> T[] childrenOfType( Class<T> type )
+ public <T extends IModelElement> T[] childrenOfType(Class<T> type)
{
- return support.childrenOfType( type );
+ return support.childrenOfType(type);
}
-
@Override
public void checkValid() throws InvalidModelException
{
super.checkValid();
- for ( IModelElement e : support.children() )
+ for (IModelElement e : support.children())
{
e.checkValid();
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/AbstractModelElement.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/AbstractModelElement.java
index c2b7e72..ca2afe4 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/AbstractModelElement.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/AbstractModelElement.java
@@ -19,14 +19,12 @@
package org.apache.felix.sigil.common.model;
-
import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
-
public abstract class AbstractModelElement implements IModelElement
{
@@ -41,65 +39,60 @@
protected ModelElementSupport support;
-
- public AbstractModelElement( String description )
+ public AbstractModelElement(String description)
{
- support = new ModelElementSupport( this );
+ support = new ModelElementSupport(this);
this.description = description.intern();
}
-
public String getElementDescription()
{
return description;
}
-
public Map<Object, Object> getMeta()
{
return meta == null ? Collections.emptyMap() : Collections.unmodifiableMap(meta);
}
-
- public void setMeta( Map<Object, Object> meta )
+ public void setMeta(Map<Object, Object> meta)
{
this.meta = meta;
}
-
@Override
public AbstractModelElement clone()
{
try
{
- AbstractModelElement clone = ( AbstractModelElement ) super.clone();
+ AbstractModelElement clone = (AbstractModelElement) super.clone();
- if ( meta != null ) {
- clone.meta = new HashMap<Object, Object>( meta );
+ if (meta != null)
+ {
+ clone.meta = new HashMap<Object, Object>(meta);
}
-
+
clone.support = new ModelElementSupport(clone);
return clone;
}
- catch ( CloneNotSupportedException e )
+ catch (CloneNotSupportedException e)
{
// can't happen but make compiler happy
- throw new IllegalStateException( e );
+ throw new IllegalStateException(e);
}
}
-
@SuppressWarnings("unchecked")
- public <T extends IModelElement> T getAncestor( Class<T> type )
+ public <T extends IModelElement> T getAncestor(Class<T> type)
{
IModelElement parent = this.parent;
- while ( parent != null )
+ while (parent != null)
{
- if ( type.isInstance( parent ) )
+ if (type.isInstance(parent))
{
- return ( T ) parent;
+ return (T) parent;
}
parent = parent.getParent();
}
@@ -107,107 +100,101 @@
return null;
}
-
public IModelElement getParent()
{
return parent;
}
-
- public void setParent( IModelElement parent )
+ public void setParent(IModelElement parent)
{
- if ( parent != null )
+ if (parent != null)
{
- if ( this.parent != null && this.parent != parent )
+ if (this.parent != null && this.parent != parent)
{
- throw new IllegalStateException( "Parent already installed" );
+ throw new IllegalStateException("Parent already installed");
}
}
this.parent = parent;
}
-
public void checkValid() throws InvalidModelException
{
- for ( String req : getRequiredProperties() )
+ for (String req : getRequiredProperties())
{
try
{
- if ( getProperty( req ) == null )
+ if (getProperty(req) == null)
{
- throw new InvalidModelException( this, "Missing property " + req );
+ throw new InvalidModelException(this, "Missing property " + req);
}
}
- catch ( NoSuchMethodException e )
+ catch (NoSuchMethodException e)
{
- throw new InvalidModelException( this, "No such property " + req );
+ throw new InvalidModelException(this, "No such property " + req);
}
}
}
-
- public Object getProperty( String name ) throws NoSuchMethodException
+ public Object getProperty(String name) throws NoSuchMethodException
{
- return support.getProperty( name );
+ return support.getProperty(name);
}
-
- public void setProperty( String name, Object value ) throws NoSuchMethodException
+ public void setProperty(String name, Object value) throws NoSuchMethodException
{
- support.setProperty( name, value );
+ support.setProperty(name, value);
}
-
- public void addProperty( String name, Object value ) throws NoSuchMethodException
+ public void addProperty(String name, Object value) throws NoSuchMethodException
{
- support.addProperty( name, value );
+ support.addProperty(name, value);
}
-
- public void removeProperty( String name, Object value ) throws NoSuchMethodException
+ public void removeProperty(String name, Object value) throws NoSuchMethodException
{
- support.removeProperty( name, value );
+ support.removeProperty(name, value);
}
-
- public Object getDefaultPropertyValue( String name )
+ public Object getDefaultPropertyValue(String name)
{
- return support.getDefaultPropertyValue( name );
+ return support.getDefaultPropertyValue(name);
}
-
public Set<String> getPropertyNames()
{
return support.getPropertyNames();
}
-
public Set<String> getRequiredProperties()
{
return Collections.emptySet();
}
- public Class<?> getPropertyType( String name ) throws NoSuchMethodException
+ public Class<?> getPropertyType(String name) throws NoSuchMethodException
{
- return support.getPropertyType( name );
+ return support.getPropertyType(name);
}
protected Object writeReplace()
{
AbstractModelElement clone = clone();
- if ( clone.meta != null ) {
- clone.serializedMeta = new HashMap<Serializable, Serializable>(clone.meta.size());
-
- for ( Map.Entry<Object, Object> e : clone.meta.entrySet() )
+ if (clone.meta != null)
+ {
+ clone.serializedMeta = new HashMap<Serializable, Serializable>(
+ clone.meta.size());
+
+ for (Map.Entry<Object, Object> e : clone.meta.entrySet())
{
- if ( e.getKey() instanceof Serializable && e.getValue() instanceof Serializable )
+ if (e.getKey() instanceof Serializable
+ && e.getValue() instanceof Serializable)
{
- clone.serializedMeta.put( ( Serializable ) e.getKey(), ( Serializable ) e.getValue() );
+ clone.serializedMeta.put((Serializable) e.getKey(),
+ (Serializable) e.getValue());
}
}
-
+
clone.meta = null;
}
@@ -216,19 +203,18 @@
protected Object readResolve()
{
- meta = serializedMeta == null ? null : new HashMap<Object, Object>( serializedMeta );
+ meta = serializedMeta == null ? null
+ : new HashMap<Object, Object>(serializedMeta);
serializedMeta = null;
return this;
}
-
public OverrideOptions getOverride()
{
return override;
}
-
- public void setOverride( OverrideOptions override )
+ public void setOverride(OverrideOptions override)
{
this.override = override;
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/ICapabilityModelElement.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/ICapabilityModelElement.java
index 7ec94ef..17c830b 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/ICapabilityModelElement.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/ICapabilityModelElement.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-
+
package org.apache.felix.sigil.common.model;
public interface ICapabilityModelElement extends IModelElement
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/ICompoundModelElement.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/ICompoundModelElement.java
index f73b337..d2581a8 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/ICompoundModelElement.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/ICompoundModelElement.java
@@ -19,10 +19,8 @@
package org.apache.felix.sigil.common.model;
-
import java.util.Set;
-
/**
* Represents a model element that is made up of sub model elements.
*
@@ -38,16 +36,14 @@
* @return
* @throws InvalidModelException
*/
- boolean addChild( IModelElement children ) throws InvalidModelException;
-
+ boolean addChild(IModelElement children) throws InvalidModelException;
/**
* Calls the applicable set/remove method of this model to remove the element from this part of the model
* @param children
* @return
*/
- boolean removeChild( IModelElement children );
-
+ boolean removeChild(IModelElement children);
/**
* List all direct child elements of this model element.
@@ -55,14 +51,12 @@
*/
IModelElement[] children();
-
/**
* Visits child elements of this model element, recursing down to sub compound elements when found.
*
* @param walker
*/
- void visit( IModelWalker walker );
-
+ void visit(IModelWalker walker);
/**
* Searches the model to find all child model elements which match the specified type
@@ -71,11 +65,9 @@
* @param type
* @return
*/
- <T extends IModelElement> T[] childrenOfType( Class<T> type );
-
+ <T extends IModelElement> T[] childrenOfType(Class<T> type);
Set<Class<? extends IModelElement>> getRequiredChildren();
-
Set<Class<? extends IModelElement>> getOptionalChildren();
}
\ No newline at end of file
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelElement.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelElement.java
index bafc0be..84e9145 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelElement.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelElement.java
@@ -19,11 +19,9 @@
package org.apache.felix.sigil.common.model;
-
import java.util.Map;
import java.util.Set;
-
/**
* IModelElement represent static information about a part of a model.
*
@@ -39,7 +37,6 @@
*/
String getElementDescription();
-
/**
* A set of key value pairs designed for use by a machine to classify a particular element.
*
@@ -47,15 +44,13 @@
*/
Map<Object, Object> getMeta();
-
/**
* Set meta data on this descriptor. Meta data is designed for use by a machine to classify or further enhance a
* particular element.
*
* @param meta
*/
- void setMeta( Map<Object, Object> meta );
-
+ void setMeta(Map<Object, Object> meta);
/**
* Check to see if this element defines a complete set of properties. The definition of what constitutes a
@@ -65,16 +60,13 @@
*/
void checkValid() throws InvalidModelException;
-
/**
* Find the parent element of this model element or null if no parent exists.
* @return
*/
IModelElement getParent();
-
- void setParent( IModelElement parent );
-
+ void setParent(IModelElement parent);
/**
* Finds the first ancestor up the hierarch of parents which is an instance of the specified
@@ -83,33 +75,24 @@
* @param type
* @return
*/
- <T extends IModelElement> T getAncestor( Class<T> type );
-
+ <T extends IModelElement> T getAncestor(Class<T> type);
IModelElement clone();
-
Set<String> getPropertyNames();
+ void setProperty(String name, Object value) throws NoSuchMethodException;
- void setProperty( String name, Object value ) throws NoSuchMethodException;
+ void addProperty(String name, Object value) throws NoSuchMethodException;
+ void removeProperty(String name, Object value) throws NoSuchMethodException;
- void addProperty( String name, Object value ) throws NoSuchMethodException;
+ Object getProperty(String name) throws NoSuchMethodException;
-
- void removeProperty( String name, Object value ) throws NoSuchMethodException;
-
-
- Object getProperty( String name ) throws NoSuchMethodException;
-
-
- Object getDefaultPropertyValue( String name );
-
+ Object getDefaultPropertyValue(String name);
Set<String> getRequiredProperties();
-
- Class<?> getPropertyType( String name ) throws NoSuchMethodException;
+ Class<?> getPropertyType(String name) throws NoSuchMethodException;
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelInfo.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelInfo.java
index adbecee..17993a7 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelInfo.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelInfo.java
@@ -19,14 +19,11 @@
package org.apache.felix.sigil.common.model;
-
public interface IModelInfo
{
String getGroupName();
-
String getGroupURI();
-
String getName();
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelWalker.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelWalker.java
index 8588e48..931c72d 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelWalker.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/IModelWalker.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.model;
-
/**
* Visitor pattern to traverse nodes in the model.
*
@@ -37,5 +36,5 @@
*
* @return true to continue walking the model, false otherwise
*/
- boolean visit( IModelElement element );
+ boolean visit(IModelElement element);
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/INamedModelElement.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/INamedModelElement.java
index 220e493..07c1664 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/INamedModelElement.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/INamedModelElement.java
@@ -19,17 +19,13 @@
package org.apache.felix.sigil.common.model;
-
public interface INamedModelElement extends IModelElement
{
- void setName( String name );
-
+ void setName(String name);
String getName();
-
OverrideOptions getOverride();
-
- void setOverride( OverrideOptions override );
+ void setOverride(OverrideOptions override);
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/IRequirementModelElement.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/IRequirementModelElement.java
index bcf29ec..2b197f6 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/IRequirementModelElement.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/IRequirementModelElement.java
@@ -19,16 +19,14 @@
package org.apache.felix.sigil.common.model;
-
public interface IRequirementModelElement extends IModelElement
{
- boolean accepts( ICapabilityModelElement provider );
-
+ boolean accepts(ICapabilityModelElement provider);
+
/**
* indicates whether the OSGi attribute "resolution=optional" is specified.
*/
boolean isOptional();
-
- void setOptional( boolean optional );
+ void setOptional(boolean optional);
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/InvalidModelException.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/InvalidModelException.java
index 7a67697..5f9740f 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/InvalidModelException.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/InvalidModelException.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.model;
-
/**
* @author dave
*
@@ -31,21 +30,18 @@
private IModelElement target;
-
- public InvalidModelException( IModelElement target, String msg )
+ public InvalidModelException(IModelElement target, String msg)
{
- super( msg );
+ super(msg);
this.target = target;
}
-
- public InvalidModelException( IModelElement target, String msg, Throwable t )
+ public InvalidModelException(IModelElement target, String msg, Throwable t)
{
- super( msg, t );
+ super(msg, t);
this.target = target;
}
-
public IModelElement getTarget()
{
return target;
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementFactory.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementFactory.java
index 2798753..94d36c9 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementFactory.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementFactory.java
@@ -19,11 +19,9 @@
package org.apache.felix.sigil.common.model;
-
import java.util.HashMap;
import java.util.Map;
-
public abstract class ModelElementFactory
{
static class ElementInfo
@@ -33,8 +31,7 @@
String groupName;
String groupURI;
-
- public ElementInfo( Class<? extends IModelElement> implType, String name, String groupName, String groupURI )
+ public ElementInfo(Class<? extends IModelElement> implType, String name, String groupName, String groupURI)
{
this.implType = implType;
this.name = name;
@@ -42,34 +39,30 @@
this.groupURI = groupURI;
}
-
public Class<? extends IModelElement> getImplType()
{
return implType;
}
-
public String getName()
{
return name;
}
-
public String getGroupName()
{
return groupName;
}
-
public String getGroupURI()
{
return groupURI;
}
-
public String toString()
{
- return "ElementInfo[" + name + ":" + groupName + ":" + groupURI + ":" + implType.getCanonicalName() + "]";
+ return "ElementInfo[" + name + ":" + groupName + ":" + groupURI + ":"
+ + implType.getCanonicalName() + "]";
}
}
@@ -78,25 +71,21 @@
private ElementInfo e;
-
- public ModelInfo( ElementInfo e )
+ public ModelInfo(ElementInfo e)
{
this.e = e;
}
-
public String getGroupName()
{
return e.getGroupName();
}
-
public String getGroupURI()
{
return e.getGroupURI();
}
-
public String getName()
{
return e.getName();
@@ -108,92 +97,88 @@
{
private HashMap<Class<? extends IModelElement>, ElementInfo> elementInfo = new HashMap<Class<? extends IModelElement>, ElementInfo>();
-
@SuppressWarnings("unchecked")
@Override
- public <T extends IModelElement> T newModelElement( Class<T> type ) throws ModelElementFactoryException
+ public <T extends IModelElement> T newModelElement(Class<T> type)
+ throws ModelElementFactoryException
{
- ElementInfo info = elementInfo.get( type );
- if ( info == null )
+ ElementInfo info = elementInfo.get(type);
+ if (info == null)
{
- throw new ModelElementFactoryException( "No implementation registered for " + type );
+ throw new ModelElementFactoryException(
+ "No implementation registered for " + type);
}
try
{
- return ( T ) info.getImplType().newInstance();
+ return (T) info.getImplType().newInstance();
}
- catch ( InstantiationException e )
+ catch (InstantiationException e)
{
- throw new ModelElementFactoryException( e );
+ throw new ModelElementFactoryException(e);
}
- catch ( IllegalAccessException e )
+ catch (IllegalAccessException e)
{
- throw new ModelElementFactoryException( e );
+ throw new ModelElementFactoryException(e);
}
}
-
@Override
- public <T extends IModelElement> void register( Class<T> type, Class<? extends T> impl, String name,
- String groupName, String groupURI )
+ public <T extends IModelElement> void register(Class<T> type,
+ Class<? extends T> impl, String name, String groupName, String groupURI)
{
- elementInfo.put( type, new ElementInfo( impl, name, groupName, groupURI ) );
+ elementInfo.put(type, new ElementInfo(impl, name, groupName, groupURI));
}
-
@Override
- public <T extends IModelElement> void unregister( Class<T> type, Class<? extends T> impl )
+ public <T extends IModelElement> void unregister(Class<T> type,
+ Class<? extends T> impl)
{
- ElementInfo info = elementInfo.get( type );
- if ( info != null && info.getImplType() == impl )
+ ElementInfo info = elementInfo.get(type);
+ if (info != null && info.getImplType() == impl)
{
- elementInfo.remove( type );
+ elementInfo.remove(type);
}
}
-
@Override
- public IModelInfo getModelInfo( Class<? extends IModelElement> type )
+ public IModelInfo getModelInfo(Class<? extends IModelElement> type)
{
- ElementInfo e = findElementInfo( type );
+ ElementInfo e = findElementInfo(type);
- if ( e == null )
+ if (e == null)
{
return null;
}
- return new ModelInfo( e );
+ return new ModelInfo(e);
}
-
@Override
- public IModelElement newModelElement( String namespaceURI, String localPart )
+ public IModelElement newModelElement(String namespaceURI, String localPart)
throws ModelElementFactoryException
{
- for ( Map.Entry<Class<? extends IModelElement>, ElementInfo> e : elementInfo.entrySet() )
+ for (Map.Entry<Class<? extends IModelElement>, ElementInfo> e : elementInfo.entrySet())
{
ElementInfo i = e.getValue();
- if ( equal( namespaceURI, i.getGroupURI() ) && equal( i.getName(), localPart ) )
+ if (equal(namespaceURI, i.getGroupURI()) && equal(i.getName(), localPart))
{
- return newModelElement( e.getKey() );
+ return newModelElement(e.getKey());
}
}
return null;
}
-
- private boolean equal( String val1, String val2 )
+ private boolean equal(String val1, String val2)
{
- return val1 == null ? val2 == null : val1.equals( val2 );
+ return val1 == null ? val2 == null : val1.equals(val2);
}
-
- private ElementInfo findElementInfo( Class<? extends IModelElement> type )
+ private ElementInfo findElementInfo(Class<? extends IModelElement> type)
{
- for ( ElementInfo e : elementInfo.values() )
+ for (ElementInfo e : elementInfo.values())
{
- if ( e.getImplType() == type )
+ if (e.getImplType() == type)
{
return e;
}
@@ -204,26 +189,22 @@
}
-
- public abstract <T extends IModelElement> T newModelElement( Class<T> type ) throws ModelElementFactoryException;
-
-
- public abstract IModelElement newModelElement( String namespaceURI, String localPart )
+ public abstract <T extends IModelElement> T newModelElement(Class<T> type)
throws ModelElementFactoryException;
+ public abstract IModelElement newModelElement(String namespaceURI, String localPart)
+ throws ModelElementFactoryException;
- public abstract <T extends IModelElement> void register( Class<T> type, Class<? extends T> impl, String name,
- String groupName, String groupURI );
+ public abstract <T extends IModelElement> void register(Class<T> type,
+ Class<? extends T> impl, String name, String groupName, String groupURI);
+ public abstract <T extends IModelElement> void unregister(Class<T> type,
+ Class<? extends T> impl);
- public abstract <T extends IModelElement> void unregister( Class<T> type, Class<? extends T> impl );
-
-
- public abstract IModelInfo getModelInfo( Class<? extends IModelElement> type );
+ public abstract IModelInfo getModelInfo(Class<? extends IModelElement> type);
private static ModelElementFactory instance = new DefaultModelElementFactory();
-
public static ModelElementFactory getInstance()
{
return instance;
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementFactoryException.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementFactoryException.java
index 392b956..d6ea643 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementFactoryException.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementFactoryException.java
@@ -19,22 +19,19 @@
package org.apache.felix.sigil.common.model;
-
public class ModelElementFactoryException extends RuntimeException
{
private static final long serialVersionUID = 1L;
-
- public ModelElementFactoryException( Throwable t )
+ public ModelElementFactoryException(Throwable t)
{
- super( t );
+ super(t);
}
-
- public ModelElementFactoryException( String msg )
+ public ModelElementFactoryException(String msg)
{
- super( msg );
+ super(msg);
}
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementSupport.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementSupport.java
index 1bd3757..4a88fae 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementSupport.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/ModelElementSupport.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.model;
-
import java.io.Serializable;
import java.lang.ref.SoftReference;
import java.lang.reflect.Array;
@@ -37,22 +36,17 @@
import org.apache.felix.sigil.common.model.annotations.Required;
-
public class ModelElementSupport implements Serializable
{
- private static final Logger log = Logger.getLogger( ModelElementSupport.class.getName() );
+ private static final Logger log = Logger.getLogger(ModelElementSupport.class.getName());
private static final long serialVersionUID = 1L;
- private static final PropertyAdapter[] EMPTY_PROPS = new PropertyAdapter[]
- {};
- private static final IModelElement[] EMPTY_ELEMENTS = new IModelElement[]
- {};
- private static final Object[] ZERO_ARGS = new Object[]
- {};
- private static final Class<?>[] ZERO_PARAMS = new Class[]
- {};
+ private static final PropertyAdapter[] EMPTY_PROPS = new PropertyAdapter[] {};
+ private static final IModelElement[] EMPTY_ELEMENTS = new IModelElement[] {};
+ private static final Object[] ZERO_ARGS = new Object[] {};
+ private static final Class<?>[] ZERO_PARAMS = new Class[] {};
private static final WeakHashMap<Class<?>, SoftReference<ChildAdapter[]>> adapterCache = new WeakHashMap<Class<?>, SoftReference<ChildAdapter[]>>();;
private static final WeakHashMap<Class<?>, SoftReference<PropertyAdapter[]>> propertyCache = new WeakHashMap<Class<?>, SoftReference<PropertyAdapter[]>>();;
@@ -63,172 +57,168 @@
private transient SoftReference<ChildAdapter[]> childrenReference;
private transient SoftReference<Set<String>> propertyNameReference;
-
- public ModelElementSupport( IModelElement target )
+ public ModelElementSupport(IModelElement target)
{
this.target = target;
}
-
- public void setProperty( String name, Object value ) throws NoSuchMethodException
+ public void setProperty(String name, Object value) throws NoSuchMethodException
{
- PropertyAdapter p = findProperty( name, value );
- if ( p == null )
+ PropertyAdapter p = findProperty(name, value);
+ if (p == null)
{
- throw new NoSuchMethodException( "No such property " + name + " for type " + target.getClass() );
+ throw new NoSuchMethodException("No such property " + name + " for type "
+ + target.getClass());
}
- invoke( target, p.getWriteMethod(), value );
+ invoke(target, p.getWriteMethod(), value);
}
-
- public void addProperty( String name, Object value ) throws NoSuchMethodException
+ public void addProperty(String name, Object value) throws NoSuchMethodException
{
- PropertyAdapter p = findProperty( name, value );
- if ( p == null )
+ PropertyAdapter p = findProperty(name, value);
+ if (p == null)
{
- throw new NoSuchMethodException( "No such property " + name + " for type " + target.getClass() );
+ throw new NoSuchMethodException("No such property " + name + " for type "
+ + target.getClass());
}
- invoke( target, p.getAddMethod(), value );
+ invoke(target, p.getAddMethod(), value);
}
-
- public void removeProperty( String name, Object value ) throws NoSuchMethodException
+ public void removeProperty(String name, Object value) throws NoSuchMethodException
{
- PropertyAdapter p = findProperty( name, value );
- if ( p == null )
+ PropertyAdapter p = findProperty(name, value);
+ if (p == null)
{
- throw new NoSuchMethodException( "No such property " + name + " for type " + target.getClass() );
+ throw new NoSuchMethodException("No such property " + name + " for type "
+ + target.getClass());
}
- invoke( target, p.getRemoveMethod(), value );
+ invoke(target, p.getRemoveMethod(), value);
}
-
- public Object getProperty( String name ) throws NoSuchMethodException
+ public Object getProperty(String name) throws NoSuchMethodException
{
- PropertyAdapter p = findProperty( name, null );
- if ( p == null )
+ PropertyAdapter p = findProperty(name, null);
+ if (p == null)
{
- throw new NoSuchMethodException( "No such property " + name + " for type " + target.getClass() );
+ throw new NoSuchMethodException("No such property " + name + " for type "
+ + target.getClass());
}
- return invoke( target, p.getReadMethod(), ZERO_ARGS );
+ return invoke(target, p.getReadMethod(), ZERO_ARGS);
}
-
public Set<String> getPropertyNames()
{
- Set<String> names = propertyNameReference == null ? null : propertyNameReference.get();
+ Set<String> names = propertyNameReference == null ? null
+ : propertyNameReference.get();
- if ( names == null )
+ if (names == null)
{
names = new HashSet<String>();
- PropertyAdapter[] props = cachedProps( target.getClass() );
- for ( PropertyAdapter prop : props )
+ PropertyAdapter[] props = cachedProps(target.getClass());
+ for (PropertyAdapter prop : props)
{
- names.add( prop.getName() );
+ names.add(prop.getName());
}
- propertyNameReference = new SoftReference<Set<String>>( names );
+ propertyNameReference = new SoftReference<Set<String>>(names);
}
return names;
}
-
- public Object getDefaultPropertyValue( String name )
+ public Object getDefaultPropertyValue(String name)
{
try
{
- Method m = target.getClass().getMethod( makeDefaultPropertyValue( name ), ZERO_PARAMS );
- return invoke( target, m, ZERO_ARGS );
+ Method m = target.getClass().getMethod(makeDefaultPropertyValue(name),
+ ZERO_PARAMS);
+ return invoke(target, m, ZERO_ARGS);
}
- catch ( SecurityException e )
+ catch (SecurityException e)
{
- throw new UndeclaredThrowableException( e );
+ throw new UndeclaredThrowableException(e);
}
- catch ( NoSuchMethodException e )
+ catch (NoSuchMethodException e)
{
// fine no default
return null;
}
}
-
- public Class<?> getPropertyType( String name ) throws NoSuchMethodException
+ public Class<?> getPropertyType(String name) throws NoSuchMethodException
{
- PropertyAdapter p = findProperty( name, null );
- if ( p == null )
+ PropertyAdapter p = findProperty(name, null);
+ if (p == null)
{
- throw new NoSuchMethodException( "No such property " + name + " for type " + target.getClass() );
+ throw new NoSuchMethodException("No such property " + name + " for type "
+ + target.getClass());
}
return p.getPropertyType();
}
-
@SuppressWarnings("unchecked")
- public <T extends IModelElement> T[] childrenOfType( Class<T> type )
+ public <T extends IModelElement> T[] childrenOfType(Class<T> type)
{
ChildAdapter[] adapters = cachedAdapters();
- if ( adapters.length == 0 )
+ if (adapters.length == 0)
{
// return (T[]) EMPTY_ELEMENTS;
- return ( ( T[] ) Array.newInstance( type, 0 ) );
+ return ((T[]) Array.newInstance(type, 0));
}
ArrayList<T> elements = new ArrayList<T>();
- for ( ChildAdapter adapter : adapters )
+ for (ChildAdapter adapter : adapters)
{
- Collection<? extends IModelElement> val = adapter.members( target );
+ Collection<? extends IModelElement> val = adapter.members(target);
- for ( IModelElement e : val )
+ for (IModelElement e : val)
{
- if ( type.isInstance( e ) )
+ if (type.isInstance(e))
{
- elements.add( ( T ) e );
+ elements.add((T) e);
}
}
}
//return elements.toArray( (T[]) EMPTY_ELEMENTS );
- return elements.toArray( ( T[] ) Array.newInstance( type, elements.size() ) );
+ return elements.toArray((T[]) Array.newInstance(type, elements.size()));
}
-
public IModelElement[] children()
{
ChildAdapter[] adapters = cachedAdapters();
- if ( adapters.length == 0 )
+ if (adapters.length == 0)
{
return EMPTY_ELEMENTS;
}
ArrayList<IModelElement> elements = new ArrayList<IModelElement>();
- for ( ChildAdapter adapter : adapters )
+ for (ChildAdapter adapter : adapters)
{
- elements.addAll( adapter.members( target ) );
+ elements.addAll(adapter.members(target));
}
- return elements.toArray( EMPTY_ELEMENTS );
+ return elements.toArray(EMPTY_ELEMENTS);
}
-
- public boolean addChild( IModelElement element ) throws InvalidModelException
+ public boolean addChild(IModelElement element) throws InvalidModelException
{
- if ( element.getParent() == null )
+ if (element.getParent() == null)
{
ChildAdapter[] adapters = cachedAdapters();
- if ( adapters.length > 0 )
+ if (adapters.length > 0)
{
- for ( ChildAdapter adapter : adapters )
+ for (ChildAdapter adapter : adapters)
{
- if ( adapter.add( target, element ) )
+ if (adapter.add(target, element))
{
- element.setParent( target );
+ element.setParent(target);
return true;
}
}
@@ -238,20 +228,19 @@
return false;
}
-
- public boolean removeChild( IModelElement element )
+ public boolean removeChild(IModelElement element)
{
- if ( element.getParent() == target )
+ if (element.getParent() == target)
{
ChildAdapter[] adapters = cachedAdapters();
- if ( adapters.length > 0 )
+ if (adapters.length > 0)
{
- for ( ChildAdapter adapter : adapters )
+ for (ChildAdapter adapter : adapters)
{
- if ( adapter.remove( target, element ) )
+ if (adapter.remove(target, element))
{
- element.setParent( null );
+ element.setParent(null);
return true;
}
}
@@ -261,27 +250,26 @@
return false;
}
-
- public Set<Class<? extends IModelElement>> getChildrenTypes( boolean required )
+ public Set<Class<? extends IModelElement>> getChildrenTypes(boolean required)
{
ChildAdapter[] adapters = cachedAdapters();
- if ( adapters.length == 0 )
+ if (adapters.length == 0)
{
return Collections.emptySet();
}
HashSet<Class<? extends IModelElement>> types = new HashSet<Class<? extends IModelElement>>();
- for ( ChildAdapter adapter : adapters )
+ for (ChildAdapter adapter : adapters)
{
- if ( adapter.isRequired() == required )
+ if (adapter.isRequired() == required)
{
Class<? extends IModelElement> type = adapter.getType();
- if ( type != null )
+ if (type != null)
{
- types.add( type );
+ types.add(type);
}
}
}
@@ -289,21 +277,21 @@
return types;
}
-
- private PropertyAdapter findProperty( String name, Object value )
+ private PropertyAdapter findProperty(String name, Object value)
{
- PropertyAdapter[] props = propertyReference == null ? null : propertyReference.get();
+ PropertyAdapter[] props = propertyReference == null ? null
+ : propertyReference.get();
- if ( props == null )
+ if (props == null)
{
- props = cachedProps( target.getClass() );
- propertyReference = new SoftReference<PropertyAdapter[]>( props );
+ props = cachedProps(target.getClass());
+ propertyReference = new SoftReference<PropertyAdapter[]>(props);
}
- for ( PropertyAdapter prop : props )
+ for (PropertyAdapter prop : props)
{
- if ( prop.getName().equals( name )
- && ( value == null || prop.getRawType().isAssignableFrom( value.getClass() ) ) )
+ if (prop.getName().equals(name)
+ && (value == null || prop.getRawType().isAssignableFrom(value.getClass())))
{
return prop;
}
@@ -312,152 +300,144 @@
return null;
}
-
- private static synchronized PropertyAdapter[] cachedProps( Class<? extends IModelElement> type )
+ private static synchronized PropertyAdapter[] cachedProps(
+ Class<? extends IModelElement> type)
{
- SoftReference<PropertyAdapter[]> ref = propertyCache.get( type );
+ SoftReference<PropertyAdapter[]> ref = propertyCache.get(type);
PropertyAdapter[] props = ref == null ? null : ref.get();
- if ( props == null )
+ if (props == null)
{
- props = loadProps( type );
- propertyCache.put( type, new SoftReference<PropertyAdapter[]>( props ) );
+ props = loadProps(type);
+ propertyCache.put(type, new SoftReference<PropertyAdapter[]>(props));
}
return props;
}
-
- private static PropertyAdapter[] loadProps( Class<? extends IModelElement> type )
+ private static PropertyAdapter[] loadProps(Class<? extends IModelElement> type)
{
ArrayList<PropertyAdapter> props = new ArrayList<PropertyAdapter>();
- for ( Method m : type.getMethods() )
+ for (Method m : type.getMethods())
{
- if ( isValidProperty( m ) )
+ if (isValidProperty(m))
{
try
{
- PropertyAdapter p = new PropertyAdapter( m, type );
- props.add( p );
+ PropertyAdapter p = new PropertyAdapter(m, type);
+ props.add(p);
}
- catch ( NoSuchMethodException e )
+ catch (NoSuchMethodException e)
{
// fine not a bean method
- log.finer( "Invalid bean property method " + m + ": " + e.getMessage() );
+ log.finer("Invalid bean property method " + m + ": " + e.getMessage());
}
}
}
- return props.toArray( EMPTY_PROPS );
+ return props.toArray(EMPTY_PROPS);
}
-
- private static boolean isValidProperty( Method m )
+ private static boolean isValidProperty(Method m)
{
- return m.getName().startsWith( "get" ) && m.getParameterTypes().length == 0
- && !m.getDeclaringClass().equals( Object.class )
- && !IModelElement.class.isAssignableFrom( m.getReturnType() );
+ return m.getName().startsWith("get") && m.getParameterTypes().length == 0
+ && !m.getDeclaringClass().equals(Object.class)
+ && !IModelElement.class.isAssignableFrom(m.getReturnType());
}
-
- private static String makeDefaultPropertyValue( String name )
+ private static String makeDefaultPropertyValue(String name)
{
- return "getDefault" + capitalise( name );
+ return "getDefault" + capitalise(name);
}
-
- private static String capitalise( String name )
+ private static String capitalise(String name)
{
- return Character.toUpperCase( name.charAt( 0 ) ) + name.substring( 1 );
+ return Character.toUpperCase(name.charAt(0)) + name.substring(1);
}
-
- private static String decapitalise( String substring )
+ private static String decapitalise(String substring)
{
- return Character.toLowerCase( substring.charAt( 0 ) ) + substring.substring( 1 );
+ return Character.toLowerCase(substring.charAt(0)) + substring.substring(1);
}
-
private ChildAdapter[] cachedAdapters()
{
- ChildAdapter[] adapters = childrenReference == null ? null : childrenReference.get();
+ ChildAdapter[] adapters = childrenReference == null ? null
+ : childrenReference.get();
- if ( adapters == null )
+ if (adapters == null)
{
- adapters = loadAdapters( target );
- childrenReference = new SoftReference<ChildAdapter[]>( adapters );
+ adapters = loadAdapters(target);
+ childrenReference = new SoftReference<ChildAdapter[]>(adapters);
}
return adapters;
}
-
- private static synchronized ChildAdapter[] loadAdapters( IModelElement target )
+ private static synchronized ChildAdapter[] loadAdapters(IModelElement target)
{
Class<? extends IModelElement> type = target.getClass();
- SoftReference<ChildAdapter[]> ref = adapterCache.get( type );
+ SoftReference<ChildAdapter[]> ref = adapterCache.get(type);
ChildAdapter[] adapters = ref == null ? null : ref.get();
- if ( adapters == null )
+ if (adapters == null)
{
- adapters = buildAdapters( type );
- adapterCache.put( type, new SoftReference<ChildAdapter[]>( adapters ) );
+ adapters = buildAdapters(type);
+ adapterCache.put(type, new SoftReference<ChildAdapter[]>(adapters));
}
return adapters;
}
-
- private static ChildAdapter[] buildAdapters( Class<? extends IModelElement> type )
+ private static ChildAdapter[] buildAdapters(Class<? extends IModelElement> type)
{
ArrayList<ChildAdapter> adapters = new ArrayList<ChildAdapter>();
- for ( Method m : type.getMethods() )
+ for (Method m : type.getMethods())
{
ChildAdapter adapter = null;
- if ( isValidGetProperty( m ) )
+ if (isValidGetProperty(m))
{
- adapter = buildGetAdapter( m );
+ adapter = buildGetAdapter(m);
}
- else if ( isValidSetProperty( m ) )
+ else if (isValidSetProperty(m))
{
- adapter = buildSetAdapter( m );
+ adapter = buildSetAdapter(m);
}
- else if ( isValidAddProperty( m ) )
+ else if (isValidAddProperty(m))
{
- adapter = buildAddAdapter( m );
+ adapter = buildAddAdapter(m);
}
- else if ( isValidRemoveProperty( m ) )
+ else if (isValidRemoveProperty(m))
{
- adapter = buildRemoveAdapter( m );
+ adapter = buildRemoveAdapter(m);
}
- if ( adapter != null )
+ if (adapter != null)
{
- adapters.add( adapter );
+ adapters.add(adapter);
}
}
- return adapters.toArray( new ChildAdapter[adapters.size()] );
+ return adapters.toArray(new ChildAdapter[adapters.size()]);
}
-
- private static ChildAdapter buildGetAdapter( Method m )
+ private static ChildAdapter buildGetAdapter(Method m)
{
- if ( IModelElement.class.isAssignableFrom( m.getReturnType() ) )
+ if (IModelElement.class.isAssignableFrom(m.getReturnType()))
{
- return new GetPropertyAdapter( m );
+ return new GetPropertyAdapter(m);
}
- else if ( Collection.class.isAssignableFrom( m.getReturnType() ) )
+ else if (Collection.class.isAssignableFrom(m.getReturnType()))
{
- return new GetCollectionAdapter( m );
+ return new GetCollectionAdapter(m);
}
- else if ( isModelArray( m.getReturnType() ) )
+ else if (isModelArray(m.getReturnType()))
{
- return new GetArrayAdapter( m );
+ return new GetArrayAdapter(m);
}
else
{
@@ -465,12 +445,11 @@
}
}
-
- private static ChildAdapter buildSetAdapter( Method m )
+ private static ChildAdapter buildSetAdapter(Method m)
{
- if ( IModelElement.class.isAssignableFrom( m.getParameterTypes()[0] ) )
+ if (IModelElement.class.isAssignableFrom(m.getParameterTypes()[0]))
{
- return new SetPropertyAdapter( m );
+ return new SetPropertyAdapter(m);
}
else
{
@@ -478,12 +457,11 @@
}
}
-
- private static ChildAdapter buildAddAdapter( Method m )
+ private static ChildAdapter buildAddAdapter(Method m)
{
- if ( IModelElement.class.isAssignableFrom( m.getParameterTypes()[0] ) )
+ if (IModelElement.class.isAssignableFrom(m.getParameterTypes()[0]))
{
- return new AddPropertyAdapter( m );
+ return new AddPropertyAdapter(m);
}
else
{
@@ -491,12 +469,11 @@
}
}
-
- private static ChildAdapter buildRemoveAdapter( Method m )
+ private static ChildAdapter buildRemoveAdapter(Method m)
{
- if ( IModelElement.class.isAssignableFrom( m.getParameterTypes()[0] ) )
+ if (IModelElement.class.isAssignableFrom(m.getParameterTypes()[0]))
{
- return new RemovePropertyAdapter( m );
+ return new RemovePropertyAdapter(m);
}
else
{
@@ -504,71 +481,66 @@
}
}
-
- private static boolean isValidRemoveProperty( Method m )
+ private static boolean isValidRemoveProperty(Method m)
{
- return m.getParameterTypes().length == 1 && m.getName().startsWith( "remove" )
- && !isDeclared( ICompoundModelElement.class, m );
+ return m.getParameterTypes().length == 1 && m.getName().startsWith("remove")
+ && !isDeclared(ICompoundModelElement.class, m);
}
-
- private static boolean isValidAddProperty( Method m )
+ private static boolean isValidAddProperty(Method m)
{
- return m.getParameterTypes().length == 1 && m.getName().startsWith( "add" )
- && !isDeclared( ICompoundModelElement.class, m );
+ return m.getParameterTypes().length == 1 && m.getName().startsWith("add")
+ && !isDeclared(ICompoundModelElement.class, m);
}
-
- private static boolean isDeclared( Class<? extends IModelElement> element, Method m )
+ private static boolean isDeclared(Class<? extends IModelElement> element, Method m)
{
try
{
- element.getMethod( m.getName(), m.getParameterTypes() );
+ element.getMethod(m.getName(), m.getParameterTypes());
return true;
}
- catch ( SecurityException e )
+ catch (SecurityException e)
{
- throw new UndeclaredThrowableException( e );
+ throw new UndeclaredThrowableException(e);
}
- catch ( NoSuchMethodException e )
+ catch (NoSuchMethodException e)
{
return false;
}
}
-
- private static boolean isValidSetProperty( Method m )
+ private static boolean isValidSetProperty(Method m)
{
- return m.getParameterTypes().length == 1 && m.getName().startsWith( "set" )
- && !isDeclared( IModelElement.class, m );
+ return m.getParameterTypes().length == 1 && m.getName().startsWith("set")
+ && !isDeclared(IModelElement.class, m);
}
-
- private static boolean isValidGetProperty( Method m )
+ private static boolean isValidGetProperty(Method m)
{
- return m.getParameterTypes().length == 0 && m.getName().startsWith( "get" )
- && !isDeclared( IModelElement.class, m ) && !isDeclared( ICompoundModelElement.class, m );
+ return m.getParameterTypes().length == 0 && m.getName().startsWith("get")
+ && !isDeclared(IModelElement.class, m)
+ && !isDeclared(ICompoundModelElement.class, m);
}
-
- private static Object invoke( Object target, Method m, Object... args )
+ private static Object invoke(Object target, Method m, Object... args)
{
try
{
- return m.invoke( target, args );
+ return m.invoke(target, args);
}
- catch ( IllegalArgumentException e )
+ catch (IllegalArgumentException e)
{
// this should already have been tested
- throw new IllegalStateException( e );
+ throw new IllegalStateException(e);
}
- catch ( IllegalAccessException e )
+ catch (IllegalAccessException e)
{
- throw new UndeclaredThrowableException( e );
+ throw new UndeclaredThrowableException(e);
}
- catch ( InvocationTargetException e )
+ catch (InvocationTargetException e)
{
- throw new UndeclaredThrowableException( e.getCause() );
+ throw new UndeclaredThrowableException(e.getCause());
}
}
@@ -583,138 +555,131 @@
Method r;
Class<?> propertyType;
-
- public PropertyAdapter( Method g, Class<?> type ) throws SecurityException, NoSuchMethodException
+ public PropertyAdapter(Method g, Class<?> type) throws SecurityException, NoSuchMethodException
{
- if ( g.getReturnType().isArray() || Iterable.class.isAssignableFrom( g.getReturnType() ) )
+ if (g.getReturnType().isArray()
+ || Iterable.class.isAssignableFrom(g.getReturnType()))
{
- prop = g.getName().substring( 3 );
+ prop = g.getName().substring(3);
// remove trailing s - as in addWibble, removeWibble, getWibbles
- prop = prop.substring( 0, prop.length() - 1 );
- name = decapitalise( prop );
- a = find( "add", prop, g.getReturnType(), type );
+ prop = prop.substring(0, prop.length() - 1);
+ name = decapitalise(prop);
+ a = find("add", prop, g.getReturnType(), type);
propertyType = a.getParameterTypes()[0];
- r = find( "remove", prop, g.getReturnType(), type );
- if ( r.getParameterTypes()[0] != propertyType )
+ r = find("remove", prop, g.getReturnType(), type);
+ if (r.getParameterTypes()[0] != propertyType)
{
- throw new NoSuchMethodException( "Add remove property method types do not match" );
+ throw new NoSuchMethodException(
+ "Add remove property method types do not match");
}
- propertyType = Array.newInstance( propertyType, 0 ).getClass();
+ propertyType = Array.newInstance(propertyType, 0).getClass();
}
else
{
- prop = g.getName().substring( 3 );
- name = decapitalise( prop );
+ prop = g.getName().substring(3);
+ name = decapitalise(prop);
propertyType = g.getReturnType();
- s = find( "set", prop, propertyType, type );
+ s = find("set", prop, propertyType, type);
}
this.g = g;
}
-
public Class<?> getRawType()
{
- return propertyType.isArray() ? propertyType.getComponentType() : propertyType;
+ return propertyType.isArray() ? propertyType.getComponentType()
+ : propertyType;
}
-
public Class<?> getPropertyType()
{
return propertyType;
}
-
public Method getReadMethod()
{
return g;
}
-
public Method getAddMethod() throws NoSuchMethodException
{
- if ( a == null )
+ if (a == null)
{
- throw new NoSuchMethodException( "No such method add" + prop );
+ throw new NoSuchMethodException("No such method add" + prop);
}
return a;
}
-
public Method getRemoveMethod() throws NoSuchMethodException
{
- if ( r == null )
+ if (r == null)
{
- throw new NoSuchMethodException( "No such method remove" + prop );
+ throw new NoSuchMethodException("No such method remove" + prop);
}
return r;
}
-
public Method getWriteMethod() throws NoSuchMethodException
{
- if ( s == null )
+ if (s == null)
{
- throw new NoSuchMethodException( "No such method set" + prop );
+ throw new NoSuchMethodException("No such method set" + prop);
}
return s;
}
-
@Override
public String toString()
{
return "PropertyAdapter[" + name + "]";
}
-
- private Method find( String prefix, String prop, Class<?> returnType, Class<?> type ) throws SecurityException,
- NoSuchMethodException
+ private Method find(String prefix, String prop, Class<?> returnType, Class<?> type)
+ throws SecurityException, NoSuchMethodException
{
String methodName = prefix + prop;
- if ( returnType.isArray() )
+ if (returnType.isArray())
{
Class<?> t = returnType.getComponentType();
- return type.getMethod( methodName, new Class[]
- { t } );
+ return type.getMethod(methodName, new Class[] { t });
}
- else if ( Iterable.class.isAssignableFrom( returnType ) )
+ else if (Iterable.class.isAssignableFrom(returnType))
{
Method f = null;
- for ( Method m : type.getMethods() )
+ for (Method m : type.getMethods())
{
- if ( m.getParameterTypes().length == 1 && m.getName().equals( methodName )
- && !IModelElement.class.isAssignableFrom( m.getParameterTypes()[0] ) )
+ if (m.getParameterTypes().length == 1
+ && m.getName().equals(methodName)
+ && !IModelElement.class.isAssignableFrom(m.getParameterTypes()[0]))
{
- if ( f == null )
+ if (f == null)
{
f = m;
}
else
{
- throw new NoSuchMethodException( "Found duplicate " + methodName );
+ throw new NoSuchMethodException("Found duplicate "
+ + methodName);
}
}
}
- if ( f == null )
+ if (f == null)
{
- throw new NoSuchMethodException( "No such method " + methodName );
+ throw new NoSuchMethodException("No such method " + methodName);
}
return f;
}
else
{
- return type.getMethod( methodName, new Class[]
- { returnType } );
+ return type.getMethod(methodName, new Class[] { returnType });
}
}
-
public String getName()
{
return name;
@@ -726,40 +691,33 @@
{
Method m;
-
- ChildAdapter( Method m )
+ ChildAdapter(Method m)
{
this.m = m;
}
-
public boolean isRequired()
{
- return m.isAnnotationPresent( Required.class );
+ return m.isAnnotationPresent(Required.class);
}
-
- boolean add( Object target, IModelElement element )
+ boolean add(Object target, IModelElement element)
{
return false;
}
-
abstract Class<? extends IModelElement> getType();
-
- boolean remove( Object target, IModelElement element )
+ boolean remove(Object target, IModelElement element)
{
return false;
}
-
- Collection<? extends IModelElement> members( Object target )
+ Collection<? extends IModelElement> members(Object target)
{
return Collections.emptyList();
}
-
@Override
public String toString()
{
@@ -769,67 +727,64 @@
private static class GetPropertyAdapter extends ChildAdapter
{
- GetPropertyAdapter( Method m )
+ GetPropertyAdapter(Method m)
{
- super( m );
+ super(m);
}
-
@Override
- Collection<? extends IModelElement> members( Object target )
+ Collection<? extends IModelElement> members(Object target)
{
- IModelElement member = ( IModelElement ) invoke( target, m, ZERO_ARGS );
- if ( member == null )
+ IModelElement member = (IModelElement) invoke(target, m, ZERO_ARGS);
+ if (member == null)
{
return Collections.emptyList();
}
else
{
- return Collections.<IModelElement> singleton( member );
+ return Collections.<IModelElement> singleton(member);
}
}
-
@SuppressWarnings("unchecked")
@Override
Class<? extends IModelElement> getType()
{
- return ( Class<? extends IModelElement> ) m.getReturnType();
+ return (Class<? extends IModelElement>) m.getReturnType();
}
}
private static class GetCollectionAdapter extends ChildAdapter
{
- public GetCollectionAdapter( Method m )
+ public GetCollectionAdapter(Method m)
{
- super( m );
+ super(m);
}
-
@SuppressWarnings("unchecked")
@Override
- Collection<? extends IModelElement> members( Object target )
+ Collection<? extends IModelElement> members(Object target)
{
- Collection members = ( Collection ) invoke( target, m, ZERO_ARGS );
- if ( members == null )
+ Collection members = (Collection) invoke(target, m, ZERO_ARGS);
+ if (members == null)
{
return Collections.emptyList();
}
else
{
- ArrayList<IModelElement> safe = new ArrayList<IModelElement>( members.size() );
- for ( Object o : members )
+ ArrayList<IModelElement> safe = new ArrayList<IModelElement>(
+ members.size());
+ for (Object o : members)
{
- if ( o instanceof IModelElement )
+ if (o instanceof IModelElement)
{
- safe.add( ( IModelElement ) o );
+ safe.add((IModelElement) o);
}
}
return safe;
}
}
-
@Override
Class<? extends IModelElement> getType()
{
@@ -841,50 +796,46 @@
private static class GetArrayAdapter extends ChildAdapter
{
- public GetArrayAdapter( Method m )
+ public GetArrayAdapter(Method m)
{
- super( m );
+ super(m);
}
-
@Override
- Collection<? extends IModelElement> members( Object target )
+ Collection<? extends IModelElement> members(Object target)
{
- IModelElement[] array = ( IModelElement[] ) invoke( target, m, ZERO_ARGS );
- if ( array == null || array.length == 0 )
+ IModelElement[] array = (IModelElement[]) invoke(target, m, ZERO_ARGS);
+ if (array == null || array.length == 0)
{
return Collections.emptyList();
}
else
{
- return ( Collection<? extends IModelElement> ) Arrays.asList( array );
+ return (Collection<? extends IModelElement>) Arrays.asList(array);
}
}
-
@SuppressWarnings("unchecked")
@Override
Class<? extends IModelElement> getType()
{
- return ( Class<? extends IModelElement> ) m.getReturnType().getComponentType();
+ return (Class<? extends IModelElement>) m.getReturnType().getComponentType();
}
}
private static class SetPropertyAdapter extends ChildAdapter
{
- public SetPropertyAdapter( Method m )
+ public SetPropertyAdapter(Method m)
{
- super( m );
+ super(m);
}
-
@Override
- boolean add( Object target, IModelElement element )
+ boolean add(Object target, IModelElement element)
{
- if ( m.getParameterTypes()[0].isAssignableFrom( element.getClass() ) )
+ if (m.getParameterTypes()[0].isAssignableFrom(element.getClass()))
{
- invoke( target, m, new Object[]
- { element } );
+ invoke(target, m, new Object[] { element });
return true;
}
else
@@ -893,14 +844,12 @@
}
}
-
@Override
- boolean remove( Object target, IModelElement element )
+ boolean remove(Object target, IModelElement element)
{
- if ( m.getParameterTypes()[0].isAssignableFrom( element.getClass() ) )
+ if (m.getParameterTypes()[0].isAssignableFrom(element.getClass()))
{
- invoke( target, m, new Object[]
- { null } );
+ invoke(target, m, new Object[] { null });
return true;
}
else
@@ -909,30 +858,27 @@
}
}
-
@SuppressWarnings("unchecked")
@Override
Class<? extends IModelElement> getType()
{
- return ( Class<? extends IModelElement> ) m.getParameterTypes()[0];
+ return (Class<? extends IModelElement>) m.getParameterTypes()[0];
}
}
private static class AddPropertyAdapter extends ChildAdapter
{
- public AddPropertyAdapter( Method m )
+ public AddPropertyAdapter(Method m)
{
- super( m );
+ super(m);
}
-
@Override
- boolean add( Object target, IModelElement element )
+ boolean add(Object target, IModelElement element)
{
- if ( m.getParameterTypes()[0].isAssignableFrom( element.getClass() ) )
+ if (m.getParameterTypes()[0].isAssignableFrom(element.getClass()))
{
- invoke( target, m, new Object[]
- { element } );
+ invoke(target, m, new Object[] { element });
return true;
}
else
@@ -941,31 +887,28 @@
}
}
-
@SuppressWarnings("unchecked")
@Override
Class<? extends IModelElement> getType()
{
- return ( Class<? extends IModelElement> ) m.getParameterTypes()[0];
+ return (Class<? extends IModelElement>) m.getParameterTypes()[0];
}
}
private static class RemovePropertyAdapter extends ChildAdapter
{
- public RemovePropertyAdapter( Method m )
+ public RemovePropertyAdapter(Method m)
{
- super( m );
+ super(m);
}
-
@Override
- boolean remove( Object target, IModelElement element )
+ boolean remove(Object target, IModelElement element)
{
- if ( m.getParameterTypes()[0].isAssignableFrom( element.getClass() ) )
+ if (m.getParameterTypes()[0].isAssignableFrom(element.getClass()))
{
- invoke( target, m, new Object[]
- { element } );
+ invoke(target, m, new Object[] { element });
return true;
}
else
@@ -974,18 +917,17 @@
}
}
-
@SuppressWarnings("unchecked")
@Override
Class<? extends IModelElement> getType()
{
- return ( Class<? extends IModelElement> ) m.getParameterTypes()[0];
+ return (Class<? extends IModelElement>) m.getParameterTypes()[0];
}
}
-
- private static boolean isModelArray( Class<?> returnType )
+ private static boolean isModelArray(Class<?> returnType)
{
- return returnType.isArray() && IModelElement.class.isAssignableFrom( returnType.getComponentType() );
+ return returnType.isArray()
+ && IModelElement.class.isAssignableFrom(returnType.getComponentType());
}
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/OverrideOptions.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/OverrideOptions.java
index 65b7387..66a60f9 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/OverrideOptions.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/OverrideOptions.java
@@ -19,11 +19,9 @@
package org.apache.felix.sigil.common.model;
-
import java.util.HashMap;
import java.util.Map;
-
/**
* @author dave
*
@@ -38,32 +36,29 @@
static
{
- for ( OverrideOptions option : OverrideOptions.values() )
+ for (OverrideOptions option : OverrideOptions.values())
{
- map.put( option.str.toLowerCase(), option );
+ map.put(option.str.toLowerCase(), option);
}
}
-
- private OverrideOptions( String str )
+ private OverrideOptions(String str)
{
this.str = str;
}
-
- public static OverrideOptions parse( String val )
+ public static OverrideOptions parse(String val)
{
- OverrideOptions option = map.get( val.toLowerCase() );
+ OverrideOptions option = map.get(val.toLowerCase());
- if ( option == null )
+ if (option == null)
{
- throw new IllegalArgumentException( "Invalid override value " + val );
+ throw new IllegalArgumentException("Invalid override value " + val);
}
return option;
}
-
@Override
public String toString()
{
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/annotations/Required.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/annotations/Required.java
index a5cc98a..592c21b 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/annotations/Required.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/annotations/Required.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.model.annotations;
-
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
@@ -27,7 +26,6 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-
@Inherited
@Documented
@Retention(RetentionPolicy.RUNTIME)
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/IBundleCapability.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/IBundleCapability.java
index 0053fd0..5765be9 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/IBundleCapability.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/IBundleCapability.java
@@ -24,5 +24,6 @@
public interface IBundleCapability extends ICapabilityModelElement
{
String getSymbolicName();
+
Version getVersion();
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ILibrary.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ILibrary.java
index b9b406d..d333fe1 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ILibrary.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ILibrary.java
@@ -19,33 +19,25 @@
package org.apache.felix.sigil.common.model.eclipse;
-
import java.util.Collection;
import org.apache.felix.sigil.common.model.IModelElement;
import org.apache.felix.sigil.common.model.osgi.IPackageImport;
import org.osgi.framework.Version;
-
public interface ILibrary extends IModelElement
{
String getName();
-
- void setName( String name );
-
+ void setName(String name);
Version getVersion();
+ void setVersion(Version version);
- void setVersion( Version version );
+ void addImport(IPackageImport pi);
-
- void addImport( IPackageImport pi );
-
-
- void removeImport( IPackageImport pi );
-
+ void removeImport(IPackageImport pi);
Collection<IPackageImport> getImports();
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ILibraryImport.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ILibraryImport.java
index 5e9b9d4..c1818f9 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ILibraryImport.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ILibraryImport.java
@@ -19,21 +19,16 @@
package org.apache.felix.sigil.common.model.eclipse;
-
import org.apache.felix.sigil.common.model.IModelElement;
import org.apache.felix.sigil.common.osgi.VersionRange;
-
public interface ILibraryImport extends IModelElement
{
String getLibraryName();
-
- void setLibraryName( String name );
-
+ void setLibraryName(String name);
VersionRange getVersions();
-
- void setVersions( VersionRange range );
+ void setVersions(VersionRange range);
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ISigilBundle.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ISigilBundle.java
index 812e3dd..5dcde31 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ISigilBundle.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/eclipse/ISigilBundle.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.model.eclipse;
-
import java.io.File;
import java.io.IOException;
import java.util.Collection;
@@ -32,94 +31,70 @@
import org.apache.felix.sigil.common.model.osgi.IPackageImport;
import org.apache.felix.sigil.common.model.osgi.IVersionedModelElement;
-
/**
* @author dave
*
*/
public interface ISigilBundle extends ICompoundModelElement, IVersionedModelElement
{
- void synchronize( IProgressMonitor monitor ) throws IOException;
-
+ void synchronize(IProgressMonitor monitor) throws IOException;
boolean isSynchronized();
-
IBundleModelElement getBundleInfo();
-
String getSymbolicName();
-
- void setBundleInfo( IBundleModelElement bundle );
-
+ void setBundleInfo(IBundleModelElement bundle);
// TODO rename this method...
- void addSourcePath( Resource path );
+ void addSourcePath(Resource path);
-
- void removeSourcePath( Resource path );
-
+ void removeSourcePath(Resource path);
Collection<Resource> getSourcePaths();
-
void clearSourcePaths();
-
Collection<String> getClasspathEntrys();
+ void addClasspathEntry(String encodedClasspath);
- void addClasspathEntry( String encodedClasspath );
-
-
- void removeClasspathEntry( String encodedClasspath );
-
+ void removeClasspathEntry(String encodedClasspath);
// XXX must be file due to SiglCore.isBundlePath
File getLocation();
-
// XXX must be file due to SiglCore.isBundlePath
- void setLocation( File location );
-
+ void setLocation(File location);
File getSourcePathLocation();
-
- void setSourcePathLocation( File location );
-
+ void setSourcePathLocation(File location);
String getSourceRootPath();
+ void setSourceRootPath(String location);
- void setSourceRootPath( String location );
-
-
- void setLicencePathLocation( File cacheSourceLocation );
-
+ void setLicencePathLocation(File cacheSourceLocation);
File getLicencePathLocation();
-
/**
* get package names included in bundle.
* Can contain wildcards e.g. org.foo.*
*/
Collection<String> getPackages();
-
/**
* remove package name from those included in bundle.
*/
- boolean removePackage( String pkg );
-
+ boolean removePackage(String pkg);
/**
* add package name to be included in bundle.
*/
- void addPackage( String pkg );
-
+ void addPackage(String pkg);
/**
* Attempt to find a package export that matches the given name or return null if none specified
@@ -127,16 +102,14 @@
* @param elementName
* @return
*/
- IPackageExport findExport( String elementName );
-
+ IPackageExport findExport(String elementName);
/**
* Attempt to find a package import that matches the given name or return null if none specified
* @param packageName
* @return
*/
- IPackageImport findImport( String packageName );
-
+ IPackageImport findImport(String packageName);
IBundleCapability getBundleCapability();
}
\ No newline at end of file
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IBundleModelElement.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IBundleModelElement.java
index cc17142..653f683 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IBundleModelElement.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IBundleModelElement.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.model.osgi;
-
import java.net.URI;
import java.util.Collection;
import java.util.Set;
@@ -29,129 +28,88 @@
import org.apache.felix.sigil.common.model.eclipse.ILibraryImport;
import org.osgi.framework.Version;
-
public interface IBundleModelElement extends INamedModelElement, ICompoundModelElement, IVersionedModelElement
{
String getActivator();
-
- void setActivator( String activator );
-
+ void setActivator(String activator);
String getCategory();
-
- void setCategory( String category );
-
+ void setCategory(String category);
String getContactAddress();
-
- void setContactAddress( String contactAddress );
-
+ void setContactAddress(String contactAddress);
String getCopyright();
-
- void setCopyright( String copyright );
-
+ void setCopyright(String copyright);
URI getDocURI();
-
- void setDocURI( URI docURI );
-
+ void setDocURI(URI docURI);
Collection<IPackageExport> getExports();
+ void addExport(IPackageExport packageExport);
- void addExport( IPackageExport packageExport );
-
-
- void removeExport( IPackageExport packageExport );
-
+ void removeExport(IPackageExport packageExport);
Collection<IPackageImport> getImports();
+ void addImport(IPackageImport packageImport);
- void addImport( IPackageImport packageImport );
-
-
- void removeImport( IPackageImport packageImport );
-
+ void removeImport(IPackageImport packageImport);
Collection<IRequiredBundle> getRequiredBundles();
+ void addRequiredBundle(IRequiredBundle bundle);
- void addRequiredBundle( IRequiredBundle bundle );
+ void removeRequiredBundle(IRequiredBundle bundle);
+ void addLibraryImport(ILibraryImport library);
- void removeRequiredBundle( IRequiredBundle bundle );
-
-
- void addLibraryImport( ILibraryImport library );
-
-
- void removeLibraryImport( ILibraryImport library );
-
+ void removeLibraryImport(ILibraryImport library);
Set<ILibraryImport> getLibraryImports();
-
URI getLicenseURI();
-
- void setLicenseURI( URI licenseURI );
-
+ void setLicenseURI(URI licenseURI);
URI getSourceLocation();
-
- void setSourceLocation( URI sourceLocation );
-
+ void setSourceLocation(URI sourceLocation);
String getSymbolicName();
-
- void setSymbolicName( String symbolicName );
-
+ void setSymbolicName(String symbolicName);
URI getUpdateLocation();
-
- void setUpdateLocation( URI updateLocation );
-
+ void setUpdateLocation(URI updateLocation);
String getVendor();
-
- void setVendor( String vendor );
-
+ void setVendor(String vendor);
Version getVersion();
+ void setVersion(Version version);
- void setVersion( Version version );
-
-
- void setDescription( String elementText );
-
+ void setDescription(String elementText);
String getDescription();
-
Collection<String> getClasspaths();
+ void addClasspath(String path);
- void addClasspath( String path );
+ void removeClasspath(String path);
-
- void removeClasspath( String path );
-
-
- void setFragmentHost( IRequiredBundle fragmentHost );
-
+ void setFragmentHost(IRequiredBundle fragmentHost);
IRequiredBundle getFragmentHost();
}
\ No newline at end of file
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageExport.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageExport.java
index 4ad7879..5f27980 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageExport.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageExport.java
@@ -19,26 +19,20 @@
package org.apache.felix.sigil.common.model.osgi;
-
import java.util.Collection;
import org.apache.felix.sigil.common.model.ICapabilityModelElement;
import org.osgi.framework.Version;
-
public interface IPackageExport extends IPackageModelElement, IVersionedModelElement, Comparable<IPackageExport>, ICapabilityModelElement
{
- void addUse( String uses );
+ void addUse(String uses);
-
- void removeUse( String uses );
-
+ void removeUse(String uses);
Collection<String> getUses();
-
- void setUses( Collection<String> asList );
-
+ void setUses(Collection<String> asList);
Version getRawVersion();
}
\ No newline at end of file
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageImport.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageImport.java
index 8c10cd5..2ddc6dd 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageImport.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageImport.java
@@ -19,12 +19,9 @@
package org.apache.felix.sigil.common.model.osgi;
-
import org.apache.felix.sigil.common.model.IRequirementModelElement;
-
-public interface IPackageImport extends IPackageModelElement, IVersionRangeModelElement, IRequirementModelElement,
- Comparable<IPackageImport>
+public interface IPackageImport extends IPackageModelElement, IVersionRangeModelElement, IRequirementModelElement, Comparable<IPackageImport>
{
/**
* indicates whether import is needed at compile-time.
@@ -33,9 +30,7 @@
*/
boolean isDependency();
-
- void setDependency( boolean dependency );
-
+ void setDependency(boolean dependency);
/**
* indicates whether import should be added to OSGi Package-Import header.
@@ -43,8 +38,7 @@
*/
OSGiImport getOSGiImport();
-
- void setOSGiImport( OSGiImport osgiImport );
+ void setOSGiImport(OSGiImport osgiImport);
enum OSGiImport
{
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageModelElement.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageModelElement.java
index c50b2c1..e236e4e 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageModelElement.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IPackageModelElement.java
@@ -19,16 +19,13 @@
package org.apache.felix.sigil.common.model.osgi;
-
import org.apache.felix.sigil.common.model.IModelElement;
-
public interface IPackageModelElement extends IModelElement
{
String getPackageName();
-
- void setPackageName( String packageName );
+ void setPackageName(String packageName);
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IRequiredBundle.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IRequiredBundle.java
index e425fdc..9c706a0 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IRequiredBundle.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IRequiredBundle.java
@@ -19,22 +19,17 @@
package org.apache.felix.sigil.common.model.osgi;
-
import org.apache.felix.sigil.common.model.IModelElement;
import org.apache.felix.sigil.common.model.IRequirementModelElement;
import org.apache.felix.sigil.common.osgi.VersionRange;
-
public interface IRequiredBundle extends IModelElement, IRequirementModelElement, Comparable<IRequiredBundle>
{
String getSymbolicName();
-
- void setSymbolicName( String symbolicName );
-
+ void setSymbolicName(String symbolicName);
VersionRange getVersions();
-
- void setVersions( VersionRange versions );
+ void setVersions(VersionRange versions);
}
\ No newline at end of file
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IVersionRangeModelElement.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IVersionRangeModelElement.java
index 60c1d6b..fe069ad 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IVersionRangeModelElement.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IVersionRangeModelElement.java
@@ -26,7 +26,6 @@
VersionRange getVersions();
-
- void setVersions( VersionRange version );
+ void setVersions(VersionRange version);
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IVersionedModelElement.java b/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IVersionedModelElement.java
index cfe75d2..8b88b13 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IVersionedModelElement.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/model/osgi/IVersionedModelElement.java
@@ -19,16 +19,13 @@
package org.apache.felix.sigil.common.model.osgi;
-
import org.osgi.framework.Version;
-
public interface IVersionedModelElement
{
Version getVersion();
-
- void setVersion( Version version );
+ void setVersion(Version version);
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/AbstractBundleRepository.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/AbstractBundleRepository.java
index dc397f0..c55e73b 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/AbstractBundleRepository.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/AbstractBundleRepository.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.repository;
-
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
@@ -39,89 +38,79 @@
import org.apache.felix.sigil.common.model.osgi.IPackageImport;
import org.apache.felix.sigil.common.model.osgi.IRequiredBundle;
-
public abstract class AbstractBundleRepository implements IBundleRepository
{
private final String id;
private final HashSet<IBundleRepositoryListener> listeners = new HashSet<IBundleRepositoryListener>();
-
- public AbstractBundleRepository( String id )
+ public AbstractBundleRepository(String id)
{
this.id = id;
}
+ public abstract void accept(IRepositoryVisitor visitor, int options);
- public abstract void accept( IRepositoryVisitor visitor, int options );
-
-
- public void addBundleRepositoryListener( IBundleRepositoryListener listener )
+ public void addBundleRepositoryListener(IBundleRepositoryListener listener)
{
- synchronized ( listeners )
+ synchronized (listeners)
{
- listeners.add( listener );
+ listeners.add(listener);
}
}
-
- public void removeBundleRepositoryListener( IBundleRepositoryListener listener )
+ public void removeBundleRepositoryListener(IBundleRepositoryListener listener)
{
- synchronized ( listeners )
+ synchronized (listeners)
{
- listeners.remove( listener );
+ listeners.remove(listener);
}
}
-
protected void notifyChange()
{
- for ( IBundleRepositoryListener l : listeners )
+ for (IBundleRepositoryListener l : listeners)
{
- l.notifyChange( this );
+ l.notifyChange(this);
}
}
-
public String getId()
{
return id;
}
-
- public void accept( IRepositoryVisitor visitor )
+ public void accept(IRepositoryVisitor visitor)
{
- accept( visitor, 0 );
+ accept(visitor, 0);
}
-
- public void writeOBR( OutputStream out ) throws IOException
+ public void writeOBR(OutputStream out) throws IOException
{
throw new UnsupportedOperationException();
}
-
- public Collection<ISigilBundle> findProviders( final ILibrary library, int options )
+ public Collection<ISigilBundle> findProviders(final ILibrary library, int options)
{
final ArrayList<ISigilBundle> found = new ArrayList<ISigilBundle>();
- final ILicensePolicy policy = findPolicy( library );
+ final ILicensePolicy policy = findPolicy(library);
IRepositoryVisitor visitor = new IRepositoryVisitor()
{
- public boolean visit( ISigilBundle bundle )
+ public boolean visit(ISigilBundle bundle)
{
- if ( policy.accept( bundle ) )
+ if (policy.accept(bundle))
{
IBundleModelElement info = bundle.getBundleInfo();
- for ( IPackageImport pi : library.getImports() )
+ for (IPackageImport pi : library.getImports())
{
- for ( IPackageExport e : info.getExports() )
+ for (IPackageExport e : info.getExports())
{
- if ( pi.getPackageName().equals( e.getPackageName() )
- && pi.getVersions().contains( e.getVersion() ) )
+ if (pi.getPackageName().equals(e.getPackageName())
+ && pi.getVersions().contains(e.getVersion()))
{
- found.add( bundle );
+ found.add(bundle);
break;
}
}
@@ -131,64 +120,63 @@
}
};
- accept( visitor, options );
+ accept(visitor, options);
return found;
}
-
- public Collection<ISigilBundle> findAllProviders( final IRequiredBundle req, int options )
+ public Collection<ISigilBundle> findAllProviders(final IRequiredBundle req,
+ int options)
{
final ArrayList<ISigilBundle> found = new ArrayList<ISigilBundle>();
- final ILicensePolicy policy = findPolicy( req );
+ final ILicensePolicy policy = findPolicy(req);
IRepositoryVisitor visitor = new IRepositoryVisitor()
{
- public boolean visit( ISigilBundle bundle )
+ public boolean visit(ISigilBundle bundle)
{
- if ( policy.accept( bundle ) )
+ if (policy.accept(bundle))
{
IBundleModelElement info = bundle.getBundleInfo();
- if ( req.getSymbolicName().equals( info.getSymbolicName() )
- && req.getVersions().contains( info.getVersion() ) )
+ if (req.getSymbolicName().equals(info.getSymbolicName())
+ && req.getVersions().contains(info.getVersion()))
{
- found.add( bundle );
+ found.add(bundle);
}
}
return true;
}
};
- accept( visitor, options );
+ accept(visitor, options);
return found;
}
-
- public Collection<ISigilBundle> findAllProviders( final IPackageImport pi, int options )
+ public Collection<ISigilBundle> findAllProviders(final IPackageImport pi, int options)
{
final ArrayList<ISigilBundle> found = new ArrayList<ISigilBundle>();
- final ILicensePolicy policy = findPolicy( pi );
+ final ILicensePolicy policy = findPolicy(pi);
IRepositoryVisitor visitor = new IRepositoryVisitor()
{
- public boolean visit( ISigilBundle bundle )
+ public boolean visit(ISigilBundle bundle)
{
- if ( policy.accept( bundle ) )
+ if (policy.accept(bundle))
{
IBundleModelElement info = bundle.getBundleInfo();
- if ( info != null )
+ if (info != null)
{
- for ( IPackageExport e : info.getExports() )
+ for (IPackageExport e : info.getExports())
{
- if ( pi.getPackageName().equals( e.getPackageName() ) )
+ if (pi.getPackageName().equals(e.getPackageName()))
{
- if ( pi.getVersions().contains( e.getVersion() ) )
+ if (pi.getVersions().contains(e.getVersion()))
{
- found.add( bundle );
+ found.add(bundle);
break;
}
}
@@ -200,31 +188,30 @@
};
- accept( visitor, options );
+ accept(visitor, options);
return found;
}
-
- public ISigilBundle findProvider( final IPackageImport pi, int options )
+ public ISigilBundle findProvider(final IPackageImport pi, int options)
{
final ArrayList<ISigilBundle> found = new ArrayList<ISigilBundle>();
- final ILicensePolicy policy = findPolicy( pi );
+ final ILicensePolicy policy = findPolicy(pi);
IRepositoryVisitor visitor = new IRepositoryVisitor()
{
- public boolean visit( ISigilBundle bundle )
+ public boolean visit(ISigilBundle bundle)
{
- if ( policy.accept( bundle ) )
+ if (policy.accept(bundle))
{
IBundleModelElement info = bundle.getBundleInfo();
- for ( IPackageExport e : info.getExports() )
+ for (IPackageExport e : info.getExports())
{
- if ( pi.getPackageName().equals( e.getPackageName() )
- && pi.getVersions().contains( e.getVersion() ) )
+ if (pi.getPackageName().equals(e.getPackageName())
+ && pi.getVersions().contains(e.getVersion()))
{
- found.add( bundle );
+ found.add(bundle);
return false;
}
}
@@ -234,30 +221,29 @@
};
- accept( visitor, options );
+ accept(visitor, options);
return found.isEmpty() ? null : found.iterator().next();
}
-
- public ISigilBundle findProvider( final IRequiredBundle req, int options )
+ public ISigilBundle findProvider(final IRequiredBundle req, int options)
{
final ArrayList<ISigilBundle> found = new ArrayList<ISigilBundle>();
- final ILicensePolicy policy = findPolicy( req );
+ final ILicensePolicy policy = findPolicy(req);
IRepositoryVisitor visitor = new IRepositoryVisitor()
{
- public boolean visit( ISigilBundle bundle )
+ public boolean visit(ISigilBundle bundle)
{
- if ( policy.accept( bundle ) )
+ if (policy.accept(bundle))
{
IBundleModelElement info = bundle.getBundleInfo();
- if ( req.getSymbolicName().equals( info.getSymbolicName() )
- && req.getVersions().contains( info.getVersion() ) )
+ if (req.getSymbolicName().equals(info.getSymbolicName())
+ && req.getVersions().contains(info.getVersion()))
{
- found.add( bundle );
+ found.add(bundle);
return false;
}
}
@@ -266,19 +252,17 @@
};
- accept( visitor, options );
+ accept(visitor, options);
return found.isEmpty() ? null : found.iterator().next();
}
-
- public IBundleModelElement buildBundleModelElement( Manifest mf )
+ public IBundleModelElement buildBundleModelElement(Manifest mf)
{
return ManifestUtil.buildBundleModelElement(mf);
}
-
- protected ILicensePolicy findPolicy( IModelElement elem )
+ protected ILicensePolicy findPolicy(IModelElement elem)
{
ILicenseManager man = BldCore.getLicenseManager();
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/AbstractRepositoryManager.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/AbstractRepositoryManager.java
index 73cf4a0..f856bf1 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/AbstractRepositoryManager.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/AbstractRepositoryManager.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.repository;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -38,7 +37,6 @@
import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
import org.apache.felix.sigil.common.repository.RepositoryChangeEvent.Type;
-
public abstract class AbstractRepositoryManager implements IRepositoryManager, IBundleRepositoryListener
{
@@ -51,16 +49,15 @@
private TreeMap<Integer, HashSet<IBundleRepository>> levelMap = new TreeMap<Integer, HashSet<IBundleRepository>>();
private int[] levels;
- private BundleResolver resolver = new BundleResolver( this );
+ private BundleResolver resolver = new BundleResolver(this);
private ArrayList<ILibrary> libraries = new ArrayList<ILibrary>();
-
public void initialise()
{
- synchronized ( repositories )
+ synchronized (repositories)
{
- if ( !initialised )
+ if (!initialised)
{
initialised = true;
loadRepositories();
@@ -68,136 +65,126 @@
}
}
-
protected abstract void loadRepositories();
-
- public void addRepositoryChangeListener( IRepositoryChangeListener listener )
+ public void addRepositoryChangeListener(IRepositoryChangeListener listener)
{
- synchronized ( listeners )
+ synchronized (listeners)
{
- listeners.add( listener );
+ listeners.add(listener);
}
}
-
- public void removeRepositoryChangeListener( IRepositoryChangeListener listener )
+ public void removeRepositoryChangeListener(IRepositoryChangeListener listener)
{
- synchronized ( listeners )
+ synchronized (listeners)
{
- listeners.remove( listener );
+ listeners.remove(listener);
}
}
-
- public void notifyChange( IBundleRepository repository )
+ public void notifyChange(IBundleRepository repository)
{
- notifyListeners( new RepositoryChangeEvent( repository, Type.CHANGED ) );
+ notifyListeners(new RepositoryChangeEvent(repository, Type.CHANGED));
}
-
- private void notifyListeners( RepositoryChangeEvent event )
+ private void notifyListeners(RepositoryChangeEvent event)
{
ArrayList<IRepositoryChangeListener> safe = null;
- synchronized ( listeners )
+ synchronized (listeners)
{
- safe = new ArrayList<IRepositoryChangeListener>( listeners );
+ safe = new ArrayList<IRepositoryChangeListener>(listeners);
}
- for ( IRepositoryChangeListener l : safe )
+ for (IRepositoryChangeListener l : safe)
{
- l.repositoryChanged( event );
+ l.repositoryChanged(event);
}
}
-
- protected void setRepositories( IBundleRepository[] repos )
+ protected void setRepositories(IBundleRepository[] repos)
{
- synchronized ( repositories )
+ synchronized (repositories)
{
repositories.clear();
order.clear();
levelMap.clear();
resetLevels();
- if ( repos != null )
+ if (repos != null)
{
- for ( int i = 0; i < repos.length; i++ )
+ for (int i = 0; i < repos.length; i++)
{
- addRepository( repos[i], i );
+ addRepository(repos[i], i);
}
}
}
}
-
- protected void addRepository( IBundleRepository rep, int level )
+ protected void addRepository(IBundleRepository rep, int level)
{
Type type = null;
- synchronized ( repositories )
+ synchronized (repositories)
{
- IBundleRepository old = repositories.put( rep.getId(), rep );
- if ( old == null )
+ IBundleRepository old = repositories.put(rep.getId(), rep);
+ if (old == null)
{
type = Type.ADDED;
- rep.addBundleRepositoryListener( this );
+ rep.addBundleRepositoryListener(this);
}
else
{
- old.removeBundleRepositoryListener( this );
+ old.removeBundleRepositoryListener(this);
type = Type.CHANGED;
- order.remove( old );
- clearLevel( rep );
+ order.remove(old);
+ clearLevel(rep);
}
- order.add( rep );
+ order.add(rep);
- HashSet<IBundleRepository> set = levelMap.get( level );
+ HashSet<IBundleRepository> set = levelMap.get(level);
- if ( set == null )
+ if (set == null)
{
set = new HashSet<IBundleRepository>();
- levelMap.put( level, set );
+ levelMap.put(level, set);
}
- set.add( rep );
+ set.add(rep);
resetLevels();
}
- notifyListeners( new RepositoryChangeEvent( rep, type ) );
+ notifyListeners(new RepositoryChangeEvent(rep, type));
}
-
- protected void removeRepository( IBundleRepository rep )
+ protected void removeRepository(IBundleRepository rep)
{
Type type = null;
- synchronized ( repositories )
+ synchronized (repositories)
{
- if ( repositories.remove( rep.getId() ) != null )
+ if (repositories.remove(rep.getId()) != null)
{
- order.remove( rep );
+ order.remove(rep);
type = Type.REMOVED;
- clearLevel( rep );
+ clearLevel(rep);
resetLevels();
}
}
- if ( type != null )
+ if (type != null)
{
- notifyListeners( new RepositoryChangeEvent( rep, type ) );
+ notifyListeners(new RepositoryChangeEvent(rep, type));
}
}
-
- private void clearLevel( IBundleRepository rep )
+ private void clearLevel(IBundleRepository rep)
{
- for ( Iterator<Map.Entry<Integer, HashSet<IBundleRepository>>> iter = levelMap.entrySet().iterator(); iter
- .hasNext(); )
+ for (Iterator<Map.Entry<Integer, HashSet<IBundleRepository>>> iter = levelMap.entrySet().iterator(); iter.hasNext();)
{
Map.Entry<Integer, HashSet<IBundleRepository>> e = iter.next();
- if ( e.getValue().remove( rep ) )
+ if (e.getValue().remove(rep))
{
- if ( e.getValue().isEmpty() )
+ if (e.getValue().isEmpty())
{
iter.remove();
}
@@ -206,35 +193,33 @@
}
}
-
public Collection<IBundleRepository> getRepositories()
{
initialise();
ArrayList<IBundleRepository> safe = null;
- synchronized ( repositories )
+ synchronized (repositories)
{
- safe = new ArrayList<IBundleRepository>( order );
+ safe = new ArrayList<IBundleRepository>(order);
}
return safe;
}
-
private void resetLevels()
{
- Collections.sort( order, new Comparator<IBundleRepository>()
+ Collections.sort(order, new Comparator<IBundleRepository>()
{
- public int compare( IBundleRepository o1, IBundleRepository o2 )
+ public int compare(IBundleRepository o1, IBundleRepository o2)
{
- int l1 = findLevel( o1 );
- int l2 = findLevel( o2 );
+ int l1 = findLevel(o1);
+ int l2 = findLevel(o2);
- if ( l1 < l2 )
+ if (l1 < l2)
{
return -1;
}
- else if ( l1 > l2 )
+ else if (l1 > l2)
{
return 1;
}
@@ -244,90 +229,83 @@
}
}
-
- private int findLevel( IBundleRepository rep )
+ private int findLevel(IBundleRepository rep)
{
- for ( Map.Entry<Integer, HashSet<IBundleRepository>> e : levelMap.entrySet() )
+ for (Map.Entry<Integer, HashSet<IBundleRepository>> e : levelMap.entrySet())
{
- if ( e.getValue().contains( rep ) )
+ if (e.getValue().contains(rep))
{
return e.getKey();
}
}
throw new IllegalStateException();
}
- } );
+ });
levels = new int[levelMap.size()];
int i = 0;
- for ( Integer v : levelMap.keySet() )
+ for (Integer v : levelMap.keySet())
{
levels[i++] = v;
}
}
-
public int[] getPriorityLevels()
{
initialise();
- synchronized ( repositories )
+ synchronized (repositories)
{
return levels;
}
}
-
- public Collection<IBundleRepository> getRepositories( int priorityLevel )
+ public Collection<IBundleRepository> getRepositories(int priorityLevel)
{
initialise();
List<IBundleRepository> found = null;
- synchronized ( repositories )
+ synchronized (repositories)
{
- HashSet<IBundleRepository> b = levelMap.get( priorityLevel );
- if ( b == null )
+ HashSet<IBundleRepository> b = levelMap.get(priorityLevel);
+ if (b == null)
{
found = Collections.emptyList();
}
else
{
- found = new ArrayList<IBundleRepository>( b );
+ found = new ArrayList<IBundleRepository>(b);
}
}
return found;
}
-
- public void addLibrary( ILibrary library )
+ public void addLibrary(ILibrary library)
{
- synchronized ( libraries )
+ synchronized (libraries)
{
- libraries.add( library );
+ libraries.add(library);
}
}
-
- public void removeLibrary( ILibrary library )
+ public void removeLibrary(ILibrary library)
{
- synchronized ( libraries )
+ synchronized (libraries)
{
- libraries.remove( library );
+ libraries.remove(library);
}
}
-
public Collection<ILibrary> getLibraries()
{
- synchronized ( libraries )
+ synchronized (libraries)
{
return libraries;
}
}
-
- public ILibrary resolveLibrary( final ILibraryImport l )
+ public ILibrary resolveLibrary(final ILibraryImport l)
{
- final ArrayList<ILibrary> found = new ArrayList<ILibrary>( 1 );
+ final ArrayList<ILibrary> found = new ArrayList<ILibrary>(1);
//ISigilProjectModel p = l.getAncestor(ISigilProjectModel.class);
//
//IModelWalker w = new IModelWalker() {
@@ -344,63 +322,62 @@
//p.visit( w );
//if ( found.isEmpty() ) { // no project specific libraries - check workspace definitions
- synchronized ( libraries )
+ synchronized (libraries)
{
- for ( ILibrary lib : libraries )
+ for (ILibrary lib : libraries)
{
- if ( l.getLibraryName().equals( lib.getName() ) && l.getVersions().contains( lib.getVersion() ) )
+ if (l.getLibraryName().equals(lib.getName())
+ && l.getVersions().contains(lib.getVersion()))
{
- updateLibrary( l, lib, found );
+ updateLibrary(l, lib, found);
}
}
}
//}
- return found.isEmpty() ? null : found.get( 0 );
+ return found.isEmpty() ? null : found.get(0);
}
-
- protected void updateLibrary( ILibraryImport li, ILibrary l, ArrayList<ILibrary> found )
+ protected void updateLibrary(ILibraryImport li, ILibrary l, ArrayList<ILibrary> found)
{
- if ( li.getLibraryName().equals( l.getName() ) && li.getVersions().contains( l.getVersion() ) )
+ if (li.getLibraryName().equals(l.getName())
+ && li.getVersions().contains(l.getVersion()))
{
- if ( found.isEmpty() )
+ if (found.isEmpty())
{
- found.add( l );
+ found.add(l);
}
else
{
- ILibrary c = found.get( 0 );
- if ( l.getVersion().compareTo( c.getVersion() ) > 0 )
+ ILibrary c = found.get(0);
+ if (l.getVersion().compareTo(c.getVersion()) > 0)
{
- found.remove( 0 );
- found.add( l );
+ found.remove(0);
+ found.add(l);
}
}
}
}
-
public IBundleResolver getBundleResolver()
{
return resolver;
}
-
- public void visit( final IModelWalker walker )
+ public void visit(final IModelWalker walker)
{
- for ( IBundleRepository rep : getRepositories() )
+ for (IBundleRepository rep : getRepositories())
{
IRepositoryVisitor wrapper = new IRepositoryVisitor()
{
- public boolean visit( ISigilBundle bundle )
+ public boolean visit(ISigilBundle bundle)
{
- bundle.visit( walker );
+ bundle.visit(walker);
// return true as still want to visit other bundles
return true;
}
};
- rep.accept( wrapper );
+ rep.accept(wrapper);
}
}
}
\ No newline at end of file
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IBundleRepository.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IBundleRepository.java
index ed21a0b..227f662 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IBundleRepository.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IBundleRepository.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.repository;
-
import java.io.IOException;
import java.io.OutputStream;
import java.util.Collection;
@@ -29,46 +28,33 @@
import org.apache.felix.sigil.common.model.osgi.IPackageImport;
import org.apache.felix.sigil.common.model.osgi.IRequiredBundle;
-
public interface IBundleRepository
{
static final int NORMAL_PRIORITY = 0;
static final int MAXIMUM_PRIORITY = -500;
static final int MINIMUM_PRIORITY = 500;
-
String getId();
+ void addBundleRepositoryListener(IBundleRepositoryListener listener);
- void addBundleRepositoryListener( IBundleRepositoryListener listener );
+ void removeBundleRepositoryListener(IBundleRepositoryListener listener);
+ void accept(IRepositoryVisitor visitor);
- void removeBundleRepositoryListener( IBundleRepositoryListener listener );
+ void accept(IRepositoryVisitor visitor, int options);
-
- void accept( IRepositoryVisitor visitor );
-
-
- void accept( IRepositoryVisitor visitor, int options );
-
-
- void writeOBR( OutputStream out ) throws IOException;
-
+ void writeOBR(OutputStream out) throws IOException;
void refresh();
+ ISigilBundle findProvider(IPackageImport packageImport, int options);
- ISigilBundle findProvider( IPackageImport packageImport, int options );
+ ISigilBundle findProvider(IRequiredBundle bundle, int options);
+ Collection<ISigilBundle> findAllProviders(IRequiredBundle bundle, int options);
- ISigilBundle findProvider( IRequiredBundle bundle, int options );
+ Collection<ISigilBundle> findAllProviders(IPackageImport packageImport, int options);
-
- Collection<ISigilBundle> findAllProviders( IRequiredBundle bundle, int options );
-
-
- Collection<ISigilBundle> findAllProviders( IPackageImport packageImport, int options );
-
-
- Collection<ISigilBundle> findProviders( ILibrary library, int options );
+ Collection<ISigilBundle> findProviders(ILibrary library, int options);
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IBundleRepositoryListener.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IBundleRepositoryListener.java
index df7b208..b63bb5f 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IBundleRepositoryListener.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IBundleRepositoryListener.java
@@ -19,8 +19,7 @@
package org.apache.felix.sigil.common.repository;
-
public interface IBundleRepositoryListener
{
- void notifyChange( IBundleRepository repository );
+ void notifyChange(IBundleRepository repository);
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IBundleResolver.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IBundleResolver.java
index 64a0492..c60d6b5 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IBundleResolver.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IBundleResolver.java
@@ -19,12 +19,10 @@
package org.apache.felix.sigil.common.repository;
-
import org.apache.felix.sigil.common.model.IModelElement;
-
public interface IBundleResolver
{
- IResolution resolve( IModelElement element, ResolutionConfig config, IResolutionMonitor monitor )
- throws ResolutionException;
+ IResolution resolve(IModelElement element, ResolutionConfig config,
+ IResolutionMonitor monitor) throws ResolutionException;
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IProviderChangeListener.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IProviderChangeListener.java
index 0f3e32f..38e313c 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IProviderChangeListener.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IProviderChangeListener.java
@@ -19,8 +19,7 @@
package org.apache.felix.sigil.common.repository;
-
public interface IProviderChangeListener
{
- void notifyChange( IRepositoryProvider provider );
+ void notifyChange(IRepositoryProvider provider);
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryChangeListener.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryChangeListener.java
index e02445c..b70161d 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryChangeListener.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryChangeListener.java
@@ -19,8 +19,7 @@
package org.apache.felix.sigil.common.repository;
-
public interface IRepositoryChangeListener
{
- void repositoryChanged( RepositoryChangeEvent event );
+ void repositoryChanged(RepositoryChangeEvent event);
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryManager.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryManager.java
index 496ef0f..53c2f69 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryManager.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryManager.java
@@ -19,45 +19,33 @@
package org.apache.felix.sigil.common.repository;
-
import java.util.Collection;
import org.apache.felix.sigil.common.model.IModelWalker;
import org.apache.felix.sigil.common.model.eclipse.ILibrary;
import org.apache.felix.sigil.common.model.eclipse.ILibraryImport;
-
public interface IRepositoryManager
{
- void addRepositoryChangeListener( IRepositoryChangeListener listener );
+ void addRepositoryChangeListener(IRepositoryChangeListener listener);
-
- void removeRepositoryChangeListener( IRepositoryChangeListener listener );
-
+ void removeRepositoryChangeListener(IRepositoryChangeListener listener);
Collection<IBundleRepository> getRepositories();
+ Collection<IBundleRepository> getRepositories(int level);
- Collection<IBundleRepository> getRepositories( int level );
+ void addLibrary(ILibrary library);
-
- void addLibrary( ILibrary library );
-
-
- void removeLibrary( ILibrary library );
-
+ void removeLibrary(ILibrary library);
Collection<ILibrary> getLibraries();
-
- ILibrary resolveLibrary( final ILibraryImport l );
-
+ ILibrary resolveLibrary(final ILibraryImport l);
IBundleResolver getBundleResolver();
-
int[] getPriorityLevels();
-
- void visit( IModelWalker modelWalker );
+ void visit(IModelWalker modelWalker);
}
\ No newline at end of file
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryProvider.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryProvider.java
index 394753d..dbc462e 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryProvider.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryProvider.java
@@ -19,11 +19,10 @@
package org.apache.felix.sigil.common.repository;
-
import java.util.Properties;
-
public interface IRepositoryProvider
{
- IBundleRepository createRepository( String id, Properties properties ) throws RepositoryException;
+ IBundleRepository createRepository(String id, Properties properties)
+ throws RepositoryException;
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryVisitor.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryVisitor.java
index 22c86d2..0f59173 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryVisitor.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IRepositoryVisitor.java
@@ -19,10 +19,8 @@
package org.apache.felix.sigil.common.repository;
-
import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
-
public interface IRepositoryVisitor
{
/**
@@ -31,5 +29,5 @@
* @param bundle
* @return
*/
- boolean visit( ISigilBundle bundle );
+ boolean visit(ISigilBundle bundle);
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IResolution.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IResolution.java
index edc07db..9a63899 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IResolution.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IResolution.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.repository;
-
import java.util.List;
import java.util.Set;
@@ -27,20 +26,15 @@
import org.apache.felix.sigil.common.model.IModelElement;
import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
-
public interface IResolution
{
Set<ISigilBundle> getBundles();
+ ISigilBundle getProvider(IModelElement requirement);
- ISigilBundle getProvider( IModelElement requirement );
+ List<IModelElement> getMatchedRequirements(ISigilBundle bundle);
-
- List<IModelElement> getMatchedRequirements( ISigilBundle bundle );
-
-
- void synchronize( IProgressMonitor monitor );
-
+ void synchronize(IProgressMonitor monitor);
boolean isSynchronized();
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IResolutionMonitor.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IResolutionMonitor.java
index 8beaa34..a866611 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/IResolutionMonitor.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/IResolutionMonitor.java
@@ -19,18 +19,14 @@
package org.apache.felix.sigil.common.repository;
-
import org.apache.felix.sigil.common.model.IModelElement;
import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
-
public interface IResolutionMonitor
{
boolean isCanceled();
+ void startResolution(IModelElement requirement);
- void startResolution( IModelElement requirement );
-
-
- void endResolution( IModelElement requirement, ISigilBundle sigilBundle );
+ void endResolution(IModelElement requirement, ISigilBundle sigilBundle);
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/RepositoryChangeEvent.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/RepositoryChangeEvent.java
index 7d1c2d8..d1be228 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/RepositoryChangeEvent.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/RepositoryChangeEvent.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.repository;
-
public class RepositoryChangeEvent
{
public static enum Type
@@ -30,20 +29,17 @@
private Type type;
private IBundleRepository repository;
-
- public RepositoryChangeEvent( IBundleRepository repository, Type type )
+ public RepositoryChangeEvent(IBundleRepository repository, Type type)
{
this.repository = repository;
this.type = type;
}
-
public Type getType()
{
return type;
}
-
public IBundleRepository getRepository()
{
return repository;
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/RepositoryException.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/RepositoryException.java
index cfa4655..ccd39d3 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/RepositoryException.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/RepositoryException.java
@@ -19,28 +19,24 @@
package org.apache.felix.sigil.common.repository;
-
public class RepositoryException extends Exception
{
private static final long serialVersionUID = 1L;
-
- public RepositoryException( String msg, Throwable cause )
+ public RepositoryException(String msg, Throwable cause)
{
- super( msg, cause );
+ super(msg, cause);
}
-
- public RepositoryException( String message )
+ public RepositoryException(String message)
{
- super( message );
+ super(message);
}
-
- public RepositoryException( Throwable cause )
+ public RepositoryException(Throwable cause)
{
- super( cause );
+ super(cause);
}
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/ResolutionConfig.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/ResolutionConfig.java
index 275d0ae..35d6c2a 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/ResolutionConfig.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/ResolutionConfig.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.repository;
-
public class ResolutionConfig
{
private int options;
@@ -33,52 +32,44 @@
public static final int LOCAL_ONLY = 16;
public static final int COMPILE_TIME = 32;
-
public ResolutionConfig()
{
- this( INCLUDE_DEPENDENTS );
+ this(INCLUDE_DEPENDENTS);
}
-
- public ResolutionConfig( int options )
+ public ResolutionConfig(int options)
{
this.options = options;
}
-
public int getOptions()
{
return options;
}
-
public boolean isDependents()
{
- return ( options & INCLUDE_DEPENDENTS ) != 0;
+ return (options & INCLUDE_DEPENDENTS) != 0;
}
-
public boolean isIgnoreErrors()
{
- return ( options & IGNORE_ERRORS ) != 0;
+ return (options & IGNORE_ERRORS) != 0;
}
-
public boolean isOptional()
{
- return ( options & INCLUDE_OPTIONAL ) != 0;
+ return (options & INCLUDE_OPTIONAL) != 0;
}
-
public boolean isCalculateLocalDependencies()
{
// TODO Auto-generated method stub
return false;
}
-
public boolean isCompileTime()
{
- return ( options & COMPILE_TIME ) != 0;
+ return (options & COMPILE_TIME) != 0;
}
}
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/ResolutionException.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/ResolutionException.java
index 1da491a..c68b9e1 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/ResolutionException.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/ResolutionException.java
@@ -19,10 +19,8 @@
package org.apache.felix.sigil.common.repository;
-
import org.apache.felix.sigil.common.model.IModelElement;
-
public class ResolutionException extends Exception
{
@@ -30,48 +28,42 @@
private IModelElement[] parsed;
-
- public ResolutionException( String message, Throwable cause )
+ public ResolutionException(String message, Throwable cause)
{
- super( message, cause );
+ super(message, cause);
}
-
- public ResolutionException( String message )
+ public ResolutionException(String message)
{
- super( message );
+ super(message);
}
-
- public ResolutionException( Throwable cause )
+ public ResolutionException(Throwable cause)
{
- super( cause );
+ super(cause);
}
-
- public ResolutionException( IModelElement root, IModelElement[] parsed )
+ public ResolutionException(IModelElement root, IModelElement[] parsed)
{
- super( buildMessage( root, parsed ) );
+ super(buildMessage(root, parsed));
this.parsed = parsed;
}
-
- private static String buildMessage( IModelElement root, IModelElement[] parsed )
+ private static String buildMessage(IModelElement root, IModelElement[] parsed)
{
StringBuilder b = new StringBuilder();
- b.append( "Failed to resolve " );
- b.append( root );
+ b.append("Failed to resolve ");
+ b.append(root);
- if ( parsed.length > 0 )
+ if (parsed.length > 0)
{
- b.append( " due to missing provider for " );
- b.append( parsed[parsed.length - 1] );
+ b.append(" due to missing provider for ");
+ b.append(parsed[parsed.length - 1]);
}
return b.toString();
}
-
public IModelElement[] getParsed()
{
return parsed;
diff --git a/sigil/common/core/src/org/apache/felix/sigil/common/repository/ResolutionMonitorAdapter.java b/sigil/common/core/src/org/apache/felix/sigil/common/repository/ResolutionMonitorAdapter.java
index f31dc91..9e5db18 100644
--- a/sigil/common/core/src/org/apache/felix/sigil/common/repository/ResolutionMonitorAdapter.java
+++ b/sigil/common/core/src/org/apache/felix/sigil/common/repository/ResolutionMonitorAdapter.java
@@ -19,39 +19,34 @@
package org.apache.felix.sigil.common.repository;
-
import org.eclipse.core.runtime.IProgressMonitor;
import org.apache.felix.sigil.common.model.IModelElement;
import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
-
public class ResolutionMonitorAdapter implements IResolutionMonitor
{
private IProgressMonitor monitor;
-
- public ResolutionMonitorAdapter( IProgressMonitor monitor )
+ public ResolutionMonitorAdapter(IProgressMonitor monitor)
{
this.monitor = monitor;
}
-
public boolean isCanceled()
{
return monitor.isCanceled();
}
-
- public void startResolution( IModelElement requirement )
+ public void startResolution(IModelElement requirement)
{
- monitor.subTask( "Resolving " + requirement );
+ monitor.subTask("Resolving " + requirement);
}
-
- public void endResolution( IModelElement requirement, ISigilBundle provider )
+ public void endResolution(IModelElement requirement, ISigilBundle provider)
{
- monitor.subTask( ( provider == null ? "Failed to resolve " : "Resolved " ) + requirement );
+ monitor.subTask((provider == null ? "Failed to resolve " : "Resolved ")
+ + requirement);
}
}
diff --git a/sigil/common/junit/src/org/apache/felix/sigil/common/junit/AbstractSigilTestCase.java b/sigil/common/junit/src/org/apache/felix/sigil/common/junit/AbstractSigilTestCase.java
index 60a0cb0..93453a0 100644
--- a/sigil/common/junit/src/org/apache/felix/sigil/common/junit/AbstractSigilTestCase.java
+++ b/sigil/common/junit/src/org/apache/felix/sigil/common/junit/AbstractSigilTestCase.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.junit;
-
import java.lang.reflect.Method;
import java.util.LinkedList;
import java.util.List;
@@ -31,7 +30,6 @@
import junit.framework.TestCase;
-
public abstract class AbstractSigilTestCase extends TestCase
{
@@ -39,91 +37,79 @@
private BundleContext ctx;
-
- public void setBundleContext( BundleContext ctx )
+ public void setBundleContext(BundleContext ctx)
{
this.ctx = ctx;
}
-
protected BundleContext getBundleContext()
{
return ctx;
}
-
@Override
protected void setUp()
{
- for ( Class<?> c : getReferences() )
+ for (Class<?> c : getReferences())
{
- ServiceTracker t = createBindTracker( c );
+ ServiceTracker t = createBindTracker(c);
t.open();
- trackers.add( t );
+ trackers.add(t);
}
}
-
@Override
protected void tearDown()
{
- for ( ServiceTracker t : trackers )
+ for (ServiceTracker t : trackers)
{
t.close();
}
trackers.clear();
}
-
- private ServiceTracker createBindTracker( final Class<?> c )
+ private ServiceTracker createBindTracker(final Class<?> c)
{
- return new ServiceTracker( ctx, c.getName(), new ServiceTrackerCustomizer()
+ return new ServiceTracker(ctx, c.getName(), new ServiceTrackerCustomizer()
{
- public Object addingService( ServiceReference reference )
+ public Object addingService(ServiceReference reference)
{
- Object o = ctx.getService( reference );
- Method m = getBindMethod( c );
- if ( m != null )
- invoke( m, o );
+ Object o = ctx.getService(reference);
+ Method m = getBindMethod(c);
+ if (m != null)
+ invoke(m, o);
return o;
}
-
- public void modifiedService( ServiceReference reference, Object service )
+ public void modifiedService(ServiceReference reference, Object service)
{
}
-
- public void removedService( ServiceReference reference, Object service )
+ public void removedService(ServiceReference reference, Object service)
{
- Method m = getUnbindMethod( c );
- if ( m != null )
- invoke( m, service );
- ctx.ungetService( reference );
+ Method m = getUnbindMethod(c);
+ if (m != null)
+ invoke(m, service);
+ ctx.ungetService(reference);
}
- } );
+ });
}
-
- private void invoke( Method m, Object o )
+ private void invoke(Method m, Object o)
{
try
{
- m.invoke( this, new Object[]
- { o } );
+ m.invoke(this, new Object[] { o });
}
- catch ( Exception e )
+ catch (Exception e)
{
- throw new IllegalStateException( "Failed to invoke binding method " + m, e );
+ throw new IllegalStateException("Failed to invoke binding method " + m, e);
}
}
-
protected abstract Class<?>[] getReferences();
+ protected abstract Method getBindMethod(Class<?> clazz);
- protected abstract Method getBindMethod( Class<?> clazz );
-
-
- protected abstract Method getUnbindMethod( Class<?> clazz );
+ protected abstract Method getUnbindMethod(Class<?> clazz);
}
diff --git a/sigil/common/junit/src/org/apache/felix/sigil/common/junit/ReflectiveSigilTestCase.java b/sigil/common/junit/src/org/apache/felix/sigil/common/junit/ReflectiveSigilTestCase.java
index 7d26a59..96743c3 100644
--- a/sigil/common/junit/src/org/apache/felix/sigil/common/junit/ReflectiveSigilTestCase.java
+++ b/sigil/common/junit/src/org/apache/felix/sigil/common/junit/ReflectiveSigilTestCase.java
@@ -19,13 +19,11 @@
package org.apache.felix.sigil.common.junit;
-
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
-
public abstract class ReflectiveSigilTestCase extends AbstractSigilTestCase
{
@@ -33,7 +31,6 @@
private Map<Class<?>, Method> bindMethods;
private Map<Class<?>, Method> unbindMethods;
-
@Override
protected Class<?>[] getReferences()
{
@@ -41,75 +38,70 @@
return references;
}
-
@Override
- protected Method getBindMethod( Class<?> clazz )
+ protected Method getBindMethod(Class<?> clazz)
{
- return bindMethods.get( clazz );
+ return bindMethods.get(clazz);
}
-
@Override
- protected Method getUnbindMethod( Class<?> clazz )
+ protected Method getUnbindMethod(Class<?> clazz)
{
- return unbindMethods.get( clazz );
+ return unbindMethods.get(clazz);
}
-
private void introspect()
{
- if ( references == null )
+ if (references == null)
{
- bindMethods = findBindMethods( getClass(), "set", "add" );
- unbindMethods = findBindMethods( getClass(), "set", "remove" );
+ bindMethods = findBindMethods(getClass(), "set", "add");
+ unbindMethods = findBindMethods(getClass(), "set", "remove");
HashSet<Class<?>> refs = new HashSet<Class<?>>();
- refs.addAll( bindMethods.keySet() );
- refs.addAll( unbindMethods.keySet() );
- references = refs.toArray( new Class<?>[refs.size()] );
+ refs.addAll(bindMethods.keySet());
+ refs.addAll(unbindMethods.keySet());
+ references = refs.toArray(new Class<?>[refs.size()]);
}
}
-
- private static Map<Class<?>, Method> findBindMethods( Class<?> clazz, String... prefix )
+ private static Map<Class<?>, Method> findBindMethods(Class<?> clazz, String... prefix)
{
HashMap<Class<?>, Method> found = new HashMap<Class<?>, Method>();
- checkDeclaredMethods( clazz, found, prefix );
+ checkDeclaredMethods(clazz, found, prefix);
return found;
}
-
- private static void checkDeclaredMethods( Class<?> clazz, Map<Class<?>, Method> found, String... prefix )
+ private static void checkDeclaredMethods(Class<?> clazz, Map<Class<?>, Method> found,
+ String... prefix)
{
- for ( Method m : clazz.getDeclaredMethods() )
+ for (Method m : clazz.getDeclaredMethods())
{
- if ( isMethodPrefixed( m, prefix ) && isBindSignature( m ) )
+ if (isMethodPrefixed(m, prefix) && isBindSignature(m))
{
- found.put( m.getParameterTypes()[0], m );
+ found.put(m.getParameterTypes()[0], m);
}
}
Class<?> sup = clazz.getSuperclass();
- if ( sup != null && sup != Object.class )
+ if (sup != null && sup != Object.class)
{
- checkDeclaredMethods( sup, found, prefix );
+ checkDeclaredMethods(sup, found, prefix);
}
- for ( Class<?> i : clazz.getInterfaces() )
+ for (Class<?> i : clazz.getInterfaces())
{
- checkDeclaredMethods( i, found, prefix );
+ checkDeclaredMethods(i, found, prefix);
}
}
-
- private static boolean isMethodPrefixed( Method m, String... prefix )
+ private static boolean isMethodPrefixed(Method m, String... prefix)
{
String n = m.getName();
- for ( String p : prefix )
+ for (String p : prefix)
{
- if ( n.startsWith( p ) && n.length() > p.length() )
+ if (n.startsWith(p) && n.length() > p.length())
{
return true;
}
@@ -117,8 +109,7 @@
return false;
}
-
- private static boolean isBindSignature( Method m )
+ private static boolean isBindSignature(Method m)
{
return m.getReturnType() == Void.TYPE && m.getParameterTypes().length == 1;
}
diff --git a/sigil/common/junit/src/org/apache/felix/sigil/common/junit/activator/Activator.java b/sigil/common/junit/src/org/apache/felix/sigil/common/junit/activator/Activator.java
index 44ddc8b..a34511c 100644
--- a/sigil/common/junit/src/org/apache/felix/sigil/common/junit/activator/Activator.java
+++ b/sigil/common/junit/src/org/apache/felix/sigil/common/junit/activator/Activator.java
@@ -19,14 +19,12 @@
package org.apache.felix.sigil.common.junit.activator;
-
import org.apache.felix.sigil.common.junit.server.JUnitService;
import org.apache.felix.sigil.common.junit.server.impl.JUnitServiceFactory;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
-
/**
* @author dave
*/
@@ -35,20 +33,18 @@
private ServiceRegistration reg;
private JUnitServiceFactory service;
-
- public void start( final BundleContext ctx )
+ public void start(final BundleContext ctx)
{
service = new JUnitServiceFactory();
- service.start( ctx );
- reg = ctx.registerService( JUnitService.class.getName(), service, null );
+ service.start(ctx);
+ reg = ctx.registerService(JUnitService.class.getName(), service, null);
}
-
- public void stop( BundleContext ctx )
+ public void stop(BundleContext ctx)
{
reg.unregister();
reg = null;
- service.stop( ctx );
+ service.stop(ctx);
service = null;
}
}
diff --git a/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/JUnitService.java b/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/JUnitService.java
index ed3271f..0d73a50 100644
--- a/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/JUnitService.java
+++ b/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/JUnitService.java
@@ -19,21 +19,17 @@
package org.apache.felix.sigil.common.junit.server;
-
import java.util.Set;
import org.osgi.framework.BundleContext;
import junit.framework.TestSuite;
-
public interface JUnitService
{
Set<String> getTests();
+ TestSuite createTest(String test);
- TestSuite createTest( String test );
-
-
- TestSuite createTest( String test, BundleContext ctx );
+ TestSuite createTest(String test, BundleContext ctx);
}
\ No newline at end of file
diff --git a/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/impl/JUnitServiceFactory.java b/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/impl/JUnitServiceFactory.java
index 6af3f6c..838d30a 100644
--- a/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/impl/JUnitServiceFactory.java
+++ b/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/impl/JUnitServiceFactory.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.junit.server.impl;
-
import java.util.HashMap;
import java.util.Set;
import java.util.TreeSet;
@@ -32,69 +31,60 @@
import org.osgi.framework.ServiceFactory;
import org.osgi.framework.ServiceRegistration;
-
public class JUnitServiceFactory implements ServiceFactory
{
private HashMap<String, Class<? extends TestCase>> tests = new HashMap<String, Class<? extends TestCase>>();
private TestClassListener listener;
-
- public void start( BundleContext ctx )
+ public void start(BundleContext ctx)
{
- listener = new TestClassListener( this );
- ctx.addBundleListener( listener );
+ listener = new TestClassListener(this);
+ ctx.addBundleListener(listener);
//listener.index(ctx.getBundle());
- for ( Bundle b : ctx.getBundles() )
+ for (Bundle b : ctx.getBundles())
{
- if ( b.getState() == Bundle.RESOLVED )
+ if (b.getState() == Bundle.RESOLVED)
{
- listener.index( b );
+ listener.index(b);
}
}
}
-
- public void stop( BundleContext ctx )
+ public void stop(BundleContext ctx)
{
- ctx.removeBundleListener( listener );
+ ctx.removeBundleListener(listener);
listener = null;
}
-
- public Object getService( Bundle bundle, ServiceRegistration reg )
+ public Object getService(Bundle bundle, ServiceRegistration reg)
{
- return new JUnitServiceImpl( this, bundle.getBundleContext() );
+ return new JUnitServiceImpl(this, bundle.getBundleContext());
}
-
- public void ungetService( Bundle bundle, ServiceRegistration reg, Object service )
+ public void ungetService(Bundle bundle, ServiceRegistration reg, Object service)
{
}
-
- public void registerTest( Class<? extends TestCase> clazz )
+ public void registerTest(Class<? extends TestCase> clazz)
{
- tests.put( clazz.getName(), clazz );
+ tests.put(clazz.getName(), clazz);
}
-
- public void unregister( Class<? extends TestCase> clazz )
+ public void unregister(Class<? extends TestCase> clazz)
{
- tests.remove( clazz.getName() );
+ tests.remove(clazz.getName());
}
-
public Set<String> getTests()
{
- return new TreeSet<String>( tests.keySet() );
+ return new TreeSet<String>(tests.keySet());
}
-
- public TestSuite getTest( String test )
+ public TestSuite getTest(String test)
{
- Class<? extends TestCase> tc = tests.get( test );
- return tc == null ? null : new TestSuite( tc );
+ Class<? extends TestCase> tc = tests.get(test);
+ return tc == null ? null : new TestSuite(tc);
}
}
diff --git a/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/impl/JUnitServiceImpl.java b/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/impl/JUnitServiceImpl.java
index d9b5cfa..593d280 100644
--- a/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/impl/JUnitServiceImpl.java
+++ b/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/impl/JUnitServiceImpl.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.junit.server.impl;
-
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
@@ -35,156 +34,147 @@
import org.apache.felix.sigil.common.junit.server.JUnitService;
import org.osgi.framework.BundleContext;
-
public class JUnitServiceImpl implements JUnitService
{
- private static final Logger log = Logger.getLogger( JUnitServiceImpl.class.getName() );
+ private static final Logger log = Logger.getLogger(JUnitServiceImpl.class.getName());
- private static final Class<?>[] BUNDLE_CONTEXT_PARAMS = new Class[]
- { BundleContext.class };
+ private static final Class<?>[] BUNDLE_CONTEXT_PARAMS = new Class[] { BundleContext.class };
private final JUnitServiceFactory junitServiceFactory;
private final BundleContext bundleContext;
-
- public JUnitServiceImpl( JUnitServiceFactory junitServiceFactory, BundleContext bundleContext )
+ public JUnitServiceImpl(JUnitServiceFactory junitServiceFactory, BundleContext bundleContext)
{
this.junitServiceFactory = junitServiceFactory;
this.bundleContext = bundleContext;
}
-
public Set<String> getTests()
{
return junitServiceFactory.getTests();
}
-
- public TestSuite createTest( String test )
+ public TestSuite createTest(String test)
{
- return createTest( test, null );
+ return createTest(test, null);
}
-
- public TestSuite createTest( String test, BundleContext ctx )
+ public TestSuite createTest(String test, BundleContext ctx)
{
try
{
- TestSuite ts = junitServiceFactory.getTest( test );
+ TestSuite ts = junitServiceFactory.getTest(test);
- if ( ts == null )
+ if (ts == null)
return null;
- TestSuite ret = new TestSuite( ts.getName() );
+ TestSuite ret = new TestSuite(ts.getName());
Enumeration<Test> e = ts.tests();
- while ( e.hasMoreElements() )
+ while (e.hasMoreElements())
{
Test t = e.nextElement();
- setContext( t, ctx );
- ret.addTest( t );
+ setContext(t, ctx);
+ ret.addTest(t);
}
return ret;
}
- catch ( final NoClassDefFoundError e )
+ catch (final NoClassDefFoundError e)
{
- TestSuite s = new TestSuite( test );
- s.addTest( new Test()
+ TestSuite s = new TestSuite(test);
+ s.addTest(new Test()
{
public int countTestCases()
{
return 1;
}
-
- public void run( TestResult result )
+ public void run(TestResult result)
{
- result.addError( this, e );
+ result.addError(this, e);
}
- } );
+ });
return s;
}
- catch ( final RuntimeException e )
+ catch (final RuntimeException e)
{
- TestSuite s = new TestSuite( test );
- s.addTest( new Test()
+ TestSuite s = new TestSuite(test);
+ s.addTest(new Test()
{
public int countTestCases()
{
return 1;
}
-
- public void run( TestResult result )
+ public void run(TestResult result)
{
- result.addError( this, e );
+ result.addError(this, e);
}
- } );
+ });
return s;
}
}
-
- private void setContext( Test t, BundleContext ctx )
+ private void setContext(Test t, BundleContext ctx)
{
try
{
- Method m = findMethod( t.getClass(), "setBundleContext", BUNDLE_CONTEXT_PARAMS );
- if ( m != null )
- m.invoke( t, ctx == null ? bundleContext : ctx );
+ Method m = findMethod(t.getClass(), "setBundleContext", BUNDLE_CONTEXT_PARAMS);
+ if (m != null)
+ m.invoke(t, ctx == null ? bundleContext : ctx);
}
- catch ( SecurityException e )
+ catch (SecurityException e)
{
- log.log( Level.WARNING, "Failed to set bundle context on " + t, e );
+ log.log(Level.WARNING, "Failed to set bundle context on " + t, e);
}
- catch ( IllegalArgumentException e )
+ catch (IllegalArgumentException e)
{
- log.log( Level.WARNING, "Failed to set bundle context on " + t, e );
+ log.log(Level.WARNING, "Failed to set bundle context on " + t, e);
}
- catch ( IllegalAccessException e )
+ catch (IllegalAccessException e)
{
- log.log( Level.WARNING, "Failed to set bundle context on " + t, e );
+ log.log(Level.WARNING, "Failed to set bundle context on " + t, e);
}
- catch ( InvocationTargetException e )
+ catch (InvocationTargetException e)
{
- log.log( Level.WARNING, "Failed to set bundle context on " + t, e );
+ log.log(Level.WARNING, "Failed to set bundle context on " + t, e);
}
}
-
- private Method findMethod( Class<?> clazz, String name, Class<?>[] params )
+ private Method findMethod(Class<?> clazz, String name, Class<?>[] params)
{
Method found = null;
- for ( Method m : clazz.getDeclaredMethods() )
+ for (Method m : clazz.getDeclaredMethods())
{
- if ( m.getName().equals( name ) && Arrays.deepEquals( m.getParameterTypes(), params ) )
+ if (m.getName().equals(name)
+ && Arrays.deepEquals(m.getParameterTypes(), params))
{
found = m;
break;
}
}
- if ( found == null )
+ if (found == null)
{
Class<?> c = clazz.getSuperclass();
- if ( c != null && c != Object.class )
+ if (c != null && c != Object.class)
{
- found = findMethod( c, name, params );
+ found = findMethod(c, name, params);
}
}
- if ( found == null )
+ if (found == null)
{
- for ( Class<?> c : clazz.getInterfaces() )
+ for (Class<?> c : clazz.getInterfaces())
{
- found = findMethod( c, name, params );
- if ( found != null )
+ found = findMethod(c, name, params);
+ if (found != null)
{
break;
}
diff --git a/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/impl/TestClassListener.java b/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/impl/TestClassListener.java
index d3ee7a3..3c7b22b 100644
--- a/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/impl/TestClassListener.java
+++ b/sigil/common/junit/src/org/apache/felix/sigil/common/junit/server/impl/TestClassListener.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.junit.server.impl;
-
import java.lang.reflect.Modifier;
import java.net.URL;
import java.util.Enumeration;
@@ -35,136 +34,127 @@
import org.osgi.framework.BundleEvent;
import org.osgi.framework.SynchronousBundleListener;
-
public class TestClassListener implements SynchronousBundleListener
{
- private static final Logger log = Logger.getLogger( TestClassListener.class.getName() );
+ private static final Logger log = Logger.getLogger(TestClassListener.class.getName());
private final JUnitServiceFactory service;
private HashMap<Long, Class<TestCase>[]> registrations = new HashMap<Long, Class<TestCase>[]>();
-
- public TestClassListener( JUnitServiceFactory service )
+ public TestClassListener(JUnitServiceFactory service)
{
this.service = service;
}
-
- public void bundleChanged( BundleEvent event )
+ public void bundleChanged(BundleEvent event)
{
- switch ( event.getType() )
+ switch (event.getType())
{
case BundleEvent.RESOLVED:
- index( event.getBundle() );
+ index(event.getBundle());
break;
case BundleEvent.UNRESOLVED:
- unindex( event.getBundle() );
+ unindex(event.getBundle());
break;
}
}
-
- void index( Bundle bundle )
+ void index(Bundle bundle)
{
- if ( isTestBundle( bundle ) )
+ if (isTestBundle(bundle))
{
- List<String> tests = findTests( bundle );
+ List<String> tests = findTests(bundle);
- if ( !tests.isEmpty() )
+ if (!tests.isEmpty())
{
LinkedList<Class<? extends TestCase>> regs = new LinkedList<Class<? extends TestCase>>();
- for ( String jc : tests )
+ for (String jc : tests)
{
try
{
- Class<?> clazz = bundle.loadClass( jc );
- if ( isTestCase( clazz ) )
+ Class<?> clazz = bundle.loadClass(jc);
+ if (isTestCase(clazz))
{
- Class<? extends TestCase> tc = clazz.asSubclass( TestCase.class );
- regs.add( tc );
- service.registerTest( tc );
+ Class<? extends TestCase> tc = clazz.asSubclass(TestCase.class);
+ regs.add(tc);
+ service.registerTest(tc);
}
}
- catch ( ClassNotFoundException e )
+ catch (ClassNotFoundException e)
{
- log.log( Level.WARNING, "Failed to load class " + jc, e );
+ log.log(Level.WARNING, "Failed to load class " + jc, e);
}
- catch ( NoClassDefFoundError e )
+ catch (NoClassDefFoundError e)
{
- log.log( Level.WARNING, "Failed to load class " + jc, e );
+ log.log(Level.WARNING, "Failed to load class " + jc, e);
}
}
- registrations.put( bundle.getBundleId(), toArray( regs ) );
+ registrations.put(bundle.getBundleId(), toArray(regs));
}
}
}
-
- private boolean isTestBundle( Bundle bundle )
+ private boolean isTestBundle(Bundle bundle)
{
try
{
- bundle.loadClass( TestCase.class.getName() );
+ bundle.loadClass(TestCase.class.getName());
return true;
}
- catch ( ClassNotFoundException e )
+ catch (ClassNotFoundException e)
{
return false;
}
}
-
@SuppressWarnings("unchecked")
- private Class<TestCase>[] toArray( LinkedList<Class<? extends TestCase>> regs )
+ private Class<TestCase>[] toArray(LinkedList<Class<? extends TestCase>> regs)
{
- return regs.toArray( new Class[regs.size()] );
+ return regs.toArray(new Class[regs.size()]);
}
-
- private boolean isTestCase( Class<?> clazz )
+ private boolean isTestCase(Class<?> clazz)
{
- return TestCase.class.isAssignableFrom( clazz ) && !Modifier.isAbstract( clazz.getModifiers() )
- && !clazz.getPackage().getName().startsWith( "junit" );
+ return TestCase.class.isAssignableFrom(clazz)
+ && !Modifier.isAbstract(clazz.getModifiers())
+ && !clazz.getPackage().getName().startsWith("junit");
}
-
- void unindex( Bundle bundle )
+ void unindex(Bundle bundle)
{
- Class<TestCase>[] classes = registrations.remove( bundle.getBundleId() );
- if ( classes != null )
+ Class<TestCase>[] classes = registrations.remove(bundle.getBundleId());
+ if (classes != null)
{
- for ( Class<TestCase> tc : classes )
+ for (Class<TestCase> tc : classes)
{
- service.unregister( tc );
+ service.unregister(tc);
}
}
}
-
- private List<String> findTests( Bundle bundle )
+ private List<String> findTests(Bundle bundle)
{
@SuppressWarnings("unchecked")
- Enumeration<URL> urls = bundle.findEntries( "", "*.class", true );
+ Enumeration<URL> urls = bundle.findEntries("", "*.class", true);
LinkedList<String> tests = new LinkedList<String>();
- while ( urls.hasMoreElements() )
+ while (urls.hasMoreElements())
{
URL url = urls.nextElement();
- tests.add( toClassName( url ) );
+ tests.add(toClassName(url));
}
return tests;
}
-
- private String toClassName( URL url )
+ private String toClassName(URL url)
{
String f = url.getFile();
- String cn = f.substring( 1, f.length() - 6 );
- return cn.replace( '/', '.' );
+ String cn = f.substring(1, f.length() - 6);
+ return cn.replace('/', '.');
}
}
diff --git a/sigil/common/obr.test/src/org/apache/felix/sigil/obr/impl/VersionRangeHelperTest.java b/sigil/common/obr.test/src/org/apache/felix/sigil/obr/impl/VersionRangeHelperTest.java
index 840d2b3..75a7513 100644
--- a/sigil/common/obr.test/src/org/apache/felix/sigil/obr/impl/VersionRangeHelperTest.java
+++ b/sigil/common/obr.test/src/org/apache/felix/sigil/obr/impl/VersionRangeHelperTest.java
@@ -29,120 +29,136 @@
public class VersionRangeHelperTest extends TestCase
{
- public void testRange1() {
+ public void testRange1()
+ {
LDAPExpr expr;
VersionRange range;
-
- expr = LDAPParser.parseExpression("(&(version>=1.0.0)(version<=2.0.0))" );
- range = VersionRangeHelper.decodeVersions( expr );
- assertEquals( VersionRange.parseVersionRange("[1.0.0,2.0.0]"), range );
+
+ expr = LDAPParser.parseExpression("(&(version>=1.0.0)(version<=2.0.0))");
+ range = VersionRangeHelper.decodeVersions(expr);
+ assertEquals(VersionRange.parseVersionRange("[1.0.0,2.0.0]"), range);
}
-
- public void testRange2() {
+
+ public void testRange2()
+ {
LDAPExpr expr;
VersionRange range;
-
+
expr = LDAPParser.parseExpression("(&(version>1.0.0)(version<2.0.0))");
- range = VersionRangeHelper.decodeVersions( expr );
- assertEquals( VersionRange.parseVersionRange("(1.0.0,2.0.0)"), range );
+ range = VersionRangeHelper.decodeVersions(expr);
+ assertEquals(VersionRange.parseVersionRange("(1.0.0,2.0.0)"), range);
}
-
- public void testRange3() {
+
+ public void testRange3()
+ {
LDAPExpr expr;
VersionRange range;
expr = LDAPParser.parseExpression("(&(!(version<1.0.0))(!(version>2.0.0)))");
- range = VersionRangeHelper.decodeVersions( expr );
- assertEquals( VersionRange.parseVersionRange("[1.0.0,2.0.0]"), range );
+ range = VersionRangeHelper.decodeVersions(expr);
+ assertEquals(VersionRange.parseVersionRange("[1.0.0,2.0.0]"), range);
}
-
- public void testRange4() {
+
+ public void testRange4()
+ {
LDAPExpr expr;
VersionRange range;
expr = LDAPParser.parseExpression("(&(!(version<=1.0.0))(!(version>=2.0.0)))");
- range = VersionRangeHelper.decodeVersions( expr );
- assertEquals( VersionRange.parseVersionRange("(1.0.0,2.0.0)"), range );
+ range = VersionRangeHelper.decodeVersions(expr);
+ assertEquals(VersionRange.parseVersionRange("(1.0.0,2.0.0)"), range);
}
-
- public void testRange5() {
+
+ public void testRange5()
+ {
LDAPExpr expr;
VersionRange range;
-
+
expr = LDAPParser.parseExpression("(version=1.0.0)");
- range = VersionRangeHelper.decodeVersions( expr );
- assertEquals( VersionRange.parseVersionRange("[1.0.0,1.0.0]"), range );
+ range = VersionRangeHelper.decodeVersions(expr);
+ assertEquals(VersionRange.parseVersionRange("[1.0.0,1.0.0]"), range);
}
-
- public void testRange6() {
+
+ public void testRange6()
+ {
LDAPExpr expr;
VersionRange range;
-
+
expr = LDAPParser.parseExpression("(version>=1.0.0)");
- range = VersionRangeHelper.decodeVersions( expr );
- assertEquals( new VersionRange(false, new Version(1,0,0), VersionRange.INFINITE_VERSION, true ), range );
+ range = VersionRangeHelper.decodeVersions(expr);
+ assertEquals(new VersionRange(false, new Version(1, 0, 0),
+ VersionRange.INFINITE_VERSION, true), range);
}
-
- public void testRange7() {
+
+ public void testRange7()
+ {
LDAPExpr expr;
VersionRange range;
-
+
expr = LDAPParser.parseExpression("(version<=2.0.0)");
- range = VersionRangeHelper.decodeVersions( expr );
- assertEquals( VersionRange.parseVersionRange("[0,2.0.0]"), range );
+ range = VersionRangeHelper.decodeVersions(expr);
+ assertEquals(VersionRange.parseVersionRange("[0,2.0.0]"), range);
}
-
- public void testRange8() {
+
+ public void testRange8()
+ {
LDAPExpr expr;
VersionRange range;
-
+
expr = LDAPParser.parseExpression("(version>1.0.0)");
- range = VersionRangeHelper.decodeVersions( expr );
- assertEquals( new VersionRange(true, new Version(1,0,0), VersionRange.INFINITE_VERSION, true ), range );
+ range = VersionRangeHelper.decodeVersions(expr);
+ assertEquals(new VersionRange(true, new Version(1, 0, 0),
+ VersionRange.INFINITE_VERSION, true), range);
}
-
- public void testRange9() {
+
+ public void testRange9()
+ {
LDAPExpr expr;
VersionRange range;
-
+
expr = LDAPParser.parseExpression("(version<2.0.0)");
- range = VersionRangeHelper.decodeVersions( expr );
- assertEquals( VersionRange.parseVersionRange("[0,2.0.0)"), range );
+ range = VersionRangeHelper.decodeVersions(expr);
+ assertEquals(VersionRange.parseVersionRange("[0,2.0.0)"), range);
}
-
- public void testRange10() {
+
+ public void testRange10()
+ {
LDAPExpr expr;
VersionRange range;
-
+
expr = LDAPParser.parseExpression("(!(version>2.0.0))");
- range = VersionRangeHelper.decodeVersions( expr );
- assertEquals( VersionRange.parseVersionRange("[0,2.0.0]"), range );
+ range = VersionRangeHelper.decodeVersions(expr);
+ assertEquals(VersionRange.parseVersionRange("[0,2.0.0]"), range);
}
-
- public void testRange11() {
+
+ public void testRange11()
+ {
LDAPExpr expr;
VersionRange range;
-
+
expr = LDAPParser.parseExpression("(!(version<1.0.0))");
- range = VersionRangeHelper.decodeVersions( expr );
- assertEquals( VersionRange.parseVersionRange("1.0.0"), range );
+ range = VersionRangeHelper.decodeVersions(expr);
+ assertEquals(VersionRange.parseVersionRange("1.0.0"), range);
}
-
- public void testRange12() {
+
+ public void testRange12()
+ {
LDAPExpr expr;
VersionRange range;
-
+
expr = LDAPParser.parseExpression("(!(version>=2.0.0))");
- range = VersionRangeHelper.decodeVersions( expr );
- assertEquals( VersionRange.parseVersionRange("[0,2.0.0)"), range );
+ range = VersionRangeHelper.decodeVersions(expr);
+ assertEquals(VersionRange.parseVersionRange("[0,2.0.0)"), range);
}
-
- public void testRange13() {
+
+ public void testRange13()
+ {
LDAPExpr expr;
VersionRange range;
-
+
expr = LDAPParser.parseExpression("(!(version<=1.0.0))");
- range = VersionRangeHelper.decodeVersions( expr );
- assertEquals( new VersionRange(true, new Version(1,0,0), VersionRange.INFINITE_VERSION, true ), range );
+ range = VersionRangeHelper.decodeVersions(expr);
+ assertEquals(new VersionRange(true, new Version(1, 0, 0),
+ VersionRange.INFINITE_VERSION, true), range);
}
}
diff --git a/sigil/common/obr/src/org/apache/felix/sigil/common/obr/OBRRepositoryProvider.java b/sigil/common/obr/src/org/apache/felix/sigil/common/obr/OBRRepositoryProvider.java
index 37deb2d..c073afc 100644
--- a/sigil/common/obr/src/org/apache/felix/sigil/common/obr/OBRRepositoryProvider.java
+++ b/sigil/common/obr/src/org/apache/felix/sigil/common/obr/OBRRepositoryProvider.java
@@ -49,13 +49,15 @@
try
{
File urlFile = new File(urlStr);
- URL repositoryURL = urlFile.exists() ? urlFile.toURI().toURL() : new URL(urlStr);
+ URL repositoryURL = urlFile.exists() ? urlFile.toURI().toURL() : new URL(
+ urlStr);
URL testURL = urlFile.exists() ? urlFile.toURI().toURL() : new URL(urlStr);
File indexCache = new File(preferences.getProperty(INDEX_CACHE_FILE));
File localCache = new File(preferences.getProperty(CACHE_DIRECTORY));
String auth = preferences.getProperty(AUTH_FILE);
File authFile = auth == null ? null : new File(auth);
- Long up = preferences.containsKey(UPDATE_PERIOD) ? Long.parseLong( preferences.getProperty(UPDATE_PERIOD) ) : 60 * 60 * 24 * 7;
+ Long up = preferences.containsKey(UPDATE_PERIOD) ? Long.parseLong(preferences.getProperty(UPDATE_PERIOD))
+ : 60 * 60 * 24 * 7;
if (testURL.openConnection().getLastModified() == 0)
{
@@ -65,7 +67,7 @@
System.err.println("WARNING: " + msg + "using cache: " + urlStr);
}
- long updatePeriod = TimeUnit.MILLISECONDS.convert(up,TimeUnit.SECONDS);
+ long updatePeriod = TimeUnit.MILLISECONDS.convert(up, TimeUnit.SECONDS);
if (preferences.getProperty(IN_MEMORY) == null)
{
return new NonCachingOBRBundleRepository(id, repositoryURL, indexCache,
diff --git a/sigil/common/obr/src/org/apache/felix/sigil/common/obr/impl/OBRHandler.java b/sigil/common/obr/src/org/apache/felix/sigil/common/obr/impl/OBRHandler.java
index fa52e42..17757b2 100644
--- a/sigil/common/obr/src/org/apache/felix/sigil/common/obr/impl/OBRHandler.java
+++ b/sigil/common/obr/src/org/apache/felix/sigil/common/obr/impl/OBRHandler.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.obr.impl;
-
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
@@ -49,7 +48,6 @@
import org.xml.sax.SAXParseException;
import org.xml.sax.helpers.DefaultHandler;
-
final class OBRHandler extends DefaultHandler
{
private static final String PACKAGE = "package";
@@ -67,175 +65,178 @@
private IPackageExport export;
private int depth;
-
- public OBRHandler( URL obrURL, File bundleCache, OBRListener listener )
+ public OBRHandler(URL obrURL, File bundleCache, OBRListener listener)
{
this.obrURL = obrURL;
this.cacheDir = bundleCache;
this.listener = listener;
}
-
- public void setDocumentLocator( Locator locator )
+ public void setDocumentLocator(Locator locator)
{
this.locator = locator;
}
-
- public void startElement( String uri, String localName, String qName, Attributes attributes ) throws SAXException
+ public void startElement(String uri, String localName, String qName,
+ Attributes attributes) throws SAXException
{
- if ( depth++ == 0 && !"repository".equals( qName ) ) {
- throw new SAXParseException("Invalid OBR document, expected repository top level element", locator);
- }
- else if ( "resource".equals( qName ) )
+ if (depth++ == 0 && !"repository".equals(qName))
{
- startResource( attributes );
+ throw new SAXParseException(
+ "Invalid OBR document, expected repository top level element", locator);
}
- else if ( "capability".equals( qName ) )
+ else if ("resource".equals(qName))
{
- startCapability( attributes );
+ startResource(attributes);
}
- else if ( "require".equals( qName ) )
+ else if ("capability".equals(qName))
{
- startRequire( attributes );
+ startCapability(attributes);
}
- else if ( "p".equals( qName ) )
+ else if ("require".equals(qName))
{
- startProperty( attributes );
+ startRequire(attributes);
+ }
+ else if ("p".equals(qName))
+ {
+ startProperty(attributes);
}
}
-
- public void endElement( String uri, String localName, String qName ) throws SAXException
+ public void endElement(String uri, String localName, String qName)
+ throws SAXException
{
depth--;
- if ( "resource".equals( qName ) )
+ if ("resource".equals(qName))
{
endResource();
}
- else if ( "capability".equals( qName ) )
+ else if ("capability".equals(qName))
{
endCapability();
}
- else if ( "require".equals( qName ) )
+ else if ("require".equals(qName))
{
endRequire();
}
- else if ( "p".equals( qName ) )
+ else if ("p".equals(qName))
{
endProperty();
}
}
-
- private void startResource( Attributes attributes ) throws SAXException
+ private void startResource(Attributes attributes) throws SAXException
{
try
{
- String uri = attributes.getValue( "", URI );
- if ( uri.endsWith( ".jar" ) )
+ String uri = attributes.getValue("", URI);
+ if (uri.endsWith(".jar"))
{
- if ( !sanity.add( uri ) )
+ if (!sanity.add(uri))
{
- throw new RuntimeException( uri );
+ throw new RuntimeException(uri);
}
- ISigilBundle b = ModelElementFactory.getInstance().newModelElement( ISigilBundle.class );
- IBundleModelElement info = ModelElementFactory.getInstance()
- .newModelElement( IBundleModelElement.class );
- info.setSymbolicName( attributes.getValue( "", SYMBOLIC_NAME ) );
- info.setVersion( VersionTable.getVersion(attributes.getValue( "", VERSION ) ) );
- info.setName( attributes.getValue( "", PRESENTATION_NAME ) );
- URI l = makeAbsolute( uri );
- info.setUpdateLocation( l );
- if ( "file".equals( l.getScheme() ) ) {
- b.setLocation( new File( l ) );
+ ISigilBundle b = ModelElementFactory.getInstance().newModelElement(
+ ISigilBundle.class);
+ IBundleModelElement info = ModelElementFactory.getInstance().newModelElement(
+ IBundleModelElement.class);
+ info.setSymbolicName(attributes.getValue("", SYMBOLIC_NAME));
+ info.setVersion(VersionTable.getVersion(attributes.getValue("", VERSION)));
+ info.setName(attributes.getValue("", PRESENTATION_NAME));
+ URI l = makeAbsolute(uri);
+ info.setUpdateLocation(l);
+ if ("file".equals(l.getScheme()))
+ {
+ b.setLocation(new File(l));
}
- else {
- b.setLocation( cachePath( info ) );
+ else
+ {
+ b.setLocation(cachePath(info));
}
- b.setBundleInfo( info );
+ b.setBundleInfo(info);
bundle = b;
}
}
- catch ( Exception e )
+ catch (Exception e)
{
- throw new SAXParseException( "Failed to build bundle info", locator, e );
+ throw new SAXParseException("Failed to build bundle info", locator, e);
}
}
-
- private URI makeAbsolute( String uri ) throws URISyntaxException
+ private URI makeAbsolute(String uri) throws URISyntaxException
{
- URI l = new URI( uri );
- if ( !l.isAbsolute() )
+ URI l = new URI(uri);
+ if (!l.isAbsolute())
{
String base = obrURL.toExternalForm();
- int i = base.lastIndexOf( "/" );
- if ( i != -1 )
+ int i = base.lastIndexOf("/");
+ if (i != -1)
{
- base = base.substring( 0, i );
- l = new URI( base + ( uri.startsWith( "/" ) ? "" : "/" ) + uri );
+ base = base.substring(0, i);
+ l = new URI(base + (uri.startsWith("/") ? "" : "/") + uri);
}
}
return l;
}
-
- private File cachePath( IBundleModelElement info )
+ private File cachePath(IBundleModelElement info)
{
- return new File( cacheDir, info.getSymbolicName() + "_" + info.getVersion() + ".jar" );
+ return new File(cacheDir, info.getSymbolicName() + "_" + info.getVersion()
+ + ".jar");
}
-
- private void startCapability( Attributes attributes )
+ private void startCapability(Attributes attributes)
{
- if ( bundle != null )
+ if (bundle != null)
{
- if ( PACKAGE.equals( attributes.getValue( "", "name" ) ) )
+ if (PACKAGE.equals(attributes.getValue("", "name")))
{
- export = ModelElementFactory.getInstance().newModelElement( IPackageExport.class );
+ export = ModelElementFactory.getInstance().newModelElement(
+ IPackageExport.class);
}
}
}
-
- private void startRequire( Attributes attributes ) throws SAXParseException
+ private void startRequire(Attributes attributes) throws SAXParseException
{
- if ( bundle != null )
+ if (bundle != null)
{
- String name = attributes.getValue( "name" );
- if ( PACKAGE.equals( name ) )
+ String name = attributes.getValue("name");
+ if (PACKAGE.equals(name))
{
- IPackageImport pi = ModelElementFactory.getInstance().newModelElement( IPackageImport.class );
+ IPackageImport pi = ModelElementFactory.getInstance().newModelElement(
+ IPackageImport.class);
try
{
- LDAPExpr expr = LDAPParser.parseExpression( attributes.getValue( "filter" ) );
- pi.setPackageName( decodePackage( expr, locator ) );
- pi.setVersions( decodeVersions( expr, locator ) );
- pi.setOptional( Boolean.valueOf( attributes.getValue( "optional" ) ) );
- bundle.getBundleInfo().addImport( pi );
+ LDAPExpr expr = LDAPParser.parseExpression(attributes.getValue("filter"));
+ pi.setPackageName(decodePackage(expr, locator));
+ pi.setVersions(decodeVersions(expr, locator));
+ pi.setOptional(Boolean.valueOf(attributes.getValue("optional")));
+ bundle.getBundleInfo().addImport(pi);
}
- catch ( LDAPParseException e )
+ catch (LDAPParseException e)
{
- throw new SAXParseException( "Failed to parse filter", locator, e );
+ throw new SAXParseException("Failed to parse filter", locator, e);
}
}
- else if ( "bundle".equals( name ) )
+ else if ("bundle".equals(name))
{
- IRequiredBundle b = ModelElementFactory.getInstance().newModelElement( IRequiredBundle.class );
+ IRequiredBundle b = ModelElementFactory.getInstance().newModelElement(
+ IRequiredBundle.class);
try
{
- LDAPExpr expr = LDAPParser.parseExpression( attributes.getValue( "filter" ) );
- b.setSymbolicName( decodeSymbolicName( expr, locator ) );
- b.setVersions( decodeVersions( expr, locator ) );
- b.setOptional( Boolean.valueOf( attributes.getValue( "optional" ) ) );
- bundle.getBundleInfo().addRequiredBundle( b );
+ LDAPExpr expr = LDAPParser.parseExpression(attributes.getValue("filter"));
+ b.setSymbolicName(decodeSymbolicName(expr, locator));
+ b.setVersions(decodeVersions(expr, locator));
+ b.setOptional(Boolean.valueOf(attributes.getValue("optional")));
+ bundle.getBundleInfo().addRequiredBundle(b);
}
- catch ( Exception e )
+ catch (Exception e)
{
- System.err.println( "Failed to parse filter in bundle " + bundle.getBundleInfo().getSymbolicName() );
- throw new SAXParseException( "Failed to parse filter in bundle "
- + bundle.getBundleInfo().getSymbolicName(), locator, e );
+ System.err.println("Failed to parse filter in bundle "
+ + bundle.getBundleInfo().getSymbolicName());
+ throw new SAXParseException("Failed to parse filter in bundle "
+ + bundle.getBundleInfo().getSymbolicName(), locator, e);
}
}
//else if ( "ee".equals( name ) ) {
@@ -252,125 +253,120 @@
}
}
-
- private static VersionRange decodeVersions( LDAPExpr expr, Locator locator ) throws SAXParseException
+ private static VersionRange decodeVersions(LDAPExpr expr, Locator locator)
+ throws SAXParseException
{
try
{
- return VersionRangeHelper.decodeVersions( expr );
+ return VersionRangeHelper.decodeVersions(expr);
}
- catch ( NumberFormatException e )
+ catch (NumberFormatException e)
{
- throw new SAXParseException( e.getMessage(), locator );
+ throw new SAXParseException(e.getMessage(), locator);
}
}
-
- private void startProperty( Attributes attributes )
+ private void startProperty(Attributes attributes)
{
- if ( export != null )
+ if (export != null)
{
- String name = attributes.getValue( "", "n" );
- String value = attributes.getValue( "", "v" );
- if ( PACKAGE.equals( name ) )
+ String name = attributes.getValue("", "n");
+ String value = attributes.getValue("", "v");
+ if (PACKAGE.equals(name))
{
- export.setPackageName( value );
+ export.setPackageName(value);
}
- else if ( "uses".equals( name ) )
+ else if ("uses".equals(name))
{
- String[] split = value.split( "," );
- export.setUses( Arrays.asList( split ) );
+ String[] split = value.split(",");
+ export.setUses(Arrays.asList(split));
}
- else if ( "version".equals( name ) )
+ else if ("version".equals(name))
{
- export.setVersion( VersionTable.getVersion( value ) );
+ export.setVersion(VersionTable.getVersion(value));
}
}
}
-
private void endResource()
{
- if ( bundle != null )
+ if (bundle != null)
{
- listener.handleBundle( bundle );
+ listener.handleBundle(bundle);
bundle = null;
}
}
-
private void endCapability()
{
- if ( bundle != null )
+ if (bundle != null)
{
- if ( export != null )
+ if (export != null)
{
- bundle.getBundleInfo().addExport( export );
+ bundle.getBundleInfo().addExport(export);
export = null;
}
}
}
-
private void endRequire()
{
// TODO Auto-generated method stub
}
-
private void endProperty()
{
// TODO Auto-generated method stub
}
-
- private static String decodePackage( LDAPExpr expr, Locator locator ) throws SAXParseException
+ private static String decodePackage(LDAPExpr expr, Locator locator)
+ throws SAXParseException
{
- ArrayList<SimpleTerm> terms = new ArrayList<SimpleTerm>( 1 );
+ ArrayList<SimpleTerm> terms = new ArrayList<SimpleTerm>(1);
- findTerms( "package", expr, terms );
+ findTerms("package", expr, terms);
- if ( terms.isEmpty() )
+ if (terms.isEmpty())
{
- throw new SAXParseException( "Missing name filter in " + expr, locator );
+ throw new SAXParseException("Missing name filter in " + expr, locator);
}
- return terms.get( 0 ).getRval();
+ return terms.get(0).getRval();
}
-
- private static String decodeSymbolicName( LDAPExpr expr, Locator locator ) throws SAXParseException
+ private static String decodeSymbolicName(LDAPExpr expr, Locator locator)
+ throws SAXParseException
{
- ArrayList<SimpleTerm> terms = new ArrayList<SimpleTerm>( 1 );
+ ArrayList<SimpleTerm> terms = new ArrayList<SimpleTerm>(1);
- findTerms( "symbolicname", expr, terms );
+ findTerms("symbolicname", expr, terms);
- if ( terms.isEmpty() )
+ if (terms.isEmpty())
{
- throw new SAXParseException( "Missing name filter in " + expr, locator );
+ throw new SAXParseException("Missing name filter in " + expr, locator);
}
- return terms.get( 0 ).getRval();
+ return terms.get(0).getRval();
}
-
- private static void findTerms( String string, LDAPExpr expr, List<SimpleTerm> terms ) throws SAXParseException
+ private static void findTerms(String string, LDAPExpr expr, List<SimpleTerm> terms)
+ throws SAXParseException
{
- if ( expr instanceof SimpleTerm )
+ if (expr instanceof SimpleTerm)
{
- SimpleTerm term = ( SimpleTerm ) expr;
- if ( term.getName().equals( string ) )
+ SimpleTerm term = (SimpleTerm) expr;
+ if (term.getName().equals(string))
{
- terms.add( term );
+ terms.add(term);
}
}
else
{
- for ( LDAPExpr c : expr.getChildren() )
+ for (LDAPExpr c : expr.getChildren())
{
- findTerms( string, c, terms );
+ findTerms(string, c, terms);
}
}
}
diff --git a/sigil/common/obr/src/org/apache/felix/sigil/common/obr/impl/OBRListener.java b/sigil/common/obr/src/org/apache/felix/sigil/common/obr/impl/OBRListener.java
index 107dd9c..12c9894 100644
--- a/sigil/common/obr/src/org/apache/felix/sigil/common/obr/impl/OBRListener.java
+++ b/sigil/common/obr/src/org/apache/felix/sigil/common/obr/impl/OBRListener.java
@@ -19,11 +19,9 @@
package org.apache.felix.sigil.common.obr.impl;
-
import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
-
public interface OBRListener
{
- void handleBundle( ISigilBundle bundle );
+ void handleBundle(ISigilBundle bundle);
}
diff --git a/sigil/common/obr/src/org/apache/felix/sigil/common/obr/impl/VersionRangeHelper.java b/sigil/common/obr/src/org/apache/felix/sigil/common/obr/impl/VersionRangeHelper.java
index 462e541..e5aff3a 100644
--- a/sigil/common/obr/src/org/apache/felix/sigil/common/obr/impl/VersionRangeHelper.java
+++ b/sigil/common/obr/src/org/apache/felix/sigil/common/obr/impl/VersionRangeHelper.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.obr.impl;
-
import java.util.ArrayList;
import java.util.List;
@@ -31,67 +30,68 @@
import org.apache.felix.sigil.common.osgi.VersionTable;
import org.osgi.framework.Version;
-
public class VersionRangeHelper
{
- public static VersionRange decodeVersions( LDAPExpr expr ) throws NumberFormatException
+ public static VersionRange decodeVersions(LDAPExpr expr) throws NumberFormatException
{
- ArrayList<LDAPExpr> terms = new ArrayList<LDAPExpr>( 1 );
+ ArrayList<LDAPExpr> terms = new ArrayList<LDAPExpr>(1);
- findExpr( "version", expr, terms );
+ findExpr("version", expr, terms);
- if ( terms.isEmpty() )
+ if (terms.isEmpty())
{
// woo hoo!
return VersionRange.ANY_VERSION;
}
else
{
- switch ( terms.size() )
+ switch (terms.size())
{
case 1:
{
- return parseSimpleVersionRange( terms.get( 0 ) );
+ return parseSimpleVersionRange(terms.get(0));
}
case 2:
{
- return parseCompoundVersionRange( terms.get( 0 ), terms.get( 1 ) );
+ return parseCompoundVersionRange(terms.get(0), terms.get(1));
}
default:
{
// (&(version>=min)(!(version=min))(version<=max)(!(version=max))) - (min,max) - not dealt with!!
// (&(|(version>min)(version=min))(|(version<max)(version=max))) - [min,max] - not dealt with!!
- throw new NumberFormatException( "Failed to parse complicated version expression " + expr );
+ throw new NumberFormatException(
+ "Failed to parse complicated version expression " + expr);
}
}
}
}
-
// (&(version>=min)(version<=max)) - [min,max]
// (&(version>min)(version<max)) - (min,max)
//
// (&(!(version<min))(!(version>max))) - [min,max]
// (&(!(version<=min))(!(version>=max)) - (min,max)
- private static VersionRange parseCompoundVersionRange( LDAPExpr left, LDAPExpr right ) throws NumberFormatException
+ private static VersionRange parseCompoundVersionRange(LDAPExpr left, LDAPExpr right)
+ throws NumberFormatException
{
- VersionRange one = parseSimpleVersionRange( left );
- VersionRange two = parseSimpleVersionRange( right );
+ VersionRange one = parseSimpleVersionRange(left);
+ VersionRange two = parseSimpleVersionRange(right);
// sanity check
- if ( one.isPointVersion() || two.isPointVersion() )
+ if (one.isPointVersion() || two.isPointVersion())
{
- throw new NumberFormatException( "Unexpected point version in compound expression " + left );
+ throw new NumberFormatException(
+ "Unexpected point version in compound expression " + left);
}
- VersionRange max = one.getFloor().equals( Version.emptyVersion ) ? one : two;
+ VersionRange max = one.getFloor().equals(Version.emptyVersion) ? one : two;
VersionRange min = max == one ? two : one;
- return new VersionRange( min.isOpenFloor(), min.getFloor(), max.getCeiling(), max.isOpenCeiling() );
+ return new VersionRange(min.isOpenFloor(), min.getFloor(), max.getCeiling(),
+ max.isOpenCeiling());
}
-
// possible variations
// (version=v) - [v,v]
//
@@ -105,122 +105,118 @@
// (!(version<min)) - [min,*)
// (!(version>=max)) - [0,max)
// (!(version<=min)) - (0,*)
- private static VersionRange parseSimpleVersionRange( LDAPExpr expr ) throws NumberFormatException
+ private static VersionRange parseSimpleVersionRange(LDAPExpr expr)
+ throws NumberFormatException
{
Version min = Version.emptyVersion;
Version max = VersionRange.INFINITE_VERSION;
boolean openFloor = false;
boolean openCeiling = false;
- if ( expr instanceof Not )
+ if (expr instanceof Not)
{
- Not n = ( Not ) expr;
- SimpleTerm t = ( SimpleTerm ) n.getEx();
- if ( t.getOp() == Ops.EQ )
+ Not n = (Not) expr;
+ SimpleTerm t = (SimpleTerm) n.getEx();
+ if (t.getOp() == Ops.EQ)
{
- throw new NumberFormatException( "Unexpected point version in negated expression " + expr );
+ throw new NumberFormatException(
+ "Unexpected point version in negated expression " + expr);
}
- if ( !isMax( t.getOp() ) )
+ if (!isMax(t.getOp()))
{
- max = toVersion( t );
- openCeiling = !openFloor( t );
+ max = toVersion(t);
+ openCeiling = !openFloor(t);
}
- else if ( !isMin( t.getOp() ) )
+ else if (!isMin(t.getOp()))
{
- min = toVersion( t );
- openFloor = !openCeiling( t );
+ min = toVersion(t);
+ openFloor = !openCeiling(t);
}
else
{
- throw new IllegalStateException( "Unexpected operator " + t.getOp() );
+ throw new IllegalStateException("Unexpected operator " + t.getOp());
}
}
else
{
- SimpleTerm t = ( SimpleTerm ) expr;
- if ( t.getOp().equals( Ops.EQ ) )
+ SimpleTerm t = (SimpleTerm) expr;
+ if (t.getOp().equals(Ops.EQ))
{
- max = toVersion( t );
+ max = toVersion(t);
min = max;
openFloor = false;
openCeiling = false;
}
- else if ( isMax( t.getOp() ) )
+ else if (isMax(t.getOp()))
{
- max = toVersion( t );
- openCeiling = openCeiling( t );
+ max = toVersion(t);
+ openCeiling = openCeiling(t);
}
- else if ( isMin( t.getOp() ) )
+ else if (isMin(t.getOp()))
{
- min = toVersion( t );
- openFloor = openFloor( t );
+ min = toVersion(t);
+ openFloor = openFloor(t);
}
else
{
- throw new IllegalStateException( "Unexpected operator " + t.getOp() );
+ throw new IllegalStateException("Unexpected operator " + t.getOp());
}
}
- return new VersionRange( openFloor, min, max, openCeiling );
+ return new VersionRange(openFloor, min, max, openCeiling);
}
-
- private static Version toVersion( SimpleTerm t )
+ private static Version toVersion(SimpleTerm t)
{
- return VersionTable.getVersion( t.getRval() );
+ return VersionTable.getVersion(t.getRval());
}
-
- private static boolean isMax( Ops op )
+ private static boolean isMax(Ops op)
{
return op == Ops.LE || op == Ops.LT;
}
-
- private static boolean isMin( Ops op )
+ private static boolean isMin(Ops op)
{
return op == Ops.GE || op == Ops.GT;
}
-
- private static boolean openFloor( SimpleTerm t )
+ private static boolean openFloor(SimpleTerm t)
{
return t.getOp() == Ops.GT;
}
-
- private static boolean openCeiling( SimpleTerm t )
+ private static boolean openCeiling(SimpleTerm t)
{
return t.getOp() == Ops.LT;
}
-
- private static void findExpr( String string, LDAPExpr expr, List<LDAPExpr> terms )
+ private static void findExpr(String string, LDAPExpr expr, List<LDAPExpr> terms)
{
- if ( expr instanceof SimpleTerm )
+ if (expr instanceof SimpleTerm)
{
- SimpleTerm term = ( SimpleTerm ) expr;
- if ( term.getName().equals( string ) )
+ SimpleTerm term = (SimpleTerm) expr;
+ if (term.getName().equals(string))
{
- terms.add( term );
+ terms.add(term);
}
}
- else if ( expr instanceof Not )
+ else if (expr instanceof Not)
{
- Not not = ( Not ) expr;
- if ( not.getEx() instanceof SimpleTerm )
+ Not not = (Not) expr;
+ if (not.getEx() instanceof SimpleTerm)
{
- SimpleTerm term = ( SimpleTerm ) not.getEx();
- if ( term.getName().equals( string ) )
+ SimpleTerm term = (SimpleTerm) not.getEx();
+ if (term.getName().equals(string))
{
- terms.add( not );
+ terms.add(not);
}
}
}
else
{
- for ( LDAPExpr c : expr.getChildren() )
+ for (LDAPExpr c : expr.getChildren())
{
- findExpr( string, c, terms );
+ findExpr(string, c, terms);
}
}
}
diff --git a/sigil/common/osgi.test/src/org/apache/felix/sigil/common/osgi/LDAPParserTest.java b/sigil/common/osgi.test/src/org/apache/felix/sigil/common/osgi/LDAPParserTest.java
index f0720a3..d03bb31 100644
--- a/sigil/common/osgi.test/src/org/apache/felix/sigil/common/osgi/LDAPParserTest.java
+++ b/sigil/common/osgi.test/src/org/apache/felix/sigil/common/osgi/LDAPParserTest.java
@@ -23,40 +23,48 @@
public class LDAPParserTest extends TestCase
{
- private static final SimpleTerm A_B = new SimpleTerm( "a", Ops.EQ, "b" );
- private static final SimpleTerm C_D = new SimpleTerm( "c", Ops.EQ, "d" );
-
- public void testSimple() {
- LDAPExpr expr = LDAPParser.parseExpression( "(a=b)" );
- assertEquals( expr, A_B );
+ private static final SimpleTerm A_B = new SimpleTerm("a", Ops.EQ, "b");
+ private static final SimpleTerm C_D = new SimpleTerm("c", Ops.EQ, "d");
+
+ public void testSimple()
+ {
+ LDAPExpr expr = LDAPParser.parseExpression("(a=b)");
+ assertEquals(expr, A_B);
}
- public void testSimpleWhiteSpace() {
- LDAPExpr expr = LDAPParser.parseExpression( " ( a = b ) " );
- assertEquals( expr, A_B );
+ public void testSimpleWhiteSpace()
+ {
+ LDAPExpr expr = LDAPParser.parseExpression(" ( a = b ) ");
+ assertEquals(expr, A_B);
}
-
- public void testNot() {
- LDAPExpr expr = LDAPParser.parseExpression( "(!(a=b))" );
- assertEquals( expr, Not.apply(A_B));
+
+ public void testNot()
+ {
+ LDAPExpr expr = LDAPParser.parseExpression("(!(a=b))");
+ assertEquals(expr, Not.apply(A_B));
}
-
- public void testAnd() {
- LDAPExpr expr = LDAPParser.parseExpression( "(&(a=b)(c=d))" );
- assertEquals( expr, And.apply(A_B, C_D) );
+
+ public void testAnd()
+ {
+ LDAPExpr expr = LDAPParser.parseExpression("(&(a=b)(c=d))");
+ assertEquals(expr, And.apply(A_B, C_D));
}
-
- public void testOr() {
- LDAPExpr expr = LDAPParser.parseExpression( "(|(a=b)(c=d))" );
- assertEquals( expr, Or.apply(A_B, C_D) );
+
+ public void testOr()
+ {
+ LDAPExpr expr = LDAPParser.parseExpression("(|(a=b)(c=d))");
+ assertEquals(expr, Or.apply(A_B, C_D));
}
-
- public void testParseException() {
- try {
- LDAPExpr expr = LDAPParser.parseExpression( ".(a=b)" );
- fail( "Unexpectedly parsed invalid ldap expr " + expr);
+
+ public void testParseException()
+ {
+ try
+ {
+ LDAPExpr expr = LDAPParser.parseExpression(".(a=b)");
+ fail("Unexpectedly parsed invalid ldap expr " + expr);
}
- catch (LDAPParseException e) {
+ catch (LDAPParseException e)
+ {
// expected
}
}
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/AbstractExpr.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/AbstractExpr.java
index fcb1084..144ae55 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/AbstractExpr.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/AbstractExpr.java
@@ -21,10 +21,12 @@
public abstract class AbstractExpr implements LDAPExpr
{
- public void visit(ExprVisitor visitor) {
+ public void visit(ExprVisitor visitor)
+ {
visitor.visitExpr(this);
- for ( LDAPExpr expr : getChildren() ) {
- visitor.visitExpr( expr );
+ for (LDAPExpr expr : getChildren())
+ {
+ visitor.visitExpr(expr);
}
}
}
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/And.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/And.java
index 4f99b15..3641bac 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/And.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/And.java
@@ -19,10 +19,8 @@
package org.apache.felix.sigil.common.osgi;
-
import java.util.Map;
-
public class And extends AbstractExpr
{
@@ -31,58 +29,55 @@
private static final long serialVersionUID = 1L;
private LDAPExpr[] children;
-
- public static LDAPExpr apply( LDAPExpr... terms )
+ public static LDAPExpr apply(LDAPExpr... terms)
{
- if ( terms == null )
+ if (terms == null)
{
- throw new NullPointerException( "terms cannot be null" );
+ throw new NullPointerException("terms cannot be null");
}
- else if ( terms.length == 0 )
+ else if (terms.length == 0)
{
return Expressions.T;
}
- else if ( terms.length == 1 )
+ else if (terms.length == 1)
{
return terms[0];
}
LDAPExpr[] filtered = new LDAPExpr[terms.length];
int ctr = 0;
- for ( int i = 0; i < terms.length; i++ )
+ for (int i = 0; i < terms.length; i++)
{
- if ( terms[i].equals( Expressions.F ) )
+ if (terms[i].equals(Expressions.F))
return Expressions.F;
- if ( terms[i].equals( Expressions.T ) )
+ if (terms[i].equals(Expressions.T))
continue;
filtered[ctr] = terms[i];
ctr++;
}
- if ( ctr == 0 )
+ if (ctr == 0)
{
return Expressions.T;
}
- else if ( ctr == 1 )
+ else if (ctr == 1)
{
return filtered[0];
}
LDAPExpr[] andTerms = new LDAPExpr[ctr];
- System.arraycopy( filtered, 0, andTerms, 0, ctr );
+ System.arraycopy(filtered, 0, andTerms, 0, ctr);
- return new And( andTerms );
+ return new And(andTerms);
}
-
- private And( LDAPExpr... children )
+ private And(LDAPExpr... children)
{
this.children = children;
}
-
- public boolean eval( Map<String, ?> map )
+ public boolean eval(Map<String, ?> map)
{
- for ( int i = 0; i < children.length; i++ )
+ for (int i = 0; i < children.length; i++)
{
- if ( !children[i].eval( map ) )
+ if (!children[i].eval(map))
{
return false;
}
@@ -90,32 +85,29 @@
return true;
}
-
public LDAPExpr[] getChildren()
{
return children;
}
-
- public void setChildren( LDAPExpr[] children )
+ public void setChildren(LDAPExpr[] children)
{
this.children = children;
}
-
@Override
- public boolean equals( Object other )
+ public boolean equals(Object other)
{
- if ( other instanceof And )
+ if (other instanceof And)
{
- And that = ( And ) other;
- if ( children.length != that.children.length )
+ And that = (And) other;
+ if (children.length != that.children.length)
{
return false;
}
- for ( int i = 0; i < children.length; i++ )
+ for (int i = 0; i < children.length; i++)
{
- if ( !children[i].equals( that.children[i] ) )
+ if (!children[i].equals(that.children[i]))
{
return false;
}
@@ -125,17 +117,16 @@
return false;
}
-
@Override
public String toString()
{
- StringBuffer buf = new StringBuffer( 256 );
- buf.append( "(&" );
- for ( int i = 0; i < children.length; i++ )
+ StringBuffer buf = new StringBuffer(256);
+ buf.append("(&");
+ for (int i = 0; i < children.length; i++)
{
- buf.append( " " ).append( children[i] ).append( " " );
+ buf.append(" ").append(children[i]).append(" ");
}
- buf.append( ")" );
+ buf.append(")");
return buf.toString();
}
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/ExprVisitor.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/ExprVisitor.java
index 88aa174..9cf5d36 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/ExprVisitor.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/ExprVisitor.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.osgi;
-
public interface ExprVisitor
{
void visitExpr(LDAPExpr expr);
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Expressions.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Expressions.java
index 6dab3ae..bb3cd81 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Expressions.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Expressions.java
@@ -19,40 +19,35 @@
package org.apache.felix.sigil.common.osgi;
-
import java.util.Map;
-
public class Expressions
{
- public static LDAPExpr and( LDAPExpr... terms )
+ public static LDAPExpr and(LDAPExpr... terms)
{
- return And.apply( terms );
+ return And.apply(terms);
}
-
- public static LDAPExpr or( LDAPExpr... terms )
+ public static LDAPExpr or(LDAPExpr... terms)
{
- return Or.apply( terms );
+ return Or.apply(terms);
}
-
- public static LDAPExpr not( LDAPExpr e )
+ public static LDAPExpr not(LDAPExpr e)
{
- return Not.apply( e );
+ return Not.apply(e);
}
public static LDAPExpr T = Bool.TRUE;
public static LDAPExpr F = Bool.FALSE;
-
// supports direct use of wildcards for ease of testing, but not literal *s
- public static SimpleTerm ex( String name, Ops op, String rhs )
+ public static SimpleTerm ex(String name, Ops op, String rhs)
{
- rhs = rhs.replace( '*', SimpleTerm.WILDCARD );
- return new SimpleTerm( name, op, rhs );
+ rhs = rhs.replace('*', SimpleTerm.WILDCARD);
+ return new SimpleTerm(name, op, rhs);
}
}
@@ -64,35 +59,30 @@
*
*/
private static final long serialVersionUID = 1L;
- public static final Bool TRUE = new Bool( true );
- public static final Bool FALSE = new Bool( false );
+ public static final Bool TRUE = new Bool(true);
+ public static final Bool FALSE = new Bool(false);
private boolean bool;
-
- public Bool( boolean bool )
+ public Bool(boolean bool)
{
this.bool = bool;
}
-
- public boolean eval( Map<String, ?> map )
+ public boolean eval(Map<String, ?> map)
{
return bool;
}
-
- public void visit( ExprVisitor v )
+ public void visit(ExprVisitor v)
{
}
-
public LDAPExpr[] getChildren()
{
return CHILDLESS;
}
-
public String toString()
{
return "(" + bool + ")";
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/FilterValidator.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/FilterValidator.java
index 7b21e3d..b1c9d3d 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/FilterValidator.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/FilterValidator.java
@@ -19,19 +19,17 @@
package org.apache.felix.sigil.common.osgi;
-
public interface FilterValidator
{
public static FilterValidator ACCEPT_ALL = new AcceptEverythingValidator();
-
- boolean validate( LDAPExpr filter );
+ boolean validate(LDAPExpr filter);
static class AcceptEverythingValidator implements FilterValidator
{
- public boolean validate( LDAPExpr filter )
+ public boolean validate(LDAPExpr filter)
{
return true;
}
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPExpr.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPExpr.java
index d7b9bf0..5420d54 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPExpr.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPExpr.java
@@ -19,30 +19,23 @@
package org.apache.felix.sigil.common.osgi;
-
import java.io.Serializable;
import java.util.Map;
-
public interface LDAPExpr extends Serializable
{
public static final LDAPExpr[] CHILDLESS = new LDAPExpr[0];
-
- public static LDAPExpr ACCEPT_ALL = Expressions.T;
+ public static LDAPExpr ACCEPT_ALL = Expressions.T;
LDAPExpr[] getChildren();
+ void visit(ExprVisitor v);
- void visit( ExprVisitor v );
-
-
- boolean equals( Object other );
-
+ boolean equals(Object other);
int hashCode();
-
- boolean eval( Map<String, ?> map );
+ boolean eval(Map<String, ?> map);
}
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPParseException.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPParseException.java
index 6cbce7a..bb2d1b9 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPParseException.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPParseException.java
@@ -19,45 +19,42 @@
package org.apache.felix.sigil.common.osgi;
-
public class LDAPParseException extends RuntimeException
{
private static final long serialVersionUID = 2L;
private ParseState ps;
- private static final String LINE_SEPARATOR = System.getProperty( "line.separator", "\\r\\n" );
+ private static final String LINE_SEPARATOR = System.getProperty("line.separator",
+ "\\r\\n");
-
- public LDAPParseException( String message, ParseState ps )
+ public LDAPParseException(String message, ParseState ps)
{
- super( message );
+ super(message);
this.ps = ps;
}
-
- public LDAPParseException( String message )
+ public LDAPParseException(String message)
{
- super( message );
+ super(message);
}
-
@Override
public String getMessage()
{
- if ( ps == null )
+ if (ps == null)
{
return super.getMessage();
}
String basicMessage = super.getMessage();
- StringBuffer buf = new StringBuffer( basicMessage.length() + ps.str.length() * 2 );
- buf.append( basicMessage ).append( LINE_SEPARATOR );
- buf.append( ps.str ).append( LINE_SEPARATOR );
- for ( int i = 0; i < ps.pos; i++ )
+ StringBuffer buf = new StringBuffer(basicMessage.length() + ps.str.length() * 2);
+ buf.append(basicMessage).append(LINE_SEPARATOR);
+ buf.append(ps.str).append(LINE_SEPARATOR);
+ for (int i = 0; i < ps.pos; i++)
{
- buf.append( " " );
+ buf.append(" ");
}
- buf.append( "^" );
+ buf.append("^");
return buf.toString();
}
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPParser.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPParser.java
index aa0056a..de1cb51 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPParser.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/LDAPParser.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.osgi;
-
import static org.apache.felix.sigil.common.osgi.Expressions.and;
import static org.apache.felix.sigil.common.osgi.Expressions.not;
import static org.apache.felix.sigil.common.osgi.Expressions.or;
@@ -33,226 +32,219 @@
import java.util.ArrayList;
import java.util.List;
-
public class LDAPParser
{
private static final LDAPParser parser = new LDAPParser();
-
- public static LDAPExpr parseExpression( String strExpr ) throws LDAPParseException
+ public static LDAPExpr parseExpression(String strExpr) throws LDAPParseException
{
- return parser.parse( strExpr );
+ return parser.parse(strExpr);
}
- public LDAPExpr parse( String strExpr ) throws LDAPParseException
+ public LDAPExpr parse(String strExpr) throws LDAPParseException
{
- if ( strExpr == null || strExpr.trim().length() == 0 )
+ if (strExpr == null || strExpr.trim().length() == 0)
{
return LDAPExpr.ACCEPT_ALL;
}
- ParseState ps = new ParseState( strExpr );
- LDAPExpr expr = parseExpr( ps );
+ ParseState ps = new ParseState(strExpr);
+ LDAPExpr expr = parseExpr(ps);
ps.skipWhitespace();
- if ( !ps.isEndOfString() )
+ if (!ps.isEndOfString())
{
- error( "expected end of expression ", ps );
+ error("expected end of expression ", ps);
}
return expr;
}
-
- public LDAPExpr parseExpr( ParseState ps ) throws LDAPParseException
+ public LDAPExpr parseExpr(ParseState ps) throws LDAPParseException
{
ps.skipWhitespace();
- if ( !( ps.peek() == '(' ) )
+ if (!(ps.peek() == '('))
{
- error( "expected (", ps );
+ error("expected (", ps);
}
ps.read();
LDAPExpr expr = null;
ps.skipWhitespace();
char ch = ps.peek();
- switch ( ch )
+ switch (ch)
{
case '&':
ps.readAndSkipWhiteSpace();
List<LDAPExpr> andList = new ArrayList<LDAPExpr>();
- while ( ps.peek() == '(' )
+ while (ps.peek() == '(')
{
- andList.add( parseExpr( ps ) );
+ andList.add(parseExpr(ps));
ps.skipWhitespace();
}
- LDAPExpr[] andArr = andList.toArray( new LDAPExpr[andList.size()] );
- expr = and( andArr );
+ LDAPExpr[] andArr = andList.toArray(new LDAPExpr[andList.size()]);
+ expr = and(andArr);
break;
case '|':
ps.readAndSkipWhiteSpace();
List<LDAPExpr> orList = new ArrayList<LDAPExpr>();
- while ( ps.peek() == '(' )
+ while (ps.peek() == '(')
{
- orList.add( parseExpr( ps ) );
+ orList.add(parseExpr(ps));
ps.skipWhitespace();
}
- LDAPExpr[] orArray = orList.toArray( new LDAPExpr[orList.size()] );
- expr = or( orArray );
+ LDAPExpr[] orArray = orList.toArray(new LDAPExpr[orList.size()]);
+ expr = or(orArray);
break;
case '!':
ps.readAndSkipWhiteSpace();
- expr = not( parseExpr( ps ) );
+ expr = not(parseExpr(ps));
break;
default:
- if ( isNameChar( ch ) )
+ if (isNameChar(ch))
{
- expr = parseSimple( ps );
+ expr = parseSimple(ps);
}
else
{
- error( "unexpected character: '" + ch + "'", ps );
+ error("unexpected character: '" + ch + "'", ps);
}
}
ps.skipWhitespace();
- if ( ps.peek() != ')' )
+ if (ps.peek() != ')')
{
- error( "expected )", ps );
+ error("expected )", ps);
}
ps.read();
return expr;
}
-
- void error( String message, ParseState ps ) throws LDAPParseException
+ void error(String message, ParseState ps) throws LDAPParseException
{
- throw new LDAPParseException( message, ps );
+ throw new LDAPParseException(message, ps);
}
-
- private SimpleTerm parseSimple( ParseState ps ) throws LDAPParseException
+ private SimpleTerm parseSimple(ParseState ps) throws LDAPParseException
{
// read name
- StringBuffer name = new StringBuffer( 16 );
- for ( char c = ps.peek(); !ps.isEndOfString() && isNameChar( c ); c = ps.peek() )
+ StringBuffer name = new StringBuffer(16);
+ for (char c = ps.peek(); !ps.isEndOfString() && isNameChar(c); c = ps.peek())
{
ps.read();
- name.append( c );
+ name.append(c);
}
ps.skipWhitespace();
Ops op = null;
// read op
- if ( ps.lookingAt( "=" ) )
+ if (ps.lookingAt("="))
{
op = EQ;
- ps.skip( 1 );
+ ps.skip(1);
}
- else if ( ps.lookingAt( ">=" ) )
+ else if (ps.lookingAt(">="))
{
op = GE;
- ps.skip( 2 );
+ ps.skip(2);
}
- else if ( ps.lookingAt( "<=" ) )
+ else if (ps.lookingAt("<="))
{
op = LE;
- ps.skip( 2 );
+ ps.skip(2);
}
- else if ( ps.lookingAt( ">" ) )
+ else if (ps.lookingAt(">"))
{
op = GT;
- ps.skip( 1 );
+ ps.skip(1);
}
- else if ( ps.lookingAt( "<" ) )
+ else if (ps.lookingAt("<"))
{
op = LT;
- ps.skip( 1 );
+ ps.skip(1);
}
- else if ( ps.lookingAt( "-=" ) )
+ else if (ps.lookingAt("-="))
{
op = APPROX;
- ps.skip( 2 );
+ ps.skip(2);
}
- else if ( ps.isEndOfString() )
+ else if (ps.isEndOfString())
{
- error( "unexpected end of expression", ps );
+ error("unexpected end of expression", ps);
}
else
{
- error( "unexpected character: '" + ps.peek() + "'", ps );
+ error("unexpected character: '" + ps.peek() + "'", ps);
}
ps.skipWhitespace();
boolean escaped = false;
- StringBuffer value = new StringBuffer( 16 );
+ StringBuffer value = new StringBuffer(16);
- while ( !ps.isEndOfString() && !Character.isWhitespace( ps.peek() ) && !( ps.peek() == ')' && !escaped ) )
+ while (!ps.isEndOfString() && !Character.isWhitespace(ps.peek())
+ && !(ps.peek() == ')' && !escaped))
{
char ch = ps.peek();
- if ( ch == '\\' )
+ if (ch == '\\')
{
escaped = true;
ps.read();
}
- else if ( ch == '*' )
+ else if (ch == '*')
{
- if ( escaped )
+ if (escaped)
{
- value.append( ch );
+ value.append(ch);
escaped = false;
}
else
{
- value.append( SimpleTerm.WILDCARD );
+ value.append(SimpleTerm.WILDCARD);
}
ps.read();
}
- else if ( isLiteralValue( ch ) )
+ else if (isLiteralValue(ch))
{
- if ( escaped )
+ if (escaped)
{
- error( "incorrectly applied escape of '" + ch + "'", ps );
+ error("incorrectly applied escape of '" + ch + "'", ps);
}
- value.append( ps.read() );
+ value.append(ps.read());
}
- else if ( isEscapedValue( ch ) )
+ else if (isEscapedValue(ch))
{
- if ( !escaped )
+ if (!escaped)
{
- error( "missing escape for '" + ch + "'", ps );
+ error("missing escape for '" + ch + "'", ps);
}
- value.append( ps.read() );
+ value.append(ps.read());
escaped = false;
}
else
{
- error( "unexpected character: '" + ps.peek() + "'", ps );
+ error("unexpected character: '" + ps.peek() + "'", ps);
}
}
ps.skipWhitespace();
- SimpleTerm expr = new SimpleTerm( name.toString(), op, value.toString() );
+ SimpleTerm expr = new SimpleTerm(name.toString(), op, value.toString());
return expr;
}
-
- private boolean isNameChar( int ch )
+ private boolean isNameChar(int ch)
{
- return !( Character.isWhitespace( ch ) || ( ch == '(' ) || ( ch == ')' ) || ( ch == '<' ) || ( ch == '>' )
- || ( ch == '=' ) || ( ch == '~' ) || ( ch == '*' ) || ( ch == '\\' ) );
+ return !(Character.isWhitespace(ch) || (ch == '(') || (ch == ')') || (ch == '<')
+ || (ch == '>') || (ch == '=') || (ch == '~') || (ch == '*') || (ch == '\\'));
}
-
- private boolean isLiteralValue( int ch )
+ private boolean isLiteralValue(int ch)
{
- return !( Character.isWhitespace( ch ) || ( ch == '(' ) || ( ch == ')' ) || ( ch == '*' ) );
+ return !(Character.isWhitespace(ch) || (ch == '(') || (ch == ')') || (ch == '*'));
}
-
- private boolean isEscapedValue( int ch )
+ private boolean isEscapedValue(int ch)
{
- return ( ch == '(' ) || ( ch == ')' ) || ( ch == '*' );
+ return (ch == '(') || (ch == ')') || (ch == '*');
}
}
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Not.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Not.java
index 0b3480d..70b423d 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Not.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Not.java
@@ -19,10 +19,8 @@
package org.apache.felix.sigil.common.osgi;
-
import java.util.Map;
-
public class Not extends AbstractExpr
{
@@ -32,76 +30,66 @@
private static final long serialVersionUID = 1L;
private LDAPExpr[] children;
-
- public static LDAPExpr apply( LDAPExpr e )
+ public static LDAPExpr apply(LDAPExpr e)
{
- if ( e == null )
+ if (e == null)
{
- throw new NullPointerException( "cannot apply Not to a null expression" );
+ throw new NullPointerException("cannot apply Not to a null expression");
}
- if ( e.equals( Expressions.T ) )
+ if (e.equals(Expressions.T))
{
return Expressions.F;
}
- if ( e.equals( Expressions.F ) )
+ if (e.equals(Expressions.F))
{
return Expressions.T;
}
- return new Not( e );
+ return new Not(e);
}
-
- private Not( LDAPExpr child )
+ private Not(LDAPExpr child)
{
- this.children = new LDAPExpr[]
- { child };
+ this.children = new LDAPExpr[] { child };
}
-
- public boolean eval( Map<String, ?> map )
+ public boolean eval(Map<String, ?> map)
{
- return !children[0].eval( map );
+ return !children[0].eval(map);
}
-
public LDAPExpr getEx()
{
return children[0];
}
-
public LDAPExpr[] getChildren()
{
return children;
}
-
- public void setChild( LDAPExpr child )
+ public void setChild(LDAPExpr child)
{
- this.children = new LDAPExpr[]
- { child };
+ this.children = new LDAPExpr[] { child };
}
-
@Override
- public boolean equals( Object other )
+ public boolean equals(Object other)
{
- if ( other instanceof Not )
+ if (other instanceof Not)
{
- Not that = ( Not ) other;
- return children[0].equals( that.children[0] );
+ Not that = (Not) other;
+ return children[0].equals(that.children[0]);
}
return false;
}
-
@Override
public String toString()
{
- StringBuffer buf = new StringBuffer( 256 );
- buf.append( "(!" );
- buf.append( " " ).append( children[0] ).append( " " );
- buf.append( ")" );
+ StringBuffer buf = new StringBuffer(256);
+ buf.append("(!");
+ buf.append(" ").append(children[0]).append(" ");
+ buf.append(")");
return buf.toString();
}
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Ops.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Ops.java
index 200e497..05d66b9 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Ops.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Ops.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.osgi;
-
public enum Ops
{
EQ, GE, LE, GT, LT, APPROX;
@@ -27,7 +26,7 @@
@Override
public String toString()
{
- switch ( this )
+ switch (this)
{
case EQ:
return "=";
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Or.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Or.java
index 5b6e215..7d5e32c 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Or.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Or.java
@@ -19,10 +19,8 @@
package org.apache.felix.sigil.common.osgi;
-
import java.util.Map;
-
public class Or extends AbstractExpr
{
@@ -32,58 +30,55 @@
private static final long serialVersionUID = 1L;
private LDAPExpr[] children;
-
- public static LDAPExpr apply( LDAPExpr... terms )
+ public static LDAPExpr apply(LDAPExpr... terms)
{
- if ( terms == null )
+ if (terms == null)
{
- throw new NullPointerException( "terms cannot be null" );
+ throw new NullPointerException("terms cannot be null");
}
- else if ( terms.length == 0 )
+ else if (terms.length == 0)
{
return Expressions.T;
}
- else if ( terms.length == 1 )
+ else if (terms.length == 1)
{
return terms[0];
}
LDAPExpr[] filtered = new LDAPExpr[terms.length];
int ctr = 0;
- for ( int i = 0; i < terms.length; i++ )
+ for (int i = 0; i < terms.length; i++)
{
- if ( terms[i].equals( Expressions.T ) )
+ if (terms[i].equals(Expressions.T))
return Expressions.T;
- if ( terms[i].equals( Expressions.F ) )
+ if (terms[i].equals(Expressions.F))
continue;
filtered[ctr] = terms[i];
ctr++;
}
- if ( ctr == 0 )
+ if (ctr == 0)
{
return Expressions.F;
}
- else if ( ctr == 1 )
+ else if (ctr == 1)
{
return filtered[0];
}
LDAPExpr[] orTerms = new LDAPExpr[ctr];
- System.arraycopy( filtered, 0, orTerms, 0, ctr );
+ System.arraycopy(filtered, 0, orTerms, 0, ctr);
- return new Or( orTerms );
+ return new Or(orTerms);
}
-
- private Or( LDAPExpr... children )
+ private Or(LDAPExpr... children)
{
this.children = children;
}
-
- public boolean eval( Map<String, ?> map )
+ public boolean eval(Map<String, ?> map)
{
- for ( int i = 0; i < children.length; i++ )
+ for (int i = 0; i < children.length; i++)
{
- if ( children[i].eval( map ) )
+ if (children[i].eval(map))
{
return true;
}
@@ -91,32 +86,29 @@
return false;
}
-
public LDAPExpr[] getChildren()
{
return children;
}
-
- public void setChildren( LDAPExpr[] children )
+ public void setChildren(LDAPExpr[] children)
{
this.children = children;
}
-
@Override
- public boolean equals( Object other )
+ public boolean equals(Object other)
{
- if ( other instanceof Or )
+ if (other instanceof Or)
{
- Or that = ( Or ) other;
- if ( children.length != that.children.length )
+ Or that = (Or) other;
+ if (children.length != that.children.length)
{
return false;
}
- for ( int i = 0; i < children.length; i++ )
+ for (int i = 0; i < children.length; i++)
{
- if ( children[i].equals( that.children[i] ) )
+ if (children[i].equals(that.children[i]))
{
return true;
}
@@ -126,17 +118,16 @@
return false;
}
-
@Override
public String toString()
{
- StringBuffer buf = new StringBuffer( 256 );
- buf.append( "(|" );
- for ( int i = 0; i < children.length; i++ )
+ StringBuffer buf = new StringBuffer(256);
+ buf.append("(|");
+ for (int i = 0; i < children.length; i++)
{
- buf.append( " " ).append( children[i] ).append( " " );
+ buf.append(" ").append(children[i]).append(" ");
}
- buf.append( ")" );
+ buf.append(")");
return buf.toString();
}
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/ParseState.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/ParseState.java
index 5bfb77b..f7f502d 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/ParseState.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/ParseState.java
@@ -19,10 +19,8 @@
package org.apache.felix.sigil.common.osgi;
-
import java.io.Serializable;
-
/**
* @author dave
*
@@ -35,39 +33,34 @@
String str;
-
- ParseState( String str )
+ ParseState(String str)
{
this.str = str;
}
-
- public boolean lookingAt( String start )
+ public boolean lookingAt(String start)
{
- return str.substring( pos ).startsWith( start );
+ return str.substring(pos).startsWith(start);
}
-
- public CharSequence skip( int n )
+ public CharSequence skip(int n)
{
int end = pos + n < str.length() ? pos + n : str.length();
int start = pos;
pos = end;
- return str.subSequence( start, end );
+ return str.subSequence(start, end);
}
-
public char read()
{
- char ch = str.charAt( pos );
- if ( pos < str.length() )
+ char ch = str.charAt(pos);
+ if (pos < str.length())
{
pos++;
}
return ch;
}
-
public char readAndSkipWhiteSpace()
{
char ch = read();
@@ -75,26 +68,23 @@
return ch;
}
-
char peek()
{
- if ( isEndOfString() )
+ if (isEndOfString())
{
- return ( char ) -1;
+ return (char) -1;
}
- return str.charAt( pos );
+ return str.charAt(pos);
}
-
boolean isEndOfString()
{
return pos == str.length();
}
-
void skipWhitespace()
{
- while ( pos < str.length() && Character.isWhitespace( str.charAt( pos ) ) )
+ while (pos < str.length() && Character.isWhitespace(str.charAt(pos)))
{
pos++;
}
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/SimpleTerm.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/SimpleTerm.java
index ffbe7dc..cb38204 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/SimpleTerm.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/SimpleTerm.java
@@ -19,13 +19,11 @@
package org.apache.felix.sigil.common.osgi;
-
import java.lang.reflect.Constructor;
import java.util.Iterator;
import java.util.Map;
import java.util.Vector;
-
public class SimpleTerm extends AbstractExpr
{
@@ -34,59 +32,54 @@
*/
private static final long serialVersionUID = 1L;
public static final char WILDCARD = 2 ^ 16 - 1;
- private static final String WILDCARD_STRING = new String( new char[]
- { SimpleTerm.WILDCARD } );
+ private static final String WILDCARD_STRING = new String(
+ new char[] { SimpleTerm.WILDCARD });
private Ops op;
private String name;
private String rval;
-
- public SimpleTerm( String name, Ops op, String value )
+ public SimpleTerm(String name, Ops op, String value)
{
this.op = op;
this.name = name.intern();
this.rval = value.intern();
}
-
public String getName()
{
return name;
}
-
public Ops getOp()
{
return op;
}
-
public String getRval()
{
return rval;
}
-
- public boolean eval( Map<String, ?> map )
+ public boolean eval(Map<String, ?> map)
{
- Object lval = map.get( name );
- if ( lval == null )
+ Object lval = map.get(name);
+ if (lval == null)
{
return false;
}
- else if ( Ops.EQ == op && WILDCARD_STRING.equals( lval ) )
+ else if (Ops.EQ == op && WILDCARD_STRING.equals(lval))
{
return true;
}
// any match in the vector will do
- else if ( lval instanceof Vector<?> )
+ else if (lval instanceof Vector<?>)
{
- Vector<?> vec = ( Vector<?> ) lval;
- for ( Iterator<?> i = vec.iterator(); i.hasNext(); )
+ Vector<?> vec = (Vector<?>) lval;
+ for (Iterator<?> i = vec.iterator(); i.hasNext();)
{
- if ( check( i.next() ) )
+ if (check(i.next()))
{
return true;
}
@@ -94,85 +87,84 @@
return false;
}
// any match in the array will do
- else if ( lval instanceof Object[] )
+ else if (lval instanceof Object[])
{
- Object[] arr = ( Object[] ) lval;
- for ( int i = 0; i < arr.length; i++ )
+ Object[] arr = (Object[]) lval;
+ for (int i = 0; i < arr.length; i++)
{
- if ( check( arr[i] ) )
+ if (check(arr[i]))
{
return true;
}
}
return false;
}
- return check( lval );
+ return check(lval);
}
-
@SuppressWarnings("unchecked")
- private boolean check( Object lval )
+ private boolean check(Object lval)
{
- if ( lval == null )
+ if (lval == null)
{
return false;
}
- else if ( Ops.EQ == op && WILDCARD_STRING.equals( lval ) )
+ else if (Ops.EQ == op && WILDCARD_STRING.equals(lval))
{
return true;
}
Object rhs = null;
- if ( lval instanceof String )
+ if (lval instanceof String)
{
- if ( Ops.APPROX == op )
+ if (Ops.APPROX == op)
{
- rhs = collapseWhiteSpace( rval );
- lval = collapseWhiteSpace( ( String ) lval );
+ rhs = collapseWhiteSpace(rval);
+ lval = collapseWhiteSpace((String) lval);
}
- if ( Ops.EQ == op || Ops.APPROX == op )
+ if (Ops.EQ == op || Ops.APPROX == op)
{
- return stringCheck( ( String ) lval );
+ return stringCheck((String) lval);
}
// rhs already a string
}
- else if ( lval.getClass() == Byte.class )
+ else if (lval.getClass() == Byte.class)
{
- rhs = Byte.valueOf( rval );
+ rhs = Byte.valueOf(rval);
}
- else if ( lval.getClass() == Short.class )
+ else if (lval.getClass() == Short.class)
{
- rhs = Short.valueOf( rval );
+ rhs = Short.valueOf(rval);
}
- else if ( lval.getClass() == Integer.class )
+ else if (lval.getClass() == Integer.class)
{
- rhs = Integer.valueOf( rval );
+ rhs = Integer.valueOf(rval);
}
- else if ( lval.getClass() == Long.class )
+ else if (lval.getClass() == Long.class)
{
- rhs = Long.valueOf( rval );
+ rhs = Long.valueOf(rval);
}
- else if ( lval.getClass() == Float.class )
+ else if (lval.getClass() == Float.class)
{
- rhs = Float.valueOf( rval );
+ rhs = Float.valueOf(rval);
}
- else if ( lval.getClass() == Double.class )
+ else if (lval.getClass() == Double.class)
{
- rhs = Double.valueOf( rval );
+ rhs = Double.valueOf(rval);
}
else
{
try
{
- Constructor<?> stringCtor = lval.getClass().getConstructor( new Class[]
- { String.class } );
- rhs = stringCtor.newInstance( rval );
+ Constructor<?> stringCtor = lval.getClass().getConstructor(
+ new Class[] { String.class });
+ rhs = stringCtor.newInstance(rval);
}
- catch ( Exception e )
+ catch (Exception e)
{
// log it
e.printStackTrace();
@@ -180,18 +172,18 @@
}
}
- if ( !( lval instanceof Comparable ) )
+ if (!(lval instanceof Comparable))
{
- return Ops.EQ == op && lval.equals( rval );
+ return Ops.EQ == op && lval.equals(rval);
}
else
{
- Comparable<? super Object> lhs = ( Comparable<? super Object> ) lval;
+ Comparable<? super Object> lhs = (Comparable<? super Object>) lval;
- int compare = lhs.compareTo( rhs );
+ int compare = lhs.compareTo(rhs);
- switch ( op )
+ switch (op)
{
case EQ:
return compare == 0;
@@ -211,12 +203,11 @@
return false;
}
-
- private boolean stringCheck( String lhs )
+ private boolean stringCheck(String lhs)
{
String rhs;
- switch ( op )
+ switch (op)
{
case EQ:
case APPROX:
@@ -229,35 +220,35 @@
int valLength = lhs.length();
int patLength = rval.length();
- if ( valLength == 0 && patLength == 0 )
+ if (valLength == 0 && patLength == 0)
{
return true;
}
boolean wc = false;
int j = 0;
- for ( int i = 0; i < patLength; i++ )
+ for (int i = 0; i < patLength; i++)
{
// trailing wildcards
- char pc = rhs.charAt( i );
- if ( j == valLength )
+ char pc = rhs.charAt(i);
+ if (j == valLength)
{
- if ( pc != SimpleTerm.WILDCARD )
+ if (pc != SimpleTerm.WILDCARD)
{
return false;
}
continue;
}
- if ( pc == SimpleTerm.WILDCARD )
+ if (pc == SimpleTerm.WILDCARD)
{
wc = true;
continue;
}
- while ( wc && j < valLength - 1 && lhs.charAt( j ) != pc )
+ while (wc && j < valLength - 1 && lhs.charAt(j) != pc)
{
j++;
}
- if ( lhs.charAt( j ) != pc )
+ if (lhs.charAt(j) != pc)
{
return false;
}
@@ -267,79 +258,74 @@
j++;
}
}
- return ( wc || j == valLength );
+ return (wc || j == valLength);
}
-
- private String collapseWhiteSpace( String in )
+ private String collapseWhiteSpace(String in)
{
- StringBuffer out = new StringBuffer( in.trim().length() );
+ StringBuffer out = new StringBuffer(in.trim().length());
boolean white = false;
- for ( int i = 0; i < in.length(); i++ )
+ for (int i = 0; i < in.length(); i++)
{
- char ch = in.charAt( i );
- if ( Character.isWhitespace( ch ) )
+ char ch = in.charAt(i);
+ if (Character.isWhitespace(ch))
{
white = true;
}
else
{
- if ( white )
+ if (white)
{
- out.append( " " );
+ out.append(" ");
white = false;
}
- out.append( ch );
+ out.append(ch);
}
}
return out.toString();
}
-
public LDAPExpr[] getChildren()
{
return CHILDLESS;
}
-
@Override
- public boolean equals( Object other )
+ public boolean equals(Object other)
{
- if ( other instanceof SimpleTerm )
+ if (other instanceof SimpleTerm)
{
- SimpleTerm that = ( SimpleTerm ) other;
- return name.equals( that.name ) && op.equals( that.op ) && rval.equals( that.rval );
+ SimpleTerm that = (SimpleTerm) other;
+ return name.equals(that.name) && op.equals(that.op) && rval.equals(that.rval);
}
return false;
}
-
@Override
public String toString()
{
- return "(" + name + " " + op.toString() + " " + escape( rval ) + ")";
+ return "(" + name + " " + op.toString() + " " + escape(rval) + ")";
}
-
- private String escape( String raw )
+ private String escape(String raw)
{
- StringBuffer buf = new StringBuffer( raw.length() + 10 );
- for ( int i = 0; i < raw.length(); i++ )
+ StringBuffer buf = new StringBuffer(raw.length() + 10);
+ for (int i = 0; i < raw.length(); i++)
{
- char ch = raw.charAt( i );
- switch ( ch )
+ char ch = raw.charAt(i);
+ switch (ch)
{
case SimpleTerm.WILDCARD:
- buf.append( "*" );
+ buf.append("*");
break;
case '(':
case ')':
case '*':
- buf.append( "\\" ).append( ch );
+ buf.append("\\").append(ch);
break;
default:
- buf.append( ch );
+ buf.append(ch);
}
}
return buf.toString();
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Utils.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Utils.java
index 9720702..feed6e8 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Utils.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/Utils.java
@@ -19,47 +19,44 @@
package org.apache.felix.sigil.common.osgi;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
public class Utils
{
- public static MapBuilder map( String name, Object value )
+ public static MapBuilder map(String name, Object value)
{
- return new MapBuilder().put( name, value );
+ return new MapBuilder().put(name, value);
}
-
- public static String toString( Map<String, Object> attrs )
+ public static String toString(Map<String, Object> attrs)
{
- if ( attrs == null )
+ if (attrs == null)
{
return "NULL";
}
- StringBuffer buf = new StringBuffer( 128 );
- List<String> keys = new ArrayList<String>( attrs.keySet() );
- Collections.sort( keys );
- buf.append( "{" );
+ StringBuffer buf = new StringBuffer(128);
+ List<String> keys = new ArrayList<String>(attrs.keySet());
+ Collections.sort(keys);
+ buf.append("{");
- for ( int i = 0; i < keys.size(); i++ )
+ for (int i = 0; i < keys.size(); i++)
{
- Object name = keys.get( i );
- Object value = attrs.get( name );
- buf.append( name ).append( "=" ).append( value ).append( "," );
+ Object name = keys.get(i);
+ Object value = attrs.get(name);
+ buf.append(name).append("=").append(value).append(",");
}
- if ( buf.length() > 1 )
+ if (buf.length() > 1)
{
- buf.delete( buf.length() - 1, buf.length() );
+ buf.delete(buf.length() - 1, buf.length());
}
- buf.append( "}" );
+ buf.append("}");
return buf.toString();
}
@@ -68,15 +65,13 @@
{
private Map<String, Object> map = new HashMap<String, Object>();
-
- public MapBuilder put( String name, Object value )
+ public MapBuilder put(String name, Object value)
{
- map.put( name, value );
+ map.put(name, value);
return this;
}
-
public Map<String, Object> toMap()
{
return map;
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionRange.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionRange.java
index 321f4e2..a3ec95c 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionRange.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionRange.java
@@ -19,12 +19,10 @@
package org.apache.felix.sigil.common.osgi;
-
import java.io.Serializable;
import org.osgi.framework.Version;
-
public class VersionRange implements Serializable
{
@@ -32,17 +30,16 @@
*
*/
private static final long serialVersionUID = 1L;
- public static final Version INFINITE_VERSION = new Version( Integer.MAX_VALUE, Integer.MAX_VALUE,
- Integer.MAX_VALUE, "" );
- public static final VersionRange ANY_VERSION = new VersionRange( false, Version.emptyVersion, INFINITE_VERSION,
- true );
+ public static final Version INFINITE_VERSION = new Version(Integer.MAX_VALUE,
+ Integer.MAX_VALUE, Integer.MAX_VALUE, "");
+ public static final VersionRange ANY_VERSION = new VersionRange(false,
+ Version.emptyVersion, INFINITE_VERSION, true);
private boolean openFloor;
private Version floor;
private Version ceiling;
private boolean openCeiling;
-
/**
* Interval constructor
*
@@ -51,7 +48,7 @@
* @param ceiling The upper bound version of the range.
* @param openCeiling Whether the upper bound of the range is inclusive (false) or exclusive (true).
*/
- public VersionRange( boolean openFloor, Version floor, Version ceiling, boolean openCeiling )
+ public VersionRange(boolean openFloor, Version floor, Version ceiling, boolean openCeiling)
{
this.openFloor = openFloor;
this.floor = floor;
@@ -59,14 +56,13 @@
this.openCeiling = openCeiling;
}
-
/**
* atLeast constructor
*
* @param openFloor
* @param floor
*/
- public VersionRange( Version atLeast )
+ public VersionRange(Version atLeast)
{
this.openFloor = false;
this.floor = atLeast;
@@ -74,202 +70,198 @@
this.openCeiling = true;
}
-
- public static VersionRange parseVersionRange( String val ) throws IllegalArgumentException, NumberFormatException
+ public static VersionRange parseVersionRange(String val)
+ throws IllegalArgumentException, NumberFormatException
{
- if ( val == null || val.trim().length() == 0 )
+ if (val == null || val.trim().length() == 0)
{
return ANY_VERSION;
}
boolean openFloor;
boolean openCeiling;
- val = val.replaceAll( "\\s", "" );
- val = val.replaceAll( "\"", "" );
- int fst = val.charAt( 0 );
- if ( fst == '[' )
+ val = val.replaceAll("\\s", "");
+ val = val.replaceAll("\"", "");
+ int fst = val.charAt(0);
+ if (fst == '[')
{
openFloor = false;
}
- else if ( fst == '(' )
+ else if (fst == '(')
{
openFloor = true;
}
else
{
- Version atLeast = VersionTable.getVersion( val );
- return new VersionRange( atLeast );
+ Version atLeast = VersionTable.getVersion(val);
+ return new VersionRange(atLeast);
}
- int lst = val.charAt( val.length() - 1 );
- if ( lst == ']' )
+ int lst = val.charAt(val.length() - 1);
+ if (lst == ']')
{
openCeiling = false;
}
- else if ( lst == ')' )
+ else if (lst == ')')
{
openCeiling = true;
}
else
{
- throw new IllegalArgumentException( "illegal version range syntax " + val
- + ": range must end in ')' or ']'" );
+ throw new IllegalArgumentException("illegal version range syntax " + val
+ + ": range must end in ')' or ']'");
}
- String inner = val.substring( 1, val.length() - 1 );
- String[] floorCeiling = inner.split( "," );
- if ( floorCeiling.length != 2 )
+ String inner = val.substring(1, val.length() - 1);
+ String[] floorCeiling = inner.split(",");
+ if (floorCeiling.length != 2)
{
- throw new IllegalArgumentException( "illegal version range syntax " + "too many commas" );
+ throw new IllegalArgumentException("illegal version range syntax "
+ + "too many commas");
}
- Version floor = VersionTable.getVersion( floorCeiling[0] );
- Version ceiling = "*".equals( floorCeiling[1] ) ? INFINITE_VERSION : Version.parseVersion( floorCeiling[1] );
- return new VersionRange( openFloor, floor, ceiling, openCeiling );
+ Version floor = VersionTable.getVersion(floorCeiling[0]);
+ Version ceiling = "*".equals(floorCeiling[1]) ? INFINITE_VERSION
+ : Version.parseVersion(floorCeiling[1]);
+ return new VersionRange(openFloor, floor, ceiling, openCeiling);
}
-
public Version getCeiling()
{
return ceiling;
}
-
public Version getFloor()
{
return floor;
}
-
public boolean isOpenCeiling()
{
return openCeiling;
}
-
public boolean isOpenFloor()
{
return openFloor;
}
-
public boolean isPointVersion()
{
- return !openFloor && !openCeiling && floor.equals( ceiling );
+ return !openFloor && !openCeiling && floor.equals(ceiling);
}
-
/**
* test a version to see if it falls in the range
*
* @param version
* @return
*/
- public boolean contains( Version version )
+ public boolean contains(Version version)
{
- if ( version.equals( INFINITE_VERSION ) )
+ if (version.equals(INFINITE_VERSION))
{
- return ceiling.equals( INFINITE_VERSION );
+ return ceiling.equals(INFINITE_VERSION);
}
else
{
- return ( version.compareTo( floor ) > 0 && version.compareTo( ceiling ) < 0 )
- || ( !openFloor && version.equals( floor ) ) || ( !openCeiling && version.equals( ceiling ) );
+ return (version.compareTo(floor) > 0 && version.compareTo(ceiling) < 0)
+ || (!openFloor && version.equals(floor))
+ || (!openCeiling && version.equals(ceiling));
}
}
-
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
- result = prime * result + ( ( ceiling == null ) ? 0 : ceiling.hashCode() );
- result = prime * result + ( ( floor == null ) ? 0 : floor.hashCode() );
- result = prime * result + ( openCeiling ? 1231 : 1237 );
- result = prime * result + ( openFloor ? 1231 : 1237 );
+ result = prime * result + ((ceiling == null) ? 0 : ceiling.hashCode());
+ result = prime * result + ((floor == null) ? 0 : floor.hashCode());
+ result = prime * result + (openCeiling ? 1231 : 1237);
+ result = prime * result + (openFloor ? 1231 : 1237);
return result;
}
-
@Override
- public boolean equals( Object obj )
+ public boolean equals(Object obj)
{
- if ( this == obj )
+ if (this == obj)
return true;
- if ( obj == null )
+ if (obj == null)
return false;
- if ( getClass() != obj.getClass() )
+ if (getClass() != obj.getClass())
return false;
- final VersionRange other = ( VersionRange ) obj;
- if ( ceiling == null )
+ final VersionRange other = (VersionRange) obj;
+ if (ceiling == null)
{
- if ( other.ceiling != null )
+ if (other.ceiling != null)
return false;
}
- else if ( !ceiling.equals( other.ceiling ) )
+ else if (!ceiling.equals(other.ceiling))
return false;
- if ( floor == null )
+ if (floor == null)
{
- if ( other.floor != null )
+ if (other.floor != null)
return false;
}
- else if ( !floor.equals( other.floor ) )
+ else if (!floor.equals(other.floor))
return false;
- if ( openCeiling != other.openCeiling )
+ if (openCeiling != other.openCeiling)
return false;
- if ( openFloor != other.openFloor )
+ if (openFloor != other.openFloor)
return false;
return true;
}
-
@Override
public String toString()
{
- if ( ANY_VERSION.equals( this ) )
+ if (ANY_VERSION.equals(this))
{
- return makeString( openFloor, Version.emptyVersion, INFINITE_VERSION, openCeiling );
+ return makeString(openFloor, Version.emptyVersion, INFINITE_VERSION,
+ openCeiling);
}
- return makeString( openFloor, floor, ceiling, openCeiling );
+ return makeString(openFloor, floor, ceiling, openCeiling);
}
-
- private String makeString( boolean openFloor, Version floor, Version ceiling, boolean openCeiling )
+ private String makeString(boolean openFloor, Version floor, Version ceiling,
+ boolean openCeiling)
{
- StringBuffer vr = new StringBuffer( 32 );
- if ( INFINITE_VERSION.equals( ceiling ) )
+ StringBuffer vr = new StringBuffer(32);
+ if (INFINITE_VERSION.equals(ceiling))
{
- vr.append( Version.emptyVersion.equals( floor ) ? "0" : floor.toString() );
+ vr.append(Version.emptyVersion.equals(floor) ? "0" : floor.toString());
}
else
{
- vr.append( openFloor ? "(" : "[" );
- String floorStr = Version.emptyVersion.equals( floor ) ? "0" : floor.toString();
+ vr.append(openFloor ? "(" : "[");
+ String floorStr = Version.emptyVersion.equals(floor) ? "0" : floor.toString();
String ceilingStr = ceiling.toString();
- vr.append( floorStr ).append( "," ).append( ceilingStr );
- vr.append( openCeiling ? ")" : "]" );
+ vr.append(floorStr).append(",").append(ceilingStr);
+ vr.append(openCeiling ? ")" : "]");
}
return vr.toString();
}
-
- public static VersionRange newInstance( Version pointVersion, VersionRangeBoundingRule lowerBoundRule,
- VersionRangeBoundingRule upperBoundRule )
+ public static VersionRange newInstance(Version pointVersion,
+ VersionRangeBoundingRule lowerBoundRule, VersionRangeBoundingRule upperBoundRule)
{
Version floor = null;
- switch ( lowerBoundRule )
+ switch (lowerBoundRule)
{
case Any:
- floor = VersionTable.getVersion( 0, 0, 0 );
+ floor = VersionTable.getVersion(0, 0, 0);
break;
case Major:
- floor = VersionTable.getVersion( pointVersion.getMajor(), 0, 0 );
+ floor = VersionTable.getVersion(pointVersion.getMajor(), 0, 0);
break;
case Minor:
- floor = VersionTable.getVersion( pointVersion.getMajor(), pointVersion.getMinor(), 0 );
+ floor = VersionTable.getVersion(pointVersion.getMajor(),
+ pointVersion.getMinor(), 0);
break;
case Micro:
- floor = VersionTable.getVersion( pointVersion.getMajor(), pointVersion.getMinor(), pointVersion.getMicro() );
+ floor = VersionTable.getVersion(pointVersion.getMajor(),
+ pointVersion.getMinor(), pointVersion.getMicro());
break;
case Exact:
floor = pointVersion;
@@ -278,19 +270,21 @@
Version ceiling = null;
boolean openCeiling = true;
- switch ( upperBoundRule )
+ switch (upperBoundRule)
{
case Any:
ceiling = INFINITE_VERSION;
break;
case Major:
- ceiling = VersionTable.getVersion( pointVersion.getMajor() + 1, 0, 0 );
+ ceiling = VersionTable.getVersion(pointVersion.getMajor() + 1, 0, 0);
break;
case Minor:
- ceiling = VersionTable.getVersion( pointVersion.getMajor(), pointVersion.getMinor() + 1, 0 );
+ ceiling = VersionTable.getVersion(pointVersion.getMajor(),
+ pointVersion.getMinor() + 1, 0);
break;
case Micro:
- ceiling = VersionTable.getVersion( pointVersion.getMajor(), pointVersion.getMinor(), pointVersion.getMicro() + 1 );
+ ceiling = VersionTable.getVersion(pointVersion.getMajor(),
+ pointVersion.getMinor(), pointVersion.getMicro() + 1);
break;
case Exact:
ceiling = pointVersion;
@@ -298,6 +292,6 @@
break;
}
- return new VersionRange( false, floor, ceiling, openCeiling );
+ return new VersionRange(false, floor, ceiling, openCeiling);
}
}
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionRangeBoundingRule.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionRangeBoundingRule.java
index 5ee45da..cb2e236 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionRangeBoundingRule.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionRangeBoundingRule.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.osgi;
-
public enum VersionRangeBoundingRule
{
Exact, Micro, Minor, Major, Any
diff --git a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionTable.java b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionTable.java
index 0cea80b..0b0b05e 100644
--- a/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionTable.java
+++ b/sigil/common/osgi/src/org/apache/felix/sigil/common/osgi/VersionTable.java
@@ -33,40 +33,49 @@
public class VersionTable
{
private static final WeakHashMap<String, Version> versions = new WeakHashMap<String, Version>();
-
- public static Version getVersion(String version) {
- synchronized( versions ) {
+
+ public static Version getVersion(String version)
+ {
+ synchronized (versions)
+ {
Version v = versions.get(version);
- if ( v == null ) {
+ if (v == null)
+ {
v = Version.parseVersion(version);
versions.put(version, v);
}
-
+
return v;
}
}
-
- public static Version getVersion(int major, int minor, int micro) {
+
+ public static Version getVersion(int major, int minor, int micro)
+ {
return getVersion(major, minor, micro, null);
}
- public static Version getVersion(int major, int minor, int micro, String qualifier) {
+ public static Version getVersion(int major, int minor, int micro, String qualifier)
+ {
String key;
-
- if ( qualifier == null || qualifier.length() == 0 ) {
+
+ if (qualifier == null || qualifier.length() == 0)
+ {
key = major + "." + minor + "." + micro;
}
- else {
- key = major + "." + minor + "." + micro + "." + qualifier;
+ else
+ {
+ key = major + "." + minor + "." + micro + "." + qualifier;
}
-
- synchronized( versions ) {
+
+ synchronized (versions)
+ {
Version v = versions.get(key);
- if ( v == null ) {
+ if (v == null)
+ {
v = new Version(major, minor, micro, qualifier);
versions.put(key, v);
}
-
+
return v;
}
}
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/BundleForm.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/BundleForm.java
index a805611..bd373d1 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/BundleForm.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/BundleForm.java
@@ -41,31 +41,34 @@
import org.osgi.framework.Constants;
public class BundleForm
-{
- public interface Resolver {
+{
+ public interface Resolver
+ {
URI[] resolve(URI base) throws URISyntaxException;
}
-
- public interface ResolutionContext {
+
+ public interface ResolutionContext
+ {
Resolver findResolver(URI uri);
}
-
- private static final Resolver NULL_RESOLVER = new Resolver() {
+
+ private static final Resolver NULL_RESOLVER = new Resolver()
+ {
public URI[] resolve(URI base)
{
return new URI[] { base };
}
-
+
};
private static final ResolutionContext NULL_CONTEXT = new ResolutionContext()
- {
+ {
public Resolver findResolver(URI uri)
{
return NULL_RESOLVER;
}
};
-
+
public static class BundleStatus
{
private String location;
@@ -73,99 +76,111 @@
private String version;
private long id;
private int status;
-
+
public String getLocation()
{
return location;
}
-
+
public void setLocation(String location)
{
this.location = location;
}
-
+
public String getBundleSymbolicName()
{
return bundleSymbolicName;
}
-
+
public void setBundleSymbolicName(String bundleSymbolicName)
{
this.bundleSymbolicName = bundleSymbolicName;
}
-
+
public String getVersion()
{
return version;
}
-
+
public void setVersion(String version)
{
this.version = version;
}
-
+
public long getId()
{
return id;
}
-
+
public void setId(long id)
{
this.id = id;
}
-
+
public void setStatus(int status)
{
this.status = status;
- }
-
- public int getStatus() {
+ }
+
+ public int getStatus()
+ {
return status;
}
public boolean isMatch(BundleStatus n)
{
- return bundleSymbolicName.equals( n.bundleSymbolicName ) && version.equals(n.version);
+ return bundleSymbolicName.equals(n.bundleSymbolicName)
+ && version.equals(n.version);
}
}
-
+
private URI[] bundles;
private Set<URI> startMap = new HashSet<URI>();
- public BundleForm() {
+ public BundleForm()
+ {
}
-
- public BundleStatus[] resolve(ResolutionContext ctx) throws IOException, URISyntaxException {
- if ( ctx == null ) {
+
+ public BundleStatus[] resolve(ResolutionContext ctx) throws IOException,
+ URISyntaxException
+ {
+ if (ctx == null)
+ {
ctx = NULL_CONTEXT;
}
-
+
ArrayList<BundleStatus> ret = new ArrayList<BundleStatus>(bundles.length);
-
- for ( int i = 0; i < bundles.length; i++ ) {
+
+ for (int i = 0; i < bundles.length; i++)
+ {
Resolver resolver = ctx.findResolver(bundles[i]);
- if ( resolver == null ) {
+ if (resolver == null)
+ {
resolver = NULL_RESOLVER;
}
URI[] resolved = resolver.resolve(bundles[i]);
- for ( URI uri : resolved ) {
+ for (URI uri : resolved)
+ {
BundleStatus bundle = toBundle(uri, isStarted(bundles[i]));
- if ( bundle == null ) {
+ if (bundle == null)
+ {
throw new IllegalStateException("Failed to read bundle " + uri);
}
- ret.add( bundle );
+ ret.add(bundle);
}
}
-
- return ret.toArray(new BundleStatus[ret.size()] );
+
+ return ret.toArray(new BundleStatus[ret.size()]);
}
-
+
private BundleStatus toBundle(URI uri, boolean started) throws IOException
{
- try {
+ try
+ {
Manifest mf = findManifest(uri);
- if ( mf == null ) return null;
+ if (mf == null)
+ return null;
Attributes attr = mf.getMainAttributes();
String bsn = attr.getValue(Constants.BUNDLE_SYMBOLICNAME);
String ver = attr.getValue(Constants.BUNDLE_VERSION);
@@ -176,7 +191,8 @@
st.setStatus(started ? Bundle.ACTIVE : Bundle.INSTALLED);
return st;
}
- catch (IllegalArgumentException e) {
+ catch (IllegalArgumentException e)
+ {
throw new IllegalArgumentException("Invalid uri " + uri, e);
}
}
@@ -185,71 +201,90 @@
{
Manifest mf = null;
- try {
+ try
+ {
File f = new File(uri);
- if ( f.isDirectory() ) {
- f = new File(f, "META-INF/MANIFEST.MF" );
- if ( f.isFile() ) {
+ if (f.isDirectory())
+ {
+ f = new File(f, "META-INF/MANIFEST.MF");
+ if (f.isFile())
+ {
FileInputStream fin = new FileInputStream(f);
- try {
+ try
+ {
mf = new Manifest(fin);
}
- finally {
+ finally
+ {
fin.close();
}
}
}
}
- catch (IllegalArgumentException e) {
+ catch (IllegalArgumentException e)
+ {
// fine
}
-
- if ( mf == null) {
+
+ if (mf == null)
+ {
InputStream in = uri.toURL().openStream();
- try {
+ try
+ {
JarInputStream jin = new JarInputStream(in);
mf = jin.getManifest();
- if ( mf == null ) {
- for(;;) {
+ if (mf == null)
+ {
+ for (;;)
+ {
JarEntry entry = jin.getNextJarEntry();
- if ( entry == null ) break;
- if ( "META-INF/MANIFEST.MF".equals(entry.getName()) ) {
+ if (entry == null)
+ break;
+ if ("META-INF/MANIFEST.MF".equals(entry.getName()))
+ {
mf = new Manifest(jin);
break;
}
}
}
-
+
}
- finally {
+ finally
+ {
in.close();
}
}
return mf;
}
- public static BundleForm create(URL formURL) throws IOException, URISyntaxException {
+ public static BundleForm create(URL formURL) throws IOException, URISyntaxException
+ {
InputStream in = formURL.openStream();
- try {
+ try
+ {
BundleForm f = new BundleForm();
BufferedReader r = new BufferedReader(new InputStreamReader(in));
LinkedList<URI> locs = new LinkedList<URI>();
- for(;;) {
+ for (;;)
+ {
String l = r.readLine();
- if ( l == null ) break;
+ if (l == null)
+ break;
l = l.trim();
- if ( !l.startsWith( "#" ) ) {
+ if (!l.startsWith("#"))
+ {
URI uri = URI.create(l);
String status = uri.getScheme();
uri = URI.create(uri.getSchemeSpecificPart());
- locs.add( uri );
- f.setStarted(uri, "start".equalsIgnoreCase(status) );
+ locs.add(uri);
+ f.setStarted(uri, "start".equalsIgnoreCase(status));
}
}
f.setBundles(locs.toArray(new URI[locs.size()]));
return f;
}
- finally {
+ finally
+ {
try
{
in.close();
@@ -262,10 +297,11 @@
}
}
- public void setBundles(URI[] bundles) {
+ public void setBundles(URI[] bundles)
+ {
this.bundles = bundles;
}
-
+
public URI[] getBundles()
{
return bundles;
@@ -275,13 +311,16 @@
{
return startMap.contains(uri);
}
-
- public void setStarted(URI uri, boolean started) {
- if ( started ) {
+
+ public void setStarted(URI uri, boolean started)
+ {
+ if (started)
+ {
startMap.add(uri);
}
- else {
+ else
+ {
startMap.remove(uri);
}
- }
+ }
}
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Client.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Client.java
index 8f9daa3..fd9a2c2 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Client.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Client.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.runtime;
-
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
@@ -43,7 +42,6 @@
import static org.apache.felix.sigil.common.runtime.Runtime.PORT_PROPERTY;
import static org.apache.felix.sigil.common.runtime.Runtime.ADDRESS_PROPERTY;
-
/**
* @author dave
*
@@ -54,36 +52,37 @@
private DataInputStream in;
private DataOutputStream out;
-
public Client()
{
}
-
+
public void connect(Properties props) throws IOException
{
- String v = props.getProperty( ADDRESS_PROPERTY );
- InetAddress address = v == null ? null : InetAddress.getByName( v );
- int port = Integer.parseInt( props.getProperty( PORT_PROPERTY, "0" ) );
-
- if ( port < 1 ) {
- throw new IOException( "Missing or invalid port" );
+ String v = props.getProperty(ADDRESS_PROPERTY);
+ InetAddress address = v == null ? null : InetAddress.getByName(v);
+ int port = Integer.parseInt(props.getProperty(PORT_PROPERTY, "0"));
+
+ if (port < 1)
+ {
+ throw new IOException("Missing or invalid port");
}
-
+
InetSocketAddress endpoint = new InetSocketAddress(address, port);
-
+
socket = new Socket();
- socket.connect( endpoint );
-
- Main.log( "Connected to " + endpoint );
-
- in = new DataInputStream( socket.getInputStream() );
- out = new DataOutputStream( socket.getOutputStream() );
+ socket.connect(endpoint);
+
+ Main.log("Connected to " + endpoint);
+
+ in = new DataInputStream(socket.getInputStream());
+ out = new DataOutputStream(socket.getOutputStream());
}
- public boolean isConnected() {
+ public boolean isConnected()
+ {
return socket != null;
}
-
+
public void disconnect() throws IOException
{
socket.close();
@@ -92,148 +91,174 @@
out = null;
}
- public void apply(BundleForm.BundleStatus[] newStatus) throws IOException, BundleException {
+ public void apply(BundleForm.BundleStatus[] newStatus) throws IOException,
+ BundleException
+ {
BundleStatus[] currentStatus = status();
-
+
stopOldBundles(currentStatus, newStatus);
-
+
boolean change = uninstallOldBundles(currentStatus, newStatus);
change |= installNewBundles(currentStatus, newStatus);
-
- if ( change )
+
+ if (change)
refresh();
-
+
startNewBundles(newStatus);
}
public void refresh() throws IOException, BundleException
{
- if ( socket == null ) throw new IllegalStateException( "Not connected" );
- new RefreshAction( in, out ).client();
+ if (socket == null)
+ throw new IllegalStateException("Not connected");
+ new RefreshAction(in, out).client();
}
- public long install( String url ) throws IOException, BundleException
+ public long install(String url) throws IOException, BundleException
{
- if ( socket == null ) throw new IllegalStateException( "Not connected" );
- return new InstallAction( in, out ).client( url );
+ if (socket == null)
+ throw new IllegalStateException("Not connected");
+ return new InstallAction(in, out).client(url);
}
-
- public void start( long bundle ) throws IOException, BundleException
+ public void start(long bundle) throws IOException, BundleException
{
- if ( socket == null ) throw new IllegalStateException( "Not connected" );
- new StartAction( in, out ).client( bundle );
+ if (socket == null)
+ throw new IllegalStateException("Not connected");
+ new StartAction(in, out).client(bundle);
}
-
- public void stop( long bundle ) throws IOException, BundleException
+ public void stop(long bundle) throws IOException, BundleException
{
- if ( socket == null ) throw new IllegalStateException( "Not connected" );
- new StopAction( in, out ).client( bundle );
+ if (socket == null)
+ throw new IllegalStateException("Not connected");
+ new StopAction(in, out).client(bundle);
}
-
- public void uninstall( long bundle ) throws IOException, BundleException
+ public void uninstall(long bundle) throws IOException, BundleException
{
- if ( socket == null ) throw new IllegalStateException( "Not connected" );
- new UninstallAction( in, out ).client( bundle );
+ if (socket == null)
+ throw new IllegalStateException("Not connected");
+ new UninstallAction(in, out).client(bundle);
}
-
- public void update( long bundle ) throws IOException, BundleException
+ public void update(long bundle) throws IOException, BundleException
{
- if ( socket == null ) throw new IllegalStateException( "Not connected" );
+ if (socket == null)
+ throw new IllegalStateException("Not connected");
Update update = new UpdateAction.Update(bundle, null);
- new UpdateAction( in, out ).client(update);
+ new UpdateAction(in, out).client(update);
}
-
- public void update( long bundle, String url ) throws IOException, BundleException
+ public void update(long bundle, String url) throws IOException, BundleException
{
- if ( socket == null ) throw new IllegalStateException( "Not connected" );
+ if (socket == null)
+ throw new IllegalStateException("Not connected");
Update update = new UpdateAction.Update(bundle, url);
- new UpdateAction( in, out ).client(update);
+ new UpdateAction(in, out).client(update);
}
-
public BundleStatus[] status() throws IOException, BundleException
{
- if ( socket == null ) throw new IllegalStateException( "Not connected" );
- return new StatusAction( in, out ).client();
+ if (socket == null)
+ throw new IllegalStateException("Not connected");
+ return new StatusAction(in, out).client();
}
-
- private boolean installNewBundles(BundleStatus[] status, BundleStatus[] newStatus) throws IOException, BundleException
+
+ private boolean installNewBundles(BundleStatus[] status, BundleStatus[] newStatus)
+ throws IOException, BundleException
{
boolean change = false;
- for (BundleStatus n : newStatus) {
+ for (BundleStatus n : newStatus)
+ {
boolean found = false;
- for ( BundleStatus o : status ) {
- if ( o.isMatch(n) ) {
+ for (BundleStatus o : status)
+ {
+ if (o.isMatch(n))
+ {
update(o.getId(), n.getLocation());
found = true;
change = true;
break;
}
}
-
- if ( !found ) {
+
+ if (!found)
+ {
install(n.getLocation());
change = true;
}
}
-
+
return change;
}
- private void startNewBundles(BundleStatus[] newStatus) throws IOException, BundleException
+ private void startNewBundles(BundleStatus[] newStatus) throws IOException,
+ BundleException
{
BundleStatus[] status = status();
- for (BundleStatus n : newStatus) {
- if ( n.getStatus() == Bundle.ACTIVE ) {
- for ( BundleStatus o : status ) {
- if ( o.isMatch(n) ) {
+ for (BundleStatus n : newStatus)
+ {
+ if (n.getStatus() == Bundle.ACTIVE)
+ {
+ for (BundleStatus o : status)
+ {
+ if (o.isMatch(n))
+ {
start(o.getId());
}
}
- }
+ }
}
}
- private void stopOldBundles(BundleStatus[] status, BundleStatus[] newStatus) throws IOException, BundleException
+ private void stopOldBundles(BundleStatus[] status, BundleStatus[] newStatus)
+ throws IOException, BundleException
{
- for (BundleStatus n : newStatus) {
- if ( n.getStatus() == Bundle.INSTALLED ) {
- for ( BundleStatus o : status ) {
- if ( o.getId() != 0 ) {
- if ( o.isMatch(n) ) {
+ for (BundleStatus n : newStatus)
+ {
+ if (n.getStatus() == Bundle.INSTALLED)
+ {
+ for (BundleStatus o : status)
+ {
+ if (o.getId() != 0)
+ {
+ if (o.isMatch(n))
+ {
stop(o.getId());
- }
+ }
}
}
- }
+ }
}
}
- private boolean uninstallOldBundles(BundleStatus[] status, BundleStatus[] newStatus) throws IOException, BundleException
+ private boolean uninstallOldBundles(BundleStatus[] status, BundleStatus[] newStatus)
+ throws IOException, BundleException
{
boolean change = false;
- for ( BundleStatus o : status ) {
- if ( o.getId() != 0 ) {
+ for (BundleStatus o : status)
+ {
+ if (o.getId() != 0)
+ {
boolean found = false;
-
- for (BundleStatus n : newStatus) {
- if ( o.isMatch(n) ) {
+
+ for (BundleStatus n : newStatus)
+ {
+ if (o.isMatch(n))
+ {
found = true;
break;
}
}
-
- if ( !found ) {
+
+ if (!found)
+ {
change = true;
uninstall(o.getId());
}
}
}
return change;
- }
+ }
}
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Main.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Main.java
index e0a1362..34572f5 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Main.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Main.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.runtime;
-
import static org.apache.felix.sigil.common.runtime.Runtime.ADDRESS_PROPERTY;
import static org.apache.felix.sigil.common.runtime.Runtime.PORT_PROPERTY;
@@ -42,89 +41,88 @@
import org.osgi.framework.launch.Framework;
import org.osgi.framework.launch.FrameworkFactory;
-
public class Main
{
private static final String COMMAND_LINE_SYNTAX = "java -jar org.apache.felix.sigil.common.runtime";
private static Framework framework;
private static final Options options;
-
+
private static boolean verbose = false;
static
{
options = new Options();
- options.addOption( "?", "help", false, "Print help for the Sigil launcher" );
- options.addOption( "p", "port", true, "Port to launch server on (0 implies auto allocate) [default 0]" );
- options.addOption( "a", "address", true, "Address to bind server to [default all]" );
- options.addOption( "c", "clean", false, "Clean bundle cache directory on init" );
- options.addOption( "s", "startLevel", true, "Start level for framework" );
- options.addOption( "v", "verbose", false, "Verbose output" );
+ options.addOption("?", "help", false, "Print help for the Sigil launcher");
+ options.addOption("p", "port", true,
+ "Port to launch server on (0 implies auto allocate) [default 0]");
+ options.addOption("a", "address", true, "Address to bind server to [default all]");
+ options.addOption("c", "clean", false, "Clean bundle cache directory on init");
+ options.addOption("s", "startLevel", true, "Start level for framework");
+ options.addOption("v", "verbose", false, "Verbose output");
}
-
- public static void main( String[] args ) throws Exception
+ public static void main(String[] args) throws Exception
{
FrameworkFactory factory = getFrameworkFactory();
try
{
Parser parser = new PosixParser();
- CommandLine cl = parser.parse( options, args );
+ CommandLine cl = parser.parse(options, args);
- if ( cl.hasOption( '?' ) )
+ if (cl.hasOption('?'))
{
printHelp();
}
else
{
verbose = cl.hasOption('v');
-
- Map<String, String> config = buildConfig( cl );
- framework = factory.newFramework( config );
+ Map<String, String> config = buildConfig(cl);
+
+ framework = factory.newFramework(config);
framework.init();
framework.start();
- Server server = launch( cl );
+ Server server = launch(cl);
- framework.waitForStop( 0 );
+ framework.waitForStop(0);
- if ( server != null )
+ if (server != null)
{
server.stop();
}
}
}
- catch ( NoSuchElementException e )
+ catch (NoSuchElementException e)
{
- System.err.println( "No " + FrameworkFactory.class.getName() + " found on classpath" );
- System.exit( 1 );
+ System.err.println("No " + FrameworkFactory.class.getName()
+ + " found on classpath");
+ System.exit(1);
}
- catch ( InterruptedException e )
+ catch (InterruptedException e)
{
- System.err.println( "Interrupted prior to framework stop" );
- System.exit( 1 );
+ System.err.println("Interrupted prior to framework stop");
+ System.exit(1);
}
- catch ( ParseException e )
+ catch (ParseException e)
{
printHelp();
- System.exit( 1 );
+ System.exit(1);
}
- catch ( BundleException e )
+ catch (BundleException e)
{
e.printStackTrace();
- System.exit( 1 );
+ System.exit(1);
}
- catch ( IOException e )
+ catch (IOException e)
{
e.printStackTrace();
- System.exit( 1 );
+ System.exit(1);
}
}
-
/**
* Simple method to parse META-INF/services file for framework factory.
* Currently, it assumes the first non-commented line is the class name
@@ -135,65 +133,64 @@
private static FrameworkFactory getFrameworkFactory() throws Exception
{
URL url = Main.class.getClassLoader().getResource(
- "META-INF/services/org.osgi.framework.launch.FrameworkFactory" );
- if ( url != null )
+ "META-INF/services/org.osgi.framework.launch.FrameworkFactory");
+ if (url != null)
{
- BufferedReader br = new BufferedReader( new InputStreamReader( url.openStream() ) );
+ BufferedReader br = new BufferedReader(
+ new InputStreamReader(url.openStream()));
try
{
- for ( String s = br.readLine(); s != null; s = br.readLine() )
+ for (String s = br.readLine(); s != null; s = br.readLine())
{
s = s.trim();
// Try to load first non-empty, non-commented line.
- if ( ( s.length() > 0 ) && ( s.charAt( 0 ) != '#' ) )
+ if ((s.length() > 0) && (s.charAt(0) != '#'))
{
- return ( FrameworkFactory ) Class.forName( s ).newInstance();
+ return (FrameworkFactory) Class.forName(s).newInstance();
}
}
}
finally
{
- if ( br != null )
+ if (br != null)
br.close();
}
}
- throw new Exception( "Could not find framework factory." );
+ throw new Exception("Could not find framework factory.");
}
-
- private static Map<String, String> buildConfig( CommandLine cl )
+ private static Map<String, String> buildConfig(CommandLine cl)
{
HashMap<String, String> config = new HashMap<String, String>();
- if ( cl.hasOption( 'c' ))
- config.put( "org.osgi.framework.storage.clean", "onFirstInit" );
-
- if ( cl.hasOption( 's' ) )
- config.put( "org.osgi.framework.startlevel.beginning", cl.getOptionValue( 's' ) );
-
+ if (cl.hasOption('c'))
+ config.put("org.osgi.framework.storage.clean", "onFirstInit");
+
+ if (cl.hasOption('s'))
+ config.put("org.osgi.framework.startlevel.beginning", cl.getOptionValue('s'));
+
return config;
}
-
- private static Server launch( CommandLine line ) throws IOException
+ private static Server launch(CommandLine line) throws IOException
{
- Server server = new Server( framework );
+ Server server = new Server(framework);
Properties props = new Properties();
- props.put( ADDRESS_PROPERTY, line.getOptionValue( 'a' ) );
- props.put( PORT_PROPERTY, line.getOptionValue( 'p' ) );
- server.start( props );
+ props.put(ADDRESS_PROPERTY, line.getOptionValue('a'));
+ props.put(PORT_PROPERTY, line.getOptionValue('p'));
+ server.start(props);
return server;
}
-
private static void printHelp()
{
HelpFormatter f = new HelpFormatter();
- f.printHelp( COMMAND_LINE_SYNTAX, options );
+ f.printHelp(COMMAND_LINE_SYNTAX, options);
}
-
- public static void log(String msg) {
- if ( verbose )
- System.out.println( msg );
+
+ public static void log(String msg)
+ {
+ if (verbose)
+ System.out.println(msg);
}
}
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Server.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Server.java
index 6d37887..4ee4357 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Server.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/Server.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.runtime;
-
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.EOFException;
@@ -47,7 +46,6 @@
import static org.apache.felix.sigil.common.runtime.Runtime.PORT_PROPERTY;
import static org.apache.felix.sigil.common.runtime.io.Constants.*;
-
/**
* @author dave
*
@@ -60,54 +58,52 @@
private AtomicBoolean stopped = new AtomicBoolean();
-
- public Server( Framework fw )
+ public Server(Framework fw)
{
this.fw = fw;
}
-
- public void start( Properties props ) throws IOException
+ public void start(Properties props) throws IOException
{
final ServerSocket socket = new ServerSocket();
-
- String v = props.getProperty( ADDRESS_PROPERTY );
- InetAddress address = v == null ? null : InetAddress.getByName( v );
- int port = Integer.parseInt( props.getProperty( PORT_PROPERTY, "0" ) );
-
- InetSocketAddress socketAddress = new InetSocketAddress(address, port);
- socket.bind( socketAddress );
- Main.log( "Started server listening on " + socket.getLocalSocketAddress() + ":" + socket.getLocalPort() );
-
- accept = new Thread( new Runnable()
+ String v = props.getProperty(ADDRESS_PROPERTY);
+ InetAddress address = v == null ? null : InetAddress.getByName(v);
+ int port = Integer.parseInt(props.getProperty(PORT_PROPERTY, "0"));
+
+ InetSocketAddress socketAddress = new InetSocketAddress(address, port);
+ socket.bind(socketAddress);
+
+ Main.log("Started server listening on " + socket.getLocalSocketAddress() + ":"
+ + socket.getLocalPort());
+
+ accept = new Thread(new Runnable()
{
public void run()
{
- while ( !stopped.get() )
+ while (!stopped.get())
{
try
{
- read.execute( new Reader( socket.accept() ) );
+ read.execute(new Reader(socket.accept()));
}
- catch ( IOException e )
+ catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
- } );
-
- accept.start();
-
- Main.log( "Started thread!" );
- }
+ });
+ accept.start();
+
+ Main.log("Started thread!");
+ }
public void stop()
{
- stopped.set( true );
+ stopped.set(true);
accept.interrupt();
accept = null;
}
@@ -117,81 +113,83 @@
private final Socket socket;
-
/**
* @param accept
*/
- public Reader( Socket socket )
+ public Reader(Socket socket)
{
this.socket = socket;
}
-
/* (non-Javadoc)
* @see java.lang.Runnable#run()
*/
public void run()
{
- Main.log( "Accepted " + socket.getInetAddress() + ":" + socket.getLocalPort() );
-
+ Main.log("Accepted " + socket.getInetAddress() + ":" + socket.getLocalPort());
+
try
{
- DataInputStream in = new DataInputStream( socket.getInputStream() );
- DataOutputStream out = new DataOutputStream( socket.getOutputStream() );
-
- while ( !stopped.get() )
+ DataInputStream in = new DataInputStream(socket.getInputStream());
+ DataOutputStream out = new DataOutputStream(socket.getOutputStream());
+
+ while (!stopped.get())
{
int action = in.readInt();
-
+
Action<?, ?> task = null;
-
- switch ( action )
+
+ switch (action)
{
case INSTALL:
- task = new InstallAction( in, out );
+ task = new InstallAction(in, out);
break;
case START:
- task = new StartAction( in, out );
+ task = new StartAction(in, out);
break;
case STOP:
- task = new StopAction( in, out );
+ task = new StopAction(in, out);
break;
case UNINSTALL:
- task = new UninstallAction( in, out );
+ task = new UninstallAction(in, out);
break;
case UPDATE:
- task = new UpdateAction( in, out );
+ task = new UpdateAction(in, out);
break;
case STATUS:
- task = new StatusAction( in, out );
+ task = new StatusAction(in, out);
break;
case REFRESH:
task = new RefreshAction(in, out);
break;
}
-
- if ( task == null ) {
- Main.log( "Invalid action " + action );
+
+ if (task == null)
+ {
+ Main.log("Invalid action " + action);
}
- else {
- task.server( fw );
+ else
+ {
+ task.server(fw);
}
}
}
- catch ( EOFException e ) {
+ catch (EOFException e)
+ {
// fine
}
- catch ( IOException e )
+ catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
- finally {
+ finally
+ {
try
{
socket.close();
}
- catch ( IOException e )
+ catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/AlreadySelectedException.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/AlreadySelectedException.java
index 32483c3..e1ce866 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/AlreadySelectedException.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/AlreadySelectedException.java
@@ -53,8 +53,9 @@
*/
public AlreadySelectedException(OptionGroup group, Option option)
{
- this("The option '" + option.getKey() + "' was specified but an option from this group "
- + "has already been selected: '" + group.getSelected() + "'");
+ this("The option '" + option.getKey()
+ + "' was specified but an option from this group "
+ + "has already been selected: '" + group.getSelected() + "'");
this.group = group;
this.option = option;
}
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/BasicParser.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/BasicParser.java
index 2737285..55bf80f 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/BasicParser.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/BasicParser.java
@@ -39,7 +39,8 @@
* when an non option is found.
* @return The <code>arguments</code> String array.
*/
- protected String[] flatten(Options options, String[] arguments, boolean stopAtNonOption)
+ protected String[] flatten(Options options, String[] arguments,
+ boolean stopAtNonOption)
{
// just echo the arguments
return arguments;
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/CommandLine.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/CommandLine.java
index 02d9dbc..912db47 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/CommandLine.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/CommandLine.java
@@ -89,11 +89,14 @@
*/
public Object getOptionObject(String opt)
{
- try {
+ try
+ {
return getParsedOptionValue(opt);
- } catch(ParseException pe) {
- System.err.println("Exception found converting " + opt + " to desired type: " +
- pe.getMessage() );
+ }
+ catch (ParseException pe)
+ {
+ System.err.println("Exception found converting " + opt + " to desired type: "
+ + pe.getMessage());
return null;
}
}
@@ -106,8 +109,7 @@
* @throws ParseException if there are problems turning the option value into the desired type
* @see PatternOptionBuilder
*/
- public Object getParsedOptionValue(String opt)
- throws ParseException
+ public Object getParsedOptionValue(String opt) throws ParseException
{
String res = getOptionValue(opt);
@@ -119,7 +121,7 @@
Object type = option.getType();
- return (res == null) ? null : TypeHandler.createValue(res, type);
+ return (res == null) ? null : TypeHandler.createValue(res, type);
}
/**
@@ -179,7 +181,8 @@
}
}
- return values.isEmpty() ? null : (String[]) values.toArray(new String[values.size()]);
+ return values.isEmpty() ? null
+ : (String[]) values.toArray(new String[values.size()]);
}
/**
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/CommandLineParser.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/CommandLineParser.java
index 237d637..cdfa8c2 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/CommandLineParser.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/CommandLineParser.java
@@ -70,7 +70,8 @@
* @throws ParseException if there are any problems encountered
* while parsing the command line tokens.
*/
- CommandLine parse(Options options, String[] arguments, boolean stopAtNonOption) throws ParseException;
+ CommandLine parse(Options options, String[] arguments, boolean stopAtNonOption)
+ throws ParseException;
/**
* Parse the arguments according to the specified options and
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/GnuParser.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/GnuParser.java
index c53cacf..e130aa9 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/GnuParser.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/GnuParser.java
@@ -46,7 +46,8 @@
* a non option has been encountered
* @return a String array of the flattened arguments
*/
- protected String[] flatten(Options options, String[] arguments, boolean stopAtNonOption)
+ protected String[] flatten(Options options, String[] arguments,
+ boolean stopAtNonOption)
{
List tokens = new ArrayList();
@@ -75,7 +76,8 @@
}
else
{
- if (opt.indexOf('=') != -1 && options.hasOption(opt.substring(0, opt.indexOf('='))))
+ if (opt.indexOf('=') != -1
+ && options.hasOption(opt.substring(0, opt.indexOf('='))))
{
// the format is --foo=value or -foo=value
tokens.add(arg.substring(0, arg.indexOf('='))); // --foo
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/HelpFormatter.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/HelpFormatter.java
index 46d9bf0..bb0cc2e 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/HelpFormatter.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/HelpFormatter.java
@@ -359,7 +359,8 @@
* @param options the Options instance
* @param footer the banner to display at the end of the help
*/
- public void printHelp(String cmdLineSyntax, String header, Options options, String footer)
+ public void printHelp(String cmdLineSyntax, String header, Options options,
+ String footer)
{
printHelp(cmdLineSyntax, header, options, footer, false);
}
@@ -376,7 +377,8 @@
* @param autoUsage whether to print an automatically generated
* usage statement
*/
- public void printHelp(String cmdLineSyntax, String header, Options options, String footer, boolean autoUsage)
+ public void printHelp(String cmdLineSyntax, String header, Options options,
+ String footer, boolean autoUsage)
{
printHelp(defaultWidth, cmdLineSyntax, header, options, footer, autoUsage);
}
@@ -392,7 +394,8 @@
* @param options the Options instance
* @param footer the banner to display at the end of the help
*/
- public void printHelp(int width, String cmdLineSyntax, String header, Options options, String footer)
+ public void printHelp(int width, String cmdLineSyntax, String header,
+ Options options, String footer)
{
printHelp(width, cmdLineSyntax, header, options, footer, false);
}
@@ -411,11 +414,12 @@
* usage statement
*/
public void printHelp(int width, String cmdLineSyntax, String header,
- Options options, String footer, boolean autoUsage)
+ Options options, String footer, boolean autoUsage)
{
PrintWriter pw = new PrintWriter(System.out);
- printHelp(pw, width, cmdLineSyntax, header, options, defaultLeftPad, defaultDescPad, footer, autoUsage);
+ printHelp(pw, width, cmdLineSyntax, header, options, defaultLeftPad,
+ defaultDescPad, footer, autoUsage);
pw.flush();
}
@@ -436,14 +440,13 @@
*
* @throws IllegalStateException if there is no room to print a line
*/
- public void printHelp(PrintWriter pw, int width, String cmdLineSyntax,
- String header, Options options, int leftPad,
- int descPad, String footer)
+ public void printHelp(PrintWriter pw, int width, String cmdLineSyntax, String header,
+ Options options, int leftPad, int descPad, String footer)
{
- printHelp(pw, width, cmdLineSyntax, header, options, leftPad, descPad, footer, false);
+ printHelp(pw, width, cmdLineSyntax, header, options, leftPad, descPad, footer,
+ false);
}
-
/**
* Print the help for <code>options</code> with the specified
* command line syntax.
@@ -463,9 +466,8 @@
*
* @throws IllegalStateException if there is no room to print a line
*/
- public void printHelp(PrintWriter pw, int width, String cmdLineSyntax,
- String header, Options options, int leftPad,
- int descPad, String footer, boolean autoUsage)
+ public void printHelp(PrintWriter pw, int width, String cmdLineSyntax, String header,
+ Options options, int leftPad, int descPad, String footer, boolean autoUsage)
{
if ((cmdLineSyntax == null) || (cmdLineSyntax.length() == 0))
{
@@ -534,7 +536,6 @@
// add the group to the processed list
processedGroups.add(group);
-
// add the usage clause
appendOptionGroup(buff, group);
}
@@ -555,7 +556,6 @@
}
}
-
// call printWrapped
printWrapped(pw, width, buff.toString().indexOf(' ') + 1, buff.toString());
}
@@ -602,7 +602,8 @@
* @param option the Option to append
* @param required whether the Option is required or not
*/
- private static void appendOption(final StringBuffer buff, final Option option, final boolean required)
+ private static void appendOption(final StringBuffer buff, final Option option,
+ final boolean required)
{
if (!required)
{
@@ -643,7 +644,8 @@
{
int argPos = cmdLineSyntax.indexOf(' ') + 1;
- printWrapped(pw, width, defaultSyntaxPrefix.length() + argPos, defaultSyntaxPrefix + cmdLineSyntax);
+ printWrapped(pw, width, defaultSyntaxPrefix.length() + argPos,
+ defaultSyntaxPrefix + cmdLineSyntax);
}
/**
@@ -658,8 +660,8 @@
* @param descPad the number of characters of padding to be prefixed
* to each description line
*/
- public void printOptions(PrintWriter pw, int width, Options options,
- int leftPad, int descPad)
+ public void printOptions(PrintWriter pw, int width, Options options, int leftPad,
+ int descPad)
{
StringBuffer sb = new StringBuffer();
@@ -711,7 +713,8 @@
*
* @return the StringBuffer with the rendered Options contents.
*/
- protected StringBuffer renderOptions(StringBuffer sb, int width, Options options, int leftPad, int descPad)
+ protected StringBuffer renderOptions(StringBuffer sb, int width, Options options,
+ int leftPad, int descPad)
{
final String lpad = createPadding(leftPad);
final String dpad = createPadding(descPad);
@@ -735,7 +738,8 @@
if (option.getOpt() == null)
{
- optBuf.append(lpad).append(" " + defaultLongOptPrefix).append(option.getLongOpt());
+ optBuf.append(lpad).append(" " + defaultLongOptPrefix).append(
+ option.getLongOpt());
}
else
{
@@ -743,7 +747,8 @@
if (option.hasLongOpt())
{
- optBuf.append(',').append(defaultLongOptPrefix).append(option.getLongOpt());
+ optBuf.append(',').append(defaultLongOptPrefix).append(
+ option.getLongOpt());
}
}
@@ -806,8 +811,8 @@
*
* @return the StringBuffer with the rendered Options contents.
*/
- protected StringBuffer renderWrappedText(StringBuffer sb, int width,
- int nextLineTabStop, String text)
+ protected StringBuffer renderWrappedText(StringBuffer sb, int width,
+ int nextLineTabStop, String text)
{
int pos = findWrapPos(text, width, 0);
@@ -840,8 +845,8 @@
return sb;
}
-
- if ( (text.length() > width) && (pos == nextLineTabStop - 1) )
+
+ if ((text.length() > width) && (pos == nextLineTabStop - 1))
{
pos = width;
}
@@ -869,7 +874,7 @@
// the line ends before the max wrap pos or a new line char found
if (((pos = text.indexOf('\n', startPos)) != -1 && pos <= width)
- || ((pos = text.indexOf('\t', startPos)) != -1 && pos <= width))
+ || ((pos = text.indexOf('\t', startPos)) != -1 && pos <= width))
{
return pos + 1;
}
@@ -878,14 +883,13 @@
return -1;
}
-
// look for the last whitespace character before startPos+width
pos = startPos + width;
char c;
- while ((pos >= startPos) && ((c = text.charAt(pos)) != ' ')
- && (c != '\n') && (c != '\r'))
+ while ((pos >= startPos) && ((c = text.charAt(pos)) != ' ') && (c != '\n')
+ && (c != '\r'))
{
--pos;
}
@@ -895,13 +899,13 @@
{
return pos;
}
-
+
// must look for the first whitespace chearacter after startPos
// + width
pos = startPos + width;
- while ((pos <= text.length()) && ((c = text.charAt(pos)) != ' ')
- && (c != '\n') && (c != '\r'))
+ while ((pos <= text.length()) && ((c = text.charAt(pos)) != ' ') && (c != '\n')
+ && (c != '\r'))
{
++pos;
}
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Option.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Option.java
index 8fd69a7..acf66e3 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Option.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Option.java
@@ -116,8 +116,7 @@
* @throws IllegalArgumentException if there are any non valid
* Option characters in <code>opt</code>.
*/
- public Option(String opt, String longOpt, boolean hasArg, String description)
- throws IllegalArgumentException
+ public Option(String opt, String longOpt, boolean hasArg, String description) throws IllegalArgumentException
{
// ensure that the option is valid
OptionValidator.validateOption(opt);
@@ -529,7 +528,8 @@
*/
public String[] getValues()
{
- return hasNoValues() ? null : (String[]) values.toArray(new String[values.size()]);
+ return hasNoValues() ? null
+ : (String[]) values.toArray(new String[values.size()]);
}
/**
@@ -603,7 +603,6 @@
Option option = (Option) o;
-
if (opt != null ? !opt.equals(option.opt) : option.opt != null)
{
return false;
@@ -644,7 +643,8 @@
}
catch (CloneNotSupportedException cnse)
{
- throw new RuntimeException("A CloneNotSupportedException was thrown: " + cnse.getMessage());
+ throw new RuntimeException("A CloneNotSupportedException was thrown: "
+ + cnse.getMessage());
}
}
@@ -667,7 +667,8 @@
*/
public boolean addValue(String value)
{
- throw new UnsupportedOperationException("The addValue method is not intended for client use. "
+ throw new UnsupportedOperationException(
+ "The addValue method is not intended for client use. "
+ "Subclasses should use the addValueForProcessing method instead. ");
}
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionBuilder.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionBuilder.java
index 7056769..2deef51 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionBuilder.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionBuilder.java
@@ -77,7 +77,6 @@
required = false;
numberOfArgs = Option.UNINITIALIZED;
-
// PMM 9/6/02 - these were missing
optionalArg = false;
valuesep = (char) 0;
@@ -346,7 +345,8 @@
public static Option create(String opt) throws IllegalArgumentException
{
Option option = null;
- try {
+ try
+ {
// create the option
option = new Option(opt, description);
@@ -358,7 +358,9 @@
option.setType(type);
option.setValueSeparator(valuesep);
option.setArgName(argName);
- } finally {
+ }
+ finally
+ {
// reset the OptionBuilder properties
OptionBuilder.reset();
}
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionGroup.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionGroup.java
index b209244..e9deeb2 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionGroup.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionGroup.java
@@ -32,7 +32,7 @@
public class OptionGroup implements Serializable
{
private static final long serialVersionUID = 1L;
-
+
/** hold the options */
private Map optionMap = new HashMap();
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionValidator.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionValidator.java
index a83d125..e051a95 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionValidator.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/OptionValidator.java
@@ -70,7 +70,8 @@
{
if (!isValidChar(chars[i]))
{
- throw new IllegalArgumentException("opt contains illegal character value '" + chars[i] + "'");
+ throw new IllegalArgumentException(
+ "opt contains illegal character value '" + chars[i] + "'");
}
}
}
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Options.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Options.java
index 79508f3..67f667e 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Options.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Options.java
@@ -126,7 +126,8 @@
* @param description Self-documenting description
* @return the resulting Options instance
*/
- public Options addOption(String opt, String longOpt, boolean hasArg, String description)
+ public Options addOption(String opt, String longOpt, boolean hasArg,
+ String description)
{
addOption(new Option(opt, longOpt, hasArg, description));
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Parser.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Parser.java
index 73fd762..bca2633 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Parser.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/Parser.java
@@ -68,7 +68,8 @@
* flattening when a non option has been encountered
* @return a String array of the flattened arguments
*/
- protected abstract String[] flatten(Options opts, String[] arguments, boolean stopAtNonOption);
+ protected abstract String[] flatten(Options opts, String[] arguments,
+ boolean stopAtNonOption);
/**
* Parses the specified <code>arguments</code> based
@@ -97,7 +98,8 @@
*
* @since 1.1
*/
- public CommandLine parse(Options options, String[] arguments, Properties properties) throws ParseException
+ public CommandLine parse(Options options, String[] arguments, Properties properties)
+ throws ParseException
{
return parse(options, arguments, properties, false);
}
@@ -114,7 +116,8 @@
* @return the <code>CommandLine</code>
* @throws ParseException if an error occurs when parsing the arguments.
*/
- public CommandLine parse(Options options, String[] arguments, boolean stopAtNonOption) throws ParseException
+ public CommandLine parse(Options options, String[] arguments, boolean stopAtNonOption)
+ throws ParseException
{
return parse(options, arguments, null, stopAtNonOption);
}
@@ -136,8 +139,8 @@
*
* @since 1.1
*/
- public CommandLine parse(Options options, String[] arguments, Properties properties, boolean stopAtNonOption)
- throws ParseException
+ public CommandLine parse(Options options, String[] arguments, Properties properties,
+ boolean stopAtNonOption) throws ParseException
{
// clear out the data in options in case it's been used before (CLI-71)
for (Iterator it = options.helpOptions().iterator(); it.hasNext();)
@@ -271,8 +274,7 @@
}
}
else if (!("yes".equalsIgnoreCase(value)
- || "true".equalsIgnoreCase(value)
- || "1".equalsIgnoreCase(value)))
+ || "true".equalsIgnoreCase(value) || "1".equalsIgnoreCase(value)))
{
// if the value is not yes, true or 1 then don't add the
// option to the CommandLine
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/PatternOptionBuilder.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/PatternOptionBuilder.java
index 34a0662..596e6b3 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/PatternOptionBuilder.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/PatternOptionBuilder.java
@@ -127,16 +127,8 @@
*/
public static boolean isValueCode(char ch)
{
- return ch == '@'
- || ch == ':'
- || ch == '%'
- || ch == '+'
- || ch == '#'
- || ch == '<'
- || ch == '>'
- || ch == '*'
- || ch == '/'
- || ch == '!';
+ return ch == '@' || ch == ':' || ch == '%' || ch == '+' || ch == '#' || ch == '<'
+ || ch == '>' || ch == '*' || ch == '/' || ch == '!';
}
/**
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/PosixParser.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/PosixParser.java
index bc0a846..5969db6 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/PosixParser.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/PosixParser.java
@@ -92,7 +92,8 @@
* when an non option is found.
* @return The flattened <code>arguments</code> String array.
*/
- protected String[] flatten(Options options, String[] arguments, boolean stopAtNonOption)
+ protected String[] flatten(Options options, String[] arguments,
+ boolean stopAtNonOption)
{
init();
this.options = options;
@@ -119,7 +120,7 @@
else
{
currentOption = options.getOption(opt);
-
+
tokens.add(opt);
if (pos != -1)
{
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/TypeHandler.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/TypeHandler.java
index 8f87762..cffe14b 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/TypeHandler.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/cli/TypeHandler.java
@@ -43,8 +43,7 @@
* @return The instance of <code>obj</code> initialised with
* the value of <code>str</code>.
*/
- public static Object createValue(String str, Object obj)
- throws ParseException
+ public static Object createValue(String str, Object obj) throws ParseException
{
return createValue(str, (Class) obj);
}
@@ -58,8 +57,7 @@
* @return The instance of <code>clazz</code> initialised with
* the value of <code>str</code>.
*/
- public static Object createValue(String str, Class clazz)
- throws ParseException
+ public static Object createValue(String str, Class clazz) throws ParseException
{
if (PatternOptionBuilder.STRING_VALUE == clazz)
{
@@ -110,8 +108,7 @@
* @return the initialised object, or null if it couldn't create
* the Object.
*/
- public static Object createObject(String classname)
- throws ParseException
+ public static Object createObject(String classname) throws ParseException
{
Class cl = null;
@@ -132,7 +129,8 @@
}
catch (Exception e)
{
- throw new ParseException(e.getClass().getName() + "; Unable to create an instance of: " + classname);
+ throw new ParseException(e.getClass().getName()
+ + "; Unable to create an instance of: " + classname);
}
return instance;
@@ -146,8 +144,7 @@
* @return the number represented by <code>str</code>, if <code>str</code>
* is not a number, null is returned.
*/
- public static Number createNumber(String str)
- throws ParseException
+ public static Number createNumber(String str) throws ParseException
{
try
{
@@ -172,8 +169,7 @@
* @param classname the class name
* @return The class if it is found, otherwise return null
*/
- public static Class createClass(String classname)
- throws ParseException
+ public static Class createClass(String classname) throws ParseException
{
try
{
@@ -192,8 +188,7 @@
* @return The date if <code>str</code> is a valid date string,
* otherwise return null.
*/
- public static Date createDate(String str)
- throws ParseException
+ public static Date createDate(String str) throws ParseException
{
throw new UnsupportedOperationException("Not yet implemented");
}
@@ -205,8 +200,7 @@
* @return The URL is <code>str</code> is well-formed, otherwise
* return null.
*/
- public static URL createURL(String str)
- throws ParseException
+ public static URL createURL(String str) throws ParseException
{
try
{
@@ -224,8 +218,7 @@
* @param str the File location
* @return The file represented by <code>str</code>.
*/
- public static File createFile(String str)
- throws ParseException
+ public static File createFile(String str) throws ParseException
{
return new File(str);
}
@@ -236,8 +229,7 @@
* @param str the paths to the files
* @return The File[] represented by <code>str</code>.
*/
- public static File[] createFiles(String str)
- throws ParseException
+ public static File[] createFiles(String str) throws ParseException
{
// to implement/port:
// return FileW.findFiles(str);
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/Action.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/Action.java
index 3beef14..40dd629 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/Action.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/Action.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.runtime.io;
-
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
@@ -34,7 +33,6 @@
import static org.apache.felix.sigil.common.runtime.io.Constants.OK;
import static org.apache.felix.sigil.common.runtime.io.Constants.ERROR;
-
/**
* @author dave
*
@@ -46,123 +44,118 @@
private final DataInputStream in;
private final DataOutputStream out;
-
- public Action( DataInputStream in, DataOutputStream out ) throws IOException
+ public Action(DataInputStream in, DataOutputStream out) throws IOException
{
this.in = in;
this.out = out;
}
-
public O client() throws IOException, BundleException
{
- return client( null );
+ return client(null);
}
+ public abstract O client(I input) throws IOException, BundleException;
- public abstract O client( I input ) throws IOException, BundleException;
-
-
- public abstract void server( Framework fw ) throws IOException;
-
+ public abstract void server(Framework fw) throws IOException;
protected boolean checkOk() throws IOException
{
int ch = readInt();
- switch ( ch )
+ switch (ch)
{
case OK:
return true;
case ERROR:
return false;
default:
- throw new IOException( "Unexpected return code " + ch );
+ throw new IOException("Unexpected return code " + ch);
}
}
-
protected void writeOk() throws IOException
{
- writeInt( OK );
+ writeInt(OK);
}
-
protected void writeError() throws IOException
{
- writeInt( ERROR );
+ writeInt(ERROR);
}
- protected void writeThrowable(Throwable t) throws IOException {
+ protected void writeThrowable(Throwable t) throws IOException
+ {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
- t.printStackTrace(new PrintStream( bos ));
- writeString( bos.toString() );
+ t.printStackTrace(new PrintStream(bos));
+ writeString(bos.toString());
}
protected String readString() throws IOException
{
int l = in.readInt();
- if ( l == -1 ) {
+ if (l == -1)
+ {
return null;
}
- else {
+ else
+ {
byte[] buf = new byte[l];
- in.readFully( buf );
+ in.readFully(buf);
return new String(buf, ASCII);
}
}
-
- protected void writeString( String str ) throws IOException
+ protected void writeString(String str) throws IOException
{
- if ( str == null ) {
+ if (str == null)
+ {
out.writeInt(-1);
}
- else {
- byte[] buf = str.getBytes( ASCII );
- out.writeInt( buf.length );
- out.write( buf );
+ else
+ {
+ byte[] buf = str.getBytes(ASCII);
+ out.writeInt(buf.length);
+ out.write(buf);
}
}
-
- protected void writeInt( int i ) throws IOException
+ protected void writeInt(int i) throws IOException
{
- out.writeInt( i );
+ out.writeInt(i);
}
-
protected int readInt() throws IOException
{
return in.readInt();
}
-
- protected void writeLong( long l ) throws IOException
- {
- out.writeLong( l );
+ protected void writeLong(long l) throws IOException
+ {
+ out.writeLong(l);
}
-
protected long readLong() throws IOException
{
return in.readLong();
}
- protected void writeBoolean( boolean b ) throws IOException
+ protected void writeBoolean(boolean b) throws IOException
{
- out.writeBoolean( b );
+ out.writeBoolean(b);
}
-
- protected boolean readBoolean() throws IOException {
+
+ protected boolean readBoolean() throws IOException
+ {
return in.readBoolean();
}
-
+
protected void flush() throws IOException
{
out.flush();
}
-
- protected void log(String msg) {
- Main.log( msg );
+
+ protected void log(String msg)
+ {
+ Main.log(msg);
}
}
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/Constants.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/Constants.java
index d3221a8..2f56779 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/Constants.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/Constants.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.runtime.io;
-
public interface Constants
{
public static final int OK = 0;
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/InstallAction.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/InstallAction.java
index 3a822ec..8fe3210 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/InstallAction.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/InstallAction.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.runtime.io;
-
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
@@ -30,7 +29,6 @@
import static org.apache.felix.sigil.common.runtime.io.Constants.INSTALL;
-
/**
* @author dave
*
@@ -38,46 +36,44 @@
public class InstallAction extends Action<String, Long>
{
- public InstallAction( DataInputStream in, DataOutputStream out ) throws IOException
+ public InstallAction(DataInputStream in, DataOutputStream out) throws IOException
{
- super( in, out );
+ super(in, out);
}
-
@Override
- public Long client( String url ) throws IOException, BundleException
+ public Long client(String url) throws IOException, BundleException
{
- writeInt( INSTALL );
- writeString( url );
+ writeInt(INSTALL);
+ writeString(url);
flush();
- if ( checkOk() )
+ if (checkOk())
{
return readLong();
}
else
{
String msg = readString();
- throw new BundleException( msg );
+ throw new BundleException(msg);
}
}
-
@Override
- public void server( Framework fw ) throws IOException
+ public void server(Framework fw) throws IOException
{
String url = readString();
try
{
- Bundle val = fw.getBundleContext().installBundle( url );
- log( "Installed " + url );
+ Bundle val = fw.getBundleContext().installBundle(url);
+ log("Installed " + url);
writeOk();
- writeLong( val.getBundleId() );
+ writeLong(val.getBundleId());
}
- catch ( BundleException e )
+ catch (BundleException e)
{
e.printStackTrace();
writeError();
- writeThrowable( e );
+ writeThrowable(e);
}
flush();
}
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/RefreshAction.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/RefreshAction.java
index 9f0064d..c2ec3ec 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/RefreshAction.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/RefreshAction.java
@@ -40,30 +40,35 @@
@Override
public Void client(Void input) throws IOException, BundleException
{
- writeInt( REFRESH );
+ writeInt(REFRESH);
flush();
- if ( checkOk() )
+ if (checkOk())
{
return null;
}
else
{
String msg = readString();
- throw new BundleException( msg );
+ throw new BundleException(msg);
}
}
@Override
public void server(Framework fw) throws IOException
{
- ServiceReference ref = fw.getBundleContext().getServiceReference(PackageAdmin.class.getName());
- if ( ref != null ) {
+ ServiceReference ref = fw.getBundleContext().getServiceReference(
+ PackageAdmin.class.getName());
+ if (ref != null)
+ {
PackageAdmin pa = (PackageAdmin) fw.getBundleContext().getService(ref);
- if ( pa != null ) {
- try {
+ if (pa != null)
+ {
+ try
+ {
pa.refreshPackages(null);
}
- finally {
+ finally
+ {
fw.getBundleContext().ungetService(ref);
}
}
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/StartAction.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/StartAction.java
index 41958cc..3eb8d0a 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/StartAction.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/StartAction.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.runtime.io;
-
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
@@ -30,7 +29,6 @@
import static org.apache.felix.sigil.common.runtime.io.Constants.START;
-
/**
* @author dave
*
@@ -38,36 +36,34 @@
public class StartAction extends Action<Long, Void>
{
- public StartAction( DataInputStream in, DataOutputStream out ) throws IOException
+ public StartAction(DataInputStream in, DataOutputStream out) throws IOException
{
- super( in, out );
+ super(in, out);
}
-
@Override
- public Void client( Long bundle ) throws IOException, BundleException
+ public Void client(Long bundle) throws IOException, BundleException
{
- writeInt( START );
- writeLong( bundle );
+ writeInt(START);
+ writeLong(bundle);
flush();
- if ( !checkOk() )
+ if (!checkOk())
{
String msg = readString();
- throw new BundleException( msg );
+ throw new BundleException(msg);
}
return null;
}
-
@Override
- public void server( Framework fw ) throws IOException
+ public void server(Framework fw) throws IOException
{
long id = readLong();
- Bundle b = fw.getBundleContext().getBundle( id );
- if ( b == null )
+ Bundle b = fw.getBundleContext().getBundle(id);
+ if (b == null)
{
writeError();
- writeString( "Unknown bundle " + id );
+ writeString("Unknown bundle " + id);
}
else
{
@@ -75,9 +71,9 @@
{
b.start();
writeOk();
- log( "Started " + b.getSymbolicName() );
+ log("Started " + b.getSymbolicName());
}
- catch ( BundleException e )
+ catch (BundleException e)
{
writeError();
writeThrowable(e);
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/StatusAction.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/StatusAction.java
index 687ee4f..8fdebd7 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/StatusAction.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/StatusAction.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.runtime.io;
-
import java.io.DataInputStream;
import java.io.DataOutputStream;
@@ -34,7 +33,6 @@
import static org.osgi.framework.Constants.BUNDLE_VERSION;
import static org.osgi.framework.Constants.BUNDLE_NAME;
-
/**
* @author dave
*
@@ -42,21 +40,21 @@
public class StatusAction extends Action<Void, BundleStatus[]>
{
- public StatusAction( DataInputStream in, DataOutputStream out ) throws IOException
+ public StatusAction(DataInputStream in, DataOutputStream out) throws IOException
{
- super( in, out );
+ super(in, out);
}
-
@Override
- public BundleStatus[] client( Void in ) throws IOException
+ public BundleStatus[] client(Void in) throws IOException
{
writeInt(STATUS);
flush();
int num = readInt();
ArrayList<BundleStatus> ret = new ArrayList<BundleStatus>(num);
-
- for (int i = 0; i < num; i++) {
+
+ for (int i = 0; i < num; i++)
+ {
BundleStatus s = new BundleStatus();
s.setId(readLong());
s.setBundleSymbolicName(readString());
@@ -65,29 +63,29 @@
s.setStatus(readInt());
ret.add(s);
}
-
+
return ret.toArray(new BundleStatus[num]);
}
-
@Override
- public void server( Framework fw ) throws IOException
+ public void server(Framework fw) throws IOException
{
- log( "Read status" );
+ log("Read status");
Bundle[] bundles = fw.getBundleContext().getBundles();
- writeInt( bundles.length );
- for ( Bundle b : bundles ) {
+ writeInt(bundles.length);
+ for (Bundle b : bundles)
+ {
writeLong(b.getBundleId());
String bsn = b.getSymbolicName();
- if ( bsn == null )
+ if (bsn == null)
bsn = (String) b.getHeaders().get(BUNDLE_NAME);
-
+
writeString(bsn);
- writeString((String) b.getHeaders().get( BUNDLE_VERSION ));
+ writeString((String) b.getHeaders().get(BUNDLE_VERSION));
writeString(b.getLocation());
writeInt(b.getState());
flush();
}
- flush();
+ flush();
}
}
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/StopAction.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/StopAction.java
index a44818b..5af9355 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/StopAction.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/StopAction.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.runtime.io;
-
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
@@ -30,7 +29,6 @@
import static org.apache.felix.sigil.common.runtime.io.Constants.STOP;
-
/**
* @author dave
*
@@ -38,36 +36,34 @@
public class StopAction extends Action<Long, Void>
{
- public StopAction( DataInputStream in, DataOutputStream out ) throws IOException
+ public StopAction(DataInputStream in, DataOutputStream out) throws IOException
{
- super( in, out );
+ super(in, out);
// TODO Auto-generated constructor stub
}
-
@Override
- public Void client( Long bundle ) throws IOException, BundleException
+ public Void client(Long bundle) throws IOException, BundleException
{
- writeInt( STOP );
- writeLong( bundle );
- if ( !checkOk() )
+ writeInt(STOP);
+ writeLong(bundle);
+ if (!checkOk())
{
String msg = readString();
- throw new BundleException( msg );
+ throw new BundleException(msg);
}
return null;
}
-
@Override
- public void server( Framework fw ) throws IOException
+ public void server(Framework fw) throws IOException
{
long id = readLong();
- Bundle b = fw.getBundleContext().getBundle( id );
- if ( b == null )
+ Bundle b = fw.getBundleContext().getBundle(id);
+ if (b == null)
{
writeError();
- writeString( "Unknown bundle " + id );
+ writeString("Unknown bundle " + id);
}
else
{
@@ -76,10 +72,10 @@
b.stop();
writeOk();
}
- catch ( BundleException e )
+ catch (BundleException e)
{
writeError();
- writeThrowable( e );
+ writeThrowable(e);
}
}
}
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/UninstallAction.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/UninstallAction.java
index eddf847..7212b26 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/UninstallAction.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/UninstallAction.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.runtime.io;
-
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
@@ -30,7 +29,6 @@
import static org.apache.felix.sigil.common.runtime.io.Constants.UNINSTALL;
-
/**
* @author dave
*
@@ -38,35 +36,33 @@
public class UninstallAction extends Action<Long, Void>
{
- public UninstallAction( DataInputStream in, DataOutputStream out ) throws IOException
+ public UninstallAction(DataInputStream in, DataOutputStream out) throws IOException
{
- super( in, out );
+ super(in, out);
}
-
@Override
- public Void client( Long bundle ) throws IOException, BundleException
+ public Void client(Long bundle) throws IOException, BundleException
{
- writeInt( UNINSTALL );
- writeLong( bundle );
- if ( !checkOk() )
+ writeInt(UNINSTALL);
+ writeLong(bundle);
+ if (!checkOk())
{
String msg = readString();
- throw new BundleException( msg );
+ throw new BundleException(msg);
}
return null;
}
-
@Override
- public void server( Framework fw ) throws IOException
+ public void server(Framework fw) throws IOException
{
long id = readLong();
- Bundle b = fw.getBundleContext().getBundle( id );
- if ( b == null )
+ Bundle b = fw.getBundleContext().getBundle(id);
+ if (b == null)
{
writeError();
- writeString( "Unknown bundle " + id );
+ writeString("Unknown bundle " + id);
}
else
{
@@ -75,10 +71,10 @@
b.uninstall();
writeOk();
}
- catch ( BundleException e )
+ catch (BundleException e)
{
writeError();
- writeThrowable( e );
+ writeThrowable(e);
}
}
}
diff --git a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/UpdateAction.java b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/UpdateAction.java
index 905e0b7..628fdd9 100644
--- a/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/UpdateAction.java
+++ b/sigil/common/runtime/src/org/apache/felix/sigil/common/runtime/io/UpdateAction.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.common.runtime.io;
-
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
@@ -32,7 +31,6 @@
import static org.apache.felix.sigil.common.runtime.io.Constants.UPDATE;
-
/**
* @author dave
*
@@ -44,79 +42,79 @@
final long bundleID;
final String location;
-
- public Update( long bundleID, String location )
+ public Update(long bundleID, String location)
{
this.bundleID = bundleID;
this.location = location;
}
}
-
- public UpdateAction( DataInputStream in, DataOutputStream out ) throws IOException
+ public UpdateAction(DataInputStream in, DataOutputStream out) throws IOException
{
- super( in, out );
+ super(in, out);
// TODO Auto-generated constructor stub
}
-
@Override
- public Void client( Update update ) throws IOException, BundleException
+ public Void client(Update update) throws IOException, BundleException
{
- writeInt( UPDATE );
- writeLong( update.bundleID );
- if ( update.location == null )
+ writeInt(UPDATE);
+ writeLong(update.bundleID);
+ if (update.location == null)
{
- writeBoolean( false );
+ writeBoolean(false);
}
else
{
- writeBoolean( true );
- writeString( update.location );
+ writeBoolean(true);
+ writeString(update.location);
}
flush();
- if ( !checkOk() )
+ if (!checkOk())
{
String msg = readString();
- throw new BundleException( msg );
+ throw new BundleException(msg);
}
return null;
}
-
@Override
- public void server( Framework fw ) throws IOException
+ public void server(Framework fw) throws IOException
{
long id = readLong();
- Bundle b = fw.getBundleContext().getBundle( id );
- if ( b == null )
+ Bundle b = fw.getBundleContext().getBundle(id);
+ if (b == null)
{
writeError();
- writeString( "Unknown bundle " + id );
+ writeString("Unknown bundle " + id);
}
else
{
try
{
boolean remote = readBoolean();
- if ( remote )
+ if (remote)
{
String loc = readString();
- try {
- InputStream in = open( loc );
- try {
+ try
+ {
+ InputStream in = open(loc);
+ try
+ {
b.update(in);
writeOk();
}
- finally {
+ finally
+ {
in.close();
}
}
- catch (IOException e) {
+ catch (IOException e)
+ {
writeError();
- writeThrowable( e );
+ writeThrowable(e);
}
}
else
@@ -125,20 +123,19 @@
writeOk();
}
}
- catch ( BundleException e )
+ catch (BundleException e)
{
writeError();
- writeString( e.getMessage() );
+ writeString(e.getMessage());
}
}
flush();
}
-
- private InputStream open( String loc ) throws IOException
+ private InputStream open(String loc) throws IOException
{
- URL url = new URL( loc );
+ URL url = new URL(loc);
return url.openStream();
}
}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/PathUtil.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/PathUtil.java
index e3a524b..9cea7fd 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/PathUtil.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/PathUtil.java
@@ -39,18 +39,18 @@
return path == null ? null : new Path(path);
}
-
/**
* @param absolutePath
* @return
*/
public static IPath newPathIfExists(File file)
{
- if (file == null) return null;
- if (file.exists()) return new Path(file.getAbsolutePath());
+ if (file == null)
+ return null;
+ if (file.exists())
+ return new Path(file.getAbsolutePath());
// fine
return null;
}
-
}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/SigilCore.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/SigilCore.java
index defb0fa..4f76a03 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/SigilCore.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/SigilCore.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse;
-
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -81,7 +80,6 @@
import org.osgi.framework.BundleContext;
import org.osgi.util.tracker.ServiceTracker;
-
/**
* The activator class controls the plug-in life cycle
*/
@@ -92,19 +90,25 @@
// The plug-in ID
public static final String PLUGIN_ID = BASE + ".eclipse.core";
public static final String NATURE_ID = BASE + ".sigilnature";
- public static final String PREFERENCES_ID = BASE + ".ui.preferences.SigilPreferencePage";
- public static final String OSGI_INSTALLS_PREFERENCES_ID = BASE + ".ui.preferences.osgiInstalls";
- public static final String EXCLUDED_RESOURCES_PREFERENCES_ID = BASE + ".ui.preferences.excludedResources";
- public static final String REPOSITORIES_PREFERENCES_ID = BASE + ".ui.preferences.repositoriesPreferencePage";
+ public static final String PREFERENCES_ID = BASE
+ + ".ui.preferences.SigilPreferencePage";
+ public static final String OSGI_INSTALLS_PREFERENCES_ID = BASE
+ + ".ui.preferences.osgiInstalls";
+ public static final String EXCLUDED_RESOURCES_PREFERENCES_ID = BASE
+ + ".ui.preferences.excludedResources";
+ public static final String REPOSITORIES_PREFERENCES_ID = BASE
+ + ".ui.preferences.repositoriesPreferencePage";
public static final String SIGIL_PROJECT_FILE = IBldProject.PROJECT_FILE;
public static final String BUILDER_ID = PLUGIN_ID + ".sigilBuilder";
public static final String CLASSPATH_CONTAINER_PATH = BASE + ".classpathContainer";
public static final String OSGI_INSTALLS = BASE + ".osgi.installs";
- public static final String OSGI_DEFAULT_INSTALL_ID = BASE + ".osgi.default.install.id";
+ public static final String OSGI_DEFAULT_INSTALL_ID = BASE
+ + ".osgi.default.install.id";
public static final String OSGI_INSTALL_PREFIX = BASE + ".osgi.install.";
public static final String OSGI_SOURCE_LOCATION = BASE + ".osgi.source.location";
- public static final String OSGI_INSTALL_CHECK_PREFERENCE = BASE + ".osgi.install.check";
+ public static final String OSGI_INSTALL_CHECK_PREFERENCE = BASE
+ + ".osgi.install.check";
public static final String LIBRARY_KEYS_PREF = BASE + ".library.keys";
public static final String PREFERENCES_REBUILD_PROJECTS = BASE + ".rebuild.projects";
public static final String QUALIFY_VERSIONS = BASE + ".qualify.versions";
@@ -113,20 +117,29 @@
public static final String DEFAULT_VERSION_UPPER_BOUND = BASE + ".versionUpperBound";
public static final String DEFAULT_EXCLUDED_RESOURCES = BASE + ".excludedResources";
- public static final String INCLUDE_OPTIONAL_DEPENDENCIES = BASE + ".includeOptionalDependencies";
+ public static final String INCLUDE_OPTIONAL_DEPENDENCIES = BASE
+ + ".includeOptionalDependencies";
- public static final String INSTALL_BUILDER_EXTENSION_POINT_ID = BASE + ".installbuilder";
- public static final String REPOSITORY_PROVIDER_EXTENSION_POINT_ID = BASE + ".repositoryprovider";
+ public static final String INSTALL_BUILDER_EXTENSION_POINT_ID = BASE
+ + ".installbuilder";
+ public static final String REPOSITORY_PROVIDER_EXTENSION_POINT_ID = BASE
+ + ".repositoryprovider";
- public static final String MARKER_UNRESOLVED_DEPENDENCY = BASE + ".unresolvedDependencyMarker";
- public static final String MARKER_UNRESOLVED_IMPORT_PACKAGE = BASE + ".unresolvedDependencyMarker.importPackage";
- public static final String MARKER_UNRESOLVED_REQUIRE_BUNDLE = BASE + ".unresolvedDependencyMarker.requireBundle";
+ public static final String MARKER_UNRESOLVED_DEPENDENCY = BASE
+ + ".unresolvedDependencyMarker";
+ public static final String MARKER_UNRESOLVED_IMPORT_PACKAGE = BASE
+ + ".unresolvedDependencyMarker.importPackage";
+ public static final String MARKER_UNRESOLVED_REQUIRE_BUNDLE = BASE
+ + ".unresolvedDependencyMarker.requireBundle";
public static final String REPOSITORY_SET = PLUGIN_ID + ".repository.set";
-
+
public static final String PREFERENCES_NOASK_OSGI_INSTALL = BASE + ".noAskOSGIHome";
- public static final String PREFERENCES_ADD_IMPORT_FOR_EXPORT = BASE + ".addImportForExport";
- public static final String PREFERENCES_INCLUDE_OPTIONAL = PLUGIN_ID + ".include.optional";
- public static final String PREFERENCES_REMOVE_IMPORT_FOR_EXPORT = BASE + ".removeImportForExport";
+ public static final String PREFERENCES_ADD_IMPORT_FOR_EXPORT = BASE
+ + ".addImportForExport";
+ public static final String PREFERENCES_INCLUDE_OPTIONAL = PLUGIN_ID
+ + ".include.optional";
+ public static final String PREFERENCES_REMOVE_IMPORT_FOR_EXPORT = BASE
+ + ".removeImportForExport";
private static final Object NULL = new Object();
@@ -154,72 +167,64 @@
return plugin;
}
-
- public static CoreException newCoreException( String msg, Throwable t )
+ public static CoreException newCoreException(String msg, Throwable t)
{
- return new CoreException( makeStatus( msg, t, IStatus.ERROR ) );
+ return new CoreException(makeStatus(msg, t, IStatus.ERROR));
}
-
- public static void log( String msg )
+ public static void log(String msg)
{
- DebugPlugin.log( makeStatus( msg, null, IStatus.INFO ) );
+ DebugPlugin.log(makeStatus(msg, null, IStatus.INFO));
}
-
- public static void error( String msg )
+ public static void error(String msg)
{
- DebugPlugin.log( makeStatus( msg, null, IStatus.ERROR ) );
+ DebugPlugin.log(makeStatus(msg, null, IStatus.ERROR));
}
-
- public static void error( String msg, Throwable t )
+ public static void error(String msg, Throwable t)
{
- DebugPlugin.log( makeStatus( msg, t, IStatus.ERROR ) );
+ DebugPlugin.log(makeStatus(msg, t, IStatus.ERROR));
}
-
- public static void warn( String msg )
+ public static void warn(String msg)
{
- DebugPlugin.log( makeStatus( msg, null, IStatus.WARNING ) );
+ DebugPlugin.log(makeStatus(msg, null, IStatus.WARNING));
}
-
- public static void warn( String msg, Throwable t )
+ public static void warn(String msg, Throwable t)
{
- DebugPlugin.log( makeStatus( msg, t, IStatus.WARNING ) );
+ DebugPlugin.log(makeStatus(msg, t, IStatus.WARNING));
}
-
- private static IStatus makeStatus( String msg, Throwable t, int status )
+ private static IStatus makeStatus(String msg, Throwable t, int status)
{
- if ( t instanceof CoreException )
+ if (t instanceof CoreException)
{
- CoreException c = ( CoreException ) t;
+ CoreException c = (CoreException) t;
return c.getStatus();
}
else
{
- return new Status( status, SigilCore.PLUGIN_ID, status, msg, t );
+ return new Status(status, SigilCore.PLUGIN_ID, status, msg, t);
}
}
-
- public static boolean isSigilProject( IProject resource )
+ public static boolean isSigilProject(IProject resource)
{
- if ( resource == null )
+ if (resource == null)
return false;
- if ( resource.isAccessible() && resource instanceof IProject )
+ if (resource.isAccessible() && resource instanceof IProject)
{
- IProject project = ( IProject ) resource;
+ IProject project = (IProject) resource;
try
{
- return project.hasNature( NATURE_ID );
+ return project.hasNature(NATURE_ID);
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- error( e.getMessage(), e );
+ error(e.getMessage(), e);
return false;
}
}
@@ -229,26 +234,22 @@
}
}
-
- public static boolean hasProjectNature( IProject project ) throws CoreException
+ public static boolean hasProjectNature(IProject project) throws CoreException
{
- return project.getNature( NATURE_ID ) != null;
+ return project.getNature(NATURE_ID) != null;
}
-
public static ResourceBundle getResourceBundle()
{
- return ResourceBundle.getBundle( "resources." + SigilCore.class.getName(), Locale.getDefault(), SigilCore.class
- .getClassLoader() );
+ return ResourceBundle.getBundle("resources." + SigilCore.class.getName(),
+ Locale.getDefault(), SigilCore.class.getClassLoader());
}
-
- public static ISigilProjectModel create( IProject project ) throws CoreException
+ public static ISigilProjectModel create(IProject project) throws CoreException
{
return projectManager.getSigilProject(project);
}
-
/**
* The constructor
*/
@@ -257,12 +258,10 @@
plugin = this;
}
-
public void earlyStartup()
{
}
-
/*
* (non-Javadoc)
*
@@ -270,9 +269,9 @@
* org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext
* )
*/
- public void start( final BundleContext context ) throws Exception
+ public void start(final BundleContext context) throws Exception
{
- super.start( context );
+ super.start(context);
modelRoot = new SigilModelRoot();
@@ -283,14 +282,13 @@
repositoryMap = new RepositoryMap();
globalRepositoryManager = new GlobalRepositoryManager(repositoryMap);
globalRepositoryManager.initialise();
-
+
projectManager = new SigilProjectManager();
- registerModelElements( context );
+ registerModelElements(context);
registerResourceListeners();
}
-
/*
* (non-Javadoc)
*
@@ -298,27 +296,27 @@
* org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext
* )
*/
- public void stop( BundleContext context ) throws Exception
+ public void stop(BundleContext context) throws Exception
{
- if ( descriptorTracker != null )
+ if (descriptorTracker != null)
{
descriptorTracker.close();
descriptorTracker = null;
}
- if ( registryTracker != null )
+ if (registryTracker != null)
{
registryTracker.close();
registryTracker = null;
}
- if ( serializerTracker != null )
+ if (serializerTracker != null)
{
serializerTracker.close();
serializerTracker = null;
}
- for ( SigilRepositoryManager m : repositoryManagers.values() )
+ for (SigilRepositoryManager m : repositoryManagers.values())
{
m.destroy();
}
@@ -330,24 +328,23 @@
plugin = null;
- super.stop( context );
+ super.stop(context);
}
-
- public static boolean isBundledPath( String bp ) throws CoreException
+ public static boolean isBundledPath(String bp) throws CoreException
{
- boolean bundle = JavaHelper.isCachedBundle( bp );
+ boolean bundle = JavaHelper.isCachedBundle(bp);
- if ( !bundle )
+ if (!bundle)
{
- bundle = isProjectPath( bp );
+ bundle = isProjectPath(bp);
- if ( !bundle )
+ if (!bundle)
{
- for ( IBundleRepository r : getGlobalRepositoryManager().getRepositories() )
+ for (IBundleRepository r : getGlobalRepositoryManager().getRepositories())
{
- bundle = isBundlePath( bp, r );
- if ( bundle )
+ bundle = isBundlePath(bp, r);
+ if (bundle)
break;
}
}
@@ -356,19 +353,18 @@
return bundle;
}
-
- private static boolean isBundlePath( final String bp, IBundleRepository r )
+ private static boolean isBundlePath(final String bp, IBundleRepository r)
{
final AtomicBoolean flag = new AtomicBoolean();
IRepositoryVisitor visitor = new IRepositoryVisitor()
{
- public boolean visit( ISigilBundle b )
+ public boolean visit(ISigilBundle b)
{
File path = b.getLocation();
- if ( path != null && path.getAbsolutePath().equals( bp ) )
+ if (path != null && path.getAbsolutePath().equals(bp))
{
- flag.set( true );
+ flag.set(true);
return false;
}
else
@@ -379,19 +375,18 @@
};
- r.accept( visitor, ResolutionConfig.INDEXED_ONLY | ResolutionConfig.LOCAL_ONLY );
+ r.accept(visitor, ResolutionConfig.INDEXED_ONLY | ResolutionConfig.LOCAL_ONLY);
return flag.get();
}
-
- private static boolean isProjectPath( String bp ) throws CoreException
+ private static boolean isProjectPath(String bp) throws CoreException
{
- for ( ISigilProjectModel p : SigilCore.getRoot().getProjects() )
+ for (ISigilProjectModel p : SigilCore.getRoot().getProjects())
{
IPath path = p.findOutputLocation();
- if ( path.toOSString().equals( bp ) )
+ if (path.toOSString().equals(bp))
{
return true;
}
@@ -400,205 +395,199 @@
return false;
}
-
private void registerResourceListeners()
{
- Job job = new Job( "Initialising sigil resource listeners" )
+ Job job = new Job("Initialising sigil resource listeners")
{
@Override
- protected IStatus run( IProgressMonitor monitor )
+ protected IStatus run(IProgressMonitor monitor)
{
- ResourcesPlugin.getWorkspace().addResourceChangeListener( new ProjectResourceListener(projectManager),
- ProjectResourceListener.EVENT_MASKS );
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(
+ new ProjectResourceListener(projectManager),
+ ProjectResourceListener.EVENT_MASKS);
return Status.OK_STATUS;
}
};
- job.setSystem( true );
+ job.setSystem(true);
job.schedule();
}
-
- private void registerModelElements( BundleContext context )
+ private void registerModelElements(BundleContext context)
{
// trick to get eclipse to lazy load BldCore for model elements
BldCore.getLicenseManager();
- ModelElementFactory.getInstance().register( ISigilProjectModel.class, SigilProject.class, "project", "sigil", null );
+ ModelElementFactory.getInstance().register(ISigilProjectModel.class,
+ SigilProject.class, "project", "sigil", null);
}
-
public static IOSGiInstallManager getInstallManager()
{
return installs;
}
-
public static ISigilModelRoot getRoot()
{
return modelRoot;
}
-
public static IRepositoryManager getGlobalRepositoryManager()
{
return globalRepositoryManager;
}
-
- public static IRepositoryManager getRepositoryManager( String set )
+ public static IRepositoryManager getRepositoryManager(String set)
{
SigilRepositoryManager manager = null;
- if ( set == null )
+ if (set == null)
{
- manager = repositoryManagers.get( NULL );
- if ( manager == null )
+ manager = repositoryManagers.get(NULL);
+ if (manager == null)
{
- manager = new SigilRepositoryManager( null, repositoryMap );
+ manager = new SigilRepositoryManager(null, repositoryMap);
manager.initialise();
- repositoryManagers.put( NULL, manager );
+ repositoryManagers.put(NULL, manager);
}
}
else
{
- manager = repositoryManagers.get( set );
+ manager = repositoryManagers.get(set);
- if ( manager == null )
+ if (manager == null)
{
- manager = new SigilRepositoryManager( set, repositoryMap );
+ manager = new SigilRepositoryManager(set, repositoryMap);
manager.initialise();
- repositoryManagers.put( set, manager );
+ repositoryManagers.put(set, manager);
}
}
return manager;
}
-
- public static IRepositoryManager getRepositoryManager( ISigilProjectModel model )
+ public static IRepositoryManager getRepositoryManager(ISigilProjectModel model)
{
- return getRepositoryManager( loadProjectRepositorySet( model ) );
+ return getRepositoryManager(loadProjectRepositorySet(model));
}
-
- private static String loadProjectRepositorySet( ISigilProjectModel model )
+ private static String loadProjectRepositorySet(ISigilProjectModel model)
{
- if ( model == null )
+ if (model == null)
{
return null;
}
- return model.getPreferences().get( REPOSITORY_SET, null );
+ return model.getPreferences().get(REPOSITORY_SET, null);
}
-
public static IRepositoryConfiguration getRepositoryConfiguration()
{
return repositoryConfig;
}
-
- public static void rebuildAllBundleDependencies( IProgressMonitor monitor )
+ public static void rebuildAllBundleDependencies(IProgressMonitor monitor)
{
Collection<ISigilProjectModel> projects = getRoot().getProjects();
- if ( !projects.isEmpty() )
+ if (!projects.isEmpty())
{
- SubMonitor progress = SubMonitor.convert( monitor, projects.size() * 20 );
- for ( ISigilProjectModel p : projects )
+ SubMonitor progress = SubMonitor.convert(monitor, projects.size() * 20);
+ for (ISigilProjectModel p : projects)
{
- rebuild( p, progress );
+ rebuild(p, progress);
}
}
monitor.done();
}
-
- public static void rebuildBundleDependencies( ISigilProjectModel project, Collection<ICapabilityModelElement> caps, IProgressMonitor monitor )
+ public static void rebuildBundleDependencies(ISigilProjectModel project,
+ Collection<ICapabilityModelElement> caps, IProgressMonitor monitor)
{
- Set<ISigilProjectModel> affected = SigilCore.getRoot().resolveDependentProjects( caps, monitor );
+ Set<ISigilProjectModel> affected = SigilCore.getRoot().resolveDependentProjects(
+ caps, monitor);
- if ( project != null ) {
- affected.remove( project );
+ if (project != null)
+ {
+ affected.remove(project);
}
- SubMonitor progress = SubMonitor.convert( monitor, affected.size() * 20 );
- for ( ISigilProjectModel dependent : affected )
+ SubMonitor progress = SubMonitor.convert(monitor, affected.size() * 20);
+ for (ISigilProjectModel dependent : affected)
{
//dependent.flushDependencyState();
- rebuild( dependent, progress );
+ rebuild(dependent, progress);
}
}
-
- public static void rebuild( ISigilProjectModel dependent, SubMonitor progress )
+ public static void rebuild(ISigilProjectModel dependent, SubMonitor progress)
{
try
{
- dependent.resetClasspath( progress.newChild( 10 ) );
- dependent.getProject().build( IncrementalProjectBuilder.FULL_BUILD, progress.newChild( 10 ) );
+ dependent.resetClasspath(progress.newChild(10));
+ dependent.getProject().build(IncrementalProjectBuilder.FULL_BUILD,
+ progress.newChild(10));
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- SigilCore.error( "Failed to rebuild " + dependent, e );
+ SigilCore.error("Failed to rebuild " + dependent, e);
}
}
-
- public IPath findDefaultBundleLocation( ISigilProjectModel m ) throws CoreException
+ public IPath findDefaultBundleLocation(ISigilProjectModel m) throws CoreException
{
IPath loc = m.getProject().getLocation();
- loc = loc.append( m.getJavaModel().getOutputLocation().removeFirstSegments( 1 ) );
- loc = loc.removeLastSegments( 1 ).append( "lib" );
- return loc.append( m.getSymbolicName() + ".jar" );
+ loc = loc.append(m.getJavaModel().getOutputLocation().removeFirstSegments(1));
+ loc = loc.removeLastSegments(1).append("lib");
+ return loc.append(m.getSymbolicName() + ".jar");
}
-
- public static void makeSigilProject( IProject project, IProgressMonitor monitor ) throws CoreException
+ public static void makeSigilProject(IProject project, IProgressMonitor monitor)
+ throws CoreException
{
IProjectDescription description = project.getDescription();
String[] natures = description.getNatureIds();
String[] newNatures = new String[natures.length + 1];
- System.arraycopy( natures, 0, newNatures, 0, natures.length );
+ System.arraycopy(natures, 0, newNatures, 0, natures.length);
newNatures[natures.length] = SigilCore.NATURE_ID;
- description.setNatureIds( newNatures );
+ description.setNatureIds(newNatures);
ICommand sigilBuild = description.newCommand();
- sigilBuild.setBuilderName( SigilCore.BUILDER_ID );
+ sigilBuild.setBuilderName(SigilCore.BUILDER_ID);
ICommand javaBuild = description.newCommand();
- javaBuild.setBuilderName( JavaCore.BUILDER_ID );
+ javaBuild.setBuilderName(JavaCore.BUILDER_ID);
- description.setBuildSpec( new ICommand[]
- { javaBuild, sigilBuild } );
+ description.setBuildSpec(new ICommand[] { javaBuild, sigilBuild });
- project.setDescription( description, new SubProgressMonitor( monitor, 2 ) );
+ project.setDescription(description, new SubProgressMonitor(monitor, 2));
- IJavaProject java = JavaCore.create( project );
- if ( java.exists() )
+ IJavaProject java = JavaCore.create(project);
+ if (java.exists())
{
IClasspathEntry[] cp = java.getRawClasspath();
// check if sigil container is already on classpath - if not add it
- if ( !isSigilOnClasspath( cp ) )
+ if (!isSigilOnClasspath(cp))
{
- ArrayList<IClasspathEntry> entries = new ArrayList<IClasspathEntry>( Arrays.asList( cp ) );
- entries.add( JavaCore.newContainerEntry( new Path( SigilCore.CLASSPATH_CONTAINER_PATH ) ) );
- java.setRawClasspath( entries.toArray( new IClasspathEntry[entries.size()] ), monitor );
+ ArrayList<IClasspathEntry> entries = new ArrayList<IClasspathEntry>(
+ Arrays.asList(cp));
+ entries.add(JavaCore.newContainerEntry(new Path(
+ SigilCore.CLASSPATH_CONTAINER_PATH)));
+ java.setRawClasspath(
+ entries.toArray(new IClasspathEntry[entries.size()]), monitor);
}
}
}
-
/**
* @param cp
* @return
*/
- private static boolean isSigilOnClasspath( IClasspathEntry[] cp )
+ private static boolean isSigilOnClasspath(IClasspathEntry[] cp)
{
- for ( IClasspathEntry e : cp )
+ for (IClasspathEntry e : cp)
{
- if ( e.getEntryKind() == IClasspathEntry.CPE_CONTAINER
- && e.getPath().segment( 0 ).equals( SigilCore.CLASSPATH_CONTAINER_PATH ) )
+ if (e.getEntryKind() == IClasspathEntry.CPE_CONTAINER
+ && e.getPath().segment(0).equals(SigilCore.CLASSPATH_CONTAINER_PATH))
{
return true;
}
@@ -606,28 +595,26 @@
return false;
}
-
- public static Image loadImage( URL url ) throws IOException
+ public static Image loadImage(URL url) throws IOException
{
ImageRegistry registry = getDefault().getImageRegistry();
String key = url.toExternalForm();
- Image img = registry.get( key );
+ Image img = registry.get(key);
- if ( img == null )
+ if (img == null)
{
- img = openImage( url );
- registry.put( key, img );
+ img = openImage(url);
+ registry.put(key, img);
}
return img;
}
-
- private static Image openImage( URL url ) throws IOException
+ private static Image openImage(URL url) throws IOException
{
Display display = Display.getCurrent();
- if ( display == null )
+ if (display == null)
{
display = Display.getDefault();
}
@@ -636,19 +623,19 @@
try
{
in = url.openStream();
- return new Image( display, in );
+ return new Image(display, in);
}
finally
{
- if ( in != null )
+ if (in != null)
{
try
{
in.close();
}
- catch ( IOException e )
+ catch (IOException e)
{
- error( "Failed to close stream", e );
+ error("Failed to close stream", e);
}
}
}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstall.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstall.java
index 154826a..d31cb1f 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstall.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstall.java
@@ -19,12 +19,10 @@
package org.apache.felix.sigil.eclipse.install;
-
import java.util.Map;
import org.eclipse.core.runtime.IPath;
-
/**
* Encapsulates all information about a particular OSGi install.
*
@@ -40,32 +38,27 @@
*/
String getId();
-
/**
* Where this install is located
* @return
*/
IPath getInstallLocation();
-
/**
* @return
*/
Map<String, String> getProperties();
-
/**
* @return
*/
String[] getLaunchArguments();
-
/**
* @return
*/
IPath getVarDirectory();
-
/**
* @return
*/
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstallBuilder.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstallBuilder.java
index 69cdbdc..2dd5148 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstallBuilder.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstallBuilder.java
@@ -19,12 +19,10 @@
package org.apache.felix.sigil.eclipse.install;
-
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
-
public interface IOSGiInstallBuilder
{
- IOSGiInstall build( String id, IPath path ) throws CoreException;
+ IOSGiInstall build(String id, IPath path) throws CoreException;
}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstallManager.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstallManager.java
index 3661463..2c304b4 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstallManager.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstallManager.java
@@ -19,20 +19,15 @@
package org.apache.felix.sigil.eclipse.install;
-
public interface IOSGiInstallManager
{
- IOSGiInstall findInstall( String id );
-
+ IOSGiInstall findInstall(String id);
String[] getInstallIDs();
-
IOSGiInstall[] getInstalls();
-
IOSGiInstall getDefaultInstall();
-
- IOSGiInstallType findInstallType( String location );
+ IOSGiInstallType findInstallType(String location);
}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstallType.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstallType.java
index 933f54d..be117e6 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstallType.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/IOSGiInstallType.java
@@ -19,11 +19,9 @@
package org.apache.felix.sigil.eclipse.install;
-
import org.eclipse.core.runtime.IPath;
import org.eclipse.swt.graphics.Image;
-
//import org.eclipse.swt.graphics.Image;
public interface IOSGiInstallType
@@ -33,47 +31,39 @@
*/
String getName();
-
/**
*
* @return
*/
String getVersion();
-
/**
* @return
*/
String getMainClass();
-
/**
* @return
*/
String[] getClassPath();
-
/**
* @return
*/
IPath getSourceLocation();
-
/**
* @return
*/
IPath getJavaDocLocation();
-
/**
* Return the paths of any bundles that are started by default in this OSGi instance.
* @return
*/
IPath[] getDefaultBundleLocations();
-
String getId();
-
Image getIcon();
}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/OSGiInstall.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/OSGiInstall.java
index 4cf4604..7b98c2c 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/OSGiInstall.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/OSGiInstall.java
@@ -19,13 +19,11 @@
package org.apache.felix.sigil.eclipse.install;
-
import java.util.Arrays;
import java.util.Map;
import org.eclipse.core.runtime.IPath;
-
public class OSGiInstall implements IOSGiInstall
{
@@ -36,81 +34,69 @@
private IPath varDirectory;
private IOSGiInstallType type;
-
public IPath getVarDirectory()
{
return varDirectory;
}
-
- public void setVarDirectory( IPath varDirectory )
+ public void setVarDirectory(IPath varDirectory)
{
this.varDirectory = varDirectory;
}
-
- public OSGiInstall( String id )
+ public OSGiInstall(String id)
{
this.id = id;
}
-
public String getId()
{
return id;
}
-
public IPath getInstallLocation()
{
return installLocation;
}
-
- public void setInstallLocation( IPath installLocation )
+ public void setInstallLocation(IPath installLocation)
{
this.installLocation = installLocation;
}
-
public String[] getLaunchArguments()
{
return launchArgs;
}
-
- public void setLaunchArguments( String[] launchArgs )
+ public void setLaunchArguments(String[] launchArgs)
{
this.launchArgs = launchArgs;
}
-
public Map<String, String> getProperties()
{
return properties;
}
-
- public void setProperties( Map<String, String> properties )
+ public void setProperties(Map<String, String> properties)
{
this.properties = properties;
}
-
public String toString()
{
- return "OSGiInstall[\n" + "id=" + id + "\n" + "type=" + type + "\n" + "installLocation=" + installLocation
- + "\n" + "launchArgs=" + Arrays.asList( launchArgs ) + "\n" + "properties=" + properties + "\n" + "]";
+ return "OSGiInstall[\n" + "id=" + id + "\n" + "type=" + type + "\n"
+ + "installLocation=" + installLocation + "\n" + "launchArgs="
+ + Arrays.asList(launchArgs) + "\n" + "properties=" + properties + "\n" + "]";
}
-
public IOSGiInstallType getType()
{
return type;
}
-
- public void setType( IOSGiInstallType type )
+ public void setType(IOSGiInstallType type)
{
this.type = type;
}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/OSGiInstallType.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/OSGiInstallType.java
index 18472a7..63c4ffe 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/OSGiInstallType.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/install/OSGiInstallType.java
@@ -19,13 +19,11 @@
package org.apache.felix.sigil.eclipse.install;
-
import java.util.Arrays;
import org.eclipse.core.runtime.IPath;
import org.eclipse.swt.graphics.Image;
-
public class OSGiInstallType implements IOSGiInstallType
{
@@ -39,120 +37,102 @@
private IPath[] defaultBundleLocations;
private Image icon;
-
public Image getIcon()
{
return icon;
}
-
- public void setIcon( Image icon )
+ public void setIcon(Image icon)
{
this.icon = icon;
}
-
public String getId()
{
return id;
}
-
public String[] getClassPath()
{
return classPath;
}
-
public IPath[] getDefaultBundleLocations()
{
return defaultBundleLocations;
}
-
public IPath getJavaDocLocation()
{
return javaDocLocation;
}
-
public String getMainClass()
{
return mainClass;
}
-
public String getName()
{
return name;
}
-
public IPath getSourceLocation()
{
return sourceLocation;
}
-
public String getVersion()
{
return version;
}
-
- public void setId( String id )
+ public void setId(String id)
{
this.id = id;
}
-
- public void setName( String name )
+ public void setName(String name)
{
this.name = name;
}
-
- public void setVersion( String version )
+ public void setVersion(String version)
{
this.version = version;
}
-
- public void setMainClass( String mainClass )
+ public void setMainClass(String mainClass)
{
this.mainClass = mainClass;
}
-
- public void setClassPath( String[] classPath )
+ public void setClassPath(String[] classPath)
{
this.classPath = classPath;
}
-
- public void setJavaDocLocation( IPath javaDocLocation )
+ public void setJavaDocLocation(IPath javaDocLocation)
{
this.javaDocLocation = javaDocLocation;
}
-
- public void setSourceLocation( IPath sourceLocation )
+ public void setSourceLocation(IPath sourceLocation)
{
this.sourceLocation = sourceLocation;
}
-
- public void setDefaultBundleLocations( IPath[] defaultBundleLocations )
+ public void setDefaultBundleLocations(IPath[] defaultBundleLocations)
{
this.defaultBundleLocations = defaultBundleLocations;
}
-
public String toString()
{
- return "OSGiInstallType[\n" + "name=" + name + "\n" + "version=" + version + "\n" + "mainClass=" + mainClass
- + "\n" + "classPath=" + Arrays.asList( classPath ) + "\n" + "javaDocLocation=" + javaDocLocation + "\n"
- + "sourceLocation=" + sourceLocation + "\n" + "defaultBundleLocations="
- + Arrays.asList( defaultBundleLocations ) + "\n" + "]";
+ return "OSGiInstallType[\n" + "name=" + name + "\n" + "version=" + version + "\n"
+ + "mainClass=" + mainClass + "\n" + "classPath=" + Arrays.asList(classPath)
+ + "\n" + "javaDocLocation=" + javaDocLocation + "\n" + "sourceLocation="
+ + sourceLocation + "\n" + "defaultBundleLocations="
+ + Arrays.asList(defaultBundleLocations) + "\n" + "]";
}
}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/adapter/FileAdaptorFactory.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/adapter/FileAdaptorFactory.java
index dcac17f..283984c 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/adapter/FileAdaptorFactory.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/adapter/FileAdaptorFactory.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.internal.adapter;
-
import org.apache.felix.sigil.common.model.ModelElementFactory;
import org.apache.felix.sigil.common.model.ModelElementFactoryException;
import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
@@ -30,7 +29,6 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdapterFactory;
-
/**
* @author savage
*
@@ -43,56 +41,53 @@
}
- private Class<?>[] types = new Class<?>[]
- { ISigilBundle.class };
-
+ private Class<?>[] types = new Class<?>[] { ISigilBundle.class };
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
*/
@SuppressWarnings("unchecked")
- public Object getAdapter( Object adaptableObject, Class adapterType )
+ public Object getAdapter(Object adaptableObject, Class adapterType)
{
Object adapted = null;
- IFile file = ( IFile ) adaptableObject;
+ IFile file = (IFile) adaptableObject;
- if ( ISigilBundle.class.equals( adapterType ) )
+ if (ISigilBundle.class.equals(adapterType))
{
- adapted = adaptBundle( file );
+ adapted = adaptBundle(file);
}
return adapted;
}
-
- private Object adaptBundle( IFile file )
+ private Object adaptBundle(IFile file)
{
Object adapted = null;
IProject project = file.getProject();
try
{
- if ( SigilCore.hasProjectNature( project ) )
+ if (SigilCore.hasProjectNature(project))
{
- ISigilProjectModel sigil = SigilCore.create( project );
- ISigilBundle bundle = ModelElementFactory.getInstance().newModelElement( ISigilBundle.class );
- bundle.setParent( sigil );
+ ISigilProjectModel sigil = SigilCore.create(project);
+ ISigilBundle bundle = ModelElementFactory.getInstance().newModelElement(
+ ISigilBundle.class);
+ bundle.setParent(sigil);
adapted = bundle;
}
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- SigilCore.error( "Failed to construct bundle", e );
+ SigilCore.error("Failed to construct bundle", e);
}
- catch ( ModelElementFactoryException e )
+ catch (ModelElementFactoryException e)
{
- SigilCore.error( "Failed to construct bundle", e );
+ SigilCore.error("Failed to construct bundle", e);
}
return adapted;
}
-
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
*/
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/adapter/ProjectAdaptorFactory.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/adapter/ProjectAdaptorFactory.java
index 0bb9f7e..ea805cd 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/adapter/ProjectAdaptorFactory.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/adapter/ProjectAdaptorFactory.java
@@ -19,14 +19,12 @@
package org.apache.felix.sigil.eclipse.internal.adapter;
-
import org.apache.felix.sigil.eclipse.SigilCore;
import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdapterFactory;
-
/**
* @author savage
*
@@ -34,39 +32,36 @@
public class ProjectAdaptorFactory implements IAdapterFactory
{
- private Class<?>[] types = new Class<?>[]
- { ISigilProjectModel.class };
-
+ private Class<?>[] types = new Class<?>[] { ISigilProjectModel.class };
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
*/
@SuppressWarnings("unchecked")
- public Object getAdapter( Object adaptableObject, Class adapterType )
+ public Object getAdapter(Object adaptableObject, Class adapterType)
{
Object adapted = null;
- IProject project = ( IProject ) adaptableObject;
+ IProject project = (IProject) adaptableObject;
- if ( ISigilProjectModel.class.equals( adapterType ) )
+ if (ISigilProjectModel.class.equals(adapterType))
{
- adapted = adaptProject( project );
+ adapted = adaptProject(project);
}
return adapted;
}
-
- private Object adaptProject( IProject project )
+ private Object adaptProject(IProject project)
{
try
{
- if ( SigilCore.isSigilProject( project ) )
+ if (SigilCore.isSigilProject(project))
{
- return SigilCore.create( project );
+ return SigilCore.create(project);
}
}
- catch ( CoreException e )
+ catch (CoreException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
@@ -74,7 +69,6 @@
return null;
}
-
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
*/
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/builders/BuildConsole.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/builders/BuildConsole.java
index 34eae26..9f3eba0 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/builders/BuildConsole.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/builders/BuildConsole.java
@@ -19,28 +19,24 @@
package org.apache.felix.sigil.eclipse.internal.builders;
-
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.console.MessageConsole;
import org.eclipse.ui.console.MessageConsoleStream;
-
public class BuildConsole extends MessageConsole
{
private static final ImageDescriptor imageDescriptor = null;
private MessageConsoleStream stream;
-
public BuildConsole()
{
- super( "Sigil Build", imageDescriptor, true );
+ super("Sigil Build", imageDescriptor, true);
}
-
public synchronized MessageConsoleStream getMessageStream()
{
- if ( stream == null )
+ if (stream == null)
{
stream = newMessageStream();
}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/builders/SigilIncrementalProjectBuilder.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/builders/SigilIncrementalProjectBuilder.java
index 63dbaf1..baf86a0 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/builders/SigilIncrementalProjectBuilder.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/builders/SigilIncrementalProjectBuilder.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.internal.builders;
-
import java.io.File;
import java.util.Collection;
import java.util.LinkedList;
@@ -56,26 +55,25 @@
import org.eclipse.ui.console.IConsoleManager;
import org.eclipse.ui.console.MessageConsoleStream;
-
public class SigilIncrementalProjectBuilder extends IncrementalProjectBuilder
{
@Override
- protected IProject[] build( int kind, @SuppressWarnings("unchecked") Map args, IProgressMonitor monitor )
- throws CoreException
+ protected IProject[] build(int kind, @SuppressWarnings("unchecked") Map args,
+ IProgressMonitor monitor) throws CoreException
{
IProject project = getProject();
- if ( checkOk( project ) )
+ if (checkOk(project))
{
- switch ( kind )
+ switch (kind)
{
case CLEAN_BUILD:
case FULL_BUILD:
- fullBuild( project, monitor );
+ fullBuild(project, monitor);
break;
case AUTO_BUILD:
case INCREMENTAL_BUILD:
- autoBuild( project, monitor );
+ autoBuild(project, monitor);
break;
}
}
@@ -83,66 +81,66 @@
return null;
}
-
/**
* @param install
* @param project
* @param monitor
* @throws CoreException
*/
- private void autoBuild( IProject project, IProgressMonitor monitor ) throws CoreException
+ private void autoBuild(IProject project, IProgressMonitor monitor)
+ throws CoreException
{
- IResourceDelta delta = getDelta( project );
+ IResourceDelta delta = getDelta(project);
final boolean[] changed = new boolean[1];
- ISigilProjectModel sigil = SigilCore.create( project );
- final IPath bldRoot = sigil.findBundleLocation().removeLastSegments( 1 );
+ ISigilProjectModel sigil = SigilCore.create(project);
+ final IPath bldRoot = sigil.findBundleLocation().removeLastSegments(1);
- delta.accept( new IResourceDeltaVisitor()
+ delta.accept(new IResourceDeltaVisitor()
{
- public boolean visit( IResourceDelta delta ) throws CoreException
+ public boolean visit(IResourceDelta delta) throws CoreException
{
- if ( !changed[0] )
+ if (!changed[0])
{
IResource res = delta.getResource();
- if ( res.getType() == IResource.FILE )
+ if (res.getType() == IResource.FILE)
{
- changed[0] = !bldRoot.isPrefixOf( res.getLocation() );
+ changed[0] = !bldRoot.isPrefixOf(res.getLocation());
}
}
return !changed[0];
}
- } );
+ });
- if ( changed[0] )
+ if (changed[0])
{
- doBuild( project, monitor );
+ doBuild(project, monitor);
}
}
-
/**
* @param install
* @param project
* @param monitor
* @throws CoreException
*/
- private void fullBuild( IProject project, IProgressMonitor monitor ) throws CoreException
+ private void fullBuild(IProject project, IProgressMonitor monitor)
+ throws CoreException
{
- doBuild( project, monitor );
+ doBuild(project, monitor);
}
-
- private boolean checkOk( IProject project ) throws CoreException
+ private boolean checkOk(IProject project) throws CoreException
{
- IMarker[] markers = project.findMarkers( IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true,
- IResource.DEPTH_INFINITE );
+ IMarker[] markers = project.findMarkers(
+ IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
- for ( IMarker m : markers )
+ for (IMarker m : markers)
{
- Integer s = ( Integer ) m.getAttribute( IMarker.SEVERITY );
- if ( s != null && s.equals( IMarker.SEVERITY_ERROR ) )
+ Integer s = (Integer) m.getAttribute(IMarker.SEVERITY);
+ if (s != null && s.equals(IMarker.SEVERITY_ERROR))
{
- SigilCore.log( "Skipping " + project.getName() + " build due to unresolved errors" );
+ SigilCore.log("Skipping " + project.getName()
+ + " build due to unresolved errors");
return false;
}
}
@@ -150,58 +148,56 @@
return true;
}
-
- private void doBuild( IProject project, IProgressMonitor monitor ) throws CoreException
+ private void doBuild(IProject project, IProgressMonitor monitor) throws CoreException
{
- ISigilProjectModel sigil = SigilCore.create( project );
+ ISigilProjectModel sigil = SigilCore.create(project);
IBldProject bld = sigil.getBldProject();
- File[] classpath = buildClasspath( sigil, monitor );
+ File[] classpath = buildClasspath(sigil, monitor);
- String destPattern = buildDestPattern( sigil );
+ String destPattern = buildDestPattern(sigil);
Properties env = new Properties();
- BundleBuilder bb = new BundleBuilder( bld, classpath, destPattern, env );
+ BundleBuilder bb = new BundleBuilder(bld, classpath, destPattern, env);
- for ( IBldProject.IBldBundle bundle : bld.getBundles() )
+ for (IBldProject.IBldBundle bundle : bld.getBundles())
{
String id = bundle.getId();
- loginfo( "creating bundle: " + id );
+ loginfo("creating bundle: " + id);
int nWarn = 0;
int nErr = 0;
String msg = "";
try
{
- boolean modified = bb.createBundle( bundle, false, new BundleBuilder.Log()
+ boolean modified = bb.createBundle(bundle, false, new BundleBuilder.Log()
{
- public void warn( String msg )
+ public void warn(String msg)
{
- logwarn( msg );
+ logwarn(msg);
}
-
- public void verbose( String msg )
+ public void verbose(String msg)
{
- loginfo( msg );
+ loginfo(msg);
}
- } );
+ });
nWarn = bb.warnings().size();
- if ( !modified )
+ if (!modified)
{
msg = " (not modified)";
}
}
- catch ( Exception e )
+ catch (Exception e)
{
List<String> errors = bb.errors();
- if ( errors != null )
+ if (errors != null)
{
nErr = errors.size();
- for ( String err : errors )
+ for (String err : errors)
{
- logerror( err );
+ logerror(err);
}
}
// FELIX-1690 - error is already logged no need to throw error as this
@@ -210,124 +206,122 @@
}
finally
{
- loginfo( id + ": " + count( nErr, "error" ) + ", " + count( nWarn, "warning" ) + msg );
+ loginfo(id + ": " + count(nErr, "error") + ", " + count(nWarn, "warning")
+ + msg);
}
}
}
-
- private static void loginfo( String message )
+ private static void loginfo(String message)
{
log("INFO: " + message);
}
- private static void logwarn( String message )
+ private static void logwarn(String message)
{
- log( "WARN: " + message );
+ log("WARN: " + message);
}
-
- private static void logerror( String message )
+ private static void logerror(String message)
{
- log( "ERROR: " + message );
+ log("ERROR: " + message);
}
private static void log(final String message)
{
// do this in background to avoid deadlock with ui
- Job job = new Job("log") {
+ Job job = new Job("log")
+ {
@Override
protected IStatus run(IProgressMonitor arg0)
{
BuildConsole console = findConsole();
MessageConsoleStream stream = console.getMessageStream();
- stream.println( message );
+ stream.println(message);
return Status.OK_STATUS;
}
};
job.schedule();
}
-
private static BuildConsole findConsole()
{
BuildConsole console = null;
IConsoleManager manager = ConsolePlugin.getDefault().getConsoleManager();
- for ( IConsole c : manager.getConsoles() )
+ for (IConsole c : manager.getConsoles())
{
- if ( c instanceof BuildConsole )
+ if (c instanceof BuildConsole)
{
- console = ( BuildConsole ) c;
+ console = (BuildConsole) c;
break;
}
}
- if ( console == null )
+ if (console == null)
{
console = new BuildConsole();
- manager.addConsoles( new IConsole[]
- { console } );
+ manager.addConsoles(new IConsole[] { console });
}
return console;
}
-
- private String buildDestPattern( ISigilProjectModel sigil ) throws CoreException
+ private String buildDestPattern(ISigilProjectModel sigil) throws CoreException
{
- IPath loc = sigil.findBundleLocation().removeLastSegments( 1 );
+ IPath loc = sigil.findBundleLocation().removeLastSegments(1);
loc.toFile().mkdirs();
return loc.toOSString() + File.separator + "[name].jar";
}
-
- private File[] buildClasspath( ISigilProjectModel sigil, IProgressMonitor monitor ) throws CoreException
- {
- LinkedList<File> files = new LinkedList<File>();
- if ( sigil.getBundle().getClasspathEntrys().isEmpty() ) {
- IClasspathEntry[] entries = sigil.getJavaModel().getResolvedClasspath(true);
- for ( IClasspathEntry cp : entries )
- {
- convert( cp, sigil, files );
- }
- }
- else {
- buildLocalClasspath( sigil, files );
- buildExternalClasspath( sigil, files, monitor );
- }
- return files.toArray( new File[files.size()] );
- }
-
-
- private void buildExternalClasspath( ISigilProjectModel sigil, List<File> files, IProgressMonitor monitor )
+ private File[] buildClasspath(ISigilProjectModel sigil, IProgressMonitor monitor)
throws CoreException
{
- Collection<IClasspathEntry> entries = sigil.findExternalClasspath( monitor );
-
- for ( IClasspathEntry cp : entries )
+ LinkedList<File> files = new LinkedList<File>();
+ if (sigil.getBundle().getClasspathEntrys().isEmpty())
{
- convert( cp, sigil, files );
+ IClasspathEntry[] entries = sigil.getJavaModel().getResolvedClasspath(true);
+ for (IClasspathEntry cp : entries)
+ {
+ convert(cp, sigil, files);
+ }
+ }
+ else
+ {
+ buildLocalClasspath(sigil, files);
+ buildExternalClasspath(sigil, files, monitor);
+ }
+ return files.toArray(new File[files.size()]);
+ }
+
+ private void buildExternalClasspath(ISigilProjectModel sigil, List<File> files,
+ IProgressMonitor monitor) throws CoreException
+ {
+ Collection<IClasspathEntry> entries = sigil.findExternalClasspath(monitor);
+
+ for (IClasspathEntry cp : entries)
+ {
+ convert(cp, sigil, files);
}
}
-
- private void buildLocalClasspath( ISigilProjectModel sigil, List<File> files ) throws CoreException
+ private void buildLocalClasspath(ISigilProjectModel sigil, List<File> files)
+ throws CoreException
{
- Collection<IClasspathEntry> entries = JavaHelper.findClasspathEntries( sigil.getBundle() );
- for ( IClasspathEntry cp : entries )
+ Collection<IClasspathEntry> entries = JavaHelper.findClasspathEntries(sigil.getBundle());
+ for (IClasspathEntry cp : entries)
{
- convert( cp, sigil, files );
+ convert(cp, sigil, files);
}
}
-
- private void convert( IClasspathEntry cp, ISigilProjectModel sigil, List<File> files ) throws CoreException
+ private void convert(IClasspathEntry cp, ISigilProjectModel sigil, List<File> files)
+ throws CoreException
{
- switch ( cp.getEntryKind() )
+ switch (cp.getEntryKind())
{
case IClasspathEntry.CPE_PROJECT:
{
@@ -350,84 +344,85 @@
}
}
-
private void convertVariable(IClasspathEntry cp, List<File> files)
{
- cp = JavaCore.getResolvedClasspathEntry( cp );
- if ( cp != null )
+ cp = JavaCore.getResolvedClasspathEntry(cp);
+ if (cp != null)
{
IPath p = cp.getPath();
- files.add( p.toFile() );
+ files.add(p.toFile());
}
}
-
- private void convertLibrary(ISigilProjectModel sigil, IClasspathEntry cp, List<File> files)
+ private void convertLibrary(ISigilProjectModel sigil, IClasspathEntry cp,
+ List<File> files)
{
IPath p = cp.getPath();
- IProject project = sigil.getProject().getWorkspace().getRoot().getProject( p.segment( 0 ) );
- if ( project.exists() )
+ IProject project = sigil.getProject().getWorkspace().getRoot().getProject(
+ p.segment(0));
+ if (project.exists())
{
- p = project.getLocation().append( p.removeFirstSegments( 1 ) );
+ p = project.getLocation().append(p.removeFirstSegments(1));
}
- files.add( p.toFile() );
+ files.add(p.toFile());
}
-
- private void convertSource(ISigilProjectModel sigil, IClasspathEntry cp, List<File> files) throws JavaModelException
+ private void convertSource(ISigilProjectModel sigil, IClasspathEntry cp,
+ List<File> files) throws JavaModelException
{
- IPath path = cp.getOutputLocation() == null ? sigil.getJavaModel().getOutputLocation() : cp
- .getOutputLocation();
- IFolder buildFolder = sigil.getProject().getFolder( path.removeFirstSegments( 1 ) );
- if ( buildFolder.exists() )
+ IPath path = cp.getOutputLocation() == null ? sigil.getJavaModel().getOutputLocation()
+ : cp.getOutputLocation();
+ IFolder buildFolder = sigil.getProject().getFolder(path.removeFirstSegments(1));
+ if (buildFolder.exists())
{
- files.add( buildFolder.getLocation().toFile() );
+ files.add(buildFolder.getLocation().toFile());
}
}
-
- private void convertProject(IClasspathEntry cp, List<File> files) throws CoreException
+ private void convertProject(IClasspathEntry cp, List<File> files)
+ throws CoreException
{
- IProject p = findProject( cp.getPath() );
- ISigilProjectModel project = SigilCore.create( p );
- if ( project.getBundle().getClasspathEntrys().isEmpty() ) {
+ IProject p = findProject(cp.getPath());
+ ISigilProjectModel project = SigilCore.create(p);
+ if (project.getBundle().getClasspathEntrys().isEmpty())
+ {
// ew this is pretty messy - if a dependent bundle specifies it's dependencies
// via package statements vs source directories then we need to add
// the classpath path of that bundle
- for ( IClasspathEntry rp : project.getJavaModel().getResolvedClasspath(true) ) {
- convert( rp, project, files );
+ for (IClasspathEntry rp : project.getJavaModel().getResolvedClasspath(true))
+ {
+ convert(rp, project, files);
}
}
- else {
- for ( String scp : project.getBundle().getClasspathEntrys() )
+ else
+ {
+ for (String scp : project.getBundle().getClasspathEntrys())
{
- IClasspathEntry jcp = project.getJavaModel().decodeClasspathEntry( scp );
- convert( jcp, project, files );
+ IClasspathEntry jcp = project.getJavaModel().decodeClasspathEntry(scp);
+ convert(jcp, project, files);
}
}
}
-
- private IProject findProject( IPath path ) throws CoreException
+ private IProject findProject(IPath path) throws CoreException
{
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- for ( IProject p : root.getProjects() )
+ for (IProject p : root.getProjects())
{
IPath projectPath = p.getFullPath();
- if ( projectPath.equals( path ) )
+ if (projectPath.equals(path))
{
return p;
}
}
- throw SigilCore.newCoreException( "No such project " + path, null );
+ throw SigilCore.newCoreException("No such project " + path, null);
}
-
- private String count( int count, String msg )
+ private String count(int count, String msg)
{
- return count + " " + msg + ( count == 1 ? "" : "s" );
+ return count + " " + msg + (count == 1 ? "" : "s");
}
}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/install/OSGiInstallManager.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/install/OSGiInstallManager.java
index 40748c6..e50dbf8 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/install/OSGiInstallManager.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/install/OSGiInstallManager.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.internal.install;
-
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
@@ -49,7 +48,6 @@
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.PreferencesUtil;
-
public class OSGiInstallManager implements IOSGiInstallManager, IPropertyChangeListener
{
private static final int NORMAL_PRIORITY = 0;
@@ -63,195 +61,185 @@
private boolean initialised;
-
- public IOSGiInstall findInstall( String id )
+ public IOSGiInstall findInstall(String id)
{
init();
- return idToInstall.get( id );
+ return idToInstall.get(id);
}
-
public String[] getInstallIDs()
{
init();
- return idToInstall.keySet().toArray( new String[idToInstall.size()] );
+ return idToInstall.keySet().toArray(new String[idToInstall.size()]);
}
-
public IOSGiInstall[] getInstalls()
{
init();
- return idToInstall.values().toArray( new IOSGiInstall[idToInstall.size()] );
+ return idToInstall.values().toArray(new IOSGiInstall[idToInstall.size()]);
}
-
public IOSGiInstall getDefaultInstall()
{
init();
- return findInstall( defaultId );
+ return findInstall(defaultId);
}
-
- public IOSGiInstallType findInstallType( String location )
+ public IOSGiInstallType findInstallType(String location)
{
IOSGiInstallType type = null;
try
{
- IOSGiInstall install = buildInstall( "tmp", new Path( location ) );
+ IOSGiInstall install = buildInstall("tmp", new Path(location));
type = install == null ? null : install.getType();
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- SigilCore.error( "Failed to build install", e );
+ SigilCore.error("Failed to build install", e);
}
return type;
}
-
- public void propertyChange( PropertyChangeEvent event )
+ public void propertyChange(PropertyChangeEvent event)
{
- synchronized ( this )
+ synchronized (this)
{
- if ( event.getProperty().equals( SigilCore.OSGI_INSTALLS ) )
+ if (event.getProperty().equals(SigilCore.OSGI_INSTALLS))
{
clearInstalls();
- String val = ( String ) event.getNewValue();
- addInstalls( val );
+ String val = (String) event.getNewValue();
+ addInstalls(val);
}
- else if ( event.getProperty().equals( SigilCore.OSGI_DEFAULT_INSTALL_ID ) )
+ else if (event.getProperty().equals(SigilCore.OSGI_DEFAULT_INSTALL_ID))
{
- defaultId = ( String ) event.getNewValue();
+ defaultId = (String) event.getNewValue();
}
}
}
-
private void init()
{
boolean show = false;
IPreferenceStore prefs = getPreferenceStore();
- synchronized ( this )
+ synchronized (this)
{
- if ( !initialised )
+ if (!initialised)
{
initialised = true;
- prefs.addPropertyChangeListener( this );
+ prefs.addPropertyChangeListener(this);
- String val = prefs.getString( SigilCore.OSGI_INSTALLS );
+ String val = prefs.getString(SigilCore.OSGI_INSTALLS);
- boolean noAsk = prefs.getBoolean( SigilCore.PREFERENCES_NOASK_OSGI_INSTALL );
- if ( val == null || val.trim().length() == 0 )
+ boolean noAsk = prefs.getBoolean(SigilCore.PREFERENCES_NOASK_OSGI_INSTALL);
+ if (val == null || val.trim().length() == 0)
{
show = !noAsk;
}
else
{
- addInstalls( val );
- defaultId = prefs.getString( SigilCore.OSGI_DEFAULT_INSTALL_ID );
+ addInstalls(val);
+ defaultId = prefs.getString(SigilCore.OSGI_DEFAULT_INSTALL_ID);
}
}
}
- if ( show )
+ if (show)
{
- showInstallPrefs( prefs );
+ showInstallPrefs(prefs);
}
}
-
- private void addInstalls( String prop )
+ private void addInstalls(String prop)
{
- if ( prop != null && prop.trim().length() > 0 )
+ if (prop != null && prop.trim().length() > 0)
{
IPreferenceStore prefs = getPreferenceStore();
- for ( String id : prop.split( "," ) )
+ for (String id : prop.split(","))
{
- String path = prefs.getString( SigilCore.OSGI_INSTALL_PREFIX + id );
- addInstall( id, new Path( path ) );
+ String path = prefs.getString(SigilCore.OSGI_INSTALL_PREFIX + id);
+ addInstall(id, new Path(path));
}
}
}
-
private IPreferenceStore getPreferenceStore()
{
return SigilCore.getDefault().getPreferenceStore();
}
-
- private void showInstallPrefs( final IPreferenceStore prefs )
+ private void showInstallPrefs(final IPreferenceStore prefs)
{
Runnable r = new Runnable()
{
public void run()
{
- MessageDialogWithToggle questionDialog = MessageDialogWithToggle.openYesNoQuestion( PlatformUI
- .getWorkbench().getActiveWorkbenchWindow().getShell(), "Sigil Configuration",
+ MessageDialogWithToggle questionDialog = MessageDialogWithToggle.openYesNoQuestion(
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
+ "Sigil Configuration",
"Missing OSGi installation. Open preferences to configure it now?",
- "Do not show this message again", false, null, null );
- prefs.setValue( SigilCore.PREFERENCES_NOASK_OSGI_INSTALL, questionDialog.getToggleState() );
- if ( questionDialog.getReturnCode() == IDialogConstants.YES_ID )
+ "Do not show this message again", false, null, null);
+ prefs.setValue(SigilCore.PREFERENCES_NOASK_OSGI_INSTALL,
+ questionDialog.getToggleState());
+ if (questionDialog.getReturnCode() == IDialogConstants.YES_ID)
{
- PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn( null,
- SigilCore.OSGI_INSTALLS_PREFERENCES_ID, null, null );
+ PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(
+ null, SigilCore.OSGI_INSTALLS_PREFERENCES_ID, null, null);
dialog.open();
}
}
};
Display d = Display.getCurrent();
- if ( d == null )
+ if (d == null)
{
d = Display.getDefault();
- d.asyncExec( r );
+ d.asyncExec(r);
}
else
{
- d.syncExec( r );
+ d.syncExec(r);
}
}
-
- private IOSGiInstall addInstall( String id, IPath path )
+ private IOSGiInstall addInstall(String id, IPath path)
{
- IOSGiInstall install = pathToinstall.get( path );
+ IOSGiInstall install = pathToinstall.get(path);
- if ( install == null )
+ if (install == null)
{
try
{
- install = buildInstall( id, path );
- if ( install != null )
+ install = buildInstall(id, path);
+ if (install != null)
{
- pathToinstall.put( path, install );
- idToInstall.put( install.getId(), install );
+ pathToinstall.put(path, install);
+ idToInstall.put(install.getId(), install);
}
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- SigilCore.error( "Failed to build install for " + path, e );
+ SigilCore.error("Failed to build install for " + path, e);
}
}
return install;
}
-
- private IOSGiInstall buildInstall( String id, IPath path ) throws CoreException
+ private IOSGiInstall buildInstall(String id, IPath path) throws CoreException
{
initBuilders();
IOSGiInstall install = null;
- for ( IOSGiInstallBuilder b : builders )
+ for (IOSGiInstallBuilder b : builders)
{
- install = b.build( id, path );
+ install = b.build(id, path);
- if ( install != null )
+ if (install != null)
{
break;
}
@@ -260,45 +248,43 @@
return install;
}
-
private void clearInstalls()
{
idToInstall.clear();
pathToinstall.clear();
}
-
private void initBuilders()
{
- synchronized ( builders )
+ synchronized (builders)
{
- if ( builders.isEmpty() )
+ if (builders.isEmpty())
{
final HashMap<IOSGiInstallBuilder, Integer> tmp = new HashMap<IOSGiInstallBuilder, Integer>();
IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint p = registry.getExtensionPoint( SigilCore.INSTALL_BUILDER_EXTENSION_POINT_ID );
- for ( IExtension e : p.getExtensions() )
+ IExtensionPoint p = registry.getExtensionPoint(SigilCore.INSTALL_BUILDER_EXTENSION_POINT_ID);
+ for (IExtension e : p.getExtensions())
{
- for ( IConfigurationElement c : e.getConfigurationElements() )
+ for (IConfigurationElement c : e.getConfigurationElements())
{
- createBuilderFromElement( c, tmp );
+ createBuilderFromElement(c, tmp);
}
}
- builders = new LinkedList<IOSGiInstallBuilder>( tmp.keySet() );
- Collections.sort( builders, new Comparator<IOSGiInstallBuilder>()
+ builders = new LinkedList<IOSGiInstallBuilder>(tmp.keySet());
+ Collections.sort(builders, new Comparator<IOSGiInstallBuilder>()
{
- public int compare( IOSGiInstallBuilder o1, IOSGiInstallBuilder o2 )
+ public int compare(IOSGiInstallBuilder o1, IOSGiInstallBuilder o2)
{
- int p1 = tmp.get( o1 );
- int p2 = tmp.get( o2 );
+ int p1 = tmp.get(o1);
+ int p2 = tmp.get(o2);
- if ( p1 == p2 )
+ if (p1 == p2)
{
return 0;
}
- else if ( p1 > p2 )
+ else if (p1 > p2)
{
return -1;
}
@@ -307,38 +293,37 @@
return 1;
}
}
- } );
+ });
}
}
}
-
- private void createBuilderFromElement( IConfigurationElement c, Map<IOSGiInstallBuilder, Integer> builder )
+ private void createBuilderFromElement(IConfigurationElement c,
+ Map<IOSGiInstallBuilder, Integer> builder)
{
try
{
- IOSGiInstallBuilder b = ( IOSGiInstallBuilder ) c.createExecutableExtension( "class" );
- int priority = parsePriority( c );
- builder.put( b, priority );
+ IOSGiInstallBuilder b = (IOSGiInstallBuilder) c.createExecutableExtension("class");
+ int priority = parsePriority(c);
+ builder.put(b, priority);
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- SigilCore.error( "Failed to create builder", e );
+ SigilCore.error("Failed to create builder", e);
}
}
-
- private int parsePriority( IConfigurationElement c )
+ private int parsePriority(IConfigurationElement c)
{
- String str = c.getAttribute( "priority" );
+ String str = c.getAttribute("priority");
- if ( str == null )
+ if (str == null)
{
return NORMAL_PRIORITY;
}
else
{
- return Integer.parseInt( str );
+ return Integer.parseInt(str);
}
}
}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/project/SigilModelRoot.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/project/SigilModelRoot.java
index cd9ef1b..7188cfe 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/project/SigilModelRoot.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/project/SigilModelRoot.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.internal.model.project;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
@@ -47,146 +46,152 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-
public class SigilModelRoot implements ISigilModelRoot
{
public List<ISigilProjectModel> getProjects()
{
IProject[] all = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- ArrayList<ISigilProjectModel> projects = new ArrayList<ISigilProjectModel>( all.length );
- for ( IProject p : all )
+ ArrayList<ISigilProjectModel> projects = new ArrayList<ISigilProjectModel>(
+ all.length);
+ for (IProject p : all)
{
try
{
- if ( p.isOpen() && p.hasNature( SigilCore.NATURE_ID ) )
+ if (p.isOpen() && p.hasNature(SigilCore.NATURE_ID))
{
- ISigilProjectModel n = SigilCore.create( p );
- projects.add( n );
+ ISigilProjectModel n = SigilCore.create(p);
+ projects.add(n);
}
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- SigilCore.error( "Failed to build model element", e );
+ SigilCore.error("Failed to build model element", e);
}
}
return projects;
}
-
- public Set<ISigilProjectModel> resolveDependentProjects( Collection<ICapabilityModelElement> caps, IProgressMonitor monitor )
+ public Set<ISigilProjectModel> resolveDependentProjects(
+ Collection<ICapabilityModelElement> caps, IProgressMonitor monitor)
{
final HashSet<ISigilProjectModel> dependents = new HashSet<ISigilProjectModel>();
- for ( final ISigilProjectModel n : getProjects() )
+ for (final ISigilProjectModel n : getProjects())
{
- for (final ICapabilityModelElement cap : caps ) {
+ for (final ICapabilityModelElement cap : caps)
+ {
final ISigilProjectModel sigil = cap.getAncestor(ISigilProjectModel.class);
-
+
n.visit(new IModelWalker()
{
public boolean visit(IModelElement element)
{
- if ( element instanceof IRequirementModelElement ) {
+ if (element instanceof IRequirementModelElement)
+ {
IRequirementModelElement req = (IRequirementModelElement) element;
- if ( req.accepts(cap) ) {
+ if (req.accepts(cap))
+ {
dependents.add(n);
return false;
}
}
- else if ( element instanceof ILibraryImport ) {
+ else if (element instanceof ILibraryImport)
+ {
ILibraryImport l = (ILibraryImport) element;
- ILibrary lib = SigilCore.getRepositoryManager( sigil ).resolveLibrary( l );
+ ILibrary lib = SigilCore.getRepositoryManager(sigil).resolveLibrary(
+ l);
- if ( lib != null )
+ if (lib != null)
{
- for ( IPackageImport i : lib.getImports() )
+ for (IPackageImport i : lib.getImports())
{
- if ( i.accepts(cap))
+ if (i.accepts(cap))
{
- dependents.add( n );
+ dependents.add(n);
}
}
}
else
{
- SigilCore.error( "No library found for " + l );
+ SigilCore.error("No library found for " + l);
}
}
return true;
}
});
}
-// if ( !sigil.equals( n ) )
-// {
-// for ( IPackageExport pe : sigil.getBundle().getBundleInfo().getExports() )
-// {
-// for ( IPackageImport i : n.getBundle().getBundleInfo().getImports() )
-// {
-// if ( pe.getPackageName().equals( i.getPackageName() )
-// && i.getVersions().contains( pe.getVersion() ) )
-// {
-// dependents.add( n );
-// }
-// }
-//
-// for ( ILibraryImport l : n.getBundle().getBundleInfo().getLibraryImports() )
-// {
-// ILibrary lib = SigilCore.getRepositoryManager( sigil ).resolveLibrary( l );
-//
-// if ( lib != null )
-// {
-// for ( IPackageImport i : lib.getImports() )
-// {
-// if ( pe.getPackageName().equals( i.getPackageName() )
-// && i.getVersions().contains( pe.getVersion() ) )
-// {
-// dependents.add( n );
-// }
-// }
-// }
-// else
-// {
-// SigilCore.error( "No library found for " + l );
-// }
-// }
-// }
-//
-// for ( IRequiredBundle r : n.getBundle().getBundleInfo().getRequiredBundles() )
-// {
-// if ( sigil.getSymbolicName().equals( r.getSymbolicName() )
-// && r.getVersions().contains( sigil.getVersion() ) )
-// {
-// dependents.add( n );
-// }
-// }
-// }
+ // if ( !sigil.equals( n ) )
+ // {
+ // for ( IPackageExport pe : sigil.getBundle().getBundleInfo().getExports() )
+ // {
+ // for ( IPackageImport i : n.getBundle().getBundleInfo().getImports() )
+ // {
+ // if ( pe.getPackageName().equals( i.getPackageName() )
+ // && i.getVersions().contains( pe.getVersion() ) )
+ // {
+ // dependents.add( n );
+ // }
+ // }
+ //
+ // for ( ILibraryImport l : n.getBundle().getBundleInfo().getLibraryImports() )
+ // {
+ // ILibrary lib = SigilCore.getRepositoryManager( sigil ).resolveLibrary( l );
+ //
+ // if ( lib != null )
+ // {
+ // for ( IPackageImport i : lib.getImports() )
+ // {
+ // if ( pe.getPackageName().equals( i.getPackageName() )
+ // && i.getVersions().contains( pe.getVersion() ) )
+ // {
+ // dependents.add( n );
+ // }
+ // }
+ // }
+ // else
+ // {
+ // SigilCore.error( "No library found for " + l );
+ // }
+ // }
+ // }
+ //
+ // for ( IRequiredBundle r : n.getBundle().getBundleInfo().getRequiredBundles() )
+ // {
+ // if ( sigil.getSymbolicName().equals( r.getSymbolicName() )
+ // && r.getVersions().contains( sigil.getVersion() ) )
+ // {
+ // dependents.add( n );
+ // }
+ // }
+ // }
}
return dependents;
}
-
- public Collection<ISigilBundle> resolveBundles( ISigilProjectModel sigil, IModelElement element,
- boolean includeOptional, IProgressMonitor monitor ) throws CoreException
+ public Collection<ISigilBundle> resolveBundles(ISigilProjectModel sigil,
+ IModelElement element, boolean includeOptional, IProgressMonitor monitor)
+ throws CoreException
{
int options = ResolutionConfig.INCLUDE_DEPENDENTS;
- if ( includeOptional )
+ if (includeOptional)
{
options |= ResolutionConfig.INCLUDE_OPTIONAL;
}
- ResolutionConfig config = new ResolutionConfig( options );
+ ResolutionConfig config = new ResolutionConfig(options);
try
{
- IBundleResolver resolver = SigilCore.getRepositoryManager( sigil ).getBundleResolver();
- IResolution resolution = resolver.resolve( element, config, new ResolutionMonitorAdapter( monitor ) );
- resolution.synchronize( monitor );
+ IBundleResolver resolver = SigilCore.getRepositoryManager(sigil).getBundleResolver();
+ IResolution resolution = resolver.resolve(element, config,
+ new ResolutionMonitorAdapter(monitor));
+ resolution.synchronize(monitor);
return resolution.getBundles();
}
- catch ( ResolutionException e )
+ catch (ResolutionException e)
{
- throw SigilCore.newCoreException( e.getMessage(), e );
+ throw SigilCore.newCoreException(e.getMessage(), e);
}
}
}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/project/SigilProject.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/project/SigilProject.java
index f00900e..2530f90 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/project/SigilProject.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/project/SigilProject.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.internal.model.project;
-
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
@@ -83,7 +82,6 @@
import org.osgi.framework.Version;
import org.osgi.service.prefs.Preferences;
-
/**
* @author dave
*
@@ -106,94 +104,104 @@
public SigilProject()
{
- super( "Sigil Project" );
+ super("Sigil Project");
}
-
- public SigilProject( IProject project ) throws CoreException
+ public SigilProject(IProject project) throws CoreException
{
this();
this.project = project;
- bldProjectFile = project.getFile( new Path( SigilCore.SIGIL_PROJECT_FILE ) );
+ bldProjectFile = project.getFile(new Path(SigilCore.SIGIL_PROJECT_FILE));
}
-
- public void save( IProgressMonitor monitor ) throws CoreException
+ public void save(IProgressMonitor monitor) throws CoreException
{
save(monitor, true);
}
-
- public void save( IProgressMonitor monitor, boolean rebuildDependencies ) throws CoreException
- {
- SubMonitor progress = SubMonitor.convert( monitor, 1000 );
- bldProjectFile.setContents( buildContents(), IFile.KEEP_HISTORY, progress.newChild( 10 ) );
-
- if ( rebuildDependencies ) {
+ public void save(IProgressMonitor monitor, boolean rebuildDependencies)
+ throws CoreException
+ {
+ SubMonitor progress = SubMonitor.convert(monitor, 1000);
+
+ bldProjectFile.setContents(buildContents(), IFile.KEEP_HISTORY,
+ progress.newChild(10));
+
+ if (rebuildDependencies)
+ {
rebuildDependencies(progress.newChild(900));
}
}
- public void rebuildDependencies(IProgressMonitor monitor) throws CoreException {
- SubMonitor progress = SubMonitor.convert( monitor, 1000 );
+ public void rebuildDependencies(IProgressMonitor monitor) throws CoreException
+ {
+ SubMonitor progress = SubMonitor.convert(monitor, 1000);
- HashSet<ICapabilityModelElement> changes = new HashSet<ICapabilityModelElement>(lastCaps);
-
+ HashSet<ICapabilityModelElement> changes = new HashSet<ICapabilityModelElement>(
+ lastCaps);
+
LinkedList<IRequirementModelElement> reqs = new LinkedList<IRequirementModelElement>();
LinkedList<ICapabilityModelElement> caps = new LinkedList<ICapabilityModelElement>();
-
+
checkChanges(progress.newChild(100), reqs, caps);
-
+
boolean reqsChanged;
boolean capsChanged;
-
- synchronized(this) {
+
+ synchronized (this)
+ {
reqsChanged = isRequirementsChanged(reqs);
capsChanged = isCapabilitiesChanged(caps);
}
-
- if ( reqsChanged ) {
+
+ if (reqsChanged)
+ {
processRequirementsChanges(progress.newChild(600));
SigilCore.rebuild(this, progress.newChild(50));
}
-
- progress.setWorkRemaining( 250 );
- if ( capsChanged ) {
+ progress.setWorkRemaining(250);
+
+ if (capsChanged)
+ {
changes.addAll(caps);
- SigilCore.rebuildBundleDependencies( this, changes, progress.newChild( 250 ) );
- }
+ SigilCore.rebuildBundleDependencies(this, changes, progress.newChild(250));
+ }
}
-
- public void flushDependencyState() {
- synchronized(this) {
+
+ public void flushDependencyState()
+ {
+ synchronized (this)
+ {
lastReqs.clear();
}
}
-
- private void processRequirementsChanges(IProgressMonitor monitor) throws CoreException
+
+ private void processRequirementsChanges(IProgressMonitor monitor)
+ throws CoreException
{
- SubMonitor progress = SubMonitor.convert( monitor, 100 );
-
- IRepositoryManager manager = SigilCore.getRepositoryManager( this );
- ResolutionConfig config = new ResolutionConfig( ResolutionConfig.INCLUDE_OPTIONAL | ResolutionConfig.IGNORE_ERRORS );
+ SubMonitor progress = SubMonitor.convert(monitor, 100);
+
+ IRepositoryManager manager = SigilCore.getRepositoryManager(this);
+ ResolutionConfig config = new ResolutionConfig(ResolutionConfig.INCLUDE_OPTIONAL
+ | ResolutionConfig.IGNORE_ERRORS);
try
{
- IResolution resolution = manager.getBundleResolver().resolve( this, config,
- new ResolutionMonitorAdapter( progress.newChild( 20 ) ) );
-
+ IResolution resolution = manager.getBundleResolver().resolve(this, config,
+ new ResolutionMonitorAdapter(progress.newChild(20)));
+
markProblems(resolution);
-
+
// pull remote bundles from repositories to be added to classpath
- if ( !resolution.isSynchronized() )
+ if (!resolution.isSynchronized())
{
- resolution.synchronize( progress.newChild( 80 ) );
+ resolution.synchronize(progress.newChild(80));
}
}
- catch ( ResolutionException e )
+ catch (ResolutionException e)
{
- throw SigilCore.newCoreException( "Failed to resolve dependencies", e );
+ throw SigilCore.newCoreException("Failed to resolve dependencies", e);
}
}
@@ -201,27 +209,26 @@
{
try
{
- getProject().deleteMarkers( SigilCore.MARKER_UNRESOLVED_DEPENDENCY, true,
- IResource.DEPTH_ONE );
+ getProject().deleteMarkers(SigilCore.MARKER_UNRESOLVED_DEPENDENCY, true,
+ IResource.DEPTH_ONE);
// Find missing imports
Collection<IPackageImport> imports = getBundle().getBundleInfo().getImports();
- for ( IPackageImport pkgImport : imports )
+ for (IPackageImport pkgImport : imports)
{
- if ( resolution.getProvider( pkgImport ) == null )
+ if (resolution.getProvider(pkgImport) == null)
{
- markMissingImport( pkgImport, getProject() );
+ markMissingImport(pkgImport, getProject());
}
}
// Find missing required bundles
- Collection<IRequiredBundle> requiredBundles = getBundle().getBundleInfo()
- .getRequiredBundles();
- for ( IRequiredBundle requiredBundle : requiredBundles )
+ Collection<IRequiredBundle> requiredBundles = getBundle().getBundleInfo().getRequiredBundles();
+ for (IRequiredBundle requiredBundle : requiredBundles)
{
- if ( resolution.getProvider( requiredBundle ) == null )
+ if (resolution.getProvider(requiredBundle) == null)
{
- markMissingRequiredBundle( requiredBundle, getProject() );
+ markMissingRequiredBundle(requiredBundle, getProject());
}
}
}
@@ -231,30 +238,35 @@
}
}
- private void checkChanges(IProgressMonitor monitor, final List<IRequirementModelElement> reqs, final List<ICapabilityModelElement> caps)
+ private void checkChanges(IProgressMonitor monitor,
+ final List<IRequirementModelElement> reqs,
+ final List<ICapabilityModelElement> caps)
{
visit(new IModelWalker()
- {
+ {
public boolean visit(IModelElement element)
{
- if ( element instanceof IRequirementModelElement ) {
+ if (element instanceof IRequirementModelElement)
+ {
reqs.add((IRequirementModelElement) element);
}
- else if ( element instanceof ICapabilityModelElement ) {
+ else if (element instanceof ICapabilityModelElement)
+ {
// also calculate uses during this pass to save multi pass on model
- if ( element instanceof IPackageExport )
+ if (element instanceof IPackageExport)
{
- IPackageExport pe = ( IPackageExport ) element;
+ IPackageExport pe = (IPackageExport) element;
try
{
- pe.setUses( Arrays.asList( JavaHelper.findUses( pe.getPackageName(), SigilProject.this ) ) );
+ pe.setUses(Arrays.asList(JavaHelper.findUses(
+ pe.getPackageName(), SigilProject.this)));
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- SigilCore.error( "Failed to build uses list for " + pe, e );
+ SigilCore.error("Failed to build uses list for " + pe, e);
}
}
-
+
caps.add((ICapabilityModelElement) element);
}
return true;
@@ -262,13 +274,14 @@
});
}
-
private boolean isRequirementsChanged(List<IRequirementModelElement> dependencies)
{
- if ( lastReqs.equals(dependencies) ) {
+ if (lastReqs.equals(dependencies))
+ {
return false;
}
- else {
+ else
+ {
lastReqs = dependencies;
return true;
}
@@ -276,38 +289,45 @@
private boolean isCapabilitiesChanged(List<ICapabilityModelElement> capabilites)
{
- if ( lastCaps.equals(capabilites) ) {
+ if (lastCaps.equals(capabilites))
+ {
return false;
}
- else {
+ else
+ {
lastCaps = capabilites;
return true;
}
}
- private static void markMissingImport( IPackageImport pkgImport, IProject project ) throws CoreException
+ 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 );
+ 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
+ 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 );
- }
+ 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);
+ }
/**
* Returns the project custom preference pool.
@@ -317,9 +337,9 @@
*/
public Preferences getPreferences()
{
- synchronized ( this )
+ synchronized (this)
{
- if ( preferences == null )
+ if (preferences == null)
{
preferences = loadPreferences();
}
@@ -328,83 +348,80 @@
}
}
-
/**
* @return
*/
private synchronized IEclipsePreferences loadPreferences()
{
- IScopeContext context = new ProjectScope( getProject() );
- final IEclipsePreferences eclipsePreferences = context.getNode( SigilCore.PLUGIN_ID );
+ IScopeContext context = new ProjectScope(getProject());
+ final IEclipsePreferences eclipsePreferences = context.getNode(SigilCore.PLUGIN_ID);
// Listen to node removal from parent in order to reset cache
INodeChangeListener nodeListener = new IEclipsePreferences.INodeChangeListener()
{
- public void added( IEclipsePreferences.NodeChangeEvent event )
+ public void added(IEclipsePreferences.NodeChangeEvent event)
{
// do nothing
}
-
- public void removed( IEclipsePreferences.NodeChangeEvent event )
+ public void removed(IEclipsePreferences.NodeChangeEvent event)
{
- if ( event.getChild() == eclipsePreferences )
+ if (event.getChild() == eclipsePreferences)
{
- synchronized ( SigilProject.this )
+ synchronized (SigilProject.this)
{
preferences = null;
}
- ( ( IEclipsePreferences ) eclipsePreferences.parent() ).removeNodeChangeListener( this );
+ ((IEclipsePreferences) eclipsePreferences.parent()).removeNodeChangeListener(this);
}
}
};
- ( ( IEclipsePreferences ) eclipsePreferences.parent() ).addNodeChangeListener( nodeListener );
+ ((IEclipsePreferences) eclipsePreferences.parent()).addNodeChangeListener(nodeListener);
return eclipsePreferences;
}
-
- public Collection<IClasspathEntry> findExternalClasspath( IProgressMonitor monitor ) throws CoreException
+ public Collection<IClasspathEntry> findExternalClasspath(IProgressMonitor monitor)
+ throws CoreException
{
- return JavaHelper.resolveClasspathEntrys( this, monitor );
+ return JavaHelper.resolveClasspathEntrys(this, monitor);
}
public Version getVersion()
{
ISigilBundle bundle = getBundle();
- return bundle == null ? null : bundle.getBundleInfo() == null ? null : bundle.getBundleInfo().getVersion();
+ return bundle == null ? null : bundle.getBundleInfo() == null ? null
+ : bundle.getBundleInfo().getVersion();
}
-
public String getSymbolicName()
{
ISigilBundle bundle = getBundle();
- return bundle == null ? null : bundle.getBundleInfo() == null ? null : bundle.getBundleInfo().getSymbolicName();
+ return bundle == null ? null : bundle.getBundleInfo() == null ? null
+ : bundle.getBundleInfo().getSymbolicName();
}
-
public IProject getProject()
{
return project;
}
-
public ISigilBundle getBundle()
{
ISigilBundle b = null;
-
+
try
{
boolean newProject = false;
-
- synchronized ( bldProjectFile )
+
+ synchronized (bldProjectFile)
{
- if ( bundle == null )
+ if (bundle == null)
{
- if ( bldProjectFile.getLocation().toFile().exists() )
+ if (bldProjectFile.getLocation().toFile().exists())
{
- bundle = parseContents( bldProjectFile );
+ bundle = parseContents(bldProjectFile);
}
else
{
@@ -416,168 +433,165 @@
b = bundle;
}
- if ( newProject ) {
+ if (newProject)
+ {
NullProgressMonitor npm = new NullProgressMonitor();
- bldProjectFile.create( buildContents(), true /* force */, npm );
- project.refreshLocal( IResource.DEPTH_ONE, npm );
+ bldProjectFile.create(buildContents(), true /* force */, npm);
+ project.refreshLocal(IResource.DEPTH_ONE, npm);
}
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- SigilCore.error( "Failed to build bundle", e );
+ SigilCore.error("Failed to build bundle", e);
}
-
+
return b;
}
-
- public void setBundle( ISigilBundle bundle )
+ public void setBundle(ISigilBundle bundle)
{
- synchronized( bldProjectFile ) {
+ synchronized (bldProjectFile)
+ {
this.bundle = bundle;
}
}
-
public IJavaProject getJavaModel()
{
- return JavaCore.create( project );
+ return JavaCore.create(project);
}
-
@Override
- public boolean equals( Object obj )
+ public boolean equals(Object obj)
{
- if ( obj == null )
+ if (obj == null)
return false;
- if ( obj == this )
+ if (obj == this)
return true;
try
{
- SigilProject p = ( SigilProject ) obj;
- return getSymbolicName().equals( p.getSymbolicName() )
- && ( getVersion() == null ? p.getVersion() == null : getVersion().equals( p.getVersion() ) );
+ SigilProject p = (SigilProject) obj;
+ return getSymbolicName().equals(p.getSymbolicName())
+ && (getVersion() == null ? p.getVersion() == null : getVersion().equals(
+ p.getVersion()));
}
- catch ( ClassCastException e )
+ catch (ClassCastException e)
{
return false;
}
}
-
@Override
public int hashCode()
{
int hc = getSymbolicName().hashCode();
- if ( getVersion() != null ) {
+ if (getVersion() != null)
+ {
hc *= getVersion().hashCode();
}
hc *= 7;
return hc;
}
-
@Override
public String toString()
{
return "SigilProject[" + getSymbolicName() + ":" + getVersion() + "]";
}
-
- public void resetClasspath( IProgressMonitor monitor ) throws CoreException
+ public void resetClasspath(IProgressMonitor monitor) throws CoreException
{
- Path containerPath = new Path( SigilCore.CLASSPATH_CONTAINER_PATH );
+ Path containerPath = new Path(SigilCore.CLASSPATH_CONTAINER_PATH);
IJavaProject java = getJavaModel();
- ClasspathContainerInitializer init = JavaCore
- .getClasspathContainerInitializer( SigilCore.CLASSPATH_CONTAINER_PATH );
- ThreadProgressMonitor.setProgressMonitor( monitor );
+ ClasspathContainerInitializer init = JavaCore.getClasspathContainerInitializer(SigilCore.CLASSPATH_CONTAINER_PATH);
+ ThreadProgressMonitor.setProgressMonitor(monitor);
try
{
- init.requestClasspathContainerUpdate( containerPath, java, null );
+ init.requestClasspathContainerUpdate(containerPath, java, null);
}
finally
{
- ThreadProgressMonitor.setProgressMonitor( null );
+ ThreadProgressMonitor.setProgressMonitor(null);
}
}
-
public IPath findBundleLocation() throws CoreException
{
IPath p = PathUtil.newPathIfExists(getBundle().getLocation());
- if ( p == null )
+ if (p == null)
{
- p = SigilCore.getDefault().findDefaultBundleLocation( this );
+ p = SigilCore.getDefault().findDefaultBundleLocation(this);
}
return p;
}
-
- public IModelElement findImport( final String packageName, final IProgressMonitor monitor )
+ public IModelElement findImport(final String packageName,
+ final IProgressMonitor monitor)
{
final IModelElement[] found = new IModelElement[1];
- visit( new IModelWalker()
+ visit(new IModelWalker()
{
- public boolean visit( IModelElement element )
+ public boolean visit(IModelElement element)
{
- if ( element instanceof IPackageImport )
+ if (element instanceof IPackageImport)
{
- IPackageImport pi = ( IPackageImport ) element;
- if ( pi.getPackageName().equals( packageName ) )
+ IPackageImport pi = (IPackageImport) element;
+ if (pi.getPackageName().equals(packageName))
{
found[0] = pi;
return false;
}
}
- else if ( element instanceof IRequiredBundle )
+ else if (element instanceof IRequiredBundle)
{
- IRequiredBundle rb = ( IRequiredBundle ) element;
+ IRequiredBundle rb = (IRequiredBundle) element;
try
{
- IRepositoryManager manager = SigilCore.getRepositoryManager( SigilProject.this );
- ResolutionConfig config = new ResolutionConfig( ResolutionConfig.IGNORE_ERRORS );
- IResolution res = manager.getBundleResolver().resolve( rb, config,
- new ResolutionMonitorAdapter( monitor ) );
- ISigilBundle b = res.getProvider( rb );
- for ( IPackageExport pe : b.getBundleInfo().getExports() )
+ IRepositoryManager manager = SigilCore.getRepositoryManager(SigilProject.this);
+ ResolutionConfig config = new ResolutionConfig(
+ ResolutionConfig.IGNORE_ERRORS);
+ IResolution res = manager.getBundleResolver().resolve(rb, config,
+ new ResolutionMonitorAdapter(monitor));
+ ISigilBundle b = res.getProvider(rb);
+ for (IPackageExport pe : b.getBundleInfo().getExports())
{
- if ( pe.getPackageName().equals( packageName ) )
+ if (pe.getPackageName().equals(packageName))
{
found[0] = rb;
return false;
}
}
}
- catch ( ResolutionException e )
+ catch (ResolutionException e)
{
- SigilCore.error( "Failed to resolve " + rb, e );
+ SigilCore.error("Failed to resolve " + rb, e);
}
}
return true;
}
- } );
+ });
return found[0];
}
-
- public boolean isInClasspath( String packageName, IProgressMonitor monitor ) throws CoreException
+ public boolean isInClasspath(String packageName, IProgressMonitor monitor)
+ throws CoreException
{
- if ( findImport( packageName, monitor ) != null )
+ if (findImport(packageName, monitor) != null)
{
return true;
}
- for ( String path : getBundle().getClasspathEntrys() )
+ for (String path : getBundle().getClasspathEntrys())
{
- IClasspathEntry cp = getJavaModel().decodeClasspathEntry( path );
- for ( IPackageFragmentRoot root : getJavaModel().findPackageFragmentRoots( cp ) )
+ IClasspathEntry cp = getJavaModel().decodeClasspathEntry(path);
+ for (IPackageFragmentRoot root : getJavaModel().findPackageFragmentRoots(cp))
{
- if ( findPackage( packageName, root ) )
+ if (findPackage(packageName, root))
{
return true;
}
@@ -586,38 +600,37 @@
return false;
}
-
- public boolean isInClasspath( ISigilBundle bundle )
+ public boolean isInClasspath(ISigilBundle bundle)
{
- for ( String path : getBundle().getClasspathEntrys() )
+ for (String path : getBundle().getClasspathEntrys())
{
- IClasspathEntry cp = getJavaModel().decodeClasspathEntry( path );
- switch ( cp.getEntryKind() )
+ IClasspathEntry cp = getJavaModel().decodeClasspathEntry(path);
+ switch (cp.getEntryKind())
{
case IClasspathEntry.CPE_PROJECT:
- ISigilProjectModel p = bundle.getAncestor( ISigilProjectModel.class );
- return p != null && cp.getPath().equals( p.getProject().getFullPath() );
+ ISigilProjectModel p = bundle.getAncestor(ISigilProjectModel.class);
+ return p != null && cp.getPath().equals(p.getProject().getFullPath());
case IClasspathEntry.CPE_LIBRARY:
- return cp.getPath().equals( bundle.getLocation() );
+ return cp.getPath().equals(bundle.getLocation());
}
}
return false;
}
-
- private boolean findPackage( String packageName, IParent parent ) throws JavaModelException
+ private boolean findPackage(String packageName, IParent parent)
+ throws JavaModelException
{
- for ( IJavaElement e : parent.getChildren() )
+ for (IJavaElement e : parent.getChildren())
{
- if ( e.getElementType() == IJavaElement.PACKAGE_FRAGMENT )
+ if (e.getElementType() == IJavaElement.PACKAGE_FRAGMENT)
{
- return e.getElementName().equals( packageName );
+ return e.getElementName().equals(packageName);
}
- if ( e instanceof IParent )
+ if (e instanceof IParent)
{
- if ( findPackage( packageName, ( IParent ) e ) )
+ if (findPackage(packageName, (IParent) e))
{
return true;
}
@@ -627,113 +640,115 @@
return false;
}
-
private ISigilBundle setupDefaults()
{
- ISigilBundle bundle = ModelElementFactory.getInstance().newModelElement( ISigilBundle.class );
- IBundleModelElement info = ModelElementFactory.getInstance().newModelElement( IBundleModelElement.class );
- info.setSymbolicName( project.getName() );
- bundle.setBundleInfo( info );
- bundle.setParent( this );
+ ISigilBundle bundle = ModelElementFactory.getInstance().newModelElement(
+ ISigilBundle.class);
+ IBundleModelElement info = ModelElementFactory.getInstance().newModelElement(
+ IBundleModelElement.class);
+ info.setSymbolicName(project.getName());
+ bundle.setBundleInfo(info);
+ bundle.setParent(this);
return bundle;
}
-
- private ISigilBundle parseContents( IFile projectFile ) throws CoreException
+ private ISigilBundle parseContents(IFile projectFile) throws CoreException
{
- if ( projectFile.getName().equals( SigilCore.SIGIL_PROJECT_FILE ) )
+ if (projectFile.getName().equals(SigilCore.SIGIL_PROJECT_FILE))
{
- return parseBldContents( projectFile.getLocationURI() );
+ return parseBldContents(projectFile.getLocationURI());
}
else
{
- throw SigilCore.newCoreException( "Unexpected project file: " + projectFile.getName(), null );
+ throw SigilCore.newCoreException("Unexpected project file: "
+ + projectFile.getName(), null);
}
}
-
- private ISigilBundle parseBldContents( URI uri ) throws CoreException
+ private ISigilBundle parseBldContents(URI uri) throws CoreException
{
try
{
- bldProject = BldFactory.getProject( uri, true );
+ bldProject = BldFactory.getProject(uri, true);
ISigilBundle bundle = bldProject.getDefaultBundle();
-
- if ( bundle == null ) {
+
+ if (bundle == null)
+ {
throw SigilCore.newCoreException("No default bundle", null);
}
-
- bundle.setParent( this );
+
+ bundle.setParent(this);
return bundle;
}
- catch ( IOException e )
+ catch (IOException e)
{
- throw SigilCore.newCoreException( "Failed to parse " + uri, e );
+ throw SigilCore.newCoreException("Failed to parse " + uri, e);
}
}
-
private InputStream buildContents() throws CoreException
{
ByteArrayOutputStream buf = new ByteArrayOutputStream();
try
{
- if ( bldProject == null )
+ if (bldProject == null)
{
- bldProject = BldFactory.newProject( bldProjectFile.getLocationURI(), null );
+ bldProject = BldFactory.newProject(bldProjectFile.getLocationURI(), null);
}
- bldProject.setDefaultBundle( getBundle() );
- bldProject.saveTo( buf );
+ bldProject.setDefaultBundle(getBundle());
+ bldProject.saveTo(buf);
}
- catch ( IOException e )
+ catch (IOException e)
{
- throw SigilCore.newCoreException( "Failed to save project file", e );
+ throw SigilCore.newCoreException("Failed to save project file", e);
}
- return new ByteArrayInputStream( buf.toByteArray() );
+ return new ByteArrayInputStream(buf.toByteArray());
}
-
public String getName()
{
return getProject().getName();
}
-
public IPath findOutputLocation() throws CoreException
{
- return getProject().getLocation().append( getJavaModel().getOutputLocation().removeFirstSegments( 1 ) );
+ return getProject().getLocation().append(
+ getJavaModel().getOutputLocation().removeFirstSegments(1));
}
-
public IBldProject getBldProject() throws CoreException
{
try
{
- return BldFactory.getProject( project.getFile( IBldProject.PROJECT_FILE ).getLocationURI() );
+ return BldFactory.getProject(project.getFile(IBldProject.PROJECT_FILE).getLocationURI());
}
- catch ( IOException e )
+ catch (IOException e)
{
- throw SigilCore.newCoreException( "Failed to get project file: ", e );
+ throw SigilCore.newCoreException("Failed to get project file: ", e);
}
}
-
- public boolean isInBundleClasspath( IPackageFragment root ) throws JavaModelException
+ public boolean isInBundleClasspath(IPackageFragment root) throws JavaModelException
{
- if ( getBundle().getClasspathEntrys().isEmpty() ) {
- for ( String p : getBundle().getPackages() ) {
- SigilCore.log("Checking " + p + "->" + root.getElementName() );
+ if (getBundle().getClasspathEntrys().isEmpty())
+ {
+ for (String p : getBundle().getPackages())
+ {
+ SigilCore.log("Checking " + p + "->" + root.getElementName());
Matcher m = GlobCompiler.compile(p).matcher(root.getElementName());
- if ( m.matches() ) {
+ if (m.matches())
+ {
return true;
}
}
return false;
}
- else {
+ else
+ {
IPackageFragmentRoot parent = (IPackageFragmentRoot) root.getParent();
- String enc = getJavaModel().encodeClasspathEntry( parent.getRawClasspathEntry() );
- return getBundle().getClasspathEntrys().contains( enc.trim() );
+ String enc = getJavaModel().encodeClasspathEntry(
+ parent.getRawClasspathEntry());
+ return getBundle().getClasspathEntrys().contains(enc.trim());
}
}
}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/repository/RepositoryConfiguration.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/repository/RepositoryConfiguration.java
index 5fdc320..081dc5a 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/repository/RepositoryConfiguration.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/repository/RepositoryConfiguration.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.internal.model.repository;
-
import java.io.File;
import java.io.IOException;
import java.net.URL;
@@ -49,7 +48,6 @@
import org.eclipse.swt.graphics.Image;
import org.osgi.framework.Bundle;
-
public class RepositoryConfiguration implements IRepositoryConfiguration
{
@@ -64,33 +62,32 @@
public static final String REPOSITORY_DEFAULT_SET = REPOSITORY + "default.set";
-
public List<IRepositoryModel> loadRepositories()
{
IPreferenceStore prefs = SigilCore.getDefault().getPreferenceStore();
ArrayList<IRepositoryModel> repositories = new ArrayList<IRepositoryModel>();
- for ( RepositoryType type : loadRepositoryTypes() )
+ for (RepositoryType type : loadRepositoryTypes())
{
String typeID = type.getId();
- if ( type.isDynamic() )
+ if (type.isDynamic())
{
- String instances = prefs.getString( REPOSITORY + typeID + INSTANCES );
- if ( instances.trim().length() > 0 )
+ String instances = prefs.getString(REPOSITORY + typeID + INSTANCES);
+ if (instances.trim().length() > 0)
{
- for ( String instance : instances.split( "," ) )
+ for (String instance : instances.split(","))
{
String key = REPOSITORY + typeID + "." + instance;
- repositories.add( loadRepository( instance, key, type, prefs ) );
+ repositories.add(loadRepository(instance, key, type, prefs));
}
}
}
else
{
String key = REPOSITORY + typeID;
- repositories.add( loadRepository( typeID, key, type, prefs ) );
+ repositories.add(loadRepository(typeID, key, type, prefs));
}
}
@@ -98,12 +95,11 @@
return repositories;
}
-
- public IRepositoryModel findRepository( String id )
+ public IRepositoryModel findRepository(String id)
{
- for ( IRepositoryModel model : loadRepositories() )
+ for (IRepositoryModel model : loadRepositories())
{
- if ( model.getId().equals( id ) )
+ if (model.getId().equals(id))
{
return model;
}
@@ -111,92 +107,93 @@
return null;
}
-
- public void saveRepositories( List<IRepositoryModel> repositories ) throws CoreException
+ public void saveRepositories(List<IRepositoryModel> repositories)
+ throws CoreException
{
IPreferenceStore prefs = getPreferences();
HashMap<IRepositoryType, List<IRepositoryModel>> mapped = new HashMap<IRepositoryType, List<IRepositoryModel>>(
- repositories.size() );
+ repositories.size());
- saveRepositoryPreferences( repositories, mapped );
- createNewEntries( mapped, prefs );
- deleteOldEntries( repositories, prefs );
+ saveRepositoryPreferences(repositories, mapped);
+ createNewEntries(mapped, prefs);
+ deleteOldEntries(repositories, prefs);
// time stamp is used as a signal to the manager
// to update its view of the stored repositories
- timeStamp( prefs );
+ timeStamp(prefs);
}
-
public List<RepositoryType> loadRepositoryTypes()
{
List<RepositoryType> repositories = new ArrayList<RepositoryType>();
IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint p = registry.getExtensionPoint( SigilCore.REPOSITORY_PROVIDER_EXTENSION_POINT_ID );
+ IExtensionPoint p = registry.getExtensionPoint(SigilCore.REPOSITORY_PROVIDER_EXTENSION_POINT_ID);
- for ( IExtension e : p.getExtensions() )
+ for (IExtension e : p.getExtensions())
{
- for ( IConfigurationElement c : e.getConfigurationElements() )
+ for (IConfigurationElement c : e.getConfigurationElements())
{
- String id = c.getAttribute( "id" );
- String type = c.getAttribute( "type" );
- boolean dynamic = Boolean.valueOf( c.getAttribute( "dynamic" ) );
- String icon = c.getAttribute( "icon" );
- Image image = ( icon == null || icon.trim().length() == 0 ) ? null : loadImage( e, icon );
- repositories.add( new RepositoryType( id, type, dynamic, image ) );
+ String id = c.getAttribute("id");
+ String type = c.getAttribute("type");
+ boolean dynamic = Boolean.valueOf(c.getAttribute("dynamic"));
+ String icon = c.getAttribute("icon");
+ Image image = (icon == null || icon.trim().length() == 0) ? null
+ : loadImage(e, icon);
+ repositories.add(new RepositoryType(id, type, dynamic, image));
}
}
return repositories;
}
-
- public IRepositoryModel newRepositoryElement( IRepositoryType type )
+ public IRepositoryModel newRepositoryElement(IRepositoryType type)
{
String id = UUID.randomUUID().toString();
PreferenceStore prefs = new PreferenceStore();
- RepositoryModel element = new RepositoryModel( id, "", type, prefs );
- prefs.setFilename( makeFileName( element ) );
- prefs.setValue( "id", id );
+ RepositoryModel element = new RepositoryModel(id, "", type, prefs);
+ prefs.setFilename(makeFileName(element));
+ prefs.setValue("id", id);
return element;
}
-
public IRepositorySet getDefaultRepositorySet()
{
//int level = findLevel( key + LEVEL, type, prefs );
ArrayList<IRepositoryModel> reps = new ArrayList<IRepositoryModel>();
- for ( String s : PrefsUtils.stringToArray( getPreferences().getString( REPOSITORY_DEFAULT_SET ) ) )
- {
- IRepositoryModel rep = findRepository( s );
- if ( rep == null ) {
- SigilCore.error( "Missing repository for " + s );
+ for (String s : PrefsUtils.stringToArray(getPreferences().getString(
+ REPOSITORY_DEFAULT_SET)))
+ {
+ IRepositoryModel rep = findRepository(s);
+ if (rep == null)
+ {
+ SigilCore.error("Missing repository for " + s);
}
- else {
- reps.add( rep );
+ else
+ {
+ reps.add(rep);
}
}
- return new RepositorySet( reps );
+ return new RepositorySet(reps);
}
-
- public IRepositorySet getRepositorySet( String name )
+ public IRepositorySet getRepositorySet(String name)
{
String key = REPOSITORY_SET + name;
- if ( getPreferences().contains( key ) )
+ if (getPreferences().contains(key))
{
ArrayList<IRepositoryModel> reps = new ArrayList<IRepositoryModel>();
- for ( String s : PrefsUtils.stringToArray( getPreferences().getString( key ) ) )
+ for (String s : PrefsUtils.stringToArray(getPreferences().getString(key)))
{
- IRepositoryModel rep = findRepository( s );
- if ( rep == null ) {
- throw new IllegalStateException( "Missing repository for " + s );
+ IRepositoryModel rep = findRepository(s);
+ if (rep == null)
+ {
+ throw new IllegalStateException("Missing repository for " + s);
}
- reps.add( rep );
+ reps.add(rep);
}
- return new RepositorySet( reps );
+ return new RepositorySet(reps);
}
else
{
@@ -204,282 +201,270 @@
}
}
-
public Map<String, IRepositorySet> loadRepositorySets()
{
IPreferenceStore store = getPreferences();
HashMap<String, IRepositorySet> sets = new HashMap<String, IRepositorySet>();
- for ( String name : PrefsUtils.stringToArray( store.getString( REPOSITORY_SETS ) ) )
+ for (String name : PrefsUtils.stringToArray(store.getString(REPOSITORY_SETS)))
{
String key = REPOSITORY_SET + name;
ArrayList<IRepositoryModel> reps = new ArrayList<IRepositoryModel>();
- for ( String s : PrefsUtils.stringToArray( getPreferences().getString( key ) ) )
+ for (String s : PrefsUtils.stringToArray(getPreferences().getString(key)))
{
- reps.add( findRepository( s ) );
+ reps.add(findRepository(s));
}
- sets.put( name, new RepositorySet( reps ) );
+ sets.put(name, new RepositorySet(reps));
}
return sets;
}
-
- public void saveRepositorySets( Map<String, IRepositorySet> sets )
+ public void saveRepositorySets(Map<String, IRepositorySet> sets)
{
IPreferenceStore store = getPreferences();
ArrayList<String> names = new ArrayList<String>();
- for ( Map.Entry<String, IRepositorySet> set : sets.entrySet() )
+ for (Map.Entry<String, IRepositorySet> set : sets.entrySet())
{
String name = set.getKey();
String key = REPOSITORY_SET + name;
ArrayList<String> ids = new ArrayList<String>();
- for ( IRepositoryModel m : set.getValue().getRepositories() )
+ for (IRepositoryModel m : set.getValue().getRepositories())
{
- ids.add( m.getId() );
+ ids.add(m.getId());
}
- store.setValue( key, PrefsUtils.listToString( ids ) );
- names.add( name );
+ store.setValue(key, PrefsUtils.listToString(ids));
+ names.add(name);
}
- for ( String name : PrefsUtils.stringToArray( store.getString( REPOSITORY_SETS ) ) )
+ for (String name : PrefsUtils.stringToArray(store.getString(REPOSITORY_SETS)))
{
- if ( !names.contains( name ) )
+ if (!names.contains(name))
{
String key = REPOSITORY_SET + name;
- store.setToDefault( key );
+ store.setToDefault(key);
}
}
- store.setValue( REPOSITORY_SETS, PrefsUtils.listToString( names ) );
- timeStamp( store );
+ store.setValue(REPOSITORY_SETS, PrefsUtils.listToString(names));
+ timeStamp(store);
}
-
- public void setDefaultRepositorySet( IRepositorySet defaultSet )
+ public void setDefaultRepositorySet(IRepositorySet defaultSet)
{
ArrayList<String> ids = new ArrayList<String>();
- for ( IRepositoryModel m : defaultSet.getRepositories() )
+ for (IRepositoryModel m : defaultSet.getRepositories())
{
- ids.add( m.getId() );
+ ids.add(m.getId());
}
IPreferenceStore prefs = getPreferences();
- prefs.setValue( REPOSITORY_DEFAULT_SET, PrefsUtils.listToString( ids ) );
- timeStamp( prefs );
+ prefs.setValue(REPOSITORY_DEFAULT_SET, PrefsUtils.listToString(ids));
+ timeStamp(prefs);
}
-
- private void timeStamp( IPreferenceStore prefs )
+ private void timeStamp(IPreferenceStore prefs)
{
- prefs.setValue( REPOSITORY_TIMESTAMP, System.currentTimeMillis() );
+ prefs.setValue(REPOSITORY_TIMESTAMP, System.currentTimeMillis());
}
-
private IPreferenceStore getPreferences()
{
return SigilCore.getDefault().getPreferenceStore();
}
-
- private void deleteOldEntries( List<IRepositoryModel> repositories, IPreferenceStore prefs )
+ private void deleteOldEntries(List<IRepositoryModel> repositories,
+ IPreferenceStore prefs)
{
- for ( IRepositoryModel e : loadRepositories() )
+ for (IRepositoryModel e : loadRepositories())
{
- if ( !repositories.contains( e ) )
+ if (!repositories.contains(e))
{
- new File( makeFileName( e ) ).delete();
- String key = makeKey( e );
- prefs.setToDefault( key + LOC );
- prefs.setToDefault( key + NAME );
+ new File(makeFileName(e)).delete();
+ String key = makeKey(e);
+ prefs.setToDefault(key + LOC);
+ prefs.setToDefault(key + NAME);
}
}
- for ( IRepositoryType type : loadRepositoryTypes() )
+ for (IRepositoryType type : loadRepositoryTypes())
{
boolean found = false;
- for ( IRepositoryModel e : repositories )
+ for (IRepositoryModel e : repositories)
{
- if ( e.getType().equals( type ) )
+ if (e.getType().equals(type))
{
found = true;
break;
}
}
- if ( !found )
+ if (!found)
{
- prefs.setToDefault( REPOSITORY + type.getId() + INSTANCES );
+ prefs.setToDefault(REPOSITORY + type.getId() + INSTANCES);
}
}
}
-
- private static void createNewEntries( HashMap<IRepositoryType, List<IRepositoryModel>> mapped,
- IPreferenceStore prefs )
+ private static void createNewEntries(
+ HashMap<IRepositoryType, List<IRepositoryModel>> mapped, IPreferenceStore prefs)
{
- for ( Map.Entry<IRepositoryType, List<IRepositoryModel>> entry : mapped.entrySet() )
+ for (Map.Entry<IRepositoryType, List<IRepositoryModel>> entry : mapped.entrySet())
{
IRepositoryType type = entry.getKey();
- if ( type.isDynamic() )
+ if (type.isDynamic())
{
StringBuffer buf = new StringBuffer();
- for ( IRepositoryModel element : entry.getValue() )
+ for (IRepositoryModel element : entry.getValue())
{
- if ( buf.length() > 0 )
+ if (buf.length() > 0)
{
- buf.append( "," );
+ buf.append(",");
}
- buf.append( element.getId() );
- saveRepository( element, prefs );
+ buf.append(element.getId());
+ saveRepository(element, prefs);
}
- prefs.setValue( REPOSITORY + type.getId() + INSTANCES, buf.toString() );
+ prefs.setValue(REPOSITORY + type.getId() + INSTANCES, buf.toString());
}
else
{
- IRepositoryModel element = entry.getValue().get( 0 );
- saveRepository( element, prefs );
+ IRepositoryModel element = entry.getValue().get(0);
+ saveRepository(element, prefs);
}
}
}
-
- private static void saveRepositoryPreferences( List<IRepositoryModel> repositories,
- HashMap<IRepositoryType, List<IRepositoryModel>> mapped ) throws CoreException
+ private static void saveRepositoryPreferences(List<IRepositoryModel> repositories,
+ HashMap<IRepositoryType, List<IRepositoryModel>> mapped) throws CoreException
{
- for ( IRepositoryModel rep : repositories )
+ for (IRepositoryModel rep : repositories)
{
try
{
- createDir( makeFileName( rep ) );
+ createDir(makeFileName(rep));
rep.getPreferences().save();
- List<IRepositoryModel> list = mapped.get( rep.getType() );
- if ( list == null )
+ List<IRepositoryModel> list = mapped.get(rep.getType());
+ if (list == null)
{
- list = new ArrayList<IRepositoryModel>( 1 );
- mapped.put( rep.getType(), list );
+ list = new ArrayList<IRepositoryModel>(1);
+ mapped.put(rep.getType(), list);
}
- list.add( rep );
+ list.add(rep);
}
- catch ( IOException e )
+ catch (IOException e)
{
- throw SigilCore.newCoreException( "Failed to save repository preferences", e );
+ throw SigilCore.newCoreException("Failed to save repository preferences",
+ e);
}
}
}
-
- private static void createDir( String fileName )
+ private static void createDir(String fileName)
{
- File file = new File( fileName );
+ File file = new File(fileName);
file.getParentFile().mkdirs();
}
-
- private static void saveRepository( IRepositoryModel element, IPreferenceStore prefs )
+ private static void saveRepository(IRepositoryModel element, IPreferenceStore prefs)
{
- String key = makeKey( element );
- prefs.setValue( key + LOC, makeFileName( element ) );
- if ( element.getType().isDynamic() )
+ String key = makeKey(element);
+ prefs.setValue(key + LOC, makeFileName(element));
+ if (element.getType().isDynamic())
{
- prefs.setValue( key + NAME, element.getName() );
+ prefs.setValue(key + NAME, element.getName());
}
- prefs.setValue( key + TIMESTAMP, now() );
+ prefs.setValue(key + TIMESTAMP, now());
}
-
private static long now()
{
return System.currentTimeMillis();
}
-
- private static String makeKey( IRepositoryModel element )
+ private static String makeKey(IRepositoryModel element)
{
IRepositoryType type = element.getType();
String key = REPOSITORY + type.getId();
- if ( type.isDynamic() )
+ if (type.isDynamic())
key = key + "." + element.getId();
return key;
}
-
- private static String makeFileName( IRepositoryModel element )
+ private static String makeFileName(IRepositoryModel element)
{
IPath path = SigilCore.getDefault().getStateLocation();
- path = path.append( "repository" );
- path = path.append( element.getType().getId() );
- path = path.append( element.getId() );
+ path = path.append("repository");
+ path = path.append(element.getType().getId());
+ path = path.append(element.getId());
return path.toOSString();
}
-
- private static RepositoryModel loadRepository( String id, String key, RepositoryType type, IPreferenceStore prefs )
+ private static RepositoryModel loadRepository(String id, String key,
+ RepositoryType type, IPreferenceStore prefs)
{
- String name = type.isDynamic() ? prefs.getString( key + NAME ) : type.getType();
+ String name = type.isDynamic() ? prefs.getString(key + NAME) : type.getType();
PreferenceStore repPrefs = new PreferenceStore();
- RepositoryModel element = new RepositoryModel( id, name, type, repPrefs );
+ RepositoryModel element = new RepositoryModel(id, name, type, repPrefs);
- String loc = prefs.getString( key + LOC );
+ String loc = prefs.getString(key + LOC);
- if ( loc == null || loc.trim().length() == 0 )
+ if (loc == null || loc.trim().length() == 0)
{
- loc = makeFileName( element );
+ loc = makeFileName(element);
}
- repPrefs.setFilename( loc );
+ repPrefs.setFilename(loc);
- if ( new File( loc ).exists() )
+ if (new File(loc).exists())
{
try
{
repPrefs.load();
}
- catch ( IOException e )
+ catch (IOException e)
{
- SigilCore.error( "Failed to load properties for repository " + key, e );
+ SigilCore.error("Failed to load properties for repository " + key, e);
}
}
- repPrefs.setValue( "id", id );
+ repPrefs.setValue("id", id);
return element;
}
-
@SuppressWarnings("unchecked")
- private static Image loadImage( IExtension ext, String icon )
+ private static Image loadImage(IExtension ext, String icon)
{
- int i = icon.lastIndexOf( "/" );
- String path = i == -1 ? "/" : icon.substring( 0, i );
- String name = i == -1 ? icon : icon.substring( i + 1 );
+ int i = icon.lastIndexOf("/");
+ String path = i == -1 ? "/" : icon.substring(0, i);
+ String name = i == -1 ? icon : icon.substring(i + 1);
- Bundle b = Platform.getBundle( ext.getContributor().getName() );
+ Bundle b = Platform.getBundle(ext.getContributor().getName());
- Enumeration<URL> en = b.findEntries( path, name, false );
+ Enumeration<URL> en = b.findEntries(path, name, false);
Image image = null;
- if ( en.hasMoreElements() )
+ if (en.hasMoreElements())
{
try
{
- image = SigilCore.loadImage( en.nextElement() );
+ image = SigilCore.loadImage(en.nextElement());
}
- catch ( IOException e )
+ catch (IOException e)
{
- SigilCore.error( "Failed to load image", e );
+ SigilCore.error("Failed to load image", e);
}
}
else
{
- SigilCore.error( "No such image " + icon + " in bundle " + b.getSymbolicName() );
+ SigilCore.error("No such image " + icon + " in bundle " + b.getSymbolicName());
}
return image;
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/repository/RepositoryModel.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/repository/RepositoryModel.java
index bdc7a6d..2b52c45 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/repository/RepositoryModel.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/repository/RepositoryModel.java
@@ -19,12 +19,10 @@
package org.apache.felix.sigil.eclipse.internal.model.repository;
-
import org.apache.felix.sigil.eclipse.model.repository.IRepositoryModel;
import org.apache.felix.sigil.eclipse.model.repository.IRepositoryType;
import org.eclipse.jface.preference.PreferenceStore;
-
public class RepositoryModel implements IRepositoryModel
{
private String id;
@@ -35,8 +33,7 @@
private PreferenceStore preferences;
-
- public RepositoryModel( String id, String name, IRepositoryType type, PreferenceStore preferences )
+ public RepositoryModel(String id, String name, IRepositoryType type, PreferenceStore preferences)
{
this.id = id;
this.name = name;
@@ -44,59 +41,51 @@
this.preferences = preferences;
}
-
public PreferenceStore getPreferences()
{
return preferences;
}
-
public IRepositoryType getType()
{
return type;
}
-
public String getId()
{
return id;
}
-
public String getName()
{
return name;
}
-
- public void setName( String name )
+ public void setName(String name)
{
this.name = name;
}
-
@Override
- public boolean equals( Object obj )
+ public boolean equals(Object obj)
{
try
{
- RepositoryModel e = ( RepositoryModel ) obj;
- return id.equals( e.id );
+ RepositoryModel e = (RepositoryModel) obj;
+ return id.equals(e.id);
}
- catch ( ClassCastException e )
+ catch (ClassCastException e)
{
return false;
}
}
-
@Override
public int hashCode()
{
return id.hashCode();
}
-
public String toString()
{
return type.getId() + ":" + id + ":" + name;
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/repository/RepositoryType.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/repository/RepositoryType.java
index bb05fe0..d65c174 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/repository/RepositoryType.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/model/repository/RepositoryType.java
@@ -19,11 +19,9 @@
package org.apache.felix.sigil.eclipse.internal.model.repository;
-
import org.apache.felix.sigil.eclipse.model.repository.IRepositoryType;
import org.eclipse.swt.graphics.Image;
-
public class RepositoryType implements IRepositoryType
{
private String type;
@@ -31,8 +29,7 @@
private Image icon;
private boolean dynamic;
-
- public RepositoryType( String id, String type, boolean dynamic, Image icon )
+ public RepositoryType(String id, String type, boolean dynamic, Image icon)
{
this.id = id;
this.type = type;
@@ -40,53 +37,46 @@
this.icon = icon;
}
-
public String getType()
{
return type;
}
-
public String getId()
{
return id;
}
-
public Image getIcon()
{
return icon;
}
-
public boolean isDynamic()
{
return dynamic;
}
-
@Override
- public boolean equals( Object obj )
+ public boolean equals(Object obj)
{
try
{
- RepositoryType t = ( RepositoryType ) obj;
- return t.id.equals( id );
+ RepositoryType t = (RepositoryType) obj;
+ return t.id.equals(id);
}
- catch ( ClassCastException e )
+ catch (ClassCastException e)
{
return false;
}
}
-
@Override
public int hashCode()
{
return id.hashCode();
}
-
@Override
public String toString()
{
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/GlobalRepositoryManager.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/GlobalRepositoryManager.java
index ec03e8a..688c041 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/GlobalRepositoryManager.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/GlobalRepositoryManager.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.internal.repository.eclipse;
-
import java.util.List;
import org.apache.felix.sigil.common.repository.IRepositoryManager;
@@ -27,21 +26,19 @@
import org.apache.felix.sigil.eclipse.internal.repository.eclipse.SigilRepositoryManager;
import org.apache.felix.sigil.eclipse.model.repository.IRepositoryModel;
-
public class GlobalRepositoryManager extends SigilRepositoryManager implements IRepositoryManager
{
public GlobalRepositoryManager(RepositoryMap map)
{
- super( null, map );
+ super(null, map);
}
-
@Override
protected IRepositoryModel[] findRepositories()
{
List<IRepositoryModel> repos = SigilCore.getRepositoryConfiguration().loadRepositories();
- return repos.toArray( new IRepositoryModel[repos.size()] );
+ return repos.toArray(new IRepositoryModel[repos.size()]);
}
}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/OSGiInstallRepository.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/OSGiInstallRepository.java
index 9b8642f..c4f124c 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/OSGiInstallRepository.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/OSGiInstallRepository.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.internal.repository.eclipse;
-
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -41,22 +40,19 @@
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 )
+ public OSGiInstallRepository(String id)
{
- super( id );
+ super(id);
}
-
public void refresh()
{
- synchronized ( this )
+ synchronized (this)
{
bundles = null;
}
@@ -64,41 +60,40 @@
notifyChange();
}
-
@Override
- public void accept( IRepositoryVisitor visitor, int options )
+ public void accept(IRepositoryVisitor visitor, int options)
{
IOSGiInstall install = SigilCore.getInstallManager().getDefaultInstall();
- if ( install != null )
+ if (install != null)
{
List<ISigilBundle> found = null;
- synchronized ( this )
+ synchronized (this)
{
- found = bundles == null ? null : bundles.get( install.getId() );
+ found = bundles == null ? null : bundles.get(install.getId());
}
- if ( found == null )
+ if (found == null)
{
found = new ArrayList<ISigilBundle>();
IPath source = install.getType().getSourceLocation();
- for ( IPath p : install.getType().getDefaultBundleLocations() )
+ for (IPath p : install.getType().getDefaultBundleLocations())
{
- loadBundle( p, found, source );
+ loadBundle(p, found, source);
}
- synchronized ( this )
+ synchronized (this)
{
bundles = new HashMap<String, List<ISigilBundle>>();
- bundles.put( install.getId(), found );
+ bundles.put(install.getId(), found);
}
}
- for ( ISigilBundle b : found )
+ for (ISigilBundle b : found)
{
- if ( !visitor.visit( b ) )
+ if (!visitor.visit(b))
{
break;
}
@@ -106,64 +101,62 @@
}
}
-
- private void loadBundle( IPath p, List<ISigilBundle> bundles, IPath source )
+ 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 )
+ jar = new JarFile(f);
+ ISigilBundle bundle = buildBundle(jar.getManifest(), f);
+ if (bundle != null)
{
- bundle.setLocation( f );
- bundle.setSourcePathLocation( source.toFile() );
+ bundle.setLocation(f);
+ bundle.setSourcePathLocation(source.toFile());
// XXX hard coded src location
- bundle.setSourceRootPath( "src" );
- bundles.add( bundle );
+ bundle.setSourceRootPath("src");
+ bundles.add(bundle);
}
}
- catch ( IOException e )
+ catch (IOException e)
{
- BldCore.error( "Failed to read jar file " + f, e );
+ BldCore.error("Failed to read jar file " + f, e);
}
- catch ( ModelElementFactoryException e )
+ catch (ModelElementFactoryException e)
{
- BldCore.error( "Failed to build bundle " + f, e );
+ BldCore.error("Failed to build bundle " + f, e);
}
- catch ( RuntimeException e )
+ catch (RuntimeException e)
{
- BldCore.error( "Failed to build bundle " + f, e );
+ BldCore.error("Failed to build bundle " + f, e);
}
finally
{
- if ( jar != null )
+ if (jar != null)
{
try
{
jar.close();
}
- catch ( IOException e )
+ catch (IOException e)
{
- BldCore.error( "Failed to close jar file", e );
+ BldCore.error("Failed to close jar file", e);
}
}
}
}
-
- private ISigilBundle buildBundle( Manifest manifest, File f )
+ private ISigilBundle buildBundle(Manifest manifest, File f)
{
- IBundleModelElement info = buildBundleModelElement( manifest );
+ IBundleModelElement info = buildBundleModelElement(manifest);
ISigilBundle bundle = null;
- if ( info != null )
+ if (info != null)
{
- bundle = ModelElementFactory.getInstance().newModelElement( ISigilBundle.class );
- bundle.addChild( info );
- bundle.setLocation( f );
+ bundle = ModelElementFactory.getInstance().newModelElement(ISigilBundle.class);
+ bundle.addChild(info);
+ bundle.setLocation(f);
}
return bundle;
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/OSGiInstallRepositoryProvider.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/OSGiInstallRepositoryProvider.java
index ebbb2a1..77591e1 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/OSGiInstallRepositoryProvider.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/OSGiInstallRepositoryProvider.java
@@ -19,17 +19,15 @@
package org.apache.felix.sigil.eclipse.internal.repository.eclipse;
-
import java.util.Properties;
import org.apache.felix.sigil.common.repository.IBundleRepository;
import org.apache.felix.sigil.common.repository.IRepositoryProvider;
-
public class OSGiInstallRepositoryProvider implements IRepositoryProvider
{
- public IBundleRepository createRepository( String id, Properties preferences )
+ public IBundleRepository createRepository(String id, Properties preferences)
{
- return new OSGiInstallRepository( id );
+ return new OSGiInstallRepository(id);
}
}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/RepositoryMap.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/RepositoryMap.java
index 27ce7b5..3c736ec 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/RepositoryMap.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/RepositoryMap.java
@@ -33,21 +33,20 @@
final Properties pref;
final IBundleRepository repo;
-
- RepositoryCache( Properties pref, IBundleRepository repo )
+ RepositoryCache(Properties pref, IBundleRepository repo)
{
this.pref = pref;
this.repo = repo;
}
}
-
+
private HashMap<String, RepositoryCache> cachedRepositories = new HashMap<String, RepositoryCache>();
synchronized void retainAll(Collection<String> ids)
{
- for ( Iterator<String> i = cachedRepositories.keySet().iterator(); i.hasNext(); )
+ for (Iterator<String> i = cachedRepositories.keySet().iterator(); i.hasNext();)
{
- if ( !ids.contains( i.next() ) )
+ if (!ids.contains(i.next()))
{
i.remove();
}
@@ -63,8 +62,7 @@
synchronized void put(String id, RepositoryCache cache)
{
// TODO Auto-generated method stub
-
- }
+ }
}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/SigilRepositoryManager.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/SigilRepositoryManager.java
index 130e0a6..1edf9ef 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/SigilRepositoryManager.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/SigilRepositoryManager.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.internal.repository.eclipse;
-
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
@@ -47,40 +46,35 @@
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
-
-public class SigilRepositoryManager extends AbstractRepositoryManager implements IRepositoryManager,
- IPropertyChangeListener
+public class SigilRepositoryManager extends AbstractRepositoryManager implements IRepositoryManager, IPropertyChangeListener
{
private final String repositorySet;
private RepositoryMap cachedRepositories;
- public SigilRepositoryManager( String repositorySet, RepositoryMap cachedRepositories )
+ public SigilRepositoryManager(String repositorySet, RepositoryMap cachedRepositories)
{
this.repositorySet = repositorySet;
this.cachedRepositories = cachedRepositories;
}
-
@Override
public void initialise()
{
super.initialise();
- SigilCore.getDefault().getPreferenceStore().addPropertyChangeListener( this );
+ SigilCore.getDefault().getPreferenceStore().addPropertyChangeListener(this);
}
-
public void destroy()
{
IPreferenceStore prefs = SigilCore.getDefault().getPreferenceStore();
- if ( prefs != null )
+ if (prefs != null)
{
- prefs.removePropertyChangeListener( this );
+ prefs.removePropertyChangeListener(this);
}
}
-
@Override
protected void loadRepositories()
{
@@ -90,54 +84,54 @@
HashSet<String> ids = new HashSet<String>();
IRepositoryModel[] models = findRepositories();
- for ( IRepositoryModel repo : models )
+ for (IRepositoryModel repo : models)
{
try
{
- IRepositoryProvider provider = findProvider( repo.getType() );
+ IRepositoryProvider provider = findProvider(repo.getType());
String id = repo.getId();
IBundleRepository repoImpl = null;
- if ( repo.getType().isDynamic() )
+ 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 );
+ String loc = prefs.getString(instance + ".loc");
+ Properties pref = loadPreferences(loc);
+ repoImpl = loadRepository(id, pref, provider);
}
else
{
- repoImpl = loadRepository( id, null, provider );
+ repoImpl = loadRepository(id, null, provider);
}
- repos.add( repoImpl );
- ids.add( id );
+ repos.add(repoImpl);
+ ids.add(id);
}
- catch ( Exception e )
+ catch (Exception e)
{
- SigilCore.error( "Failed to load repository for " + repo, e );
+ SigilCore.error("Failed to load repository for " + repo, e);
}
}
- setRepositories( repos.toArray( new IBundleRepository[repos.size()] ) );
+ setRepositories(repos.toArray(new IBundleRepository[repos.size()]));
- cachedRepositories.retainAll( ids );
+ cachedRepositories.retainAll(ids);
}
-
- private IRepositoryProvider findProvider( IRepositoryType repositoryType ) throws CoreException
+ 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 );
+ IExtensionPoint p = registry.getExtensionPoint(SigilCore.REPOSITORY_PROVIDER_EXTENSION_POINT_ID);
- for ( IExtension e : p.getExtensions() )
+ for (IExtension e : p.getExtensions())
{
- for ( IConfigurationElement c : e.getConfigurationElements() )
+ for (IConfigurationElement c : e.getConfigurationElements())
{
- if ( id.equals( c.getAttribute( "id" ) ) )
+ if (id.equals(c.getAttribute("id")))
{
- IRepositoryProvider provider = ( IRepositoryProvider ) c.createExecutableExtension( "class" );
+ IRepositoryProvider provider = (IRepositoryProvider) c.createExecutableExtension("class");
return provider;
}
}
@@ -146,84 +140,84 @@
return null;
}
-
protected IRepositoryModel[] findRepositories()
{
- if ( repositorySet == null )
+ if (repositorySet == null)
{
return SigilCore.getRepositoryConfiguration().getDefaultRepositorySet().getRepositories();
}
else
{
- IRepositorySet set = SigilCore.getRepositoryConfiguration().getRepositorySet( repositorySet );
- if ( set == null ) {
- SigilCore.error( "Unknown repository set " + repositorySet );
+ IRepositorySet set = SigilCore.getRepositoryConfiguration().getRepositorySet(
+ repositorySet);
+ if (set == null)
+ {
+ SigilCore.error("Unknown repository set " + repositorySet);
return SigilCore.getRepositoryConfiguration().getDefaultRepositorySet().getRepositories();
}
- else {
+ else
+ {
return set.getRepositories();
}
}
}
-
- private IBundleRepository loadRepository( String id, Properties pref, IRepositoryProvider provider )
- throws RepositoryException
+ private IBundleRepository loadRepository(String id, Properties pref,
+ IRepositoryProvider provider) throws RepositoryException
{
try
{
- if ( pref == null )
+ if (pref == null)
{
pref = new Properties();
}
- RepositoryCache cache = cachedRepositories.get( id );
+ RepositoryCache cache = cachedRepositories.get(id);
- if ( cache == null || !cache.pref.equals( pref ) )
+ if (cache == null || !cache.pref.equals(pref))
{
- IBundleRepository repo = provider.createRepository( id, pref );
- cache = new RepositoryCache( pref, repo );
- cachedRepositories.put( id, cache );
+ IBundleRepository repo = provider.createRepository(id, pref);
+ cache = new RepositoryCache(pref, repo);
+ cachedRepositories.put(id, cache);
}
return cache.repo;
}
- catch ( RuntimeException e )
+ catch (RuntimeException e)
{
- throw new RepositoryException( "Failed to build repositories", e );
+ throw new RepositoryException("Failed to build repositories", e);
}
}
-
- private Properties loadPreferences( String loc ) throws FileNotFoundException, IOException
+ private Properties loadPreferences(String loc) throws FileNotFoundException,
+ IOException
{
FileInputStream in = null;
try
{
Properties pref = new Properties();
- pref.load( new FileInputStream( loc ) );
+ pref.load(new FileInputStream(loc));
return pref;
}
finally
{
- if ( in != null )
+ if (in != null)
{
try
{
in.close();
}
- catch ( IOException e )
+ catch (IOException e)
{
- SigilCore.error( "Failed to close file", e );
+ SigilCore.error("Failed to close file", e);
}
}
}
}
-
- public void propertyChange( PropertyChangeEvent event )
+ public void propertyChange(PropertyChangeEvent event)
{
- if ( event.getProperty().equals( "repository.timestamp" ) )
+ if (event.getProperty().equals("repository.timestamp"))
{
loadRepositories();
}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/WorkspaceRepository.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/WorkspaceRepository.java
index 7bd02e8..19e1e82 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/WorkspaceRepository.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/WorkspaceRepository.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.internal.repository.eclipse;
-
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
@@ -49,91 +48,93 @@
{
private static final int UPDATE_MASK = IResourceDelta.CONTENT | IResourceDelta.OPEN;
-
- static final int EVENT_MASKS = IResourceChangeEvent.PRE_DELETE | IResourceChangeEvent.POST_CHANGE | IResourceChangeEvent.PRE_REFRESH;
- public WorkspaceRepository( String id )
+ static final int EVENT_MASKS = IResourceChangeEvent.PRE_DELETE
+ | IResourceChangeEvent.POST_CHANGE | IResourceChangeEvent.PRE_REFRESH;
+
+ public WorkspaceRepository(String id)
{
- super( id );
- }
-
-
+ super(id);
+ }
+
@Override
- public void accept( IRepositoryVisitor visitor, int options )
+ public void accept(IRepositoryVisitor visitor, int options)
{
List<ISigilProjectModel> models = SigilCore.getRoot().getProjects();
- for ( ISigilProjectModel project : models )
+ for (ISigilProjectModel project : models)
{
ISigilBundle b = project.getBundle();
- if ( b == null )
+ if (b == null)
{
- SigilCore.error( "No bundle found for project " + project.getProject().getName() );
+ SigilCore.error("No bundle found for project "
+ + project.getProject().getName());
}
else
{
- if ( (options & ResolutionConfig.COMPILE_TIME) != 0 ) {
+ if ((options & ResolutionConfig.COMPILE_TIME) != 0)
+ {
b = compileTimeFilter(project, b);
}
- visitor.visit( b );
+ visitor.visit(b);
}
}
}
-
private ISigilBundle compileTimeFilter(ISigilProjectModel project, ISigilBundle bundle)
{
bundle = (ISigilBundle) bundle.clone();
Collection<String> packages = findPackages(project);
-
- for ( IPackageExport pe : bundle.getBundleInfo().getExports() ) {
+
+ for (IPackageExport pe : bundle.getBundleInfo().getExports())
+ {
final String packagePath = pe.getPackageName().replace('.', '/');
- if ( !packages.contains(packagePath) ) {
+ if (!packages.contains(packagePath))
+ {
bundle.getBundleInfo().removeExport(pe);
}
}
-
+
return bundle;
}
-
-
private Collection<String> findPackages(ISigilProjectModel project)
{
final IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
final IContentType javaContentType = contentTypeManager.getContentType("org.eclipse.jdt.core.javaSource");
final HashSet<String> packages = new HashSet<String>();
-
+
try
{
project.getProject().accept(new IResourceVisitor()
{
public boolean visit(IResource resource) throws CoreException
{
- if ( resource instanceof IFile ) {
+ if (resource instanceof IFile)
+ {
IFile f = (IFile) resource;
IContentType ct = contentTypeManager.findContentTypeFor(f.getName());
- if ( ct != null && ct.isKindOf(javaContentType) ) {
+ if (ct != null && ct.isKindOf(javaContentType))
+ {
IPath p = f.getProjectRelativePath();
p = p.removeLastSegments(1);
p = p.removeFirstSegments(1);
- packages.add( p.toString() );
+ packages.add(p.toString());
}
}
-
+
return true;
}
});
}
catch (CoreException e)
{
- SigilCore.error( "Failed to read packages for " + project.getProject().getName() );
+ SigilCore.error("Failed to read packages for "
+ + project.getProject().getName());
}
-
+
return packages;
- }
-
-
+ }
public void refresh()
{
@@ -143,11 +144,12 @@
// potential performance improvement in future?
}
- public void resourceChanged( IResourceChangeEvent event )
+ public void resourceChanged(IResourceChangeEvent event)
{
try
{
- switch (event.getType()) {
+ switch (event.getType())
+ {
case IResourceChangeEvent.PRE_DELETE:
handleDelete(event);
break;
@@ -159,9 +161,9 @@
break;
}
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- SigilCore.error( "Workspace repository update failed", e );
+ SigilCore.error("Workspace repository update failed", e);
}
}
@@ -169,21 +171,22 @@
private void handleDelete(IResourceChangeEvent event)
{
- if ( event.getResource() instanceof IProject ) {
+ if (event.getResource() instanceof IProject)
+ {
IProject project = (IProject) event.getResource();
- if ( isSigilProject(project) )
+ if (isSigilProject(project))
{
deleted.add(project);
}
}
}
-
private void handleRefresh(IResourceChangeEvent event)
{
- if ( event.getResource() instanceof IProject ) {
+ if (event.getResource() instanceof IProject)
+ {
IProject project = (IProject) event.getResource();
- if ( isSigilProject(project) )
+ if (isSigilProject(project))
{
SigilCore.log("Refreshing workspace repository");
notifyChange();
@@ -191,28 +194,27 @@
}
}
-
private void handleChange(IResourceChangeEvent event) throws CoreException
{
final boolean[] notify = new boolean[1];
-
- event.getDelta().accept( new IResourceDeltaVisitor()
+
+ event.getDelta().accept(new IResourceDeltaVisitor()
{
- public boolean visit( IResourceDelta delta ) throws CoreException
+ public boolean visit(IResourceDelta delta) throws CoreException
{
boolean checkMembers = true;
IResource resource = delta.getResource();
- if ( resource instanceof IProject )
+ if (resource instanceof IProject)
{
- IProject project = ( IProject ) resource;
- if ( isSigilProject(project) )
+ IProject project = (IProject) resource;
+ if (isSigilProject(project))
{
- switch ( delta.getKind() )
+ switch (delta.getKind())
{
case IResourceDelta.CHANGED:
int flag = delta.getFlags();
- if ( ( flag & UPDATE_MASK ) == 0 )
+ if ((flag & UPDATE_MASK) == 0)
{
break;
}
@@ -230,9 +232,9 @@
checkMembers = false;
}
}
- else if ( resource.getName().equals( SigilCore.SIGIL_PROJECT_FILE ) )
+ else if (resource.getName().equals(SigilCore.SIGIL_PROJECT_FILE))
{
- switch ( delta.getKind() )
+ switch (delta.getKind())
{
case IResourceDelta.CHANGED:
case IResourceDelta.ADDED:
@@ -243,17 +245,17 @@
}
return checkMembers && !notify[0];
}
- } );
-
- if (notify[0]) {
+ });
+
+ if (notify[0])
+ {
notifyChange();
}
}
-
private boolean isSigilProject(IProject project)
{
- return SigilCore.isSigilProject( project ) || deleted.remove(project);
+ return SigilCore.isSigilProject(project) || deleted.remove(project);
}
}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/WorkspaceRepositoryProvider.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/WorkspaceRepositoryProvider.java
index d9c723b..0562ebf 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/WorkspaceRepositoryProvider.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/repository/eclipse/WorkspaceRepositoryProvider.java
@@ -19,31 +19,28 @@
package org.apache.felix.sigil.eclipse.internal.repository.eclipse;
-
import java.util.Properties;
import org.apache.felix.sigil.common.repository.IBundleRepository;
import org.apache.felix.sigil.common.repository.IRepositoryProvider;
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 )
+ public IBundleRepository createRepository(String id, Properties preferences)
{
- if ( repository == null )
+ if (repository == null)
{
- repository = new WorkspaceRepository( id );
- ResourcesPlugin.getWorkspace().addResourceChangeListener( repository, WorkspaceRepository.EVENT_MASKS );
+ repository = new WorkspaceRepository(id);
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(repository,
+ WorkspaceRepository.EVENT_MASKS);
}
return repository;
}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/resources/ProjectResourceListener.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/resources/ProjectResourceListener.java
index 377f575..340f95e 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/resources/ProjectResourceListener.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/resources/ProjectResourceListener.java
@@ -34,6 +34,7 @@
import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+
//import org.eclipse.core.runtime.IProgressMonitor;
//import org.eclipse.core.runtime.IStatus;
//import org.eclipse.core.runtime.Status;
@@ -41,7 +42,8 @@
public class ProjectResourceListener implements IResourceChangeListener
{
- public static final int EVENT_MASKS = IResourceChangeEvent.PRE_DELETE | IResourceChangeEvent.POST_CHANGE;
+ public static final int EVENT_MASKS = IResourceChangeEvent.PRE_DELETE
+ | IResourceChangeEvent.POST_CHANGE;
private final SigilProjectManager projectManager;
public ProjectResourceListener(SigilProjectManager projectManager)
@@ -49,11 +51,12 @@
this.projectManager = projectManager;
}
- public void resourceChanged( IResourceChangeEvent event )
+ public void resourceChanged(IResourceChangeEvent event)
{
try
{
- switch ( event.getType() ) {
+ switch (event.getType())
+ {
case IResourceChangeEvent.PRE_REFRESH:
handleRefresh(event);
break;
@@ -64,40 +67,43 @@
handlePostChange(event);
break;
}
-
+
handleUpdate();
}
catch (CoreException e)
{
- SigilCore.error( "Failed to process resource change", e );
+ SigilCore.error("Failed to process resource change", e);
}
}
private void handleUpdate()
{
- if( capabilities.size() > 0 ) {
- final LinkedList<ICapabilityModelElement> changes = new LinkedList<ICapabilityModelElement>(capabilities);
+ if (capabilities.size() > 0)
+ {
+ final LinkedList<ICapabilityModelElement> changes = new LinkedList<ICapabilityModelElement>(
+ capabilities);
capabilities.clear();
-
- ResolveProjectsJob job = new ResolveProjectsJob(ResourcesPlugin.getWorkspace(), changes);
- job.schedule();
+
+ ResolveProjectsJob job = new ResolveProjectsJob(
+ ResourcesPlugin.getWorkspace(), changes);
+ job.schedule();
}
}
-
+
private void handleRefresh(IResourceChangeEvent event) throws CoreException
{
IResourceDelta delta = event.getDelta();
- if ( delta != null )
+ if (delta != null)
{
- delta.accept( new IResourceDeltaVisitor()
+ delta.accept(new IResourceDeltaVisitor()
{
- public boolean visit( IResourceDelta delta ) throws CoreException
+ public boolean visit(IResourceDelta delta) throws CoreException
{
IResource resource = delta.getResource();
- if ( resource instanceof IProject )
+ if (resource instanceof IProject)
{
- IProject project = ( IProject ) resource;
- if ( SigilCore.isSigilProject( project ) )
+ IProject project = (IProject) resource;
+ if (SigilCore.isSigilProject(project))
{
readCapabilities(project);
}
@@ -106,28 +112,28 @@
}
return true;
}
- } );
+ });
}
- }
+ }
private LinkedList<ICapabilityModelElement> capabilities = new LinkedList<ICapabilityModelElement>();
-
+
private void handlePostChange(IResourceChangeEvent event) throws CoreException
{
IResourceDelta delta = event.getDelta();
- if ( delta != null )
+ if (delta != null)
{
- delta.accept( new IResourceDeltaVisitor()
+ delta.accept(new IResourceDeltaVisitor()
{
- public boolean visit( IResourceDelta delta ) throws CoreException
+ public boolean visit(IResourceDelta delta) throws CoreException
{
IResource resource = delta.getResource();
- if ( resource instanceof IProject )
+ if (resource instanceof IProject)
{
- IProject project = ( IProject ) resource;
- if ( SigilCore.isSigilProject( project ) )
+ IProject project = (IProject) resource;
+ if (SigilCore.isSigilProject(project))
{
- switch ( delta.getKind() )
+ switch (delta.getKind())
{
case IResourceDelta.REMOVED:
case IResourceDelta.ADDED:
@@ -140,17 +146,17 @@
}
return true;
}
- } );
+ });
}
}
protected void handlePreDelete(IResourceChangeEvent event) throws CoreException
{
IResource resource = event.getResource();
- if ( resource instanceof IProject )
+ if (resource instanceof IProject)
{
- IProject project = ( IProject ) resource;
- if ( SigilCore.isSigilProject( project ) )
+ IProject project = (IProject) resource;
+ if (SigilCore.isSigilProject(project))
{
readCapabilities(project);
projectManager.flushSigilProject(project);
@@ -162,10 +168,11 @@
{
ISigilProjectModel sigil = SigilCore.create(project);
sigil.visit(new IModelWalker()
- {
+ {
public boolean visit(IModelElement element)
{
- if ( element instanceof ICapabilityModelElement ) {
+ if (element instanceof ICapabilityModelElement)
+ {
capabilities.add((ICapabilityModelElement) element);
}
return true;
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/resources/SigilProjectManager.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/resources/SigilProjectManager.java
index 7b734f7..03a8826 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/resources/SigilProjectManager.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/internal/resources/SigilProjectManager.java
@@ -28,28 +28,34 @@
public class SigilProjectManager
{
private static HashMap<IProject, SigilProject> projects = new HashMap<IProject, SigilProject>();
-
- public SigilProject getSigilProject(IProject project) throws CoreException {
- if ( project.hasNature( SigilCore.NATURE_ID ) )
+
+ public SigilProject getSigilProject(IProject project) throws CoreException
+ {
+ if (project.hasNature(SigilCore.NATURE_ID))
{
SigilProject p = null;
- synchronized( projects ) {
+ synchronized (projects)
+ {
p = projects.get(project);
- if ( p == null ) {
- p = new SigilProject( project );
- projects.put(project, p);
+ if (p == null)
+ {
+ p = new SigilProject(project);
+ projects.put(project, p);
}
}
- return p;
+ return p;
}
else
{
- throw SigilCore.newCoreException( "Project " + project.getName() + " is not a sigil project", null );
+ throw SigilCore.newCoreException("Project " + project.getName()
+ + " is not a sigil project", null);
}
}
-
- public void flushSigilProject(IProject project) {
- synchronized(project) {
+
+ public void flushSigilProject(IProject project)
+ {
+ synchronized (project)
+ {
projects.remove(project);
}
}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/job/ResolveProjectsJob.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/job/ResolveProjectsJob.java
index bb9be60..e444918 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/job/ResolveProjectsJob.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/job/ResolveProjectsJob.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.job;
-
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
@@ -38,32 +37,31 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
-
public class ResolveProjectsJob extends WorkspaceJob
{
private final Collection<ISigilProjectModel> sigilProjects;
private final LinkedList<ICapabilityModelElement> capabilities;
-
- public ResolveProjectsJob( IWorkspace workspace )
+
+ public ResolveProjectsJob(IWorkspace workspace)
{
- super( "Resolving Sigil projects" );
- setRule( workspace.getRoot() );
+ super("Resolving Sigil projects");
+ setRule(workspace.getRoot());
sigilProjects = SigilCore.getRoot().getProjects();
capabilities = null;
}
public ResolveProjectsJob(IWorkspace workspace, LinkedList<ICapabilityModelElement> capabilities)
{
- super( "Resolving Sigil projects" );
+ super("Resolving Sigil projects");
this.capabilities = capabilities;
- setRule( workspace.getRoot() );
+ setRule(workspace.getRoot());
sigilProjects = SigilCore.getRoot().getProjects();
}
public ResolveProjectsJob(ISigilProjectModel project)
{
- super( "Resolving Sigil project" );
- setRule( project.getProject().getWorkspace().getRoot() );
+ super("Resolving Sigil project");
+ setRule(project.getProject().getWorkspace().getRoot());
sigilProjects = Collections.singleton(project);
capabilities = null;
}
@@ -71,22 +69,25 @@
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException
{
- MultiStatus status = new MultiStatus( SigilCore.PLUGIN_ID, 0, "Error resolving Sigil projects", null );
+ MultiStatus status = new MultiStatus(SigilCore.PLUGIN_ID, 0,
+ "Error resolving Sigil projects", null);
boolean flush = sigilProjects.size() > 0;
-
- for ( ISigilProjectModel sigilProject : sigilProjects )
+
+ for (ISigilProjectModel sigilProject : sigilProjects)
{
try
{
- if ( isDependent(sigilProject) ) {
- if ( flush) sigilProject.flushDependencyState();
+ if (isDependent(sigilProject))
+ {
+ if (flush)
+ sigilProject.flushDependencyState();
sigilProject.rebuildDependencies(monitor);
}
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- status.add( e.getStatus() );
+ status.add(e.getStatus());
}
}
@@ -95,27 +96,34 @@
private boolean isDependent(ISigilProjectModel sigilProject)
{
- if ( capabilities == null ) {
+ if (capabilities == null)
+ {
return true;
}
- else {
+ else
+ {
ISigilBundle b = sigilProject.getBundle();
- if ( b == null ) {
+ if (b == null)
+ {
// sigil project deleted can't be a dependent
return false;
}
- else {
+ else
+ {
final boolean[] dep = new boolean[1];
-
+
b.visit(new IModelWalker()
{
public boolean visit(IModelElement element)
{
- if (element instanceof IRequirementModelElement) {
+ if (element instanceof IRequirementModelElement)
+ {
IRequirementModelElement r = (IRequirementModelElement) element;
-
- for (ICapabilityModelElement c : capabilities) {
- if( r.accepts(c)) {
+
+ for (ICapabilityModelElement c : capabilities)
+ {
+ if (r.accepts(c))
+ {
dep[0] = true;
break;
}
@@ -125,7 +133,7 @@
return !dep[0];
}
});
-
+
return dep[0];
}
}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/job/ThreadProgressMonitor.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/job/ThreadProgressMonitor.java
index e60be3f..033ba92 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/job/ThreadProgressMonitor.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/job/ThreadProgressMonitor.java
@@ -19,21 +19,17 @@
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 )
+ public static void setProgressMonitor(IProgressMonitor monitor)
{
- local.set( monitor );
+ local.set(monitor);
}
-
public static IProgressMonitor getProgressMonitor()
{
return local.get();
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/project/ISigilModelRoot.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/project/ISigilModelRoot.java
index 0570da8..4544c88 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/project/ISigilModelRoot.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/project/ISigilModelRoot.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.model.project;
-
import java.util.Collection;
import java.util.List;
import java.util.Set;
@@ -30,15 +29,14 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-
public interface ISigilModelRoot
{
List<ISigilProjectModel> getProjects();
+ Set<ISigilProjectModel> resolveDependentProjects(
+ Collection<ICapabilityModelElement> caps, IProgressMonitor monitor);
- Set<ISigilProjectModel> resolveDependentProjects( Collection<ICapabilityModelElement> caps, IProgressMonitor monitor );
-
-
- Collection<ISigilBundle> resolveBundles( ISigilProjectModel sigil, IModelElement element, boolean includeOptional,
- IProgressMonitor monitor ) throws CoreException;
+ Collection<ISigilBundle> resolveBundles(ISigilProjectModel sigil,
+ IModelElement element, boolean includeOptional, IProgressMonitor monitor)
+ throws CoreException;
}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/project/ISigilProjectModel.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/project/ISigilProjectModel.java
index 60afe17..0b80c5b 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/project/ISigilProjectModel.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/project/ISigilProjectModel.java
@@ -19,10 +19,8 @@
package org.apache.felix.sigil.eclipse.model.project;
-
import java.util.Collection;
-
import org.apache.felix.sigil.common.config.IBldProject;
import org.apache.felix.sigil.common.core.BldCore;
import org.apache.felix.sigil.common.model.ICompoundModelElement;
@@ -39,7 +37,6 @@
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)}.
@@ -55,14 +52,11 @@
*/
IProject getProject();
-
// shortcut to getProject().getName()
String getName();
-
Preferences getPreferences();
-
/**
*
* @param monitor
@@ -73,64 +67,52 @@
* @throws CoreException
*/
void save(IProgressMonitor monitor) throws CoreException;
-
+
/**
* Save the project and optionally rebuildDependencies
* @param monitor
* @param rebuildDependencies
* @throws CoreException
*/
- void save( IProgressMonitor monitor, boolean rebuildDependencies ) throws CoreException;
-
- void rebuildDependencies(IProgressMonitor monitor) throws CoreException;
-
- void flushDependencyState();
+ void save(IProgressMonitor monitor, boolean rebuildDependencies) throws CoreException;
+ void rebuildDependencies(IProgressMonitor monitor) throws CoreException;
+
+ void flushDependencyState();
/**
* @return
*/
Version getVersion();
-
String getSymbolicName();
-
ISigilBundle getBundle();
-
- void setBundle( ISigilBundle bundle );
-
+ void setBundle(ISigilBundle bundle);
/**
* @return
*/
IJavaProject getJavaModel();
-
- void resetClasspath( IProgressMonitor monitor ) throws CoreException;
-
+ void resetClasspath(IProgressMonitor monitor) throws CoreException;
IPath findBundleLocation() throws CoreException;
+ IModelElement findImport(String packageName, IProgressMonitor monitor);
- IModelElement findImport( String packageName, IProgressMonitor monitor );
+ boolean isInClasspath(String packageName, IProgressMonitor monitor)
+ throws CoreException;
+ boolean isInClasspath(ISigilBundle bundle);
- boolean isInClasspath( String packageName, IProgressMonitor monitor ) throws CoreException;
-
-
- boolean isInClasspath( ISigilBundle bundle );
-
-
- boolean isInBundleClasspath( IPackageFragment root ) throws JavaModelException;
-
+ boolean isInBundleClasspath(IPackageFragment root) throws JavaModelException;
IPath findOutputLocation() throws CoreException;
-
IBldProject getBldProject() throws CoreException;
-
- Collection<IClasspathEntry> findExternalClasspath( IProgressMonitor monitor ) throws CoreException;
+ Collection<IClasspathEntry> findExternalClasspath(IProgressMonitor monitor)
+ throws CoreException;
}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryConfiguration.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryConfiguration.java
index bcba18b..f3683b6 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryConfiguration.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryConfiguration.java
@@ -19,43 +19,32 @@
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);
- IRepositoryModel findRepository( String id );
-
-
- void saveRepositories( List<IRepositoryModel> repositories ) throws CoreException;
-
+ void saveRepositories(List<IRepositoryModel> repositories) throws CoreException;
List<RepositoryType> loadRepositoryTypes();
-
- IRepositoryModel newRepositoryElement( IRepositoryType type );
-
+ IRepositoryModel newRepositoryElement(IRepositoryType type);
IRepositorySet getDefaultRepositorySet();
+ void setDefaultRepositorySet(IRepositorySet defaultSet);
- void setDefaultRepositorySet( IRepositorySet defaultSet );
-
-
- IRepositorySet getRepositorySet( String name );
-
+ IRepositorySet getRepositorySet(String name);
Map<String, IRepositorySet> loadRepositorySets();
-
- void saveRepositorySets( Map<String, IRepositorySet> sets );
+ void saveRepositorySets(Map<String, IRepositorySet> sets);
}
\ No newline at end of file
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryModel.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryModel.java
index 37f2649..89c8671 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryModel.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryModel.java
@@ -19,24 +19,18 @@
package org.apache.felix.sigil.eclipse.model.repository;
-
import org.eclipse.jface.preference.PreferenceStore;
-
public interface IRepositoryModel
{
String getId();
-
- void setName( String stringValue );
-
+ void setName(String stringValue);
String getName();
-
PreferenceStore getPreferences();
-
IRepositoryType getType();
}
\ No newline at end of file
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositorySet.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositorySet.java
index d28f5e2..8ebb46c 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositorySet.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositorySet.java
@@ -19,17 +19,13 @@
package org.apache.felix.sigil.eclipse.model.repository;
-
public interface IRepositorySet
{
- void setRepository( IRepositoryModel id, int position );
+ void setRepository(IRepositoryModel id, int position);
-
- void removeRepository( IRepositoryModel id );
-
+ void removeRepository(IRepositoryModel id);
IRepositoryModel[] getRepositories();
-
- void setRepositories( IRepositoryModel[] repositories );
+ void setRepositories(IRepositoryModel[] repositories);
}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryType.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryType.java
index f25f2d8..d56ba7c 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryType.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/IRepositoryType.java
@@ -19,22 +19,17 @@
package org.apache.felix.sigil.eclipse.model.repository;
-
import org.eclipse.swt.graphics.Image;
-
public interface IRepositoryType
{
String getType();
-
String getId();
-
Image getIcon();
-
boolean isDynamic();
}
\ No newline at end of file
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/RepositorySet.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/RepositorySet.java
index c3cb1a6..1d80a8a 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/RepositorySet.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/repository/RepositorySet.java
@@ -19,11 +19,9 @@
package org.apache.felix.sigil.eclipse.model.repository;
-
import java.util.ArrayList;
import java.util.Collection;
-
public class RepositorySet implements IRepositorySet
{
@@ -31,49 +29,42 @@
private IRepositoryModel[] reps;
-
public RepositorySet()
{
- this( EMPTY );
+ this(EMPTY);
}
-
- public RepositorySet( Collection<IRepositoryModel> reps )
+ public RepositorySet(Collection<IRepositoryModel> reps)
{
- this( reps.toArray( new IRepositoryModel[reps.size()] ) );
+ this(reps.toArray(new IRepositoryModel[reps.size()]));
}
-
- public RepositorySet( IRepositoryModel[] repositories )
+ public RepositorySet(IRepositoryModel[] repositories)
{
this.reps = repositories;
}
-
- public void setRepository( IRepositoryModel id, int position )
+ 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()] );
+ 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 )
+ public void removeRepository(IRepositoryModel id)
{
- ArrayList<IRepositoryModel> tmp = new ArrayList<IRepositoryModel>( reps.length + 1 );
- tmp.remove( id );
- reps = tmp.toArray( new IRepositoryModel[tmp.size()] );
+ ArrayList<IRepositoryModel> tmp = new ArrayList<IRepositoryModel>(reps.length + 1);
+ tmp.remove(id);
+ reps = tmp.toArray(new IRepositoryModel[tmp.size()]);
}
-
- public void setRepositories( IRepositoryModel[] repositories )
+ public void setRepositories(IRepositoryModel[] repositories)
{
reps = repositories == null ? EMPTY : repositories;
}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/Grep.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/Grep.java
index 036f06c..01faa5c 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/Grep.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/Grep.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.model.util;
-
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.CharBuffer;
@@ -35,12 +34,11 @@
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" );
+ private static Pattern linePattern = Pattern.compile(".*\r?\n");
// The input pattern that we're looking for
private Pattern pattern;
@@ -49,77 +47,72 @@
private FileChannel fc;
-
- private Grep( IFile f, Pattern pattern ) throws IOException, CoreException
+ private Grep(IFile f, Pattern pattern) throws IOException, CoreException
{
this.pattern = pattern;
- cb = openBuffer( f );
+ cb = openBuffer(f);
}
-
- private CharBuffer openBuffer( IFile f ) throws IOException, CoreException
+ private CharBuffer openBuffer(IFile f) throws IOException, CoreException
{
- Charset charset = Charset.forName( f.getCharset() );
+ 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() );
+ 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 );
+ 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 );
+ return decoder.decode(bb);
}
-
- public static String[] grep( Pattern pattern, IFile... files ) throws CoreException
+ public static String[] grep(Pattern pattern, IFile... files) throws CoreException
{
LinkedList<String> matches = new LinkedList<String>();
- for ( IFile f : files )
+ for (IFile f : files)
{
try
{
- Grep g = new Grep( f, pattern );
- g.grep( matches );
+ Grep g = new Grep(f, pattern);
+ g.grep(matches);
g.close();
}
- catch ( IOException e )
+ catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
- return matches.toArray( new String[matches.size()] );
+ 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 )
+ private void grep(List<String> matches)
{
- Matcher lm = linePattern.matcher( cb ); // Line matcher
+ Matcher lm = linePattern.matcher(cb); // Line matcher
Matcher pm = null; // Pattern matcher
int lines = 0;
- while ( lm.find() )
+ while (lm.find())
{
lines++;
CharSequence cs = lm.group(); // The current line
- if ( pm == null )
- pm = pattern.matcher( cs );
+ if (pm == null)
+ pm = pattern.matcher(cs);
else
- pm.reset( cs );
- if ( pm.find() )
- matches.add( pm.group() );
- if ( lm.end() == cb.limit() )
+ pm.reset(cs);
+ if (pm.find())
+ matches.add(pm.group());
+ if (lm.end() == cb.limit())
break;
}
}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/JavaHelper.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/JavaHelper.java
index 3a4d774..c01c9d2 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/JavaHelper.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/JavaHelper.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.model.util;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -94,7 +93,6 @@
import org.eclipse.jdt.core.Signature;
import org.osgi.framework.Version;
-
/**
* @author dave
*
@@ -102,31 +100,30 @@
public class JavaHelper
{
- public static final IAccessRule DENY_RULE = JavaCore.newAccessRule( new Path( "**" ), IAccessRule.K_NON_ACCESSIBLE
- | IAccessRule.IGNORE_IF_BETTER );
+ public static final IAccessRule DENY_RULE = JavaCore.newAccessRule(new Path("**"),
+ IAccessRule.K_NON_ACCESSIBLE | IAccessRule.IGNORE_IF_BETTER);
- public static final IAccessRule ALLOW_ALL_RULE = JavaCore
- .newAccessRule( new Path( "**" ), IAccessRule.K_ACCESSIBLE );
+ public static final IAccessRule ALLOW_ALL_RULE = JavaCore.newAccessRule(
+ new Path("**"), IAccessRule.K_ACCESSIBLE);
private static Map<String, Collection<IClasspathEntry>> entryCache = new HashMap<String, Collection<IClasspathEntry>>();
-
- public static Collection<IClasspathEntry> findClasspathEntries( ISigilBundle bundle )
+ public static Collection<IClasspathEntry> findClasspathEntries(ISigilBundle bundle)
{
LinkedList<IClasspathEntry> cp = new LinkedList<IClasspathEntry>();
- ISigilProjectModel sp = bundle.getAncestor( ISigilProjectModel.class );
+ ISigilProjectModel sp = bundle.getAncestor(ISigilProjectModel.class);
- if ( sp != null )
+ if (sp != null)
{
IJavaProject p = sp.getJavaModel();
- for ( String enc : bundle.getClasspathEntrys() )
+ for (String enc : bundle.getClasspathEntrys())
{
- IClasspathEntry e = p.decodeClasspathEntry( enc );
- if ( e != null )
+ IClasspathEntry e = p.decodeClasspathEntry(enc);
+ if (e != null)
{
- cp.add( e );
+ cp.add(e);
}
}
}
@@ -134,25 +131,24 @@
return cp;
}
-
- public static Collection<ICompilationUnit> findCompilationUnits( ISigilProjectModel project )
- throws JavaModelException
+ public static Collection<ICompilationUnit> findCompilationUnits(
+ ISigilProjectModel project) throws JavaModelException
{
LinkedList<ICompilationUnit> ret = new LinkedList<ICompilationUnit>();
IJavaProject java = project.getJavaModel();
- for ( IClasspathEntry cp : findClasspathEntries( project.getBundle() ) )
+ for (IClasspathEntry cp : findClasspathEntries(project.getBundle()))
{
- IPackageFragmentRoot[] roots = java.findPackageFragmentRoots( cp );
- for ( IPackageFragmentRoot rt : roots )
+ IPackageFragmentRoot[] roots = java.findPackageFragmentRoots(cp);
+ for (IPackageFragmentRoot rt : roots)
{
- for ( IJavaElement j : rt.getChildren() )
+ for (IJavaElement j : rt.getChildren())
{
- IPackageFragment p = ( IPackageFragment ) j;
+ IPackageFragment p = (IPackageFragment) j;
ICompilationUnit[] units = p.getCompilationUnits();
- for ( ICompilationUnit u : units )
+ for (ICompilationUnit u : units)
{
- ret.add( u );
+ ret.add(u);
}
}
}
@@ -161,126 +157,126 @@
return ret;
}
-
/**
* @param project
* @param packageName
* @return
*/
- public static Collection<IPackageExport> findExportsForPackage( ISigilProjectModel project, final String packageName )
+ public static Collection<IPackageExport> findExportsForPackage(
+ ISigilProjectModel project, final String packageName)
{
final LinkedList<IPackageExport> results = new LinkedList<IPackageExport>();
- SigilCore.getRepositoryManager( project ).visit( new IModelWalker()
+ SigilCore.getRepositoryManager(project).visit(new IModelWalker()
{
- public boolean visit( IModelElement element )
+ public boolean visit(IModelElement element)
{
- if ( element instanceof IPackageExport )
+ if (element instanceof IPackageExport)
{
- IPackageExport e = ( IPackageExport ) element;
- if ( e.getPackageName().equals( packageName ) )
+ IPackageExport e = (IPackageExport) element;
+ if (e.getPackageName().equals(packageName))
{
- results.add( e );
+ results.add(e);
}
}
return true;
}
- } );
+ });
return results;
}
-
- public static String[] findUses( String packageName, ISigilProjectModel projectModel ) throws CoreException
+ public static String[] findUses(String packageName, ISigilProjectModel projectModel)
+ throws CoreException
{
ArrayList<String> uses = new ArrayList<String>();
- for ( final String dependency : findPackageDependencies( packageName, projectModel ) )
+ for (final String dependency : findPackageDependencies(packageName, projectModel))
{
- if ( !dependency.equals( packageName ) )
+ if (!dependency.equals(packageName))
{
final boolean[] found = new boolean[1];
- projectModel.visit( new IModelWalker()
+ projectModel.visit(new IModelWalker()
{
- public boolean visit( IModelElement element )
+ public boolean visit(IModelElement element)
{
- if ( element instanceof IPackageImport )
+ if (element instanceof IPackageImport)
{
- IPackageImport pi = ( IPackageImport ) element;
- if ( pi.getPackageName().equals( dependency ) )
+ IPackageImport pi = (IPackageImport) element;
+ if (pi.getPackageName().equals(dependency))
{
found[0] = true;
}
}
return !found[0];
}
- } );
+ });
- if ( found[0] )
+ if (found[0])
{
- uses.add( dependency );
+ uses.add(dependency);
}
}
}
- return uses.toArray( new String[uses.size()] );
+ return uses.toArray(new String[uses.size()]);
}
-
- private static String[] findPackageDependencies( String packageName, ISigilProjectModel projectModel )
- throws CoreException
+ private static String[] findPackageDependencies(String packageName,
+ ISigilProjectModel projectModel) throws CoreException
{
HashSet<String> imports = new HashSet<String>();
- IPackageFragment p = ( IPackageFragment ) projectModel.getJavaModel().findElement(
- new Path( packageName.replace( '.', '/' ) ) );
+ IPackageFragment p = (IPackageFragment) projectModel.getJavaModel().findElement(
+ new Path(packageName.replace('.', '/')));
- if ( p == null )
+ if (p == null)
{
- throw SigilCore.newCoreException( "Unknown package " + packageName, null );
+ throw SigilCore.newCoreException("Unknown package " + packageName, null);
}
- for ( ICompilationUnit cu : p.getCompilationUnits() )
+ for (ICompilationUnit cu : p.getCompilationUnits())
{
- scanImports( cu, imports );
+ scanImports(cu, imports);
}
- for ( IClassFile cf : p.getClassFiles() )
+ for (IClassFile cf : p.getClassFiles())
{
- scanImports( cf, imports );
+ scanImports(cf, imports);
}
- return imports.toArray( new String[imports.size()] );
+ return imports.toArray(new String[imports.size()]);
}
-
/**
* @param project
* @param monitor
* @return
*/
- public static List<IPackageImport> findRequiredImports( ISigilProjectModel project, IProgressMonitor monitor )
+ public static List<IPackageImport> findRequiredImports(ISigilProjectModel project,
+ IProgressMonitor monitor)
{
LinkedList<IPackageImport> imports = new LinkedList<IPackageImport>();
- for ( String packageName : findJavaImports( project, monitor ) )
+ for (String packageName : findJavaImports(project, monitor))
{
- if ( !ProfileManager.isBootDelegate( project, packageName ) )
+ if (!ProfileManager.isBootDelegate(project, packageName))
{ // these must come from boot classloader
try
{
- if ( !project.isInClasspath( packageName, monitor ) )
+ if (!project.isInClasspath(packageName, monitor))
{
- Collection<IPackageExport> exports = findExportsForPackage( project, packageName );
- if ( !exports.isEmpty() )
+ Collection<IPackageExport> exports = findExportsForPackage(
+ project, packageName);
+ if (!exports.isEmpty())
{
- imports.add( select( exports ) );
+ imports.add(select(exports));
}
}
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- SigilCore.error( "Failed to check classpath", e );
+ SigilCore.error("Failed to check classpath", e);
}
}
}
@@ -288,171 +284,175 @@
return imports;
}
-
/**
* @param project
* @param monitor
* @return
*/
- public static Collection<IModelElement> findUnusedReferences( final ISigilProjectModel project,
- final IProgressMonitor monitor )
+ public static Collection<IModelElement> findUnusedReferences(
+ final ISigilProjectModel project, final IProgressMonitor monitor)
{
final LinkedList<IModelElement> unused = new LinkedList<IModelElement>();
- final Set<String> packages = findJavaImports( project, monitor );
+ final Set<String> packages = findJavaImports(project, monitor);
- project.visit( new IModelWalker()
+ project.visit(new IModelWalker()
{
- public boolean visit( IModelElement element )
+ public boolean visit(IModelElement element)
{
- if ( element instanceof IPackageImport )
+ if (element instanceof IPackageImport)
{
- IPackageImport pi = ( IPackageImport ) element;
- if ( !packages.contains( pi.getPackageName() ) )
+ IPackageImport pi = (IPackageImport) element;
+ if (!packages.contains(pi.getPackageName()))
{
- unused.add( pi );
+ unused.add(pi);
}
}
- else if ( element instanceof IRequiredBundle )
+ else if (element instanceof IRequiredBundle)
{
- IRequiredBundle rb = ( IRequiredBundle ) element;
- IRepositoryManager manager = SigilCore.getRepositoryManager( project );
- ResolutionConfig config = new ResolutionConfig( ResolutionConfig.INCLUDE_OPTIONAL
- | ResolutionConfig.IGNORE_ERRORS );
+ IRequiredBundle rb = (IRequiredBundle) element;
+ IRepositoryManager manager = SigilCore.getRepositoryManager(project);
+ ResolutionConfig config = new ResolutionConfig(
+ ResolutionConfig.INCLUDE_OPTIONAL
+ | ResolutionConfig.IGNORE_ERRORS);
try
{
- IResolution r = manager.getBundleResolver().resolve( rb, config,
- new ResolutionMonitorAdapter( monitor ) );
- ISigilBundle bundle = r.getProvider( rb );
+ IResolution r = manager.getBundleResolver().resolve(rb, config,
+ new ResolutionMonitorAdapter(monitor));
+ ISigilBundle bundle = r.getProvider(rb);
boolean found = false;
- for ( IPackageExport pe : bundle.getBundleInfo().getExports() )
+ for (IPackageExport pe : bundle.getBundleInfo().getExports())
{
- if ( packages.contains( pe.getPackageName() ) )
+ if (packages.contains(pe.getPackageName()))
{
found = true;
break;
}
}
- if ( !found )
+ if (!found)
{
- unused.add( rb );
+ unused.add(rb);
}
}
- catch ( ResolutionException e )
+ catch (ResolutionException e)
{
- SigilCore.error( "Failed to resolve " + rb, e );
+ SigilCore.error("Failed to resolve " + rb, e);
}
}
return true;
}
- } );
+ });
return unused;
}
-
- public static Collection<IClasspathEntry> resolveClasspathEntrys( ISigilProjectModel sigil,
- IProgressMonitor monitor ) throws CoreException
+ public static Collection<IClasspathEntry> resolveClasspathEntrys(
+ ISigilProjectModel sigil, IProgressMonitor monitor) throws CoreException
{
- if ( monitor == null )
+ if (monitor == null)
{
monitor = Job.getJobManager().createProgressGroup();
- monitor.beginTask( "Resolving classpath for " + sigil.getSymbolicName(), 2 );
+ monitor.beginTask("Resolving classpath for " + sigil.getSymbolicName(), 2);
}
ArrayList<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
- ResolutionConfig config = new ResolutionConfig( ResolutionConfig.INCLUDE_OPTIONAL
- | ResolutionConfig.IGNORE_ERRORS | ResolutionConfig.INDEXED_ONLY | ResolutionConfig.LOCAL_ONLY | ResolutionConfig.COMPILE_TIME );
+ ResolutionConfig config = new ResolutionConfig(ResolutionConfig.INCLUDE_OPTIONAL
+ | ResolutionConfig.IGNORE_ERRORS | ResolutionConfig.INDEXED_ONLY
+ | ResolutionConfig.LOCAL_ONLY | ResolutionConfig.COMPILE_TIME);
IResolution resolution;
try
{
- resolution = SigilCore.getRepositoryManager( sigil ).getBundleResolver().resolve( sigil, config,
- new ResolutionMonitorAdapter( monitor ) );
+ resolution = SigilCore.getRepositoryManager(sigil).getBundleResolver().resolve(
+ sigil, config, new ResolutionMonitorAdapter(monitor));
}
- catch ( ResolutionException e )
+ catch (ResolutionException e)
{
- throw SigilCore.newCoreException( "Failed to resolve dependencies", e );
+ throw SigilCore.newCoreException("Failed to resolve dependencies", e);
}
- monitor.worked( 1 );
+ monitor.worked(1);
Set<ISigilBundle> bundles = resolution.getBundles();
- for ( ISigilBundle bundle : bundles )
+ for (ISigilBundle bundle : bundles)
{
- if ( !sigil.getSymbolicName().equals(bundle.getBundleInfo().getSymbolicName()) )
+ if (!sigil.getSymbolicName().equals(bundle.getBundleInfo().getSymbolicName()))
{ // discard self reference...
- List<IModelElement> matched = resolution.getMatchedRequirements( bundle );
- for ( IClasspathEntry cpe : buildClassPathEntry( sigil, bundle, bundles, matched, monitor ) )
+ List<IModelElement> matched = resolution.getMatchedRequirements(bundle);
+ for (IClasspathEntry cpe : buildClassPathEntry(sigil, bundle, bundles,
+ matched, monitor))
{
- entries.add( cpe );
+ entries.add(cpe);
}
}
}
- Collections.sort( entries, new Comparator<IClasspathEntry>()
+ Collections.sort(entries, new Comparator<IClasspathEntry>()
{
- public int compare( IClasspathEntry o1, IClasspathEntry o2 )
+ public int compare(IClasspathEntry o1, IClasspathEntry o2)
{
- return o1.toString().compareTo( o2.toString() );
+ return o1.toString().compareTo(o2.toString());
}
- } );
+ });
- monitor.worked( 1 );
+ monitor.worked(1);
monitor.done();
return entries;
}
-
- private static Collection<IClasspathEntry> buildClassPathEntry( ISigilProjectModel project, ISigilBundle provider,
- Set<ISigilBundle> all, List<IModelElement> requirements, IProgressMonitor monitor ) throws CoreException
+ private static Collection<IClasspathEntry> buildClassPathEntry(
+ ISigilProjectModel project, ISigilBundle provider, Set<ISigilBundle> all,
+ List<IModelElement> requirements, IProgressMonitor monitor) throws CoreException
{
- IAccessRule[] rules = buildAccessRules( project, provider, all, requirements );
+ IAccessRule[] rules = buildAccessRules(project, provider, all, requirements);
IClasspathAttribute[] attrs = new IClasspathAttribute[0];
- ISigilProjectModel other = provider.getAncestor( ISigilProjectModel.class );
+ ISigilProjectModel other = provider.getAncestor(ISigilProjectModel.class);
try
{
- if ( other == null )
+ if (other == null)
{
- provider.synchronize( monitor );
- return newBundleEntry( provider, rules, attrs, false );
+ provider.synchronize(monitor);
+ return newBundleEntry(provider, rules, attrs, false);
}
else
{
- return newProjectEntry( other, rules, attrs, false );
+ return newProjectEntry(other, rules, attrs, false);
}
}
- catch ( IOException e )
+ catch (IOException e)
{
- throw SigilCore.newCoreException( "Failed to synchronize " + provider, e );
+ throw SigilCore.newCoreException("Failed to synchronize " + provider, e);
}
}
-
- private static Collection<IClasspathEntry> newProjectEntry( ISigilProjectModel n, IAccessRule[] rules,
- IClasspathAttribute[] attributes, boolean export ) throws CoreException
+ private static Collection<IClasspathEntry> newProjectEntry(ISigilProjectModel n,
+ IAccessRule[] rules, IClasspathAttribute[] attributes, boolean export)
+ throws CoreException
{
ArrayList<IClasspathEntry> entries = new ArrayList<IClasspathEntry>();
- entries.add( JavaCore.newProjectEntry( n.getProject().getFullPath(), rules, false, attributes, export ) );
- for ( IClasspathEntry e : n.getJavaModel().getRawClasspath() )
+ entries.add(JavaCore.newProjectEntry(n.getProject().getFullPath(), rules, false,
+ attributes, export));
+ for (IClasspathEntry e : n.getJavaModel().getRawClasspath())
{
- switch ( e.getEntryKind() )
+ switch (e.getEntryKind())
{
case IClasspathEntry.CPE_LIBRARY:
- entries.add( JavaCore.newLibraryEntry( e.getPath(), e.getSourceAttachmentPath(), e
- .getSourceAttachmentRootPath(), rules, attributes, export ) );
+ entries.add(JavaCore.newLibraryEntry(e.getPath(),
+ e.getSourceAttachmentPath(), e.getSourceAttachmentRootPath(),
+ rules, attributes, export));
break;
case IClasspathEntry.CPE_VARIABLE:
- IPath path = JavaCore.getResolvedVariablePath( e.getPath() );
- if ( path != null )
+ IPath path = JavaCore.getResolvedVariablePath(e.getPath());
+ if (path != null)
{
- entries.add( JavaCore.newLibraryEntry( path, e.getSourceAttachmentPath(), e
- .getSourceAttachmentRootPath(), rules, attributes, export ) );
+ entries.add(JavaCore.newLibraryEntry(path,
+ e.getSourceAttachmentPath(), e.getSourceAttachmentRootPath(),
+ rules, attributes, export));
}
break;
}
@@ -461,13 +461,13 @@
return entries;
}
-
- private static Collection<IClasspathEntry> newBundleEntry( ISigilBundle bundle, IAccessRule[] rules,
- IClasspathAttribute[] attributes, boolean exported ) throws CoreException
+ private static Collection<IClasspathEntry> newBundleEntry(ISigilBundle bundle,
+ IAccessRule[] rules, IClasspathAttribute[] attributes, boolean exported)
+ throws CoreException
{
String name = bundle.getBundleInfo().getSymbolicName();
- if ( bundle.getBundleInfo().getVersion() != null )
+ if (bundle.getBundleInfo().getVersion() != null)
{
name += "_version_" + bundle.getBundleInfo().getVersion();
}
@@ -476,148 +476,150 @@
Collection<IClasspathEntry> entries = null;
- synchronized ( entryCache )
+ synchronized (entryCache)
{
- entries = entryCache.get( cacheName );
+ entries = entryCache.get(cacheName);
- if ( entries == null )
+ if (entries == null)
{
IPath path = PathUtil.newPathIfExists(bundle.getLocation());
- if ( path == null )
+ if (path == null)
{
- SigilCore.error( "Found null path for " + bundle.getSymbolicName() );
+ SigilCore.error("Found null path for " + bundle.getSymbolicName());
entries = Collections.emptyList();
}
else
{
- entries = buildEntries( path, name, bundle, rules, attributes, exported );
+ entries = buildEntries(path, name, bundle, rules, attributes,
+ exported);
}
- entryCache.put( cacheName, entries );
+ entryCache.put(cacheName, entries);
}
}
return entries;
}
- private static IPath bundleCache = SigilCore.getDefault().getStateLocation().append( "bundle-cache" );
+ private static IPath bundleCache = SigilCore.getDefault().getStateLocation().append(
+ "bundle-cache");
-
- public static boolean isCachedBundle( String bp )
+ public static boolean isCachedBundle(String bp)
{
- return bp.startsWith( bundleCache.toOSString() );
+ return bp.startsWith(bundleCache.toOSString());
}
-
- private static Collection<IClasspathEntry> buildEntries( IPath path, String name, ISigilBundle bundle,
- IAccessRule[] rules, IClasspathAttribute[] attributes, boolean exported ) throws CoreException
+ private static Collection<IClasspathEntry> buildEntries(IPath path, String name,
+ ISigilBundle bundle, IAccessRule[] rules, IClasspathAttribute[] attributes,
+ boolean exported) throws CoreException
{
- if ( path.toFile().isDirectory() )
+ if (path.toFile().isDirectory())
{
- throw SigilCore.newCoreException( "Bundle location cannot be a directory", null );
+ throw SigilCore.newCoreException("Bundle location cannot be a directory",
+ null);
}
else
{
// ok it's a jar could contain libs etc
try
{
- IPath cache = bundleCache.append( name );
+ IPath cache = bundleCache.append(name);
Collection<String> classpath = bundle.getBundleInfo().getClasspaths();
- ArrayList<IClasspathEntry> entries = new ArrayList<IClasspathEntry>( classpath.size() );
+ ArrayList<IClasspathEntry> entries = new ArrayList<IClasspathEntry>(
+ classpath.size());
IPath source = PathUtil.newPathIfExists(bundle.getSourcePathLocation());
IPath rootPath = PathUtil.newPathIfNotNull(bundle.getSourceRootPath());
- if ( source != null && !source.toFile().exists() )
+ if (source != null && !source.toFile().exists())
{
source = null;
}
- if ( !classpath.isEmpty() )
+ if (!classpath.isEmpty())
{
- unpack( cache, bundle, classpath );
- for ( String cp : classpath )
+ unpack(cache, bundle, classpath);
+ for (String cp : classpath)
{
- IPath p = ".".equals( cp ) ? path : cache.append( cp );
- if ( p.toFile().exists() )
+ IPath p = ".".equals(cp) ? path : cache.append(cp);
+ if (p.toFile().exists())
{
- IClasspathEntry e = JavaCore.newLibraryEntry( p, source, rootPath, rules,
- attributes, exported );
- entries.add( e );
+ IClasspathEntry e = JavaCore.newLibraryEntry(p, source,
+ rootPath, rules, attributes, exported);
+ entries.add(e);
}
}
}
else
{ // default classpath is .
- IClasspathEntry e = JavaCore.newLibraryEntry( path, source, rootPath, rules,
- attributes, exported );
- entries.add( e );
+ IClasspathEntry e = JavaCore.newLibraryEntry(path, source, rootPath,
+ rules, attributes, exported);
+ entries.add(e);
}
return entries;
}
- catch ( IOException e )
+ catch (IOException e)
{
- throw SigilCore.newCoreException( "Failed to unpack bundle", e );
+ throw SigilCore.newCoreException("Failed to unpack bundle", e);
}
}
}
private static HashMap<IPath, Collection<String>> unpacked = new HashMap<IPath, Collection<String>>();
-
- private static synchronized void unpack( IPath cache, ISigilBundle bundle, Collection<String> classpath )
- throws IOException
+ private static synchronized void unpack(IPath cache, ISigilBundle bundle,
+ Collection<String> classpath) throws IOException
{
- Collection<String> check = unpacked.get( cache );
+ Collection<String> check = unpacked.get(cache);
- if ( check == null || !check.equals( classpath ) )
+ if (check == null || !check.equals(classpath))
{
- if ( classpath.size() == 1 && classpath.contains( "." ) )
+ if (classpath.size() == 1 && classpath.contains("."))
{
- unpacked.put( cache, classpath );
+ unpacked.put(cache, classpath);
}
else
{
// trim . from path to avoid check later in inClasspath
- check = new HashSet<String>( classpath );
- check.remove( "." );
+ check = new HashSet<String>(classpath);
+ check.remove(".");
- File dir = createEmptyDir( cache );
+ File dir = createEmptyDir(cache);
FileInputStream fin = null;
try
{
- fin = new FileInputStream( bundle.getLocation() );
- JarInputStream in = new JarInputStream( fin );
+ fin = new FileInputStream(bundle.getLocation());
+ JarInputStream in = new JarInputStream(fin);
JarEntry entry;
- while ( ( entry = in.getNextJarEntry() ) != null )
+ while ((entry = in.getNextJarEntry()) != null)
{
- if ( inClasspath( check, entry ) )
+ if (inClasspath(check, entry))
{
- File f = new File( dir, entry.getName() );
- if ( entry.isDirectory() )
+ File f = new File(dir, entry.getName());
+ if (entry.isDirectory())
{
- createDir( f );
+ createDir(f);
}
else
{
try
{
File p = f.getParentFile();
- createDir( p );
- streamTo( in, f );
+ createDir(p);
+ streamTo(in, f);
}
- catch ( RuntimeException e )
+ catch (RuntimeException e)
{
- SigilCore.error( "Failed to unpack " + entry, e );
+ SigilCore.error("Failed to unpack " + entry, e);
}
}
}
}
- unpacked.put( cache, classpath );
+ unpacked.put(cache, classpath);
}
finally
{
- if ( fin != null )
+ if (fin != null)
{
fin.close();
}
@@ -626,17 +628,16 @@
}
}
-
/**
* @param classpath
* @param entry
* @return
*/
- private static boolean inClasspath( Collection<String> classpath, JarEntry entry )
+ private static boolean inClasspath(Collection<String> classpath, JarEntry entry)
{
- for ( String s : classpath )
+ for (String s : classpath)
{
- if ( entry.getName().startsWith( s ) )
+ if (entry.getName().startsWith(s))
{
return true;
}
@@ -644,31 +645,29 @@
return false;
}
-
- private static void createDir( File p ) throws IOException
+ private static void createDir(File p) throws IOException
{
- if ( !p.exists() )
+ if (!p.exists())
{
- if ( !p.mkdirs() )
- throw new IOException( "Failed to create directory " + p );
+ if (!p.mkdirs())
+ throw new IOException("Failed to create directory " + p);
}
}
-
- private static void streamTo( InputStream in, File f ) throws IOException
+ private static void streamTo(InputStream in, File f) throws IOException
{
- FileOutputStream fos = new FileOutputStream( f );
+ FileOutputStream fos = new FileOutputStream(f);
try
{
byte[] buf = new byte[1024];
- for ( ;; )
+ for (;;)
{
- int r = in.read( buf );
+ int r = in.read(buf);
- if ( r == -1 )
+ if (r == -1)
break;
- fos.write( buf, 0, r );
+ fos.write(buf, 0, r);
}
fos.flush();
@@ -679,101 +678,98 @@
{
fos.close();
}
- catch ( IOException e )
+ catch (IOException e)
{
- SigilCore.error( "Failed to close stream", e );
+ SigilCore.error("Failed to close stream", e);
}
}
}
-
- private static File createEmptyDir( IPath cache )
+ private static File createEmptyDir(IPath cache)
{
File dir = cache.toFile();
- if ( dir.exists() )
+ if (dir.exists())
{
- deleteAll( dir );
+ deleteAll(dir);
}
dir.mkdirs();
return dir;
}
-
- private static void deleteAll( File file )
+ private static void deleteAll(File file)
{
File[] sub = file.listFiles();
- if ( sub != null )
+ if (sub != null)
{
- for ( File f : sub )
+ for (File f : sub)
{
- deleteAll( f );
+ deleteAll(f);
}
}
file.delete();
}
-
- private static IAccessRule[] buildAccessRules( ISigilProjectModel project, ISigilBundle bundle,
- Set<ISigilBundle> all, List<IModelElement> requirements ) throws JavaModelException
+ private static IAccessRule[] buildAccessRules(ISigilProjectModel project,
+ ISigilBundle bundle, Set<ISigilBundle> all, List<IModelElement> requirements)
+ throws JavaModelException
{
ArrayList<IAccessRule> rules = new ArrayList<IAccessRule>();
- for ( IModelElement e : requirements )
+ for (IModelElement e : requirements)
{
- if ( e instanceof IRequiredBundle )
+ if (e instanceof IRequiredBundle)
{
IRequiredBundle host = project.getBundle().getBundleInfo().getFragmentHost();
- if ( host != null )
+ if (host != null)
{
- if ( host.equals( e ) )
+ if (host.equals(e))
{
- return new IAccessRule[]
- { ALLOW_ALL_RULE };
+ return new IAccessRule[] { ALLOW_ALL_RULE };
}
else
{
- return buildExportRules( bundle, all, requirements );
+ return buildExportRules(bundle, all, requirements);
}
}
else
{
- return buildExportRules( bundle, all, requirements );
+ return buildExportRules(bundle, all, requirements);
}
}
- else if ( e instanceof IPackageImport )
+ else if (e instanceof IPackageImport)
{
- IPackageImport pi = ( IPackageImport ) e;
+ IPackageImport pi = (IPackageImport) e;
String pckg = pi.getPackageName();
HashSet<String> pckgs = new HashSet<String>();
- pckgs.add( pckg );
+ pckgs.add(pckg);
//findIndirectReferences(pckgs, pckg, project.getJavaModel(), project.getJavaModel());
- for ( String p : pckgs )
+ for (String p : pckgs)
{
- rules.add( newPackageAccess( p ) );
+ rules.add(newPackageAccess(p));
}
}
}
- rules.add( DENY_RULE );
+ rules.add(DENY_RULE);
- return rules.toArray( new IAccessRule[rules.size()] );
+ return rules.toArray(new IAccessRule[rules.size()]);
}
-
- private static IAccessRule[] buildExportRules( ISigilBundle bundle, Set<ISigilBundle> all,
- List<IModelElement> requirements )
+
+ private static IAccessRule[] buildExportRules(ISigilBundle bundle,
+ Set<ISigilBundle> all, List<IModelElement> requirements)
{
- Set<IPackageExport> ex = mergeExports( bundle, all, requirements );
+ Set<IPackageExport> ex = mergeExports(bundle, all, requirements);
IAccessRule[] rules = new IAccessRule[ex.size() + 1];
Iterator<IPackageExport> iter = ex.iterator();
- for ( int i = 0; i < rules.length - 1; i++ )
+ for (int i = 0; i < rules.length - 1; i++)
{
IPackageExport p = iter.next();
- rules[i] = JavaCore.newAccessRule( new Path( p.getPackageName().replace( '.', '/' ) ).append( "*" ),
- IAccessRule.K_ACCESSIBLE );
+ rules[i] = JavaCore.newAccessRule(new Path(p.getPackageName().replace('.',
+ '/')).append("*"), IAccessRule.K_ACCESSIBLE);
}
rules[rules.length - 1] = DENY_RULE;
@@ -781,224 +777,218 @@
return rules;
}
-
- private static Set<IPackageExport> mergeExports( ISigilBundle bundle, Set<ISigilBundle> all,
- List<IModelElement> requirements )
+ private static Set<IPackageExport> mergeExports(ISigilBundle bundle,
+ Set<ISigilBundle> all, List<IModelElement> requirements)
{
IBundleModelElement headers = bundle.getBundleInfo();
// FIXME treeset as PackageExport does not implement equals/hashCode
- TreeSet<IPackageExport> exports = new TreeSet<IPackageExport>( headers.getExports() );
+ TreeSet<IPackageExport> exports = new TreeSet<IPackageExport>(
+ headers.getExports());
IRequiredBundle host = headers.getFragmentHost();
- if ( host != null )
+ if (host != null)
{
- for ( ISigilBundle b : all )
+ for (ISigilBundle b : all)
{
- if ( host.accepts( b.getBundleCapability() ) )
+ if (host.accepts(b.getBundleCapability()))
{
- exports.addAll( b.getBundleInfo().getExports() );
+ exports.addAll(b.getBundleInfo().getExports());
break;
}
}
}
return exports;
- }
-
+ }
/*
* Searches for C (and D, E, etc) in case:
* A extends B extends C where A, B and C are in different packages and A is in this bundle
* and B and C are in one or more external bundles
*/
- private static void findIndirectReferences( Set<String> indirect, String pckg, IParent parent, IJavaProject p )
- throws JavaModelException
+ private static void findIndirectReferences(Set<String> indirect, String pckg,
+ IParent parent, IJavaProject p) throws JavaModelException
{
- for ( IJavaElement e : parent.getChildren() )
+ for (IJavaElement e : parent.getChildren())
{
boolean skip = false;
- switch ( e.getElementType() )
+ switch (e.getElementType())
{
case IJavaElement.PACKAGE_FRAGMENT_ROOT:
- IPackageFragmentRoot rt = ( IPackageFragmentRoot ) e;
+ IPackageFragmentRoot rt = (IPackageFragmentRoot) e;
IClasspathEntry ce = rt.getRawClasspathEntry();
IPath path = ce.getPath();
- skip = "org.eclipse.jdt.launching.JRE_CONTAINER".equals( path.toString() );
+ skip = "org.eclipse.jdt.launching.JRE_CONTAINER".equals(path.toString());
break;
case IJavaElement.CLASS_FILE:
- IClassFile cf = ( IClassFile ) e;
- if ( cf.getElementName().startsWith( pckg ) )
+ IClassFile cf = (IClassFile) e;
+ if (cf.getElementName().startsWith(pckg))
{
- findIndirectReferences( indirect, findPackage( cf.getType().getSuperclassName() ), p, p );
+ findIndirectReferences(indirect,
+ findPackage(cf.getType().getSuperclassName()), p, p);
}
break;
case IJavaElement.COMPILATION_UNIT:
- ICompilationUnit cu = ( ICompilationUnit ) e;
+ ICompilationUnit cu = (ICompilationUnit) e;
break;
}
- if ( !skip && e instanceof IParent )
+ if (!skip && e instanceof IParent)
{
- IParent newParent = ( IParent ) e;
- findIndirectReferences( indirect, pckg, newParent, p );
+ IParent newParent = (IParent) e;
+ findIndirectReferences(indirect, pckg, newParent, p);
}
}
}
-
- private static IAccessRule newPackageAccess( String packageName )
+ private static IAccessRule newPackageAccess(String packageName)
{
- return JavaCore.newAccessRule( new Path( packageName.replace( '.', '/' ) ).append( "*" ),
- IAccessRule.K_ACCESSIBLE );
+ return JavaCore.newAccessRule(
+ new Path(packageName.replace('.', '/')).append("*"), IAccessRule.K_ACCESSIBLE);
}
-
- private static Set<String> findJavaImports( ISigilProjectModel project, IProgressMonitor monitor )
+ private static Set<String> findJavaImports(ISigilProjectModel project,
+ IProgressMonitor monitor)
{
Set<String> imports = new HashSet<String>();
- findJavaModelImports( project, imports, monitor );
- findTextImports( project, imports, monitor );
+ findJavaModelImports(project, imports, monitor);
+ findTextImports(project, imports, monitor);
return imports;
}
-
- private static void findTextImports( ISigilProjectModel project, Set<String> imports, IProgressMonitor monitor )
+ private static void findTextImports(ISigilProjectModel project, Set<String> imports,
+ IProgressMonitor monitor)
{
IContentTypeManager contentTypeManager = Platform.getContentTypeManager();
- IContentType txt = contentTypeManager.getContentType( "org.eclipse.core.runtime.text" );
- for ( Resource p : project.getBundle().getSourcePaths() )
+ IContentType txt = contentTypeManager.getContentType("org.eclipse.core.runtime.text");
+ for (Resource p : project.getBundle().getSourcePaths())
{
- IFile f = project.getProject().getFile( p.getLocalFile() );
- if ( f.exists() )
+ IFile f = project.getProject().getFile(p.getLocalFile());
+ if (f.exists())
{
try
{
IContentDescription desc = f.getContentDescription();
- if ( desc != null )
+ if (desc != null)
{
IContentType type = desc.getContentType();
- if ( type != null )
+ if (type != null)
{
- if ( type.isKindOf( txt ) )
+ if (type.isKindOf(txt))
{
- parseText( f, imports );
+ parseText(f, imports);
}
}
}
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- SigilCore.error( "Failed to parse text file " + f, e );
+ SigilCore.error("Failed to parse text file " + f, e);
}
}
}
}
-
- private static void findJavaModelImports( ISigilProjectModel project, Set<String> imports, IProgressMonitor monitor )
+ private static void findJavaModelImports(ISigilProjectModel project,
+ Set<String> imports, IProgressMonitor monitor)
{
try
{
- for ( IPackageFragment root : project.getJavaModel().getPackageFragments() )
+ for (IPackageFragment root : project.getJavaModel().getPackageFragments())
{
- IPackageFragmentRoot rt = ( IPackageFragmentRoot ) root
- .getAncestor( IJavaElement.PACKAGE_FRAGMENT_ROOT );
+ IPackageFragmentRoot rt = (IPackageFragmentRoot) root.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
- if ( isInClassPath( project, rt ) )
+ if (isInClassPath(project, rt))
{
- for ( ICompilationUnit cu : root.getCompilationUnits() )
+ for (ICompilationUnit cu : root.getCompilationUnits())
{
- scanImports( cu, imports );
+ scanImports(cu, imports);
}
- for ( IClassFile cf : root.getClassFiles() )
+ for (IClassFile cf : root.getClassFiles())
{
- scanImports( cf, imports );
+ scanImports(cf, imports);
}
}
}
}
- catch ( JavaModelException e )
+ catch (JavaModelException e)
{
- SigilCore.error( "Failed to parse java model", e );
+ SigilCore.error("Failed to parse java model", e);
}
}
// matches word.word.word.word.Word
- private static final Pattern JAVA_CLASS_PATTERN = Pattern.compile( "((\\w*\\.\\w*)+?)\\.[A-Z]\\w*" );
+ private static final Pattern JAVA_CLASS_PATTERN = Pattern.compile("((\\w*\\.\\w*)+?)\\.[A-Z]\\w*");
-
- private static void parseText( IFile f, Set<String> imports ) throws CoreException
+ private static void parseText(IFile f, Set<String> imports) throws CoreException
{
- for ( String result : Grep.grep( JAVA_CLASS_PATTERN, f ) )
+ for (String result : Grep.grep(JAVA_CLASS_PATTERN, f))
{
- findImport( result, imports );
+ findImport(result, imports);
}
}
+ private static boolean isInClassPath(ISigilProjectModel project,
+ IPackageFragmentRoot rt) throws JavaModelException
+ {
+ String path = encode(project, rt.getRawClasspathEntry());
+ return project.getBundle().getClasspathEntrys().contains(path);
+ }
- private static boolean isInClassPath( ISigilProjectModel project, IPackageFragmentRoot rt )
+ private static String encode(ISigilProjectModel project, IClasspathEntry cp)
+ {
+ return project.getJavaModel().encodeClasspathEntry(cp).trim();
+ }
+
+ private static void scanImports(IParent parent, Set<String> imports)
throws JavaModelException
{
- String path = encode( project, rt.getRawClasspathEntry() );
- return project.getBundle().getClasspathEntrys().contains( path );
- }
-
-
- private static String encode( ISigilProjectModel project, IClasspathEntry cp )
- {
- return project.getJavaModel().encodeClasspathEntry( cp ).trim();
- }
-
-
- private static void scanImports( IParent parent, Set<String> imports ) throws JavaModelException
- {
- for ( IJavaElement e : parent.getChildren() )
+ for (IJavaElement e : parent.getChildren())
{
- switch ( e.getElementType() )
+ switch (e.getElementType())
{
case IJavaElement.TYPE:
- handleType( ( IType ) e, imports );
+ handleType((IType) e, imports);
break;
case IJavaElement.IMPORT_DECLARATION:
- handleImport( ( IImportDeclaration ) e, imports );
+ handleImport((IImportDeclaration) e, imports);
break;
case IJavaElement.FIELD:
- handleField( ( IField ) e, imports );
+ handleField((IField) e, imports);
break;
case IJavaElement.LOCAL_VARIABLE:
- handleLocalVariable( ( ILocalVariable ) e, imports );
+ handleLocalVariable((ILocalVariable) e, imports);
break;
case IJavaElement.ANNOTATION:
- handleAnnotation( ( IAnnotation ) e, imports );
+ handleAnnotation((IAnnotation) e, imports);
break;
case IJavaElement.METHOD:
- handleMethod( ( IMethod ) e, imports );
+ handleMethod((IMethod) e, imports);
break;
default:
// no action
break;
}
- if ( e instanceof IParent )
+ if (e instanceof IParent)
{
- scanImports( ( IParent ) e, imports );
+ scanImports((IParent) e, imports);
}
}
}
-
- private static void handleType( IType e, Set<String> imports ) throws JavaModelException
+ private static void handleType(IType e, Set<String> imports)
+ throws JavaModelException
{
- findImportFromType( e.getSuperclassTypeSignature(), imports );
- for ( String sig : e.getSuperInterfaceTypeSignatures() )
+ findImportFromType(e.getSuperclassTypeSignature(), imports);
+ for (String sig : e.getSuperInterfaceTypeSignatures())
{
- findImportFromType( sig, imports );
+ findImportFromType(sig, imports);
}
//findImportsForSuperTypes(e, imports);
}
-
/*private static void findImportsForSuperTypes(IType e, Set<String> imports) throws JavaModelException {
IJavaProject project = (IJavaProject) e.getAncestor(IJavaModel.JAVA_PROJECT);
LinkedList<String> types = new LinkedList<String>();
@@ -1026,125 +1016,114 @@
}
} */
- private static void handleMethod( IMethod e, Set<String> imports ) throws JavaModelException
+ private static void handleMethod(IMethod e, Set<String> imports)
+ throws JavaModelException
{
- findImportFromType( e.getReturnType(), imports );
+ findImportFromType(e.getReturnType(), imports);
- for ( String param : e.getParameterTypes() )
+ for (String param : e.getParameterTypes())
{
- findImportFromType( param, imports );
+ findImportFromType(param, imports);
}
- for ( String ex : e.getExceptionTypes() )
+ for (String ex : e.getExceptionTypes())
{
- findImportFromType( ex, imports );
+ findImportFromType(ex, imports);
}
}
-
- private static void handleAnnotation( IAnnotation e, Set<String> imports )
+ private static void handleAnnotation(IAnnotation e, Set<String> imports)
{
- findImport( e.getElementName(), imports );
+ findImport(e.getElementName(), imports);
}
-
- private static void handleLocalVariable( ILocalVariable e, Set<String> imports )
+ private static void handleLocalVariable(ILocalVariable e, Set<String> imports)
{
- findImportFromType( e.getTypeSignature(), imports );
+ findImportFromType(e.getTypeSignature(), imports);
}
-
- private static void handleField( IField e, Set<String> imports ) throws IllegalArgumentException,
- JavaModelException
+ private static void handleField(IField e, Set<String> imports)
+ throws IllegalArgumentException, JavaModelException
{
- findImportFromType( Signature.getElementType( e.getTypeSignature() ), imports );
+ findImportFromType(Signature.getElementType(e.getTypeSignature()), imports);
}
-
- private static void handleImport( IImportDeclaration id, Set<String> imports )
+ private static void handleImport(IImportDeclaration id, Set<String> imports)
{
- findImport( id.getElementName(), imports );
+ findImport(id.getElementName(), imports);
}
-
- private static void findImportFromType( String type, Set<String> imports )
+ private static void findImportFromType(String type, Set<String> imports)
{
- String element = decodeSignature( type );
- findImport( element, imports );
+ String element = decodeSignature(type);
+ findImport(element, imports);
}
-
- private static String decodeSignature( String type )
+ private static String decodeSignature(String type)
{
- return decodeSignature( type, false );
+ return decodeSignature(type, false);
}
-
- private static String decodeSignature( String type, boolean resolve )
+ private static String decodeSignature(String type, boolean resolve)
{
- if ( type == null )
+ if (type == null)
{
return null;
}
- if ( type.length() > 0 )
+ if (type.length() > 0)
{
- switch ( type.charAt( 0 ) )
+ switch (type.charAt(0))
{
case Signature.C_ARRAY:
- return decodeSignature( type.substring( 1 ) );
+ return decodeSignature(type.substring(1));
case Signature.C_UNRESOLVED:
- return resolve ? resolve( type.substring( 1, type.length() - 1 ) ) : null;
+ return resolve ? resolve(type.substring(1, type.length() - 1)) : null;
case Signature.C_RESOLVED:
- return type.substring( 1 );
+ return type.substring(1);
}
}
return type;
}
-
- private static String resolve( String substring )
+ private static String resolve(String substring)
{
// TODO Auto-generated method stub
return null;
}
-
- private static void findImport( String clazz, Set<String> imports )
+ private static void findImport(String clazz, Set<String> imports)
{
- String packageName = findPackage( clazz );
- if ( packageName != null )
+ String packageName = findPackage(clazz);
+ if (packageName != null)
{
- imports.add( packageName );
+ imports.add(packageName);
}
}
-
- private static String findPackage( String clazz )
+ private static String findPackage(String clazz)
{
- if ( clazz == null )
+ if (clazz == null)
return null;
- int pos = clazz.lastIndexOf( '.' );
- return pos == -1 ? null : clazz.substring( 0, pos );
+ int pos = clazz.lastIndexOf('.');
+ return pos == -1 ? null : clazz.substring(0, pos);
}
-
- private static String findClass( String clazz )
+ private static String findClass(String clazz)
{
- if ( clazz == null )
+ if (clazz == null)
return null;
- int pos = clazz.lastIndexOf( '.' );
- return pos == -1 ? null : clazz.substring( pos + 1 );
+ int pos = clazz.lastIndexOf('.');
+ return pos == -1 ? null : clazz.substring(pos + 1);
}
-
- private static IPackageImport select( Collection<IPackageExport> proposals )
+ private static IPackageImport select(Collection<IPackageExport> proposals)
{
IPackageExport pe = null;
- for ( IPackageExport check : proposals )
+ for (IPackageExport check : proposals)
{
- if ( pe == null || check.getVersion().compareTo( pe.getVersion() ) > 0 )
+ if (pe == null || check.getVersion().compareTo(pe.getVersion()) > 0)
{
pe = check;
}
@@ -1155,56 +1134,55 @@
Version version = pe.getVersion();
VersionRange versions = ModelHelper.getDefaultRange(version);
- IPackageImport pi = ModelElementFactory.getInstance().newModelElement( IPackageImport.class );
- pi.setPackageName( packageName );
- pi.setVersions( versions );
+ IPackageImport pi = ModelElementFactory.getInstance().newModelElement(
+ IPackageImport.class);
+ pi.setPackageName(packageName);
+ pi.setVersions(versions);
return pi;
}
-
- public static Iterable<IJavaElement> findTypes( IParent parent, int... type ) throws JavaModelException
+ public static Iterable<IJavaElement> findTypes(IParent parent, int... type)
+ throws JavaModelException
{
LinkedList<IJavaElement> found = new LinkedList<IJavaElement>();
- scanForElement( parent, type, found, false );
+ scanForElement(parent, type, found, false);
return found;
}
-
- public static IJavaElement findType( IParent parent, int... type ) throws JavaModelException
+ public static IJavaElement findType(IParent parent, int... type)
+ throws JavaModelException
{
LinkedList<IJavaElement> found = new LinkedList<IJavaElement>();
- scanForElement( parent, type, found, true );
+ scanForElement(parent, type, found, true);
return found.isEmpty() ? null : found.getFirst();
}
-
- private static void scanForElement( IParent parent, int[] type, List<IJavaElement> roots, boolean thereCanBeOnlyOne )
- throws JavaModelException
+ private static void scanForElement(IParent parent, int[] type,
+ List<IJavaElement> roots, boolean thereCanBeOnlyOne) throws JavaModelException
{
- for ( IJavaElement e : parent.getChildren() )
+ for (IJavaElement e : parent.getChildren())
{
- if ( isType( type, e ) )
+ if (isType(type, e))
{
- roots.add( e );
- if ( thereCanBeOnlyOne )
+ roots.add(e);
+ if (thereCanBeOnlyOne)
{
break;
}
}
- else if ( e instanceof IParent )
+ else if (e instanceof IParent)
{
- scanForElement( ( IParent ) e, type, roots, thereCanBeOnlyOne );
+ scanForElement((IParent) e, type, roots, thereCanBeOnlyOne);
}
}
}
-
- private static boolean isType( int[] type, IJavaElement e )
+ private static boolean isType(int[] type, IJavaElement e)
{
- for ( int i : type )
+ for (int i : type)
{
- if ( i == e.getElementType() )
+ if (i == e.getElementType())
{
return true;
}
@@ -1212,26 +1190,26 @@
return false;
}
-
- public static boolean isAssignableTo( String ifaceOrParentClass, IType type ) throws JavaModelException
+ public static boolean isAssignableTo(String ifaceOrParentClass, IType type)
+ throws JavaModelException
{
- if ( ifaceOrParentClass == null )
+ if (ifaceOrParentClass == null)
return true;
- ITypeHierarchy h = type.newSupertypeHierarchy( null );
+ ITypeHierarchy h = type.newSupertypeHierarchy(null);
- for ( IType superType : h.getAllClasses() )
+ for (IType superType : h.getAllClasses())
{
String name = superType.getFullyQualifiedName();
- if ( name.equals( ifaceOrParentClass ) )
+ if (name.equals(ifaceOrParentClass))
{
return true;
}
}
- for ( IType ifaceType : h.getAllInterfaces() )
+ for (IType ifaceType : h.getAllInterfaces())
{
String name = ifaceType.getFullyQualifiedName();
- if ( name.equals( ifaceOrParentClass ) )
+ if (name.equals(ifaceOrParentClass))
{
return true;
}
@@ -1240,61 +1218,62 @@
return false;
}
-
- private static IType findType( ITypeRoot root ) throws JavaModelException
+ private static IType findType(ITypeRoot root) throws JavaModelException
{
// TODO Auto-generated method stub
- for ( IJavaElement child : root.getChildren() )
+ for (IJavaElement child : root.getChildren())
{
- if ( child.getElementType() == IJavaElement.TYPE )
+ if (child.getElementType() == IJavaElement.TYPE)
{
- return ( IType ) child;
+ return (IType) child;
}
}
- throw new JavaModelException( new IllegalStateException( "Missing type for " + root ), IStatus.ERROR );
+ throw new JavaModelException(
+ new IllegalStateException("Missing type for " + root), IStatus.ERROR);
}
-
- public static Set<String> findLocalPackageDependencies(
- ISigilProjectModel project, String packageName, IProgressMonitor monitor) throws JavaModelException
+ public static Set<String> findLocalPackageDependencies(ISigilProjectModel project,
+ String packageName, IProgressMonitor monitor) throws JavaModelException
{
- Set<String> imports = findJavaImports( project, monitor );
+ Set<String> imports = findJavaImports(project, monitor);
imports.remove(packageName);
return imports;
}
-
- public static Set<String> findLocalPackageUsers(
- ISigilProjectModel project, String packageName, IProgressMonitor monitor) throws JavaModelException
+ public static Set<String> findLocalPackageUsers(ISigilProjectModel project,
+ String packageName, IProgressMonitor monitor) throws JavaModelException
{
Set<String> imports = new HashSet<String>();
Set<String> check = new HashSet<String>();
- for ( IPackageFragment root : project.getJavaModel().getPackageFragments() )
+ for (IPackageFragment root : project.getJavaModel().getPackageFragments())
{
- IPackageFragmentRoot rt = ( IPackageFragmentRoot ) root
- .getAncestor( IJavaElement.PACKAGE_FRAGMENT_ROOT );
+ IPackageFragmentRoot rt = (IPackageFragmentRoot) root.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
- if ( isInClassPath( project, rt ) )
+ if (isInClassPath(project, rt))
{
- for ( ICompilationUnit cu : root.getCompilationUnits() )
+ for (ICompilationUnit cu : root.getCompilationUnits())
{
IPackageFragment pack = (IPackageFragment) cu.getAncestor(IJavaModel.PACKAGE_FRAGMENT);
- if ( !pack.getElementName().equals(packageName)) {
- scanImports( cu, check );
- if (check.contains(packageName)) {
+ if (!pack.getElementName().equals(packageName))
+ {
+ scanImports(cu, check);
+ if (check.contains(packageName))
+ {
imports.add(pack.getElementName());
}
}
check.clear();
}
- for ( IClassFile cf : root.getClassFiles() )
+ for (IClassFile cf : root.getClassFiles())
{
IPackageFragment pack = (IPackageFragment) cf.getAncestor(IJavaModel.PACKAGE_FRAGMENT);
- if ( !pack.getElementName().equals(packageName)) {
- scanImports( cf, check );
- if (check.contains(packageName)) {
+ if (!pack.getElementName().equals(packageName))
+ {
+ scanImports(cf, check);
+ if (check.contains(packageName))
+ {
imports.add(pack.getElementName());
}
}
@@ -1302,7 +1281,7 @@
}
}
}
-
+
return imports;
}
}
\ No newline at end of file
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/ModelHelper.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/ModelHelper.java
index 67ffd43..5a4ca70 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/ModelHelper.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/ModelHelper.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.model.util;
-
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
@@ -39,75 +38,77 @@
import org.eclipse.jface.preference.IPreferenceStore;
import org.osgi.framework.Version;
-
public class ModelHelper
{
- public static List<IModelElement> findUsers( IModelElement e )
+ public static List<IModelElement> findUsers(IModelElement e)
{
LinkedList<IModelElement> users = new LinkedList<IModelElement>();
- findUsers( e, users );
+ findUsers(e, users);
return users;
}
-
- private static void findUsers( IModelElement e, final LinkedList<IModelElement> users )
+ private static void findUsers(IModelElement e, final LinkedList<IModelElement> users)
{
- if ( e instanceof ICapabilityModelElement )
+ if (e instanceof ICapabilityModelElement)
{
- final ICapabilityModelElement cap = ( ICapabilityModelElement ) e;
- SigilCore.getGlobalRepositoryManager().visit( new IModelWalker()
+ final ICapabilityModelElement cap = (ICapabilityModelElement) e;
+ SigilCore.getGlobalRepositoryManager().visit(new IModelWalker()
{
- public boolean visit( IModelElement element )
+ public boolean visit(IModelElement element)
{
- if ( element instanceof IRequirementModelElement )
+ if (element instanceof IRequirementModelElement)
{
- IRequirementModelElement req = ( IRequirementModelElement ) element;
- if ( req.accepts( cap ) )
+ IRequirementModelElement req = (IRequirementModelElement) element;
+ if (req.accepts(cap))
{
- users.add( req );
+ users.add(req);
}
return false;
}
return true;
}
- } );
+ });
}
-
- if ( e instanceof ICompoundModelElement )
+
+ if (e instanceof ICompoundModelElement)
{
- ICompoundModelElement c = ( ICompoundModelElement ) e;
+ ICompoundModelElement c = (ICompoundModelElement) e;
IModelElement[] ch = c.children();
- for ( IModelElement ee : ch )
+ for (IModelElement ee : ch)
{
- findUsers( ee, users );
+ findUsers(ee, users);
}
}
}
-
- public static VersionRange getDefaultRange(Version version) {
- IPreferenceStore store = SigilCore.getDefault().getPreferenceStore();
-
- VersionRangeBoundingRule lowerBoundRule = VersionRangeBoundingRule.valueOf( store
- .getString( SigilCore.DEFAULT_VERSION_LOWER_BOUND ) );
- VersionRangeBoundingRule upperBoundRule = VersionRangeBoundingRule.valueOf( store
- .getString( SigilCore.DEFAULT_VERSION_UPPER_BOUND ) );
- VersionRange selectedVersions = VersionRange.newInstance( version, lowerBoundRule, upperBoundRule );
+ public static VersionRange getDefaultRange(Version version)
+ {
+ IPreferenceStore store = SigilCore.getDefault().getPreferenceStore();
+
+ VersionRangeBoundingRule lowerBoundRule = VersionRangeBoundingRule.valueOf(store.getString(SigilCore.DEFAULT_VERSION_LOWER_BOUND));
+ VersionRangeBoundingRule upperBoundRule = VersionRangeBoundingRule.valueOf(store.getString(SigilCore.DEFAULT_VERSION_UPPER_BOUND));
+
+ VersionRange selectedVersions = VersionRange.newInstance(version, lowerBoundRule,
+ upperBoundRule);
return selectedVersions;
}
-
- public static IPackageExport findExport(ISigilProjectModel sigil, final String packageName) {
+
+ public static IPackageExport findExport(ISigilProjectModel sigil,
+ final String packageName)
+ {
final ArrayList<IPackageExport> found = new ArrayList<IPackageExport>(1);
sigil.visit(new IModelWalker()
- {
+ {
public boolean visit(IModelElement element)
{
- if (element instanceof IPackageExport) {
+ if (element instanceof IPackageExport)
+ {
IPackageExport pe = (IPackageExport) element;
- if (pe.getPackageName().equals(packageName)) {
+ if (pe.getPackageName().equals(packageName))
+ {
found.add(pe);
}
}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/ProfileManager.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/ProfileManager.java
index 23d67c1..abb9d79 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/ProfileManager.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/model/util/ProfileManager.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.model.util;
-
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
@@ -35,27 +34,25 @@
import org.eclipse.core.runtime.Platform;
import org.osgi.framework.Bundle;
-
public class ProfileManager
{
- private static final Pattern[] BOOT_DELEGATION_PATTERNS = new Pattern[]
- { GlobCompiler.compile( "org.ietf.jgss" ), GlobCompiler.compile( "org.omg.*" ),
- GlobCompiler.compile( "org.w3c.*" ), GlobCompiler.compile( "org.xml.*" ), GlobCompiler.compile( "sun.*" ),
- GlobCompiler.compile( "com.sun.*" ), };
+ private static final Pattern[] BOOT_DELEGATION_PATTERNS = new Pattern[] {
+ GlobCompiler.compile("org.ietf.jgss"), GlobCompiler.compile("org.omg.*"),
+ GlobCompiler.compile("org.w3c.*"), GlobCompiler.compile("org.xml.*"),
+ GlobCompiler.compile("sun.*"), GlobCompiler.compile("com.sun.*"), };
private static HashMap<String, Properties> profiles;
-
- public static boolean isBootDelegate( ISigilProjectModel project, String packageName )
+ public static boolean isBootDelegate(ISigilProjectModel project, String packageName)
{
- if ( packageName.startsWith( "java." ) )
+ if (packageName.startsWith("java."))
{
return true;
}
- for ( Pattern p : BOOT_DELEGATION_PATTERNS )
+ for (Pattern p : BOOT_DELEGATION_PATTERNS)
{
- if ( p.matcher( packageName ).matches() )
+ if (p.matcher(packageName).matches())
{
return true;
}
@@ -63,60 +60,59 @@
return false;
}
-
- public static Properties findProfileForVersion( String javaVersion )
+ public static Properties findProfileForVersion(String javaVersion)
{
Map<String, Properties> profiles = loadProfiles();
- if ( "1.5.0".equals( javaVersion ) )
+ if ("1.5.0".equals(javaVersion))
{
- return profiles.get( "J2SE-1.5" );
+ return profiles.get("J2SE-1.5");
}
- else if ( "1.6.0".equals( javaVersion ) )
+ else if ("1.6.0".equals(javaVersion))
{
- return profiles.get( "J2SE-1.6" );
+ return profiles.get("J2SE-1.6");
}
return null;
}
-
private synchronized static Map<String, Properties> loadProfiles()
{
- if ( profiles == null )
+ if (profiles == null)
{
profiles = new HashMap<String, Properties>();
- Bundle b = Platform.getBundle( "org.eclipse.osgi" );
+ Bundle b = Platform.getBundle("org.eclipse.osgi");
- for ( String profile : loadProfiles( b ) )
+ for (String profile : loadProfiles(b))
{
- if ( profile.trim().length() > 0 )
+ if (profile.trim().length() > 0)
{
- URL url = findURL( profile, b );
- if ( url != null )
+ URL url = findURL(profile, b);
+ if (url != null)
{
try
{
- Properties p = loadProperties( url );
- String name = p.getProperty( "osgi.java.profile.name" );
- if ( name != null )
+ Properties p = loadProperties(url);
+ String name = p.getProperty("osgi.java.profile.name");
+ if (name != null)
{
- profiles.put( name, p );
+ profiles.put(name, p);
}
else
{
- SigilCore.error( "Invalid profile definition, no name specified: " + url );
+ SigilCore.error("Invalid profile definition, no name specified: "
+ + url);
}
}
- catch ( IOException e )
+ catch (IOException e)
{
- SigilCore.error( "Failed to load java profile", e );
+ SigilCore.error("Failed to load java profile", e);
}
}
else
{
- SigilCore.error( "Unknown profile **" + profile + "**" );
+ SigilCore.error("Unknown profile **" + profile + "**");
}
}
// else ignore empty values
@@ -125,45 +121,40 @@
return profiles;
}
-
- private static String[] loadProfiles( Bundle b )
+ private static String[] loadProfiles(Bundle b)
{
- URL url = findURL( "profile.list", b );
+ URL url = findURL("profile.list", b);
- if ( url != null )
+ if (url != null)
{
try
{
- Properties p = loadProperties( url );
- String s = p.getProperty( "java.profiles" );
- return s == null ? new String[]
- {} : s.split( "," );
+ Properties p = loadProperties(url);
+ String s = p.getProperty("java.profiles");
+ return s == null ? new String[] {} : s.split(",");
}
- catch ( IOException e )
+ catch (IOException e)
{
- SigilCore.error( "Failed to load java profile list", e );
+ SigilCore.error("Failed to load java profile list", e);
}
}
else
{
- SigilCore.error( "Failed to find java profile list" );
+ SigilCore.error("Failed to find java profile list");
}
// fine no properties found
- return new String[]
- {};
+ return new String[] {};
}
-
@SuppressWarnings("unchecked")
- private static URL findURL( String file, Bundle b )
+ private static URL findURL(String file, Bundle b)
{
- Enumeration e = b.findEntries( "/", file, false );
- return e == null ? null : ( URL ) ( e.hasMoreElements() ? e.nextElement() : null );
+ Enumeration e = b.findEntries("/", file, false);
+ return e == null ? null : (URL) (e.hasMoreElements() ? e.nextElement() : null);
}
-
- private static Properties loadProperties( URL url ) throws IOException
+ private static Properties loadProperties(URL url) throws IOException
{
Properties p = new Properties();
@@ -172,17 +163,17 @@
try
{
in = url.openStream();
- p.load( in );
+ p.load(in);
}
finally
{
- if ( in != null )
+ if (in != null)
{
try
{
in.close();
}
- catch ( IOException e )
+ catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/nature/SigilProjectNature.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/nature/SigilProjectNature.java
index 603e61e..fb3ef0f 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/nature/SigilProjectNature.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/nature/SigilProjectNature.java
@@ -19,37 +19,31 @@
package org.apache.felix.sigil.eclipse.nature;
-
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.runtime.CoreException;
-
public class SigilProjectNature implements IProjectNature
{
private IProject project;
-
public void configure() throws CoreException
{
// TODO configure project builder
}
-
public void deconfigure() throws CoreException
{
}
-
public IProject getProject()
{
return project;
}
-
- public void setProject( IProject project )
+ public void setProject(IProject project)
{
this.project = project;
}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/PrefsUtils.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/PrefsUtils.java
index e525c41..14e7d57 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/PrefsUtils.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/PrefsUtils.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.preferences;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -27,7 +26,6 @@
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.text.StrTokenizer;
-
public class PrefsUtils
{
@@ -35,28 +33,26 @@
{
}
-
- public static final String arrayToString( String[] array )
+ public static final String arrayToString(String[] array)
{
StringBuilder builder = new StringBuilder();
- for ( int i = 0; i < array.length; i++ )
+ for (int i = 0; i < array.length; i++)
{
- if ( i > 0 )
- builder.append( ',' );
- builder.append( StringEscapeUtils.escapeCsv( array[i] ) );
+ if (i > 0)
+ builder.append(',');
+ builder.append(StringEscapeUtils.escapeCsv(array[i]));
}
return builder.toString();
}
-
- public static final String[] stringToArray( String string )
+ public static final String[] stringToArray(String string)
{
- StrTokenizer tokenizer = new StrTokenizer( string, ',', '"' );
+ StrTokenizer tokenizer = new StrTokenizer(string, ',', '"');
String[] array = new String[tokenizer.size()];
- for ( int i = 0; i < array.length; i++ )
+ for (int i = 0; i < array.length; i++)
{
array[i] = tokenizer.nextToken();
}
@@ -64,15 +60,13 @@
return array;
}
-
- public static String listToString( List<String> names )
+ public static String listToString(List<String> names)
{
- return arrayToString( names.toArray( new String[names.size()] ) );
+ return arrayToString(names.toArray(new String[names.size()]));
}
-
- public static List<String> stringToList( String string )
+ public static List<String> stringToList(String string)
{
- return new ArrayList<String>( Arrays.asList( stringToArray( string ) ) );
+ return new ArrayList<String>(Arrays.asList(stringToArray(string)));
}
}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/PromptablePreference.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/PromptablePreference.java
index 4235c54..e904bdc 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/PromptablePreference.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/PromptablePreference.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.preferences;
-
public enum PromptablePreference
{
Always, Prompt, Never
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/SigilPreferencesInitializer.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/SigilPreferencesInitializer.java
index 22e4271..7dbfc0d 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/SigilPreferencesInitializer.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/preferences/SigilPreferencesInitializer.java
@@ -19,39 +19,42 @@
package org.apache.felix.sigil.eclipse.preferences;
-
import org.apache.felix.sigil.common.osgi.VersionRangeBoundingRule;
import org.apache.felix.sigil.eclipse.SigilCore;
import org.apache.felix.sigil.eclipse.internal.model.repository.RepositoryConfiguration;
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
import org.eclipse.jface.preference.IPreferenceStore;
-
public class SigilPreferencesInitializer extends AbstractPreferenceInitializer
{
- public static final String[] EXCLUDED_RESOURCES = new String[]
- { ".project", ".classpath", ".settings" };
-
+ public static final String[] EXCLUDED_RESOURCES = new String[] { ".project",
+ ".classpath", ".settings" };
@Override
public void initializeDefaultPreferences()
{
IPreferenceStore store = SigilCore.getDefault().getPreferenceStore();
- store.setDefault( SigilCore.OSGI_INSTALL_CHECK_PREFERENCE, true );
+ store.setDefault(SigilCore.OSGI_INSTALL_CHECK_PREFERENCE, true);
- store.setDefault( SigilCore.DEFAULT_VERSION_LOWER_BOUND, VersionRangeBoundingRule.Micro.name() );
- store.setDefault( SigilCore.DEFAULT_VERSION_UPPER_BOUND, VersionRangeBoundingRule.Any.name() );
+ store.setDefault(SigilCore.DEFAULT_VERSION_LOWER_BOUND,
+ VersionRangeBoundingRule.Micro.name());
+ store.setDefault(SigilCore.DEFAULT_VERSION_UPPER_BOUND,
+ VersionRangeBoundingRule.Any.name());
- store.setDefault( SigilCore.DEFAULT_EXCLUDED_RESOURCES, PrefsUtils.arrayToString( EXCLUDED_RESOURCES ) );
+ store.setDefault(SigilCore.DEFAULT_EXCLUDED_RESOURCES,
+ PrefsUtils.arrayToString(EXCLUDED_RESOURCES));
- store.setDefault( SigilCore.PREFERENCES_NOASK_OSGI_INSTALL, false );
+ store.setDefault(SigilCore.PREFERENCES_NOASK_OSGI_INSTALL, false);
- store.setDefault( SigilCore.PREFERENCES_ADD_IMPORT_FOR_EXPORT, PromptablePreference.Prompt.name() );
+ store.setDefault(SigilCore.PREFERENCES_ADD_IMPORT_FOR_EXPORT,
+ PromptablePreference.Prompt.name());
- store.setDefault( SigilCore.PREFERENCES_REBUILD_PROJECTS, PromptablePreference.Prompt.name() );
+ store.setDefault(SigilCore.PREFERENCES_REBUILD_PROJECTS,
+ PromptablePreference.Prompt.name());
- store.setDefault( RepositoryConfiguration.REPOSITORY_DEFAULT_SET, "org.apache.felix.sigil.core.workspaceprovider" );
+ store.setDefault(RepositoryConfiguration.REPOSITORY_DEFAULT_SET,
+ "org.apache.felix.sigil.core.workspaceprovider");
}
}
diff --git a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/property/SigilPropertyTester.java b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/property/SigilPropertyTester.java
index 97f8baf..97caef3 100644
--- a/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/property/SigilPropertyTester.java
+++ b/sigil/eclipse/core/src/org/apache/felix/sigil/eclipse/property/SigilPropertyTester.java
@@ -19,13 +19,11 @@
package org.apache.felix.sigil.eclipse.property;
-
import org.apache.felix.sigil.eclipse.SigilCore;
import org.eclipse.core.expressions.PropertyTester;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-
public class SigilPropertyTester extends PropertyTester
{
@@ -33,32 +31,31 @@
{
}
-
- public boolean test( Object receiver, String property, Object[] args, Object expectedValue )
+ public boolean test(Object receiver, String property, Object[] args,
+ Object expectedValue)
{
- IResource resource = ( IResource ) receiver;
- if ( "isSigilProject".equals( property ) )
+ IResource resource = (IResource) receiver;
+ if ("isSigilProject".equals(property))
{
- return expectedValue.equals( isSigilProjectLikeResource( resource ) );
+ return expectedValue.equals(isSigilProjectLikeResource(resource));
}
return false;
}
-
/**
* @param resource
* @return
*/
- private static boolean isSigilProjectLikeResource( IResource resource )
+ private static boolean isSigilProjectLikeResource(IResource resource)
{
- if ( resource instanceof IProject )
+ if (resource instanceof IProject)
{
- IProject p = ( IProject ) resource;
- return SigilCore.isSigilProject( p );
+ IProject p = (IProject) resource;
+ return SigilCore.isSigilProject(p);
}
else
{
- return resource.getName().equals( SigilCore.SIGIL_PROJECT_FILE );
+ return resource.getName().equals(SigilCore.SIGIL_PROJECT_FILE);
}
}
diff --git a/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/AbstractNewWizardAction.java b/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/AbstractNewWizardAction.java
index be13319..56609de 100644
--- a/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/AbstractNewWizardAction.java
+++ b/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/AbstractNewWizardAction.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.cheatsheets.actions;
-
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.ISelection;
@@ -32,7 +31,6 @@
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
-
public abstract class AbstractNewWizardAction extends Action
{
@@ -44,31 +42,29 @@
try
{
INewWizard wizard = createWizard();
- wizard.init( PlatformUI.getWorkbench(), getSelection() );
- WizardDialog dialog = new WizardDialog( shell, wizard );
+ wizard.init(PlatformUI.getWorkbench(), getSelection());
+ WizardDialog dialog = new WizardDialog(shell, wizard);
int res = dialog.open();
- notifyResult( res == Window.OK );
+ notifyResult(res == Window.OK);
}
- catch ( CoreException e )
+ catch (CoreException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
-
protected abstract INewWizard createWizard() throws CoreException;
-
private IStructuredSelection getSelection()
{
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if ( window != null )
+ if (window != null)
{
ISelection selection = window.getSelectionService().getSelection();
- if ( selection instanceof IStructuredSelection )
+ if (selection instanceof IStructuredSelection)
{
- return ( IStructuredSelection ) selection;
+ return (IStructuredSelection) selection;
}
}
return StructuredSelection.EMPTY;
diff --git a/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/CopyResourceFromPlugin.java b/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/CopyResourceFromPlugin.java
index 6be47b2..14491de 100644
--- a/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/CopyResourceFromPlugin.java
+++ b/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/CopyResourceFromPlugin.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.cheatsheets.actions;
-
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
@@ -47,7 +46,6 @@
import org.eclipse.ui.part.FileEditorInput;
import org.osgi.framework.Bundle;
-
public class CopyResourceFromPlugin extends Action implements ICheatSheetAction
{
@@ -57,10 +55,9 @@
private String sourcePath;
private String editorID;
-
- public void run( String[] params, ICheatSheetManager manager )
+ public void run(String[] params, ICheatSheetManager manager)
{
- if ( params != null && params.length > 4 )
+ if (params != null && params.length > 4)
{
targetProject = params[0];
targetFolder = params[1];
@@ -72,31 +69,31 @@
WorkspaceModifyOperation op = new WorkspaceModifyOperation()
{
@Override
- protected void execute( IProgressMonitor monitor ) throws CoreException
+ protected void execute(IProgressMonitor monitor) throws CoreException
{
try
{
- Bundle b = Platform.getBundle( sourceBundle );
+ Bundle b = Platform.getBundle(sourceBundle);
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
- IProject project = workspaceRoot.getProject( targetProject );
- IPath path = new Path( targetFolder )
- .append( sourcePath.substring( sourcePath.lastIndexOf( '/' ) ) );
- IFile file = project.getFile( path );
+ IProject project = workspaceRoot.getProject(targetProject);
+ IPath path = new Path(targetFolder).append(sourcePath.substring(sourcePath.lastIndexOf('/')));
+ IFile file = project.getFile(path);
- if ( !file.exists() )
+ if (!file.exists())
{
- mkdirs( ( IFolder ) file.getParent(), monitor );
+ mkdirs((IFolder) file.getParent(), monitor);
- InputStream in = FileLocator.openStream( b, new Path( sourcePath ), false );
- file.create( in, true, monitor );
+ InputStream in = FileLocator.openStream(b, new Path(sourcePath),
+ false);
+ file.create(in, true, monitor);
}
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- FileEditorInput input = new FileEditorInput( file );
- window.getActivePage().openEditor( input, editorID );
+ FileEditorInput input = new FileEditorInput(file);
+ window.getActivePage().openEditor(input, editorID);
}
- catch ( IOException e )
+ catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
@@ -106,32 +103,32 @@
try
{
- new ProgressMonitorDialog( Display.getCurrent().getActiveShell() ).run( false, false, op );
+ new ProgressMonitorDialog(Display.getCurrent().getActiveShell()).run(false,
+ false, op);
}
- catch ( InvocationTargetException e )
+ catch (InvocationTargetException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
- catch ( InterruptedException e )
+ catch (InterruptedException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
-
- private void mkdirs( IFolder folder, IProgressMonitor monitor ) throws CoreException
+ private void mkdirs(IFolder folder, IProgressMonitor monitor) throws CoreException
{
IContainer parent = folder.getParent();
- if ( !parent.exists() )
+ if (!parent.exists())
{
- mkdirs( ( IFolder ) parent, monitor );
+ mkdirs((IFolder) parent, monitor);
}
- if ( !folder.exists() )
+ if (!folder.exists())
{
- folder.create( true, true, monitor );
+ folder.create(true, true, monitor);
}
}
diff --git a/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/OpenEmptySigilProjectWizardAction.java b/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/OpenEmptySigilProjectWizardAction.java
index 1ee883c..ef869b3 100644
--- a/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/OpenEmptySigilProjectWizardAction.java
+++ b/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/OpenEmptySigilProjectWizardAction.java
@@ -19,23 +19,20 @@
package org.apache.felix.sigil.eclipse.cheatsheets.actions;
-
import org.apache.felix.sigil.eclipse.ui.wizard.project.SigilProjectWizard;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ui.INewWizard;
import org.eclipse.ui.cheatsheets.ICheatSheetAction;
import org.eclipse.ui.cheatsheets.ICheatSheetManager;
-
public class OpenEmptySigilProjectWizardAction extends AbstractNewWizardAction implements ICheatSheetAction
{
private String name;
-
- public void run( String[] params, ICheatSheetManager manager )
+ public void run(String[] params, ICheatSheetManager manager)
{
- if ( params != null && params.length > 0 )
+ if (params != null && params.length > 0)
{
name = params[0];
}
@@ -43,12 +40,11 @@
run();
}
-
@Override
protected INewWizard createWizard() throws CoreException
{
SigilProjectWizard wizard = new SigilProjectWizard();
- wizard.setName( name );
+ wizard.setName(name);
return wizard;
}
}
diff --git a/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/ResolveProjectDependencies.java b/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/ResolveProjectDependencies.java
index a7ca1cc..cebdfc4 100644
--- a/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/ResolveProjectDependencies.java
+++ b/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/ResolveProjectDependencies.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.cheatsheets.actions;
-
import org.apache.felix.sigil.eclipse.SigilCore;
import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
import org.apache.felix.sigil.eclipse.ui.actions.ResolveProjectDependenciesAction;
@@ -31,29 +30,27 @@
import org.eclipse.ui.cheatsheets.ICheatSheetAction;
import org.eclipse.ui.cheatsheets.ICheatSheetManager;
-
public class ResolveProjectDependencies extends Action implements ICheatSheetAction
{
private String targetProject;
-
- public void run( String[] params, ICheatSheetManager manager )
+ public void run(String[] params, ICheatSheetManager manager)
{
- if ( params != null && params.length > 3 )
+ if (params != null && params.length > 3)
{
targetProject = params[0];
}
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
- IProject project = workspaceRoot.getProject( targetProject );
+ IProject project = workspaceRoot.getProject(targetProject);
try
{
- ISigilProjectModel sigil = SigilCore.create( project );
- new ResolveProjectDependenciesAction( sigil, false ).run();
+ ISigilProjectModel sigil = SigilCore.create(project);
+ new ResolveProjectDependenciesAction(sigil, false).run();
}
- catch ( CoreException e )
+ catch (CoreException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
diff --git a/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/ShowViewAction.java b/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/ShowViewAction.java
index 57ebfff..9e9af4a 100644
--- a/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/ShowViewAction.java
+++ b/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/cheatsheets/actions/ShowViewAction.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.cheatsheets.actions;
-
import org.apache.felix.sigil.eclipse.SigilCore;
import org.eclipse.jface.action.Action;
import org.eclipse.ui.IWorkbenchPage;
@@ -29,23 +28,22 @@
import org.eclipse.ui.cheatsheets.ICheatSheetAction;
import org.eclipse.ui.cheatsheets.ICheatSheetManager;
-
public class ShowViewAction extends Action implements ICheatSheetAction
{
- public void run( String[] params, ICheatSheetManager manager )
+ public void run(String[] params, ICheatSheetManager manager)
{
- if ( params != null && params.length > 0 )
+ if (params != null && params.length > 0)
{
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage page = window.getActivePage();
try
{
- page.showView( params[0] );
+ page.showView(params[0]);
}
- catch ( PartInitException e )
+ catch (PartInitException e)
{
- SigilCore.error( "Failed to show view", e );
+ SigilCore.error("Failed to show view", e);
}
}
diff --git a/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/help/Activator.java b/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/help/Activator.java
index 6aea34a..99429cc 100644
--- a/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/help/Activator.java
+++ b/sigil/eclipse/help/src/org/apache/felix/sigil/eclipse/help/Activator.java
@@ -19,11 +19,9 @@
package org.apache.felix.sigil.eclipse.help;
-
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
-
/**
* The activator class controls the plug-in life cycle
*/
@@ -36,7 +34,6 @@
// The shared instance
private static Activator plugin;
-
/**
* The constructor
*/
@@ -44,29 +41,26 @@
{
}
-
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
- public void start( BundleContext context ) throws Exception
+ public void start(BundleContext context) throws Exception
{
- super.start( context );
+ super.start(context);
plugin = this;
}
-
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
- public void stop( BundleContext context ) throws Exception
+ public void stop(BundleContext context) throws Exception
{
plugin = null;
- super.stop( context );
+ super.stop(context);
}
-
/**
* Returns the shared instance
*
diff --git a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/LaunchHelper.java b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/LaunchHelper.java
index 289428b..b2deb73 100644
--- a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/LaunchHelper.java
+++ b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/LaunchHelper.java
@@ -34,35 +34,37 @@
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.ILaunchConfiguration;
-public class LaunchHelper {
+public class LaunchHelper
+{
- public static IOSGiInstall getInstall(ILaunchConfiguration config) {
- return null;
- }
+ public static IOSGiInstall getInstall(ILaunchConfiguration config)
+ {
+ return null;
+ }
- public static int getRetries( ILaunchConfiguration config )
+ public static int getRetries(ILaunchConfiguration config)
{
return 5;
}
- public static Properties buildClientProps( ILaunchConfiguration config )
+ public static Properties buildClientProps(ILaunchConfiguration config)
{
Properties props = new Properties();
- props.put( Runtime.ADDRESS_PROPERTY, "localhost" );
- props.put( Runtime.PORT_PROPERTY, "9090" );
+ props.put(Runtime.ADDRESS_PROPERTY, "localhost");
+ props.put(Runtime.PORT_PROPERTY, "9090");
return props;
}
- public static String[] getProgramArgs( ILaunchConfiguration config )
+ public static String[] getProgramArgs(ILaunchConfiguration config)
{
return new String[] { "-p", "9090", "-a", "localhost", "-c" };
}
- public static long getBackoff( ILaunchConfiguration config )
+ public static long getBackoff(ILaunchConfiguration config)
{
return 1000;
}
-
+
public static URL toURL(String loc) throws MalformedURLException
{
URL url = null;
@@ -73,19 +75,23 @@
catch (MalformedURLException e)
{
IFile f = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(loc));
- if ( f.exists() ) {
+ if (f.exists())
+ {
url = f.getLocation().toFile().toURL();
}
- else {
- throw new MalformedURLException("Unknown file " + loc );
+ else
+ {
+ throw new MalformedURLException("Unknown file " + loc);
}
}
return url;
}
- public static BundleForm getBundleForm(ILaunchConfiguration config) throws CoreException
+ public static BundleForm getBundleForm(ILaunchConfiguration config)
+ throws CoreException
{
- String loc = config.getAttribute(OSGiLaunchConfigurationConstants.FORM_FILE_LOCATION, (String) null);
+ String loc = config.getAttribute(
+ OSGiLaunchConfigurationConstants.FORM_FILE_LOCATION, (String) null);
try
{
URL url = toURL(loc);
diff --git a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/OSGiLauncher.java b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/OSGiLauncher.java
index 193ba26..c376444 100644
--- a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/OSGiLauncher.java
+++ b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/OSGiLauncher.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.runtime;
-
import java.io.IOException;
import java.net.ConnectException;
@@ -45,49 +44,48 @@
import org.eclipse.jdt.launching.IVMRunner;
import org.eclipse.jdt.launching.VMRunnerConfiguration;
-
-public class OSGiLauncher extends AbstractJavaLaunchConfigurationDelegate implements ILaunchConfigurationDelegate,
- ILaunchConfigurationDelegate2
+public class OSGiLauncher extends AbstractJavaLaunchConfigurationDelegate implements ILaunchConfigurationDelegate, ILaunchConfigurationDelegate2
{
- public void launch( ILaunchConfiguration config, String mode, ILaunch launch, IProgressMonitor monitor )
- throws CoreException
+ public void launch(ILaunchConfiguration config, String mode, ILaunch launch,
+ IProgressMonitor monitor) throws CoreException
{
- IOSGiInstall osgi = LaunchHelper.getInstall( config );
+ IOSGiInstall osgi = LaunchHelper.getInstall(config);
- VMRunnerConfiguration vmconfig = new VMRunnerConfiguration( Main.class.getName(), buildClasspath( osgi, config ) );
+ VMRunnerConfiguration vmconfig = new VMRunnerConfiguration(Main.class.getName(),
+ buildClasspath(osgi, config));
- String vm = getVMArguments( config );
- if ( vm != null && vm.trim().length() > 0 )
- vmconfig.setVMArguments( vm.split( " " ) );
-
- IPath path = getWorkingDirectoryPath( config );
- vmconfig.setWorkingDirectory( path == null ? null : path.toOSString() );
-
- vmconfig.setBootClassPath( getBootpath( config ) );
- vmconfig.setEnvironment( getEnvironment( config ) );
- vmconfig.setProgramArguments( LaunchHelper.getProgramArgs( config ) );
+ String vm = getVMArguments(config);
+ if (vm != null && vm.trim().length() > 0)
+ vmconfig.setVMArguments(vm.split(" "));
- IVMInstall install = getVMInstall( config );
+ IPath path = getWorkingDirectoryPath(config);
+ vmconfig.setWorkingDirectory(path == null ? null : path.toOSString());
- IVMRunner runner = install.getVMRunner( mode );
+ vmconfig.setBootClassPath(getBootpath(config));
+ vmconfig.setEnvironment(getEnvironment(config));
+ vmconfig.setProgramArguments(LaunchHelper.getProgramArgs(config));
- setDefaultSourceLocator( launch, config );
+ IVMInstall install = getVMInstall(config);
- SigilCore.log( "VM=" + install.getName() );
- SigilCore.log( "Main=" + vmconfig.getClassToLaunch() );
- SigilCore.log( "VMArgs=" + Arrays.asList( vmconfig.getVMArguments() ) );
- SigilCore.log( "Boot Classpath=" + Arrays.asList( vmconfig.getBootClassPath() ) );
- SigilCore.log( "Classpath=" + Arrays.asList( vmconfig.getClassPath() ) );
- SigilCore.log( "Args=" + Arrays.asList( vmconfig.getProgramArguments() ) );
- SigilCore.log( "Working Dir=" + vmconfig.getWorkingDirectory() );
+ IVMRunner runner = install.getVMRunner(mode);
- runner.run( vmconfig, launch, monitor );
+ setDefaultSourceLocator(launch, config);
- Client client = connect( config );
-
+ SigilCore.log("VM=" + install.getName());
+ SigilCore.log("Main=" + vmconfig.getClassToLaunch());
+ SigilCore.log("VMArgs=" + Arrays.asList(vmconfig.getVMArguments()));
+ SigilCore.log("Boot Classpath=" + Arrays.asList(vmconfig.getBootClassPath()));
+ SigilCore.log("Classpath=" + Arrays.asList(vmconfig.getClassPath()));
+ SigilCore.log("Args=" + Arrays.asList(vmconfig.getProgramArguments()));
+ SigilCore.log("Working Dir=" + vmconfig.getWorkingDirectory());
+
+ runner.run(vmconfig, launch, monitor);
+
+ Client client = connect(config);
+
BundleForm form = LaunchHelper.getBundleForm(config);
-
+
try
{
String name = LaunchHelper.getRepositoryManagerName(config);
@@ -99,96 +97,95 @@
throw SigilCore.newCoreException("Failed to apply bundle form", e);
}
- SigilCore.log( "Connected " + client.isConnected() );
+ SigilCore.log("Connected " + client.isConnected());
}
-
- private Client connect( ILaunchConfiguration config ) throws CoreException
+ private Client connect(ILaunchConfiguration config) throws CoreException
{
- Properties props = LaunchHelper.buildClientProps( config );
+ Properties props = LaunchHelper.buildClientProps(config);
- int retry = LaunchHelper.getRetries( config );
+ int retry = LaunchHelper.getRetries(config);
Client client = null;
- for ( int i = 0; i < retry; i++ )
+ for (int i = 0; i < retry; i++)
{
client = new Client();
try
{
- client.connect( props );
+ client.connect(props);
break;
}
- catch ( ConnectException e )
+ catch (ConnectException e)
{
- SigilCore.log( "Failed to connect to client: " + e.getMessage() );
+ SigilCore.log("Failed to connect to client: " + e.getMessage());
}
- catch ( IOException e )
+ catch (IOException e)
{
- throw SigilCore.newCoreException( "Failed to connect client", e );
+ throw SigilCore.newCoreException("Failed to connect client", e);
}
try
{
- Thread.sleep( LaunchHelper.getBackoff( config ) );
+ Thread.sleep(LaunchHelper.getBackoff(config));
}
- catch ( InterruptedException e )
+ catch (InterruptedException e)
{
- SigilCore.log( "Interrupted during backoff" );
+ SigilCore.log("Interrupted during backoff");
}
}
- if ( client == null )
+ if (client == null)
{
- throw SigilCore.newCoreException( "Failed to connect client after retries, check error log for details",
- null );
+ throw SigilCore.newCoreException(
+ "Failed to connect client after retries, check error log for details",
+ null);
}
return client;
}
-
- public String[] getBootpath( ILaunchConfiguration configuration ) throws CoreException
+ public String[] getBootpath(ILaunchConfiguration configuration) throws CoreException
{
- String[] bootpath = super.getBootpath( configuration );
+ String[] bootpath = super.getBootpath(configuration);
ArrayList<String> filtered = new ArrayList<String>();
- if ( bootpath != null )
+ if (bootpath != null)
{
- for ( String bp : bootpath )
+ for (String bp : bootpath)
{
- if ( !SigilCore.isBundledPath( bp ) )
+ if (!SigilCore.isBundledPath(bp))
{
- filtered.add( bp );
+ filtered.add(bp);
}
}
}
- return filtered.toArray( new String[filtered.size()] );
+ return filtered.toArray(new String[filtered.size()]);
}
-
- private String[] buildClasspath( IOSGiInstall osgi, ILaunchConfiguration config ) throws CoreException
+ private String[] buildClasspath(IOSGiInstall osgi, ILaunchConfiguration config)
+ throws CoreException
{
ArrayList<String> cp = new ArrayList<String>();
- cp.add( Main.class.getProtectionDomain().getCodeSource().getLocation().getFile() );
+ cp.add(Main.class.getProtectionDomain().getCodeSource().getLocation().getFile());
- for ( String c : getClasspath( config ) )
+ for (String c : getClasspath(config))
{
- cp.add( c );
+ cp.add(c);
}
- if ( osgi != null )
+ if (osgi != null)
{
- for ( String c : osgi.getType().getClassPath() )
+ for (String c : osgi.getType().getClassPath())
{
- cp.add( c );
+ cp.add(c);
}
}
- return cp.toArray( new String[cp.size()] );
+ return cp.toArray(new String[cp.size()]);
}
}
diff --git a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/RuntimeBundleResolver.java b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/RuntimeBundleResolver.java
index b8230eb..bbb1b50 100644
--- a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/RuntimeBundleResolver.java
+++ b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/RuntimeBundleResolver.java
@@ -31,11 +31,13 @@
public URI[] resolve(URI base) throws URISyntaxException
{
ArrayList<URI> uris = new ArrayList<URI>(1);
-
+
IBundleResolver resolver = manager.getBundleResolver();
- IRequiredBundle element = ModelElementFactory.getInstance().newModelElement(IRequiredBundle.class);
+ IRequiredBundle element = ModelElementFactory.getInstance().newModelElement(
+ IRequiredBundle.class);
String[] parts = base.getSchemeSpecificPart().split(":");
- switch( parts.length ) {
+ switch (parts.length)
+ {
case 2:
Version v = Version.parseVersion(parts[1]);
element.setVersions(new VersionRange(false, v, v, false));
@@ -44,25 +46,32 @@
element.setSymbolicName(parts[0]);
break;
default:
- throw new URISyntaxException(base.toString(), "Unexpected number of parts: " + parts.length);
+ throw new URISyntaxException(base.toString(),
+ "Unexpected number of parts: " + parts.length);
}
try
{
- ResolutionConfig config = new ResolutionConfig(ResolutionConfig.IGNORE_ERRORS);
+ ResolutionConfig config = new ResolutionConfig(
+ ResolutionConfig.IGNORE_ERRORS);
IResolution resolution = resolver.resolve(element, config, null);
- if ( resolution.getBundles().isEmpty() ) {
- SigilCore.error( "Failed to resolve bundle for " + base );
+ if (resolution.getBundles().isEmpty())
+ {
+ SigilCore.error("Failed to resolve bundle for " + base);
}
- for ( ISigilBundle b : resolution.getBundles() ) {
+ for (ISigilBundle b : resolution.getBundles())
+ {
ISigilProjectModel p = b.getAncestor(ISigilProjectModel.class);
- if ( p != null ) {
+ if (p != null)
+ {
uris.add(p.findBundleLocation().toFile().toURI());
- SigilCore.log("Adding project source to source path " + p.getName());
+ SigilCore.log("Adding project source to source path "
+ + p.getName());
SigilSourcePathProvider.addProjectSource(launchConfig, p);
}
- else {
+ else
+ {
b.synchronize(null);
- uris.add( b.getLocation().toURI() );
+ uris.add(b.getLocation().toURI());
}
}
}
@@ -78,27 +87,29 @@
{
SigilCore.error("Failed to access " + base, e);
}
- SigilCore.log( "Resolved " + uris );
+ SigilCore.log("Resolved " + uris);
return uris.toArray(new URI[uris.size()]);
}
}
-
+
private final IRepositoryManager manager;
private final ILaunchConfiguration launchConfig;
-
- public RuntimeBundleResolver(IRepositoryManager manager, ILaunchConfiguration launchConfig) {
+
+ public RuntimeBundleResolver(IRepositoryManager manager, ILaunchConfiguration launchConfig)
+ {
this.manager = manager;
this.launchConfig = launchConfig;
}
public Resolver findResolver(URI uri)
{
- SigilCore.log( "Finding resolver for " + uri.getScheme() );
- if ( "sigil".equals( uri.getScheme() ) ) {
- SigilCore.log( "Found resolver for " + uri.getScheme() );
+ SigilCore.log("Finding resolver for " + uri.getScheme());
+ if ("sigil".equals(uri.getScheme()))
+ {
+ SigilCore.log("Found resolver for " + uri.getScheme());
return new SigilBundleResolver();
}
return null;
}
-
+
}
diff --git a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/FilteredModelView.java b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/FilteredModelView.java
index f0511ea..ecfba3d 100644
--- a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/FilteredModelView.java
+++ b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/FilteredModelView.java
@@ -1,6 +1,5 @@
package org.apache.felix.sigil.eclipse.runtime.config;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -29,7 +28,6 @@
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.Text;
-
public class FilteredModelView<T> extends Composite
{
private ArrayList<T> selected = new ArrayList<T>();
@@ -39,9 +37,9 @@
private StructuredViewer viewer;
private String txt = "";
- public FilteredModelView( Composite parent, int style )
+ public FilteredModelView(Composite parent, int style)
{
- super( parent, style );
+ super(parent, style);
initLayout();
}
@@ -50,42 +48,39 @@
return selected;
}
-
public List<T> getElements()
{
return elements;
}
- public void addElement( T element )
+ public void addElement(T element)
{
- elements.add( element );
+ elements.add(element);
refresh();
}
-
- public void addElements( Collection<T> elements )
+ public void addElements(Collection<T> elements)
{
- this.elements.addAll( elements );
+ this.elements.addAll(elements);
refresh();
}
-
- public void removeElement( T element )
+ public void removeElement(T element)
{
- elements.remove( element );
+ elements.remove(element);
refresh();
}
-
- public void removeElements( Collection<T> elements )
+ public void removeElements(Collection<T> elements)
{
- this.elements.removeAll( elements );
+ this.elements.removeAll(elements);
refresh();
}
public void refresh()
{
- SigilUI.runInUI( new Runnable() {
+ SigilUI.runInUI(new Runnable()
+ {
public void run()
{
@@ -96,108 +91,104 @@
private void initLayout()
{
- Text bundleTxt = createSelectionBox( this );
+ Text bundleTxt = createSelectionBox(this);
- Control view = createViewBox( this );
+ Control view = createViewBox(this);
// layout
- bundleTxt.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
- view.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
+ bundleTxt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ view.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
- setLayout( new GridLayout( 1, false ) );
+ setLayout(new GridLayout(1, false));
}
-
- private Control createViewBox( Composite parent )
+ private Control createViewBox(Composite parent)
{
- Table table = new Table( this, SWT.MULTI );
+ Table table = new Table(this, SWT.MULTI);
- viewer = createViewer( table );
+ viewer = createViewer(table);
- viewer.setContentProvider( new ArrayContentProvider() );
+ viewer.setContentProvider(new ArrayContentProvider());
- viewer.addSelectionChangedListener( new ISelectionChangedListener()
+ viewer.addSelectionChangedListener(new ISelectionChangedListener()
{
@SuppressWarnings("unchecked")
- public void selectionChanged( SelectionChangedEvent event )
+ public void selectionChanged(SelectionChangedEvent event)
{
- if ( event.getSelection().isEmpty() )
+ if (event.getSelection().isEmpty())
{
selected.clear();
}
else
{
- IStructuredSelection sel = ( IStructuredSelection ) event.getSelection();
- selected.addAll( sel.toList() );
+ IStructuredSelection sel = (IStructuredSelection) event.getSelection();
+ selected.addAll(sel.toList());
}
}
- } );
-
- viewer.setInput( elements );
+ });
- viewer.setFilters( new ViewerFilter[]
- { new ViewerFilter()
+ viewer.setInput(elements);
+
+ viewer.setFilters(new ViewerFilter[] { new ViewerFilter()
+ {
+ @SuppressWarnings("unchecked")
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element)
{
- @SuppressWarnings("unchecked")
- @Override
- public boolean select( Viewer viewer, Object parentElement, Object element )
+ if (filter.select((T) element))
{
- if ( filter.select( ( T ) element ) )
- {
- String name = elementDescriptor.getName( ( T ) element );
- return name.startsWith( txt );
- }
- else
- {
- return false;
- }
+ String name = elementDescriptor.getName((T) element);
+ return name.startsWith(txt);
}
- } } );
+ else
+ {
+ return false;
+ }
+ }
+ } });
return table;
}
-
- protected StructuredViewer createViewer( Table table )
+ protected StructuredViewer createViewer(Table table)
{
- TableViewer tableViewer = new TableViewer( table );
-
- tableViewer.setLabelProvider( new DefaultLabelProvider() {
+ TableViewer tableViewer = new TableViewer(table);
- public Image getImage( Object arg0 )
+ tableViewer.setLabelProvider(new DefaultLabelProvider()
+ {
+
+ public Image getImage(Object arg0)
{
return null;
}
@SuppressWarnings("unchecked")
- public String getText( Object element )
+ public String getText(Object element)
{
- return elementDescriptor.getLabel( ( T ) element );
+ return elementDescriptor.getLabel((T) element);
}
-
+
});
return tableViewer;
}
-
- private Text createSelectionBox( Composite parent )
+ private Text createSelectionBox(Composite parent)
{
- final Text txtSelection = new Text( parent, SWT.SEARCH );
+ final Text txtSelection = new Text(parent, SWT.SEARCH);
- txtSelection.addKeyListener( new KeyAdapter()
+ txtSelection.addKeyListener(new KeyAdapter()
{
@Override
- public void keyReleased( KeyEvent e )
+ public void keyReleased(KeyEvent e)
{
txt = txtSelection.getText();
refresh();
}
- } );
+ });
return txtSelection;
}
-
/*
* ControlDecoration selectionDecor = new ControlDecoration( txtSelection, SWT.LEFT | SWT.TOP );
FieldDecoration proposalDecor = FieldDecorationRegistry.getDefault().getFieldDecoration(
@@ -225,28 +216,27 @@
*/
- public void setElementDescriptor( IElementDescriptor<T> elementDescriptor )
+ public void setElementDescriptor(IElementDescriptor<T> elementDescriptor)
{
- if ( elementDescriptor == null )
+ if (elementDescriptor == null)
{
elementDescriptor = UIHelper.getDefaultElementDescriptor();
}
this.elementDescriptor = elementDescriptor;
}
-
- public IElementDescriptor<T> getElementDescriptor() {
+
+ public IElementDescriptor<T> getElementDescriptor()
+ {
return elementDescriptor;
}
-
- public void setFilter( IFilter<T> filter )
+ public void setFilter(IFilter<T> filter)
{
- if ( filter == null )
+ if (filter == null)
{
filter = UIHelper.getDefaultFilter();
}
this.filter = filter;
}
-
}
diff --git a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/FormSelectionDialog.java b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/FormSelectionDialog.java
index d1ac51f..001a16d 100644
--- a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/FormSelectionDialog.java
+++ b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/FormSelectionDialog.java
@@ -22,7 +22,7 @@
public class FormSelectionDialog extends Dialog
{
private IFile formFile;
-
+
public FormSelectionDialog(Shell parent)
{
super(parent);
@@ -39,45 +39,52 @@
viewer.setContentProvider(new BaseWorkbenchContentProvider());
viewer.setInput(ResourcesPlugin.getWorkspace().getRoot());
viewer.addSelectionChangedListener(new ISelectionChangedListener()
- {
+ {
public void selectionChanged(SelectionChangedEvent evt)
{
- if (evt.getSelection().isEmpty()) {
+ if (evt.getSelection().isEmpty())
+ {
updateFile(null);
}
- else {
+ else
+ {
StructuredSelection sel = (StructuredSelection) evt.getSelection();
IResource r = (IResource) sel.getFirstElement();
- if ( r instanceof IFile ) {
+ if (r instanceof IFile)
+ {
IFile f = (IFile) r;
updateFile(f);
}
- else {
+ else
+ {
updateFile(null);
}
}
}
});
viewer.setLabelProvider(new WorkbenchLabelProvider());
-
+
tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
-
+
return composite;
}
-
- public IFile getFormFile() {
+
+ public IFile getFormFile()
+ {
return formFile;
}
protected void updateFile(IFile file)
{
formFile = file;
-
- if ( file == null ) {
- getButton(Window.OK).setEnabled(false);
+
+ if (file == null)
+ {
+ getButton(Window.OK).setEnabled(false);
}
- else {
- getButton(Window.OK).setEnabled(true);
+ else
+ {
+ getButton(Window.OK).setEnabled(true);
}
}
diff --git a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/OSGiLaunchConfigurationTab.java b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/OSGiLaunchConfigurationTab.java
index e3d3179..668fed3 100644
--- a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/OSGiLaunchConfigurationTab.java
+++ b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/OSGiLaunchConfigurationTab.java
@@ -21,7 +21,6 @@
import java.net.URL;
-
import org.apache.felix.sigil.common.runtime.BundleForm;
import org.apache.felix.sigil.eclipse.SigilCore;
import org.apache.felix.sigil.eclipse.runtime.LaunchHelper;
@@ -64,7 +63,7 @@
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite)
*/
- public void createControl( Composite parent )
+ public void createControl(Composite parent)
{
Composite configurationView = new Composite(parent, SWT.NONE);
new Label(configurationView, SWT.NONE).setText("Form");
@@ -73,8 +72,8 @@
formText = new Text(configurationView, SWT.BORDER);
// layout
- formText.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false ) );
-
+ formText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
formText.addKeyListener(new KeyAdapter()
{
@Override
@@ -83,25 +82,26 @@
updateLocation();
}
});
-
+
Button browse = new Button(configurationView, SWT.PUSH);
browse.setText("Browse");
-
- browse.addSelectionListener( new SelectionAdapter() {
+
+ browse.addSelectionListener(new SelectionAdapter()
+ {
@Override
- public void widgetSelected(SelectionEvent e) {
- FormSelectionDialog dialog =
- new FormSelectionDialog(getShell());
- if ( dialog.open() == Window.OK ) {
+ public void widgetSelected(SelectionEvent e)
+ {
+ FormSelectionDialog dialog = new FormSelectionDialog(getShell());
+ if (dialog.open() == Window.OK)
+ {
formLocation = dialog.getFormFile().getFullPath().toOSString();
formText.setText(formLocation);
updateLocation();
}
}
});
-
-
- configurationView.setLayout( new GridLayout( 3, false ) );
+
+ configurationView.setLayout(new GridLayout(3, false));
setControl(configurationView);
}
@@ -109,7 +109,8 @@
private void updateLocation()
{
String loc = formText.getText();
- if ( loc.trim().length() > 0 ) {
+ if (loc.trim().length() > 0)
+ {
try
{
URL url = LaunchHelper.toURL(loc);
@@ -121,10 +122,11 @@
catch (Exception e)
{
SigilCore.warn("Failed to resolve bundle form", e);
- setErrorMessage("Invalid form file " + e.getMessage() );
+ setErrorMessage("Invalid form file " + e.getMessage());
}
}
- else {
+ else
+ {
setErrorMessage("Missing form file");
}
updateLaunchConfigurationDialog();
@@ -133,11 +135,12 @@
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration)
*/
- public void initializeFrom( ILaunchConfiguration config )
+ public void initializeFrom(ILaunchConfiguration config)
{
try
{
- formLocation = config.getAttribute(OSGiLaunchConfigurationConstants.FORM_FILE_LOCATION, "");
+ formLocation = config.getAttribute(
+ OSGiLaunchConfigurationConstants.FORM_FILE_LOCATION, "");
formText.setText(formLocation);
}
catch (CoreException e)
@@ -149,18 +152,22 @@
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
*/
- public void performApply( ILaunchConfigurationWorkingCopy config )
+ public void performApply(ILaunchConfigurationWorkingCopy config)
{
- config.setAttribute(OSGiLaunchConfigurationConstants.FORM_FILE_LOCATION, formLocation);
- config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER, OSGiLaunchConfigurationConstants.CLASSPATH_PROVIDER );
- config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER, OSGiLaunchConfigurationConstants.CLASSPATH_PROVIDER);
+ config.setAttribute(OSGiLaunchConfigurationConstants.FORM_FILE_LOCATION,
+ formLocation);
+ config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_SOURCE_PATH_PROVIDER,
+ OSGiLaunchConfigurationConstants.CLASSPATH_PROVIDER);
+ config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CLASSPATH_PROVIDER,
+ OSGiLaunchConfigurationConstants.CLASSPATH_PROVIDER);
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)
*/
- public void setDefaults( ILaunchConfigurationWorkingCopy config )
+ public void setDefaults(ILaunchConfigurationWorkingCopy config)
{
- config.setAttribute(OSGiLaunchConfigurationConstants.FORM_FILE_LOCATION, (String) null);
+ config.setAttribute(OSGiLaunchConfigurationConstants.FORM_FILE_LOCATION,
+ (String) null);
}
}
diff --git a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/OSGiLaunchConfigurationTabGroup.java b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/OSGiLaunchConfigurationTabGroup.java
index 77834a0..1acaa4e 100644
--- a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/OSGiLaunchConfigurationTabGroup.java
+++ b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/OSGiLaunchConfigurationTabGroup.java
@@ -37,16 +37,12 @@
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchConfigurationTabGroup#createTabs(org.eclipse.debug.ui.ILaunchConfigurationDialog, java.lang.String)
*/
- public void createTabs( ILaunchConfigurationDialog arg0, String arg1 )
+ public void createTabs(ILaunchConfigurationDialog arg0, String arg1)
{
ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] {
- new OSGiLaunchConfigurationTab(),
- new CommonTab(),
- new JavaArgumentsTab(),
- new JavaClasspathTab(),
- new EnvironmentTab()
- };
- setTabs(tabs);
+ new OSGiLaunchConfigurationTab(), new CommonTab(),
+ new JavaArgumentsTab(), new JavaClasspathTab(), new EnvironmentTab() };
+ setTabs(tabs);
}
}
diff --git a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/shortcut/OSGiLaunchShortCut.java b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/shortcut/OSGiLaunchShortCut.java
index 8b83917..7e2f426 100644
--- a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/shortcut/OSGiLaunchShortCut.java
+++ b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/shortcut/OSGiLaunchShortCut.java
@@ -33,19 +33,19 @@
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchShortcut#launch(org.eclipse.jface.viewers.ISelection, java.lang.String)
*/
- public void launch( ISelection arg0, String arg1 )
+ public void launch(ISelection arg0, String arg1)
{
// TODO Auto-generated method stub
-
+
}
/* (non-Javadoc)
* @see org.eclipse.debug.ui.ILaunchShortcut#launch(org.eclipse.ui.IEditorPart, java.lang.String)
*/
- public void launch( IEditorPart arg0, String arg1 )
+ public void launch(IEditorPart arg0, String arg1)
{
// TODO Auto-generated method stub
-
+
}
}
diff --git a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/source/SigilSourcePathProvider.java b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/source/SigilSourcePathProvider.java
index 2b6f170..31c6091 100644
--- a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/source/SigilSourcePathProvider.java
+++ b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/source/SigilSourcePathProvider.java
@@ -25,126 +25,138 @@
public IRuntimeClasspathEntry[] resolveClasspath(IRuntimeClasspathEntry[] entries,
ILaunchConfiguration configuration) throws CoreException
{
- ArrayList<IRuntimeClasspathEntry> all = new ArrayList<IRuntimeClasspathEntry>(entries.length);
-
- all.addAll( workbenchSourcePath(entries, configuration) );
-// all.addAll( launchOverridePath( configuration ) );
-// all.addAll( newtonSourcePath( configuration ) );
- Set<IRuntimeClasspathEntry> dynamic = dynamicRuntime.get( configuration );
- if ( dynamic != null ) {
- all.addAll( dynamic );
+ ArrayList<IRuntimeClasspathEntry> all = new ArrayList<IRuntimeClasspathEntry>(
+ entries.length);
+
+ all.addAll(workbenchSourcePath(entries, configuration));
+ // all.addAll( launchOverridePath( configuration ) );
+ // all.addAll( newtonSourcePath( configuration ) );
+ Set<IRuntimeClasspathEntry> dynamic = dynamicRuntime.get(configuration);
+ if (dynamic != null)
+ {
+ all.addAll(dynamic);
}
-
- return (IRuntimeClasspathEntry[]) all
- .toArray(new IRuntimeClasspathEntry[all.size()]);
+
+ return (IRuntimeClasspathEntry[]) all.toArray(new IRuntimeClasspathEntry[all.size()]);
}
- private List<IRuntimeClasspathEntry> workbenchSourcePath(IRuntimeClasspathEntry[] entries, ILaunchConfiguration configuration) throws CoreException {
- return Arrays.asList( super.resolveClasspath(entries, configuration) );
+ private List<IRuntimeClasspathEntry> workbenchSourcePath(
+ IRuntimeClasspathEntry[] entries, ILaunchConfiguration configuration)
+ throws CoreException
+ {
+ return Arrays.asList(super.resolveClasspath(entries, configuration));
}
-
- private Collection<IRuntimeClasspathEntry> launchOverridePath(ILaunchConfiguration configuration) throws CoreException {
+
+ private Collection<IRuntimeClasspathEntry> launchOverridePath(
+ ILaunchConfiguration configuration) throws CoreException
+ {
ArrayList<IRuntimeClasspathEntry> overrides = new ArrayList<IRuntimeClasspathEntry>();
-
- if ( configuration.getAttribute( OSGiLaunchConfigurationConstants.AUTOMATIC_ADD, true) ) {
- for ( ISigilProjectModel n : SigilCore.getRoot().getProjects() ) {
- overrides.add( JavaRuntime.newProjectRuntimeClasspathEntry(n.getJavaModel()));
- }
+
+ if (configuration.getAttribute(OSGiLaunchConfigurationConstants.AUTOMATIC_ADD,
+ true))
+ {
+ for (ISigilProjectModel n : SigilCore.getRoot().getProjects())
+ {
+ overrides.add(JavaRuntime.newProjectRuntimeClasspathEntry(n.getJavaModel()));
+ }
}
-
+
return overrides;
}
- public static void addProjectSource(ILaunchConfiguration config, ISigilProjectModel project) {
- Set<IRuntimeClasspathEntry> dynamic = dynamicRuntime.get( config );
-
- if ( dynamic == null ) {
+ public static void addProjectSource(ILaunchConfiguration config,
+ ISigilProjectModel project)
+ {
+ Set<IRuntimeClasspathEntry> dynamic = dynamicRuntime.get(config);
+
+ if (dynamic == null)
+ {
dynamic = new HashSet<IRuntimeClasspathEntry>();
- dynamicRuntime.put( config, dynamic );
+ dynamicRuntime.put(config, dynamic);
}
-
+
IJavaProject javaProject = project.getJavaModel();
IRuntimeClasspathEntry cp = JavaRuntime.newProjectRuntimeClasspathEntry(javaProject);
-
- dynamic.add( cp );
- }
-
-// private List<IRuntimeClasspathEntry> newtonSourcePath( ILaunchConfiguration configuration ) throws CoreException {
-// List<IRuntimeClasspathEntry> all = new ArrayList<IRuntimeClasspathEntry>();
-//
-//// Collection<IPath> jars = findNewtonJars( configuration );
-//
-//// IPath source = findSourcePath( configuration );
-//
-//// for ( IPath jar : jars ) {
-//// IRuntimeClasspathEntry cp = JavaRuntime.newArchiveRuntimeClasspathEntry(jar);
-////
-//// if ( source != null ) {
-//// cp.setSourceAttachmentPath( source );
-//// cp.setSourceAttachmentRootPath( findSrcDir( source ) );
-//// }
-//// cp.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
-////
-//// all.add( cp );
-//// }
-//
-// return all;
-// }
-
-// @SuppressWarnings("unchecked")
-// private IPath findSrcDir( IPath sourceZip ) throws CoreException {
-// ZipFile zip = null;
-//
-// IPath path = null;
-//
-// try {
-// File file = sourceZip.toFile();
-// if (file.exists() && file.isFile() ) {
-// zip = new ZipFile(file);
-//
-// for ( Enumeration e = zip.entries(); e.hasMoreElements(); ) {
-// ZipEntry entry = (ZipEntry) e.nextElement();
-// if ( entry.getName().endsWith( "src/" ) ); {
-// path = new Path( entry.getName() );
-// break;
-// }
-// }
-// } // else return null;
-// }
-// catch (ZipException e) {
-// throw SigilCore.newCoreException("Failed to open source zip:" + sourceZip.toFile(), e);
-// }
-// catch (IOException e) {
-// throw SigilCore.newCoreException("Failed to open source zip" + sourceZip.toFile(), e);
-// }
-// finally {
-// if ( zip != null ) {
-// try {
-// zip.close();
-// }
-// catch (IOException e) {
-// SigilCore.error( "Failed to close src zip", e);
-// }
-// }
-// }
-//
-// return path;
-// }
-
-// private Collection<IPath> findNewtonJars( ILaunchConfiguration configuration ) throws CoreException {
-// ArrayList<IPath> paths = new ArrayList<IPath>();
-//
-// INewtonInstall install = NewtonLaunchConfigurationHelper.getNewtonInstall(configuration);
-//
-// for ( IPath path : install.getType().getDefaultBundleLocations() ) {
-// paths.add(path);
-// }
-//
-// return paths;
-// }
-
-// private IPath findSourcePath( ILaunchConfiguration configuration ) throws CoreException {
-// INewtonInstall install = NewtonLaunchConfigurationHelper.getNewtonInstall(configuration);
-// return install.getType().getSourceLocation();
-// }
+
+ dynamic.add(cp);
+ }
+
+ // private List<IRuntimeClasspathEntry> newtonSourcePath( ILaunchConfiguration configuration ) throws CoreException {
+ // List<IRuntimeClasspathEntry> all = new ArrayList<IRuntimeClasspathEntry>();
+ //
+ //// Collection<IPath> jars = findNewtonJars( configuration );
+ //
+ //// IPath source = findSourcePath( configuration );
+ //
+ //// for ( IPath jar : jars ) {
+ //// IRuntimeClasspathEntry cp = JavaRuntime.newArchiveRuntimeClasspathEntry(jar);
+ ////
+ //// if ( source != null ) {
+ //// cp.setSourceAttachmentPath( source );
+ //// cp.setSourceAttachmentRootPath( findSrcDir( source ) );
+ //// }
+ //// cp.setClasspathProperty(IRuntimeClasspathEntry.USER_CLASSES);
+ ////
+ //// all.add( cp );
+ //// }
+ //
+ // return all;
+ // }
+
+ // @SuppressWarnings("unchecked")
+ // private IPath findSrcDir( IPath sourceZip ) throws CoreException {
+ // ZipFile zip = null;
+ //
+ // IPath path = null;
+ //
+ // try {
+ // File file = sourceZip.toFile();
+ // if (file.exists() && file.isFile() ) {
+ // zip = new ZipFile(file);
+ //
+ // for ( Enumeration e = zip.entries(); e.hasMoreElements(); ) {
+ // ZipEntry entry = (ZipEntry) e.nextElement();
+ // if ( entry.getName().endsWith( "src/" ) ); {
+ // path = new Path( entry.getName() );
+ // break;
+ // }
+ // }
+ // } // else return null;
+ // }
+ // catch (ZipException e) {
+ // throw SigilCore.newCoreException("Failed to open source zip:" + sourceZip.toFile(), e);
+ // }
+ // catch (IOException e) {
+ // throw SigilCore.newCoreException("Failed to open source zip" + sourceZip.toFile(), e);
+ // }
+ // finally {
+ // if ( zip != null ) {
+ // try {
+ // zip.close();
+ // }
+ // catch (IOException e) {
+ // SigilCore.error( "Failed to close src zip", e);
+ // }
+ // }
+ // }
+ //
+ // return path;
+ // }
+
+ // private Collection<IPath> findNewtonJars( ILaunchConfiguration configuration ) throws CoreException {
+ // ArrayList<IPath> paths = new ArrayList<IPath>();
+ //
+ // INewtonInstall install = NewtonLaunchConfigurationHelper.getNewtonInstall(configuration);
+ //
+ // for ( IPath path : install.getType().getDefaultBundleLocations() ) {
+ // paths.add(path);
+ // }
+ //
+ // return paths;
+ // }
+
+ // private IPath findSourcePath( ILaunchConfiguration configuration ) throws CoreException {
+ // INewtonInstall install = NewtonLaunchConfigurationHelper.getNewtonInstall(configuration);
+ // return install.getType().getSourceLocation();
+ // }
}
diff --git a/sigil/eclipse/search/src/org/apache/felix/sigil/search/ISearchResult.java b/sigil/eclipse/search/src/org/apache/felix/sigil/search/ISearchResult.java
index e22df6c..568ada8 100644
--- a/sigil/eclipse/search/src/org/apache/felix/sigil/search/ISearchResult.java
+++ b/sigil/eclipse/search/src/org/apache/felix/sigil/search/ISearchResult.java
@@ -19,21 +19,16 @@
package org.apache.felix.sigil.search;
-
import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
import org.apache.felix.sigil.common.model.osgi.IPackageExport;
-
public interface ISearchResult
{
ISigilBundle getProvider();
-
IPackageExport getExport();
-
String getPackageName();
-
String getClassName();
}
diff --git a/sigil/eclipse/search/src/org/apache/felix/sigil/search/SigilSearch.java b/sigil/eclipse/search/src/org/apache/felix/sigil/search/SigilSearch.java
index d850579..316785c 100644
--- a/sigil/eclipse/search/src/org/apache/felix/sigil/search/SigilSearch.java
+++ b/sigil/eclipse/search/src/org/apache/felix/sigil/search/SigilSearch.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.search;
-
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
@@ -53,7 +52,6 @@
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
-
/**
* The activator class controls the plug-in life cycle
*/
@@ -69,7 +67,6 @@
private static SigilSearch plugin;
private static Index index;
-
/**
* The constructor
*/
@@ -77,45 +74,40 @@
{
}
-
- public static List<ISearchResult> findProviders( String fullyQualifiedName, ISigilProjectModel sigil,
- IProgressMonitor monitor )
+ public static List<ISearchResult> findProviders(String fullyQualifiedName,
+ ISigilProjectModel sigil, IProgressMonitor monitor)
{
- listen( sigil );
- return index.findProviders( fullyQualifiedName, monitor );
+ listen(sigil);
+ return index.findProviders(fullyQualifiedName, monitor);
}
-
- public static List<ISearchResult> findProviders( Pattern namePattern, ISigilProjectModel sigil,
- IProgressMonitor monitor )
+ public static List<ISearchResult> findProviders(Pattern namePattern,
+ ISigilProjectModel sigil, IProgressMonitor monitor)
{
- listen( sigil );
- return index.findProviders( namePattern, monitor );
+ listen(sigil);
+ return index.findProviders(namePattern, monitor);
}
-
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
- public void start( BundleContext context ) throws Exception
+ public void start(BundleContext context) throws Exception
{
- super.start( context );
+ super.start(context);
plugin = this;
}
-
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
- public void stop( BundleContext context ) throws Exception
+ public void stop(BundleContext context) throws Exception
{
plugin = null;
- super.stop( context );
+ super.stop(context);
}
-
/**
* Returns the shared instance
*
@@ -126,156 +118,157 @@
return plugin;
}
-
- private static void listen( ISigilProjectModel sigil )
+ private static void listen(ISigilProjectModel sigil)
{
- synchronized ( plugin )
+ synchronized (plugin)
{
- if ( index == null )
+ if (index == null)
{
index = new Index();
- for ( IBundleRepository rep : SigilCore.getRepositoryManager( sigil ).getRepositories() )
+ for (IBundleRepository rep : SigilCore.getRepositoryManager(sigil).getRepositories())
{
- index( index, rep );
+ index(index, rep);
}
- SigilCore.getRepositoryManager( sigil ).addRepositoryChangeListener( new IRepositoryChangeListener()
- {
- public void repositoryChanged( RepositoryChangeEvent event )
+ SigilCore.getRepositoryManager(sigil).addRepositoryChangeListener(
+ new IRepositoryChangeListener()
{
- index( index, event.getRepository() );
- }
- } );
+ public void repositoryChanged(RepositoryChangeEvent event)
+ {
+ index(index, event.getRepository());
+ }
+ });
}
}
}
-
- private static void index( final Index index, final IBundleRepository rep )
+ private static void index(final Index index, final IBundleRepository rep)
{
- index.delete( rep );
- rep.accept( new IRepositoryVisitor()
+ index.delete(rep);
+ rep.accept(new IRepositoryVisitor()
{
- public boolean visit( ISigilBundle bundle )
+ public boolean visit(ISigilBundle bundle)
{
- ISigilProjectModel p = bundle.getAncestor( ISigilProjectModel.class );
- if ( p == null )
+ ISigilProjectModel p = bundle.getAncestor(ISigilProjectModel.class);
+ if (p == null)
{
- if ( bundle.isSynchronized() )
+ if (bundle.isSynchronized())
{
IPath loc = PathUtil.newPathIfExists(bundle.getLocation());
- if ( loc == null ) {
+ if (loc == null)
+ {
SigilCore.error("Location is null for " + bundle);
}
- else {
- if ( loc.isAbsolute() )
+ else
+ {
+ if (loc.isAbsolute())
{
- indexJar( rep, bundle, loc );
+ indexJar(rep, bundle, loc);
}
}
}
}
else
{
- indexProject( rep, p );
+ indexProject(rep, p);
}
return true;
}
- } );
+ });
}
-
- private static void indexProject( IBundleRepository rep, ISigilProjectModel sigil )
+ private static void indexProject(IBundleRepository rep, ISigilProjectModel sigil)
{
try
{
- for ( ICompilationUnit unit : JavaHelper.findCompilationUnits( sigil ) )
+ for (ICompilationUnit unit : JavaHelper.findCompilationUnits(sigil))
{
- IPackageFragment p = ( IPackageFragment ) unit.getParent();
+ IPackageFragment p = (IPackageFragment) unit.getParent();
ISigilBundle b = sigil.getBundle();
- IPackageExport export = b.findExport( p.getElementName() );
- index.addEntry( unit, rep, b, export != null );
+ IPackageExport export = b.findExport(p.getElementName());
+ index.addEntry(unit, rep, b, export != null);
}
}
- catch ( JavaModelException e )
+ catch (JavaModelException e)
{
- SigilCore.error( "Failed to index project", e);
+ SigilCore.error("Failed to index project", e);
}
}
-
- private static void indexJar( IBundleRepository rep, ISigilBundle bundle, IPath loc )
+ private static void indexJar(IBundleRepository rep, ISigilBundle bundle, IPath loc)
{
JarFile jar = null;
try
{
- jar = new JarFile( loc.toOSString() );
- for ( Map.Entry<JarEntry, IPackageExport> export : findExportedClasses( bundle, jar ).entrySet() )
+ jar = new JarFile(loc.toOSString());
+ for (Map.Entry<JarEntry, IPackageExport> export : findExportedClasses(bundle,
+ jar).entrySet())
{
JarEntry entry = export.getKey();
InputStream in = null;
try
{
- in = jar.getInputStream( entry );
- ClassParser parser = new ClassParser( in, entry.getName() );
+ in = jar.getInputStream(entry);
+ ClassParser parser = new ClassParser(in, entry.getName());
JavaClass c = parser.parse();
- index.addEntry( c, rep, bundle, true );
+ index.addEntry(c, rep, bundle, true);
}
finally
{
- if ( in != null )
+ if (in != null)
{
in.close();
}
}
}
}
- catch ( IOException e )
+ catch (IOException e)
{
- SigilCore.error( "Failed to read jar " + loc, e );
+ SigilCore.error("Failed to read jar " + loc, e);
}
finally
{
- if ( jar != null )
+ if (jar != null)
{
try
{
jar.close();
}
- catch ( IOException e )
+ catch (IOException e)
{
- SigilCore.error( "Failed to close jar " + loc, e );
+ SigilCore.error("Failed to close jar " + loc, e);
}
}
}
}
-
- private static Map<JarEntry, IPackageExport> findExportedClasses( ISigilBundle bundle, JarFile jar )
+ private static Map<JarEntry, IPackageExport> findExportedClasses(ISigilBundle bundle,
+ JarFile jar)
{
HashMap<JarEntry, IPackageExport> found = new HashMap<JarEntry, IPackageExport>();
- IPackageExport[] exports = bundle.getBundleInfo().childrenOfType( IPackageExport.class );
- if ( exports.length > 0 )
+ IPackageExport[] exports = bundle.getBundleInfo().childrenOfType(
+ IPackageExport.class);
+ if (exports.length > 0)
{
- Arrays.sort( exports, new Comparator<IPackageExport>()
+ Arrays.sort(exports, new Comparator<IPackageExport>()
{
- public int compare( IPackageExport o1, IPackageExport o2 )
+ public int compare(IPackageExport o1, IPackageExport o2)
{
- return -1 * o1.compareTo( o2 );
+ return -1 * o1.compareTo(o2);
}
- } );
- for ( Enumeration<JarEntry> e = jar.entries(); e.hasMoreElements(); )
+ });
+ for (Enumeration<JarEntry> e = jar.entries(); e.hasMoreElements();)
{
JarEntry entry = e.nextElement();
- String className = toClassName( entry );
- if ( className != null )
+ String className = toClassName(entry);
+ if (className != null)
{
- IPackageExport ex = findExport( className, exports );
+ IPackageExport ex = findExport(className, exports);
- if ( found != null )
+ if (found != null)
{
- found.put( entry, ex );
+ found.put(entry, ex);
}
}
}
@@ -284,12 +277,11 @@
return found;
}
-
- private static IPackageExport findExport( String className, IPackageExport[] exports )
+ private static IPackageExport findExport(String className, IPackageExport[] exports)
{
- for ( IPackageExport e : exports )
+ for (IPackageExport e : exports)
{
- if ( className.startsWith( e.getPackageName() ) )
+ if (className.startsWith(e.getPackageName()))
{
return e;
}
@@ -297,14 +289,13 @@
return null;
}
-
- private static String toClassName( JarEntry entry )
+ private static String toClassName(JarEntry entry)
{
String name = entry.getName();
- if ( name.endsWith( CLASS_EXTENSION ) )
+ if (name.endsWith(CLASS_EXTENSION))
{
- name = name.substring( 0, name.length() - CLASS_EXTENSION.length() );
- name = name.replace( '/', '.' );
+ name = name.substring(0, name.length() - CLASS_EXTENSION.length());
+ name = name.replace('/', '.');
return name;
}
else
diff --git a/sigil/eclipse/search/src/org/apache/felix/sigil/search/index/Index.java b/sigil/eclipse/search/src/org/apache/felix/sigil/search/index/Index.java
index 7427b65..8d20b27 100644
--- a/sigil/eclipse/search/src/org/apache/felix/sigil/search/index/Index.java
+++ b/sigil/eclipse/search/src/org/apache/felix/sigil/search/index/Index.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.search.index;
-
import java.lang.ref.SoftReference;
import java.util.Collections;
import java.util.HashMap;
@@ -45,7 +44,6 @@
import org.eclipse.jdt.core.IPackageFragment;
import org.osgi.framework.Version;
-
public class Index
{
private HashMap<String, ClassData> primary = new HashMap<String, ClassData>();
@@ -57,38 +55,34 @@
{
HashMap<IBundleRepository, Set<ISearchResult>> provided = new HashMap<IBundleRepository, Set<ISearchResult>>();
-
- void add( IBundleRepository rep, ISearchResult export )
+ void add(IBundleRepository rep, ISearchResult export)
{
- Set<ISearchResult> exports = provided.get( rep );
+ Set<ISearchResult> exports = provided.get(rep);
- if ( exports == null )
+ if (exports == null)
{
exports = new HashSet<ISearchResult>();
- provided.put( rep, exports );
+ provided.put(rep, exports);
}
- exports.add( export );
+ exports.add(export);
}
-
List<ISearchResult> getResults()
{
LinkedList<ISearchResult> exports = new LinkedList<ISearchResult>();
- for ( Set<ISearchResult> p : provided.values() )
+ for (Set<ISearchResult> p : provided.values())
{
- exports.addAll( p );
+ exports.addAll(p);
}
return exports;
}
-
- void remove( IBundleRepository rep )
+ void remove(IBundleRepository rep)
{
- provided.remove( rep );
+ provided.remove(rep);
}
-
boolean isEmpty()
{
return provided.isEmpty();
@@ -107,9 +101,7 @@
private SoftReference<ISigilBundle> bundleReference;
private SoftReference<IPackageExport> exportReference;
-
- public SearchResult( String className, IBundleRepository rep, ISigilBundle bundle, String packageName,
- boolean exported )
+ public SearchResult(String className, IBundleRepository rep, ISigilBundle bundle, String packageName, boolean exported)
{
this.className = className;
this.rep = rep;
@@ -119,99 +111,97 @@
this.packageName = packageName;
}
-
public String getClassName()
{
return className;
}
-
public String getPackageName()
{
return packageName;
}
-
public IPackageExport getExport()
{
IPackageExport ipe = null;
- if ( exported )
+ if (exported)
{
ipe = exportReference == null ? null : exportReference.get();
- if ( ipe == null )
+ if (ipe == null)
{
- ipe = getProvider().findExport( packageName );
- exportReference = new SoftReference<IPackageExport>( ipe );
+ ipe = getProvider().findExport(packageName);
+ exportReference = new SoftReference<IPackageExport>(ipe);
}
}
return ipe;
}
-
public ISigilBundle getProvider()
{
ISigilBundle b = bundleReference == null ? null : bundleReference.get();
- if ( b == null )
+ if (b == null)
{
- IRequiredBundle rb = ModelElementFactory.getInstance().newModelElement( IRequiredBundle.class );
- rb.setSymbolicName( bundleSymbolicName );
- VersionRange versions = new VersionRange( false, version, version, false );
- rb.setVersions( versions );
- b = rep.findProvider( rb, 0 );
- bundleReference = new SoftReference<ISigilBundle>( b );
+ IRequiredBundle rb = ModelElementFactory.getInstance().newModelElement(
+ IRequiredBundle.class);
+ rb.setSymbolicName(bundleSymbolicName);
+ VersionRange versions = new VersionRange(false, version, version, false);
+ rb.setVersions(versions);
+ b = rep.findProvider(rb, 0);
+ bundleReference = new SoftReference<ISigilBundle>(b);
}
return b;
}
}
-
- public void addEntry( JavaClass c, IBundleRepository rep, ISigilBundle bundle, boolean exported )
+ public void addEntry(JavaClass c, IBundleRepository rep, ISigilBundle bundle,
+ boolean exported)
{
- addEntry( c.getClassName(), rep, bundle, c.getPackageName(), exported );
+ addEntry(c.getClassName(), rep, bundle, c.getPackageName(), exported);
}
-
- public void addEntry( ICompilationUnit unit, IBundleRepository rep, ISigilBundle bundle, boolean exported )
+ public void addEntry(ICompilationUnit unit, IBundleRepository rep,
+ ISigilBundle bundle, boolean exported)
{
String name = unit.getElementName();
- if ( name.endsWith( ".java" ) )
+ if (name.endsWith(".java"))
{
- name = name.substring( 0, name.length() - 5 );
+ name = name.substring(0, name.length() - 5);
}
- IPackageFragment p = ( IPackageFragment ) unit.getAncestor( IJavaElement.PACKAGE_FRAGMENT );
- addEntry( p.getElementName() + "." + name, rep, bundle, p.getElementName(), exported );
+ IPackageFragment p = (IPackageFragment) unit.getAncestor(IJavaElement.PACKAGE_FRAGMENT);
+ addEntry(p.getElementName() + "." + name, rep, bundle, p.getElementName(),
+ exported);
}
-
- private void addEntry( String className, IBundleRepository rep, ISigilBundle bundle, String packageName,
- boolean exported )
+ private void addEntry(String className, IBundleRepository rep, ISigilBundle bundle,
+ String packageName, boolean exported)
{
- List<String> keys = genKeys( className );
+ List<String> keys = genKeys(className);
lock.writeLock().lock();
try
{
- for ( String key : keys )
+ for (String key : keys)
{
- ClassData data = primary.get( key );
+ ClassData data = primary.get(key);
- if ( data == null )
+ if (data == null)
{
data = new ClassData();
- primary.put( key, data );
+ primary.put(key, data);
}
- SearchResult result = new SearchResult( className, rep, bundle, packageName, exported );
- data.add( rep, result );
+ SearchResult result = new SearchResult(className, rep, bundle,
+ packageName, exported);
+ data.add(rep, result);
}
- HashSet<String> all = secondary.get( rep );
- if ( all == null )
+ HashSet<String> all = secondary.get(rep);
+ if (all == null)
{
all = new HashSet<String>();
- secondary.put( rep, all );
+ secondary.put(rep, all);
}
- all.addAll( keys );
+ all.addAll(keys);
}
finally
{
@@ -219,14 +209,14 @@
}
}
-
- public List<ISearchResult> findProviders( String className, IProgressMonitor monitor )
+ public List<ISearchResult> findProviders(String className, IProgressMonitor monitor)
{
lock.readLock().lock();
try
{
- ClassData data = primary.get( className );
- return data == null ? Collections.<ISearchResult> emptyList() : data.getResults();
+ ClassData data = primary.get(className);
+ return data == null ? Collections.<ISearchResult> emptyList()
+ : data.getResults();
}
finally
{
@@ -234,14 +224,14 @@
}
}
-
- public List<ISearchResult> findProviders( Pattern className, IProgressMonitor monitor )
+ public List<ISearchResult> findProviders(Pattern className, IProgressMonitor monitor)
{
lock.readLock().lock();
try
{
- ClassData data = primary.get( className );
- return data == null ? Collections.<ISearchResult> emptyList() : data.getResults();
+ ClassData data = primary.get(className);
+ return data == null ? Collections.<ISearchResult> emptyList()
+ : data.getResults();
}
finally
{
@@ -249,22 +239,21 @@
}
}
-
- public void delete( IBundleRepository rep )
+ public void delete(IBundleRepository rep)
{
lock.writeLock().lock();
try
{
- Set<String> keys = secondary.remove( rep );
- if ( keys != null )
+ Set<String> keys = secondary.remove(rep);
+ if (keys != null)
{
- for ( String key : keys )
+ for (String key : keys)
{
- ClassData data = primary.get( key );
- data.remove( rep );
- if ( data.isEmpty() )
+ ClassData data = primary.get(key);
+ data.remove(rep);
+ if (data.isEmpty())
{
- primary.remove( key );
+ primary.remove(key);
}
}
}
@@ -275,16 +264,15 @@
}
}
-
- private List<String> genKeys( String className )
+ private List<String> genKeys(String className)
{
LinkedList<String> keys = new LinkedList<String>();
- keys.add( className );
- int i = className.lastIndexOf( '.' );
- if ( i != -1 )
+ keys.add(className);
+ int i = className.lastIndexOf('.');
+ if (i != -1)
{
- String name = className.substring( i + 1 );
- keys.add( name );
+ String name = className.substring(i + 1);
+ keys.add(name);
}
return keys;
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/SigilUI.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/SigilUI.java
index ccd3191..9b427f9 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/SigilUI.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/SigilUI.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui;
-
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.util.Locale;
@@ -39,7 +38,6 @@
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
-
/**
* The activator class controls the plug-in life cycle
*/
@@ -56,13 +54,12 @@
public static final String ID_REPOSITORY_VIEW = "org.apache.felix.sigil.ui.repositoryBrowser";
public static final String ID_DEPENDENCY_VIEW = "org.apache.felix.sigil.ui.bundleDependencyView";
-
+
public static final String WORKSPACE_REPOSITORY_ID = "org.apache.felix.sigil.core.workspaceprovider";
// The shared instance
private static SigilUI plugin;
-
/**
* The constructor
*/
@@ -70,30 +67,27 @@
{
}
-
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
- public void start( BundleContext context ) throws Exception
+ public void start(BundleContext context) throws Exception
{
- super.start( context );
+ super.start(context);
SigilCore.getDefault();
plugin = this;
}
-
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
- public void stop( BundleContext context ) throws Exception
+ public void stop(BundleContext context) throws Exception
{
plugin = null;
- super.stop( context );
+ super.stop(context);
}
-
/**
* Returns the shared instance
*
@@ -104,81 +98,76 @@
return plugin;
}
-
public static ResourceBundle getResourceBundle()
{
- return ResourceBundle.getBundle( "resources." + SigilUI.class.getName(), Locale.getDefault(), SigilUI.class
- .getClassLoader() );
+ return ResourceBundle.getBundle("resources." + SigilUI.class.getName(),
+ Locale.getDefault(), SigilUI.class.getClassLoader());
}
-
- public static void runWorkspaceOperation( IRunnableWithProgress op, Shell shell )
+ public static void runWorkspaceOperation(IRunnableWithProgress op, Shell shell)
{
- if ( shell == null )
+ if (shell == null)
{
shell = getActiveWorkbenchShell();
}
try
{
- new ProgressMonitorDialog( shell ).run( true, true, op );
+ new ProgressMonitorDialog(shell).run(true, true, op);
}
- catch ( InvocationTargetException e )
+ catch (InvocationTargetException e)
{
- SigilCore.error( "Workspace operation failed", e );
+ SigilCore.error("Workspace operation failed", e);
}
- catch ( InterruptedException e1 )
+ catch (InterruptedException e1)
{
- SigilCore.log( "Workspace operation interrupted" );
+ SigilCore.log("Workspace operation interrupted");
}
}
-
- public static void runWorkspaceOperationSync( IRunnableWithProgress op, Shell shell ) throws Throwable
+ public static void runWorkspaceOperationSync(IRunnableWithProgress op, Shell shell)
+ throws Throwable
{
- if ( shell == null )
+ if (shell == null)
{
shell = getActiveWorkbenchShell();
}
try
{
- new ProgressMonitorDialog( shell ).run( false, true, op );
+ new ProgressMonitorDialog(shell).run(false, true, op);
}
- catch ( InvocationTargetException e )
+ catch (InvocationTargetException e)
{
throw e.getCause();
}
- catch ( InterruptedException e1 )
+ catch (InterruptedException e1)
{
- SigilCore.log( "Workspace operation interrupted" );
+ SigilCore.log("Workspace operation interrupted");
}
}
-
public static IWorkbenchWindow getActiveWorkbenchWindow()
{
return getDefault().getWorkbench().getActiveWorkbenchWindow();
}
-
public static Shell getActiveWorkbenchShell()
{
final Shell[] shell = new Shell[1];
- runInUISync( new Runnable()
+ runInUISync(new Runnable()
{
public void run()
{
shell[0] = getActiveDisplay().getActiveShell();
}
- } );
+ });
return shell[0];
}
-
public static Display getActiveDisplay()
{
Display d = Display.getCurrent();
- if ( d == null )
+ if (d == null)
{
d = Display.getDefault();
}
@@ -186,10 +175,9 @@
return d;
}
-
- public static void runInUI( Runnable runnable )
+ public static void runInUI(Runnable runnable)
{
- getActiveDisplay().asyncExec( runnable );
+ getActiveDisplay().asyncExec(runnable);
}
@SuppressWarnings("unchecked")
@@ -197,7 +185,8 @@
{
final Object[] result = new Object[1];
final Exception[] exception = new Exception[1];
- runInUISync(new Runnable() {
+ runInUISync(new Runnable()
+ {
public void run()
{
try
@@ -209,50 +198,49 @@
exception[0] = e;
}
}
-
+
});
- if ( exception[0] == null ) {
+ if (exception[0] == null)
+ {
return (T) result[0];
}
- else {
+ else
+ {
throw exception[0];
}
}
-
- public static void runInUISync( Runnable runnable )
+ public static void runInUISync(Runnable runnable)
{
- getActiveDisplay().syncExec( runnable );
+ getActiveDisplay().syncExec(runnable);
}
-
- public static Image cacheImage( String path, ClassLoader classLoader )
+ public static Image cacheImage(String path, ClassLoader classLoader)
{
ImageRegistry registry = SigilUI.getDefault().getImageRegistry();
- Image image = registry.get( path );
+ Image image = registry.get(path);
- if ( image == null )
+ if (image == null)
{
- image = loadImage( path, classLoader );
+ image = loadImage(path, classLoader);
// XXX-FIXME-XXX add null image
- if ( image != null )
+ if (image != null)
{
- registry.put( path, image );
+ registry.put(path, image);
}
}
return image;
}
-
- private static Image loadImage( String resource, ClassLoader loader )
+ private static Image loadImage(String resource, ClassLoader loader)
{
- InputStream in = loader.getResourceAsStream( resource );
- if ( in != null )
+ InputStream in = loader.getResourceAsStream(resource);
+ if (in != null)
{
- ImageData data = new ImageData( in );
- return new Image( SigilUI.getActiveDisplay(), data );
+ ImageData data = new ImageData(in);
+ return new Image(SigilUI.getActiveDisplay(), data);
}
else
{
@@ -260,5 +248,4 @@
}
}
-
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/DisplayAction.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/DisplayAction.java
index 36ceb93..e40b86d 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/DisplayAction.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/DisplayAction.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.actions;
-
import org.eclipse.jface.action.Action;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.resource.ImageDescriptor;
@@ -27,7 +26,6 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
-
public abstract class DisplayAction extends Action
{
@@ -36,30 +34,26 @@
super();
}
-
- public DisplayAction( String text )
+ public DisplayAction(String text)
{
- super( text );
+ super(text);
}
-
- public DisplayAction( String text, ImageDescriptor image )
+ public DisplayAction(String text, ImageDescriptor image)
{
- super( text, image );
+ super(text, image);
}
-
- public DisplayAction( String text, int style )
+ public DisplayAction(String text, int style)
{
- super( text, style );
+ super(text, style);
}
-
protected Display findDisplay()
{
Display d = Display.getCurrent();
- if ( d == null )
+ if (d == null)
{
d = Display.getDefault();
}
@@ -67,21 +61,19 @@
return d;
}
-
- protected void runInUI( final Shell shell, final WorkspaceModifyOperation op )
+ protected void runInUI(final Shell shell, final WorkspaceModifyOperation op)
{
}
-
- protected void info( final Shell shell, final String msg )
+ protected void info(final Shell shell, final String msg)
{
- shell.getDisplay().asyncExec( new Runnable()
+ shell.getDisplay().asyncExec(new Runnable()
{
public void run()
{
- MessageDialog.openInformation( shell, "Information", msg );
+ MessageDialog.openInformation(shell, "Information", msg);
}
- } );
+ });
}
}
\ No newline at end of file
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/PruneProjectDependenciesAction.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/PruneProjectDependenciesAction.java
index 29535b5..d3715c0 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/PruneProjectDependenciesAction.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/PruneProjectDependenciesAction.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.actions;
-
import java.util.Collection;
import org.apache.felix.sigil.common.model.IModelElement;
@@ -39,68 +38,68 @@
import org.eclipse.ui.actions.WorkspaceModifyOperation;
import org.eclipse.ui.progress.IProgressService;
-
public class PruneProjectDependenciesAction extends DisplayAction
{
private ISigilProjectModel project;
-
- public PruneProjectDependenciesAction( ISigilProjectModel project )
+ public PruneProjectDependenciesAction(ISigilProjectModel project)
{
this.project = project;
}
-
@Override
public void run()
{
final Shell shell = findDisplay().getActiveShell();
- Job job = new Job( "Resolving imports" )
+ Job job = new Job("Resolving imports")
{
@Override
- protected IStatus run( IProgressMonitor monitor )
+ protected IStatus run(IProgressMonitor monitor)
{
- Collection<IModelElement> unused = JavaHelper.findUnusedReferences( project, monitor );
+ Collection<IModelElement> unused = JavaHelper.findUnusedReferences(
+ project, monitor);
- if ( unused.isEmpty() )
+ if (unused.isEmpty())
{
- info( shell, "No unused references found" );
+ info(shell, "No unused references found");
}
else
{
- final ResourceReviewDialog<IModelElement> dialog = new ResourceReviewDialog<IModelElement>( shell,
- "Review Unused Imports", unused );
+ final ResourceReviewDialog<IModelElement> dialog = new ResourceReviewDialog<IModelElement>(
+ shell, "Review Unused Imports", unused);
- shell.getDisplay().asyncExec( new Runnable()
+ shell.getDisplay().asyncExec(new Runnable()
{
public void run()
{
- if ( dialog.open() == Window.OK )
+ if (dialog.open() == Window.OK)
{
WorkspaceModifyOperation op = new WorkspaceModifyOperation()
{
@Override
- protected void execute( IProgressMonitor monitor ) throws CoreException
+ protected void execute(IProgressMonitor monitor)
+ throws CoreException
{
- for ( IModelElement e : dialog.getResources() )
+ for (IModelElement e : dialog.getResources())
{
- if ( !project.getBundle().getBundleInfo().removeChild( e ) )
+ if (!project.getBundle().getBundleInfo().removeChild(
+ e))
{
- SigilCore.error( "Failed to remove " + e );
+ SigilCore.error("Failed to remove " + e);
}
}
- project.save( monitor );
+ project.save(monitor);
}
};
- SigilUI.runWorkspaceOperation( op, shell );
+ SigilUI.runWorkspaceOperation(op, shell);
}
}
- } );
+ });
}
return Status.OK_STATUS;
@@ -110,6 +109,6 @@
job.schedule();
IProgressService p = PlatformUI.getWorkbench().getProgressService();
- p.showInDialog( shell, job );
+ p.showInDialog(shell, job);
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/RefreshRepositoryAction.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/RefreshRepositoryAction.java
index 54be687..c737c2f 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/RefreshRepositoryAction.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/RefreshRepositoryAction.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.actions;
-
import java.lang.reflect.InvocationTargetException;
import java.util.List;
@@ -33,19 +32,16 @@
import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
-
public class RefreshRepositoryAction extends DisplayAction
{
private final IRepositoryModel[] model;
-
- public RefreshRepositoryAction( IRepositoryModel... model )
+ public RefreshRepositoryAction(IRepositoryModel... model)
{
- super( "Refresh repository" );
+ super("Refresh repository");
this.model = model;
}
-
@Override
public void run()
{
@@ -53,16 +49,16 @@
{
@Override
- protected void execute( IProgressMonitor monitor ) throws CoreException, InvocationTargetException,
- InterruptedException
+ protected void execute(IProgressMonitor monitor) throws CoreException,
+ InvocationTargetException, InterruptedException
{
boolean changed = false;
- for ( IBundleRepository b : SigilCore.getGlobalRepositoryManager().getRepositories() )
+ for (IBundleRepository b : SigilCore.getGlobalRepositoryManager().getRepositories())
{
- for ( IRepositoryModel m : model )
+ for (IRepositoryModel m : model)
{
- if ( b.getId().equals( m.getId() ) )
+ if (b.getId().equals(m.getId()))
{
b.refresh();
changed = true;
@@ -70,18 +66,18 @@
}
}
- if ( changed )
+ if (changed)
{
List<ISigilProjectModel> projects = SigilCore.getRoot().getProjects();
- SubMonitor sub = SubMonitor.convert( monitor, projects.size() * 10 );
- for ( ISigilProjectModel p : projects )
+ SubMonitor sub = SubMonitor.convert(monitor, projects.size() * 10);
+ for (ISigilProjectModel p : projects)
{
- p.resetClasspath( sub.newChild( 10 ) );
+ p.resetClasspath(sub.newChild(10));
}
}
}
};
- SigilUI.runWorkspaceOperation( op, null );
+ SigilUI.runWorkspaceOperation(op, null);
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/ResolveProjectDependenciesAction.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/ResolveProjectDependenciesAction.java
index 9f1ed6e..413281e 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/ResolveProjectDependenciesAction.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/actions/ResolveProjectDependenciesAction.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.actions;
-
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
@@ -40,83 +39,84 @@
import org.eclipse.ui.actions.WorkspaceModifyOperation;
import org.eclipse.ui.progress.IProgressService;
-
public class ResolveProjectDependenciesAction extends DisplayAction
{
private ISigilProjectModel project;
private boolean review;
-
- public ResolveProjectDependenciesAction( ISigilProjectModel project, boolean review )
+ public ResolveProjectDependenciesAction(ISigilProjectModel project, boolean review)
{
this.project = project;
this.review = review;
}
-
public void run()
{
final Shell shell = findDisplay().getActiveShell();
- Job job = new Job( "Resolving dependencies" )
+ Job job = new Job("Resolving dependencies")
{
@Override
- protected IStatus run( IProgressMonitor monitor )
+ protected IStatus run(IProgressMonitor monitor)
{
- monitor.beginTask( "", IProgressMonitor.UNKNOWN );
+ monitor.beginTask("", IProgressMonitor.UNKNOWN);
- List<IPackageImport> imports = JavaHelper.findRequiredImports( project, monitor );
+ List<IPackageImport> imports = JavaHelper.findRequiredImports(project,
+ monitor);
- if ( imports.isEmpty() )
+ if (imports.isEmpty())
{
- info( shell, "No new dependencies found" );
+ info(shell, "No new dependencies found");
}
else
{
- Collections.sort( imports, new Comparator<IPackageImport>()
+ Collections.sort(imports, new Comparator<IPackageImport>()
{
- public int compare( IPackageImport o1, IPackageImport o2 )
+ public int compare(IPackageImport o1, IPackageImport o2)
{
- int i = o1.getPackageName().compareTo( o2.getPackageName() );
+ int i = o1.getPackageName().compareTo(o2.getPackageName());
// shouldn't get more than one import for same package
// but may as well sort if do...
- if ( i == 0 )
+ if (i == 0)
{
- i = o1.getVersions().getFloor().compareTo( o2.getVersions().getFloor() );
+ i = o1.getVersions().getFloor().compareTo(
+ o2.getVersions().getFloor());
}
return i;
}
- } );
+ });
final ResourceReviewDialog<IPackageImport> dialog = new ResourceReviewDialog<IPackageImport>(
- shell, "Review New Dependencies", imports );
- shell.getDisplay().asyncExec( new Runnable()
+ shell, "Review New Dependencies", imports);
+ shell.getDisplay().asyncExec(new Runnable()
{
public void run()
{
- if ( !review || dialog.open() == Window.OK )
+ if (!review || dialog.open() == Window.OK)
{
WorkspaceModifyOperation op = new WorkspaceModifyOperation()
{
@Override
- protected void execute( IProgressMonitor monitor ) throws CoreException
+ protected void execute(IProgressMonitor monitor)
+ throws CoreException
{
- for ( IPackageImport pi : dialog.getResources() )
+ for (IPackageImport pi : dialog.getResources())
{
- project.getBundle().getBundleInfo().addImport( pi );
+ project.getBundle().getBundleInfo().addImport(
+ pi);
}
- project.save( monitor );
+ project.save(monitor);
}
};
- SigilUI.runWorkspaceOperation( op, shell );
+ SigilUI.runWorkspaceOperation(op, shell);
}
}
- } );
+ });
}
return Status.OK_STATUS;
@@ -126,7 +126,7 @@
job.schedule();
IProgressService p = PlatformUI.getWorkbench().getProgressService();
- p.showInDialog( shell, job );
+ p.showInDialog(shell, job);
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/classpath/SigilClassPathContainer.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/classpath/SigilClassPathContainer.java
index 236dbbd..3edab69 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/classpath/SigilClassPathContainer.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/classpath/SigilClassPathContainer.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.classpath;
-
import org.apache.felix.sigil.eclipse.SigilCore;
import org.apache.felix.sigil.eclipse.job.ThreadProgressMonitor;
import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
@@ -30,7 +29,6 @@
import org.eclipse.jdt.core.IClasspathContainer;
import org.eclipse.jdt.core.IClasspathEntry;
-
/**
* @author dave
*
@@ -41,19 +39,17 @@
private IClasspathEntry[] entries;
private ISigilProjectModel sigil;
-
- public SigilClassPathContainer( ISigilProjectModel sigil )
+ public SigilClassPathContainer(ISigilProjectModel sigil)
{
this.sigil = sigil;
}
-
/* (non-Javadoc)
* @see org.eclipse.jdt.core.IClasspathContainer#getClasspathEntries()
*/
public IClasspathEntry[] getClasspathEntries()
{
- if ( entries == null )
+ if (entries == null)
{
buildClassPathEntries();
}
@@ -61,7 +57,6 @@
return entries;
}
-
/* (non-Javadoc)
* @see org.eclipse.jdt.core.IClasspathContainer#getDescription()
*/
@@ -70,7 +65,6 @@
return "Bundle Context Classpath";
}
-
/* (non-Javadoc)
* @see org.eclipse.jdt.core.IClasspathContainer#getKind()
*/
@@ -79,16 +73,14 @@
return K_SYSTEM;
}
-
/* (non-Javadoc)
* @see org.eclipse.jdt.core.IClasspathContainer#getPath()
*/
public IPath getPath()
{
- return new Path( SigilCore.CLASSPATH_CONTAINER_PATH );
+ return new Path(SigilCore.CLASSPATH_CONTAINER_PATH);
}
-
/**
* @return
* @throws CoreException
@@ -99,18 +91,17 @@
try
{
IProgressMonitor monitor = ThreadProgressMonitor.getProgressMonitor();
- entries = sigil.findExternalClasspath( monitor ).toArray( new IClasspathEntry[0] );
+ entries = sigil.findExternalClasspath(monitor).toArray(new IClasspathEntry[0]);
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- SigilCore.error( "Failed to build classpath entries", e );
+ SigilCore.error("Failed to build classpath entries", e);
}
finally
{
- if ( entries == null )
+ if (entries == null)
{
- entries = new IClasspathEntry[]
- {};
+ entries = new IClasspathEntry[] {};
}
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/classpath/SigilClasspathContainerInitializer.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/classpath/SigilClasspathContainerInitializer.java
index 03f196f..46e66b5 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/classpath/SigilClasspathContainerInitializer.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/classpath/SigilClasspathContainerInitializer.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.classpath;
-
import org.apache.felix.sigil.eclipse.SigilCore;
import org.apache.felix.sigil.eclipse.job.*;
import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
@@ -32,7 +31,6 @@
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
-
public class SigilClasspathContainerInitializer extends ClasspathContainerInitializer
{
@@ -41,55 +39,52 @@
// TODO Auto-generated constructor stub
}
-
@Override
- public boolean canUpdateClasspathContainer( IPath containerPath, IJavaProject project )
+ public boolean canUpdateClasspathContainer(IPath containerPath, IJavaProject project)
{
return true;
}
-
@Override
- public void requestClasspathContainerUpdate( IPath containerPath, IJavaProject project,
- IClasspathContainer containerSuggestion ) throws CoreException
+ public void requestClasspathContainerUpdate(IPath containerPath,
+ IJavaProject project, IClasspathContainer containerSuggestion)
+ throws CoreException
{
- ISigilProjectModel sigil = SigilCore.create( project.getProject() );
+ ISigilProjectModel sigil = SigilCore.create(project.getProject());
- IClasspathContainer sigilContainer = new SigilClassPathContainer( sigil );
+ IClasspathContainer sigilContainer = new SigilClassPathContainer(sigil);
- IJavaProject[] affectedProjects = new IJavaProject[]
- { project };
+ IJavaProject[] affectedProjects = new IJavaProject[] { project };
- IClasspathContainer[] respectiveContainers = new IClasspathContainer[]
- { sigilContainer };
+ IClasspathContainer[] respectiveContainers = new IClasspathContainer[] { sigilContainer };
IProgressMonitor monitor = ThreadProgressMonitor.getProgressMonitor();
- if ( monitor == null )
+ if (monitor == null)
{
monitor = Job.getJobManager().createProgressGroup();
}
- JavaCore.setClasspathContainer( containerPath, affectedProjects, respectiveContainers, monitor );
+ JavaCore.setClasspathContainer(containerPath, affectedProjects,
+ respectiveContainers, monitor);
}
-
@Override
- public void initialize( IPath containerPath, IJavaProject project ) throws CoreException
+ public void initialize(IPath containerPath, IJavaProject project)
+ throws CoreException
{
- ISigilProjectModel sigil = SigilCore.create( project.getProject() );
+ ISigilProjectModel sigil = SigilCore.create(project.getProject());
- IClasspathContainer sigilContainer = new SigilClassPathContainer( sigil );
+ IClasspathContainer sigilContainer = new SigilClassPathContainer(sigil);
- IJavaProject[] affectedProjects = new IJavaProject[]
- { project };
+ IJavaProject[] affectedProjects = new IJavaProject[] { project };
- IClasspathContainer[] respectiveContainers = new IClasspathContainer[]
- { sigilContainer };
+ IClasspathContainer[] respectiveContainers = new IClasspathContainer[] { sigilContainer };
IProgressMonitor monitor = Job.getJobManager().createProgressGroup();
- JavaCore.setClasspathContainer( containerPath, affectedProjects, respectiveContainers, monitor );
+ JavaCore.setClasspathContainer(containerPath, affectedProjects,
+ respectiveContainers, monitor);
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/classpath/SigilLibraryPage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/classpath/SigilLibraryPage.java
index c18ec50..1fa13fd 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/classpath/SigilLibraryPage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/classpath/SigilLibraryPage.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.classpath;
-
import org.apache.felix.sigil.eclipse.SigilCore;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.IClasspathEntry;
@@ -30,51 +29,45 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
-
public class SigilLibraryPage extends WizardPage implements IClasspathContainerPage
{
private IClasspathEntry classpathEntry;
-
public SigilLibraryPage()
{
- super( "Sigil" );
+ super("Sigil");
}
-
- public void createControl( Composite parent )
+ public void createControl(Composite parent)
{
- setTitle( "Sigil Library" );
+ setTitle("Sigil Library");
- Label label = new Label( parent, SWT.NONE );
- label.setText( "Press Finish to add the Sigil Library" );
- label.setFont( parent.getFont() );
+ Label label = new Label(parent, SWT.NONE);
+ label.setText("Press Finish to add the Sigil Library");
+ label.setFont(parent.getFont());
- setControl( label );
+ setControl(label);
}
-
public boolean finish()
{
- classpathEntry = JavaCore.newContainerEntry( new Path( SigilCore.CLASSPATH_CONTAINER_PATH ) );
+ classpathEntry = JavaCore.newContainerEntry(new Path(
+ SigilCore.CLASSPATH_CONTAINER_PATH));
return true;
}
-
public boolean isPageComplete()
{
return true;
}
-
public IClasspathEntry getSelection()
{
return classpathEntry;
}
-
- public void setSelection( IClasspathEntry containerEntry )
+ public void setSelection(IClasspathEntry containerEntry)
{
this.classpathEntry = containerEntry;
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/completion/CompletionProposal.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/completion/CompletionProposal.java
index 460e27f..b74ea93 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/completion/CompletionProposal.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/completion/CompletionProposal.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.editors.completion;
-
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
@@ -27,7 +26,6 @@
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
-
class CompletionProposal implements ICompletionProposal
{
@@ -40,7 +38,6 @@
private String fDisplayString;
private Image fImage;
-
/**
* Creates a new completion proposal based on the provided information. The replacement string is
* considered being the display string too. All remaining fields are set to <code>null</code>.
@@ -50,13 +47,12 @@
* @param replacementLength the length of the text to be replaced
* @param cursorPosition the position of the cursor following the insert relative to replacementOffset
*/
- public CompletionProposal( String replacementString, int replacementOffset, int replacementLength,
- int cursorPosition )
+ public CompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition)
{
- this( replacementString, replacementOffset, replacementLength, cursorPosition, null, null, null, null );
+ this(replacementString, replacementOffset, replacementLength, cursorPosition,
+ null, null, null, null);
}
-
/**
* Creates a new completion proposal. All fields are initialized based on the provided information.
*
@@ -69,9 +65,7 @@
* @param contextInformation the context information associated with this proposal
* @param additionalProposalInfo the additional information associated with this proposal
*/
- public CompletionProposal( String replacementString, int replacementOffset, int replacementLength,
- int cursorPosition, Image image, String displayString, IContextInformation contextInformation,
- String additionalProposalInfo )
+ public CompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image, String displayString, IContextInformation contextInformation, String additionalProposalInfo)
{
fReplacementString = replacementString;
fReplacementOffset = replacementOffset;
@@ -83,23 +77,21 @@
fAdditionalProposalInfo = additionalProposalInfo;
}
-
/* (non-Javadoc)
* @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument)
*/
- public void apply( IDocument document )
+ public void apply(IDocument document)
{
try
{
- document.replace( fReplacementOffset, fReplacementLength, fReplacementString );
+ document.replace(fReplacementOffset, fReplacementLength, fReplacementString);
}
- catch ( BadLocationException x )
+ catch (BadLocationException x)
{
// ignore
}
}
-
/* (non-Javadoc)
* @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo()
*/
@@ -108,7 +100,6 @@
return fAdditionalProposalInfo;
}
-
/* (non-Javadoc)
* @see org.eclipse.jface.text.contentassist.ICompletionProposal#getContextInformation()
*/
@@ -117,18 +108,16 @@
return fContextInformation;
}
-
/* (non-Javadoc)
* @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString()
*/
public String getDisplayString()
{
- if ( fDisplayString != null )
+ if (fDisplayString != null)
return fDisplayString;
return fReplacementString;
}
-
/* (non-Javadoc)
* @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage()
*/
@@ -137,13 +126,12 @@
return fImage;
}
-
/* (non-Javadoc)
* @see org.eclipse.jface.text.contentassist.ICompletionProposal#getSelection(org.eclipse.jface.text.IDocument)
*/
- public Point getSelection( IDocument document )
+ public Point getSelection(IDocument document)
{
- return new Point( fReplacementOffset + fCursorPosition, 0 );
+ return new Point(fReplacementOffset + fCursorPosition, 0);
}
}
\ No newline at end of file
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/AbstractResourceSection.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/AbstractResourceSection.java
index abd4ad8..6fb8ee1 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/AbstractResourceSection.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/AbstractResourceSection.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
-
import java.io.File;
import org.apache.felix.sigil.eclipse.SigilCore;
@@ -43,35 +42,29 @@
import org.eclipse.swt.widgets.Tree;
import org.eclipse.ui.forms.IManagedForm;
-
-public abstract class AbstractResourceSection extends SigilSection implements IResourceChangeListener,
- ICheckStateListener
+public abstract class AbstractResourceSection extends SigilSection implements IResourceChangeListener, ICheckStateListener
{
- protected static final Object[] EMPTY = new Object[]
- {};
+ protected static final Object[] EMPTY = new Object[] {};
protected Tree tree;
protected CheckboxTreeViewer viewer;
private IWorkspace workspace;
-
- public AbstractResourceSection( SigilPage page, Composite parent, ISigilProjectModel project ) throws CoreException
+ public AbstractResourceSection(SigilPage page, Composite parent, ISigilProjectModel project) throws CoreException
{
- super( page, parent, project );
+ super(page, parent, project);
}
-
@Override
- public void initialize( IManagedForm form )
+ public void initialize(IManagedForm form)
{
- super.initialize( form );
- viewer.setAllChecked( false );
- viewer.setGrayedElements( EMPTY );
+ super.initialize(form);
+ viewer.setAllChecked(false);
+ viewer.setGrayedElements(EMPTY);
refreshSelections();
viewer.refresh();
}
-
@Override
public void refresh()
{
@@ -79,145 +72,137 @@
super.refresh();
}
-
- public void checkStateChanged( CheckStateChangedEvent event )
+ public void checkStateChanged(CheckStateChangedEvent event)
{
- handleStateChanged( ( IResource ) event.getElement(), event.getChecked(), true, true );
+ handleStateChanged((IResource) event.getElement(), event.getChecked(), true, true);
}
-
- public void resourceChanged( IResourceChangeEvent event )
+ public void resourceChanged(IResourceChangeEvent event)
{
- if ( !getSection().getDisplay().isDisposed() )
+ if (!getSection().getDisplay().isDisposed())
{
- getSection().getDisplay().asyncExec( new Runnable()
+ getSection().getDisplay().asyncExec(new Runnable()
{
public void run()
{
- if ( getSection().isVisible() )
+ if (getSection().isVisible())
{
viewer.refresh();
}
}
- } );
+ });
}
}
-
- protected void startWorkspaceListener( IWorkspace workspace )
+ protected void startWorkspaceListener(IWorkspace workspace)
{
this.workspace = workspace;
- workspace.addResourceChangeListener( this );
+ workspace.addResourceChangeListener(this);
}
-
@Override
public void dispose()
{
- workspace.removeResourceChangeListener( this );
+ workspace.removeResourceChangeListener(this);
}
-
protected abstract void refreshSelections();
+ protected abstract void syncResourceModel(IResource element, boolean checked);
- protected abstract void syncResourceModel( IResource element, boolean checked );
-
-
- protected IResource findResource( IPath path )
+ protected IResource findResource(IPath path)
{
IProject project2 = getProjectModel().getProject();
- File f = project2.getLocation().append( path ).toFile();
+ File f = project2.getLocation().append(path).toFile();
- if ( f.exists() )
+ if (f.exists())
{
try
{
- if ( f.isFile() )
+ if (f.isFile())
{
- return project2.getFile( path );
+ return project2.getFile(path);
}
else
{
- return project2.getFolder( path );
+ return project2.getFolder(path);
}
}
- catch ( IllegalArgumentException e )
+ catch (IllegalArgumentException e)
{
- SigilCore.error( "Unknown path " + path );
+ SigilCore.error("Unknown path " + path);
return null;
}
}
else
{
- SigilCore.error( "Unknown file " + f );
+ SigilCore.error("Unknown file " + f);
return null;
}
}
-
- protected void handleStateChanged( IResource element, boolean checked, boolean recurse, boolean sync )
+ protected void handleStateChanged(IResource element, boolean checked,
+ boolean recurse, boolean sync)
{
- if ( element instanceof IContainer )
+ if (element instanceof IContainer)
{
- setParentsGrayChecked( element, checked );
- if ( recurse )
+ setParentsGrayChecked(element, checked);
+ if (recurse)
{
- recursiveCheck( ( IContainer ) element, checked, sync );
+ recursiveCheck((IContainer) element, checked, sync);
}
}
else
{
- setParentsGrayChecked( element, checked );
+ setParentsGrayChecked(element, checked);
}
- if ( sync )
+ if (sync)
{
- syncResourceModel( element, checked );
+ syncResourceModel(element, checked);
}
}
-
- private void recursiveCheck( IContainer element, final boolean checked, final boolean sync )
+ private void recursiveCheck(IContainer element, final boolean checked,
+ final boolean sync)
{
try
{
- element.accept( new IResourceVisitor()
+ element.accept(new IResourceVisitor()
{
- public boolean visit( IResource resource ) throws CoreException
+ public boolean visit(IResource resource) throws CoreException
{
- viewer.setChecked( resource, checked );
- if ( sync )
+ viewer.setChecked(resource, checked);
+ if (sync)
{
- syncResourceModel( resource, checked );
+ syncResourceModel(resource, checked);
}
return true;
}
- } );
+ });
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- DebugPlugin.log( e.getStatus() );
+ DebugPlugin.log(e.getStatus());
}
}
-
- private void setParentsGrayChecked( IResource r, boolean checked )
+ private void setParentsGrayChecked(IResource r, boolean checked)
{
- while ( r.getParent() != null )
+ while (r.getParent() != null)
{
r = r.getParent();
- if ( ( viewer.getGrayed( r ) && viewer.getChecked( r ) ) == checked )
+ if ((viewer.getGrayed(r) && viewer.getChecked(r)) == checked)
{
break;
}
- if ( viewer.getChecked( r ) == checked )
+ if (viewer.getChecked(r) == checked)
{
- viewer.setGrayed( r, !checked );
+ viewer.setGrayed(r, !checked);
}
else
{
- viewer.setGrayChecked( r, checked );
+ viewer.setGrayChecked(r, checked);
}
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/BundleDependencySection.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/BundleDependencySection.java
index 6ef63ba..76e298a 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/BundleDependencySection.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/BundleDependencySection.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
-
import java.util.Set;
import org.apache.felix.sigil.common.model.IModelElement;
@@ -44,7 +43,6 @@
import org.eclipse.ui.forms.widgets.TableWrapData;
import org.eclipse.ui.forms.widgets.TableWrapLayout;
-
public abstract class BundleDependencySection extends SigilSection
{
@@ -53,39 +51,29 @@
private Button edit;
private Button remove;
-
- public BundleDependencySection( SigilPage page, Composite parent, ISigilProjectModel project,
- Set<IModelElement> unresolvedElements ) throws CoreException
+ public BundleDependencySection(SigilPage page, Composite parent, ISigilProjectModel project, Set<IModelElement> unresolvedElements) throws CoreException
{
- super( page, parent, project );
- viewer.setUnresolvedElements( unresolvedElements );
+ super(page, parent, project);
+ viewer.setUnresolvedElements(unresolvedElements);
}
-
- public BundleDependencySection( SigilPage page, Composite parent, ISigilProjectModel project ) throws CoreException
+ public BundleDependencySection(SigilPage page, Composite parent, ISigilProjectModel project) throws CoreException
{
- this( page, parent, project, null );
+ this(page, parent, project, null);
}
-
protected abstract String getTitle();
-
- protected abstract Label createLabel( Composite parent, FormToolkit toolkit );
-
+ protected abstract Label createLabel(Composite parent, FormToolkit toolkit);
protected abstract IContentProvider getContentProvider();
-
protected abstract void handleAdd();
-
protected abstract void handleEdit();
-
protected abstract void handleRemoved();
-
@Override
public void refresh()
{
@@ -93,100 +81,96 @@
viewer.refresh();
}
-
protected ISelection getSelection()
{
return viewer.getSelection();
}
-
@Override
- protected void createSection( Section section, FormToolkit toolkit )
+ protected void createSection(Section section, FormToolkit toolkit)
{
- setTitle( getTitle() );
+ setTitle(getTitle());
- Composite body = createGridBody( 2, false, toolkit );
+ Composite body = createGridBody(2, false, toolkit);
- Label label = createLabel( body, toolkit );
+ Label label = createLabel(body, toolkit);
- label.setLayoutData( new GridData( SWT.LEFT, SWT.CENTER, true, true, 2, 1 ) );
+ label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true, 2, 1));
- Table bundleTable = toolkit.createTable( body, SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL | SWT.BORDER );
- GridData data = new GridData( GridData.FILL_BOTH );
+ Table bundleTable = toolkit.createTable(body, SWT.MULTI | SWT.FULL_SELECTION
+ | SWT.VIRTUAL | SWT.BORDER);
+ GridData data = new GridData(GridData.FILL_BOTH);
data.heightHint = 600;
- bundleTable.setLayoutData( data );
- bundleTable.setLinesVisible( false );
- createButtons( body, toolkit );
- createViewer( bundleTable );
+ bundleTable.setLayoutData(data);
+ bundleTable.setLinesVisible(false);
+ createButtons(body, toolkit);
+ createViewer(bundleTable);
}
-
- protected void createButtons( Composite body, FormToolkit toolkit )
+ protected void createButtons(Composite body, FormToolkit toolkit)
{
- Composite buttons = toolkit.createComposite( body );
+ Composite buttons = toolkit.createComposite(body);
TableWrapLayout layout = new TableWrapLayout();
layout.numColumns = 1;
layout.topMargin = 0;
layout.leftMargin = 0;
layout.rightMargin = 0;
layout.bottomMargin = 0;
- buttons.setLayout( layout );
+ buttons.setLayout(layout);
GridData data = new GridData();
data.verticalAlignment = SWT.TOP;
- buttons.setLayoutData( data );
+ buttons.setLayoutData(data);
- add = toolkit.createButton( buttons, "Add", SWT.NULL );
- add.setLayoutData( new TableWrapData( TableWrapData.FILL ) );
- add.addSelectionListener( new SelectionAdapter()
+ add = toolkit.createButton(buttons, "Add", SWT.NULL);
+ add.setLayoutData(new TableWrapData(TableWrapData.FILL));
+ add.addSelectionListener(new SelectionAdapter()
{
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
handleAdd();
}
- } );
+ });
- edit = toolkit.createButton( buttons, "Edit", SWT.NULL );
- edit.setLayoutData( new TableWrapData( TableWrapData.FILL ) );
- edit.addSelectionListener( new SelectionAdapter()
+ edit = toolkit.createButton(buttons, "Edit", SWT.NULL);
+ edit.setLayoutData(new TableWrapData(TableWrapData.FILL));
+ edit.addSelectionListener(new SelectionAdapter()
{
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
handleEdit();
}
- } );
+ });
- remove = toolkit.createButton( buttons, "Remove", SWT.NULL );
- remove.setLayoutData( new TableWrapData( TableWrapData.FILL ) );
- remove.addSelectionListener( new SelectionAdapter()
+ remove = toolkit.createButton(buttons, "Remove", SWT.NULL);
+ remove.setLayoutData(new TableWrapData(TableWrapData.FILL));
+ remove.addSelectionListener(new SelectionAdapter()
{
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
handleRemoved();
}
- } );
+ });
- setSelected( false );
+ setSelected(false);
}
-
- protected void createViewer( Table bundleTable )
+ protected void createViewer(Table bundleTable)
{
- viewer = new ProjectTableViewer( bundleTable );
- viewer.setContentProvider( getContentProvider() );
- viewer.addSelectionChangedListener( new ISelectionChangedListener()
+ viewer = new ProjectTableViewer(bundleTable);
+ viewer.setContentProvider(getContentProvider());
+ viewer.addSelectionChangedListener(new ISelectionChangedListener()
{
- public void selectionChanged( SelectionChangedEvent event )
+ public void selectionChanged(SelectionChangedEvent event)
{
- setSelected( !event.getSelection().isEmpty() );
+ setSelected(!event.getSelection().isEmpty());
}
- } );
+ });
}
-
- private void setSelected( boolean selected )
+ private void setSelected(boolean selected)
{
- edit.setEnabled( selected );
- remove.setEnabled( selected );
+ edit.setEnabled(selected);
+ remove.setEnabled(selected);
}
}
\ No newline at end of file
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ClasspathSection.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ClasspathSection.java
index 2086a3c..6261f21 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ClasspathSection.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ClasspathSection.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -57,196 +56,189 @@
import org.eclipse.ui.forms.widgets.TableWrapData;
import org.eclipse.ui.forms.widgets.TableWrapLayout;
-
public class ClasspathSection extends SigilSection
{
private ProjectTableViewer viewer;
private final Comparator<IClasspathEntry> CLASSPATH_COMPARATOR = new Comparator<IClasspathEntry>()
{
- public int compare( IClasspathEntry o1, IClasspathEntry o2 )
+ public int compare(IClasspathEntry o1, IClasspathEntry o2)
{
- return compareClasspaths( o1, o2 );
+ return compareClasspaths(o1, o2);
}
};
-
- public ClasspathSection( SigilPage page, Composite parent, ISigilProjectModel project ) throws CoreException
+ public ClasspathSection(SigilPage page, Composite parent, ISigilProjectModel project) throws CoreException
{
- super( page, parent, project );
+ super(page, parent, project);
}
-
@Override
- protected void createSection( Section section, FormToolkit toolkit )
+ protected void createSection(Section section, FormToolkit toolkit)
{
- setTitle( "Classpath" );
+ setTitle("Classpath");
- Composite body = createGridBody( 2, false, toolkit );
+ Composite body = createGridBody(2, false, toolkit);
- Label label = toolkit.createLabel( body, "Specify the internal classpath of this bundle." );
- label.setLayoutData( new GridData( SWT.LEFT, SWT.CENTER, true, true, 2, 1 ) );
+ Label label = toolkit.createLabel(body,
+ "Specify the internal classpath of this bundle.");
+ label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, true, 2, 1));
- Table bundleTable = toolkit.createTable( body, SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL | SWT.BORDER );
- GridData tableLayoutData = new GridData( SWT.FILL, SWT.FILL, true, true );
+ Table bundleTable = toolkit.createTable(body, SWT.MULTI | SWT.FULL_SELECTION
+ | SWT.VIRTUAL | SWT.BORDER);
+ GridData tableLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
tableLayoutData.heightHint = 150;
- bundleTable.setLayoutData( tableLayoutData );
+ bundleTable.setLayoutData(tableLayoutData);
- createButtons( body, toolkit );
- createViewer( bundleTable );
+ createButtons(body, toolkit);
+ createViewer(bundleTable);
}
-
- private void createButtons( Composite body, FormToolkit toolkit )
+ private void createButtons(Composite body, FormToolkit toolkit)
{
- Composite buttons = toolkit.createComposite( body );
+ Composite buttons = toolkit.createComposite(body);
TableWrapLayout layout = new TableWrapLayout();
layout.numColumns = 1;
layout.topMargin = 0;
layout.leftMargin = 0;
layout.rightMargin = 0;
layout.bottomMargin = 0;
- buttons.setLayout( layout );
+ buttons.setLayout(layout);
- Button add = toolkit.createButton( buttons, "Add", SWT.NULL );
- add.setLayoutData( new TableWrapData( TableWrapData.FILL ) );
- add.addSelectionListener( new SelectionAdapter()
+ Button add = toolkit.createButton(buttons, "Add", SWT.NULL);
+ add.setLayoutData(new TableWrapData(TableWrapData.FILL));
+ add.addSelectionListener(new SelectionAdapter()
{
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
handleAdd();
}
- } );
+ });
- Button remove = toolkit.createButton( buttons, "Remove", SWT.NULL );
- remove.setLayoutData( new TableWrapData( TableWrapData.FILL ) );
- remove.addSelectionListener( new SelectionAdapter()
+ Button remove = toolkit.createButton(buttons, "Remove", SWT.NULL);
+ remove.setLayoutData(new TableWrapData(TableWrapData.FILL));
+ remove.addSelectionListener(new SelectionAdapter()
{
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
handleRemoved();
}
- } );
+ });
}
-
- private void createViewer( Table bundleTable )
+ private void createViewer(Table bundleTable)
{
- viewer = new ProjectTableViewer( bundleTable );
- viewer.setContentProvider( new DefaultTableProvider()
+ viewer = new ProjectTableViewer(bundleTable);
+ viewer.setContentProvider(new DefaultTableProvider()
{
- public Object[] getElements( Object inputElement )
+ public Object[] getElements(Object inputElement)
{
ArrayList<IClasspathEntry> cp = new ArrayList<IClasspathEntry>();
- for ( IClasspathEntry cpe : JavaHelper.findClasspathEntries( getBundle() ) )
+ for (IClasspathEntry cpe : JavaHelper.findClasspathEntries(getBundle()))
{
- cp.add( cpe );
+ cp.add(cpe);
}
- Collections.sort( cp, new Comparator<IClasspathEntry>()
+ Collections.sort(cp, new Comparator<IClasspathEntry>()
{
- public int compare( IClasspathEntry o1, IClasspathEntry o2 )
+ public int compare(IClasspathEntry o1, IClasspathEntry o2)
{
- return o1.toString().compareTo( o2.toString() );
+ return o1.toString().compareTo(o2.toString());
}
- } );
+ });
return cp.toArray();
}
- } );
- viewer.setComparator( new ViewerComparator()
+ });
+ viewer.setComparator(new ViewerComparator()
{
@Override
- public int category( Object element )
+ public int category(Object element)
{
- return index( ( IClasspathEntry ) element );
+ return index((IClasspathEntry) element);
}
- } );
+ });
}
-
protected ISigilBundle getBundle()
{
return getProjectModel().getBundle();
}
-
private void handleAdd()
{
try
{
BackgroundLoadingSelectionDialog<IClasspathEntry> dialog = new BackgroundLoadingSelectionDialog<IClasspathEntry>(
- getSection().getShell(), "Classpath Entry:", true );
+ getSection().getShell(), "Classpath Entry:", true);
- dialog.setDescriptor( new IElementDescriptor<IClasspathEntry>()
+ dialog.setDescriptor(new IElementDescriptor<IClasspathEntry>()
{
- public String getName( IClasspathEntry element )
+ public String getName(IClasspathEntry element)
{
return element.getPath().toString();
}
-
- public String getLabel( IClasspathEntry element )
+ public String getLabel(IClasspathEntry element)
{
- return getName( element );
+ return getName(element);
}
- } );
+ });
- dialog.setLabelProvider( new ModelLabelProvider() );
+ dialog.setLabelProvider(new ModelLabelProvider());
- dialog.setFilter( new IFilter<IClasspathEntry>()
+ dialog.setFilter(new IFilter<IClasspathEntry>()
{
- public boolean select( IClasspathEntry cp )
+ public boolean select(IClasspathEntry cp)
{
- switch ( cp.getEntryKind() )
+ switch (cp.getEntryKind())
{
case IClasspathEntry.CPE_LIBRARY:
case IClasspathEntry.CPE_VARIABLE:
case IClasspathEntry.CPE_SOURCE:
- return !getBundle().getClasspathEntrys().contains( encode( cp ) );
+ return !getBundle().getClasspathEntrys().contains(encode(cp));
default:
return false;
}
}
- } );
+ });
- dialog.setComparator( CLASSPATH_COMPARATOR );
+ dialog.setComparator(CLASSPATH_COMPARATOR);
IClasspathEntry[] classpath = getProjectModel().getJavaModel().getRawClasspath();
- dialog.addElements( Arrays.asList( classpath ) );
- if ( dialog.open() == Window.OK )
+ dialog.addElements(Arrays.asList(classpath));
+ if (dialog.open() == Window.OK)
{
List<IClasspathEntry> selectedElements = dialog.getSelectedElements();
Object[] added = selectedElements.toArray();
- for ( IClasspathEntry entry : selectedElements )
+ for (IClasspathEntry entry : selectedElements)
{
- getBundle().addClasspathEntry( encode( entry ) );
+ getBundle().addClasspathEntry(encode(entry));
}
- viewer.add( added );
+ viewer.add(added);
viewer.refresh();
markDirty();
}
}
- catch ( JavaModelException e )
+ catch (JavaModelException e)
{
- ErrorDialog.openError( getSection().getShell(), "Error", null, e.getStatus() );
+ ErrorDialog.openError(getSection().getShell(), "Error", null, e.getStatus());
}
}
-
- private int compareClasspaths( IClasspathEntry o1, IClasspathEntry o2 )
+ private int compareClasspaths(IClasspathEntry o1, IClasspathEntry o2)
{
- if ( o1.getEntryKind() == o2.getEntryKind() )
+ if (o1.getEntryKind() == o2.getEntryKind())
{
ModelLabelProvider mlp = viewer.getLabelProvider();
- return mlp.getText( o1 ).compareTo( mlp.getText( o2 ) );
+ return mlp.getText(o1).compareTo(mlp.getText(o2));
}
else
{
- int i1 = index( o1 );
- int i2 = index( o2 );
+ int i1 = index(o1);
+ int i2 = index(o2);
- if ( i1 < i2 )
+ if (i1 < i2)
{
return -1;
}
@@ -257,10 +249,9 @@
}
}
-
- private static int index( IClasspathEntry o1 )
+ private static int index(IClasspathEntry o1)
{
- switch ( o1.getEntryKind() )
+ switch (o1.getEntryKind())
{
case IClasspathEntry.CPE_SOURCE:
return 0;
@@ -273,30 +264,28 @@
case IClasspathEntry.CPE_CONTAINER:
return 4;
default:
- throw new IllegalStateException( "Unknown classpath entry type " + o1 );
+ throw new IllegalStateException("Unknown classpath entry type " + o1);
}
}
-
- private String encode( IClasspathEntry cp )
+ private String encode(IClasspathEntry cp)
{
- return getProjectModel().getJavaModel().encodeClasspathEntry( cp ).trim();
+ return getProjectModel().getJavaModel().encodeClasspathEntry(cp).trim();
}
-
@SuppressWarnings("unchecked")
private void handleRemoved()
{
- IStructuredSelection selection = ( IStructuredSelection ) viewer.getSelection();
+ IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
- if ( !selection.isEmpty() )
+ if (!selection.isEmpty())
{
- for ( Iterator<IClasspathEntry> i = selection.iterator(); i.hasNext(); )
+ for (Iterator<IClasspathEntry> i = selection.iterator(); i.hasNext();)
{
getBundle().removeClasspathEntry(
- getProjectModel().getJavaModel().encodeClasspathEntry( i.next() ).trim() );
+ getProjectModel().getJavaModel().encodeClasspathEntry(i.next()).trim());
}
- viewer.remove( selection.toArray() );
+ viewer.remove(selection.toArray());
markDirty();
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ContentSummarySection.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ContentSummarySection.java
index a2a3e4b..f0eedf4 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ContentSummarySection.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ContentSummarySection.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
-
import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
import org.apache.felix.sigil.eclipse.ui.internal.form.SigilPage;
import org.apache.felix.sigil.eclipse.ui.internal.form.SigilSection;
@@ -31,42 +30,40 @@
import org.eclipse.ui.forms.widgets.Hyperlink;
import org.eclipse.ui.forms.widgets.Section;
-
public class ContentSummarySection extends SigilSection
{
- public ContentSummarySection( SigilPage page, Composite parent, ISigilProjectModel project ) throws CoreException
+ public ContentSummarySection(SigilPage page, Composite parent, ISigilProjectModel project) throws CoreException
{
- super( page, parent, project );
+ super(page, parent, project);
}
-
@Override
- protected void createSection( Section section, FormToolkit toolkit )
+ protected void createSection(Section section, FormToolkit toolkit)
{
- setTitle( "Project Content" );
+ setTitle("Project Content");
- Composite body = createTableWrapBody( 2, toolkit );
- Hyperlink link = toolkit.createHyperlink( body, "Contents:", SWT.NONE );
- link.setHref( ContentsForm.PAGE_ID );
- link.addHyperlinkListener( this );
- toolkit.createLabel( body, "Manage the content that this bundle provides." );
+ Composite body = createTableWrapBody(2, toolkit);
+ Hyperlink link = toolkit.createHyperlink(body, "Contents:", SWT.NONE);
+ link.setHref(ContentsForm.PAGE_ID);
+ link.addHyperlinkListener(this);
+ toolkit.createLabel(body, "Manage the content that this bundle provides.");
- link = toolkit.createHyperlink( body, "Dependencies:", SWT.NONE );
- link.setHref( DependenciesForm.PAGE_ID );
- link.addHyperlinkListener( this );
- toolkit.createLabel( body, "Manage the dependencies that this bundle needs to run." );
+ link = toolkit.createHyperlink(body, "Dependencies:", SWT.NONE);
+ link.setHref(DependenciesForm.PAGE_ID);
+ link.addHyperlinkListener(this);
+ toolkit.createLabel(body,
+ "Manage the dependencies that this bundle needs to run.");
- link = toolkit.createHyperlink( body, "Exports:", SWT.NONE );
- link.setHref( ExportsForm.PAGE_ID );
- link.addHyperlinkListener( this );
- toolkit.createLabel( body, "Manage the resources that this bundle exports." );
+ link = toolkit.createHyperlink(body, "Exports:", SWT.NONE);
+ link.setHref(ExportsForm.PAGE_ID);
+ link.addHyperlinkListener(this);
+ toolkit.createLabel(body, "Manage the resources that this bundle exports.");
}
-
@Override
- public void linkActivated( HyperlinkEvent e )
+ public void linkActivated(HyperlinkEvent e)
{
- getPage().getEditor().setActivePage( ( String ) e.getHref() );
+ getPage().getEditor().setActivePage((String) e.getHref());
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ContentsForm.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ContentsForm.java
index cedc2cd..0271305 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ContentsForm.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ContentsForm.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
-
import org.apache.felix.sigil.eclipse.SigilCore;
import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
import org.apache.felix.sigil.eclipse.ui.internal.form.SigilPage;
@@ -32,7 +31,6 @@
import org.eclipse.ui.forms.widgets.TableWrapData;
import org.eclipse.ui.forms.widgets.TableWrapLayout;
-
public class ContentsForm extends SigilPage
{
@@ -40,21 +38,19 @@
private ISigilProjectModel project;
-
- public ContentsForm( FormEditor editor, ISigilProjectModel project )
+ public ContentsForm(FormEditor editor, ISigilProjectModel project)
{
- super( editor, PAGE_ID, "Contents" );
+ super(editor, PAGE_ID, "Contents");
this.project = project;
}
-
@Override
- protected void createFormContent( IManagedForm managedForm )
+ protected void createFormContent(IManagedForm managedForm)
{
FormToolkit toolkit = managedForm.getToolkit();
ScrolledForm form = managedForm.getForm();
- form.setText( "Contents" );
+ form.setText("Contents");
Composite body = form.getBody();
TableWrapLayout layout = new TableWrapLayout();
@@ -64,34 +60,35 @@
layout.rightMargin = 10;
layout.numColumns = 1;
layout.horizontalSpacing = 10;
- body.setLayout( layout );
- body.setLayoutData( new TableWrapData( TableWrapData.FILL ) );
+ body.setLayout(layout);
+ body.setLayoutData(new TableWrapData(TableWrapData.FILL));
- Composite top = toolkit.createComposite( body );
+ Composite top = toolkit.createComposite(body);
layout = new TableWrapLayout();
layout.verticalSpacing = 20;
- top.setLayout( layout );
- TableWrapData data = new TableWrapData( TableWrapData.FILL_GRAB );
+ top.setLayout(layout);
+ TableWrapData data = new TableWrapData(TableWrapData.FILL_GRAB);
//data.colspan = 2;
- top.setLayoutData( data );
+ top.setLayoutData(data);
- Composite bottom = toolkit.createComposite( body );
+ Composite bottom = toolkit.createComposite(body);
layout = new TableWrapLayout();
layout.verticalSpacing = 20;
- bottom.setLayout( layout );
- bottom.setLayoutData( new TableWrapData( TableWrapData.FILL_GRAB ) );
+ bottom.setLayout(layout);
+ bottom.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
try
{
- ClasspathSection classpath = new ClasspathSection( this, top, project );
- managedForm.addPart( classpath );
+ ClasspathSection classpath = new ClasspathSection(this, top, project);
+ managedForm.addPart(classpath);
- ResourceBuildSection runtimeBuild = new ResourceBuildSection( this, bottom, project );
- managedForm.addPart( runtimeBuild );
+ ResourceBuildSection runtimeBuild = new ResourceBuildSection(this, bottom,
+ project);
+ managedForm.addPart(runtimeBuild);
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- SigilCore.error( "Failed to create contents form", e );
+ SigilCore.error("Failed to create contents form", e);
}
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/DependenciesForm.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/DependenciesForm.java
index 179caa9..abb94ea 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/DependenciesForm.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/DependenciesForm.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
-
import java.util.Set;
import org.apache.felix.sigil.common.model.IModelElement;
@@ -35,7 +34,6 @@
import org.eclipse.ui.forms.widgets.TableWrapData;
import org.eclipse.ui.forms.widgets.TableWrapLayout;
-
public class DependenciesForm extends SigilPage
{
@@ -47,29 +45,26 @@
private ImportPackagesSection importPackages;
private RequiresBundleSection requiresSection;
-
- public DependenciesForm( FormEditor editor, ISigilProjectModel project, Set<IModelElement> unresolved )
+ public DependenciesForm(FormEditor editor, ISigilProjectModel project, Set<IModelElement> unresolved)
{
- super( editor, PAGE_ID, "Dependencies" );
+ super(editor, PAGE_ID, "Dependencies");
this.project = project;
this.unresolvedElements = unresolved;
}
-
@Override
public boolean canLeaveThePage()
{
return !isDirty();
}
-
@Override
- protected void createFormContent( IManagedForm managedForm )
+ protected void createFormContent(IManagedForm managedForm)
{
FormToolkit toolkit = managedForm.getToolkit();
ScrolledForm form = managedForm.getForm();
- form.setText( "Dependencies" );
+ form.setText("Dependencies");
Composite body = form.getBody();
TableWrapLayout layout = new TableWrapLayout();
@@ -79,43 +74,46 @@
layout.rightMargin = 10;
layout.numColumns = 2;
layout.horizontalSpacing = 10;
- body.setLayout( layout );
- body.setLayoutData( new TableWrapData( TableWrapData.FILL_GRAB ) );
+ body.setLayout(layout);
+ body.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
- Composite left = toolkit.createComposite( body );
+ Composite left = toolkit.createComposite(body);
layout = new TableWrapLayout();
layout.verticalSpacing = 20;
- left.setLayout( layout );
- TableWrapData layoutData = new TableWrapData( TableWrapData.FILL_GRAB );
+ left.setLayout(layout);
+ TableWrapData layoutData = new TableWrapData(TableWrapData.FILL_GRAB);
layoutData.rowspan = 2;
- left.setLayoutData( layoutData );
+ left.setLayoutData(layoutData);
- Composite right = toolkit.createComposite( body );
+ Composite right = toolkit.createComposite(body);
layout = new TableWrapLayout();
layout.verticalSpacing = 20;
- right.setLayout( layout );
- right.setLayoutData( new TableWrapData( TableWrapData.FILL_GRAB ) );
+ right.setLayout(layout);
+ right.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
- Composite bottom = toolkit.createComposite( body );
+ Composite bottom = toolkit.createComposite(body);
layout = new TableWrapLayout();
layout.verticalSpacing = 20;
- bottom.setLayout( layout );
- bottom.setLayoutData( new TableWrapData( TableWrapData.FILL_GRAB ) );
+ bottom.setLayout(layout);
+ bottom.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
try
{
- importPackages = new ImportPackagesSection( this, left, project, unresolvedElements );
- managedForm.addPart( importPackages );
+ importPackages = new ImportPackagesSection(this, left, project,
+ unresolvedElements);
+ managedForm.addPart(importPackages);
- requiresSection = new RequiresBundleSection( this, right, project, unresolvedElements );
- managedForm.addPart( requiresSection );
+ requiresSection = new RequiresBundleSection(this, right, project,
+ unresolvedElements);
+ managedForm.addPart(requiresSection);
- DependencyManagementSection depMgmt = new DependencyManagementSection( this, bottom, project );
- managedForm.addPart( depMgmt );
+ DependencyManagementSection depMgmt = new DependencyManagementSection(this,
+ bottom, project);
+ managedForm.addPart(depMgmt);
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- SigilCore.error( "Failed to create dependencies form", e );
+ SigilCore.error("Failed to create dependencies form", e);
}
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/DependencyManagementSection.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/DependencyManagementSection.java
index 0f0a4b9..f8fd0ef 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/DependencyManagementSection.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/DependencyManagementSection.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
-
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
@@ -61,96 +60,94 @@
import org.eclipse.ui.forms.widgets.Hyperlink;
import org.eclipse.ui.forms.widgets.Section;
-
public class DependencyManagementSection extends SigilSection
{
private Hyperlink hypConvertRBtoIP;
-
- public DependencyManagementSection( SigilPage page, Composite parent, ISigilProjectModel project )
- throws CoreException
+ public DependencyManagementSection(SigilPage page, Composite parent, ISigilProjectModel project) throws CoreException
{
- super( page, parent, project );
+ super(page, parent, project);
}
-
- protected void createSection( Section section, FormToolkit toolkit ) throws CoreException
+ protected void createSection(Section section, FormToolkit toolkit)
+ throws CoreException
{
- setTitle( "Dependency Management" );
+ setTitle("Dependency Management");
- Composite body = createGridBody( 1, false, toolkit );
+ Composite body = createGridBody(1, false, toolkit);
- hypConvertRBtoIP = toolkit.createHyperlink( body, "Convert Required Bundles to Imported Packages", SWT.NONE );
- hypConvertRBtoIP.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
+ hypConvertRBtoIP = toolkit.createHyperlink(body,
+ "Convert Required Bundles to Imported Packages", SWT.NONE);
+ hypConvertRBtoIP.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- hypConvertRBtoIP.addHyperlinkListener( new HyperlinkAdapter()
+ hypConvertRBtoIP.addHyperlinkListener(new HyperlinkAdapter()
{
- public void linkActivated( HyperlinkEvent e )
+ public void linkActivated(HyperlinkEvent e)
{
run();
}
- } );
+ });
}
-
protected void run()
{
final Map<String, IPackageExport> exports = new HashMap<String, IPackageExport>();
final Set<String> imports = new HashSet<String>();
// Find all exports
- final ExportedPackageFinder exportFinder = new ExportedPackageFinder( getProjectModel(),
- new AccumulatorAdapter<IPackageExport>()
+ final ExportedPackageFinder exportFinder = new ExportedPackageFinder(
+ getProjectModel(), new AccumulatorAdapter<IPackageExport>()
{
- public void addElements( Collection<? extends IPackageExport> elements )
+ public void addElements(Collection<? extends IPackageExport> elements)
{
- for ( IPackageExport export : elements )
+ for (IPackageExport export : elements)
{
- exports.put( export.getPackageName(), export );
+ exports.put(export.getPackageName(), export);
}
}
- } );
- Job findExportsJob = new Job( "Find exports" )
+ });
+ Job findExportsJob = new Job("Find exports")
{
- protected IStatus run( IProgressMonitor monitor )
+ protected IStatus run(IProgressMonitor monitor)
{
- return exportFinder.run( monitor );
+ return exportFinder.run(monitor);
}
};
- findExportsJob.setUser( true );
+ findExportsJob.setUser(true);
findExportsJob.schedule();
// Find imports from Java source
- Job findImportsJob = new Job( "Find imports" )
+ Job findImportsJob = new Job("Find imports")
{
- protected IStatus run( IProgressMonitor monitor )
+ protected IStatus run(IProgressMonitor monitor)
{
IJavaProject javaProject = getProjectModel().getJavaModel();
try
{
IPackageFragment[] packages = javaProject.getPackageFragments();
- for ( IPackageFragment pkg : packages )
+ for (IPackageFragment pkg : packages)
{
ICompilationUnit[] compilationUnits = pkg.getCompilationUnits();
- for ( ICompilationUnit compilationUnit : compilationUnits )
+ for (ICompilationUnit compilationUnit : compilationUnits)
{
IImportDeclaration[] importDecls = compilationUnit.getImports();
- for ( IImportDeclaration importDecl : importDecls )
+ for (IImportDeclaration importDecl : importDecls)
{
- imports.add( getPackageName( importDecl ) );
+ imports.add(getPackageName(importDecl));
}
}
}
return Status.OK_STATUS;
}
- catch ( JavaModelException e )
+ catch (JavaModelException e)
{
- return new Status( IStatus.ERROR, SigilUI.PLUGIN_ID, 0, "Error finding imports", e );
+ return new Status(IStatus.ERROR, SigilUI.PLUGIN_ID, 0,
+ "Error finding imports", e);
}
}
};
- findImportsJob.setUser( true );
+ findImportsJob.setUser(true);
findImportsJob.schedule();
// Wait for both jobs to complete
@@ -159,7 +156,7 @@
findImportsJob.join();
findExportsJob.join();
}
- catch ( InterruptedException e )
+ catch (InterruptedException e)
{
// Aborted, just do nothing
return;
@@ -169,26 +166,26 @@
IBundleModelElement bundleInfo = getProjectModel().getBundle().getBundleInfo();
Collection<IPackageImport> existingImports = bundleInfo.getImports();
Map<String, IPackageImport> existingImportsMap = new HashMap<String, IPackageImport>();
- for ( IPackageImport existingImport : existingImports )
+ for (IPackageImport existingImport : existingImports)
{
- existingImportsMap.put( existingImport.getPackageName(), existingImport );
+ existingImportsMap.put(existingImport.getPackageName(), existingImport);
}
// Add imports to the bundle
ModelElementFactory elementFactory = ModelElementFactory.getInstance();
int count = 0;
- for ( String pkgImport : imports )
+ for (String pkgImport : imports)
{
- IPackageExport export = exports.get( pkgImport );
- if ( export != null && !existingImportsMap.containsKey( pkgImport ) )
+ IPackageExport export = exports.get(pkgImport);
+ if (export != null && !existingImportsMap.containsKey(pkgImport))
{
VersionRange versionRange = ModelHelper.getDefaultRange(export.getVersion());
- IPackageImport newImport = elementFactory.newModelElement( IPackageImport.class );
- newImport.setPackageName( pkgImport );
- newImport.setVersions( versionRange );
- newImport.setOptional( false );
+ IPackageImport newImport = elementFactory.newModelElement(IPackageImport.class);
+ newImport.setPackageName(pkgImport);
+ newImport.setVersions(versionRange);
+ newImport.setOptional(false);
- bundleInfo.addImport( newImport );
+ bundleInfo.addImport(newImport);
count++;
}
}
@@ -196,31 +193,31 @@
// Remove required bundles
Collection<IRequiredBundle> requiredBundles = bundleInfo.getRequiredBundles();
int requiredBundlesSize = requiredBundles.size();
- for ( IRequiredBundle requiredBundle : requiredBundles )
+ for (IRequiredBundle requiredBundle : requiredBundles)
{
- bundleInfo.removeRequiredBundle( requiredBundle );
+ bundleInfo.removeRequiredBundle(requiredBundle);
}
// Update the editor
- if ( count + requiredBundlesSize > 0 )
+ if (count + requiredBundlesSize > 0)
{
IFormPart[] parts = getPage().getManagedForm().getParts();
- for ( IFormPart formPart : parts )
+ for (IFormPart formPart : parts)
{
formPart.refresh();
- ( ( AbstractFormPart ) formPart ).markDirty();
+ ((AbstractFormPart) formPart).markDirty();
}
}
- MessageDialog.openInformation( getManagedForm().getForm().getShell(), "Dependency Management", "Removed "
- + requiredBundlesSize + " required bundle(s) and added " + count + " imported package(s)." );
+ MessageDialog.openInformation(getManagedForm().getForm().getShell(),
+ "Dependency Management", "Removed " + requiredBundlesSize
+ + " required bundle(s) and added " + count + " imported package(s).");
}
-
- private static String getPackageName( IImportDeclaration decl )
+ private static String getPackageName(IImportDeclaration decl)
{
String name = decl.getElementName();
- int lastDot = name.lastIndexOf( '.' );
- return name.substring( 0, lastDot );
+ int lastDot = name.lastIndexOf('.');
+ return name.substring(0, lastDot);
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ExcludedResourcesFilter.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ExcludedResourcesFilter.java
index 782537d..4a94341 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ExcludedResourcesFilter.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ExcludedResourcesFilter.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
-
import java.util.HashSet;
import java.util.Set;
import java.util.regex.Pattern;
@@ -32,39 +31,35 @@
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
-
public class ExcludedResourcesFilter extends ViewerFilter
{
private final Set<Pattern> exclusionSet = new HashSet<Pattern>();
-
public ExcludedResourcesFilter()
{
loadExclusions();
}
-
public final synchronized void loadExclusions()
{
exclusionSet.clear();
IPreferenceStore store = SigilCore.getDefault().getPreferenceStore();
- String[] exclusions = PrefsUtils.stringToArray( store.getString( SigilCore.DEFAULT_EXCLUDED_RESOURCES ) );
- for ( String exclusion : exclusions )
+ String[] exclusions = PrefsUtils.stringToArray(store.getString(SigilCore.DEFAULT_EXCLUDED_RESOURCES));
+ for (String exclusion : exclusions)
{
- exclusionSet.add( GlobCompiler.compile( exclusion ) );
+ exclusionSet.add(GlobCompiler.compile(exclusion));
}
}
-
@Override
- public synchronized boolean select( Viewer viewer, Object parentElement, Object element )
+ public synchronized boolean select(Viewer viewer, Object parentElement, Object element)
{
- IResource file = ( IResource ) element;
+ IResource file = (IResource) element;
String path = file.getName();
- for ( Pattern p : exclusionSet )
+ for (Pattern p : exclusionSet)
{
- if ( p.matcher( path ).matches() )
+ if (p.matcher(path).matches())
{
return false;
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ExportPackagesSection.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ExportPackagesSection.java
index 7f2c013..05242bd 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ExportPackagesSection.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ExportPackagesSection.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
-
import java.util.Iterator;
import java.util.List;
@@ -48,50 +47,47 @@
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.osgi.framework.Version;
-
public class ExportPackagesSection extends BundleDependencySection
{
- public ExportPackagesSection( SigilPage page, Composite parent, ISigilProjectModel project ) throws CoreException
+ public ExportPackagesSection(SigilPage page, Composite parent, ISigilProjectModel project) throws CoreException
{
- super( page, parent, project );
+ super(page, parent, project);
}
-
@Override
protected String getTitle()
{
return "Export Packages";
}
-
@Override
- protected Label createLabel( Composite parent, FormToolkit toolkit )
+ protected Label createLabel(Composite parent, FormToolkit toolkit)
{
- return toolkit.createLabel( parent, "Specify which packages this bundle shares with other bundles." );
+ return toolkit.createLabel(parent,
+ "Specify which packages this bundle shares with other bundles.");
}
-
@Override
protected IContentProvider getContentProvider()
{
return new DefaultTableProvider()
{
- public Object[] getElements( Object inputElement )
+ public Object[] getElements(Object inputElement)
{
return getBundle().getBundleInfo().getExports().toArray();
}
};
}
-
@Override
protected void handleAdd()
{
- NewPackageExportDialog dialog = ResourcesDialogHelper.createNewExportDialog( getSection().getShell(),
- "Add Exported Package", null, getProjectModel(), true );
+ NewPackageExportDialog dialog = ResourcesDialogHelper.createNewExportDialog(
+ getSection().getShell(), "Add Exported Package", null, getProjectModel(),
+ true);
- if ( dialog.open() == Window.OK )
+ if (dialog.open() == Window.OK)
{
try
{
@@ -99,12 +95,13 @@
boolean exportsAdded = false;
List<IPackageFragment> newPkgFragments = dialog.getSelectedElements();
- for ( IPackageFragment pkgFragment : newPkgFragments )
+ for (IPackageFragment pkgFragment : newPkgFragments)
{
- IPackageExport pkgExport = ModelElementFactory.getInstance().newModelElement( IPackageExport.class );
- pkgExport.setPackageName( pkgFragment.getElementName() );
- pkgExport.setVersion( dialog.getVersion() );
- getBundle().getBundleInfo().addExport( pkgExport );
+ IPackageExport pkgExport = ModelElementFactory.getInstance().newModelElement(
+ IPackageExport.class);
+ pkgExport.setPackageName(pkgFragment.getElementName());
+ pkgExport.setVersion(dialog.getVersion());
+ getBundle().getBundleInfo().addExport(pkgExport);
exportsAdded = true;
}
@@ -114,106 +111,107 @@
boolean shouldAddImports = OptionalPrompt.optionallyPrompt(
SigilCore.PREFERENCES_ADD_IMPORT_FOR_EXPORT, "Add Exports",
- "Should corresponding imports be added?", getSection().getShell() );
- if ( shouldAddImports )
+ "Should corresponding imports be added?", getSection().getShell());
+ if (shouldAddImports)
{
- for ( IPackageFragment pkgFragment : newPkgFragments )
+ for (IPackageFragment pkgFragment : newPkgFragments)
{
IPackageImport pkgImport = ModelElementFactory.getInstance().newModelElement(
- IPackageImport.class );
- pkgImport.setPackageName( pkgFragment.getElementName() );
+ IPackageImport.class);
+ pkgImport.setPackageName(pkgFragment.getElementName());
Version version = dialog.getVersion();
- if ( version == null )
+ if (version == null)
{
version = getBundle().getVersion();
}
VersionRange versionRange = ModelHelper.getDefaultRange(version);
- pkgImport.setVersions( versionRange );
+ pkgImport.setVersions(versionRange);
- getBundle().getBundleInfo().addImport( pkgImport );
+ getBundle().getBundleInfo().addImport(pkgImport);
importsAdded = true;
}
}
- if ( importsAdded )
+ if (importsAdded)
{
refreshAllPages();
markDirty();
}
- else if ( exportsAdded )
+ else if (exportsAdded)
{
refresh();
markDirty();
}
}
- catch ( ModelElementFactoryException e )
+ catch (ModelElementFactoryException e)
{
- SigilCore.error( "Failed to buiild model element for package export", e );
+ SigilCore.error("Failed to buiild model element for package export", e);
}
}
}
-
@SuppressWarnings("unchecked")
@Override
protected void handleEdit()
{
- IStructuredSelection selection = ( IStructuredSelection ) getSelection();
+ IStructuredSelection selection = (IStructuredSelection) getSelection();
boolean changed = false;
- if ( !selection.isEmpty() )
+ if (!selection.isEmpty())
{
- for ( Iterator<IPackageExport> i = selection.iterator(); i.hasNext(); )
+ for (Iterator<IPackageExport> i = selection.iterator(); i.hasNext();)
{
IPackageExport packageExport = i.next();
- NewPackageExportDialog dialog = ResourcesDialogHelper.createNewExportDialog( getSection().getShell(),
- "Edit Imported Package", packageExport, getProjectModel(), false );
- if ( dialog.open() == Window.OK )
+ NewPackageExportDialog dialog = ResourcesDialogHelper.createNewExportDialog(
+ getSection().getShell(), "Edit Imported Package", packageExport,
+ getProjectModel(), false);
+ if (dialog.open() == Window.OK)
{
changed = true;
IPackageFragment pkgFragment = dialog.getSelectedElement();
- packageExport.setPackageName( pkgFragment.getElementName() );
- packageExport.setVersion( dialog.getVersion() );
+ packageExport.setPackageName(pkgFragment.getElementName());
+ packageExport.setVersion(dialog.getVersion());
}
}
}
- if ( changed )
+ if (changed)
{
refresh();
markDirty();
}
}
-
@SuppressWarnings("unchecked")
@Override
protected void handleRemoved()
{
- IStructuredSelection selection = ( IStructuredSelection ) getSelection();
-
- if ( !selection.isEmpty() )
+ IStructuredSelection selection = (IStructuredSelection) getSelection();
+
+ if (!selection.isEmpty())
{
boolean importsRemoved = false;
- boolean shouldRemoveImports = OptionalPrompt.optionallyPrompt(
+ boolean shouldRemoveImports = OptionalPrompt.optionallyPrompt(
SigilCore.PREFERENCES_REMOVE_IMPORT_FOR_EXPORT, "Remove Exports",
- "Should corresponding imports be removed?", getSection().getShell() );
-
+ "Should corresponding imports be removed?", getSection().getShell());
+
IBundleModelElement info = getBundle().getBundleInfo();
-
- for ( Iterator<IPackageExport> i = selection.iterator(); i.hasNext(); )
+
+ for (Iterator<IPackageExport> i = selection.iterator(); i.hasNext();)
{
IPackageExport pe = i.next();
- info.removeExport( pe );
-
+ info.removeExport(pe);
+
// Remove corresponding imports (maybe)
- if (shouldRemoveImports)
- {
- for(IPackageImport pi : info.getImports() ) {
- if (pi.getPackageName().equals(pe.getPackageName())) {
+ if (shouldRemoveImports)
+ {
+ for (IPackageImport pi : info.getImports())
+ {
+ if (pi.getPackageName().equals(pe.getPackageName()))
+ {
importsRemoved = true;
info.removeImport(pi);
}
@@ -221,28 +219,27 @@
}
}
- if ( importsRemoved )
+ if (importsRemoved)
{
refreshAllPages();
}
- else {
+ else
+ {
refresh();
}
-
+
markDirty();
}
}
-
/**
*
*/
private void refreshAllPages()
{
- ( ( SigilProjectEditorPart ) getPage().getEditor() ).refreshAllPages();
+ ((SigilProjectEditorPart) getPage().getEditor()).refreshAllPages();
}
-
private ISigilBundle getBundle()
{
return getProjectModel().getBundle();
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ExportsForm.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ExportsForm.java
index c83515b..9537ff6 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ExportsForm.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ExportsForm.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
-
import org.apache.felix.sigil.eclipse.SigilCore;
import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
import org.apache.felix.sigil.eclipse.ui.internal.form.SigilPage;
@@ -31,7 +30,6 @@
import org.eclipse.ui.forms.widgets.TableWrapData;
import org.eclipse.ui.forms.widgets.TableWrapLayout;
-
public class ExportsForm extends SigilPage
{
@@ -39,19 +37,17 @@
private ISigilProjectModel project;
-
- public ExportsForm( FormEditor editor, ISigilProjectModel project )
+ public ExportsForm(FormEditor editor, ISigilProjectModel project)
{
- super( editor, PAGE_ID, "Exports" );
+ super(editor, PAGE_ID, "Exports");
this.project = project;
}
-
@Override
- protected void createFormContent( IManagedForm managedForm )
+ protected void createFormContent(IManagedForm managedForm)
{
ScrolledForm form = managedForm.getForm();
- form.setText( "Exports" );
+ form.setText("Exports");
Composite body = form.getBody();
TableWrapLayout layout = new TableWrapLayout();
@@ -62,17 +58,18 @@
layout.numColumns = 1;
layout.horizontalSpacing = 10;
layout.verticalSpacing = 20;
- body.setLayout( layout );
- body.setLayoutData( new TableWrapData( TableWrapData.FILL ) );
+ body.setLayout(layout);
+ body.setLayoutData(new TableWrapData(TableWrapData.FILL));
try
{
- ExportPackagesSection exportPackages = new ExportPackagesSection( this, body, project );
- managedForm.addPart( exportPackages );
+ ExportPackagesSection exportPackages = new ExportPackagesSection(this, body,
+ project);
+ managedForm.addPart(exportPackages);
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- SigilCore.error( "Failed to create contents form", e );
+ SigilCore.error("Failed to create contents form", e);
}
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/GeneralInfoSection.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/GeneralInfoSection.java
index 77c713c..850a9e4 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/GeneralInfoSection.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/GeneralInfoSection.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
-
import org.apache.felix.sigil.common.model.ModelElementFactory;
import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
import org.apache.felix.sigil.common.model.osgi.IBundleModelElement;
@@ -45,7 +44,6 @@
import org.osgi.framework.BundleActivator;
import org.osgi.framework.Version;
-
/**
* @author dave
*
@@ -69,200 +67,194 @@
private SigilFormEntry activatorEntry;
private SigilFormEntry fragmentHostEntry;
-
/**
* @param parent
* @param toolkit
* @param style
* @throws CoreException
*/
- public GeneralInfoSection( SigilPage page, Composite parent, ISigilProjectModel project ) throws CoreException
+ public GeneralInfoSection(SigilPage page, Composite parent, ISigilProjectModel project) throws CoreException
{
- super( page, parent, project );
+ super(page, parent, project);
}
-
- protected void createSection( Section section, FormToolkit toolkit )
+ protected void createSection(Section section, FormToolkit toolkit)
{
- setTitle( "General Information" );
+ setTitle("General Information");
- Composite body = createGridBody( 3, false, toolkit );
+ Composite body = createGridBody(3, false, toolkit);
- Label label = toolkit.createLabel( body, "This section describes general information about this project." );
- label.setLayoutData( new GridData( SWT.LEFT, SWT.CENTER, true, false, 3, 1 ) );
+ Label label = toolkit.createLabel(body,
+ "This section describes general information about this project.");
+ label.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 3, 1));
- symbolicNameEntry = new SigilFormEntry( body, toolkit, "Symbolic Name" );
- symbolicNameEntry.setFormEntryListener( new SigilFormEntryAdapter()
+ symbolicNameEntry = new SigilFormEntry(body, toolkit, "Symbolic Name");
+ symbolicNameEntry.setFormEntryListener(new SigilFormEntryAdapter()
{
@Override
- public void textValueChanged( SigilFormEntry form )
+ public void textValueChanged(SigilFormEntry form)
{
- symbolicName = nullIfEmpty( ( String ) form.getValue() );
+ symbolicName = nullIfEmpty((String) form.getValue());
checkDirty();
}
- } );
+ });
- nameEntry = new SigilFormEntry( body, toolkit, "Name" );
- nameEntry.setFormEntryListener( new SigilFormEntryAdapter()
+ nameEntry = new SigilFormEntry(body, toolkit, "Name");
+ nameEntry.setFormEntryListener(new SigilFormEntryAdapter()
{
@Override
- public void textValueChanged( SigilFormEntry form )
+ public void textValueChanged(SigilFormEntry form)
{
- name = nullIfEmpty( ( String ) form.getValue() );
+ name = nullIfEmpty((String) form.getValue());
checkDirty();
}
- } );
+ });
- descriptionEntry = new SigilFormEntry( body, toolkit, "Description" );
- descriptionEntry.setFormEntryListener( new SigilFormEntryAdapter()
+ descriptionEntry = new SigilFormEntry(body, toolkit, "Description");
+ descriptionEntry.setFormEntryListener(new SigilFormEntryAdapter()
{
@Override
- public void textValueChanged( SigilFormEntry form )
+ public void textValueChanged(SigilFormEntry form)
{
- description = nullIfEmpty( ( String ) form.getValue() );
+ description = nullIfEmpty((String) form.getValue());
checkDirty();
}
- } );
+ });
IFormValueConverter converter = new IFormValueConverter()
{
- public String getLabel( Object value )
+ public String getLabel(Object value)
{
- Version v = ( Version ) value;
+ Version v = (Version) value;
return v.toString();
}
-
- public Object getValue( String label )
+ public Object getValue(String label)
{
- return VersionTable.getVersion( label );
+ return VersionTable.getVersion(label);
}
};
- versionEntry = new SigilFormEntry( body, toolkit, "Version", null, converter );
- versionEntry.setFormEntryListener( new SigilFormEntryAdapter()
+ versionEntry = new SigilFormEntry(body, toolkit, "Version", null, converter);
+ versionEntry.setFormEntryListener(new SigilFormEntryAdapter()
{
@Override
- public void textValueChanged( SigilFormEntry form )
+ public void textValueChanged(SigilFormEntry form)
{
- version = ( Version ) form.getValue();
+ version = (Version) form.getValue();
checkDirty();
}
- } );
+ });
- providerEntry = new SigilFormEntry( body, toolkit, "Provider" );
- providerEntry.setFormEntryListener( new SigilFormEntryAdapter()
+ providerEntry = new SigilFormEntry(body, toolkit, "Provider");
+ providerEntry.setFormEntryListener(new SigilFormEntryAdapter()
{
@Override
- public void textValueChanged( SigilFormEntry form )
+ public void textValueChanged(SigilFormEntry form)
{
- provider = nullIfEmpty( ( String ) form.getValue() );
+ provider = nullIfEmpty((String) form.getValue());
checkDirty();
}
- } );
+ });
- activatorEntry = new SigilFormEntry( body, toolkit, "Bundle Activator", "Browse...", null );
- activatorEntry.setFormEntryListener( new SigilFormEntryAdapter()
+ activatorEntry = new SigilFormEntry(body, toolkit, "Bundle Activator",
+ "Browse...", null);
+ activatorEntry.setFormEntryListener(new SigilFormEntryAdapter()
{
@Override
- public void textValueChanged( SigilFormEntry form )
+ public void textValueChanged(SigilFormEntry form)
{
- activator = ( String ) form.getValue();
+ activator = (String) form.getValue();
checkDirty();
}
-
@Override
- public void browseButtonSelected( SigilFormEntry form )
+ public void browseButtonSelected(SigilFormEntry form)
{
BackgroundLoadingSelectionDialog<String> dialog = ResourcesDialogHelper.createClassSelectDialog(
- getShell(), "Add Bundle Activator", getProjectModel(), activator, BundleActivator.class.getName() );
+ getShell(), "Add Bundle Activator", getProjectModel(), activator,
+ BundleActivator.class.getName());
- if ( dialog.open() == Window.OK )
+ if (dialog.open() == Window.OK)
{
- form.setValue( dialog.getSelectedElement() );
+ form.setValue(dialog.getSelectedElement());
}
}
- } );
+ });
converter = new IFormValueConverter()
{
- public String getLabel( Object value )
+ public String getLabel(Object value)
{
- IRequiredBundle b = ( IRequiredBundle ) value;
+ IRequiredBundle b = (IRequiredBundle) value;
return b == null ? null : b.getSymbolicName() + " " + b.getVersions();
}
-
- public Object getValue( String label )
+ public Object getValue(String label)
{
return null;
}
};
- fragmentHostEntry = new SigilFormEntry( body, toolkit, "Fragment Host", "Browse...", converter );
- fragmentHostEntry.setFormEntryListener( new SigilFormEntryAdapter()
+ fragmentHostEntry = new SigilFormEntry(body, toolkit, "Fragment Host",
+ "Browse...", converter);
+ fragmentHostEntry.setFormEntryListener(new SigilFormEntryAdapter()
{
@Override
- public void textValueChanged( SigilFormEntry form )
+ public void textValueChanged(SigilFormEntry form)
{
- fragmentHost = ( IRequiredBundle ) form.getValue();
+ fragmentHost = (IRequiredBundle) form.getValue();
checkDirty();
}
-
@Override
- public void browseButtonSelected( SigilFormEntry form )
+ public void browseButtonSelected(SigilFormEntry form)
{
- NewResourceSelectionDialog<IBundleModelElement> dialog = ResourcesDialogHelper
- .createRequiredBundleDialog( getSection().getShell(), "Add Required Bundle", getProjectModel(),
- null, getBundle().getBundleInfo().getRequiredBundles() );
+ NewResourceSelectionDialog<IBundleModelElement> dialog = ResourcesDialogHelper.createRequiredBundleDialog(
+ getSection().getShell(), "Add Required Bundle", getProjectModel(),
+ null, getBundle().getBundleInfo().getRequiredBundles());
- if ( dialog.open() == Window.OK )
+ if (dialog.open() == Window.OK)
{
- IRequiredBundle required = ModelElementFactory.getInstance()
- .newModelElement( IRequiredBundle.class );
- required.setSymbolicName( dialog.getSelectedName() );
- required.setVersions( dialog.getSelectedVersions() );
- form.setValue( required );
+ IRequiredBundle required = ModelElementFactory.getInstance().newModelElement(
+ IRequiredBundle.class);
+ required.setSymbolicName(dialog.getSelectedName());
+ required.setVersions(dialog.getSelectedVersions());
+ form.setValue(required);
}
}
- } );
- fragmentHostEntry.setFreeText( false );
+ });
+ fragmentHostEntry.setFreeText(false);
}
-
- private static String nullIfEmpty( String value )
+ private static String nullIfEmpty(String value)
{
- if ( value.trim().length() == 0 )
+ if (value.trim().length() == 0)
{
return null;
}
return value;
}
-
private Shell getShell()
{
return getSection().getShell();
}
-
@Override
- public void commit( boolean onSave )
+ public void commit(boolean onSave)
{
- getBundle().getBundleInfo().setSymbolicName( symbolicName );
- getBundle().getBundleInfo().setName( name );
- getBundle().getBundleInfo().setVersion( version );
- getBundle().getBundleInfo().setDescription( description );
- getBundle().getBundleInfo().setVendor( provider );
- getBundle().getBundleInfo().setFragmentHost( fragmentHost );
- getBundle().getBundleInfo().setActivator( activator );
+ getBundle().getBundleInfo().setSymbolicName(symbolicName);
+ getBundle().getBundleInfo().setName(name);
+ getBundle().getBundleInfo().setVersion(version);
+ getBundle().getBundleInfo().setDescription(description);
+ getBundle().getBundleInfo().setVendor(provider);
+ getBundle().getBundleInfo().setFragmentHost(fragmentHost);
+ getBundle().getBundleInfo().setActivator(activator);
- super.commit( onSave );
+ super.commit(onSave);
}
-
@Override
public void refresh()
{
@@ -274,39 +266,42 @@
fragmentHost = getProjectModel().getBundle().getBundleInfo().getFragmentHost();
activator = getProjectModel().getBundle().getBundleInfo().getActivator();
- nameEntry.setValue( name );
- symbolicNameEntry.setValue( symbolicName );
- versionEntry.setValue( version );
- descriptionEntry.setValue( description );
- providerEntry.setValue( provider );
- fragmentHostEntry.setValue( fragmentHost );
- activatorEntry.setValue( activator );
+ nameEntry.setValue(name);
+ symbolicNameEntry.setValue(symbolicName);
+ versionEntry.setValue(version);
+ descriptionEntry.setValue(description);
+ providerEntry.setValue(provider);
+ fragmentHostEntry.setValue(fragmentHost);
+ activatorEntry.setValue(activator);
super.refresh();
}
-
private void checkDirty()
{
- boolean dirty = different( symbolicName, getProjectModel().getBundle().getBundleInfo().getSymbolicName() )
- || different( name, getProjectModel().getBundle().getBundleInfo().getName() )
- || different( version, getProjectModel().getBundle().getBundleInfo().getVersion() )
- || different( description, getProjectModel().getBundle().getBundleInfo().getDescription() )
- || different( provider, getProjectModel().getBundle().getBundleInfo().getVendor() )
- || different( fragmentHost, getProjectModel().getBundle().getBundleInfo().getFragmentHost() )
- || different( activator, getProjectModel().getBundle().getBundleInfo().getActivator() );
+ boolean dirty = different(symbolicName,
+ getProjectModel().getBundle().getBundleInfo().getSymbolicName())
+ || different(name, getProjectModel().getBundle().getBundleInfo().getName())
+ || different(version,
+ getProjectModel().getBundle().getBundleInfo().getVersion())
+ || different(description,
+ getProjectModel().getBundle().getBundleInfo().getDescription())
+ || different(provider,
+ getProjectModel().getBundle().getBundleInfo().getVendor())
+ || different(fragmentHost,
+ getProjectModel().getBundle().getBundleInfo().getFragmentHost())
+ || different(activator,
+ getProjectModel().getBundle().getBundleInfo().getActivator());
- if ( dirty )
+ if (dirty)
markDirty();
}
-
- private boolean different( Object val1, Object val2 )
+ private boolean different(Object val1, Object val2)
{
- return val1 == null ? val2 != null : !val1.equals( val2 );
+ return val1 == null ? val2 != null : !val1.equals(val2);
}
-
private ISigilBundle getBundle()
{
return getProjectModel().getBundle();
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/IDependencyChecker.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/IDependencyChecker.java
index 695f8d0..e78c0df 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/IDependencyChecker.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/IDependencyChecker.java
@@ -19,15 +19,12 @@
package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
-
import org.apache.felix.sigil.common.model.osgi.IPackageImport;
import org.apache.felix.sigil.common.model.osgi.IRequiredBundle;
-
public interface IDependencyChecker
{
- boolean isSatisfied( IPackageImport packageImport );
+ boolean isSatisfied(IPackageImport packageImport);
-
- boolean isSatisfied( IRequiredBundle requiredBundle );
+ boolean isSatisfied(IRequiredBundle requiredBundle);
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ImportPackagesSection.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ImportPackagesSection.java
index b5eecc3..993a406 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ImportPackagesSection.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ImportPackagesSection.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -43,91 +42,85 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.forms.widgets.FormToolkit;
-
public class ImportPackagesSection extends BundleDependencySection
{
- public ImportPackagesSection( SigilPage page, Composite parent, ISigilProjectModel project,
- Set<IModelElement> unresolvedPackages ) throws CoreException
+ public ImportPackagesSection(SigilPage page, Composite parent, ISigilProjectModel project, Set<IModelElement> unresolvedPackages) throws CoreException
{
- super( page, parent, project, unresolvedPackages );
+ super(page, parent, project, unresolvedPackages);
}
-
@Override
protected String getTitle()
{
return "Import Packages";
}
-
@Override
- protected Label createLabel( Composite parent, FormToolkit toolkit )
+ protected Label createLabel(Composite parent, FormToolkit toolkit)
{
- return toolkit.createLabel( parent, "Specify which packages this bundle imports from other bundles." );
+ return toolkit.createLabel(parent,
+ "Specify which packages this bundle imports from other bundles.");
}
-
@Override
protected IContentProvider getContentProvider()
{
return new DefaultTableProvider()
{
- public Object[] getElements( Object inputElement )
+ public Object[] getElements(Object inputElement)
{
- ArrayList<IPackageImport> imports = new ArrayList<IPackageImport>( getBundle().getBundleInfo()
- .getImports() );
- Collections.sort( imports, new Comparator<IPackageImport>()
+ ArrayList<IPackageImport> imports = new ArrayList<IPackageImport>(
+ getBundle().getBundleInfo().getImports());
+ Collections.sort(imports, new Comparator<IPackageImport>()
{
- public int compare( IPackageImport o1, IPackageImport o2 )
+ public int compare(IPackageImport o1, IPackageImport o2)
{
- return o1.getPackageName().compareTo( o2.getPackageName() );
+ return o1.getPackageName().compareTo(o2.getPackageName());
}
- } );
+ });
return imports.toArray();
}
};
}
-
protected ISigilBundle getBundle()
{
return getProjectModel().getBundle();
}
-
@Override
protected void handleAdd()
{
NewResourceSelectionDialog<? extends IPackageModelElement> dialog = ResourcesDialogHelper.createImportDialog(
- getSection().getShell(), "Add Imported Package", getProjectModel(), null, getBundle().getBundleInfo()
- .getImports() );
+ getSection().getShell(), "Add Imported Package", getProjectModel(), null,
+ getBundle().getBundleInfo().getImports());
- if ( dialog.open() == Window.OK )
+ if (dialog.open() == Window.OK)
{
- IPackageImport pi = ModelElementFactory.getInstance().newModelElement( IPackageImport.class );
- pi.setPackageName( dialog.getSelectedName() );
- pi.setVersions( dialog.getSelectedVersions() );
- pi.setOptional( dialog.isOptional() );
+ IPackageImport pi = ModelElementFactory.getInstance().newModelElement(
+ IPackageImport.class);
+ pi.setPackageName(dialog.getSelectedName());
+ pi.setVersions(dialog.getSelectedVersions());
+ pi.setOptional(dialog.isOptional());
- getBundle().getBundleInfo().addImport( pi );
+ getBundle().getBundleInfo().addImport(pi);
refresh();
markDirty();
}
}
-
@SuppressWarnings("unchecked")
@Override
protected void handleRemoved()
{
- IStructuredSelection selection = ( IStructuredSelection ) getSelection();
+ IStructuredSelection selection = (IStructuredSelection) getSelection();
- if ( !selection.isEmpty() )
+ if (!selection.isEmpty())
{
- for ( Iterator<IPackageImport> i = selection.iterator(); i.hasNext(); )
+ for (Iterator<IPackageImport> i = selection.iterator(); i.hasNext();)
{
- getBundle().getBundleInfo().removeImport( i.next() );
+ getBundle().getBundleInfo().removeImport(i.next());
}
refresh();
@@ -135,38 +128,38 @@
}
}
-
@SuppressWarnings("unchecked")
@Override
protected void handleEdit()
{
- IStructuredSelection selection = ( IStructuredSelection ) getSelection();
+ IStructuredSelection selection = (IStructuredSelection) getSelection();
boolean changed = false;
- if ( !selection.isEmpty() )
+ if (!selection.isEmpty())
{
- for ( Iterator<IPackageImport> i = selection.iterator(); i.hasNext(); )
+ for (Iterator<IPackageImport> i = selection.iterator(); i.hasNext();)
{
IPackageImport packageImport = i.next();
- NewResourceSelectionDialog<? extends IPackageModelElement> dialog = ResourcesDialogHelper
- .createImportDialog( getSection().getShell(), "Edit Imported Package", getProjectModel(),
- packageImport, getBundle().getBundleInfo().getImports() );
- if ( dialog.open() == Window.OK )
+ NewResourceSelectionDialog<? extends IPackageModelElement> dialog = ResourcesDialogHelper.createImportDialog(
+ getSection().getShell(), "Edit Imported Package", getProjectModel(),
+ packageImport, getBundle().getBundleInfo().getImports());
+ if (dialog.open() == Window.OK)
{
changed = true;
- IPackageImport newImport = ModelElementFactory.getInstance().newModelElement( IPackageImport.class );
- newImport.setPackageName( dialog.getSelectedName() );
- newImport.setVersions( dialog.getSelectedVersions() );
- newImport.setOptional( dialog.isOptional() );
+ IPackageImport newImport = ModelElementFactory.getInstance().newModelElement(
+ IPackageImport.class);
+ newImport.setPackageName(dialog.getSelectedName());
+ newImport.setVersions(dialog.getSelectedVersions());
+ newImport.setOptional(dialog.isOptional());
- getBundle().getBundleInfo().removeImport( packageImport );
- getBundle().getBundleInfo().addImport( newImport );
+ getBundle().getBundleInfo().removeImport(packageImport);
+ getBundle().getBundleInfo().addImport(newImport);
}
}
}
- if ( changed )
+ if (changed)
{
refresh();
markDirty();
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/NewPackageExportDialog.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/NewPackageExportDialog.java
index 5b294c0..b6aeb1d 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/NewPackageExportDialog.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/NewPackageExportDialog.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
-
import java.util.Comparator;
import org.apache.felix.sigil.common.osgi.VersionTable;
@@ -40,19 +39,17 @@
import org.eclipse.swt.widgets.Text;
import org.osgi.framework.Version;
-
public class NewPackageExportDialog extends BackgroundLoadingSelectionDialog<IPackageFragment>
{
private static final IElementDescriptor<IPackageFragment> PKG_FRAGMENT_STRINGIFIER = new IElementDescriptor<IPackageFragment>()
{
- public String getLabel( IPackageFragment element )
+ public String getLabel(IPackageFragment element)
{
- return getName( element );
+ return getName(element);
}
-
- public String getName( IPackageFragment element )
+ public String getName(IPackageFragment element)
{
return element.getElementName();
}
@@ -60,122 +57,116 @@
private static final Comparator<IPackageFragment> PKG_FRAGMENT_COMPARATOR = new Comparator<IPackageFragment>()
{
- public int compare( IPackageFragment o1, IPackageFragment o2 )
+ public int compare(IPackageFragment o1, IPackageFragment o2)
{
- return o1.getElementName().compareTo( o2.getElementName() );
+ return o1.getElementName().compareTo(o2.getElementName());
}
};
private Version version = null;
private String error = null;
- private Version projectVersion = VersionTable.getVersion( 0, 0, 0 );
+ private Version projectVersion = VersionTable.getVersion(0, 0, 0);
private Button btnInheritBundleVersion;
private Button btnExplicitVersion;
private Text txtVersion;
-
- public NewPackageExportDialog( Shell parentShell, boolean multiSelect )
+ public NewPackageExportDialog(Shell parentShell, boolean multiSelect)
{
- super( parentShell, "Package:", multiSelect );
- setDescriptor( PKG_FRAGMENT_STRINGIFIER );
- setComparator( PKG_FRAGMENT_COMPARATOR );
+ super(parentShell, "Package:", multiSelect);
+ setDescriptor(PKG_FRAGMENT_STRINGIFIER);
+ setComparator(PKG_FRAGMENT_COMPARATOR);
}
-
@Override
- protected Control createDialogArea( Composite parent )
+ protected Control createDialogArea(Composite parent)
{
// Create controls
- Composite container = ( Composite ) super.createDialogArea( parent );
- Composite composite = new Composite( container, SWT.NONE );
+ Composite container = (Composite) super.createDialogArea(parent);
+ Composite composite = new Composite(container, SWT.NONE);
- Group grpVersion = new Group( composite, SWT.NONE );
- grpVersion.setText( "Version" );
+ Group grpVersion = new Group(composite, SWT.NONE);
+ grpVersion.setText("Version");
- btnInheritBundleVersion = new Button( grpVersion, SWT.RADIO );
- btnInheritBundleVersion.setText( "Inherit bundle version" );
- new Label( grpVersion, SWT.NONE ); // Spacer
- btnExplicitVersion = new Button( grpVersion, SWT.RADIO );
- btnExplicitVersion.setText( "Fixed version:" );
- txtVersion = new Text( grpVersion, SWT.BORDER );
+ btnInheritBundleVersion = new Button(grpVersion, SWT.RADIO);
+ btnInheritBundleVersion.setText("Inherit bundle version");
+ new Label(grpVersion, SWT.NONE); // Spacer
+ btnExplicitVersion = new Button(grpVersion, SWT.RADIO);
+ btnExplicitVersion.setText("Fixed version:");
+ txtVersion = new Text(grpVersion, SWT.BORDER);
// Initialize
- if ( version == null )
+ if (version == null)
{
- btnInheritBundleVersion.setSelection( true );
- txtVersion.setEnabled( false );
- txtVersion.setText( projectVersion.toString() );
+ btnInheritBundleVersion.setSelection(true);
+ txtVersion.setEnabled(false);
+ txtVersion.setText(projectVersion.toString());
}
else
{
- btnExplicitVersion.setSelection( true );
- txtVersion.setEnabled( true );
- txtVersion.setText( version.toString() );
+ btnExplicitVersion.setSelection(true);
+ txtVersion.setEnabled(true);
+ txtVersion.setText(version.toString());
}
updateButtons();
// Listeners
Listener radioAndTextListener = new Listener()
{
- public void handleEvent( Event event )
+ public void handleEvent(Event event)
{
error = null;
- if ( btnInheritBundleVersion.getSelection() )
+ if (btnInheritBundleVersion.getSelection())
{
version = null;
- txtVersion.setEnabled( false );
+ txtVersion.setEnabled(false);
}
else
{
- txtVersion.setEnabled( true );
+ txtVersion.setEnabled(true);
try
{
- version = VersionTable.getVersion( txtVersion.getText() );
+ version = VersionTable.getVersion(txtVersion.getText());
}
- catch ( IllegalArgumentException e )
+ catch (IllegalArgumentException e)
{
error = "Invalid version";
}
}
- setErrorMessage( error );
+ setErrorMessage(error);
updateButtons();
}
};
- txtVersion.addListener( SWT.Modify, radioAndTextListener );
- btnInheritBundleVersion.addListener( SWT.Selection, radioAndTextListener );
- btnExplicitVersion.addListener( SWT.Selection, radioAndTextListener );
+ txtVersion.addListener(SWT.Modify, radioAndTextListener);
+ btnInheritBundleVersion.addListener(SWT.Selection, radioAndTextListener);
+ btnExplicitVersion.addListener(SWT.Selection, radioAndTextListener);
// Layout
- composite.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
- composite.setLayout( new GridLayout( 1, false ) );
- grpVersion.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
- grpVersion.setLayout( new GridLayout( 2, false ) );
- txtVersion.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ composite.setLayout(new GridLayout(1, false));
+ grpVersion.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ grpVersion.setLayout(new GridLayout(2, false));
+ txtVersion.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
return container;
}
-
@Override
protected boolean canComplete()
{
return super.canComplete() && error == null;
}
-
- public void setProjectVersion( Version projectVersion )
+ public void setProjectVersion(Version projectVersion)
{
this.projectVersion = projectVersion;
}
-
- public void setVersion( Version version )
+ public void setVersion(Version version)
{
this.version = version;
}
-
public Version getVersion()
{
return version;
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/NewResourceSelectionDialog.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/NewResourceSelectionDialog.java
index 5aa0b54..ab14e0e 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/NewResourceSelectionDialog.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/NewResourceSelectionDialog.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
-
import org.apache.felix.sigil.common.model.osgi.IVersionedModelElement;
import org.apache.felix.sigil.common.osgi.VersionRange;
import org.apache.felix.sigil.eclipse.model.util.ModelHelper;
@@ -39,7 +38,6 @@
import org.eclipse.swt.widgets.Shell;
import org.osgi.framework.Version;
-
public class NewResourceSelectionDialog<E extends IVersionedModelElement> extends BackgroundLoadingSelectionDialog<E>
{
@@ -50,138 +48,129 @@
private VersionRange selectedVersions = null;
private boolean optional = false;
-
- public NewResourceSelectionDialog( Shell parentShell, String selectionLabel, boolean multi )
+ public NewResourceSelectionDialog(Shell parentShell, String selectionLabel, boolean multi)
{
- super( parentShell, selectionLabel, multi );
+ super(parentShell, selectionLabel, multi);
}
-
- public void setOptionalEnabled( boolean enabled )
+ public void setOptionalEnabled(boolean enabled)
{
optionalEnabled = enabled;
}
-
@Override
- protected Control createDialogArea( Composite parent )
+ protected Control createDialogArea(Composite parent)
{
// Create controls
- Composite container = ( Composite ) super.createDialogArea( parent );
- Composite composite = new Composite( container, SWT.NONE );
+ Composite container = (Composite) super.createDialogArea(parent);
+ Composite composite = new Composite(container, SWT.NONE);
- if ( optionalEnabled )
+ if (optionalEnabled)
{
- new Label( composite, SWT.NONE ); //Spacer
- btnOptional = new Button( composite, SWT.CHECK );
- btnOptional.setText( "Optional" );
+ new Label(composite, SWT.NONE); //Spacer
+ btnOptional = new Button(composite, SWT.CHECK);
+ btnOptional.setText("Optional");
}
- Label lblVersionRange = new Label( composite, SWT.NONE );
- lblVersionRange.setText( "Version Range:" );
- Group group = new Group( composite, SWT.BORDER );
+ Label lblVersionRange = new Label(composite, SWT.NONE);
+ lblVersionRange.setText("Version Range:");
+ Group group = new Group(composite, SWT.BORDER);
- pnlVersionRange = new VersionRangeComponent( group, SWT.NONE );
+ pnlVersionRange = new VersionRangeComponent(group, SWT.NONE);
// Initialize
- if ( selectedVersions != null )
+ if (selectedVersions != null)
{
- pnlVersionRange.setVersions( selectedVersions );
+ pnlVersionRange.setVersions(selectedVersions);
}
- if ( optionalEnabled )
+ if (optionalEnabled)
{
- btnOptional.setSelection( optional );
+ btnOptional.setSelection(optional);
updateButtons();
}
// Hookup Listeners
- pnlVersionRange.addVersionChangeListener( new VersionsChangeListener()
+ pnlVersionRange.addVersionChangeListener(new VersionsChangeListener()
{
- public void versionsChanged( VersionRange range )
+ public void versionsChanged(VersionRange range)
{
selectedVersions = range;
updateButtons();
}
- } );
- pnlVersionRange.addValidationListener( new IValidationListener()
+ });
+ pnlVersionRange.addValidationListener(new IValidationListener()
{
- public void validationMessage( String message, int level )
+ public void validationMessage(String message, int level)
{
- setMessage( message, level );
+ setMessage(message, level);
updateButtons();
}
- } );
+ });
- if ( optionalEnabled )
+ if (optionalEnabled)
{
- btnOptional.addSelectionListener( new SelectionAdapter()
+ btnOptional.addSelectionListener(new SelectionAdapter()
{
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
optional = btnOptional.getSelection();
}
- } );
+ });
}
// Layout
- composite.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
- GridLayout layout = new GridLayout( 2, false );
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ GridLayout layout = new GridLayout(2, false);
layout.verticalSpacing = 10;
layout.horizontalSpacing = 10;
- composite.setLayout( layout );
+ composite.setLayout(layout);
- lblVersionRange.setLayoutData( new GridData( SWT.LEFT, SWT.TOP, false, false ) );
- group.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
- group.setLayout( new FillLayout() );
+ lblVersionRange.setLayoutData(new GridData(SWT.LEFT, SWT.TOP, false, false));
+ group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ group.setLayout(new FillLayout());
return container;
}
-
@Override
- protected void elementSelected( E selection )
+ protected void elementSelected(E selection)
{
- if ( selection != null )
+ if (selection != null)
{
Version version = selection.getVersion();
selectedVersions = ModelHelper.getDefaultRange(version);
- pnlVersionRange.setVersions( selectedVersions );
+ pnlVersionRange.setVersions(selectedVersions);
}
}
-
@Override
protected synchronized boolean canComplete()
{
return super.canComplete() && selectedVersions != null;
}
-
public VersionRange getSelectedVersions()
{
return selectedVersions;
}
-
- public void setVersions( VersionRange versions )
+ public void setVersions(VersionRange versions)
{
selectedVersions = versions;
- if ( pnlVersionRange != null && !pnlVersionRange.isDisposed() )
+ if (pnlVersionRange != null && !pnlVersionRange.isDisposed())
{
- pnlVersionRange.setVersions( versions );
+ pnlVersionRange.setVersions(versions);
updateButtons();
}
}
-
public boolean isOptional()
{
return optional;
}
-
- public void setOptional( boolean optional )
+ public void setOptional(boolean optional)
{
this.optional = optional;
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/OverviewForm.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/OverviewForm.java
index d1c08f5..aa061e0 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/OverviewForm.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/OverviewForm.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
-
import org.apache.felix.sigil.eclipse.SigilCore;
import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
import org.apache.felix.sigil.eclipse.ui.internal.form.SigilPage;
@@ -31,7 +30,6 @@
import org.eclipse.ui.forms.widgets.TableWrapData;
import org.eclipse.ui.forms.widgets.TableWrapLayout;
-
/**
* @author dave
*
@@ -41,21 +39,19 @@
public static final String PAGE_ID = "overview";
private ISigilProjectModel sigil;
-
- public OverviewForm( SigilProjectEditorPart editor, ISigilProjectModel sigil )
+ public OverviewForm(SigilProjectEditorPart editor, ISigilProjectModel sigil)
{
- super( editor, PAGE_ID, "Overview" );
+ 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" );
+ form.setText("Overview");
Composite body = form.getBody();
TableWrapLayout layout = new TableWrapLayout();
@@ -65,28 +61,28 @@
layout.rightMargin = 10;
layout.numColumns = 2;
layout.horizontalSpacing = 10;
- body.setLayout( layout );
- body.setLayoutData( new TableWrapData( TableWrapData.FILL ) );
+ body.setLayout(layout);
+ body.setLayoutData(new TableWrapData(TableWrapData.FILL));
- Composite left = toolkit.createComposite( body );
+ Composite left = toolkit.createComposite(body);
layout = new TableWrapLayout();
layout.verticalSpacing = 20;
- left.setLayout( layout );
- left.setLayoutData( new TableWrapData( TableWrapData.FILL_GRAB ) );
+ left.setLayout(layout);
+ left.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
- Composite right = toolkit.createComposite( body );
+ Composite right = toolkit.createComposite(body);
layout = new TableWrapLayout();
layout.verticalSpacing = 20;
- right.setLayout( layout );
- right.setLayoutData( new TableWrapData( TableWrapData.FILL_GRAB ) );
+ right.setLayout(layout);
+ right.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
try
{
- GeneralInfoSection general = new GeneralInfoSection( this, left, sigil );
- managedForm.addPart( general );
+ GeneralInfoSection general = new GeneralInfoSection(this, left, sigil);
+ managedForm.addPart(general);
- ContentSummarySection content = new ContentSummarySection( this, right, sigil );
- managedForm.addPart( content );
+ ContentSummarySection content = new ContentSummarySection(this, right, sigil);
+ managedForm.addPart(content);
// XXX-FELIX
// commented out due to removal of runtime newton integration
@@ -94,12 +90,12 @@
//TestingSection testing = new TestingSection(this, right, newton);
//managedForm.addPart(testing);
- ToolsSection tools = new ToolsSection( this, right, sigil );
- managedForm.addPart( tools );
+ ToolsSection tools = new ToolsSection(this, right, sigil);
+ managedForm.addPart(tools);
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- SigilCore.error( "Failed to create overview form", e );
+ SigilCore.error("Failed to create overview form", e);
}
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/PackageExportDialog.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/PackageExportDialog.java
index 60f9e8b..b44eb5f 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/PackageExportDialog.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/PackageExportDialog.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
-
import org.apache.felix.sigil.common.osgi.VersionTable;
import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.ViewerFilter;
@@ -32,57 +31,51 @@
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 )
+ public PackageExportDialog(Shell parentShell, String title, IContentProvider content, ViewerFilter filter, Object scope)
{
- super( parentShell, content, filter, scope, title, "Package Name:", true );
+ super(parentShell, content, filter, scope, title, "Package Name:", true);
}
-
@Override
- protected void createCustom( Composite body )
+ 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()
+ 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 )
+ public void keyReleased(KeyEvent e)
{
try
{
- version = VersionTable.getVersion( versionText.getText() );
- setErrorMessage( null );
+ version = VersionTable.getVersion(versionText.getText());
+ setErrorMessage(null);
}
- catch ( IllegalArgumentException ex )
+ catch (IllegalArgumentException ex)
{
- setErrorMessage( "Invalid version" );
+ setErrorMessage("Invalid version");
}
}
- } );
- if ( version != null )
+ });
+ if (version != null)
{
- versionText.setText( version.toString() );
+ versionText.setText(version.toString());
}
}
-
public Version getVersion()
{
return version;
}
-
- public void setVersion( Version version )
+ public void setVersion(Version version)
{
this.version = version;
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ProjectLabelProvider.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ProjectLabelProvider.java
index 6eb6e4f..e90b342 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ProjectLabelProvider.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ProjectLabelProvider.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
-
import java.io.InputStream;
import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
@@ -40,7 +39,6 @@
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.widgets.Widget;
-
public class ProjectLabelProvider extends DefaultLabelProvider implements IBaseLabelProvider
{
@@ -48,50 +46,48 @@
private final ImageRegistry registry;
private final IDependencyChecker checker;
-
- public ProjectLabelProvider( Widget parent, ImageRegistry registry )
+ public ProjectLabelProvider(Widget parent, ImageRegistry registry)
{
- this( parent, registry, null );
+ this(parent, registry, null);
}
-
- public ProjectLabelProvider( Widget parent, ImageRegistry registry, IDependencyChecker checker )
+ public ProjectLabelProvider(Widget parent, ImageRegistry registry, IDependencyChecker checker)
{
this.parent = parent;
this.registry = registry;
this.checker = checker;
}
-
- public Image getImage( Object element )
+ public Image getImage(Object element)
{
Image result = null;
- if ( element instanceof ISigilBundle || element instanceof IRequiredBundle
- || element instanceof IBundleModelElement )
+ if (element instanceof ISigilBundle || element instanceof IRequiredBundle
+ || element instanceof IBundleModelElement)
{
result = findBundle();
}
- else if ( element instanceof IPackageImport )
+ else if (element instanceof IPackageImport)
{
- if ( checker != null )
+ if (checker != null)
{
- result = checker.isSatisfied( ( IPackageImport ) element ) ? findPackage() : findPackageError();
+ result = checker.isSatisfied((IPackageImport) element) ? findPackage()
+ : findPackageError();
}
else
{
result = findPackage();
}
}
- else if ( element instanceof IPackageExport )
+ else if (element instanceof IPackageExport)
{
result = findPackage();
}
- else if ( element instanceof IPackageFragmentRoot )
+ else if (element instanceof IPackageFragmentRoot)
{
- IPackageFragmentRoot root = ( IPackageFragmentRoot ) element;
+ IPackageFragmentRoot root = (IPackageFragmentRoot) element;
try
{
- if ( root.getKind() == IPackageFragmentRoot.K_SOURCE )
+ if (root.getKind() == IPackageFragmentRoot.K_SOURCE)
{
result = findPackage();
}
@@ -100,12 +96,12 @@
result = findBundle();
}
}
- catch ( JavaModelException e )
+ catch (JavaModelException e)
{
- SigilCore.error( "Failed to inspect package fragment root", e );
+ SigilCore.error("Failed to inspect package fragment root", e);
}
}
- else if ( element instanceof IClasspathEntry )
+ else if (element instanceof IClasspathEntry)
{
result = findPackage();
}
@@ -113,113 +109,109 @@
return result;
}
-
- public String getText( Object element )
+ public String getText(Object element)
{
- if ( element instanceof ISigilBundle )
+ if (element instanceof ISigilBundle)
{
- ISigilBundle bundle = ( ISigilBundle ) element;
+ ISigilBundle bundle = (ISigilBundle) element;
return bundle.getBundleInfo().getSymbolicName();
}
- if ( element instanceof IRequiredBundle )
+ if (element instanceof IRequiredBundle)
{
- IRequiredBundle req = ( IRequiredBundle ) element;
+ IRequiredBundle req = (IRequiredBundle) element;
return req.getSymbolicName() + " " + req.getVersions();
}
- if ( element instanceof IPackageImport )
+ if (element instanceof IPackageImport)
{
- IPackageImport req = ( IPackageImport ) element;
+ IPackageImport req = (IPackageImport) element;
return req.getPackageName() + " " + req.getVersions();
}
- if ( element instanceof IPackageExport )
+ if (element instanceof IPackageExport)
{
- IPackageExport pe = ( IPackageExport ) element;
+ IPackageExport pe = (IPackageExport) element;
return pe.getPackageName() + " " + pe.getVersion();
}
- if ( element instanceof IResource )
+ if (element instanceof IResource)
{
- IResource resource = ( IResource ) element;
+ IResource resource = (IResource) element;
return resource.getName();
}
- if ( element instanceof IPackageFragment )
+ if (element instanceof IPackageFragment)
{
- IPackageFragment f = ( IPackageFragment ) element;
+ IPackageFragment f = (IPackageFragment) element;
return f.getElementName();
}
- if ( element instanceof IPackageFragmentRoot )
+ if (element instanceof IPackageFragmentRoot)
{
- IPackageFragmentRoot f = ( IPackageFragmentRoot ) element;
+ IPackageFragmentRoot f = (IPackageFragmentRoot) element;
try
{
return f.getUnderlyingResource().getName();
}
- catch ( JavaModelException e )
+ catch (JavaModelException e)
{
return "unknown";
}
}
- if ( element instanceof IClasspathEntry )
+ if (element instanceof IClasspathEntry)
{
- IClasspathEntry cp = ( IClasspathEntry ) element;
+ IClasspathEntry cp = (IClasspathEntry) element;
return cp.getPath().toString();
}
return element.toString();
}
-
private Image findPackage()
{
- Image image = registry.get( "package" );
+ Image image = registry.get("package");
- if ( image == null )
+ if (image == null)
{
- image = loadImage( "icons/package_obj.png" );
- registry.put( "package", image );
+ 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 image = registry.get("package_error");
+ if (image == null)
{
- image = loadImage( "icons/package_obj_error.gif" );
- registry.put( "package_error", image );
+ image = loadImage("icons/package_obj_error.gif");
+ registry.put("package_error", image);
}
return image;
}
-
private Image findBundle()
{
- Image image = registry.get( "bundle" );
+ Image image = registry.get("bundle");
- if ( image == null )
+ if (image == null)
{
- image = loadImage( "icons/jar_obj.png" );
- registry.put( "bundle", image );
+ image = loadImage("icons/jar_obj.png");
+ registry.put("bundle", image);
}
return image;
}
-
- private Image loadImage( String resource )
+ private Image loadImage(String resource)
{
- InputStream in = ProjectLabelProvider.class.getClassLoader().getResourceAsStream( resource );
- ImageData data = new ImageData( in );
- return new Image( parent.getDisplay(), data );
+ InputStream in = ProjectLabelProvider.class.getClassLoader().getResourceAsStream(
+ resource);
+ ImageData data = new ImageData(in);
+ return new Image(parent.getDisplay(), data);
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ProjectTableViewer.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ProjectTableViewer.java
index 583b198..674ea0e 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ProjectTableViewer.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ProjectTableViewer.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
-
import java.util.Set;
import org.apache.felix.sigil.common.model.IModelElement;
@@ -28,35 +27,30 @@
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.swt.widgets.Table;
-
public class ProjectTableViewer extends TableViewer
{
private ModelLabelProvider labelProvider;
-
- public ProjectTableViewer( Table table )
+ public ProjectTableViewer(Table table)
{
- super( table );
+ super(table);
labelProvider = new ModelLabelProvider();
- setLabelProvider( labelProvider );
+ setLabelProvider(labelProvider);
}
-
@Override
- public void setContentProvider( IContentProvider provider )
+ public void setContentProvider(IContentProvider provider)
{
- super.setContentProvider( provider );
- setInput( getTable() );
+ super.setContentProvider(provider);
+ setInput(getTable());
}
-
- public void setUnresolvedElements( Set<? extends IModelElement> elements )
+ public void setUnresolvedElements(Set<? extends IModelElement> elements)
{
- labelProvider.setUnresolvedElements( elements );
+ labelProvider.setUnresolvedElements(elements);
}
-
@Override
public ModelLabelProvider getLabelProvider()
{
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/PropertiesForm.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/PropertiesForm.java
index 66a98de..8662fef 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/PropertiesForm.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/PropertiesForm.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
-
import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.propertiesfileeditor.IPropertiesFilePartitions;
@@ -27,27 +26,25 @@
import org.eclipse.jdt.ui.text.JavaTextTools;
import org.eclipse.jface.preference.IPreferenceStore;
-
@SuppressWarnings("restriction")
public class PropertiesForm extends SigilSourcePage
{
public static final String PAGE_ID = "properties";
-
- public PropertiesForm( SigilProjectEditorPart editor, ISigilProjectModel project )
+ public PropertiesForm(SigilProjectEditorPart editor, ISigilProjectModel project)
{
- super( PAGE_ID );
+ 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 ) );
+ setPreferenceStore(store);
+ setSourceViewerConfiguration(new PropertiesFileSourceViewerConfiguration(
+ textTools.getColorManager(), store, this,
+ IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING));
/*IFileEditorInput fileInput = (IFileEditorInput) editor.getEditorInput();
this.setDocumentProvider(fileInput);*/
}
-
@Override
public boolean isSaveAsAllowed()
{
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/RequiresBundleSection.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/RequiresBundleSection.java
index e4f692c..400795e 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/RequiresBundleSection.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/RequiresBundleSection.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
-
import java.util.Iterator;
import java.util.Set;
@@ -42,123 +41,116 @@
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
+ public RequiresBundleSection(SigilPage page, Composite parent, ISigilProjectModel project, Set<IModelElement> unresolvedElements) throws CoreException
{
- super( page, parent, project, unresolvedElements );
+ super(page, parent, project, unresolvedElements);
}
-
@Override
protected String getTitle()
{
return "Requires Bundles";
}
-
@Override
- protected Label createLabel( Composite parent, FormToolkit toolkit )
+ protected Label createLabel(Composite parent, FormToolkit toolkit)
{
- return toolkit.createLabel( parent, "Specify which bundles this bundle depends on." );
+ return toolkit.createLabel(parent,
+ "Specify which bundles this bundle depends on.");
}
-
@Override
protected IContentProvider getContentProvider()
{
return new DefaultTableProvider()
{
- public Object[] getElements( Object inputElement )
+ 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() );
+ getSection().getShell(), "Add Required Bundle", getProjectModel(), null,
+ getBundle().getBundleInfo().getRequiredBundles());
- if ( dialog.open() == Window.OK )
+ if (dialog.open() == Window.OK)
{
- IRequiredBundle required = ModelElementFactory.getInstance().newModelElement( IRequiredBundle.class );
- required.setSymbolicName( dialog.getSelectedName() );
- required.setVersions( dialog.getSelectedVersions() );
- required.setOptional( dialog.isOptional() );
+ IRequiredBundle required = ModelElementFactory.getInstance().newModelElement(
+ IRequiredBundle.class);
+ required.setSymbolicName(dialog.getSelectedName());
+ required.setVersions(dialog.getSelectedVersions());
+ required.setOptional(dialog.isOptional());
- getBundle().getBundleInfo().addRequiredBundle( required );
+ getBundle().getBundleInfo().addRequiredBundle(required);
refresh();
markDirty();
}
}
- catch ( ModelElementFactoryException e )
+ catch (ModelElementFactoryException e)
{
- SigilCore.error( "Failed to build required bundle", e );
+ SigilCore.error("Failed to build required bundle", e);
}
}
-
@SuppressWarnings("unchecked")
@Override
protected void handleEdit()
{
- IStructuredSelection selection = ( IStructuredSelection ) getSelection();
+ IStructuredSelection selection = (IStructuredSelection) getSelection();
boolean changed = false;
- if ( !selection.isEmpty() )
+ if (!selection.isEmpty())
{
- for ( Iterator<IRequiredBundle> i = selection.iterator(); i.hasNext(); )
+ 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 )
+ 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() );
+ requiredBundle.setSymbolicName(dialog.getSelectedName());
+ requiredBundle.setVersions(dialog.getSelectedVersions());
+ requiredBundle.setOptional(dialog.isOptional());
}
}
}
- if ( changed )
+ if (changed)
{
refresh();
markDirty();
}
}
-
@SuppressWarnings("unchecked")
@Override
protected void handleRemoved()
{
- IStructuredSelection selection = ( IStructuredSelection ) getSelection();
+ IStructuredSelection selection = (IStructuredSelection) getSelection();
- if ( !selection.isEmpty() )
+ if (!selection.isEmpty())
{
- for ( Iterator<IRequiredBundle> i = selection.iterator(); i.hasNext(); )
+ for (Iterator<IRequiredBundle> i = selection.iterator(); i.hasNext();)
{
- getBundle().getBundleInfo().removeRequiredBundle( i.next() );
+ getBundle().getBundleInfo().removeRequiredBundle(i.next());
}
refresh();
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ResourceBuildSection.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ResourceBuildSection.java
index 7965602..fe7678b 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ResourceBuildSection.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ResourceBuildSection.java
@@ -19,11 +19,9 @@
package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
-
import java.util.concurrent.Callable;
import java.util.concurrent.atomic.AtomicBoolean;
-
import org.apache.felix.sigil.common.config.Resource;
import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
import org.apache.felix.sigil.eclipse.SigilCore;
@@ -54,78 +52,73 @@
import org.eclipse.ui.model.BaseWorkbenchContentProvider;
import org.eclipse.ui.model.WorkbenchLabelProvider;
-
/**
* @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
+ public ResourceBuildSection(SigilPage page, Composite parent, ISigilProjectModel project) throws CoreException
{
- super( page, parent, project );
+ super(page, parent, project);
}
-
@Override
- protected void createSection( Section section, FormToolkit toolkit )
+ protected void createSection(Section section, FormToolkit toolkit)
{
- setTitle( "Resources" );
+ setTitle("Resources");
- Composite body = createTableWrapBody( 1, toolkit );
+ Composite body = createTableWrapBody(1, toolkit);
- toolkit.createLabel( body, "Specify which resources are included in the bundle." );
+ 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." );
+ 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 );
+ TableWrapData data = new TableWrapData(TableWrapData.FILL_GRAB);
data.heightHint = 200;
- tree.setLayoutData( data );
+ tree.setLayoutData(data);
- viewer = new CheckboxTreeViewer( tree );
+ viewer = new CheckboxTreeViewer(tree);
IProject base = getProjectModel().getProject();
viewer.setContentProvider(new BaseWorkbenchContentProvider());
viewer.setLabelProvider(new WorkbenchLabelProvider());
- viewer.addCheckStateListener( this );
+ viewer.addCheckStateListener(this);
resourcesFilter = new ExcludedResourcesFilter();
- viewer.addFilter( resourcesFilter );
- viewer.setInput( base );
+ viewer.addFilter(resourcesFilter);
+ viewer.setInput(base);
- link.addListener( SWT.Selection, new Listener()
+ link.addListener(SWT.Selection, new Listener()
{
- public void handleEvent( Event event )
+ public void handleEvent(Event event)
{
- if ( "excludedResourcePrefs".equals( event.text ) )
+ if ("excludedResourcePrefs".equals(event.text))
{
- PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn( getPage().getEditorSite()
- .getShell(), SigilCore.EXCLUDED_RESOURCES_PREFERENCES_ID, null, null );
+ PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(
+ getPage().getEditorSite().getShell(),
+ SigilCore.EXCLUDED_RESOURCES_PREFERENCES_ID, null, null);
dialog.open();
}
}
- } );
+ });
- SigilCore.getDefault().getPreferenceStore().addPropertyChangeListener( this );
+ SigilCore.getDefault().getPreferenceStore().addPropertyChangeListener(this);
- startWorkspaceListener( base.getWorkspace() );
+ startWorkspaceListener(base.getWorkspace());
}
-
@Override
- public void commit( boolean onSave )
+ public void commit(boolean onSave)
{
ISigilBundle bundle = getProjectModel().getBundle();
@@ -133,25 +126,25 @@
try
{
- SigilUI.runInUISync( new Callable<Void>()
+ SigilUI.runInUISync(new Callable<Void>()
{
public Void call() throws Exception
{
- for ( Object o : viewer.getCheckedElements() )
+ for (Object o : viewer.getCheckedElements())
{
- if ( !viewer.getGrayed( o ) )
+ if (!viewer.getGrayed(o))
{
- IResource r = ( IResource ) o;
-
- getProjectModel().getBundle().addSourcePath( toBldResource(r) );
+ IResource r = (IResource) o;
+
+ getProjectModel().getBundle().addSourcePath(toBldResource(r));
}
}
-
+
return null;
}
- } );
+ });
- super.commit( onSave );
+ super.commit(onSave);
}
catch (Exception e)
{
@@ -159,43 +152,41 @@
}
}
-
@Override
protected void refreshSelections()
{
// zero the state
- for ( Resource path : getProjectModel().getBundle().getSourcePaths() )
+ for (Resource path : getProjectModel().getBundle().getSourcePaths())
{
- IResource r = findResource( new Path(path.getLocalFile()) );
- if ( r != null )
+ IResource r = findResource(new Path(path.getLocalFile()));
+ if (r != null)
{
- viewer.expandToLevel( r, 0 );
- viewer.setChecked( r, true );
- viewer.setGrayed( r, false );
- handleStateChanged( r, true, false, false );
+ viewer.expandToLevel(r, 0);
+ viewer.setChecked(r, true);
+ viewer.setGrayed(r, false);
+ handleStateChanged(r, true, false, false);
}
else
{
- SigilCore.error( "Unknown path " + path );
+ SigilCore.error("Unknown path " + path);
}
}
}
-
@Override
- protected void syncResourceModel( IResource element, boolean checked )
+ protected void syncResourceModel(IResource element, boolean checked)
{
try
{
Resource resource = toBldResource(element);
-
- if ( checked )
+
+ if (checked)
{
- getProjectModel().getBundle().addSourcePath( resource );
+ getProjectModel().getBundle().addSourcePath(resource);
}
else
{
- getProjectModel().getBundle().removeSourcePath( resource );
+ getProjectModel().getBundle().removeSourcePath(resource);
}
markDirty();
@@ -213,28 +204,31 @@
*/
private Resource toBldResource(IResource element) throws CoreException
{
- return getProjectModel().getBldProject().newResource(element.getProjectRelativePath().toString());
+ return getProjectModel().getBldProject().newResource(
+ element.getProjectRelativePath().toString());
}
private AtomicBoolean disposed = new AtomicBoolean();
-
+
@Override
public void dispose()
{
- disposed.set( true );
- SigilCore.getDefault().getPreferenceStore().removePropertyChangeListener( this );
+ disposed.set(true);
+ SigilCore.getDefault().getPreferenceStore().removePropertyChangeListener(this);
super.dispose();
}
-
- public void propertyChange( PropertyChangeEvent event )
+ public void propertyChange(PropertyChangeEvent event)
{
- if ( !disposed.get() ) {
+ if (!disposed.get())
+ {
resourcesFilter.loadExclusions();
- try {
+ try
+ {
viewer.refresh();
}
- catch (SWTException e) {
+ catch (SWTException e)
+ {
// can happen on dispose
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ResourceImportDialog.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ResourceImportDialog.java
index 6cde232..e667941 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ResourceImportDialog.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ResourceImportDialog.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
-
import org.apache.felix.sigil.common.model.ModelElementFactory;
import org.apache.felix.sigil.common.model.osgi.IPackageImport;
import org.apache.felix.sigil.common.osgi.VersionRange;
@@ -31,81 +30,73 @@
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 )
+ public ResourceImportDialog(Shell parentShell, String title, String label, IContentProvider content, ViewerFilter filter, Object scope)
{
- super( parentShell, content, filter, scope, title, label, true );
+ super(parentShell, content, filter, scope, title, label, true);
}
-
public VersionRange getVersions()
{
return range;
}
-
@Override
- protected void createCustom( Composite body )
+ protected void createCustom(Composite body)
{
- versions = new VersionRangeComponent( body, SWT.BORDER );
- versions.addVersionChangeListener( this );
- versions.setVersions( range );
+ versions = new VersionRangeComponent(body, SWT.BORDER);
+ versions.addVersionChangeListener(this);
+ versions.setVersions(range);
- GridData data = new GridData( SWT.LEFT, SWT.TOP, true, true );
+ GridData data = new GridData(SWT.LEFT, SWT.TOP, true, true);
data.horizontalSpan = 2;
data.widthHint = 300;
data.heightHint = 200;
- versions.setLayoutData( data );
+ versions.setLayoutData(data);
}
-
@Override
- protected void selectionChanged( SelectionChangedEvent event )
+ protected void selectionChanged(SelectionChangedEvent event)
{
- if ( event.getSelection().isEmpty() )
+ if (event.getSelection().isEmpty())
{
- versions.setEnabled( false );
+ versions.setEnabled(false);
}
else
{
- versions.setEnabled( true );
+ versions.setEnabled(true);
}
}
-
- public void versionsChanged( VersionRange range )
+ public void versionsChanged(VersionRange range)
{
this.range = range;
- if ( range == null )
+ if (range == null)
{
- setErrorMessage( "Invalid version" );
+ setErrorMessage("Invalid version");
}
else
{
- setErrorMessage( null );
+ setErrorMessage(null);
}
}
-
- public void setVersions( VersionRange range )
+ 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() );
+ IPackageImport packageImport = ModelElementFactory.getInstance().newModelElement(
+ IPackageImport.class);
+ packageImport.setPackageName((String) getSelected()[0]);
+ packageImport.setVersions(getVersions());
return packageImport;
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ResourceSelectDialog.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ResourceSelectDialog.java
index 00bb575..7b7740a 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ResourceSelectDialog.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ResourceSelectDialog.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
-
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@@ -58,7 +57,6 @@
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.Text;
-
public class ResourceSelectDialog extends Dialog
{
@@ -69,22 +67,20 @@
{
private int check;
-
- public UpdateViewerRunnable( int check )
+ public UpdateViewerRunnable(int check)
{
this.check = check;
}
-
public void run()
{
- if ( check == keyCheck.get() )
+ if (check == keyCheck.get())
{
try
{
viewer.refresh();
}
- catch ( SWTException e )
+ catch (SWTException e)
{
// discard
}
@@ -119,11 +115,9 @@
private IContentProvider content;
private ILabelProvider labelProvider;
-
- public ResourceSelectDialog( Shell parentShell, IContentProvider content, ViewerFilter filter, Object scope,
- String title, String selectionText, boolean isCombo )
+ public ResourceSelectDialog(Shell parentShell, IContentProvider content, ViewerFilter filter, Object scope, String title, String selectionText, boolean isCombo)
{
- super( parentShell );
+ super(parentShell);
this.title = title;
this.selectionText = selectionText;
this.content = content;
@@ -132,18 +126,16 @@
this.isCombo = isCombo;
}
-
- public void setJob( Job job )
+ public void setJob(Job job)
{
this.job = job;
}
-
public void refreshResources()
{
try
{
- getShell().getDisplay().asyncExec( new Runnable()
+ getShell().getDisplay().asyncExec(new Runnable()
{
public void run()
{
@@ -151,65 +143,63 @@
{
viewer.refresh();
}
- catch ( SWTException e )
+ catch (SWTException e)
{
// attempt to exec after dialog closed - discard
}
}
- } );
+ });
}
- catch ( NullPointerException e )
+ catch (NullPointerException e)
{
// attempt to exec after dialog closed - discard
}
- catch ( SWTException e )
+ 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 )
+ protected void configureShell(Shell shell)
{
- super.configureShell( shell );
- if ( title != null )
+ super.configureShell(shell);
+ if (title != null)
{
- shell.setText( title );
+ shell.setText(title);
}
}
-
@Override
public void create()
{
super.create();
- if ( getItemCount() == 0 )
+ if (getItemCount() == 0)
{
- setErrorMessage( "No resources available" );
- getButton( IDialogConstants.OK_ID ).setEnabled( false );
+ 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 );
+ ISelection selection = selected == null ? EMPTY_SELECTION
+ : new SingletonSelection(selected);
+ setSelected(new SelectionChangedEvent(viewer, selection), true);
}
- if ( job != null )
+ if (job != null)
{
job.schedule();
}
}
-
@Override
public boolean close()
{
- if ( job != null )
+ if (job != null)
{
job.cancel();
}
@@ -217,10 +207,9 @@
return super.close();
}
-
private int getItemCount()
{
- if ( isCombo )
+ if (isCombo)
{
return resourceNameCombo.getItemCount();
}
@@ -230,135 +219,131 @@
}
}
-
@Override
- protected Control createDialogArea( Composite parent )
+ protected Control createDialogArea(Composite parent)
{
- Composite body = ( Composite ) super.createDialogArea( parent );
+ Composite body = (Composite) super.createDialogArea(parent);
- GridLayout layout = ( GridLayout ) body.getLayout();
+ 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 )
+ 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 );
+ l.setLayoutData(data);
- if ( isCombo )
+ if (isCombo)
{
- createCombo( body );
+ createCombo(body);
}
else
{
- createTable( body );
+ createTable(body);
}
- viewer.addFilter( filter );
- viewer.setContentProvider( content );
- viewer.setLabelProvider( getLabelProvider() );
- viewer.setComparator( new ViewerComparator() );
- viewer.setInput( scope );
+ viewer.addFilter(filter);
+ viewer.setContentProvider(content);
+ viewer.setLabelProvider(getLabelProvider());
+ viewer.setComparator(new ViewerComparator());
+ viewer.setInput(scope);
- viewer.addSelectionChangedListener( new ISelectionChangedListener()
+ viewer.addSelectionChangedListener(new ISelectionChangedListener()
{
- public void selectionChanged( SelectionChangedEvent event )
+ public void selectionChanged(SelectionChangedEvent event)
{
- setSelected( event, false );
+ setSelected(event, false);
}
- } );
- createCustom( body );
+ });
+ createCustom(body);
- errorMessageText = new Text( body, SWT.READ_ONLY | SWT.WRAP );
- data = new GridData( GridData.GRAB_HORIZONTAL | GridData.HORIZONTAL_ALIGN_FILL );
+ 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 );
+ errorMessageText.setLayoutData(data);
+ errorMessageText.setBackground(errorMessageText.getDisplay().getSystemColor(
+ SWT.COLOR_WIDGET_BACKGROUND));
+ setErrorMessage(errorMessage);
return body;
}
-
- protected void createCustom( Composite body )
+ protected void createCustom(Composite body)
{
}
-
- private void createCombo( Composite body )
+ private void createCombo(Composite body)
{
- resourceNameCombo = new Combo( body, SWT.SINGLE | SWT.BORDER );
- GridData data = new GridData( GridData.HORIZONTAL_ALIGN_END );
+ resourceNameCombo = new Combo(body, SWT.SINGLE | SWT.BORDER);
+ GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END);
data.widthHint = 200;
- resourceNameCombo.setLayoutData( data );
+ resourceNameCombo.setLayoutData(data);
- viewer = new ComboViewer( resourceNameCombo );
+ viewer = new ComboViewer(resourceNameCombo);
}
-
- private void createTable( Composite body )
+ private void createTable(Composite body)
{
- final Text txtFilter = new Text( body, SWT.BORDER );
- GridData data = new GridData( GridData.HORIZONTAL_ALIGN_END );
+ 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 );
+ txtFilter.setLayoutData(data);
- resourceNameTable = new Table( body, SWT.MULTI | SWT.BORDER );
- data = new GridData( GridData.HORIZONTAL_ALIGN_END );
+ resourceNameTable = new Table(body, SWT.MULTI | SWT.BORDER);
+ data = new GridData(GridData.HORIZONTAL_ALIGN_END);
data.widthHint = 400;
data.heightHint = 400;
- resourceNameTable.setLayoutData( data );
+ resourceNameTable.setLayoutData(data);
- viewer = new TableViewer( resourceNameTable );
+ viewer = new TableViewer(resourceNameTable);
- txtFilter.addKeyListener( new KeyAdapter()
+ txtFilter.addKeyListener(new KeyAdapter()
{
@Override
- public void keyReleased( KeyEvent e )
+ public void keyReleased(KeyEvent e)
{
- switch ( e.keyCode )
+ switch (e.keyCode)
{
case SWT.ARROW_UP:
- scrollTable( -1 );
+ scrollTable(-1);
break;
case SWT.ARROW_DOWN:
- scrollTable( +1 );
+ scrollTable(+1);
break;
default:
- Runnable r = new UpdateViewerRunnable( keyCheck.incrementAndGet() );
- background.schedule( r, 100, TimeUnit.MILLISECONDS );
+ 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 )
+ public boolean select(Viewer viewer, Object parentElement, Object element)
{
- return getLabelProvider().getText( element ).startsWith( txtFilter.getText() );
+ return getLabelProvider().getText(element).startsWith(txtFilter.getText());
}
};
- viewer.addFilter( filter );
+ viewer.addFilter(filter);
}
-
- private void scrollTable( int delta )
+ private void scrollTable(int delta)
{
int i = resourceNameTable.getSelectionIndex();
- if ( i == -1 )
+ if (i == -1)
{
- if ( delta < 0 )
+ if (delta < 0)
{
i = resourceNameTable.getItemCount() - 1;
}
@@ -372,87 +357,80 @@
i += delta;
}
- if ( i > -1 && i < resourceNameTable.getItemCount() )
+ 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 );
+ 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 )
+ private void setSelected(SelectionChangedEvent event, boolean reveal)
{
- if ( event.getSelection().isEmpty() )
+ if (event.getSelection().isEmpty())
{
selected = null;
- setErrorMessage( "No resource selected" );
+ setErrorMessage("No resource selected");
}
else
{
- selected = ( ( IStructuredSelection ) event.getSelection() ).toArray();
- setErrorMessage( null );
+ selected = ((IStructuredSelection) event.getSelection()).toArray();
+ setErrorMessage(null);
}
- selectionChanged( event );
+ selectionChanged(event);
- if ( reveal && !event.getSelection().isEmpty() )
+ if (reveal && !event.getSelection().isEmpty())
{
- if ( resourceNameCombo != null )
+ if (resourceNameCombo != null)
{
- IStructuredSelection sel = ( IStructuredSelection ) event.getSelection();
- resourceNameCombo.select( resourceNameCombo.indexOf( ( String ) sel.getFirstElement() ) );
+ IStructuredSelection sel = (IStructuredSelection) event.getSelection();
+ resourceNameCombo.select(resourceNameCombo.indexOf((String) sel.getFirstElement()));
}
else
{
- viewer.setSelection( event.getSelection(), true );
+ viewer.setSelection(event.getSelection(), true);
}
}
}
-
protected ILabelProvider getLabelProvider()
{
return labelProvider;
}
-
public Object[] getSelected()
{
return selected;
}
-
- public void setSelected( Object[] selected )
+ public void setSelected(Object[] selected)
{
this.selected = selected;
}
-
- protected void selectionChanged( SelectionChangedEvent event )
+ protected void selectionChanged(SelectionChangedEvent event)
{
}
-
- public void setErrorMessage( String errorMessage )
+ public void setErrorMessage(String errorMessage)
{
this.errorMessage = errorMessage;
- if ( errorMessageText != null && !errorMessageText.isDisposed() )
+ if (errorMessageText != null && !errorMessageText.isDisposed())
{
- errorMessageText.setText( errorMessage == null ? " \n " : errorMessage );
+ errorMessageText.setText(errorMessage == null ? " \n " : errorMessage);
boolean hasError = errorMessage != null
- && ( StringConverter.removeWhiteSpaces( errorMessage ) ).length() > 0;
- errorMessageText.setEnabled( hasError );
- errorMessageText.setVisible( hasError );
+ && (StringConverter.removeWhiteSpaces(errorMessage)).length() > 0;
+ errorMessageText.setEnabled(hasError);
+ errorMessageText.setVisible(hasError);
errorMessageText.getParent().update();
- Control ok = getButton( IDialogConstants.OK_ID );
- if ( ok != null )
+ Control ok = getButton(IDialogConstants.OK_ID);
+ if (ok != null)
{
- ok.setEnabled( !hasError );
+ ok.setEnabled(!hasError);
}
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/SigilProjectEditorPart.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/SigilProjectEditorPart.java
index d415457..8992870 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/SigilProjectEditorPart.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/SigilProjectEditorPart.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
-
import java.lang.reflect.InvocationTargetException;
import java.util.Collections;
import java.util.HashSet;
@@ -62,68 +61,68 @@
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 final Set<IModelElement> unresolvedElements = Collections.synchronizedSet(new HashSet<IModelElement>());
private ISigilProjectModel project;
private ISigilProjectModel tempProject;
private volatile boolean saving = false;
private int dependenciesPageIndex;
- private Image errorImage = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
+ private Image errorImage = PlatformUI.getWorkbench().getSharedImages().getImage(
+ ISharedImages.IMG_OBJS_ERROR_TSK);
private PropertiesForm textPage;
-
public IProject getProject()
{
- IFileEditorInput fileInput = ( IFileEditorInput ) getEditorInput();
+ 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 )
+ public void doSave(IProgressMonitor monitor)
{
- monitor.beginTask( "Saving", IProgressMonitor.UNKNOWN );
+ monitor.beginTask("Saving", IProgressMonitor.UNKNOWN);
try
{
saving = true;
- new ProgressMonitorDialog( getSite().getShell() ).run( true, true, new IRunnableWithProgress()
- {
- public void run( IProgressMonitor monitor ) throws InvocationTargetException,
- InterruptedException
+ new ProgressMonitorDialog(getSite().getShell()).run(true, true,
+ new IRunnableWithProgress()
{
- try
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException
{
- if ( doInternalSave(monitor) ) {
- project.setBundle( null );
- tempProject.setBundle(null);
- project.rebuildDependencies(monitor);
- refreshAllPages();
- }
+ try
+ {
+ if (doInternalSave(monitor))
+ {
+ project.setBundle(null);
+ tempProject.setBundle(null);
+ project.rebuildDependencies(monitor);
+ refreshAllPages();
+ }
- monitor.done();
+ monitor.done();
+ }
+ catch (CoreException e)
+ {
+ throw new InvocationTargetException(e);
+ }
}
- catch ( CoreException e )
- {
- throw new InvocationTargetException( e );
- }
- }
- } );
+ });
}
- catch ( InvocationTargetException e )
+ catch (InvocationTargetException e)
{
- SigilCore.error( "Failed to save " + project, e.getTargetException() );
+ SigilCore.error("Failed to save " + project, e.getTargetException());
}
- catch ( InterruptedException e )
+ catch (InterruptedException e)
{
- monitor.setCanceled( true );
+ monitor.setCanceled(true);
return;
}
finally
@@ -133,40 +132,38 @@
monitor.done();
}
-
private boolean doInternalSave(final IProgressMonitor monitor) throws CoreException
{
- if ( textPage.isDirty() )
+ if (textPage.isDirty())
{
- SigilUI.runInUISync( new Runnable()
+ SigilUI.runInUISync(new Runnable()
{
public void run()
{
- textPage.doSave( monitor );
+ textPage.doSave(monitor);
}
- } );
+ });
return true;
}
- else if ( isDirty() )
+ else if (isDirty())
{
- commitPages( true );
- tempProject.save( monitor, false );
- SigilUI.runInUISync( new Runnable()
+ commitPages(true);
+ tempProject.save(monitor, false);
+ SigilUI.runInUISync(new Runnable()
{
public void run()
{
textPage.setInput(getEditorInput());
editorDirtyStateChanged();
}
- } );
+ });
return true;
}
-
+
// ok no changes
return false;
}
-
/* (non-Javadoc)
* @see org.eclipse.ui.forms.editor.FormEditor#addPages()
*/
@@ -175,36 +172,35 @@
{
try
{
- addPage( new OverviewForm( this, tempProject ) );
- addPage( new ContentsForm( this, tempProject ) );
- dependenciesPageIndex = addPage( new DependenciesForm( this, tempProject, unresolvedElements ) );
- addPage( new ExportsForm( this, tempProject ) );
- textPage = new PropertiesForm( this, tempProject );
- addPage( textPage, getEditorInput() );
- setPartName( project.getSymbolicName() );
+ addPage(new OverviewForm(this, tempProject));
+ addPage(new ContentsForm(this, tempProject));
+ dependenciesPageIndex = addPage(new DependenciesForm(this, tempProject,
+ unresolvedElements));
+ addPage(new ExportsForm(this, tempProject));
+ textPage = new PropertiesForm(this, tempProject);
+ addPage(textPage, getEditorInput());
+ setPartName(project.getSymbolicName());
refreshTabImages();
}
- catch ( PartInitException e )
+ catch (PartInitException e)
{
- SigilCore.error( "Failed to build " + this, e );
+ SigilCore.error("Failed to build " + this, e);
}
}
-
protected void refreshTabImages()
{
- if ( unresolvedElements.isEmpty() )
+ if (unresolvedElements.isEmpty())
{
- setPageImage( dependenciesPageIndex, null );
+ setPageImage(dependenciesPageIndex, null);
}
else
{
- setPageImage( dependenciesPageIndex, errorImage );
+ setPageImage(dependenciesPageIndex, errorImage);
}
}
-
/* (non-Javadoc)
* @see org.eclipse.ui.part.EditorPart#doSaveAs()
*/
@@ -214,7 +210,6 @@
// save as not allowed
}
-
/* (non-Javadoc)
* @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
*/
@@ -224,20 +219,19 @@
return false;
}
-
@Override
public void dispose()
{
- ResourcesPlugin.getWorkspace().removeResourceChangeListener( this );
+ ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
super.dispose();
}
-
- public void resourceChanged( IResourceChangeEvent event )
+ public void resourceChanged(IResourceChangeEvent event)
{
try
{
- switch (event.getType()) {
+ switch (event.getType())
+ {
case IResourceChangeEvent.POST_BUILD:
handleBuild(event);
break;
@@ -246,36 +240,35 @@
break;
}
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- ErrorDialog.openError( getSite().getShell(), "Error", null, e.getStatus() );
+ ErrorDialog.openError(getSite().getShell(), "Error", null, e.getStatus());
}
}
-
private void handleBuild(IResourceChangeEvent event) throws CoreException
{
refreshView();
}
-
private void handleChange(IResourceChangeEvent event) throws CoreException
{
IResourceDelta delta = event.getDelta();
- final IFile editorFile = ( ( IFileEditorInput ) getEditorInput() ).getFile();
- delta.accept( new IResourceDeltaVisitor()
+ final IFile editorFile = ((IFileEditorInput) getEditorInput()).getFile();
+ delta.accept(new IResourceDeltaVisitor()
{
- public boolean visit( IResourceDelta delta ) throws CoreException
+ public boolean visit(IResourceDelta delta) throws CoreException
{
int kind = delta.getKind();
IResource resource = delta.getResource();
- if ( resource instanceof IProject )
+ if (resource instanceof IProject)
{
int flags = delta.getFlags();
- return handleProjectChange(editorFile, (IProject) resource, kind, flags);
+ return handleProjectChange(editorFile, (IProject) resource, kind,
+ flags);
}
- if ( resource instanceof IFile )
+ if (resource instanceof IFile)
{
handleFileChange(editorFile, (IFile) resource, kind);
// Recurse no more
@@ -284,158 +277,155 @@
return true;
}
- } );
+ });
}
-
protected void handleFileChange(IFile editorFile, IFile affectedFile, int kind)
{
- if ( affectedFile.equals( editorFile ) )
+ if (affectedFile.equals(editorFile))
{
- switch ( kind )
+ switch (kind)
{
case IResourceDelta.REMOVED:
- close( false );
+ close(false);
break;
case IResourceDelta.CHANGED:
- if ( !saving )
+ if (!saving)
{
reload();
}
- SigilUI.runInUISync( new Runnable()
+ SigilUI.runInUISync(new Runnable()
{
public void run()
{
- setPartName( project.getSymbolicName() );
+ setPartName(project.getSymbolicName());
}
- } );
+ });
break;
}
}
}
-
- private boolean handleProjectChange(IResource editorFile, IProject project, int kind, int flags) throws CoreException
+ private boolean handleProjectChange(IResource editorFile, IProject project, int kind,
+ int flags) throws CoreException
{
- if ( !editorFile.getProject().equals( project ) )
+ if (!editorFile.getProject().equals(project))
{
return false;
}
- if ( kind == IResourceDelta.CHANGED )
+ if (kind == IResourceDelta.CHANGED)
{
int mask = flags & (IResourceDelta.MARKERS);
- if ( mask > 0 ) {
+ if (mask > 0)
+ {
refreshView();
}
}
return true;
}
-
private void refreshView() throws CoreException
{
loadUnresolvedDependencies();
refreshAllPages();
}
-
protected void refreshAllPages()
{
Runnable op = new Runnable()
{
public void run()
{
- for ( Iterator<?> iter = pages.iterator(); iter.hasNext(); )
+ for (Iterator<?> iter = pages.iterator(); iter.hasNext();)
{
- IFormPage page = ( IFormPage ) iter.next();
- if ( page != null )
+ IFormPage page = (IFormPage) iter.next();
+ if (page != null)
{
IManagedForm managedForm = page.getManagedForm();
- if ( managedForm != null )
+ if (managedForm != null)
{
managedForm.refresh();
IFormPart[] parts = managedForm.getParts();
- for ( IFormPart part : parts )
+ for (IFormPart part : parts)
{
part.refresh();
}
}
}
}
- firePropertyChange( IEditorPart.PROP_DIRTY );
- setPartName( project.getSymbolicName() );
+ firePropertyChange(IEditorPart.PROP_DIRTY);
+ setPartName(project.getSymbolicName());
refreshTabImages();
}
};
- getSite().getShell().getDisplay().syncExec( op );
+ getSite().getShell().getDisplay().syncExec(op);
}
-
private void reload()
{
tempProject.setBundle(null);
- project.setBundle( null );
+ project.setBundle(null);
refreshAllPages();
}
-
@Override
- public void init( IEditorSite site, IEditorInput input ) throws PartInitException
+ public void init(IEditorSite site, IEditorInput input) throws PartInitException
{
- super.init( site, input );
+ super.init(site, input);
try
{
- this.project = SigilCore.create( getProject() );
+ this.project = SigilCore.create(getProject());
this.tempProject = (ISigilProjectModel) project.clone();
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- throw new PartInitException( "Error creating Sigil project", e );
+ throw new PartInitException("Error creating Sigil project", e);
}
- ResourcesPlugin.getWorkspace().addResourceChangeListener( this, IResourceChangeEvent.POST_CHANGE | IResourceChangeEvent.PRE_REFRESH );
-
- if ( input instanceof IFileEditorInput )
+ ResourcesPlugin.getWorkspace().addResourceChangeListener(this,
+ IResourceChangeEvent.POST_CHANGE | IResourceChangeEvent.PRE_REFRESH);
+
+ if (input instanceof IFileEditorInput)
{
try
{
loadUnresolvedDependencies();
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- throw new PartInitException( "Error retrieving dependency markers", 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 );
+ IMarker[] markers = getProject().findMarkers(
+ SigilCore.MARKER_UNRESOLVED_DEPENDENCY, true, IResource.DEPTH_ONE);
unresolvedElements.clear();
- for ( IMarker marker : markers )
+ for (IMarker marker : markers)
{
- String elementName = ( String ) marker.getAttribute( "element" );
- String versionRangeStr = ( String ) marker.getAttribute( "versionRange" );
- if ( elementName != null && versionRangeStr != null )
+ 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 ) )
+ 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 );
+ 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 ) )
+ 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 );
+ IRequiredBundle req = factory.newModelElement(IRequiredBundle.class);
+ req.setSymbolicName(elementName);
+ req.setVersions(VersionRange.parseVersionRange(versionRangeStr));
+ unresolvedElements.add(req);
}
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/SigilSourcePage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/SigilSourcePage.java
index 064ca41..1b38972 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/SigilSourcePage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/SigilSourcePage.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
-
import org.eclipse.core.resources.IMarker;
import org.eclipse.jface.text.ITextListener;
import org.eclipse.jface.text.TextEvent;
@@ -31,7 +30,6 @@
import org.eclipse.ui.forms.editor.IFormPage;
import org.eclipse.ui.ide.IDE;
-
public class SigilSourcePage extends TextEditor implements IFormPage
{
private final String id;
@@ -40,105 +38,91 @@
private boolean active;
private Control control;
-
- public SigilSourcePage( String id )
+ public SigilSourcePage(String id)
{
this.id = id;
}
-
@Override
- public void createPartControl( Composite parent )
+ public void createPartControl(Composite parent)
{
- super.createPartControl( parent );
+ super.createPartControl(parent);
Control[] children = parent.getChildren();
control = children[children.length - 1];
- getSourceViewer().addTextListener( new ITextListener()
+ getSourceViewer().addTextListener(new ITextListener()
{
- public void textChanged( TextEvent event )
+ public void textChanged(TextEvent event)
{
- if ( editor != null )
+ if (editor != null)
{
editor.refreshAllPages();
}
}
- } );
+ });
//PlatformUI.getWorkbench().getHelpSystem().setHelp(fControl, IHelpContextIds.MANIFEST_SOURCE_PAGE);
}
-
- public void initialize( FormEditor editor )
+ public void initialize(FormEditor editor)
{
- this.editor = ( SigilProjectEditorPart ) 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 )
+ public void setIndex(int index)
{
this.index = index;
}
-
public boolean isActive()
{
return active;
}
-
- public void setActive( boolean active )
+ public void setActive(boolean active)
{
this.active = active;
}
-
public Control getPartControl()
{
return control;
}
-
- public boolean selectReveal( Object object )
+ public boolean selectReveal(Object object)
{
- if ( object instanceof IMarker )
+ if (object instanceof IMarker)
{
- IDE.gotoMarker( this, ( IMarker ) object );
+ 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
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/TestingSection.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/TestingSection.java
index 4ac1185..24b2e1f 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/TestingSection.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/TestingSection.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
-
import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
import org.apache.felix.sigil.eclipse.ui.internal.form.SigilPage;
import org.apache.felix.sigil.eclipse.ui.internal.form.SigilSection;
@@ -36,60 +35,59 @@
import org.eclipse.ui.forms.widgets.Hyperlink;
import org.eclipse.ui.forms.widgets.Section;
-
public class TestingSection extends SigilSection
{
- public TestingSection( SigilPage page, Composite parent, ISigilProjectModel project ) throws CoreException
+ public TestingSection(SigilPage page, Composite parent, ISigilProjectModel project) throws CoreException
{
- super( page, parent, project );
+ super(page, parent, project);
}
-
- protected void createSection( Section section, FormToolkit toolkit )
+ protected void createSection(Section section, FormToolkit toolkit)
{
- setTitle( "Testing" );
+ setTitle("Testing");
- Composite body = createTableWrapBody( 1, toolkit );
+ Composite body = createTableWrapBody(1, toolkit);
- toolkit.createLabel( body, "Test this project by launching a separate Newton application:" );
+ toolkit.createLabel(body,
+ "Test this project by launching a separate Newton application:");
- Hyperlink launch = toolkit.createHyperlink( body, "Launch a newton container", SWT.NULL );
- launch.setHref( "launchShortcut.run.org.cauldron.sigil.launching.shortcut" );
- launch.addHyperlinkListener( this );
+ Hyperlink launch = toolkit.createHyperlink(body, "Launch a newton container",
+ SWT.NULL);
+ launch.setHref("launchShortcut.run.org.cauldron.sigil.launching.shortcut");
+ launch.addHyperlinkListener(this);
- Hyperlink debug = toolkit.createHyperlink( body, "Debug a newton container", SWT.NULL );
- debug.setHref( "launchShortcut.debug.org.cauldron.sigil.launching.shortcut" );
- debug.addHyperlinkListener( this );
+ Hyperlink debug = toolkit.createHyperlink(body, "Debug a newton container",
+ SWT.NULL);
+ debug.setHref("launchShortcut.debug.org.cauldron.sigil.launching.shortcut");
+ debug.addHyperlinkListener(this);
}
-
- public void linkActivated( HyperlinkEvent e )
+ public void linkActivated(HyperlinkEvent e)
{
- String href = ( String ) e.getHref();
- if ( href.startsWith( "launchShortcut." ) ) { //$NON-NLS-1$
- href = href.substring( 15 );
- int index = href.indexOf( '.' );
- if ( index < 0 )
+ String href = (String) e.getHref();
+ if (href.startsWith("launchShortcut.")) { //$NON-NLS-1$
+ href = href.substring(15);
+ int index = href.indexOf('.');
+ if (index < 0)
return; // error. Format of href should be launchShortcut.<mode>.<launchShortcutId>
- String mode = href.substring( 0, index );
- String id = href.substring( index + 1 );
+ String mode = href.substring(0, index);
+ String id = href.substring(index + 1);
//getEditor().doSave(null);
IExtensionRegistry registry = Platform.getExtensionRegistry();
- IConfigurationElement[] elements = registry
- .getConfigurationElementsFor( "org.eclipse.debug.ui.launchShortcuts" ); //$NON-NLS-1$
- for ( int i = 0; i < elements.length; i++ )
+ IConfigurationElement[] elements = registry.getConfigurationElementsFor("org.eclipse.debug.ui.launchShortcuts"); //$NON-NLS-1$
+ for (int i = 0; i < elements.length; i++)
{
- if ( id.equals( elements[i].getAttribute( "id" ) ) ) //$NON-NLS-1$
+ if (id.equals(elements[i].getAttribute("id"))) //$NON-NLS-1$
try
{
- ILaunchShortcut shortcut = ( ILaunchShortcut ) elements[i].createExecutableExtension( "class" ); //$NON-NLS-1$
+ ILaunchShortcut shortcut = (ILaunchShortcut) elements[i].createExecutableExtension("class"); //$NON-NLS-1$
// preLaunch();
- shortcut.launch( new StructuredSelection( getLaunchObject() ), mode );
+ shortcut.launch(new StructuredSelection(getLaunchObject()), mode);
}
- catch ( CoreException e1 )
+ catch (CoreException e1)
{
e1.printStackTrace();
}
@@ -97,19 +95,16 @@
}
}
-
private Object getLaunchObject()
{
return getProjectModel().getProject();
}
-
- public void linkEntered( HyperlinkEvent e )
+ public void linkEntered(HyperlinkEvent e)
{
}
-
- public void linkExited( HyperlinkEvent e )
+ public void linkExited(HyperlinkEvent e)
{
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ToolsSection.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ToolsSection.java
index 050388e..f8a5b57 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ToolsSection.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/ToolsSection.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
-
import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
import org.apache.felix.sigil.eclipse.ui.actions.PruneProjectDependenciesAction;
import org.apache.felix.sigil.eclipse.ui.actions.ResolveProjectDependenciesAction;
@@ -33,67 +32,62 @@
import org.eclipse.ui.forms.widgets.Hyperlink;
import org.eclipse.ui.forms.widgets.Section;
-
public class ToolsSection extends SigilSection
{
- public ToolsSection( SigilPage page, Composite parent, ISigilProjectModel project ) throws CoreException
+ public ToolsSection(SigilPage page, Composite parent, ISigilProjectModel project) throws CoreException
{
- super( page, parent, project );
+ super(page, parent, project);
}
-
- protected void createSection( Section section, FormToolkit toolkit )
+ protected void createSection(Section section, FormToolkit toolkit)
{
- setTitle( "Tools" );
+ setTitle("Tools");
- Composite body = createTableWrapBody( 1, toolkit );
+ Composite body = createTableWrapBody(1, toolkit);
- toolkit.createLabel( body, "Tools to help manage this project:" );
+ toolkit.createLabel(body, "Tools to help manage this project:");
- Hyperlink launch = toolkit.createHyperlink( body, "Resolve missing dependencies", SWT.NULL );
- launch.setHref( "resolve" );
- launch.addHyperlinkListener( this );
+ Hyperlink launch = toolkit.createHyperlink(body, "Resolve missing dependencies",
+ SWT.NULL);
+ launch.setHref("resolve");
+ launch.addHyperlinkListener(this);
- Hyperlink debug = toolkit.createHyperlink( body, "Prune unused dependencies", SWT.NULL );
- debug.setHref( "prune" );
- debug.addHyperlinkListener( this );
+ Hyperlink debug = toolkit.createHyperlink(body, "Prune unused dependencies",
+ SWT.NULL);
+ debug.setHref("prune");
+ debug.addHyperlinkListener(this);
}
-
- public void linkActivated( HyperlinkEvent e )
+ public void linkActivated(HyperlinkEvent e)
{
- String href = ( String ) e.getHref();
- if ( "resolve".equals( href ) )
+ String href = (String) e.getHref();
+ if ("resolve".equals(href))
{
handleResolve();
}
- else if ( "prune".equals( href ) )
+ else if ("prune".equals(href))
{
handlePrune();
}
}
-
private void handlePrune()
{
- new PruneProjectDependenciesAction( getProjectModel() ).run();
+ new PruneProjectDependenciesAction(getProjectModel()).run();
}
-
private void handleResolve()
{
final ISigilProjectModel project = getProjectModel();
- new ResolveProjectDependenciesAction( project, true ).run();
+ new ResolveProjectDependenciesAction(project, true).run();
}
-
- public void linkEntered( HyperlinkEvent e )
+ public void linkEntered(HyperlinkEvent e)
{
}
-
- public void linkExited( HyperlinkEvent e )
+ public void linkExited(HyperlinkEvent e)
{
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/VersionRangeComponent.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/VersionRangeComponent.java
index 5feb668..db97af2 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/VersionRangeComponent.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/VersionRangeComponent.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.editors.project;
-
import java.util.HashSet;
import java.util.Set;
@@ -40,7 +39,6 @@
import org.eclipse.swt.widgets.Text;
import org.osgi.framework.Version;
-
public class VersionRangeComponent extends Composite
{
private VersionRange versions = VersionRange.ANY_VERSION;
@@ -57,257 +55,244 @@
private Set<VersionsChangeListener> listeners = new HashSet<VersionsChangeListener>();
private Set<IValidationListener> validationListeners = new HashSet<IValidationListener>();
-
- public VersionRangeComponent( Composite parent, int style )
+ public VersionRangeComponent(Composite parent, int style)
{
- super( parent, style );
- createComponents( this );
+ super(parent, style);
+ createComponents(this);
}
-
- public void addVersionChangeListener( VersionsChangeListener listener )
+ public void addVersionChangeListener(VersionsChangeListener listener)
{
- synchronized ( listeners )
+ synchronized (listeners)
{
- listeners.add( listener );
+ listeners.add(listener);
}
}
-
- public void removeVersionChangeListener( VersionsChangeListener listener )
+ public void removeVersionChangeListener(VersionsChangeListener listener)
{
- synchronized ( listeners )
+ synchronized (listeners)
{
- listeners.remove( listener );
+ listeners.remove(listener);
}
}
-
- public void addValidationListener( IValidationListener listener )
+ public void addValidationListener(IValidationListener listener)
{
- validationListeners.add( listener );
+ validationListeners.add(listener);
}
-
- public void removeValidationListener( IValidationListener listener )
+ public void removeValidationListener(IValidationListener listener)
{
- validationListeners.remove( listener );
+ validationListeners.remove(listener);
}
-
@Override
- public void setEnabled( boolean enabled )
+ public void setEnabled(boolean enabled)
{
- super.setEnabled( enabled );
- specificButton.setEnabled( enabled );
- rangeButton.setEnabled( enabled );
- if ( enabled )
+ super.setEnabled(enabled);
+ specificButton.setEnabled(enabled);
+ rangeButton.setEnabled(enabled);
+ if (enabled)
{
- specificButton.setSelection( versions.isPointVersion() );
+ specificButton.setSelection(versions.isPointVersion());
setSpecific();
}
else
{
- minimumText.setEnabled( enabled );
- maximumText.setEnabled( enabled );
- minInclusiveButton.setEnabled( enabled );
- maxInclusiveButton.setEnabled( enabled );
+ minimumText.setEnabled(enabled);
+ maximumText.setEnabled(enabled);
+ minInclusiveButton.setEnabled(enabled);
+ maxInclusiveButton.setEnabled(enabled);
}
}
-
public VersionRange getVersions()
{
return versions;
}
-
- public void setVersions( VersionRange versions )
+ public void setVersions(VersionRange versions)
{
this.versions = versions == null ? VersionRange.ANY_VERSION : versions;
updateFields();
}
-
private void updateFields()
{
- if ( versions.isPointVersion() )
+ if (versions.isPointVersion())
{
- specificButton.setSelection( true );
- specificText.setText( versions.getCeiling() == VersionRange.INFINITE_VERSION ? "*" : versions.getFloor()
- .toString() );
+ specificButton.setSelection(true);
+ specificText.setText(versions.getCeiling() == VersionRange.INFINITE_VERSION ? "*"
+ : versions.getFloor().toString());
}
else
{
- rangeButton.setSelection( true );
- minimumText.setText( versions.getFloor().toString() );
- minInclusiveButton.setSelection( !versions.isOpenFloor() );
- maximumText.setText( versions.getCeiling() == VersionRange.INFINITE_VERSION ? "*" : versions.getCeiling()
- .toString() );
- maxInclusiveButton.setSelection( !versions.isOpenCeiling() );
+ rangeButton.setSelection(true);
+ minimumText.setText(versions.getFloor().toString());
+ minInclusiveButton.setSelection(!versions.isOpenFloor());
+ maximumText.setText(versions.getCeiling() == VersionRange.INFINITE_VERSION ? "*"
+ : versions.getCeiling().toString());
+ maxInclusiveButton.setSelection(!versions.isOpenCeiling());
}
setSpecific();
}
-
- private void createComponents( Composite body )
+ private void createComponents(Composite body)
{
- setLayout( new GridLayout( 3, false ) );
+ setLayout(new GridLayout(3, false));
- specificButton = new Button( body, SWT.RADIO );
- specificButton.setText( "Specific:" );
- specificButton.addSelectionListener( new SelectionAdapter()
+ specificButton = new Button(body, SWT.RADIO);
+ specificButton.setText("Specific:");
+ specificButton.addSelectionListener(new SelectionAdapter()
{
@Override
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
setSpecific();
}
- } );
+ });
- new Label( body, SWT.NONE ).setText( "Version:" );
+ new Label(body, SWT.NONE).setText("Version:");
- specificText = new Text( body, SWT.BORDER );
- specificText.addKeyListener( new KeyAdapter()
+ specificText = new Text(body, SWT.BORDER);
+ specificText.addKeyListener(new KeyAdapter()
{
@Override
- public void keyReleased( KeyEvent e )
+ public void keyReleased(KeyEvent e)
{
setVersions();
}
- } );
+ });
- rangeButton = new Button( body, SWT.RADIO );
- rangeButton.setText( "Range:" );
+ rangeButton = new Button(body, SWT.RADIO);
+ rangeButton.setText("Range:");
- new Label( body, SWT.NONE ).setText( "Minimum:" );
+ new Label(body, SWT.NONE).setText("Minimum:");
- minimumText = new Text( body, SWT.BORDER );
- minimumText.addKeyListener( new KeyAdapter()
+ minimumText = new Text(body, SWT.BORDER);
+ minimumText.addKeyListener(new KeyAdapter()
{
@Override
- public void keyReleased( KeyEvent e )
+ public void keyReleased(KeyEvent e)
{
setVersions();
}
- } );
+ });
- minInclusiveButton = new Button( body, SWT.CHECK );
- minInclusiveButton.setText( "inclusive" );
- minInclusiveButton.setSelection( true );
- minInclusiveButton.addSelectionListener( new SelectionAdapter()
+ minInclusiveButton = new Button(body, SWT.CHECK);
+ minInclusiveButton.setText("inclusive");
+ minInclusiveButton.setSelection(true);
+ minInclusiveButton.addSelectionListener(new SelectionAdapter()
{
@Override
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
setVersions();
}
- } );
+ });
- new Label( body, SWT.NONE ).setText( "Maximum:" );
- maximumText = new Text( body, SWT.BORDER );
- maximumText.addKeyListener( new KeyAdapter()
+ new Label(body, SWT.NONE).setText("Maximum:");
+ maximumText = new Text(body, SWT.BORDER);
+ maximumText.addKeyListener(new KeyAdapter()
{
@Override
- public void keyReleased( KeyEvent e )
+ public void keyReleased(KeyEvent e)
{
setVersions();
}
- } );
+ });
- maxInclusiveButton = new Button( body, SWT.CHECK );
- maxInclusiveButton.setText( "inclusive" );
- maxInclusiveButton.setSelection( false );
- maxInclusiveButton.addSelectionListener( new SelectionAdapter()
+ maxInclusiveButton = new Button(body, SWT.CHECK);
+ maxInclusiveButton.setText("inclusive");
+ maxInclusiveButton.setSelection(false);
+ maxInclusiveButton.addSelectionListener(new SelectionAdapter()
{
@Override
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
setVersions();
}
- } );
+ });
// Layout
- specificButton.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false, 3, 1 ) );
- specificText.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false, 2, 1 ) );
- rangeButton.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false, 3, 1 ) );
- minimumText.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
- maximumText.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
+ specificButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 3, 1));
+ specificText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
+ rangeButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 3, 1));
+ minimumText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ maximumText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
updateFields();
}
-
private void setVersions()
{
try
{
- if ( specificButton.getSelection() )
+ if (specificButton.getSelection())
{
- if ( "*".equals( specificText.getText() ) )
+ if ("*".equals(specificText.getText()))
{
versions = VersionRange.ANY_VERSION;
}
- else if ( specificText.getText().trim().length() == 0 )
+ else if (specificText.getText().trim().length() == 0)
{
versions = null;
}
else
{
- Version v = VersionTable.getVersion( specificText.getText().trim() );
- versions = new VersionRange( false, v, v, false );
+ Version v = VersionTable.getVersion(specificText.getText().trim());
+ versions = new VersionRange(false, v, v, false);
}
}
else
{
- Version min = VersionTable.getVersion( minimumText.getText() );
- Version max = "*".equals( maximumText.getText() ) ? VersionRange.INFINITE_VERSION : VersionTable.getVersion( maximumText.getText() );
- versions = new VersionRange( !minInclusiveButton.getSelection(), min, max, !maxInclusiveButton
- .getSelection() );
+ Version min = VersionTable.getVersion(minimumText.getText());
+ Version max = "*".equals(maximumText.getText()) ? VersionRange.INFINITE_VERSION
+ : VersionTable.getVersion(maximumText.getText());
+ versions = new VersionRange(!minInclusiveButton.getSelection(), min, max,
+ !maxInclusiveButton.getSelection());
}
- fireValidationMessage( null, IMessageProvider.NONE );
+ fireValidationMessage(null, IMessageProvider.NONE);
}
- catch ( IllegalArgumentException e )
+ catch (IllegalArgumentException e)
{
versions = null;
- fireValidationMessage( "Invalid version", IMessageProvider.ERROR );
+ fireValidationMessage("Invalid version", IMessageProvider.ERROR);
}
fireVersionChange();
}
-
private void fireVersionChange()
{
- synchronized ( listeners )
+ synchronized (listeners)
{
- for ( VersionsChangeListener l : listeners )
+ for (VersionsChangeListener l : listeners)
{
- l.versionsChanged( versions );
+ l.versionsChanged(versions);
}
}
}
-
- private void fireValidationMessage( String message, int level )
+ private void fireValidationMessage(String message, int level)
{
- for ( IValidationListener validationListener : validationListeners )
+ for (IValidationListener validationListener : validationListeners)
{
- validationListener.validationMessage( message, level );
+ validationListener.validationMessage(message, level);
}
}
-
private void setSpecific()
{
boolean specific = specificButton.getSelection();
- specificButton.setSelection( specific );
- specificText.setEnabled( specific );
- minimumText.setEnabled( !specific );
- maximumText.setEnabled( !specific );
- minInclusiveButton.setEnabled( !specific );
- maxInclusiveButton.setEnabled( !specific );
+ specificButton.setSelection(specific);
+ specificText.setEnabled(specific);
+ minimumText.setEnabled(!specific);
+ maximumText.setEnabled(!specific);
+ minInclusiveButton.setEnabled(!specific);
+ maxInclusiveButton.setEnabled(!specific);
setVersions();
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/VersionsChangeListener.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/VersionsChangeListener.java
index 373336c..c8c2c09 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/VersionsChangeListener.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/editors/project/VersionsChangeListener.java
@@ -23,5 +23,5 @@
public interface VersionsChangeListener
{
- void versionsChanged( VersionRange range );
+ void versionsChanged(VersionRange range);
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/IFormValueConverter.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/IFormValueConverter.java
index aefd69b..8897857 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/IFormValueConverter.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/IFormValueConverter.java
@@ -19,11 +19,9 @@
package org.apache.felix.sigil.eclipse.ui.internal.form;
-
public interface IFormValueConverter
{
- String getLabel( Object value );
+ String getLabel(Object value);
-
- Object getValue( String label );
+ Object getValue(String label);
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/ISigilFormEntryListener.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/ISigilFormEntryListener.java
index 5ed9a3e..9c09f27 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/ISigilFormEntryListener.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/ISigilFormEntryListener.java
@@ -19,11 +19,9 @@
package org.apache.felix.sigil.eclipse.ui.internal.form;
-
public interface ISigilFormEntryListener
{
- void browseButtonSelected( SigilFormEntry form );
+ void browseButtonSelected(SigilFormEntry form);
-
- void textValueChanged( SigilFormEntry form );
+ void textValueChanged(SigilFormEntry form);
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilFormEntry.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilFormEntry.java
index 39ba2be..db480fa 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilFormEntry.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilFormEntry.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.form;
-
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
@@ -36,18 +35,16 @@
import org.eclipse.ui.forms.IFormColors;
import org.eclipse.ui.forms.widgets.FormToolkit;
-
public class SigilFormEntry
{
private static final IFormValueConverter NULL_DESCRIPTOR = new IFormValueConverter()
{
- public String getLabel( Object value )
+ public String getLabel(Object value)
{
- return ( String ) value;
+ return (String) value;
}
-
- public Object getValue( String label )
+ public Object getValue(String label)
{
return label;
}
@@ -62,77 +59,69 @@
private Object value;
private ISigilFormEntryListener listener;
-
- public SigilFormEntry( Composite parent, FormToolkit toolkit, String title )
+ public SigilFormEntry(Composite parent, FormToolkit toolkit, String title)
{
- this( parent, toolkit, title, null, null );
+ this(parent, toolkit, title, null, null);
}
-
- public SigilFormEntry( Composite parent, FormToolkit toolkit, String title, String browse,
- IFormValueConverter descriptor )
+ public SigilFormEntry(Composite parent, FormToolkit toolkit, String title, String browse, IFormValueConverter descriptor)
{
this.descriptor = descriptor == null ? NULL_DESCRIPTOR : descriptor;
- createComponent( parent, title, browse, toolkit );
+ createComponent(parent, title, browse, toolkit);
}
-
- public void setFormEntryListener( ISigilFormEntryListener listener )
+ public void setFormEntryListener(ISigilFormEntryListener listener)
{
this.listener = listener;
}
-
- public void setValue( Object value )
+ public void setValue(Object value)
{
this.value = value;
- String text = descriptor.getLabel( value );
- if ( text == null )
+ String text = descriptor.getLabel(value);
+ if (text == null)
{
text = "";
}
- txt.setText( text );
+ txt.setText(text);
handleValueChanged();
}
-
public Object getValue()
{
return value;
}
-
- public void setFreeText( boolean freeText )
+ public void setFreeText(boolean freeText)
{
this.freeText = freeText;
}
-
- public void setEditable( boolean editable )
+ public void setEditable(boolean editable)
{
- lbl.setEnabled( editable );
- txt.setEditable( editable );
- if ( btn != null )
+ lbl.setEnabled(editable);
+ txt.setEditable(editable);
+ if (btn != null)
{
- btn.setEnabled( editable );
+ btn.setEnabled(editable);
}
}
-
- private void createComponent( Composite parent, String title, String browse, FormToolkit toolkit )
+ private void createComponent(Composite parent, String title, String browse,
+ FormToolkit toolkit)
{
- lbl = toolkit.createLabel( parent, title );
- lbl.setForeground( toolkit.getColors().getColor( IFormColors.TITLE ) );
+ lbl = toolkit.createLabel(parent, title);
+ lbl.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
- txt = toolkit.createText( parent, "", SWT.SINGLE | SWT.BORDER );
- txt.addKeyListener( new KeyAdapter()
+ txt = toolkit.createText(parent, "", SWT.SINGLE | SWT.BORDER);
+ txt.addKeyListener(new KeyAdapter()
{
@Override
- public void keyPressed( KeyEvent e )
+ public void keyPressed(KeyEvent e)
{
- if ( freeText )
+ if (freeText)
{
- switch ( e.character )
+ switch (e.character)
{
case '\r':
handleValueChanged();
@@ -140,10 +129,10 @@
}
else
{
- switch ( e.character )
+ switch (e.character)
{
case '\b':
- setValue( null );
+ setValue(null);
handleValueChanged();
default:
e.doit = false;
@@ -151,72 +140,71 @@
}
}
}
- } );
- txt.addFocusListener( new FocusAdapter()
+ });
+ txt.addFocusListener(new FocusAdapter()
{
@Override
- public void focusLost( FocusEvent e )
+ public void focusLost(FocusEvent e)
{
handleValueChanged();
}
- } );
+ });
- if ( browse != null )
+ if (browse != null)
{
- btn = toolkit.createButton( parent, browse, SWT.PUSH );
- btn.addSelectionListener( new SelectionAdapter()
+ btn = toolkit.createButton(parent, browse, SWT.PUSH);
+ btn.addSelectionListener(new SelectionAdapter()
{
@Override
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
handleBrowseSelected();
}
- } );
+ });
}
- fillIntoGrid( parent );
+ fillIntoGrid(parent);
}
-
private void handleBrowseSelected()
{
- if ( listener != null )
+ if (listener != null)
{
- listener.browseButtonSelected( this );
+ listener.browseButtonSelected(this);
}
}
-
private void handleValueChanged()
{
- if ( freeText )
+ if (freeText)
{
- this.value = descriptor.getValue( txt.getText() );
+ this.value = descriptor.getValue(txt.getText());
}
- if ( listener != null )
+ if (listener != null)
{
- listener.textValueChanged( this );
+ listener.textValueChanged(this);
}
}
-
- private void fillIntoGrid( Composite parent )
+ private void fillIntoGrid(Composite parent)
{
- if ( parent.getLayout() instanceof GridLayout )
+ if (parent.getLayout() instanceof GridLayout)
{
- GridLayout layout = ( GridLayout ) parent.getLayout();
+ GridLayout layout = (GridLayout) parent.getLayout();
int cols = layout.numColumns;
- lbl.setLayoutData( new GridData( SWT.LEFT, SWT.CENTER, false, false ) );
+ lbl.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
- if ( btn == null )
+ if (btn == null)
{
- txt.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false, Math.max( 1, cols - 1 ), 1 ) );
+ txt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false,
+ Math.max(1, cols - 1), 1));
}
else
{
- txt.setLayoutData( new GridData( SWT.FILL, SWT.CENTER, true, false, Math.max( 1, cols - 2 ), 1 ) );
+ txt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false,
+ Math.max(1, cols - 2), 1));
}
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilFormEntryAdapter.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilFormEntryAdapter.java
index e96237f..df25a5e 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilFormEntryAdapter.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilFormEntryAdapter.java
@@ -19,15 +19,13 @@
package org.apache.felix.sigil.eclipse.ui.internal.form;
-
public class SigilFormEntryAdapter implements ISigilFormEntryListener
{
- public void browseButtonSelected( SigilFormEntry form )
+ public void browseButtonSelected(SigilFormEntry form)
{
}
-
- public void textValueChanged( SigilFormEntry form )
+ public void textValueChanged(SigilFormEntry form)
{
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilPage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilPage.java
index 20c976f..12be8b8 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilPage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilPage.java
@@ -19,17 +19,15 @@
package org.apache.felix.sigil.eclipse.ui.internal.form;
-
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.forms.editor.FormPage;
-
public class SigilPage extends FormPage
{
- public SigilPage( FormEditor editor, String id, String title )
+ public SigilPage(FormEditor editor, String id, String title)
{
- super( editor, id, title );
+ super(editor, id, title);
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilSection.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilSection.java
index e95e941..37245bf 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilSection.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/form/SigilSection.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.form;
-
import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
@@ -40,7 +39,6 @@
import org.eclipse.ui.forms.widgets.TableWrapData;
import org.eclipse.ui.forms.widgets.TableWrapLayout;
-
@SuppressWarnings("restriction")
public abstract class SigilSection extends SectionPart implements IHyperlinkListener, IPartSelectionListener
{
@@ -48,127 +46,122 @@
private SigilPage page;
private ISigilProjectModel project;
-
- public SigilSection( SigilPage page, Composite parent, ISigilProjectModel project ) throws CoreException
+ public SigilSection(SigilPage page, Composite parent, ISigilProjectModel project) throws CoreException
{
- super( parent, page.getManagedForm().getToolkit(), ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE
- | ExpandableComposite.EXPANDED );
+ super(parent, page.getManagedForm().getToolkit(), ExpandableComposite.TITLE_BAR
+ | ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
this.project = project;
this.page = page;
- createSection( getSection(), page.getManagedForm().getToolkit() );
+ createSection(getSection(), page.getManagedForm().getToolkit());
}
-
public ISigilProjectModel getProjectModel()
{
return project;
}
-
public SigilPage getPage()
{
return page;
}
-
- public void setExpanded( boolean expanded )
+ public void setExpanded(boolean expanded)
{
- getSection().setExpanded( expanded );
+ getSection().setExpanded(expanded);
}
+ protected abstract void createSection(Section section, FormToolkit toolkit)
+ throws CoreException;
- protected abstract void createSection( Section section, FormToolkit toolkit ) throws CoreException;
-
-
- protected void setTitle( String title )
+ protected void setTitle(String title)
{
Section section = getSection();
- section.setText( title );
-
- TableWrapLayout layout = new TableWrapLayout();
+ section.setText(title);
- layout.topMargin = 2;
- layout.bottomMargin = 2;
- layout.leftMargin = 2;
- layout.rightMargin = 2;
+ TableWrapLayout layout = new TableWrapLayout();
- layout.horizontalSpacing = 0;
- layout.verticalSpacing = 0;
+ layout.topMargin = 2;
+ layout.bottomMargin = 2;
+ layout.leftMargin = 2;
+ layout.rightMargin = 2;
- layout.makeColumnsEqualWidth = false;
- layout.numColumns = 1;
+ layout.horizontalSpacing = 0;
+ layout.verticalSpacing = 0;
- section.setLayout( layout );
-
- TableWrapData data = new TableWrapData( TableWrapData.FILL_GRAB );
- section.setLayoutData( data );
+ layout.makeColumnsEqualWidth = false;
+ layout.numColumns = 1;
+
+ section.setLayout(layout);
+
+ TableWrapData data = new TableWrapData(TableWrapData.FILL_GRAB);
+ section.setLayoutData(data);
}
- protected void setMarker( String type, String message, int priority, int severity ) throws CoreException
+ protected void setMarker(String type, String message, int priority, int severity)
+ throws CoreException
{
- IFileEditorInput file = ( IFileEditorInput ) getPage().getEditor().getEditorInput();
- IMarker marker = file.getFile().createMarker( type );
- marker.setAttribute( IMarker.MESSAGE, message );
- marker.setAttribute( IMarker.PRIORITY, priority );
- marker.setAttribute( IMarker.SEVERITY, severity );
+ IFileEditorInput file = (IFileEditorInput) getPage().getEditor().getEditorInput();
+ IMarker marker = file.getFile().createMarker(type);
+ marker.setAttribute(IMarker.MESSAGE, message);
+ marker.setAttribute(IMarker.PRIORITY, priority);
+ marker.setAttribute(IMarker.SEVERITY, severity);
}
-
protected void clearMarkers() throws CoreException
{
- IFileEditorInput file = ( IFileEditorInput ) getPage().getEditor().getEditorInput();
- file.getFile().deleteMarkers( null, true, IResource.DEPTH_INFINITE );
+ IFileEditorInput file = (IFileEditorInput) getPage().getEditor().getEditorInput();
+ file.getFile().deleteMarkers(null, true, IResource.DEPTH_INFINITE);
}
-
- protected Composite createTableWrapBody( int columns, FormToolkit toolkit )
+ protected Composite createTableWrapBody(int columns, FormToolkit toolkit)
{
Section section = getSection();
- Composite client = toolkit.createComposite( section );
+ Composite client = toolkit.createComposite(section);
TableWrapLayout layout = new TableWrapLayout();
- layout.leftMargin = layout.rightMargin = toolkit.getBorderStyle() != SWT.NULL ? 0 : 2;
+ layout.leftMargin = layout.rightMargin = toolkit.getBorderStyle() != SWT.NULL ? 0
+ : 2;
layout.numColumns = columns;
- client.setLayout( layout );
- client.setLayoutData( new TableWrapData( TableWrapData.FILL_GRAB ) );
+ client.setLayout(layout);
+ client.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
- section.setClient( client );
+ section.setClient(client);
return client;
}
-
- protected Composite createGridBody( int columns, boolean columnsSameWidth, FormToolkit toolkit )
+ protected Composite createGridBody(int columns, boolean columnsSameWidth,
+ FormToolkit toolkit)
{
Section section = getSection();
- Composite client = toolkit.createComposite( section );
+ Composite client = toolkit.createComposite(section);
GridLayout layout = new GridLayout();
layout.makeColumnsEqualWidth = columnsSameWidth;
layout.numColumns = columns;
- client.setLayout( layout );
+ client.setLayout(layout);
- client.setLayoutData( new TableWrapData( TableWrapData.FILL_GRAB ) );
+ client.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
- section.setClient( client );
+ section.setClient(client);
return client;
}
- public void linkActivated( HyperlinkEvent e )
- {
+ public void linkActivated(HyperlinkEvent e)
+ {
}
-
+
public void linkExited(HyperlinkEvent e)
- {
+ {
}
-
+
public void linkEntered(HyperlinkEvent e)
{
}
- public void selectionChanged( IFormPart part, ISelection selection )
+ public void selectionChanged(IFormPart part, ISelection selection)
{
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/AbstractResourceCommandHandler.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/AbstractResourceCommandHandler.java
index f365026..6f77d31 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/AbstractResourceCommandHandler.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/AbstractResourceCommandHandler.java
@@ -19,10 +19,8 @@
package org.apache.felix.sigil.eclipse.ui.internal.handlers;
-
import org.eclipse.core.commands.AbstractHandler;
-
public abstract class AbstractResourceCommandHandler extends AbstractHandler
{
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/EditorResourceCommandHandler.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/EditorResourceCommandHandler.java
index 8a444aa..addde2b 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/EditorResourceCommandHandler.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/EditorResourceCommandHandler.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.handlers;
-
import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.commands.ExecutionEvent;
@@ -36,38 +35,39 @@
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.handlers.HandlerUtil;
-
public abstract class EditorResourceCommandHandler extends AbstractResourceCommandHandler
{
- public Object execute( ExecutionEvent event ) throws ExecutionException
+ public Object execute(ExecutionEvent event) throws ExecutionException
{
- final Shell shell = HandlerUtil.getActiveShell( event );
- final IEditorPart editorPart = HandlerUtil.getActiveEditor( event );
- if ( editorPart != null )
+ final Shell shell = HandlerUtil.getActiveShell(event);
+ final IEditorPart editorPart = HandlerUtil.getActiveEditor(event);
+ if (editorPart != null)
{
IEditorInput editorInput = editorPart.getEditorInput();
- if ( !( editorInput instanceof IFileEditorInput ) )
+ if (!(editorInput instanceof IFileEditorInput))
{
- throw new ExecutionException( "Editor input must be a file" );
+ throw new ExecutionException("Editor input must be a file");
}
- IFileEditorInput fileInput = ( IFileEditorInput ) editorInput;
+ IFileEditorInput fileInput = (IFileEditorInput) editorInput;
try
{
// Save the editor content (if dirty)
IRunnableWithProgress saveOperation = new IRunnableWithProgress()
{
- public void run( IProgressMonitor monitor ) throws InvocationTargetException, InterruptedException
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException
{
- if ( editorPart.isDirty() )
+ if (editorPart.isDirty())
{
- if ( MessageDialog
- .openQuestion( shell, "Save File",
- "The file contents must be saved before the command can be executed. Do you wish to save now?" ) )
+ if (MessageDialog.openQuestion(
+ shell,
+ "Save File",
+ "The file contents must be saved before the command can be executed. Do you wish to save now?"))
{
- editorPart.doSave( monitor );
+ editorPart.doSave(monitor);
}
else
{
@@ -76,18 +76,17 @@
}
}
};
- new ProgressMonitorDialog( shell ).run( false, true, saveOperation );
+ new ProgressMonitorDialog(shell).run(false, true, saveOperation);
// Execute on the file
IFile file = fileInput.getFile();
- getResourceCommandHandler().execute( new IResource[]
- { file }, event );
+ getResourceCommandHandler().execute(new IResource[] { file }, event);
}
- catch ( InvocationTargetException e )
+ catch (InvocationTargetException e)
{
- throw new ExecutionException( "Error saving file", e.getTargetException() );
+ throw new ExecutionException("Error saving file", e.getTargetException());
}
- catch ( InterruptedException e )
+ catch (InterruptedException e)
{
// Exit the command silently
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/IResourceCommandHandler.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/IResourceCommandHandler.java
index 56d1d2a..68350db 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/IResourceCommandHandler.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/IResourceCommandHandler.java
@@ -19,15 +19,13 @@
package org.apache.felix.sigil.eclipse.ui.internal.handlers;
-
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IResource;
-
public interface IResourceCommandHandler
{
- Object execute( IResource[] resources, ExecutionEvent event ) throws ExecutionException;
+ Object execute(IResource[] resources, ExecutionEvent event) throws ExecutionException;
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/SelectionResourceCommandHandler.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/SelectionResourceCommandHandler.java
index 00ebdba..3085ee1 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/SelectionResourceCommandHandler.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/SelectionResourceCommandHandler.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.handlers;
-
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IResource;
@@ -27,19 +26,18 @@
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.handlers.HandlerUtil;
-
public abstract class SelectionResourceCommandHandler extends AbstractResourceCommandHandler
{
- public final Object execute( ExecutionEvent event ) throws ExecutionException
+ public final Object execute(ExecutionEvent event) throws ExecutionException
{
- ISelection selection = HandlerUtil.getCurrentSelection( event );
+ ISelection selection = HandlerUtil.getCurrentSelection(event);
- Object[] objectArray = ( ( IStructuredSelection ) selection ).toArray();
+ Object[] objectArray = ((IStructuredSelection) selection).toArray();
IResource[] resourceArray = new IResource[objectArray.length];
- System.arraycopy( objectArray, 0, resourceArray, 0, objectArray.length );
+ System.arraycopy(objectArray, 0, resourceArray, 0, objectArray.length);
- return getResourceCommandHandler().execute( resourceArray, event );
+ return getResourceCommandHandler().execute(resourceArray, event);
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/ConvertProjectCommandHandler.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/ConvertProjectCommandHandler.java
index 53d6417..1ac3e8b 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/ConvertProjectCommandHandler.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/ConvertProjectCommandHandler.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.handlers.project;
-
import org.apache.felix.sigil.eclipse.SigilCore;
import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
import org.apache.felix.sigil.eclipse.ui.SigilUI;
@@ -35,39 +34,40 @@
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
-
public class ConvertProjectCommandHandler implements IResourceCommandHandler
{
- public Object execute( IResource[] resources, ExecutionEvent event ) throws ExecutionException
+ public Object execute(IResource[] resources, ExecutionEvent event)
+ throws ExecutionException
{
- for ( IResource r : resources )
+ for (IResource r : resources)
{
- final IProject project = ( IProject ) r;
- if ( project != null )
+ final IProject project = (IProject) r;
+ if (project != null)
{
WorkspaceModifyOperation op = new WorkspaceModifyOperation()
{
@Override
- protected void execute( IProgressMonitor monitor ) throws CoreException
+ protected void execute(IProgressMonitor monitor) throws CoreException
{
- SigilCore.makeSigilProject( project, monitor );
- IJavaProject java = JavaCore.create( project );
- ISigilProjectModel sigil = SigilCore.create( project );
+ SigilCore.makeSigilProject(project, monitor);
+ IJavaProject java = JavaCore.create(project);
+ ISigilProjectModel sigil = SigilCore.create(project);
IClasspathEntry[] entries = java.getRawClasspath();
- for ( int i = 0; i < entries.length; i++ )
+ for (int i = 0; i < entries.length; i++)
{
IClasspathEntry entry = entries[i];
- if ( entry.getEntryKind() == IClasspathEntry.CPE_SOURCE )
+ if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE)
{
- String encodedClasspath = sigil.getJavaModel().encodeClasspathEntry( entry );
- sigil.getBundle().addClasspathEntry( encodedClasspath );
+ String encodedClasspath = sigil.getJavaModel().encodeClasspathEntry(
+ entry);
+ sigil.getBundle().addClasspathEntry(encodedClasspath);
}
}
- sigil.save( monitor );
+ sigil.save(monitor);
}
};
- SigilUI.runWorkspaceOperation( op, null );
+ SigilUI.runWorkspaceOperation(op, null);
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/ConvertProjectHandler.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/ConvertProjectHandler.java
index 2bc47b1..919cc65 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/ConvertProjectHandler.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/ConvertProjectHandler.java
@@ -19,11 +19,9 @@
package org.apache.felix.sigil.eclipse.ui.internal.handlers.project;
-
import org.apache.felix.sigil.eclipse.ui.internal.handlers.IResourceCommandHandler;
import org.apache.felix.sigil.eclipse.ui.internal.handlers.SelectionResourceCommandHandler;
-
public class ConvertProjectHandler extends SelectionResourceCommandHandler
{
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/RefreshSigilClasspathCommandHandler.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/RefreshSigilClasspathCommandHandler.java
index 5b82b32..27b49c4 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/RefreshSigilClasspathCommandHandler.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/RefreshSigilClasspathCommandHandler.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.handlers.project;
-
import java.lang.reflect.InvocationTargetException;
import org.apache.felix.sigil.eclipse.SigilCore;
@@ -34,35 +33,36 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
-
public class RefreshSigilClasspathCommandHandler implements IResourceCommandHandler
{
- public Object execute( IResource[] resources, ExecutionEvent event ) throws ExecutionException
+ public Object execute(IResource[] resources, ExecutionEvent event)
+ throws ExecutionException
{
try
{
- for ( IResource res : resources )
+ for (IResource res : resources)
{
- IProject p = ( IProject ) res;
- final ISigilProjectModel model = SigilCore.create( p );
+ IProject p = (IProject) res;
+ final ISigilProjectModel model = SigilCore.create(p);
WorkspaceModifyOperation op = new WorkspaceModifyOperation()
{
@Override
- protected void execute( IProgressMonitor monitor ) throws CoreException, InvocationTargetException,
+ protected void execute(IProgressMonitor monitor)
+ throws CoreException, InvocationTargetException,
InterruptedException
{
- model.resetClasspath( monitor );
+ model.resetClasspath(monitor);
}
};
- SigilUI.runWorkspaceOperation( op, null );
+ SigilUI.runWorkspaceOperation(op, null);
}
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- SigilCore.error( "Failed to create sigil project for refresh action", e );
+ SigilCore.error("Failed to create sigil project for refresh action", e);
}
return null;
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/RefreshSigilClasspathHandler.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/RefreshSigilClasspathHandler.java
index e081dff..8c6317d 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/RefreshSigilClasspathHandler.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/handlers/project/RefreshSigilClasspathHandler.java
@@ -19,11 +19,9 @@
package org.apache.felix.sigil.eclipse.ui.internal.handlers.project;
-
import org.apache.felix.sigil.eclipse.ui.internal.handlers.IResourceCommandHandler;
import org.apache.felix.sigil.eclipse.ui.internal.handlers.SelectionResourceCommandHandler;
-
public class RefreshSigilClasspathHandler extends SelectionResourceCommandHandler
{
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/perspective/SigilPerspectiveFactory.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/perspective/SigilPerspectiveFactory.java
index 1873a2b..de0bffe 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/perspective/SigilPerspectiveFactory.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/perspective/SigilPerspectiveFactory.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.perspective;
-
import org.apache.felix.sigil.eclipse.ui.SigilUI;
import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jdt.ui.JavaUI;
@@ -28,7 +27,6 @@
import org.eclipse.ui.IPerspectiveFactory;
import org.eclipse.ui.progress.IProgressConstants;
-
public class SigilPerspectiveFactory implements IPerspectiveFactory
{
@@ -36,7 +34,7 @@
private static final String ID_SEARCH_VIEW = "org.eclipse.search.ui.views.SearchView"; //$NON-NLS-1$
private static final String ID_CONSOLE_VIEW = "org.eclipse.ui.console.ConsoleView"; //$NON-NLS-1$
- public void createInitialLayout( IPageLayout layout )
+ public void createInitialLayout(IPageLayout layout)
{
/*
* Use ProjectExplorer vs PackageExplorer due to a bug with Drag and Drop on Mac OS X which affects PackageExplorer
@@ -44,66 +42,68 @@
*/
String editorArea = layout.getEditorArea();
- IFolderLayout folder = layout.createFolder( "left", IPageLayout.LEFT, ( float ) 0.25, editorArea ); //$NON-NLS-1$
- folder.addView( ID_PROJECT_EXPLORER );
- folder.addView( JavaUI.ID_TYPE_HIERARCHY );
- folder.addPlaceholder( IPageLayout.ID_RES_NAV );
- folder.addPlaceholder( SigilUI.ID_REPOSITORY_VIEW );
- folder.addView( IPageLayout.ID_OUTLINE );
+ IFolderLayout folder = layout.createFolder(
+ "left", IPageLayout.LEFT, (float) 0.25, editorArea); //$NON-NLS-1$
+ folder.addView(ID_PROJECT_EXPLORER);
+ folder.addView(JavaUI.ID_TYPE_HIERARCHY);
+ folder.addPlaceholder(IPageLayout.ID_RES_NAV);
+ folder.addPlaceholder(SigilUI.ID_REPOSITORY_VIEW);
+ folder.addView(IPageLayout.ID_OUTLINE);
- IFolderLayout outputfolder = layout.createFolder( "bottom", IPageLayout.BOTTOM, ( float ) 0.75, editorArea ); //$NON-NLS-1$
- outputfolder.addView( IPageLayout.ID_PROBLEM_VIEW );
- outputfolder.addView( JavaUI.ID_JAVADOC_VIEW );
- outputfolder.addView( JavaUI.ID_SOURCE_VIEW );
- outputfolder.addPlaceholder( ID_SEARCH_VIEW );
- outputfolder.addPlaceholder( ID_CONSOLE_VIEW );
- outputfolder.addPlaceholder( IPageLayout.ID_BOOKMARKS );
- outputfolder.addPlaceholder( IProgressConstants.PROGRESS_VIEW_ID );
- outputfolder.addPlaceholder( SigilUI.ID_DEPENDENCY_VIEW );
+ IFolderLayout outputfolder = layout.createFolder(
+ "bottom", IPageLayout.BOTTOM, (float) 0.75, editorArea); //$NON-NLS-1$
+ outputfolder.addView(IPageLayout.ID_PROBLEM_VIEW);
+ outputfolder.addView(JavaUI.ID_JAVADOC_VIEW);
+ outputfolder.addView(JavaUI.ID_SOURCE_VIEW);
+ outputfolder.addPlaceholder(ID_SEARCH_VIEW);
+ outputfolder.addPlaceholder(ID_CONSOLE_VIEW);
+ outputfolder.addPlaceholder(IPageLayout.ID_BOOKMARKS);
+ outputfolder.addPlaceholder(IProgressConstants.PROGRESS_VIEW_ID);
+ outputfolder.addPlaceholder(SigilUI.ID_DEPENDENCY_VIEW);
- layout.addActionSet( IDebugUIConstants.LAUNCH_ACTION_SET );
- layout.addActionSet( JavaUI.ID_ACTION_SET );
- layout.addActionSet( JavaUI.ID_ELEMENT_CREATION_ACTION_SET );
- layout.addActionSet( IPageLayout.ID_NAVIGATE_ACTION_SET );
+ layout.addActionSet(IDebugUIConstants.LAUNCH_ACTION_SET);
+ layout.addActionSet(JavaUI.ID_ACTION_SET);
+ layout.addActionSet(JavaUI.ID_ELEMENT_CREATION_ACTION_SET);
+ layout.addActionSet(IPageLayout.ID_NAVIGATE_ACTION_SET);
// views - sigil
- layout.addShowViewShortcut( SigilUI.ID_REPOSITORY_VIEW );
- layout.addShowViewShortcut( SigilUI.ID_DEPENDENCY_VIEW );
+ layout.addShowViewShortcut(SigilUI.ID_REPOSITORY_VIEW);
+ layout.addShowViewShortcut(SigilUI.ID_DEPENDENCY_VIEW);
// views - java
- layout.addShowViewShortcut( JavaUI.ID_PACKAGES );
- layout.addShowViewShortcut( JavaUI.ID_TYPE_HIERARCHY );
- layout.addShowViewShortcut( JavaUI.ID_SOURCE_VIEW );
- layout.addShowViewShortcut( JavaUI.ID_JAVADOC_VIEW );
+ layout.addShowViewShortcut(JavaUI.ID_PACKAGES);
+ layout.addShowViewShortcut(JavaUI.ID_TYPE_HIERARCHY);
+ layout.addShowViewShortcut(JavaUI.ID_SOURCE_VIEW);
+ layout.addShowViewShortcut(JavaUI.ID_JAVADOC_VIEW);
// views - search
- layout.addShowViewShortcut( ID_SEARCH_VIEW );
+ layout.addShowViewShortcut(ID_SEARCH_VIEW);
// views - debugging
- layout.addShowViewShortcut( ID_CONSOLE_VIEW );
+ layout.addShowViewShortcut(ID_CONSOLE_VIEW);
// views - standard workbench
- layout.addShowViewShortcut( IPageLayout.ID_OUTLINE );
- layout.addShowViewShortcut( IPageLayout.ID_PROBLEM_VIEW );
- layout.addShowViewShortcut( IPageLayout.ID_RES_NAV );
- layout.addShowViewShortcut( IPageLayout.ID_TASK_LIST );
- layout.addShowViewShortcut( IProgressConstants.PROGRESS_VIEW_ID );
- layout.addShowViewShortcut( ID_PROJECT_EXPLORER );
+ layout.addShowViewShortcut(IPageLayout.ID_OUTLINE);
+ layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW);
+ layout.addShowViewShortcut(IPageLayout.ID_RES_NAV);
+ layout.addShowViewShortcut(IPageLayout.ID_TASK_LIST);
+ layout.addShowViewShortcut(IProgressConstants.PROGRESS_VIEW_ID);
+ layout.addShowViewShortcut(ID_PROJECT_EXPLORER);
// new actions - Java project creation wizard
- layout.addNewWizardShortcut( "org.eclipse.jdt.ui.wizards.NewPackageCreationWizard" ); //$NON-NLS-1$
- layout.addNewWizardShortcut( "org.eclipse.jdt.ui.wizards.NewClassCreationWizard" ); //$NON-NLS-1$
- layout.addNewWizardShortcut( "org.eclipse.jdt.ui.wizards.NewInterfaceCreationWizard" ); //$NON-NLS-1$
- layout.addNewWizardShortcut( "org.eclipse.jdt.ui.wizards.NewEnumCreationWizard" ); //$NON-NLS-1$
- layout.addNewWizardShortcut( "org.eclipse.jdt.ui.wizards.NewAnnotationCreationWizard" ); //$NON-NLS-1$
- layout.addNewWizardShortcut( "org.eclipse.jdt.ui.wizards.NewSourceFolderCreationWizard" ); //$NON-NLS-1$
- layout.addNewWizardShortcut( "org.eclipse.jdt.ui.wizards.NewSnippetFileCreationWizard" ); //$NON-NLS-1$
- layout.addNewWizardShortcut( "org.eclipse.jdt.ui.wizards.NewJavaWorkingSetWizard" ); //$NON-NLS-1$
- layout.addNewWizardShortcut( "org.eclipse.ui.wizards.new.folder" );//$NON-NLS-1$
- layout.addNewWizardShortcut( "org.eclipse.ui.wizards.new.file" );//$NON-NLS-1$
- layout.addNewWizardShortcut( "org.eclipse.ui.editors.wizards.UntitledTextFileWizard" );//$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewPackageCreationWizard"); //$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewClassCreationWizard"); //$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewInterfaceCreationWizard"); //$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewEnumCreationWizard"); //$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewAnnotationCreationWizard"); //$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewSourceFolderCreationWizard"); //$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewSnippetFileCreationWizard"); //$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewJavaWorkingSetWizard"); //$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.folder");//$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.file");//$NON-NLS-1$
+ layout.addNewWizardShortcut("org.eclipse.ui.editors.wizards.UntitledTextFileWizard");//$NON-NLS-1$
- layout.addNewWizardShortcut( "org.apache.felix.sigil.editors.newProjectWizard" );
+ layout.addNewWizardShortcut("org.apache.felix.sigil.editors.newProjectWizard");
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/ExcludedResourcesPrefsPage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/ExcludedResourcesPrefsPage.java
index fb57f84..dca4767 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/ExcludedResourcesPrefsPage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/ExcludedResourcesPrefsPage.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.preferences;
-
import java.util.ArrayList;
import org.apache.felix.sigil.eclipse.SigilCore;
@@ -46,7 +45,6 @@
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
-
public class ExcludedResourcesPrefsPage extends PreferencePage implements IWorkbenchPreferencePage
{
@@ -54,145 +52,138 @@
private IWorkbench workbench;
private ArrayList<String> resources;
-
public ExcludedResourcesPrefsPage()
{
super();
- setDescription( "Specify resources that should not be offered for inclusion in a generated bundle." );
+ setDescription("Specify resources that should not be offered for inclusion in a generated bundle.");
}
-
@Override
- protected Control createContents( Composite parent )
+ protected Control createContents(Composite parent)
{
// Create controls
- Composite composite = new Composite( parent, SWT.NONE );
- Table table = new Table( composite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION );
+ Composite composite = new Composite(parent, SWT.NONE);
+ Table table = new Table(composite, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
- Button btnAdd = new Button( composite, SWT.PUSH );
- btnAdd.setText( "Add" );
+ Button btnAdd = new Button(composite, SWT.PUSH);
+ btnAdd.setText("Add");
- final Button btnRemove = new Button( composite, SWT.PUSH );
- btnRemove.setText( "Remove" );
- btnRemove.setEnabled( false );
+ final Button btnRemove = new Button(composite, SWT.PUSH);
+ btnRemove.setText("Remove");
+ btnRemove.setEnabled(false);
// Create viewer
- viewer = new TableViewer( table );
- viewer.setContentProvider( new ArrayContentProvider() );
+ viewer = new TableViewer(table);
+ viewer.setContentProvider(new ArrayContentProvider());
// Load data
- loadPreferences( false );
- viewer.setInput( resources );
+ loadPreferences(false);
+ viewer.setInput(resources);
// Listeners
- viewer.addSelectionChangedListener( new ISelectionChangedListener()
+ viewer.addSelectionChangedListener(new ISelectionChangedListener()
{
- public void selectionChanged( SelectionChangedEvent event )
+ public void selectionChanged(SelectionChangedEvent event)
{
- btnRemove.setEnabled( !viewer.getSelection().isEmpty() );
+ btnRemove.setEnabled(!viewer.getSelection().isEmpty());
}
- } );
+ });
- btnRemove.addSelectionListener( new SelectionAdapter()
+ btnRemove.addSelectionListener(new SelectionAdapter()
{
@Override
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
- IStructuredSelection selection = ( IStructuredSelection ) viewer.getSelection();
+ IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
Object[] deleted = selection.toArray();
- for ( Object delete : deleted )
+ for (Object delete : deleted)
{
- resources.remove( delete );
+ resources.remove(delete);
}
- viewer.remove( deleted );
+ viewer.remove(deleted);
}
- } );
+ });
- btnAdd.addSelectionListener( new SelectionAdapter()
+ btnAdd.addSelectionListener(new SelectionAdapter()
{
@Override
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
- InputDialog dialog = new InputDialog( getShell(), "Add Resource", "Enter resource name", "",
- new IInputValidator()
+ InputDialog dialog = new InputDialog(getShell(), "Add Resource",
+ "Enter resource name", "", new IInputValidator()
{
- public String isValid( String newText )
+ public String isValid(String newText)
{
String error = null;
- if ( newText == null || newText.length() == 0 )
+ if (newText == null || newText.length() == 0)
{
error = "Name must not be empty.";
}
- else if ( resources.contains( newText ) )
+ else if (resources.contains(newText))
{
error = "Specified resource name is already on the list.";
}
return error;
}
- } );
+ });
- if ( dialog.open() == Window.OK )
+ if (dialog.open() == Window.OK)
{
String value = dialog.getValue();
- resources.add( value );
- viewer.add( value );
+ resources.add(value);
+ viewer.add(value);
}
}
- } );
+ });
// Layout
- composite.setLayout( new GridLayout( 2, false ) );
- table.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true, 1, 3 ) );
- btnAdd.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false ) );
- btnRemove.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false ) );
+ composite.setLayout(new GridLayout(2, false));
+ table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 3));
+ btnAdd.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+ btnRemove.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
return composite;
}
-
- private void loadPreferences( boolean useDefaults )
+ private void loadPreferences(boolean useDefaults)
{
String resourcesListStr = useDefaults ? getPreferenceStore().getDefaultString(
- SigilCore.DEFAULT_EXCLUDED_RESOURCES ) : getPreferenceStore().getString(
- SigilCore.DEFAULT_EXCLUDED_RESOURCES );
- String[] resourcesArray = PrefsUtils.stringToArray( resourcesListStr );
+ SigilCore.DEFAULT_EXCLUDED_RESOURCES) : getPreferenceStore().getString(
+ SigilCore.DEFAULT_EXCLUDED_RESOURCES);
+ String[] resourcesArray = PrefsUtils.stringToArray(resourcesListStr);
- resources = new ArrayList<String>( resourcesArray.length );
- for ( String resource : resourcesArray )
+ resources = new ArrayList<String>(resourcesArray.length);
+ for (String resource : resourcesArray)
{
- resources.add( resource );
+ resources.add(resource);
}
}
-
- public void init( IWorkbench workbench )
+ public void init(IWorkbench workbench)
{
this.workbench = workbench;
}
-
@Override
protected IPreferenceStore doGetPreferenceStore()
{
return SigilCore.getDefault().getPreferenceStore();
}
-
@Override
public boolean performOk()
{
- String resourcesStr = PrefsUtils.arrayToString( resources.toArray( new String[resources.size()] ) );
- getPreferenceStore().setValue( SigilCore.DEFAULT_EXCLUDED_RESOURCES, resourcesStr );
+ String resourcesStr = PrefsUtils.arrayToString(resources.toArray(new String[resources.size()]));
+ getPreferenceStore().setValue(SigilCore.DEFAULT_EXCLUDED_RESOURCES, resourcesStr);
return true;
}
-
@Override
protected void performDefaults()
{
super.performDefaults();
- loadPreferences( true );
- viewer.setInput( resources );
+ loadPreferences(true);
+ viewer.setInput(resources);
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/LibraryConfigurationDialog.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/LibraryConfigurationDialog.java
index 652f75f..c0c85eb 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/LibraryConfigurationDialog.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/LibraryConfigurationDialog.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.preferences;
-
import java.util.Comparator;
import java.util.Iterator;
import java.util.TreeSet;
@@ -54,21 +53,21 @@
import org.eclipse.swt.widgets.Text;
import org.osgi.framework.Version;
-
public class LibraryConfigurationDialog extends TitleAreaDialog
{
private static final Comparator<IPackageImport> COMPARATOR = new Comparator<IPackageImport>()
{
- public int compare( IPackageImport o1, IPackageImport o2 )
+ public int compare(IPackageImport o1, IPackageImport o2)
{
- return o1.getPackageName().compareTo( o2.getPackageName() );
+ return o1.getPackageName().compareTo(o2.getPackageName());
}
};
private String name;
private Version version;
- private TreeSet<IPackageImport> packageImports = new TreeSet<IPackageImport>( COMPARATOR );
+ private TreeSet<IPackageImport> packageImports = new TreeSet<IPackageImport>(
+ COMPARATOR);
private boolean editOnly;
@@ -76,146 +75,142 @@
private Text txtName;
private Text txtVersion;
-
- public LibraryConfigurationDialog( Shell parentShell )
+ public LibraryConfigurationDialog(Shell parentShell)
{
- super( parentShell );
+ super(parentShell);
name = "";
version = Version.emptyVersion;
}
-
- public LibraryConfigurationDialog( Shell parentShell, ILibrary lib )
+ public LibraryConfigurationDialog(Shell parentShell, ILibrary lib)
{
- super( parentShell );
+ super(parentShell);
editOnly = true;
name = lib.getName();
version = lib.getVersion();
- packageImports.addAll( lib.getImports() );
+ packageImports.addAll(lib.getImports());
}
-
@Override
- protected Control createDialogArea( Composite par )
+ protected Control createDialogArea(Composite par)
{
- setTitle( "Add Library" );
- Composite container = ( Composite ) super.createDialogArea( par );
+ setTitle("Add Library");
+ Composite container = (Composite) super.createDialogArea(par);
- Composite topPanel = new Composite( container, SWT.NONE );
+ Composite topPanel = new Composite(container, SWT.NONE);
- new Label( topPanel, SWT.NONE ).setText( "Name" );
+ new Label(topPanel, SWT.NONE).setText("Name");
- txtName = new Text( topPanel, SWT.BORDER );
- txtName.setEditable( !editOnly );
- if ( name != null )
- txtName.setText( name );
+ txtName = new Text(topPanel, SWT.BORDER);
+ txtName.setEditable(!editOnly);
+ if (name != null)
+ txtName.setText(name);
- new Label( topPanel, SWT.NONE ).setText( "Version" );
+ new Label(topPanel, SWT.NONE).setText("Version");
- txtVersion = new Text( topPanel, SWT.BORDER );
- txtVersion.setText( version.toString() );
- txtVersion.setEditable( !editOnly );
+ txtVersion = new Text(topPanel, SWT.BORDER);
+ txtVersion.setText(version.toString());
+ txtVersion.setEditable(!editOnly);
- Composite bottomPanel = new Composite( container, SWT.NONE );
+ Composite bottomPanel = new Composite(container, SWT.NONE);
- Table table = new Table( bottomPanel, SWT.BORDER );
- table.setSize( new Point( 300, 200 ) );
+ Table table = new Table(bottomPanel, SWT.BORDER);
+ table.setSize(new Point(300, 200));
- Button add = new Button( bottomPanel, SWT.PUSH );
- add.setText( "Add..." );
+ Button add = new Button(bottomPanel, SWT.PUSH);
+ add.setText("Add...");
- final Button edit = new Button( bottomPanel, SWT.PUSH );
- edit.setText( "Edit..." );
- edit.setEnabled( false );
+ final Button edit = new Button(bottomPanel, SWT.PUSH);
+ edit.setText("Edit...");
+ edit.setEnabled(false);
- final Button remove = new Button( bottomPanel, SWT.PUSH );
- remove.setText( "Remove" );
- remove.setEnabled( false );
+ final Button remove = new Button(bottomPanel, SWT.PUSH);
+ remove.setText("Remove");
+ remove.setEnabled(false);
updateState();
// Hookup Listeners
- txtName.addModifyListener( new ModifyListener()
+ txtName.addModifyListener(new ModifyListener()
{
- public void modifyText( ModifyEvent e )
+ public void modifyText(ModifyEvent e)
{
updateState();
}
- } );
- txtVersion.addModifyListener( new ModifyListener()
+ });
+ txtVersion.addModifyListener(new ModifyListener()
{
- public void modifyText( ModifyEvent e )
+ public void modifyText(ModifyEvent e)
{
updateState();
}
- } );
- add.addSelectionListener( new SelectionAdapter()
+ });
+ add.addSelectionListener(new SelectionAdapter()
{
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
handleAdd();
}
- } );
- edit.addSelectionListener( new SelectionAdapter()
+ });
+ edit.addSelectionListener(new SelectionAdapter()
{
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
handleEdit();
}
- } );
- remove.addSelectionListener( new SelectionAdapter()
+ });
+ remove.addSelectionListener(new SelectionAdapter()
{
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
handleRemove();
}
- } );
+ });
// Layout
- topPanel.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
- topPanel.setLayout( new GridLayout( 2, false ) );
- txtName.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
- txtVersion.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
+ topPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ topPanel.setLayout(new GridLayout(2, false));
+ txtName.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ txtVersion.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- bottomPanel.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
- bottomPanel.setLayout( new GridLayout( 2, false ) );
- table.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true, 1, 4 ) );
- add.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false ) );
- edit.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false ) );
- remove.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false ) );
+ bottomPanel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ bottomPanel.setLayout(new GridLayout(2, false));
+ table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 4));
+ add.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+ edit.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+ remove.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
// Table Viewer
- viewer = new TableViewer( table );
- viewer.setLabelProvider( new LabelProvider()
+ viewer = new TableViewer(table);
+ viewer.setLabelProvider(new LabelProvider()
{
@Override
- public String getText( Object element )
+ public String getText(Object element)
{
- IPackageImport pi = ( IPackageImport ) element;
+ IPackageImport pi = (IPackageImport) element;
return pi.getPackageName() + " " + pi.getVersions();
}
- } );
- viewer.addSelectionChangedListener( new ISelectionChangedListener()
+ });
+ viewer.addSelectionChangedListener(new ISelectionChangedListener()
{
- public void selectionChanged( SelectionChangedEvent event )
+ public void selectionChanged(SelectionChangedEvent event)
{
- edit.setEnabled( !event.getSelection().isEmpty() );
- remove.setEnabled( !event.getSelection().isEmpty() );
+ edit.setEnabled(!event.getSelection().isEmpty());
+ remove.setEnabled(!event.getSelection().isEmpty());
}
- } );
- viewer.setContentProvider( new DefaultTableProvider()
+ });
+ viewer.setContentProvider(new DefaultTableProvider()
{
- public Object[] getElements( Object inputElement )
+ public Object[] getElements(Object inputElement)
{
- return toArray( inputElement );
+ return toArray(inputElement);
}
- } );
+ });
- viewer.setInput( packageImports );
+ viewer.setInput(packageImports);
return container;
}
-
private void updateState()
{
String error = null;
@@ -225,45 +220,43 @@
try
{
- version = VersionTable.getVersion( txtVersion.getText() );
- if ( version.getQualifier().indexOf( '_' ) > -1 )
+ version = VersionTable.getVersion(txtVersion.getText());
+ if (version.getQualifier().indexOf('_') > -1)
{
warning = "The use of underscores in a version qualifier is discouraged.";
}
}
- catch ( IllegalArgumentException e )
+ catch (IllegalArgumentException e)
{
version = null;
error = "Invalid version format";
}
- Button okButton = getButton( IDialogConstants.OK_ID );
- if ( okButton != null && !okButton.isDisposed() )
- okButton.setEnabled( allowOkay() );
+ Button okButton = getButton(IDialogConstants.OK_ID);
+ if (okButton != null && !okButton.isDisposed())
+ okButton.setEnabled(allowOkay());
- setErrorMessage( error );
- setMessage( warning, IMessageProvider.WARNING );
+ setErrorMessage(error);
+ setMessage(warning, IMessageProvider.WARNING);
}
-
private boolean allowOkay()
{
return name != null && name.length() > 0 && version != null;
}
-
@Override
- protected Button createButton( Composite parent, int id, String label, boolean defaultButton )
+ protected Button createButton(Composite parent, int id, String label,
+ boolean defaultButton)
{
- Button button = super.createButton( parent, id, label, defaultButton );
- if ( id == IDialogConstants.OK_ID )
+ Button button = super.createButton(parent, id, label, defaultButton);
+ if (id == IDialogConstants.OK_ID)
{
- button.setEnabled( allowOkay() );
+ button.setEnabled(allowOkay());
}
return button;
}
-
private void handleAdd()
{
/*NewResourceSelectionDialog<? extends IPackageModelElement> dialog = ResourcesDialogHelper.createImportDialog(getShell(), "Add Imported Package", null, packageImports);
@@ -278,7 +271,6 @@
}*/
}
-
private void handleEdit()
{
/*IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
@@ -312,33 +304,32 @@
} */
}
-
private void handleRemove()
{
- IStructuredSelection selection = ( IStructuredSelection ) viewer.getSelection();
+ IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
- if ( !selection.isEmpty() )
+ if (!selection.isEmpty())
{
- for ( Iterator<IPackageImport> i = selection.iterator(); i.hasNext(); )
+ for (Iterator<IPackageImport> i = selection.iterator(); i.hasNext();)
{
- packageImports.remove( i.next() );
+ packageImports.remove(i.next());
}
viewer.refresh();
}
}
-
public ILibrary getLibrary()
{
- ILibrary library = ModelElementFactory.getInstance().newModelElement( ILibrary.class );
+ ILibrary library = ModelElementFactory.getInstance().newModelElement(
+ ILibrary.class);
- library.setName( name );
- library.setVersion( version );
+ library.setName(name);
+ library.setVersion(version);
- for ( IPackageImport pi : packageImports )
+ for (IPackageImport pi : packageImports)
{
- library.addImport( pi );
+ library.addImport(pi);
}
return library;
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/LibraryPreferencePage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/LibraryPreferencePage.java
index 348de4b..a93cd33 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/LibraryPreferencePage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/LibraryPreferencePage.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.preferences;
-
import java.util.Comparator;
import java.util.Iterator;
import java.util.TreeSet;
@@ -50,7 +49,6 @@
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
-
public class LibraryPreferencePage extends PreferencePage implements IWorkbenchPreferencePage
{
@@ -62,227 +60,216 @@
private Button btnEdit;
private Button btnRemove;
-
- public void init( IWorkbench workbench )
+ public void init(IWorkbench workbench)
{
}
-
@Override
- protected Control createContents( Composite parent )
+ protected Control createContents(Composite parent)
{
- Control control = initContents( parent );
+ Control control = initContents(parent);
loadPreferences();
return control;
}
-
@Override
protected IPreferenceStore doGetPreferenceStore()
{
return SigilCore.getDefault().getPreferenceStore();
}
-
@Override
protected void performDefaults()
{
super.performDefaults();
}
-
@Override
public boolean performOk()
{
IPreferenceStore prefs = getPreferenceStore();
- for ( String key : prefs.getString( SigilCore.LIBRARY_KEYS_PREF ).split( "," ) )
+ for (String key : prefs.getString(SigilCore.LIBRARY_KEYS_PREF).split(","))
{
- prefs.setToDefault( key );
+ prefs.setToDefault(key);
}
StringBuffer keys = new StringBuffer();
- for ( ILibrary lib : libraries )
+ for (ILibrary lib : libraries)
{
- throw new IllegalStateException( "XXX-FIXME-XXX" );
+ throw new IllegalStateException("XXX-FIXME-XXX");
}
- prefs.setValue( SigilCore.LIBRARY_KEYS_PREF, keys.toString() );
+ prefs.setValue(SigilCore.LIBRARY_KEYS_PREF, keys.toString());
return true;
}
-
- private Control initContents( Composite parent )
+ private Control initContents(Composite parent)
{
- Composite control = new Composite( parent, SWT.NONE );
- control.setFont( parent.getFont() );
+ Composite control = new Composite(parent, SWT.NONE);
+ control.setFont(parent.getFont());
- GridLayout grid = new GridLayout( 3, false );
- control.setLayout( grid );
+ GridLayout grid = new GridLayout(3, false);
+ control.setLayout(grid);
- initRepositories( control );
+ initRepositories(control);
return control;
}
-
- private void initRepositories( Composite composite )
+ private void initRepositories(Composite composite)
{
// Create controls
- new Label( composite, SWT.NONE ).setText( "Libraries:" );
- new Label( composite, SWT.NONE ); // Spacer
- table = new Table( composite, SWT.SINGLE | SWT.BORDER );
+ new Label(composite, SWT.NONE).setText("Libraries:");
+ new Label(composite, SWT.NONE); // Spacer
+ table = new Table(composite, SWT.SINGLE | SWT.BORDER);
//table.setFont(control.getFont());
- btnAdd = new Button( composite, SWT.PUSH );
- btnAdd.setText( "Add..." );
+ btnAdd = new Button(composite, SWT.PUSH);
+ btnAdd.setText("Add...");
//add.setFont(control.getFont());
- btnEdit = new Button( composite, SWT.PUSH );
- btnEdit.setText( "Edit..." );
+ btnEdit = new Button(composite, SWT.PUSH);
+ btnEdit.setText("Edit...");
//edit.setFont(control.getFont());
- btnRemove = new Button( composite, SWT.PUSH );
- btnRemove.setText( "Remove" );
+ btnRemove = new Button(composite, SWT.PUSH);
+ btnRemove.setText("Remove");
//remove.setFont(control.getFont());
// Table Model
- libraries = new TreeSet<ILibrary>( new Comparator<ILibrary>()
+ libraries = new TreeSet<ILibrary>(new Comparator<ILibrary>()
{
- public int compare( ILibrary l1, ILibrary l2 )
+ public int compare(ILibrary l1, ILibrary l2)
{
- int c = l1.getName().compareTo( l2.getName() );
- if ( c == 0 )
+ int c = l1.getName().compareTo(l2.getName());
+ if (c == 0)
{
- c = l1.getVersion().compareTo( l2.getVersion() );
+ c = l1.getVersion().compareTo(l2.getVersion());
}
return c;
}
- } );
- libraryView = new TableViewer( table );
- libraryView.setLabelProvider( new LabelProvider()
+ });
+ libraryView = new TableViewer(table);
+ libraryView.setLabelProvider(new LabelProvider()
{
- public String getText( Object element )
+ public String getText(Object element)
{
- ILibrary rep = ( ILibrary ) element;
+ ILibrary rep = (ILibrary) element;
return rep.getName() + " " + rep.getVersion();
}
- } );
- libraryView.setContentProvider( new DefaultTableProvider()
+ });
+ libraryView.setContentProvider(new DefaultTableProvider()
{
- public Object[] getElements( Object inputElement )
+ public Object[] getElements(Object inputElement)
{
- return toArray( inputElement );
+ return toArray(inputElement);
}
- } );
- libraryView.setInput( libraries );
+ });
+ libraryView.setInput(libraries);
// Initialize controls
updateButtonStates();
// Hookup Listeners
- libraryView.addSelectionChangedListener( new ISelectionChangedListener()
+ libraryView.addSelectionChangedListener(new ISelectionChangedListener()
{
- public void selectionChanged( SelectionChangedEvent event )
+ public void selectionChanged(SelectionChangedEvent event)
{
updateButtonStates();
}
- } );
- btnAdd.addSelectionListener( new SelectionAdapter()
+ });
+ btnAdd.addSelectionListener(new SelectionAdapter()
{
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
handleAdd();
}
- } );
- btnEdit.addSelectionListener( new SelectionAdapter()
+ });
+ btnEdit.addSelectionListener(new SelectionAdapter()
{
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
handleEdit();
}
- } );
- btnRemove.addSelectionListener( new SelectionAdapter()
+ });
+ btnRemove.addSelectionListener(new SelectionAdapter()
{
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
handleRemove();
}
- } );
+ });
// Layout
- composite.setLayout( new GridLayout( 2, false ) );
- table.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true, 1, 4 ) );
- GridDataFactory buttonGD = GridDataFactory.swtDefaults().align( SWT.FILL, SWT.CENTER );
- btnAdd.setLayoutData( buttonGD.create() );
- btnEdit.setLayoutData( buttonGD.create() );
- btnRemove.setLayoutData( buttonGD.create() );
+ composite.setLayout(new GridLayout(2, false));
+ table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 4));
+ GridDataFactory buttonGD = GridDataFactory.swtDefaults().align(SWT.FILL,
+ SWT.CENTER);
+ btnAdd.setLayoutData(buttonGD.create());
+ btnEdit.setLayoutData(buttonGD.create());
+ btnRemove.setLayoutData(buttonGD.create());
}
-
private void updateButtonStates()
{
ISelection sel = libraryView.getSelection();
- btnEdit.setEnabled( !sel.isEmpty() );
- btnRemove.setEnabled( !sel.isEmpty() );
+ btnEdit.setEnabled(!sel.isEmpty());
+ btnRemove.setEnabled(!sel.isEmpty());
}
-
private void handleAdd()
{
- LibraryConfigurationDialog d = new LibraryConfigurationDialog( getShell() );
- if ( d.open() == Window.OK )
+ LibraryConfigurationDialog d = new LibraryConfigurationDialog(getShell());
+ if (d.open() == Window.OK)
{
- libraries.add( d.getLibrary() );
+ libraries.add(d.getLibrary());
libraryView.refresh();
}
}
-
private void handleEdit()
{
- IStructuredSelection sel = ( IStructuredSelection ) libraryView.getSelection();
+ IStructuredSelection sel = (IStructuredSelection) libraryView.getSelection();
boolean change = false;
- for ( @SuppressWarnings("unchecked")
- Iterator<ILibrary> i = sel.iterator(); i.hasNext(); )
+ for (@SuppressWarnings("unchecked")
+ Iterator<ILibrary> i = sel.iterator(); i.hasNext();)
{
ILibrary lib = i.next();
- LibraryConfigurationDialog d = new LibraryConfigurationDialog( getShell(), lib );
- if ( d.open() == Window.OK )
+ LibraryConfigurationDialog d = new LibraryConfigurationDialog(getShell(), lib);
+ if (d.open() == Window.OK)
{
- libraries.remove( lib );
- libraries.add( d.getLibrary() );
+ libraries.remove(lib);
+ libraries.add(d.getLibrary());
change = true;
}
}
- if ( change )
+ if (change)
{
libraryView.refresh();
}
}
-
private void handleRemove()
{
- IStructuredSelection sel = ( IStructuredSelection ) libraryView.getSelection();
- for ( @SuppressWarnings("unchecked")
- Iterator<ILibrary> i = sel.iterator(); i.hasNext(); )
+ IStructuredSelection sel = (IStructuredSelection) libraryView.getSelection();
+ for (@SuppressWarnings("unchecked")
+ Iterator<ILibrary> i = sel.iterator(); i.hasNext();)
{
- libraries.remove( i );
+ libraries.remove(i);
}
libraryView.refresh();
}
-
private void loadPreferences()
{
IPreferenceStore prefs = getPreferenceStore();
- String keys = prefs.getString( SigilCore.LIBRARY_KEYS_PREF );
- if ( keys.trim().length() > 0 )
+ String keys = prefs.getString(SigilCore.LIBRARY_KEYS_PREF);
+ if (keys.trim().length() > 0)
{
- for ( String key : keys.split( "," ) )
+ for (String key : keys.split(","))
{
- String libStr = prefs.getString( key );
+ String libStr = prefs.getString(key);
// XXX-FIXME-XXX parse library string
// lib = parse(libstr);
// libraries.add(lib);
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/OptionalPrompt.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/OptionalPrompt.java
index d4d739a..2b5f22f 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/OptionalPrompt.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/OptionalPrompt.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.preferences;
-
import org.apache.felix.sigil.eclipse.SigilCore;
import org.apache.felix.sigil.eclipse.preferences.PromptablePreference;
import org.eclipse.jface.dialogs.IDialogConstants;
@@ -27,21 +26,22 @@
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.swt.widgets.Shell;
-
public class OptionalPrompt
{
- public static boolean optionallyPrompt( String prefName, String title, String text, Shell parentShell)
+ public static boolean optionallyPrompt(String prefName, String title, String text,
+ Shell parentShell)
{
- return optionallyPrompt(SigilCore.getDefault().getPreferenceStore(), prefName, title, text, parentShell);
+ return optionallyPrompt(SigilCore.getDefault().getPreferenceStore(), prefName,
+ title, text, parentShell);
}
-
- public static boolean optionallyPrompt( IPreferenceStore prefStore, String prefName, String title, String text,
- Shell parentShell )
+
+ public static boolean optionallyPrompt(IPreferenceStore prefStore, String prefName,
+ String title, String text, Shell parentShell)
{
boolean result = false;
PromptablePreference value = preference(prefStore, prefName);
- switch ( value )
+ switch (value)
{
case Always:
result = true;
@@ -50,33 +50,35 @@
result = false;
break;
case Prompt:
- MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion( parentShell, title, text,
- "Do not ask this again", false, null, null );
- result = ( dialog.getReturnCode() == IDialogConstants.YES_ID );
- if ( dialog.getToggleState() )
+ MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoQuestion(
+ parentShell, title, text, "Do not ask this again", false, null, null);
+ result = (dialog.getReturnCode() == IDialogConstants.YES_ID);
+ if (dialog.getToggleState())
{
// User said don't ask again... take the current answer as the new preference
- prefStore.setValue( prefName, result ? PromptablePreference.Always.name()
- : PromptablePreference.Never.name() );
+ prefStore.setValue(prefName,
+ result ? PromptablePreference.Always.name()
+ : PromptablePreference.Never.name());
}
}
return result;
}
- public static int optionallyPromptWithCancel( String prefName, String title,
- String text, Shell parentShell )
+ public static int optionallyPromptWithCancel(String prefName, String title,
+ String text, Shell parentShell)
{
- return optionallyPromptWithCancel(SigilCore.getDefault().getPreferenceStore(), prefName, title, text, parentShell);
+ return optionallyPromptWithCancel(SigilCore.getDefault().getPreferenceStore(),
+ prefName, title, text, parentShell);
}
-
- public static int optionallyPromptWithCancel( IPreferenceStore prefStore, String prefName, String title,
- String text, Shell parentShell )
+
+ public static int optionallyPromptWithCancel(IPreferenceStore prefStore,
+ String prefName, String title, String text, Shell parentShell)
{
int result = IDialogConstants.NO_ID;
PromptablePreference value = preference(prefStore, prefName);
- switch ( value )
+ switch (value)
{
case Always:
result = IDialogConstants.YES_ID;
@@ -85,32 +87,35 @@
result = IDialogConstants.NO_ID;
break;
case Prompt:
- MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoCancelQuestion( parentShell, title,
- text, "Do not ask this again", false, null, null );
+ MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoCancelQuestion(
+ parentShell, title, text, "Do not ask this again", false, null, null);
result = dialog.getReturnCode();
- if ( result != IDialogConstants.CANCEL_ID )
+ if (result != IDialogConstants.CANCEL_ID)
{
- if ( dialog.getToggleState() )
+ if (dialog.getToggleState())
{
// User said don't ask again... take the current answer as the new preference
- prefStore.setValue( prefName,
- ( result == IDialogConstants.YES_ID ) ? PromptablePreference.Always.name()
- : PromptablePreference.Never.name() );
+ prefStore.setValue(
+ prefName,
+ (result == IDialogConstants.YES_ID) ? PromptablePreference.Always.name()
+ : PromptablePreference.Never.name());
}
}
}
return result;
}
-
+
/**
* @param prefStore
* @param prefName
* @return
*/
- private static PromptablePreference preference(IPreferenceStore prefStore, String prefName)
+ private static PromptablePreference preference(IPreferenceStore prefStore,
+ String prefName)
{
- String val = prefStore.getString( prefName );
- return (val == null || val.trim().length() == 0) ? PromptablePreference.Prompt : PromptablePreference.valueOf( val );
- }
+ String val = prefStore.getString(prefName);
+ return (val == null || val.trim().length() == 0) ? PromptablePreference.Prompt
+ : PromptablePreference.valueOf(val);
+ }
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/ProjectDependentPreferencesPage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/ProjectDependentPreferencesPage.java
index d9a7aa7..b738194 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/ProjectDependentPreferencesPage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/ProjectDependentPreferencesPage.java
@@ -19,33 +19,30 @@
package org.apache.felix.sigil.eclipse.ui.internal.preferences;
-
import org.apache.felix.sigil.eclipse.ui.util.ProjectUtils;
import org.eclipse.jface.preference.PreferencePage;
-
public abstract class ProjectDependentPreferencesPage extends PreferencePage
{
- public ProjectDependentPreferencesPage( String title )
+ public ProjectDependentPreferencesPage(String title)
{
- super( title );
+ super(title);
}
-
@Override
public boolean performOk()
{
- if ( isDirty() )
+ if (isDirty())
{
- return ProjectUtils.runTaskWithRebuildCheck( new Runnable()
+ return ProjectUtils.runTaskWithRebuildCheck(new Runnable()
{
public void run()
{
doSave();
}
- }, getShell() );
+ }, getShell());
}
else
{
@@ -53,9 +50,7 @@
}
}
-
protected abstract void doSave();
-
protected abstract boolean isDirty();
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/SigilPreferencePage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/SigilPreferencePage.java
index bd34121..6f68eb4 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/SigilPreferencePage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/SigilPreferencePage.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.preferences;
-
import org.apache.felix.sigil.eclipse.SigilCore;
import org.apache.felix.sigil.eclipse.preferences.PromptablePreference;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
@@ -28,41 +27,42 @@
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
-
public class SigilPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage
{
@Override
protected void createFieldEditors()
{
- RadioGroupFieldEditor impExpField = new RadioGroupFieldEditor( SigilCore.PREFERENCES_ADD_IMPORT_FOR_EXPORT,
- "Add Imports for New Exports", 1, new String[][]
- { new String[]
- { "Always (Recommended)", PromptablePreference.Always.toString() }, new String[]
- { "Prompt", PromptablePreference.Prompt.toString() }, new String[]
- { "Never", PromptablePreference.Never.toString() } }, getFieldEditorParent(), true );
+ RadioGroupFieldEditor impExpField = new RadioGroupFieldEditor(
+ SigilCore.PREFERENCES_ADD_IMPORT_FOR_EXPORT, "Add Imports for New Exports",
+ 1, new String[][] {
+ new String[] { "Always (Recommended)",
+ PromptablePreference.Always.toString() },
+ new String[] { "Prompt", PromptablePreference.Prompt.toString() },
+ new String[] { "Never", PromptablePreference.Never.toString() } },
+ getFieldEditorParent(), true);
- addField( impExpField );
+ addField(impExpField);
- RadioGroupFieldEditor rebuildExpField = new RadioGroupFieldEditor( SigilCore.PREFERENCES_REBUILD_PROJECTS,
- "Rebuild Projects On Install Change", 1, new String[][]
- { new String[]
- { "Always (Recommended)", PromptablePreference.Always.toString() }, new String[]
- { "Prompt", PromptablePreference.Prompt.toString() }, new String[]
- { "Never", PromptablePreference.Never.toString() } }, getFieldEditorParent(), true );
+ RadioGroupFieldEditor rebuildExpField = new RadioGroupFieldEditor(
+ SigilCore.PREFERENCES_REBUILD_PROJECTS, "Rebuild Projects On Install Change",
+ 1, new String[][] {
+ new String[] { "Always (Recommended)",
+ PromptablePreference.Always.toString() },
+ new String[] { "Prompt", PromptablePreference.Prompt.toString() },
+ new String[] { "Never", PromptablePreference.Never.toString() } },
+ getFieldEditorParent(), true);
- addField( rebuildExpField );
+ addField(rebuildExpField);
}
-
@Override
protected IPreferenceStore doGetPreferenceStore()
{
return SigilCore.getDefault().getPreferenceStore();
}
-
- public void init( IWorkbench workbench )
+ public void init(IWorkbench workbench)
{
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/VersionsPreferencePage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/VersionsPreferencePage.java
index a07d567..233ce5b 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/VersionsPreferencePage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/VersionsPreferencePage.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.preferences;
-
import org.apache.felix.sigil.common.osgi.VersionRange;
import org.apache.felix.sigil.common.osgi.VersionRangeBoundingRule;
import org.apache.felix.sigil.common.osgi.VersionTable;
@@ -43,11 +42,11 @@
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.osgi.framework.Version;
-
public class VersionsPreferencePage extends PreferencePage implements IWorkbenchPreferencePage
{
- private static final Version SAMPLE_VERSION = VersionTable.getVersion( 1, 2, 3, "qualifier" );
+ private static final Version SAMPLE_VERSION = VersionTable.getVersion(1, 2, 3,
+ "qualifier");
private IWorkbench workbench;
@@ -74,361 +73,353 @@
private Version sampleVersion = SAMPLE_VERSION;
private Version matchVersion = null;
-
public VersionsPreferencePage()
{
super();
- setDescription( "Specify the Lower and Upper bounds for a default version range calculated from a point version, e.g. \"1.2.3.qualifier\"" );
+ setDescription("Specify the Lower and Upper bounds for a default version range calculated from a point version, e.g. \"1.2.3.qualifier\"");
}
-
@Override
- protected Control createContents( Composite parent )
+ protected Control createContents(Composite parent)
{
// Create controls
- Composite composite = new Composite( parent, SWT.NONE );
+ Composite composite = new Composite(parent, SWT.NONE);
- Group grpLowerBound = new Group( composite, SWT.NONE );
- grpLowerBound.setText( "Lower Bound" );
- btnLowerBoundExact = new Button( grpLowerBound, SWT.RADIO );
- btnLowerBoundExact.setText( "Exact e.g. [1.2.3.qualifer, ...)" );
- btnLowerBoundMicro = new Button( grpLowerBound, SWT.RADIO );
- btnLowerBoundMicro.setText( "Micro e.g. [1.2.3, ...)" );
- btnLowerBoundMinor = new Button( grpLowerBound, SWT.RADIO );
- btnLowerBoundMinor.setText( "Minor e.g. [1.2, ...)" );
- btnLowerBoundMajor = new Button( grpLowerBound, SWT.RADIO );
- btnLowerBoundMajor.setText( "Major e.g. [1, ...)" );
- btnLowerBoundAny = new Button( grpLowerBound, SWT.RADIO );
- btnLowerBoundAny.setText( "Any e.g. [0, ...)" );
+ Group grpLowerBound = new Group(composite, SWT.NONE);
+ grpLowerBound.setText("Lower Bound");
+ btnLowerBoundExact = new Button(grpLowerBound, SWT.RADIO);
+ btnLowerBoundExact.setText("Exact e.g. [1.2.3.qualifer, ...)");
+ btnLowerBoundMicro = new Button(grpLowerBound, SWT.RADIO);
+ btnLowerBoundMicro.setText("Micro e.g. [1.2.3, ...)");
+ btnLowerBoundMinor = new Button(grpLowerBound, SWT.RADIO);
+ btnLowerBoundMinor.setText("Minor e.g. [1.2, ...)");
+ btnLowerBoundMajor = new Button(grpLowerBound, SWT.RADIO);
+ btnLowerBoundMajor.setText("Major e.g. [1, ...)");
+ btnLowerBoundAny = new Button(grpLowerBound, SWT.RADIO);
+ btnLowerBoundAny.setText("Any e.g. [0, ...)");
- Group grpUpperBound = new Group( composite, SWT.NONE );
- grpUpperBound.setText( "Upper Bound" );
+ Group grpUpperBound = new Group(composite, SWT.NONE);
+ grpUpperBound.setText("Upper Bound");
- btnUpperBoundExact = new Button( grpUpperBound, SWT.RADIO );
- btnUpperBoundExact.setText( "Exact e.g. [..., 1.2.3.qualifer]" );
- btnUpperBoundMicro = new Button( grpUpperBound, SWT.RADIO );
- btnUpperBoundMicro.setText( "Micro e.g. [..., 1.2.4)" );
- btnUpperBoundMinor = new Button( grpUpperBound, SWT.RADIO );
- btnUpperBoundMinor.setText( "Minor e.g. [..., 1.3)" );
- btnUpperBoundMajor = new Button( grpUpperBound, SWT.RADIO );
- btnUpperBoundMajor.setText( "Major e.g. [..., 2)" );
- btnUpperBoundAny = new Button( grpUpperBound, SWT.RADIO );
- btnUpperBoundAny.setText( "Any e.g. [..., \u221e)" );
+ btnUpperBoundExact = new Button(grpUpperBound, SWT.RADIO);
+ btnUpperBoundExact.setText("Exact e.g. [..., 1.2.3.qualifer]");
+ btnUpperBoundMicro = new Button(grpUpperBound, SWT.RADIO);
+ btnUpperBoundMicro.setText("Micro e.g. [..., 1.2.4)");
+ btnUpperBoundMinor = new Button(grpUpperBound, SWT.RADIO);
+ btnUpperBoundMinor.setText("Minor e.g. [..., 1.3)");
+ btnUpperBoundMajor = new Button(grpUpperBound, SWT.RADIO);
+ btnUpperBoundMajor.setText("Major e.g. [..., 2)");
+ btnUpperBoundAny = new Button(grpUpperBound, SWT.RADIO);
+ btnUpperBoundAny.setText("Any e.g. [..., \u221e)");
- Group grpRangeTest = new Group( composite, SWT.NONE );
- grpRangeTest.setText( "Range Test" );
- new Label( grpRangeTest, SWT.NONE ).setText( "Sample Input Version: " );
- txtSampleVersion = new Text( grpRangeTest, SWT.BORDER );
- new Label( grpRangeTest, SWT.NONE ).setText( "Calculated Version Range: " );
- lblCalculatedRange = new Label( grpRangeTest, SWT.NONE );
+ Group grpRangeTest = new Group(composite, SWT.NONE);
+ grpRangeTest.setText("Range Test");
+ new Label(grpRangeTest, SWT.NONE).setText("Sample Input Version: ");
+ txtSampleVersion = new Text(grpRangeTest, SWT.BORDER);
+ new Label(grpRangeTest, SWT.NONE).setText("Calculated Version Range: ");
+ lblCalculatedRange = new Label(grpRangeTest, SWT.NONE);
- new Label( grpRangeTest, SWT.NONE ).setText( "Test: " );
- txtMatchVersion = new Text( grpRangeTest, SWT.BORDER );
- new Label( grpRangeTest, SWT.NONE ).setText( "Result: " );
- lblMatchResult = new Label( grpRangeTest, SWT.NONE );
+ new Label(grpRangeTest, SWT.NONE).setText("Test: ");
+ txtMatchVersion = new Text(grpRangeTest, SWT.BORDER);
+ new Label(grpRangeTest, SWT.NONE).setText("Result: ");
+ lblMatchResult = new Label(grpRangeTest, SWT.NONE);
// Initialize controls
- loadPreferences( false );
+ loadPreferences(false);
updateRadioButtons();
- txtSampleVersion.setText( sampleVersion.toString() );
+ txtSampleVersion.setText(sampleVersion.toString());
updateCalculatedRange();
// Add listeners
SelectionListener buttonListener = new SelectionListener()
{
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
readRadioButtons();
updateCalculatedRange();
}
-
- public void widgetDefaultSelected( SelectionEvent e )
+ public void widgetDefaultSelected(SelectionEvent e)
{
readRadioButtons();
updateCalculatedRange();
}
};
- btnLowerBoundAny.addSelectionListener( buttonListener );
- btnLowerBoundMajor.addSelectionListener( buttonListener );
- btnLowerBoundMinor.addSelectionListener( buttonListener );
- btnLowerBoundMicro.addSelectionListener( buttonListener );
- btnLowerBoundExact.addSelectionListener( buttonListener );
+ btnLowerBoundAny.addSelectionListener(buttonListener);
+ btnLowerBoundMajor.addSelectionListener(buttonListener);
+ btnLowerBoundMinor.addSelectionListener(buttonListener);
+ btnLowerBoundMicro.addSelectionListener(buttonListener);
+ btnLowerBoundExact.addSelectionListener(buttonListener);
- btnUpperBoundAny.addSelectionListener( buttonListener );
- btnUpperBoundMajor.addSelectionListener( buttonListener );
- btnUpperBoundMinor.addSelectionListener( buttonListener );
- btnUpperBoundMicro.addSelectionListener( buttonListener );
- btnUpperBoundExact.addSelectionListener( buttonListener );
+ btnUpperBoundAny.addSelectionListener(buttonListener);
+ btnUpperBoundMajor.addSelectionListener(buttonListener);
+ btnUpperBoundMinor.addSelectionListener(buttonListener);
+ btnUpperBoundMicro.addSelectionListener(buttonListener);
+ btnUpperBoundExact.addSelectionListener(buttonListener);
- txtSampleVersion.addModifyListener( new ModifyListener()
+ txtSampleVersion.addModifyListener(new ModifyListener()
{
- public void modifyText( ModifyEvent e )
+ public void modifyText(ModifyEvent e)
{
try
{
- sampleVersion = VersionTable.getVersion( txtSampleVersion.getText() );
+ sampleVersion = VersionTable.getVersion(txtSampleVersion.getText());
}
- catch ( IllegalArgumentException x )
+ catch (IllegalArgumentException x)
{
sampleVersion = null;
}
updateCalculatedRange();
}
- } );
- txtMatchVersion.addModifyListener( new ModifyListener()
+ });
+ txtMatchVersion.addModifyListener(new ModifyListener()
{
- public void modifyText( ModifyEvent e )
+ public void modifyText(ModifyEvent e)
{
try
{
- matchVersion = VersionTable.getVersion( txtMatchVersion.getText() );
+ matchVersion = VersionTable.getVersion(txtMatchVersion.getText());
}
- catch ( IllegalArgumentException x )
+ catch (IllegalArgumentException x)
{
matchVersion = null;
}
updateCalculatedRange();
}
- } );
+ });
// Layout
- GridLayout layout = new GridLayout( 1, false );
+ GridLayout layout = new GridLayout(1, false);
layout.verticalSpacing = 20;
- composite.setLayout( layout );
+ composite.setLayout(layout);
- grpLowerBound.setLayoutData( new GridData( SWT.FILL, SWT.TOP, true, false ) );
- grpLowerBound.setLayout( new GridLayout( 1, false ) );
+ grpLowerBound.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+ grpLowerBound.setLayout(new GridLayout(1, false));
- grpUpperBound.setLayoutData( new GridData( SWT.FILL, SWT.TOP, true, false ) );
- grpUpperBound.setLayout( new GridLayout( 1, false ) );
+ grpUpperBound.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+ grpUpperBound.setLayout(new GridLayout(1, false));
- grpRangeTest.setLayoutData( new GridData( SWT.FILL, SWT.TOP, true, true ) );
- grpRangeTest.setLayout( new GridLayout( 2, false ) );
+ grpRangeTest.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, true));
+ grpRangeTest.setLayout(new GridLayout(2, false));
- txtSampleVersion.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
- lblCalculatedRange.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
- txtMatchVersion.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
- lblMatchResult.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
+ txtSampleVersion.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ lblCalculatedRange.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ txtMatchVersion.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ lblMatchResult.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
return composite;
}
-
- private void loadPreferences( boolean useDefaults )
+ private void loadPreferences(boolean useDefaults)
{
IPreferenceStore prefs = getPreferenceStore();
String lowerBoundStr;
- if ( useDefaults )
+ if (useDefaults)
{
- lowerBoundStr = prefs.getDefaultString( SigilCore.DEFAULT_VERSION_LOWER_BOUND );
+ lowerBoundStr = prefs.getDefaultString(SigilCore.DEFAULT_VERSION_LOWER_BOUND);
}
else
{
- lowerBoundStr = prefs.getString( SigilCore.DEFAULT_VERSION_LOWER_BOUND );
+ lowerBoundStr = prefs.getString(SigilCore.DEFAULT_VERSION_LOWER_BOUND);
}
String upperBoundStr;
- if ( useDefaults )
+ if (useDefaults)
{
- upperBoundStr = prefs.getDefaultString( SigilCore.DEFAULT_VERSION_UPPER_BOUND );
+ upperBoundStr = prefs.getDefaultString(SigilCore.DEFAULT_VERSION_UPPER_BOUND);
}
else
{
- upperBoundStr = prefs.getString( SigilCore.DEFAULT_VERSION_UPPER_BOUND );
+ upperBoundStr = prefs.getString(SigilCore.DEFAULT_VERSION_UPPER_BOUND);
}
- lowerBoundRule = VersionRangeBoundingRule.valueOf( lowerBoundStr );
- upperBoundRule = VersionRangeBoundingRule.valueOf( upperBoundStr );
+ lowerBoundRule = VersionRangeBoundingRule.valueOf(lowerBoundStr);
+ upperBoundRule = VersionRangeBoundingRule.valueOf(upperBoundStr);
}
-
private void updateRadioButtons()
{
- switch ( lowerBoundRule )
+ switch (lowerBoundRule)
{
case Exact:
- btnLowerBoundExact.setSelection( true );
- btnLowerBoundMicro.setSelection( false );
- btnLowerBoundMinor.setSelection( false );
- btnLowerBoundMajor.setSelection( false );
- btnLowerBoundAny.setSelection( false );
+ btnLowerBoundExact.setSelection(true);
+ btnLowerBoundMicro.setSelection(false);
+ btnLowerBoundMinor.setSelection(false);
+ btnLowerBoundMajor.setSelection(false);
+ btnLowerBoundAny.setSelection(false);
break;
case Micro:
- btnLowerBoundExact.setSelection( false );
- btnLowerBoundMicro.setSelection( true );
- btnLowerBoundMinor.setSelection( false );
- btnLowerBoundMajor.setSelection( false );
- btnLowerBoundAny.setSelection( false );
+ btnLowerBoundExact.setSelection(false);
+ btnLowerBoundMicro.setSelection(true);
+ btnLowerBoundMinor.setSelection(false);
+ btnLowerBoundMajor.setSelection(false);
+ btnLowerBoundAny.setSelection(false);
break;
case Minor:
- btnLowerBoundExact.setSelection( false );
- btnLowerBoundMicro.setSelection( false );
- btnLowerBoundMinor.setSelection( true );
- btnLowerBoundMajor.setSelection( false );
- btnLowerBoundAny.setSelection( false );
+ btnLowerBoundExact.setSelection(false);
+ btnLowerBoundMicro.setSelection(false);
+ btnLowerBoundMinor.setSelection(true);
+ btnLowerBoundMajor.setSelection(false);
+ btnLowerBoundAny.setSelection(false);
break;
case Major:
- btnLowerBoundExact.setSelection( false );
- btnLowerBoundMicro.setSelection( false );
- btnLowerBoundMinor.setSelection( false );
- btnLowerBoundMajor.setSelection( true );
- btnLowerBoundAny.setSelection( false );
+ btnLowerBoundExact.setSelection(false);
+ btnLowerBoundMicro.setSelection(false);
+ btnLowerBoundMinor.setSelection(false);
+ btnLowerBoundMajor.setSelection(true);
+ btnLowerBoundAny.setSelection(false);
break;
case Any:
- btnLowerBoundExact.setSelection( false );
- btnLowerBoundMicro.setSelection( false );
- btnLowerBoundMinor.setSelection( false );
- btnLowerBoundMajor.setSelection( false );
- btnLowerBoundAny.setSelection( true );
+ btnLowerBoundExact.setSelection(false);
+ btnLowerBoundMicro.setSelection(false);
+ btnLowerBoundMinor.setSelection(false);
+ btnLowerBoundMajor.setSelection(false);
+ btnLowerBoundAny.setSelection(true);
break;
}
- switch ( upperBoundRule )
+ switch (upperBoundRule)
{
case Exact:
- btnUpperBoundExact.setSelection( true );
- btnUpperBoundMicro.setSelection( false );
- btnUpperBoundMinor.setSelection( false );
- btnUpperBoundMajor.setSelection( false );
- btnUpperBoundAny.setSelection( false );
+ btnUpperBoundExact.setSelection(true);
+ btnUpperBoundMicro.setSelection(false);
+ btnUpperBoundMinor.setSelection(false);
+ btnUpperBoundMajor.setSelection(false);
+ btnUpperBoundAny.setSelection(false);
break;
case Micro:
- btnUpperBoundExact.setSelection( false );
- btnUpperBoundMicro.setSelection( true );
- btnUpperBoundMinor.setSelection( false );
- btnUpperBoundMajor.setSelection( false );
- btnUpperBoundAny.setSelection( false );
+ btnUpperBoundExact.setSelection(false);
+ btnUpperBoundMicro.setSelection(true);
+ btnUpperBoundMinor.setSelection(false);
+ btnUpperBoundMajor.setSelection(false);
+ btnUpperBoundAny.setSelection(false);
break;
case Minor:
- btnUpperBoundExact.setSelection( false );
- btnUpperBoundMicro.setSelection( false );
- btnUpperBoundMinor.setSelection( true );
- btnUpperBoundMajor.setSelection( false );
- btnUpperBoundAny.setSelection( false );
+ btnUpperBoundExact.setSelection(false);
+ btnUpperBoundMicro.setSelection(false);
+ btnUpperBoundMinor.setSelection(true);
+ btnUpperBoundMajor.setSelection(false);
+ btnUpperBoundAny.setSelection(false);
break;
case Major:
- btnUpperBoundExact.setSelection( false );
- btnUpperBoundMicro.setSelection( false );
- btnUpperBoundMinor.setSelection( false );
- btnUpperBoundMajor.setSelection( true );
- btnUpperBoundAny.setSelection( false );
+ btnUpperBoundExact.setSelection(false);
+ btnUpperBoundMicro.setSelection(false);
+ btnUpperBoundMinor.setSelection(false);
+ btnUpperBoundMajor.setSelection(true);
+ btnUpperBoundAny.setSelection(false);
break;
case Any:
- btnUpperBoundExact.setSelection( false );
- btnUpperBoundMicro.setSelection( false );
- btnUpperBoundMinor.setSelection( false );
- btnUpperBoundMajor.setSelection( false );
- btnUpperBoundAny.setSelection( true );
+ btnUpperBoundExact.setSelection(false);
+ btnUpperBoundMicro.setSelection(false);
+ btnUpperBoundMinor.setSelection(false);
+ btnUpperBoundMajor.setSelection(false);
+ btnUpperBoundAny.setSelection(true);
}
}
-
private void readRadioButtons()
{
- if ( btnLowerBoundExact.getSelection() )
+ if (btnLowerBoundExact.getSelection())
{
lowerBoundRule = VersionRangeBoundingRule.Exact;
}
- else if ( btnLowerBoundMicro.getSelection() )
+ else if (btnLowerBoundMicro.getSelection())
{
lowerBoundRule = VersionRangeBoundingRule.Micro;
}
- else if ( btnLowerBoundMinor.getSelection() )
+ else if (btnLowerBoundMinor.getSelection())
{
lowerBoundRule = VersionRangeBoundingRule.Minor;
}
- else if ( btnLowerBoundMajor.getSelection() )
+ else if (btnLowerBoundMajor.getSelection())
{
lowerBoundRule = VersionRangeBoundingRule.Major;
}
- else if ( btnLowerBoundAny.getSelection() )
+ else if (btnLowerBoundAny.getSelection())
{
lowerBoundRule = VersionRangeBoundingRule.Any;
}
- if ( btnUpperBoundExact.getSelection() )
+ if (btnUpperBoundExact.getSelection())
{
upperBoundRule = VersionRangeBoundingRule.Exact;
}
- else if ( btnUpperBoundMicro.getSelection() )
+ else if (btnUpperBoundMicro.getSelection())
{
upperBoundRule = VersionRangeBoundingRule.Micro;
}
- else if ( btnUpperBoundMinor.getSelection() )
+ else if (btnUpperBoundMinor.getSelection())
{
upperBoundRule = VersionRangeBoundingRule.Minor;
}
- else if ( btnUpperBoundMajor.getSelection() )
+ else if (btnUpperBoundMajor.getSelection())
{
upperBoundRule = VersionRangeBoundingRule.Major;
}
- else if ( btnUpperBoundAny.getSelection() )
+ else if (btnUpperBoundAny.getSelection())
{
upperBoundRule = VersionRangeBoundingRule.Any;
}
}
-
private void updateCalculatedRange()
{
VersionRange range;
String rangeStr;
String matchResult;
- if ( sampleVersion == null )
+ if (sampleVersion == null)
{
range = null;
rangeStr = "";
}
else
{
- range = VersionRange.newInstance( sampleVersion, lowerBoundRule, upperBoundRule );
+ range = VersionRange.newInstance(sampleVersion, lowerBoundRule,
+ upperBoundRule);
rangeStr = range.toString();
}
- lblCalculatedRange.setText( rangeStr );
+ lblCalculatedRange.setText(rangeStr);
- if ( matchVersion == null || range == null )
+ if (matchVersion == null || range == null)
{
matchResult = "";
}
else
{
- matchResult = range.contains( matchVersion ) ? "MATCH!" : "No Match";
+ matchResult = range.contains(matchVersion) ? "MATCH!" : "No Match";
}
- lblMatchResult.setText( matchResult );
+ lblMatchResult.setText(matchResult);
}
-
- public void init( IWorkbench workbench )
+ public void init(IWorkbench workbench)
{
this.workbench = workbench;
}
-
@Override
protected IPreferenceStore doGetPreferenceStore()
{
return SigilCore.getDefault().getPreferenceStore();
}
-
@Override
public boolean performOk()
{
- getPreferenceStore().setValue( SigilCore.DEFAULT_VERSION_LOWER_BOUND, lowerBoundRule.name() );
- getPreferenceStore().setValue( SigilCore.DEFAULT_VERSION_UPPER_BOUND, upperBoundRule.name() );
+ getPreferenceStore().setValue(SigilCore.DEFAULT_VERSION_LOWER_BOUND,
+ lowerBoundRule.name());
+ getPreferenceStore().setValue(SigilCore.DEFAULT_VERSION_UPPER_BOUND,
+ upperBoundRule.name());
return true;
}
-
@Override
protected void performDefaults()
{
super.performDefaults();
- loadPreferences( true );
+ loadPreferences(true);
updateRadioButtons();
updateCalculatedRange();
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/installs/OSGiInstallsPreferencePage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/installs/OSGiInstallsPreferencePage.java
index 2770b54..14dbe83 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/installs/OSGiInstallsPreferencePage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/installs/OSGiInstallsPreferencePage.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.preferences.installs;
-
import java.util.HashMap;
import java.util.UUID;
@@ -53,7 +52,6 @@
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
-
public class OSGiInstallsPreferencePage extends ProjectDependentPreferencesPage implements IWorkbenchPreferencePage
{
@@ -63,19 +61,17 @@
private String location;
private IOSGiInstallType type;
-
- private Install( String id, String location )
+ private Install(String id, String location)
{
this.id = id;
this.location = location;
}
-
private IOSGiInstallType getType()
{
- if ( type == null )
+ if (type == null)
{
- type = SigilCore.getInstallManager().findInstallType( location );
+ type = SigilCore.getInstallManager().findInstallType(location);
}
return type;
}
@@ -85,24 +81,21 @@
private CheckboxTableViewer viewer;
private boolean changed;
-
public OSGiInstallsPreferencePage()
{
- super( "OSGi Installs" );
+ super("OSGi Installs");
}
-
- public void init( IWorkbench workbench )
+ public void init(IWorkbench workbench)
{
}
-
@Override
- protected Control createContents( Composite parent )
+ protected Control createContents(Composite parent)
{
- Composite control = new Composite( parent, SWT.NONE );
+ Composite control = new Composite(parent, SWT.NONE);
- buildComponents( control );
+ buildComponents(control);
load();
@@ -111,79 +104,77 @@
return control;
}
-
@Override
protected boolean isDirty()
{
return changed;
}
-
- private void buildComponents( Composite control )
+ private void buildComponents(Composite control)
{
- new Label( control, SWT.NONE ).setText( "Installs:" );
- new Label( control, SWT.NONE ); // padding
+ new Label(control, SWT.NONE).setText("Installs:");
+ new Label(control, SWT.NONE); // padding
- Table table = new Table( control, SWT.CHECK | SWT.SINGLE | SWT.BORDER );
+ Table table = new Table(control, SWT.CHECK | SWT.SINGLE | SWT.BORDER);
- Button add = new Button( control, SWT.PUSH );
- add.setText( "Add" );
- add.addSelectionListener( new SelectionAdapter()
+ Button add = new Button(control, SWT.PUSH);
+ add.setText("Add");
+ add.addSelectionListener(new SelectionAdapter()
{
@Override
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
add();
}
- } );
+ });
- final Button remove = new Button( control, SWT.PUSH );
- remove.setEnabled( false );
- remove.setText( "Remove" );
- remove.addSelectionListener( new SelectionAdapter()
+ final Button remove = new Button(control, SWT.PUSH);
+ remove.setEnabled(false);
+ remove.setText("Remove");
+ remove.addSelectionListener(new SelectionAdapter()
{
@Override
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
remove();
}
- } );
+ });
// viewers
- viewer = new CheckboxTableViewer( table );
- viewer.setContentProvider( new DefaultTableProvider()
+ viewer = new CheckboxTableViewer(table);
+ viewer.setContentProvider(new DefaultTableProvider()
{
- public Object[] getElements( Object inputElement )
+ public Object[] getElements(Object inputElement)
{
- return toArray( inputElement );
+ return toArray(inputElement);
}
- } );
+ });
- viewer.setLabelProvider( new LabelProvider()
+ viewer.setLabelProvider(new LabelProvider()
{
@Override
- public String getText( Object element )
+ public String getText(Object element)
{
- Install i = ( Install ) element;
+ Install i = (Install) element;
IOSGiInstallType type = i.getType();
- if ( type == null )
+ if (type == null)
{
return "<invalid> [" + i.location + "]";
}
else
{
- return type.getName() + " " + type.getVersion() + " [" + i.location + "]";
+ return type.getName() + " " + type.getVersion() + " [" + i.location
+ + "]";
}
}
-
@Override
- public Image getImage( Object element )
+ public Image getImage(Object element)
{
- Install i = ( Install ) element;
+ Install i = (Install) element;
IOSGiInstallType type = i.getType();
- if ( type == null )
+ if (type == null)
{
return null;
}
@@ -192,139 +183,134 @@
return type.getIcon();
}
}
- } );
+ });
- viewer.addSelectionChangedListener( new ISelectionChangedListener()
+ viewer.addSelectionChangedListener(new ISelectionChangedListener()
{
- public void selectionChanged( SelectionChangedEvent event )
+ public void selectionChanged(SelectionChangedEvent event)
{
boolean enabled = !event.getSelection().isEmpty();
- remove.setEnabled( enabled );
+ remove.setEnabled(enabled);
}
- } );
+ });
- viewer.addCheckStateListener( new ICheckStateListener()
+ viewer.addCheckStateListener(new ICheckStateListener()
{
- public void checkStateChanged( CheckStateChangedEvent event )
+ public void checkStateChanged(CheckStateChangedEvent event)
{
- if ( event.getChecked() )
+ if (event.getChecked())
{
changed = true;
}
- viewer.setCheckedElements( new Object[]
- { event.getElement() } );
+ viewer.setCheckedElements(new Object[] { event.getElement() });
}
- } );
+ });
- viewer.setInput( installs.values() );
+ viewer.setInput(installs.values());
// layout
- control.setLayout( new GridLayout( 2, false ) );
- table.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true, 1, 3 ) );
- add.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false ) );
- remove.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false ) );
+ control.setLayout(new GridLayout(2, false));
+ table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 3));
+ add.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+ remove.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
}
-
private void load()
{
- String pref = getPreferenceStore().getString( SigilCore.OSGI_INSTALLS );
- if ( pref != null && pref.length() > 0 )
+ String pref = getPreferenceStore().getString(SigilCore.OSGI_INSTALLS);
+ if (pref != null && pref.length() > 0)
{
- for ( String id : pref.split( "," ) )
+ for (String id : pref.split(","))
{
- String loc = getPreferenceStore().getString( SigilCore.OSGI_INSTALL_PREFIX + id );
- installs.put( id, new Install( id, loc ) );
+ String loc = getPreferenceStore().getString(
+ SigilCore.OSGI_INSTALL_PREFIX + id);
+ installs.put(id, new Install(id, loc));
}
}
viewer.refresh();
- if ( !installs.isEmpty() )
+ if (!installs.isEmpty())
{
- String defId = getPreferenceStore().getString( SigilCore.OSGI_DEFAULT_INSTALL_ID );
- if ( defId == null || defId.trim().length() == 0 )
+ String defId = getPreferenceStore().getString(
+ SigilCore.OSGI_DEFAULT_INSTALL_ID);
+ if (defId == null || defId.trim().length() == 0)
{
- viewer.setCheckedElements( new Object[]
- { installs.values().iterator().next() } );
+ viewer.setCheckedElements(new Object[] { installs.values().iterator().next() });
}
else
{
- viewer.setCheckedElements( new Object[]
- { installs.get( defId ) } );
+ viewer.setCheckedElements(new Object[] { installs.get(defId) });
}
}
}
-
protected void doSave()
{
// zero out old configs
- String pref = getPreferenceStore().getString( SigilCore.OSGI_INSTALLS );
- if ( pref != null && pref.length() > 0 )
+ String pref = getPreferenceStore().getString(SigilCore.OSGI_INSTALLS);
+ if (pref != null && pref.length() > 0)
{
- for ( String id : pref.split( "," ) )
+ for (String id : pref.split(","))
{
- getPreferenceStore().setToDefault( SigilCore.OSGI_INSTALL_PREFIX + id );
+ getPreferenceStore().setToDefault(SigilCore.OSGI_INSTALL_PREFIX + id);
}
}
// store new configs
- if ( installs.isEmpty() )
+ if (installs.isEmpty())
{
- getPreferenceStore().setToDefault( SigilCore.OSGI_INSTALLS );
- getPreferenceStore().setToDefault( SigilCore.OSGI_DEFAULT_INSTALL_ID );
+ getPreferenceStore().setToDefault(SigilCore.OSGI_INSTALLS);
+ getPreferenceStore().setToDefault(SigilCore.OSGI_DEFAULT_INSTALL_ID);
}
else
{
StringBuffer buf = new StringBuffer();
- for ( Install i : installs.values() )
+ for (Install i : installs.values())
{
- if ( buf.length() > 0 )
+ if (buf.length() > 0)
{
- buf.append( "," );
+ buf.append(",");
}
- buf.append( i.id );
- getPreferenceStore().setValue( SigilCore.OSGI_INSTALL_PREFIX + i.id, i.location );
+ buf.append(i.id);
+ getPreferenceStore().setValue(SigilCore.OSGI_INSTALL_PREFIX + i.id,
+ i.location);
}
- getPreferenceStore().setValue( SigilCore.OSGI_INSTALLS, buf.toString() );
- Install def = ( Install ) viewer.getCheckedElements()[0];
- getPreferenceStore().setValue( SigilCore.OSGI_DEFAULT_INSTALL_ID, def.id );
+ getPreferenceStore().setValue(SigilCore.OSGI_INSTALLS, buf.toString());
+ Install def = (Install) viewer.getCheckedElements()[0];
+ getPreferenceStore().setValue(SigilCore.OSGI_DEFAULT_INSTALL_ID, def.id);
}
changed = false;
}
-
private boolean isOK()
{
return installs.isEmpty() || viewer.getCheckedElements().length > 0;
}
-
private void add()
{
Shell shell = SigilUI.getActiveWorkbenchShell();
- DirectoryDialog dialog = new DirectoryDialog( shell );
+ DirectoryDialog dialog = new DirectoryDialog(shell);
String dir = dialog.open();
- if ( dir != null )
+ if (dir != null)
{
- Install install = new Install( UUID.randomUUID().toString(), dir );
- if ( install.getType() == null )
+ Install install = new Install(UUID.randomUUID().toString(), dir);
+ if (install.getType() == null)
{
- MessageDialog.openError( shell, "Error", "Invalid OSGi install directory" );
+ MessageDialog.openError(shell, "Error", "Invalid OSGi install directory");
}
else
{
boolean empty = installs.isEmpty();
- installs.put( install.id, install );
+ installs.put(install.id, install);
viewer.refresh();
- if ( empty )
+ if (empty)
{
- viewer.setCheckedElements( new Object[]
- { install } );
+ viewer.setCheckedElements(new Object[] { install });
}
checkValid();
@@ -333,39 +319,35 @@
}
}
-
private void checkValid()
{
- if ( isOK() )
+ if (isOK())
{
- setErrorMessage( null );
- setValid( true );
+ setErrorMessage(null);
+ setValid(true);
}
else
{
- setErrorMessage( "Missing default OSGi install" );
- setValid( false );
+ setErrorMessage("Missing default OSGi install");
+ setValid(false);
}
}
-
private void remove()
{
- IStructuredSelection sel = ( IStructuredSelection ) viewer.getSelection();
- Install i = ( Install ) sel.getFirstElement();
- boolean def = viewer.getChecked( i );
- installs.remove( i.id );
+ IStructuredSelection sel = (IStructuredSelection) viewer.getSelection();
+ Install i = (Install) sel.getFirstElement();
+ boolean def = viewer.getChecked(i);
+ installs.remove(i.id);
viewer.refresh();
- if ( def && installs.size() > 0 )
+ if (def && installs.size() > 0)
{
- viewer.setCheckedElements( new Object[]
- { installs.values().iterator().next() } );
+ viewer.setCheckedElements(new Object[] { installs.values().iterator().next() });
}
checkValid();
changed = true;
}
-
@Override
protected IPreferenceStore doGetPreferenceStore()
{
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/project/ProjectPropertyPage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/project/ProjectPropertyPage.java
index 967b3fc..ce23d9b 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/project/ProjectPropertyPage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/project/ProjectPropertyPage.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.preferences.project;
-
import java.util.concurrent.Callable;
import org.apache.felix.sigil.eclipse.SigilCore;
@@ -49,7 +48,6 @@
import org.eclipse.ui.dialogs.PropertyPage;
import org.osgi.service.prefs.BackingStoreException;
-
public class ProjectPropertyPage extends PropertyPage implements IWorkbenchPropertyPage
{
@@ -58,170 +56,163 @@
private Composite settings;
private Button projectSpecificBtn;
-
@Override
- protected Control createContents( Composite parent )
+ protected Control createContents(Composite parent)
{
- final Composite control = new Composite( parent, SWT.NONE );
+ final Composite control = new Composite(parent, SWT.NONE);
- projectSpecificBtn = new Button( control, SWT.CHECK );
- projectSpecificBtn.setText( "Enable project specific settings" );
- projectSpecificBtn.addSelectionListener( new SelectionAdapter()
+ projectSpecificBtn = new Button(control, SWT.CHECK);
+ projectSpecificBtn.setText("Enable project specific settings");
+ projectSpecificBtn.addSelectionListener(new SelectionAdapter()
{
@Override
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
- setProjectSpecific( !projectSpecific );
+ setProjectSpecific(!projectSpecific);
}
- } );
+ });
- Label link = new Label( control, SWT.UNDERLINE_SINGLE );
- link.addMouseListener( new MouseAdapter()
+ Label link = new Label(control, SWT.UNDERLINE_SINGLE);
+ link.addMouseListener(new MouseAdapter()
{
@Override
- public void mouseDown( MouseEvent e )
+ public void mouseDown(MouseEvent e)
{
- PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn( null,
- SigilCore.REPOSITORIES_PREFERENCES_ID, null, null );
+ PreferenceDialog dialog = PreferencesUtil.createPreferenceDialogOn(null,
+ SigilCore.REPOSITORIES_PREFERENCES_ID, null, null);
dialog.open();
}
- } );
+ });
- link.setText( "Configure workspace settings" );
+ link.setText("Configure workspace settings");
- settings = new Composite( control, SWT.BORDER );
- settings.setLayout( new GridLayout( 1, false ) );
- createSettings( settings );
+ settings = new Composite(control, SWT.BORDER);
+ settings.setLayout(new GridLayout(1, false));
+ createSettings(settings);
- setFonts( control );
+ setFonts(control);
// layout
- control.setLayout( new GridLayout( 2, false ) );
- projectSpecificBtn.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
- settings.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true, 2, 1 ) );
+ control.setLayout(new GridLayout(2, false));
+ projectSpecificBtn.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ settings.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
// load settings
String currentSet = getCurrentSet();
- if ( currentSet == null )
+ if (currentSet == null)
{
- setProjectSpecific( false );
+ setProjectSpecific(false);
}
else
{
- setView.setSelection( new StructuredSelection( currentSet ) );
- setProjectSpecific( true );
+ setView.setSelection(new StructuredSelection(currentSet));
+ setProjectSpecific(true);
}
return control;
}
-
- private void setFonts( Composite control )
+ private void setFonts(Composite control)
{
Composite p = control.getParent();
- for ( Control c : control.getChildren() )
+ for (Control c : control.getChildren())
{
- c.setFont( p.getFont() );
- if ( c instanceof Composite )
+ c.setFont(p.getFont());
+ if (c instanceof Composite)
{
- setFonts( ( Composite ) c );
+ setFonts((Composite) c);
}
}
}
-
- private void setProjectSpecific( boolean projectSpecific )
+ private void setProjectSpecific(boolean projectSpecific)
{
- if ( this.projectSpecific != projectSpecific )
+ if (this.projectSpecific != projectSpecific)
{
this.projectSpecific = projectSpecific;
- settings.setEnabled( projectSpecific );
- for ( Control c : settings.getChildren() )
+ settings.setEnabled(projectSpecific);
+ for (Control c : settings.getChildren())
{
- c.setEnabled( projectSpecific );
+ c.setEnabled(projectSpecific);
}
- projectSpecificBtn.setSelection( projectSpecific );
+ projectSpecificBtn.setSelection(projectSpecific);
}
}
-
- private void createSettings( Composite parent )
+ private void createSettings(Composite parent)
{
- Composite control = new Composite( parent, SWT.NONE );
+ Composite control = new Composite(parent, SWT.NONE);
- new Label( control, SWT.NONE ).setText( "Repository Set:" );
- Combo combo = new Combo( control, SWT.SINGLE );
+ new Label(control, SWT.NONE).setText("Repository Set:");
+ Combo combo = new Combo(control, SWT.SINGLE);
- setView = new ComboViewer( combo );
- setView.setContentProvider( new DefaultTableProvider()
+ setView = new ComboViewer(combo);
+ setView.setContentProvider(new DefaultTableProvider()
{
- public Object[] getElements( Object inputElement )
+ public Object[] getElements(Object inputElement)
{
- return toArray( inputElement );
+ return toArray(inputElement);
}
- } );
+ });
- setView.setInput( SigilCore.getRepositoryConfiguration().loadRepositorySets().keySet() );
+ setView.setInput(SigilCore.getRepositoryConfiguration().loadRepositorySets().keySet());
// layout
- control.setLayout( new GridLayout( 2, false ) );
+ control.setLayout(new GridLayout(2, false));
}
-
private String getCurrentSet()
{
try
{
- IProject p = ( IProject ) getElement().getAdapter( IProject.class );
- ISigilProjectModel model = SigilCore.create( p );
- return model.getPreferences().get( SigilCore.REPOSITORY_SET, null );
+ IProject p = (IProject) getElement().getAdapter(IProject.class);
+ ISigilProjectModel model = SigilCore.create(p);
+ return model.getPreferences().get(SigilCore.REPOSITORY_SET, null);
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- SigilCore.error( "Failed to read repository set", e );
+ SigilCore.error("Failed to read repository set", e);
return null;
}
}
-
@Override
public boolean okToLeave()
{
- if ( projectSpecific )
+ if (projectSpecific)
{
- if ( setView.getSelection().isEmpty() )
+ if (setView.getSelection().isEmpty())
{
- setErrorMessage( "Must select a repository set" );
+ setErrorMessage("Must select a repository set");
return false;
}
}
- setErrorMessage( null );
+ setErrorMessage(null);
return true;
}
-
@Override
public boolean performOk()
{
- return ProjectUtils.runTaskWithRebuildCheck( new Callable<Boolean>()
+ return ProjectUtils.runTaskWithRebuildCheck(new Callable<Boolean>()
{
public Boolean call() throws CoreException, BackingStoreException
{
String set = null;
- if ( projectSpecific )
+ if (projectSpecific)
{
- set = ( String ) ( ( IStructuredSelection ) setView.getSelection() ).getFirstElement();
+ set = (String) ((IStructuredSelection) setView.getSelection()).getFirstElement();
}
- IProject p = ( IProject ) getElement().getAdapter( IProject.class );
- ISigilProjectModel model = SigilCore.create( p );
- model.getPreferences().put( SigilCore.REPOSITORY_SET, set );
+ IProject p = (IProject) getElement().getAdapter(IProject.class);
+ ISigilProjectModel model = SigilCore.create(p);
+ model.getPreferences().put(SigilCore.REPOSITORY_SET, set);
model.getPreferences().flush();
return true;
}
- }, getShell() );
+ }, getShell());
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/NewRepositoryWizard.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/NewRepositoryWizard.java
index c10d84c..0e5935e 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/NewRepositoryWizard.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/NewRepositoryWizard.java
@@ -19,11 +19,9 @@
package org.apache.felix.sigil.eclipse.ui.internal.preferences.repository;
-
import org.apache.felix.sigil.eclipse.model.repository.IRepositoryModel;
import org.eclipse.jface.wizard.Wizard;
-
public class NewRepositoryWizard extends Wizard
{
@@ -31,13 +29,11 @@
private RepositoryTypeSelectionPage page = new RepositoryTypeSelectionPage();
-
public void addPages()
{
- addPage( page );
+ addPage(page);
}
-
@Override
public boolean performFinish()
{
@@ -45,14 +41,12 @@
return true;
}
-
@Override
public boolean needsPreviousAndNextButtons()
{
return true;
}
-
public IRepositoryModel getRepository()
{
return repository;
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoriesPreferencePage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoriesPreferencePage.java
index a8f0bea..a1c3a0c 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoriesPreferencePage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoriesPreferencePage.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.preferences.repository;
-
import org.apache.felix.sigil.eclipse.SigilCore;
import org.apache.felix.sigil.eclipse.model.repository.IRepositoryConfiguration;
import org.apache.felix.sigil.eclipse.model.repository.IRepositorySet;
@@ -37,7 +36,6 @@
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
-
public class RepositoriesPreferencePage extends ProjectDependentPreferencesPage implements IWorkbenchPreferencePage
{
@@ -45,89 +43,82 @@
private RepositoriesView viewPage;
private RepositorySetsView setPage;
-
public RepositoriesPreferencePage()
{
- super( "Repository Preferences" );
+ super("Repository Preferences");
}
-
@Override
- protected Control createContents( Composite parent )
+ protected Control createContents(Composite parent)
{
- Control control = initContents( parent );
+ Control control = initContents(parent);
return control;
}
-
@Override
protected IPreferenceStore doGetPreferenceStore()
{
return SigilCore.getDefault().getPreferenceStore();
}
-
protected void changed()
{
changed = true;
updateApplyButton();
}
-
- private Control initContents( Composite parent )
+ private Control initContents(Composite parent)
{
- viewPage = new RepositoriesView( this );
- setPage = new RepositorySetsView( this );
+ viewPage = new RepositoriesView(this);
+ setPage = new RepositorySetsView(this);
- Composite control = new Composite( parent, SWT.NONE );
+ Composite control = new Composite(parent, SWT.NONE);
- TabFolder folder = new TabFolder( control, SWT.TOP );
+ TabFolder folder = new TabFolder(control, SWT.TOP);
- TabItem view = new TabItem( folder, SWT.NONE );
- view.setText( "Repositories" );
- view.setControl( viewPage.createContents( folder ) );
+ TabItem view = new TabItem(folder, SWT.NONE);
+ view.setText("Repositories");
+ view.setControl(viewPage.createContents(folder));
- TabItem sets = new TabItem( folder, SWT.NONE );
- sets.setText( "Sets" );
- sets.setControl( setPage.createContents( folder ) );
+ TabItem sets = new TabItem(folder, SWT.NONE);
+ sets.setText("Sets");
+ sets.setControl(setPage.createContents(folder));
- control.setLayout( new GridLayout( 1, true ) );
- folder.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
+ control.setLayout(new GridLayout(1, true));
+ folder.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
return control;
}
-
- public void init( IWorkbench workbench )
+ public void init(IWorkbench workbench)
{
// TODO Auto-generated method stub
}
-
@Override
protected void doSave()
{
try
{
IRepositoryConfiguration config = SigilCore.getRepositoryConfiguration();
- config.saveRepositories( viewPage.getRepositories() );
- config.saveRepositorySets( setPage.getSets() );
- IRepositorySet defaultSet = new RepositorySet( setPage.getDefaultRepositories() );
- config.setDefaultRepositorySet( defaultSet );
+ config.saveRepositories(viewPage.getRepositories());
+ config.saveRepositorySets(setPage.getSets());
+ IRepositorySet defaultSet = new RepositorySet(
+ setPage.getDefaultRepositories());
+ config.setDefaultRepositorySet(defaultSet);
- setErrorMessage( null );
- getApplyButton().setEnabled( false );
+ setErrorMessage(null);
+ getApplyButton().setEnabled(false);
changed = false;
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- setErrorMessage( "Failed to save repositories:" + e.getStatus().getMessage() );
- SigilCore.error( "Failed to save repositories", e );
+ setErrorMessage("Failed to save repositories:" + e.getStatus().getMessage());
+ SigilCore.error("Failed to save repositories", e);
}
}
-
@Override
protected boolean isDirty()
{
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoriesView.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoriesView.java
index 136052d..fab0a60 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoriesView.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoriesView.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.preferences.repository;
-
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -50,7 +49,6 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
-
public class RepositoriesView
{
private final RepositoriesPreferencePage page;
@@ -59,260 +57,247 @@
private TableViewer repositoryView;
-
- public RepositoriesView( RepositoriesPreferencePage page )
+ public RepositoriesView(RepositoriesPreferencePage page)
{
this.page = page;
}
-
- public Control createContents( Composite parent )
+ public Control createContents(Composite parent)
{
// Create Controls
- Composite composite = new Composite( parent, SWT.NONE );
+ Composite composite = new Composite(parent, SWT.NONE);
- Table table = new Table( composite, SWT.MULTI | SWT.BORDER );
+ Table table = new Table(composite, SWT.MULTI | SWT.BORDER);
// Table Viewer Setup
- repositoryView = new TableViewer( table );
- repositoryView.setLabelProvider( new LabelProvider()
+ repositoryView = new TableViewer(table);
+ repositoryView.setLabelProvider(new LabelProvider()
{
@Override
- public String getText( Object element )
+ public String getText(Object element)
{
- IRepositoryModel rep = ( IRepositoryModel ) element;
+ IRepositoryModel rep = (IRepositoryModel) element;
return rep.getName();
}
-
@Override
- public Image getImage( Object element )
+ public Image getImage(Object element)
{
- IRepositoryModel rep = ( IRepositoryModel ) element;
+ IRepositoryModel rep = (IRepositoryModel) element;
return rep.getType().getIcon();
}
- } );
+ });
- repositoryView.setContentProvider( new DefaultTableProvider()
+ repositoryView.setContentProvider(new DefaultTableProvider()
{
- public Object[] getElements( Object inputElement )
+ public Object[] getElements(Object inputElement)
{
- return toArray( inputElement );
+ return toArray(inputElement);
}
- } );
+ });
// Layout
- composite.setLayout( new GridLayout( 2, false ) );
- table.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true, 1, 6 ) );
+ composite.setLayout(new GridLayout(2, false));
+ table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 6));
- createButtons( composite, repositoryView );
+ createButtons(composite, repositoryView);
repositories = SigilCore.getRepositoryConfiguration().loadRepositories();
- repositoryView.setInput( repositories );
+ repositoryView.setInput(repositories);
return composite;
}
-
- private void createButtons( final Composite composite, final TableViewer repositoryView )
+ private void createButtons(final Composite composite, final TableViewer repositoryView)
{
- final Button add = new Button( composite, SWT.PUSH );
- add.setText( "Add..." );
- add.setEnabled( true );
+ final Button add = new Button(composite, SWT.PUSH);
+ add.setText("Add...");
+ add.setEnabled(true);
- final Button edit = new Button( composite, SWT.PUSH );
- edit.setText( "Edit..." );
- edit.setEnabled( false );
+ final Button edit = new Button(composite, SWT.PUSH);
+ edit.setText("Edit...");
+ edit.setEnabled(false);
- final Button remove = new Button( composite, SWT.PUSH );
- remove.setText( "Remove" );
- remove.setEnabled( false );
+ final Button remove = new Button(composite, SWT.PUSH);
+ remove.setText("Remove");
+ remove.setEnabled(false);
- final Button refresh = new Button( composite, SWT.PUSH );
- refresh.setText( "Refresh" );
- refresh.setEnabled( false );
+ final Button refresh = new Button(composite, SWT.PUSH);
+ refresh.setText("Refresh");
+ refresh.setEnabled(false);
// Listeners
- add.addSelectionListener( new SelectionAdapter()
+ add.addSelectionListener(new SelectionAdapter()
{
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
- add( composite );
+ add(composite);
}
- } );
+ });
- edit.addSelectionListener( new SelectionAdapter()
+ edit.addSelectionListener(new SelectionAdapter()
{
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
- IStructuredSelection sel = ( IStructuredSelection ) repositoryView.getSelection();
- edit( composite, sel );
+ IStructuredSelection sel = (IStructuredSelection) repositoryView.getSelection();
+ edit(composite, sel);
}
- } );
+ });
- remove.addSelectionListener( new SelectionAdapter()
+ remove.addSelectionListener(new SelectionAdapter()
{
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
- IStructuredSelection sel = ( IStructuredSelection ) repositoryView.getSelection();
- remove( sel );
+ IStructuredSelection sel = (IStructuredSelection) repositoryView.getSelection();
+ remove(sel);
}
- } );
+ });
- refresh.addSelectionListener( new SelectionAdapter()
+ refresh.addSelectionListener(new SelectionAdapter()
{
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
- IStructuredSelection sel = ( IStructuredSelection ) repositoryView.getSelection();
- refresh( composite, sel );
+ IStructuredSelection sel = (IStructuredSelection) repositoryView.getSelection();
+ refresh(composite, sel);
}
- } );
+ });
- repositoryView.addSelectionChangedListener( new ISelectionChangedListener()
+ repositoryView.addSelectionChangedListener(new ISelectionChangedListener()
{
- public void selectionChanged( SelectionChangedEvent event )
+ public void selectionChanged(SelectionChangedEvent event)
{
boolean selected = !event.getSelection().isEmpty();
- if ( selected )
+ if (selected)
{
- refresh.setEnabled( true );
+ refresh.setEnabled(true);
- IStructuredSelection sel = ( IStructuredSelection ) event.getSelection();
+ IStructuredSelection sel = (IStructuredSelection) event.getSelection();
- checkEditEnabled( edit, sel );
- checkRemoveEnabled( remove, sel );
+ checkEditEnabled(edit, sel);
+ checkRemoveEnabled(remove, sel);
}
else
{
- refresh.setEnabled( false );
- edit.setEnabled( false );
- remove.setEnabled( false );
+ refresh.setEnabled(false);
+ edit.setEnabled(false);
+ remove.setEnabled(false);
}
}
- } );
+ });
- add.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false ) );
- edit.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false ) );
- remove.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false ) );
+ add.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+ edit.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+ remove.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
}
-
@SuppressWarnings("unchecked")
- private void checkRemoveEnabled( Button button, IStructuredSelection sel )
+ private void checkRemoveEnabled(Button button, IStructuredSelection sel)
{
boolean alldynamic = true;
- for ( Iterator i = sel.iterator(); i.hasNext(); )
+ for (Iterator i = sel.iterator(); i.hasNext();)
{
- IRepositoryModel model = ( IRepositoryModel ) i.next();
- if ( !model.getType().isDynamic() )
+ IRepositoryModel model = (IRepositoryModel) i.next();
+ if (!model.getType().isDynamic())
{
alldynamic = false;
break;
}
}
- button.setEnabled( alldynamic );
+ button.setEnabled(alldynamic);
}
-
- private void checkEditEnabled( Button edit, IStructuredSelection sel )
+ private void checkEditEnabled(Button edit, IStructuredSelection sel)
{
- if ( sel.size() == 1 )
+ if (sel.size() == 1)
{
- IRepositoryModel element = ( IRepositoryModel ) sel.getFirstElement();
- if ( WizardHelper.hasWizard( element.getType() ) )
+ IRepositoryModel element = (IRepositoryModel) sel.getFirstElement();
+ if (WizardHelper.hasWizard(element.getType()))
{
- edit.setEnabled( true );
+ edit.setEnabled(true);
}
else
{
- edit.setEnabled( false );
+ edit.setEnabled(false);
}
}
else
{
- edit.setEnabled( false );
+ edit.setEnabled(false);
}
}
-
@SuppressWarnings("unchecked")
- protected void refresh( Control parent, IStructuredSelection sel )
+ protected void refresh(Control parent, IStructuredSelection sel)
{
- ArrayList<IRepositoryModel> models = new ArrayList<IRepositoryModel>( sel.size() );
+ ArrayList<IRepositoryModel> models = new ArrayList<IRepositoryModel>(sel.size());
- for ( Iterator i = sel.iterator(); i.hasNext(); )
+ for (Iterator i = sel.iterator(); i.hasNext();)
{
- IRepositoryModel model = ( IRepositoryModel ) i.next();
- models.add( model );
+ IRepositoryModel model = (IRepositoryModel) i.next();
+ models.add(model);
}
- new RefreshRepositoryAction( models.toArray( new IRepositoryModel[models.size()] ) ).run();
+ new RefreshRepositoryAction(models.toArray(new IRepositoryModel[models.size()])).run();
}
-
- private void add( Control parent )
+ private void add(Control parent)
{
NewRepositoryWizard wizard = new NewRepositoryWizard();
- WizardDialog dialog = new WizardDialog( getShell( parent ), wizard );
- if ( dialog.open() == Window.OK )
+ WizardDialog dialog = new WizardDialog(getShell(parent), wizard);
+ if (dialog.open() == Window.OK)
{
- repositories.add( wizard.getRepository() );
+ repositories.add(wizard.getRepository());
updated();
}
}
-
- private void edit( Control parent, IStructuredSelection sel )
+ private void edit(Control parent, IStructuredSelection sel)
{
- IRepositoryModel model = ( IRepositoryModel ) sel.getFirstElement();
+ IRepositoryModel model = (IRepositoryModel) sel.getFirstElement();
try
{
- RepositoryWizard wizard = WizardHelper.loadWizard( model.getType() );
- wizard.init( model );
- WizardDialog dialog = new WizardDialog( getShell( parent ), wizard );
- if ( dialog.open() == Window.OK )
+ RepositoryWizard wizard = WizardHelper.loadWizard(model.getType());
+ wizard.init(model);
+ WizardDialog dialog = new WizardDialog(getShell(parent), wizard);
+ if (dialog.open() == Window.OK)
{
updated();
}
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- SigilCore.error( "Failed to load wizard", e );
- MessageDialog
- .openError( getShell( parent ), "Error", "Failed to load wizard:" + e.getStatus().getMessage() );
+ SigilCore.error("Failed to load wizard", e);
+ MessageDialog.openError(getShell(parent), "Error", "Failed to load wizard:"
+ + e.getStatus().getMessage());
}
}
-
- private Shell getShell( Control parent )
+ private Shell getShell(Control parent)
{
return parent.getShell();
}
-
@SuppressWarnings("unchecked")
- private void remove( IStructuredSelection sel )
+ private void remove(IStructuredSelection sel)
{
boolean change = false;
- for ( Iterator i = sel.iterator(); i.hasNext(); )
+ for (Iterator i = sel.iterator(); i.hasNext();)
{
- change = repositories.remove( i.next() );
+ change = repositories.remove(i.next());
}
- if ( change )
+ if (change)
{
updated();
}
}
-
private void updated()
{
repositoryView.refresh();
page.changed();
}
-
public List<IRepositoryModel> getRepositories()
{
return repositories;
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositorySetDialog.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositorySetDialog.java
index 6ddc791..a2e08a4 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositorySetDialog.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositorySetDialog.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.preferences.repository;
-
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -50,7 +49,6 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
-
public class RepositorySetDialog extends TitleAreaDialog
{
@@ -65,101 +63,94 @@
private String newName;
-
- public RepositorySetDialog( Shell shell, Set<String> set )
+ public RepositorySetDialog(Shell shell, Set<String> set)
{
- this( shell, null, true, set );
+ this(shell, null, true, set);
}
-
- public RepositorySetDialog( Shell parent, RepositoryViewData data, boolean nameEditable, Set<String> set )
+ public RepositorySetDialog(Shell parent, RepositoryViewData data, boolean nameEditable, Set<String> set)
{
- super( parent );
+ super(parent);
this.set = set;
this.setName = data == null ? "" : data.getName();
- this.repositories = data == null ? new ArrayList<IRepositoryModel>() : new ArrayList<IRepositoryModel>( Arrays
- .asList( data.getRepositories() ) );
+ this.repositories = data == null ? new ArrayList<IRepositoryModel>()
+ : new ArrayList<IRepositoryModel>(Arrays.asList(data.getRepositories()));
this.nameEditable = nameEditable;
}
-
@Override
- protected Control createDialogArea( Composite parent )
+ protected Control createDialogArea(Composite parent)
{
- Composite area = ( Composite ) super.createDialogArea( parent );
- createControl( area );
+ Composite area = (Composite) super.createDialogArea(parent);
+ createControl(area);
return area;
}
-
- public void createControl( Composite parent )
+ public void createControl(Composite parent)
{
// controls
- Composite body = new Composite( parent, SWT.NONE );
- body.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+ Composite body = new Composite(parent, SWT.NONE);
+ body.setLayoutData(new GridData(GridData.FILL_BOTH));
- if ( nameEditable )
+ if (nameEditable)
{
- new Label( body, SWT.NONE ).setText( "Name" );
+ new Label(body, SWT.NONE).setText("Name");
- nameTxt = new Text( body, SWT.BORDER );
+ nameTxt = new Text(body, SWT.BORDER);
- nameTxt.setText( setName );
+ nameTxt.setText(setName);
- nameTxt.addKeyListener( new KeyAdapter()
+ nameTxt.addKeyListener(new KeyAdapter()
{
@Override
- public void keyReleased( KeyEvent e )
+ public void keyReleased(KeyEvent e)
{
checkComplete();
}
- } );
+ });
}
- Composite table = new Composite( body, SWT.NONE );
- table.setLayout( new GridLayout( 2, false ) );
- createTable( table );
+ Composite table = new Composite(body, SWT.NONE);
+ table.setLayout(new GridLayout(2, false));
+ createTable(table);
// layout
- body.setLayout( new GridLayout( 2, false ) );
- if ( nameEditable )
+ body.setLayout(new GridLayout(2, false));
+ if (nameEditable)
{
- nameTxt.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
+ nameTxt.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
}
- table.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true, 2, 1 ) );
+ table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
}
-
public RepositoryViewData getData()
{
String name = nameEditable ? newName : setName;
- IRepositoryModel[] reps = repositories.toArray( new IRepositoryModel[repositories.size()] );
- return new RepositoryViewData( name, reps );
+ IRepositoryModel[] reps = repositories.toArray(new IRepositoryModel[repositories.size()]);
+ return new RepositoryViewData(name, reps);
}
-
private void checkComplete()
{
- if ( nameEditable )
+ if (nameEditable)
{
String name = nameTxt.getText();
- if ( !name.equals( setName ) && set.contains( name ) )
+ if (!name.equals(setName) && set.contains(name))
{
- setErrorMessage( "Set " + name + " already exists" );
- Button b = getButton( IDialogConstants.OK_ID );
- b.setEnabled( false );
+ setErrorMessage("Set " + name + " already exists");
+ Button b = getButton(IDialogConstants.OK_ID);
+ b.setEnabled(false);
}
}
- setErrorMessage( null );
- Button b = getButton( IDialogConstants.OK_ID );
- b.setEnabled( true );
+ setErrorMessage(null);
+ Button b = getButton(IDialogConstants.OK_ID);
+ b.setEnabled(true);
}
-
@Override
protected void okPressed()
{
- if ( nameEditable )
+ if (nameEditable)
{
newName = nameTxt.getText();
}
@@ -167,150 +158,140 @@
super.okPressed();
}
-
- private void createTable( Composite body )
+ private void createTable(Composite body)
{
- createViewer( body );
+ createViewer(body);
- Composite btns = new Composite( body, SWT.NONE );
- btns.setLayout( new GridLayout( 1, true ) );
+ Composite btns = new Composite(body, SWT.NONE);
+ btns.setLayout(new GridLayout(1, true));
- createButtons( btns );
+ createButtons(btns);
// layout
- viewer.getTable().setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
- btns.setLayoutData( new GridData( SWT.RIGHT, SWT.TOP, false, false ) );
+ viewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+ btns.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false));
}
-
- private void createButtons( Composite parent )
+ private void createButtons(Composite parent)
{
- upBtn = new Button( parent, SWT.PUSH );
- upBtn.setText( "Up" );
- upBtn.addSelectionListener( new SelectionAdapter()
+ upBtn = new Button(parent, SWT.PUSH);
+ upBtn.setText("Up");
+ upBtn.addSelectionListener(new SelectionAdapter()
{
@Override
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
up();
}
- } );
+ });
- downBtn = new Button( parent, SWT.PUSH );
- downBtn.setText( "Down" );
- downBtn.addSelectionListener( new SelectionAdapter()
+ downBtn = new Button(parent, SWT.PUSH);
+ downBtn.setText("Down");
+ downBtn.addSelectionListener(new SelectionAdapter()
{
@Override
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
down();
}
- } );
+ });
- setUpDownEnabled( false );
+ setUpDownEnabled(false);
}
-
private void up()
{
- IRepositoryModel model = ( IRepositoryModel ) ( ( StructuredSelection ) viewer.getSelection() )
- .getFirstElement();
- int i = repositories.indexOf( model );
- if ( i > 0 )
+ IRepositoryModel model = (IRepositoryModel) ((StructuredSelection) viewer.getSelection()).getFirstElement();
+ int i = repositories.indexOf(model);
+ if (i > 0)
{
- repositories.remove( i );
- repositories.add( i - 1, model );
+ repositories.remove(i);
+ repositories.add(i - 1, model);
viewer.refresh();
}
}
-
private void down()
{
- IRepositoryModel model = ( IRepositoryModel ) ( ( StructuredSelection ) viewer.getSelection() )
- .getFirstElement();
- int i = repositories.indexOf( model );
- if ( i < repositories.size() - 1 )
+ IRepositoryModel model = (IRepositoryModel) ((StructuredSelection) viewer.getSelection()).getFirstElement();
+ int i = repositories.indexOf(model);
+ if (i < repositories.size() - 1)
{
- repositories.remove( i );
- repositories.add( i + 1, model );
+ repositories.remove(i);
+ repositories.add(i + 1, model);
viewer.refresh();
}
}
-
- private void createViewer( Composite parent )
+ private void createViewer(Composite parent)
{
- viewer = CheckboxTableViewer.newCheckList( parent, SWT.BORDER );
+ viewer = CheckboxTableViewer.newCheckList(parent, SWT.BORDER);
- viewer.addSelectionChangedListener( new ISelectionChangedListener()
+ viewer.addSelectionChangedListener(new ISelectionChangedListener()
{
- public void selectionChanged( SelectionChangedEvent event )
+ public void selectionChanged(SelectionChangedEvent event)
{
- setUpDownEnabled( !viewer.getSelection().isEmpty() );
+ setUpDownEnabled(!viewer.getSelection().isEmpty());
}
- } );
+ });
- viewer.setContentProvider( new DefaultTableProvider()
+ viewer.setContentProvider(new DefaultTableProvider()
{
- public Object[] getElements( Object inputElement )
+ public Object[] getElements(Object inputElement)
{
- return toArray( inputElement );
+ return toArray(inputElement);
}
- } );
+ });
- viewer.setLabelProvider( new DefaultLabelProvider()
+ viewer.setLabelProvider(new DefaultLabelProvider()
{
- public Image getImage( Object element )
+ public Image getImage(Object element)
{
return null;
}
-
- public String getText( Object element )
+ public String getText(Object element)
{
- IRepositoryModel m = ( IRepositoryModel ) element;
+ IRepositoryModel m = (IRepositoryModel) element;
return m.getName();
}
- } );
+ });
- viewer.setInput( repositories );
+ viewer.setInput(repositories);
- for ( IRepositoryModel m : repositories )
+ for (IRepositoryModel m : repositories)
{
- viewer.setChecked( m, true );
+ viewer.setChecked(m, true);
}
List<IRepositoryModel> allRepositories = SigilCore.getRepositoryConfiguration().loadRepositories();
- for ( IRepositoryModel m : allRepositories )
+ for (IRepositoryModel m : allRepositories)
{
- if ( !repositories.contains( m ) )
+ if (!repositories.contains(m))
{
- repositories.add( m );
+ repositories.add(m);
}
}
viewer.refresh();
}
-
- private void setUpDownEnabled( boolean enabled )
+ private void setUpDownEnabled(boolean enabled)
{
- upBtn.setEnabled( enabled );
- downBtn.setEnabled( enabled );
+ upBtn.setEnabled(enabled);
+ downBtn.setEnabled(enabled);
}
-
private List<IRepositoryModel> getRepositories()
{
ArrayList<IRepositoryModel> reps = new ArrayList<IRepositoryModel>();
- for ( IRepositoryModel m : repositories )
+ for (IRepositoryModel m : repositories)
{
- if ( viewer.getChecked( m ) )
+ if (viewer.getChecked(m))
{
- reps.add( m );
+ reps.add(m);
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositorySetsView.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositorySetsView.java
index a9b5401..bcb6248 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositorySetsView.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositorySetsView.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.preferences.repository;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -49,7 +48,6 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
-
public class RepositorySetsView
{
private static final String DEFAULT = "default";
@@ -62,218 +60,206 @@
private RepositoryViewData defaultSet;
-
- public RepositorySetsView( RepositoriesPreferencePage page )
+ public RepositorySetsView(RepositoriesPreferencePage page)
{
this.page = page;
}
-
- public Control createContents( Composite parent )
+ public Control createContents(Composite parent)
{
// Create Controls
- Composite composite = new Composite( parent, SWT.NONE );
+ Composite composite = new Composite(parent, SWT.NONE);
- Table table = new Table( composite, SWT.SINGLE | SWT.BORDER );
+ Table table = new Table(composite, SWT.SINGLE | SWT.BORDER);
// Table Viewer Setup
- setView = new TableViewer( table );
+ setView = new TableViewer(table);
- setView.setContentProvider( new DefaultTableProvider()
+ setView.setContentProvider(new DefaultTableProvider()
{
- public Object[] getElements( Object inputElement )
+ public Object[] getElements(Object inputElement)
{
- return toArray( inputElement );
+ return toArray(inputElement);
}
- } );
+ });
- defaultSet = new RepositoryViewData( DEFAULT, SigilCore.getRepositoryConfiguration().getDefaultRepositorySet()
- .getRepositories() );
+ defaultSet = new RepositoryViewData(
+ DEFAULT,
+ SigilCore.getRepositoryConfiguration().getDefaultRepositorySet().getRepositories());
- sets.add( defaultSet );
+ sets.add(defaultSet);
- for ( Map.Entry<String, IRepositorySet> e : SigilCore.getRepositoryConfiguration().loadRepositorySets()
- .entrySet() )
+ for (Map.Entry<String, IRepositorySet> e : SigilCore.getRepositoryConfiguration().loadRepositorySets().entrySet())
{
IRepositorySet s = e.getValue();
- sets.add( new RepositoryViewData( e.getKey(), s.getRepositories() ) );
+ sets.add(new RepositoryViewData(e.getKey(), s.getRepositories()));
}
- setView.setLabelProvider( new DefaultLabelProvider()
+ setView.setLabelProvider(new DefaultLabelProvider()
{
- public Image getImage( Object element )
+ public Image getImage(Object element)
{
return null;
}
-
- public String getText( Object element )
+ public String getText(Object element)
{
- RepositoryViewData data = ( RepositoryViewData ) element;
+ RepositoryViewData data = (RepositoryViewData) element;
return data.getName();
}
- } );
+ });
- setView.setInput( sets );
+ setView.setInput(sets);
// Layout
- composite.setLayout( new GridLayout( 2, false ) );
- table.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true, 1, 6 ) );
+ composite.setLayout(new GridLayout(2, false));
+ table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 6));
- createButtons( composite );
+ createButtons(composite);
return composite;
}
-
- private void createButtons( final Composite composite )
+ private void createButtons(final Composite composite)
{
- final Button add = new Button( composite, SWT.PUSH );
- add.setText( "Add..." );
- add.setEnabled( true );
+ final Button add = new Button(composite, SWT.PUSH);
+ add.setText("Add...");
+ add.setEnabled(true);
- final Button edit = new Button( composite, SWT.PUSH );
- edit.setText( "Edit..." );
- edit.setEnabled( false );
+ final Button edit = new Button(composite, SWT.PUSH);
+ edit.setText("Edit...");
+ edit.setEnabled(false);
- final Button remove = new Button( composite, SWT.PUSH );
- remove.setText( "Remove" );
- remove.setEnabled( false );
+ final Button remove = new Button(composite, SWT.PUSH);
+ remove.setText("Remove");
+ remove.setEnabled(false);
// Listeners
- add.addSelectionListener( new SelectionAdapter()
+ add.addSelectionListener(new SelectionAdapter()
{
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
- add( composite );
+ add(composite);
}
- } );
+ });
- edit.addSelectionListener( new SelectionAdapter()
+ edit.addSelectionListener(new SelectionAdapter()
{
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
- IStructuredSelection sel = ( IStructuredSelection ) setView.getSelection();
- edit( composite, sel );
+ IStructuredSelection sel = (IStructuredSelection) setView.getSelection();
+ edit(composite, sel);
}
- } );
+ });
- remove.addSelectionListener( new SelectionAdapter()
+ remove.addSelectionListener(new SelectionAdapter()
{
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
- IStructuredSelection sel = ( IStructuredSelection ) setView.getSelection();
- remove( sel );
+ IStructuredSelection sel = (IStructuredSelection) setView.getSelection();
+ remove(sel);
}
- } );
+ });
- setView.addSelectionChangedListener( new ISelectionChangedListener()
+ setView.addSelectionChangedListener(new ISelectionChangedListener()
{
- public void selectionChanged( SelectionChangedEvent event )
+ public void selectionChanged(SelectionChangedEvent event)
{
boolean enabled = !event.getSelection().isEmpty();
- if ( enabled )
+ if (enabled)
{
- RepositoryViewData element = ( RepositoryViewData ) ( ( IStructuredSelection ) event.getSelection() )
- .getFirstElement();
- edit.setEnabled( true );
- remove.setEnabled( element != defaultSet );
+ RepositoryViewData element = (RepositoryViewData) ((IStructuredSelection) event.getSelection()).getFirstElement();
+ edit.setEnabled(true);
+ remove.setEnabled(element != defaultSet);
}
else
{
- edit.setEnabled( false );
- remove.setEnabled( false );
+ edit.setEnabled(false);
+ remove.setEnabled(false);
}
}
- } );
+ });
- add.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false ) );
- edit.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false ) );
- remove.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, false ) );
+ add.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+ edit.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
+ remove.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
}
-
- private void add( Control parent )
+ private void add(Control parent)
{
- RepositorySetDialog wizard = new RepositorySetDialog( getShell( parent ), getNames() );
- if ( wizard.open() == Window.OK )
+ RepositorySetDialog wizard = new RepositorySetDialog(getShell(parent), getNames());
+ if (wizard.open() == Window.OK)
{
- sets.add( wizard.getData() );
+ sets.add(wizard.getData());
updated();
}
}
-
- private void edit( Control parent, IStructuredSelection sel )
+ private void edit(Control parent, IStructuredSelection sel)
{
- RepositoryViewData data = ( RepositoryViewData ) sel.getFirstElement();
- RepositorySetDialog wizard = new RepositorySetDialog( getShell( parent ), data, data != defaultSet, getNames() );
- if ( wizard.open() == Window.OK )
+ RepositoryViewData data = (RepositoryViewData) sel.getFirstElement();
+ RepositorySetDialog wizard = new RepositorySetDialog(getShell(parent), data,
+ data != defaultSet, getNames());
+ if (wizard.open() == Window.OK)
{
- if ( data != defaultSet )
+ if (data != defaultSet)
{
- data.setName( wizard.getData().getName() );
+ data.setName(wizard.getData().getName());
}
- data.setRepositories( wizard.getData().getRepositories() );
+ data.setRepositories(wizard.getData().getRepositories());
updated();
}
}
-
private Set<String> getNames()
{
HashSet<String> names = new HashSet<String>();
- for ( RepositoryViewData view : sets )
+ for (RepositoryViewData view : sets)
{
- if ( view != defaultSet )
+ if (view != defaultSet)
{
- names.add( view.getName() );
+ names.add(view.getName());
}
}
return names;
}
-
- private Shell getShell( Control parent )
+ private Shell getShell(Control parent)
{
return parent.getShell();
}
-
- private void remove( IStructuredSelection sel )
+ private void remove(IStructuredSelection sel)
{
- if ( sets.remove( sel.getFirstElement() ) )
+ if (sets.remove(sel.getFirstElement()))
{
updated();
}
}
-
private void updated()
{
setView.refresh();
page.changed();
}
-
public Map<String, IRepositorySet> getSets()
{
HashMap<String, IRepositorySet> ret = new HashMap<String, IRepositorySet>();
- for ( RepositoryViewData data : sets )
+ for (RepositoryViewData data : sets)
{
- if ( data != defaultSet )
+ if (data != defaultSet)
{
- IRepositorySet set = new RepositorySet( data.getRepositories() );
- ret.put( data.getName(), set );
+ IRepositorySet set = new RepositorySet(data.getRepositories());
+ ret.put(data.getName(), set);
}
}
return ret;
}
-
public IRepositoryModel[] getDefaultRepositories()
{
return defaultSet.getRepositories();
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoryTypeSelectionPage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoryTypeSelectionPage.java
index 33b4ac5..309ab09 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoryTypeSelectionPage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoryTypeSelectionPage.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.preferences.repository;
-
import java.util.ArrayList;
import java.util.Iterator;
@@ -42,7 +41,6 @@
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
-
public class RepositoryTypeSelectionPage extends WizardSelectionPage implements IWizardPage
{
@@ -51,97 +49,92 @@
private TableViewer repositoryView;
private IRepositoryModel repositoryElement;
-
public RepositoryTypeSelectionPage()
{
- super( TITLE );
- setTitle( TITLE );
+ super(TITLE);
+ setTitle(TITLE);
}
-
- public void createControl( Composite parent )
+ public void createControl(Composite parent)
{
- Composite control = new Composite( parent, SWT.NONE );
+ Composite control = new Composite(parent, SWT.NONE);
// components
- new Label( control, SWT.NONE ).setText( "Repositories" );
- Table table = new Table( control, SWT.SINGLE | SWT.BORDER );
+ new Label(control, SWT.NONE).setText("Repositories");
+ Table table = new Table(control, SWT.SINGLE | SWT.BORDER);
// layout
- control.setLayout( new GridLayout( 1, true ) );
- table.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
+ control.setLayout(new GridLayout(1, true));
+ table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
// view
- repositoryView = new TableViewer( table );
- repositoryView.setLabelProvider( new LabelProvider()
+ repositoryView = new TableViewer(table);
+ repositoryView.setLabelProvider(new LabelProvider()
{
@Override
- public String getText( Object element )
+ public String getText(Object element)
{
- IRepositoryType rep = ( IRepositoryType ) element;
+ IRepositoryType rep = (IRepositoryType) element;
return rep.getType();
}
-
@Override
- public Image getImage( Object element )
+ public Image getImage(Object element)
{
- IRepositoryType rep = ( IRepositoryType ) element;
+ IRepositoryType rep = (IRepositoryType) element;
return rep.getIcon();
}
- } );
+ });
- repositoryView.setContentProvider( new DefaultTableProvider()
+ repositoryView.setContentProvider(new DefaultTableProvider()
{
- public Object[] getElements( Object inputElement )
+ public Object[] getElements(Object inputElement)
{
- return toArray( inputElement );
+ return toArray(inputElement);
}
- } );
+ });
- repositoryView.addSelectionChangedListener( new ISelectionChangedListener()
+ repositoryView.addSelectionChangedListener(new ISelectionChangedListener()
{
- public void selectionChanged( SelectionChangedEvent event )
+ public void selectionChanged(SelectionChangedEvent event)
{
- if ( !event.getSelection().isEmpty() )
+ if (!event.getSelection().isEmpty())
{
- IStructuredSelection sel = ( IStructuredSelection ) event.getSelection();
- IRepositoryType type = ( IRepositoryType ) sel.getFirstElement();
- repositoryElement = SigilCore.getRepositoryConfiguration().newRepositoryElement( type );
- selectWizardNode( new RepositoryWizardNode( repositoryElement ) );
+ IStructuredSelection sel = (IStructuredSelection) event.getSelection();
+ IRepositoryType type = (IRepositoryType) sel.getFirstElement();
+ repositoryElement = SigilCore.getRepositoryConfiguration().newRepositoryElement(
+ type);
+ selectWizardNode(new RepositoryWizardNode(repositoryElement));
}
}
- } );
+ });
- ArrayList<IRepositoryType> descriptors = new ArrayList<IRepositoryType>( SigilCore.getRepositoryConfiguration()
- .loadRepositoryTypes() );
+ ArrayList<IRepositoryType> descriptors = new ArrayList<IRepositoryType>(
+ SigilCore.getRepositoryConfiguration().loadRepositoryTypes());
- for ( Iterator<IRepositoryType> i = descriptors.iterator(); i.hasNext(); )
+ for (Iterator<IRepositoryType> i = descriptors.iterator(); i.hasNext();)
{
- if ( !i.next().isDynamic() )
+ if (!i.next().isDynamic())
{
i.remove();
}
}
- repositoryView.setInput( descriptors );
+ repositoryView.setInput(descriptors);
- setControl( control );
+ setControl(control);
}
-
- public void selectWizardNode( RepositoryWizardNode node )
+ public void selectWizardNode(RepositoryWizardNode node)
{
- setSelectedNode( node );
+ setSelectedNode(node);
}
-
public RepositoryWizardNode getSelectedWizardNode()
{
- return ( RepositoryWizardNode ) getSelectedNode();
+ return (RepositoryWizardNode) getSelectedNode();
}
-
public IRepositoryModel getRepository()
{
return repositoryElement;
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoryViewData.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoryViewData.java
index b86756b..714bb12 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoryViewData.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoryViewData.java
@@ -19,42 +19,35 @@
package org.apache.felix.sigil.eclipse.ui.internal.preferences.repository;
-
import org.apache.felix.sigil.eclipse.model.repository.IRepositoryModel;
-
class RepositoryViewData
{
private String name;
private IRepositoryModel[] reps;
-
- RepositoryViewData( String name, IRepositoryModel[] reps )
+ RepositoryViewData(String name, IRepositoryModel[] reps)
{
this.name = name;
this.reps = reps;
}
-
String getName()
{
return name;
}
-
IRepositoryModel[] getRepositories()
{
return reps;
}
-
- void setName( String name )
+ void setName(String name)
{
this.name = name;
}
-
- void setRepositories( IRepositoryModel[] reps )
+ void setRepositories(IRepositoryModel[] reps)
{
this.reps = reps;
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoryWizardNode.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoryWizardNode.java
index bbfda3b..6a4a7d6 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoryWizardNode.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/RepositoryWizardNode.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.preferences.repository;
-
import org.apache.felix.sigil.eclipse.SigilCore;
import org.apache.felix.sigil.eclipse.model.repository.IRepositoryModel;
import org.apache.felix.sigil.eclipse.ui.wizard.repository.RepositoryWizard;
@@ -28,7 +27,6 @@
import org.eclipse.jface.wizard.IWizardNode;
import org.eclipse.swt.graphics.Point;
-
public class RepositoryWizardNode implements IWizardNode
{
@@ -36,53 +34,47 @@
private RepositoryWizard wizard;
-
- public RepositoryWizardNode( IRepositoryModel repository )
+ public RepositoryWizardNode(IRepositoryModel repository)
{
this.repository = repository;
}
-
public void dispose()
{
- if ( wizard != null )
+ if (wizard != null)
{
wizard.dispose();
wizard = null;
}
}
-
public Point getExtent()
{
- return new Point( -1, -1 );
+ return new Point(-1, -1);
}
-
public IWizard getWizard()
{
- if ( wizard == null )
+ if (wizard == null)
{
try
{
- wizard = WizardHelper.loadWizard( repository.getType() );
- wizard.init( repository );
+ wizard = WizardHelper.loadWizard(repository.getType());
+ wizard.init(repository);
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- SigilCore.error( "Failed to create wizard for " + repository.getType(), e );
+ SigilCore.error("Failed to create wizard for " + repository.getType(), e);
}
}
return wizard;
}
-
public IRepositoryModel getRepository()
{
return repository;
}
-
public boolean isContentCreated()
{
return wizard != null;
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/WizardHelper.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/WizardHelper.java
index aab59d5..43709bb 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/WizardHelper.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/preferences/repository/WizardHelper.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.preferences.repository;
-
import org.apache.felix.sigil.eclipse.SigilCore;
import org.apache.felix.sigil.eclipse.model.repository.IRepositoryType;
import org.apache.felix.sigil.eclipse.ui.SigilUI;
@@ -31,38 +30,36 @@
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
-
public class WizardHelper
{
- public static RepositoryWizard loadWizard( IRepositoryType type ) throws CoreException
+ public static RepositoryWizard loadWizard(IRepositoryType type) throws CoreException
{
- IConfigurationElement e = findWizardConfig( type.getId() );
+ IConfigurationElement e = findWizardConfig(type.getId());
- if ( e == null )
+ if (e == null)
{
- throw SigilCore.newCoreException( "No wizard registered for repository " + type, null );
+ throw SigilCore.newCoreException("No wizard registered for repository "
+ + type, null);
}
- return ( RepositoryWizard ) e.createExecutableExtension( "class" );
+ return (RepositoryWizard) e.createExecutableExtension("class");
}
-
- public static boolean hasWizard( IRepositoryType type )
+ public static boolean hasWizard(IRepositoryType type)
{
- return findWizardConfig( type.getId() ) != null;
+ return findWizardConfig(type.getId()) != null;
}
-
- private static IConfigurationElement findWizardConfig( String id )
+ private static IConfigurationElement findWizardConfig(String id)
{
IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint p = registry.getExtensionPoint( SigilUI.REPOSITORY_WIZARD_EXTENSION_POINT_ID );
+ IExtensionPoint p = registry.getExtensionPoint(SigilUI.REPOSITORY_WIZARD_EXTENSION_POINT_ID);
- for ( IExtension e : p.getExtensions() )
+ for (IExtension e : p.getExtensions())
{
- for ( IConfigurationElement c : e.getConfigurationElements() )
+ for (IConfigurationElement c : e.getConfigurationElements())
{
- if ( id.equals( c.getAttribute( "repository" ) ) )
+ if (id.equals(c.getAttribute("repository")))
{
return c;
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportPackageProposal.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportPackageProposal.java
index 3f16ee5..a9b8d3a 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportPackageProposal.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportPackageProposal.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.quickfix;
-
import org.apache.felix.sigil.common.model.ModelElementFactory;
import org.apache.felix.sigil.common.model.ModelElementFactoryException;
import org.apache.felix.sigil.common.model.osgi.IPackageExport;
@@ -37,84 +36,77 @@
import org.eclipse.swt.graphics.Point;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
-
public class ImportPackageProposal implements IJavaCompletionProposal
{
private IPackageExport e;
private ISigilProjectModel n;
-
- public ImportPackageProposal( IPackageExport e, ISigilProjectModel n )
+ public ImportPackageProposal(IPackageExport e, ISigilProjectModel n)
{
this.e = e;
this.n = n;
}
-
public int getRelevance()
{
return 100;
}
-
- public void apply( IDocument document )
+ public void apply(IDocument document)
{
try
{
- final IPackageImport i = ModelElementFactory.getInstance().newModelElement( IPackageImport.class );
- i.setPackageName( e.getPackageName() );
+ final IPackageImport i = ModelElementFactory.getInstance().newModelElement(
+ IPackageImport.class);
+ i.setPackageName(e.getPackageName());
VersionRange selectedVersions = ModelHelper.getDefaultRange(e.getVersion());
- i.setVersions( selectedVersions );
+ i.setVersions(selectedVersions);
WorkspaceModifyOperation op = new WorkspaceModifyOperation()
{
@Override
- protected void execute( IProgressMonitor monitor ) throws CoreException
+ protected void execute(IProgressMonitor monitor) throws CoreException
{
- n.getBundle().getBundleInfo().addImport( i );
- n.save( monitor );
+ n.getBundle().getBundleInfo().addImport(i);
+ n.save(monitor);
}
};
- SigilUI.runWorkspaceOperation( op, null );
+ SigilUI.runWorkspaceOperation(op, null);
}
- catch ( ModelElementFactoryException e )
+ catch (ModelElementFactoryException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
-
public String getAdditionalProposalInfo()
{
return null;
}
-
public IContextInformation getContextInformation()
{
// TODO Auto-generated method stub
return null;
}
-
public String getDisplayString()
{
- return "Import package " + e.getPackageName() + " version " + e.getVersion() + " to bundle";
+ return "Import package " + e.getPackageName() + " version " + e.getVersion()
+ + " to bundle";
}
-
public Image getImage()
{
// TODO Auto-generated method stub
return null;
}
-
- public Point getSelection( IDocument document )
+ public Point getSelection(IDocument document)
{
return null;
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportQuickFixProcessor.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportQuickFixProcessor.java
index d4edee1..3f72696 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportQuickFixProcessor.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportQuickFixProcessor.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.quickfix;
-
import java.util.ArrayList;
import java.util.HashMap;
@@ -49,17 +48,15 @@
import org.eclipse.jdt.ui.text.java.IProblemLocation;
import org.eclipse.jdt.ui.text.java.IQuickFixProcessor;
-
@SuppressWarnings("restriction")
public class ImportQuickFixProcessor implements IQuickFixProcessor
{
private static final Object SYNC_FLAG = new Object();
-
- public boolean hasCorrections( ICompilationUnit unit, int problemId )
+ public boolean hasCorrections(ICompilationUnit unit, int problemId)
{
- switch ( problemId )
+ switch (problemId)
{
case IProblem.ImportNotFound:
case IProblem.ForbiddenReference:
@@ -71,156 +68,158 @@
}
}
-
- public IJavaCompletionProposal[] getCorrections( IInvocationContext context, IProblemLocation[] locations )
- throws CoreException
+ public IJavaCompletionProposal[] getCorrections(IInvocationContext context,
+ IProblemLocation[] locations) throws CoreException
{
try
{
HashMap<Object, IJavaCompletionProposal> results = new HashMap<Object, IJavaCompletionProposal>();
- ISigilProjectModel project = findProject( context );
+ ISigilProjectModel project = findProject(context);
- if ( project != null )
+ if (project != null)
{
- for ( int i = 0; i < locations.length; i++ )
+ for (int i = 0; i < locations.length; i++)
{
- switch ( locations[i].getProblemId() )
+ switch (locations[i].getProblemId())
{
case IProblem.ForbiddenReference:
- handleImportNotFound( project, context, locations[i], results );
+ handleImportNotFound(project, context, locations[i], results);
break;
case IProblem.ImportNotFound:
- handleImportNotFound( project, context, locations[i], results );
+ handleImportNotFound(project, context, locations[i], results);
break;
case IProblem.IsClassPathCorrect:
- handleIsClassPathCorrect( project, context, locations[i], results );
+ handleIsClassPathCorrect(project, context, locations[i],
+ results);
break;
case IProblem.UndefinedType:
- handleUndefinedType( project, context, locations[i], results );
+ handleUndefinedType(project, context, locations[i], results);
break;
case IProblem.UndefinedName:
- handleUndefinedName( project, context, locations[i], results );
+ handleUndefinedName(project, context, locations[i], results);
break;
}
}
}
- return ( IJavaCompletionProposal[] ) results.values().toArray( new IJavaCompletionProposal[results.size()] );
+ return (IJavaCompletionProposal[]) results.values().toArray(
+ new IJavaCompletionProposal[results.size()]);
}
- catch ( RuntimeException e )
+ catch (RuntimeException e)
{
e.printStackTrace();
throw e;
}
}
-
- private void handleUndefinedName( ISigilProjectModel project, IInvocationContext context, IProblemLocation problem,
- HashMap<Object, IJavaCompletionProposal> results )
+ private void handleUndefinedName(ISigilProjectModel project,
+ IInvocationContext context, IProblemLocation problem,
+ HashMap<Object, IJavaCompletionProposal> results)
{
- Name node = findNode( context, problem );
+ Name node = findNode(context, problem);
- if ( node == null )
+ if (node == null)
{
return;
}
- addSearchResults( node, project, results );
+ addSearchResults(node, project, results);
}
-
- private void handleIsClassPathCorrect( ISigilProjectModel project, final IInvocationContext context,
- IProblemLocation problemLocation, final HashMap<Object, IJavaCompletionProposal> results )
+ private void handleIsClassPathCorrect(ISigilProjectModel project,
+ final IInvocationContext context, IProblemLocation problemLocation,
+ final HashMap<Object, IJavaCompletionProposal> results)
{
- for ( final String type : problemLocation.getProblemArguments() )
+ for (final String type : problemLocation.getProblemArguments())
{
- final String iPackage = type.substring( 0, type.lastIndexOf( "." ) );
+ final String iPackage = type.substring(0, type.lastIndexOf("."));
- for ( IPackageExport pe : JavaHelper.findExportsForPackage( project, iPackage ) )
+ for (IPackageExport pe : JavaHelper.findExportsForPackage(project, iPackage))
{
- results.put( type, new ImportPackageProposal( pe, project ) );
+ results.put(type, new ImportPackageProposal(pe, project));
}
}
- if ( !results.containsKey( SYNC_FLAG ) )
+ if (!results.containsKey(SYNC_FLAG))
{
//results.put( SYNC_FLAG, null);
}
}
-
- private void handleUndefinedType( ISigilProjectModel project, IInvocationContext context, IProblemLocation problem,
- HashMap<Object, IJavaCompletionProposal> results ) throws CoreException
+ private void handleUndefinedType(ISigilProjectModel project,
+ IInvocationContext context, IProblemLocation problem,
+ HashMap<Object, IJavaCompletionProposal> results) throws CoreException
{
- Name node = findNode( context, problem );
+ Name node = findNode(context, problem);
- if ( node == null )
+ if (node == null)
{
return;
}
- addSearchResults( node, project, results );
+ addSearchResults(node, project, results);
}
-
- private void handleImportNotFound( ISigilProjectModel project, final IInvocationContext context,
- IProblemLocation location, final HashMap<Object, IJavaCompletionProposal> results ) throws CoreException
+ private void handleImportNotFound(ISigilProjectModel project,
+ final IInvocationContext context, IProblemLocation location,
+ final HashMap<Object, IJavaCompletionProposal> results) throws CoreException
{
- ASTNode selectedNode = location.getCoveringNode( context.getASTRoot() );
- if ( selectedNode == null )
+ ASTNode selectedNode = location.getCoveringNode(context.getASTRoot());
+ if (selectedNode == null)
return;
- if ( selectedNode instanceof ClassInstanceCreation )
+ if (selectedNode instanceof ClassInstanceCreation)
{
- ClassInstanceCreation c = ( ClassInstanceCreation ) selectedNode;
+ ClassInstanceCreation c = (ClassInstanceCreation) selectedNode;
Type t = c.getType();
- Name node = findName( t );
- if ( node != null )
+ Name node = findName(t);
+ if (node != null)
{
- addSearchResults( node, project, results );
+ addSearchResults(node, project, results);
}
}
else
{
- for ( final String iPackage : readPackage( selectedNode, location ) )
+ for (final String iPackage : readPackage(selectedNode, location))
{
- if ( !results.containsKey( iPackage ) )
+ if (!results.containsKey(iPackage))
{
- for ( IPackageExport pe : JavaHelper.findExportsForPackage( project, iPackage ) )
+ for (IPackageExport pe : JavaHelper.findExportsForPackage(project,
+ iPackage))
{
- results.put( iPackage, new ImportPackageProposal( pe, project ) );
+ results.put(iPackage, new ImportPackageProposal(pe, project));
}
}
}
}
}
-
- private void addSearchResults( Name node, ISigilProjectModel project,
- HashMap<Object, IJavaCompletionProposal> results )
+ private void addSearchResults(Name node, ISigilProjectModel project,
+ HashMap<Object, IJavaCompletionProposal> results)
{
- for ( ISearchResult result : SigilSearch.findProviders( node.getFullyQualifiedName(), project, null ) )
+ for (ISearchResult result : SigilSearch.findProviders(
+ node.getFullyQualifiedName(), project, null))
{
- if ( project.getBundle().findImport( result.getPackageName() ) == null )
+ if (project.getBundle().findImport(result.getPackageName()) == null)
{
- String type = result.getPackageName() + "." + node.getFullyQualifiedName();
- results.put( type, new ImportSearchResultProposal( SigilUI.getActiveWorkbenchShell(), result, node,
- project ) );
+ String type = result.getPackageName() + "."
+ + node.getFullyQualifiedName();
+ results.put(type, new ImportSearchResultProposal(
+ SigilUI.getActiveWorkbenchShell(), result, node, project));
}
}
}
-
- private Name findName( Type t )
+ private Name findName(Type t)
{
- if ( t.isSimpleType() )
+ if (t.isSimpleType())
{
- SimpleType st = ( SimpleType ) t;
+ SimpleType st = (SimpleType) t;
return st.getName();
}
- else if ( t.isArrayType() )
+ else if (t.isArrayType())
{
- ArrayType at = ( ArrayType ) t;
- return findName( at.getElementType() );
+ ArrayType at = (ArrayType) t;
+ return findName(at.getElementType());
}
else
{
@@ -228,41 +227,40 @@
}
}
-
- private Name findNode( IInvocationContext context, IProblemLocation problem )
+ private Name findNode(IInvocationContext context, IProblemLocation problem)
{
- ASTNode selectedNode = problem.getCoveringNode( context.getASTRoot() );
- if ( selectedNode == null )
+ ASTNode selectedNode = problem.getCoveringNode(context.getASTRoot());
+ if (selectedNode == null)
{
return null;
}
- while ( selectedNode.getLocationInParent() == QualifiedName.NAME_PROPERTY )
+ while (selectedNode.getLocationInParent() == QualifiedName.NAME_PROPERTY)
{
selectedNode = selectedNode.getParent();
}
Name node = null;
- if ( selectedNode instanceof Type )
+ if (selectedNode instanceof Type)
{
- node = findName( ( Type ) selectedNode );
+ node = findName((Type) selectedNode);
}
- else if ( selectedNode instanceof Name )
+ else if (selectedNode instanceof Name)
{
- node = ( Name ) selectedNode;
+ node = (Name) selectedNode;
}
return node;
}
-
- private ISigilProjectModel findProject( IInvocationContext context ) throws CoreException
+ private ISigilProjectModel findProject(IInvocationContext context)
+ throws CoreException
{
IProject project = context.getCompilationUnit().getJavaProject().getProject();
- if ( project.hasNature( SigilCore.NATURE_ID ) )
+ if (project.hasNature(SigilCore.NATURE_ID))
{
- return SigilCore.create( project );
+ return SigilCore.create(project);
}
else
{
@@ -270,45 +268,46 @@
}
}
-
- private String[] readPackage( ASTNode selectedNode, IProblemLocation location )
+ private String[] readPackage(ASTNode selectedNode, IProblemLocation location)
{
ArrayList<String> packages = new ArrayList<String>();
- ImportDeclaration id = ( ImportDeclaration ) ASTNodes.getParent( selectedNode, ASTNode.IMPORT_DECLARATION );
+ ImportDeclaration id = (ImportDeclaration) ASTNodes.getParent(selectedNode,
+ ASTNode.IMPORT_DECLARATION);
- if ( id == null )
+ if (id == null)
{
- MethodInvocation m = ( MethodInvocation ) ASTNodes.getParent( selectedNode, ASTNode.METHOD_INVOCATION );
+ MethodInvocation m = (MethodInvocation) ASTNodes.getParent(selectedNode,
+ ASTNode.METHOD_INVOCATION);
- if ( m != null )
+ if (m != null)
{
- packages.add( readPackage( m ) );
- while ( m.getExpression() != null && m.getExpression() instanceof MethodInvocation )
+ packages.add(readPackage(m));
+ while (m.getExpression() != null
+ && m.getExpression() instanceof MethodInvocation)
{
- m = ( MethodInvocation ) m.getExpression();
- packages.add( readPackage( m ) );
+ m = (MethodInvocation) m.getExpression();
+ packages.add(readPackage(m));
}
}
}
else
{
- if ( id.isOnDemand() )
+ if (id.isOnDemand())
{
- packages.add( id.getName().toString() );
+ packages.add(id.getName().toString());
}
else
{
String iStr = id.getName().toString();
- packages.add( iStr.substring( 0, iStr.lastIndexOf( "." ) ) );
+ packages.add(iStr.substring(0, iStr.lastIndexOf(".")));
}
}
- return packages.toArray( new String[packages.size()] );
+ return packages.toArray(new String[packages.size()]);
}
-
- private String readPackage( MethodInvocation m )
+ private String readPackage(MethodInvocation m)
{
return m.resolveMethodBinding().getDeclaringClass().getPackage().getName();
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportSearchResultProposal.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportSearchResultProposal.java
index efcd9bf..60210b4 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportSearchResultProposal.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportSearchResultProposal.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.quickfix;
-
import org.apache.felix.sigil.common.model.ModelElementFactory;
import org.apache.felix.sigil.common.model.osgi.IPackageExport;
import org.apache.felix.sigil.common.model.osgi.IPackageImport;
@@ -51,7 +50,6 @@
import org.eclipse.ui.actions.WorkspaceModifyOperation;
import org.osgi.framework.Version;
-
public class ImportSearchResultProposal implements IJavaCompletionProposal
{
@@ -60,123 +58,124 @@
private final ISearchResult result;
private final Shell shell;
-
- public ImportSearchResultProposal( Shell shell, ISearchResult result, Name node, ISigilProjectModel project )
+ public ImportSearchResultProposal(Shell shell, ISearchResult result, Name node, ISigilProjectModel project)
{
this.shell = shell;
this.result = result;
this.project = project;
- if ( node != null )
+ if (node != null)
{
- CompilationUnit cu = ( CompilationUnit ) ASTNodes.getParent( node, ASTNode.COMPILATION_UNIT );
- this.fCompilationUnit = ( ICompilationUnit ) cu.getJavaElement();
+ CompilationUnit cu = (CompilationUnit) ASTNodes.getParent(node,
+ ASTNode.COMPILATION_UNIT);
+ this.fCompilationUnit = (ICompilationUnit) cu.getJavaElement();
}
}
-
public int getRelevance()
{
return 100;
}
-
- public void apply( IDocument document )
+ public void apply(IDocument document)
{
IPackageExport e = result.getExport();
- if ( result.getExport() == null )
+ if (result.getExport() == null)
{
- if ( MessageDialog.openQuestion( shell, "Modify " + result.getProvider().getBundleInfo().getSymbolicName(),
- result.getPackageName() + " is not exported. Do you want to export it now?" ) )
+ if (MessageDialog.openQuestion(shell, "Modify "
+ + result.getProvider().getBundleInfo().getSymbolicName(),
+ result.getPackageName()
+ + " is not exported. Do you want to export it now?"))
{
- final IPackageExport pe = ModelElementFactory.getInstance().newModelElement( IPackageExport.class );
- pe.setPackageName( result.getPackageName() );
+ final IPackageExport pe = ModelElementFactory.getInstance().newModelElement(
+ IPackageExport.class);
+ pe.setPackageName(result.getPackageName());
//e.setVersion(version)
- final ISigilProjectModel mod = result.getProvider().getAncestor( ISigilProjectModel.class );
- if ( mod == null )
+ final ISigilProjectModel mod = result.getProvider().getAncestor(
+ ISigilProjectModel.class);
+ if (mod == null)
{
- throw new IllegalStateException( "Attempt to modify binary package export" );
+ throw new IllegalStateException(
+ "Attempt to modify binary package export");
}
WorkspaceModifyOperation op = new WorkspaceModifyOperation()
{
@Override
- protected void execute( IProgressMonitor monitor ) throws CoreException
+ protected void execute(IProgressMonitor monitor) throws CoreException
{
- mod.getBundle().getBundleInfo().addExport( pe );
- mod.save( monitor );
+ mod.getBundle().getBundleInfo().addExport(pe);
+ mod.save(monitor);
}
};
- SigilUI.runWorkspaceOperation( op, null );
+ SigilUI.runWorkspaceOperation(op, null);
e = pe;
}
}
- final IPackageImport i = ModelElementFactory.getInstance().newModelElement( IPackageImport.class );
- i.setPackageName( e.getPackageName() );
+ final IPackageImport i = ModelElementFactory.getInstance().newModelElement(
+ IPackageImport.class);
+ i.setPackageName(e.getPackageName());
VersionRange selectedVersions = ModelHelper.getDefaultRange(e.getVersion());
- i.setVersions( selectedVersions );
+ i.setVersions(selectedVersions);
WorkspaceModifyOperation op = new WorkspaceModifyOperation()
{
@Override
- protected void execute( IProgressMonitor monitor ) throws CoreException
+ protected void execute(IProgressMonitor monitor) throws CoreException
{
- project.getBundle().getBundleInfo().addImport( i );
- project.save( null );
+ project.getBundle().getBundleInfo().addImport(i);
+ project.save(null);
}
};
- SigilUI.runWorkspaceOperation( op, null );
+ SigilUI.runWorkspaceOperation(op, null);
addSourceImport();
}
-
private void addSourceImport()
{
// add import
try
{
- ImportRewrite rewrite = CodeStyleConfiguration.createImportRewrite( fCompilationUnit, true );
- rewrite.addImport( result.getClassName() );
- JavaModelUtil.applyEdit( fCompilationUnit, rewrite.rewriteImports( null ), false, null );
+ ImportRewrite rewrite = CodeStyleConfiguration.createImportRewrite(
+ fCompilationUnit, true);
+ rewrite.addImport(result.getClassName());
+ JavaModelUtil.applyEdit(fCompilationUnit, rewrite.rewriteImports(null),
+ false, null);
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- SigilCore.error( "Failed to add import", e );
+ SigilCore.error("Failed to add import", e);
}
}
-
public String getAdditionalProposalInfo()
{
return null;
}
-
public IContextInformation getContextInformation()
{
// TODO Auto-generated method stub
return null;
}
-
public String getDisplayString()
{
String type = result.getClassName();
- String loc = result.getExport() == null ? " from " + result.getProvider().getBundleInfo().getSymbolicName()
- : " version " + result.getExport().getVersion();
+ String loc = result.getExport() == null ? " from "
+ + result.getProvider().getBundleInfo().getSymbolicName() : " version "
+ + result.getExport().getVersion();
return "Import " + type + loc;
}
-
public Image getImage()
{
// TODO Auto-generated method stub
return null;
}
-
- public Point getSelection( IDocument document )
+ public Point getSelection(IDocument document)
{
return null;
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportedClassReference.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportedClassReference.java
index 363e089..b5c787d 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportedClassReference.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/quickfix/ImportedClassReference.java
@@ -19,29 +19,24 @@
package org.apache.felix.sigil.eclipse.ui.internal.quickfix;
-
import org.apache.felix.sigil.common.model.osgi.IPackageImport;
-
public class ImportedClassReference
{
private IPackageImport pi;
private String type;
-
- public ImportedClassReference( IPackageImport packageImport, String typeName )
+ public ImportedClassReference(IPackageImport packageImport, String typeName)
{
this.pi = packageImport;
this.type = typeName;
}
-
public IPackageImport getPackageImport()
{
return pi;
}
-
public String getFullType()
{
return type;
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/BundleActivatorChange.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/BundleActivatorChange.java
index 41f6806..773264c 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/BundleActivatorChange.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/BundleActivatorChange.java
@@ -75,7 +75,7 @@
public void initializeValidationData(IProgressMonitor monitor)
{
// TODO Auto-generated method stub
-
+
}
/* (non-Javadoc)
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/ExportPackageChange.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/ExportPackageChange.java
index ab0233e..df1d34d 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/ExportPackageChange.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/ExportPackageChange.java
@@ -78,17 +78,19 @@
@Override
public Change perform(IProgressMonitor progress) throws CoreException
- {
- if (oldExport != null) {
+ {
+ if (oldExport != null)
+ {
sigil.getBundle().getBundleInfo().removeChild(oldExport);
}
-
- if (newExport != null) {
+
+ if (newExport != null)
+ {
sigil.getBundle().getBundleInfo().addExport(newExport);
}
-
+
sigil.save(progress);
-
+
return new ExportPackageChange(sigil, newExport, oldExport);
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/ImportPackageChange.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/ImportPackageChange.java
index 9537a3d..cf3b990 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/ImportPackageChange.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/ImportPackageChange.java
@@ -72,16 +72,18 @@
@Override
public Change perform(IProgressMonitor progress) throws CoreException
{
- if (oldImport!=null) {
+ if (oldImport != null)
+ {
sigil.getBundle().getBundleInfo().removeImport(oldImport);
}
-
- if (newImport != null) {
+
+ if (newImport != null)
+ {
sigil.getBundle().getBundleInfo().addImport(newImport);
}
-
+
sigil.save(progress);
-
+
return new ImportPackageChange(sigil, newImport, oldImport);
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/MoveActivatorParticipant.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/MoveActivatorParticipant.java
index 205be07..f45a4e9 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/MoveActivatorParticipant.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/MoveActivatorParticipant.java
@@ -47,19 +47,22 @@
CheckConditionsContext ctx) throws OperationCanceledException
{
RefactoringStatus status = null;
- if(getArguments().getUpdateReferences()) {
+ if (getArguments().getUpdateReferences())
+ {
IPackageFragment pf = (IPackageFragment) compilationUnit.getAncestor(IJavaModel.PACKAGE_FRAGMENT);
String oldName = qualifiedName(pf, compilationUnit.getElementName());
try
{
ISigilProjectModel sigil = SigilCore.create(compilationUnit.getJavaProject().getProject());
- if (oldName.equals(sigil.getBundle().getBundleInfo().getActivator())) {
+ if (oldName.equals(sigil.getBundle().getBundleInfo().getActivator()))
+ {
IPackageFragment dest = (IPackageFragment) getArguments().getDestination();
String newName = qualifiedName(dest, compilationUnit.getElementName());
-
+
RefactorUtil.touch(ctx, sigil);
changes.add(new BundleActivatorChange(sigil, oldName, newName));
- status = RefactoringStatus.createInfoStatus("Updating bundle activator from " + oldName + " to " + newName );
+ status = RefactoringStatus.createInfoStatus("Updating bundle activator from "
+ + oldName + " to " + newName);
}
}
catch (CoreException e)
@@ -67,7 +70,7 @@
SigilCore.warn("Failed to update activator", e);
}
}
-
+
return status;
}
@@ -86,15 +89,16 @@
public Change createChange(IProgressMonitor monitor) throws CoreException,
OperationCanceledException
{
- if (changes.isEmpty()) {
+ if (changes.isEmpty())
+ {
return new NullChange();
}
- else
+ else
{
CompositeChange ret = new CompositeChange("Export-Package update");
-
+
ret.addAll(changes.toArray(new Change[changes.size()]));
-
+
return ret;
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/MovePackageParticipant.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/MovePackageParticipant.java
index 389b9a3..7cfb4f7 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/MovePackageParticipant.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/MovePackageParticipant.java
@@ -52,50 +52,69 @@
public RefactoringStatus checkConditions(IProgressMonitor monitor,
CheckConditionsContext context) throws OperationCanceledException
{
- if (getArguments().getUpdateReferences()) {
+ if (getArguments().getUpdateReferences())
+ {
try
{
ISigilProjectModel sourceProject = SigilCore.create(packageFragment.getJavaProject().getProject());
IPackageFragmentRoot dest = (IPackageFragmentRoot) getArguments().getDestination();
ISigilProjectModel destProject = SigilCore.create(dest.getJavaProject().getProject());
-
+
RefactoringStatus status = new RefactoringStatus();
- if ( !sourceProject.equals(destProject) ) {
+ if (!sourceProject.equals(destProject))
+ {
RefactorUtil.touch(context, sourceProject);
RefactorUtil.touch(context, destProject);
-
+
final String packageName = packageFragment.getElementName();
- IPackageExport oldExport = ModelHelper.findExport(sourceProject, packageName);
-
- if (oldExport != null) {
- IPackageExport newExport = ModelElementFactory.getInstance().newModelElement(IPackageExport.class);
-
+ IPackageExport oldExport = ModelHelper.findExport(sourceProject,
+ packageName);
+
+ if (oldExport != null)
+ {
+ IPackageExport newExport = ModelElementFactory.getInstance().newModelElement(
+ IPackageExport.class);
+
newExport.setPackageName(oldExport.getPackageName());
newExport.setVersion(oldExport.getRawVersion());
-
- changes.add(new ExportPackageChange(destProject,null, newExport));
- changes.add(new ExportPackageChange(sourceProject, oldExport, null));
-
- status.addWarning("Package " + packageName + " is exported from " + sourceProject.getSymbolicName() + ", this may effect client bundles that use require bundle");
- }
- else {
- SubMonitor sub = SubMonitor.convert(monitor);
-
- Set<String> users = JavaHelper.findLocalPackageUsers(sourceProject, packageName, sub.newChild(100));
- Set<String> dependencies = JavaHelper.findLocalPackageDependencies(sourceProject, packageName, sub.newChild(100));
- if (users.size() > 0 && dependencies.size() > 0) {
- status.addWarning("Package " + packageName + " is coupled to " + users + " and " + dependencies + " this may cause a cyclical dependency");
+ changes.add(new ExportPackageChange(destProject, null, newExport));
+ changes.add(new ExportPackageChange(sourceProject, oldExport,
+ null));
+
+ status.addWarning("Package " + packageName + " is exported from "
+ + sourceProject.getSymbolicName()
+ + ", this may effect client bundles that use require bundle");
+ }
+ else
+ {
+ SubMonitor sub = SubMonitor.convert(monitor);
+
+ Set<String> users = JavaHelper.findLocalPackageUsers(
+ sourceProject, packageName, sub.newChild(100));
+ Set<String> dependencies = JavaHelper.findLocalPackageDependencies(
+ sourceProject, packageName, sub.newChild(100));
+
+ if (users.size() > 0 && dependencies.size() > 0)
+ {
+ status.addWarning("Package " + packageName
+ + " is coupled to " + users + " and " + dependencies
+ + " this may cause a cyclical dependency");
}
-
- if (users.size() > 0) { // attempt to move an API package
- IPackageExport newExport = createNewExport(status, destProject, packageName);
+
+ if (users.size() > 0)
+ { // attempt to move an API package
+ IPackageExport newExport = createNewExport(status,
+ destProject, packageName);
createNewImport(status, sourceProject, newExport);
}
-
- if (dependencies.size() > 0){ // moved an impl package
- for (String dep : dependencies) {
- IPackageExport newExport = createNewExport(status, sourceProject, dep);
+
+ if (dependencies.size() > 0)
+ { // moved an impl package
+ for (String dep : dependencies)
+ {
+ IPackageExport newExport = createNewExport(status,
+ sourceProject, dep);
createNewImport(status, destProject, newExport);
}
}
@@ -109,32 +128,36 @@
throw new OperationCanceledException(e.getMessage());
}
}
- else {
+ else
+ {
return new RefactoringStatus();
}
}
- private void createNewImport(RefactoringStatus status,
- ISigilProjectModel project, IPackageExport export)
+ private void createNewImport(RefactoringStatus status, ISigilProjectModel project,
+ IPackageExport export)
{
- IPackageImport newImport = ModelElementFactory.getInstance().newModelElement(IPackageImport.class);
+ IPackageImport newImport = ModelElementFactory.getInstance().newModelElement(
+ IPackageImport.class);
newImport.setPackageName(export.getPackageName());
newImport.setVersions(ModelHelper.getDefaultRange(export.getVersion()));
-
+
status.addInfo("Creating new import in " + project.getSymbolicName());
- changes.add( new ImportPackageChange(project, null, newImport));
+ changes.add(new ImportPackageChange(project, null, newImport));
}
private IPackageExport createNewExport(RefactoringStatus status,
ISigilProjectModel project, String packageName)
{
- IPackageExport newExport = ModelElementFactory.getInstance().newModelElement(IPackageExport.class);
- newExport.setPackageName(packageName);
+ IPackageExport newExport = ModelElementFactory.getInstance().newModelElement(
+ IPackageExport.class);
+ newExport.setPackageName(packageName);
// new export inherits project version by default
newExport.setVersion(project.getVersion());
-
- status.addInfo("Creating new export " + packageName + " in " + project.getSymbolicName());
- changes.add( new ExportPackageChange(project, null, newExport));
+
+ status.addInfo("Creating new export " + packageName + " in "
+ + project.getSymbolicName());
+ changes.add(new ExportPackageChange(project, null, newExport));
return newExport;
}
@@ -142,15 +165,16 @@
public Change createChange(IProgressMonitor monitor) throws CoreException,
OperationCanceledException
{
- if (changes.isEmpty()) {
+ if (changes.isEmpty())
+ {
return new NullChange();
}
- else
+ else
{
CompositeChange ret = new CompositeChange("Export-Package update");
-
+
ret.addAll(changes.toArray(new Change[changes.size()]));
-
+
return ret;
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RefactorUtil.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RefactorUtil.java
index 327e47d..017bc15 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RefactorUtil.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RefactorUtil.java
@@ -35,7 +35,7 @@
static final void touch(CheckConditionsContext context, ISigilProjectModel sigil)
{
ResourceChangeChecker checker = (ResourceChangeChecker) context.getChecker(ResourceChangeChecker.class);
- IResourceChangeDescriptionFactory deltaFactory= checker.getDeltaFactory();
+ IResourceChangeDescriptionFactory deltaFactory = checker.getDeltaFactory();
IFile file = sigil.getProject().getFile(SigilCore.SIGIL_PROJECT_FILE);
deltaFactory.change(file);
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RenameActivatorPackageParticipant.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RenameActivatorPackageParticipant.java
index a73bfc6..d62c501 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RenameActivatorPackageParticipant.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RenameActivatorPackageParticipant.java
@@ -45,19 +45,23 @@
CheckConditionsContext ctx) throws OperationCanceledException
{
RefactoringStatus status = null;
- if(getArguments().getUpdateReferences()) {
+ if (getArguments().getUpdateReferences())
+ {
try
{
ISigilProjectModel sigil = SigilCore.create(packageFragment.getJavaProject().getProject());
RefactorUtil.touch(ctx, sigil);
-
+
String oldName = sigil.getBundle().getBundleInfo().getActivator();
- if ( oldName != null ) {
+ if (oldName != null)
+ {
String[] parts = splitPackageClass(oldName);
- if (parts[0].equals(packageFragment.getElementName())) {
+ if (parts[0].equals(packageFragment.getElementName()))
+ {
String newName = getArguments().getNewName() + "." + parts[1];
changes.add(new BundleActivatorChange(sigil, oldName, newName));
- status = RefactoringStatus.createInfoStatus("Updating bundle activator from " + oldName + " to " + newName );
+ status = RefactoringStatus.createInfoStatus("Updating bundle activator from "
+ + oldName + " to " + newName);
}
}
}
@@ -66,7 +70,7 @@
SigilCore.warn("Failed to update activator", e);
}
}
-
+
return status;
}
@@ -74,11 +78,13 @@
{
String[] parts = new String[2];
int i = className.lastIndexOf('.');
- if ( i == -1 ) {
+ if (i == -1)
+ {
parts[0] = "";
parts[1] = className;
}
- else {
+ else
+ {
parts[0] = className.substring(0, i);
parts[1] = className.substring(i + 1);
}
@@ -89,22 +95,23 @@
public Change createChange(IProgressMonitor monitor) throws CoreException,
OperationCanceledException
{
- if (changes.isEmpty()) {
+ if (changes.isEmpty())
+ {
return new NullChange();
}
- else
+ else
{
CompositeChange ret = new CompositeChange("Export-Package update");
-
+
ret.addAll(changes.toArray(new Change[changes.size()]));
-
+
return ret;
}
}
@Override
public String getName()
- {
+ {
return "Sigil Rename Activator Package Participant";
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RenameActivatorParticipant.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RenameActivatorParticipant.java
index 79a6d4c..60b6d81 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RenameActivatorParticipant.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RenameActivatorParticipant.java
@@ -47,18 +47,21 @@
CheckConditionsContext ctx) throws OperationCanceledException
{
RefactoringStatus status = null;
- if(getArguments().getUpdateReferences()) {
+ if (getArguments().getUpdateReferences())
+ {
IPackageFragment pf = (IPackageFragment) compilationUnit.getAncestor(IJavaModel.PACKAGE_FRAGMENT);
String oldName = qualifiedName(pf, compilationUnit.getElementName());
try
{
ISigilProjectModel sigil = SigilCore.create(compilationUnit.getJavaProject().getProject());
- if (oldName.equals(sigil.getBundle().getBundleInfo().getActivator())) {
+ if (oldName.equals(sigil.getBundle().getBundleInfo().getActivator()))
+ {
String newName = qualifiedName(pf, getArguments().getNewName());
-
+
RefactorUtil.touch(ctx, sigil);
changes.add(new BundleActivatorChange(sigil, oldName, newName));
- status = RefactoringStatus.createInfoStatus("Updating bundle activator from " + oldName + " to " + newName );
+ status = RefactoringStatus.createInfoStatus("Updating bundle activator from "
+ + oldName + " to " + newName);
}
}
catch (CoreException e)
@@ -66,7 +69,7 @@
SigilCore.warn("Failed to update activator", e);
}
}
-
+
return status;
}
@@ -85,15 +88,16 @@
public Change createChange(IProgressMonitor monitor) throws CoreException,
OperationCanceledException
{
- if (changes.isEmpty()) {
+ if (changes.isEmpty())
+ {
return new NullChange();
}
- else
+ else
{
CompositeChange ret = new CompositeChange("Export-Package update");
-
+
ret.addAll(changes.toArray(new Change[changes.size()]));
-
+
return ret;
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RenamePackageParticipant.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RenamePackageParticipant.java
index c1aabba..36382de 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RenamePackageParticipant.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/refactor/RenamePackageParticipant.java
@@ -49,47 +49,57 @@
@Override
public RefactoringStatus checkConditions(IProgressMonitor pm,
CheckConditionsContext context) throws OperationCanceledException
- {
+ {
RefactoringStatus status = new RefactoringStatus();
-
- if (getArguments().getUpdateReferences()) {
+
+ if (getArguments().getUpdateReferences())
+ {
try
{
ISigilProjectModel sigil = SigilCore.create(packageFragment.getJavaProject().getProject());
final String packageName = packageFragment.getElementName();
-
+
SigilCore.log("Rename checkConditions " + packageName);
-
+
IPackageExport oldExport = ModelHelper.findExport(sigil, packageName);
-
- if (oldExport != null) {
+
+ if (oldExport != null)
+ {
// record change to check if out of sync...
RefactorUtil.touch(context, sigil);
-
- status = RefactoringStatus.createWarningStatus("Package " + packageName + " is exported. Renaming this package may effect bundles outside of this workspace");
- SigilCore.log("Export Package " + packageName + " renamed to " + getArguments().getNewName());
-
- IPackageExport newExport = ModelElementFactory.getInstance().newModelElement(IPackageExport.class);
+
+ status = RefactoringStatus.createWarningStatus("Package "
+ + packageName
+ + " is exported. Renaming this package may effect bundles outside of this workspace");
+ SigilCore.log("Export Package " + packageName + " renamed to "
+ + getArguments().getNewName());
+
+ IPackageExport newExport = ModelElementFactory.getInstance().newModelElement(
+ IPackageExport.class);
newExport.setPackageName(getArguments().getNewName());
newExport.setVersion(oldExport.getVersion());
-
- changes.add(new ExportPackageChange(sigil, oldExport, newExport));
-
- for ( ISigilProjectModel other : SigilCore.getRoot().getProjects() ) {
- if ( !sigil.equals(other) ) {
+
+ changes.add(new ExportPackageChange(sigil, oldExport, newExport));
+
+ for (ISigilProjectModel other : SigilCore.getRoot().getProjects())
+ {
+ if (!sigil.equals(other))
+ {
// record change to check if out of sync...
RefactorUtil.touch(context, other);
}
- changes.add(createImportChange(status, other, oldExport, newExport));
+ changes.add(createImportChange(status, other, oldExport,
+ newExport));
}
}
}
catch (CoreException e)
{
SigilCore.warn("Failed to create export package refactor", e);
- throw new OperationCanceledException("Failed to create export package refactor");
+ throw new OperationCanceledException(
+ "Failed to create export package refactor");
}
- }
+ }
return status;
}
@@ -97,15 +107,16 @@
public Change createChange(IProgressMonitor pm) throws CoreException,
OperationCanceledException
{
- if (changes.isEmpty()) {
+ if (changes.isEmpty())
+ {
return new NullChange();
}
- else
+ else
{
CompositeChange ret = new CompositeChange("Export-Package update");
-
+
ret.addAll(changes.toArray(new Change[changes.size()]));
-
+
return ret;
}
}
@@ -123,24 +134,28 @@
return true;
}
- private Change createImportChange(RefactoringStatus status, ISigilProjectModel sigil, IPackageExport oldExport, IPackageExport newExport)
+ private Change createImportChange(RefactoringStatus status, ISigilProjectModel sigil,
+ IPackageExport oldExport, IPackageExport newExport)
{
IBundleModelElement info = sigil.getBundle().getBundleInfo();
Collection<IPackageImport> imports = info.getImports();
-
- for (IPackageImport oldImport : imports) {
- if (oldImport.accepts(oldExport)) {
- IPackageImport newImport = ModelElementFactory.getInstance().newModelElement(IPackageImport.class);
-
+
+ for (IPackageImport oldImport : imports)
+ {
+ if (oldImport.accepts(oldExport))
+ {
+ IPackageImport newImport = ModelElementFactory.getInstance().newModelElement(
+ IPackageImport.class);
+
newImport.setPackageName(newExport.getPackageName());
newImport.setVersions(oldImport.getVersions());
-
+
status.addInfo(buildImportChangeMsg(sigil, oldImport, newImport));
-
+
return new ImportPackageChange(sigil, oldImport, newImport);
}
}
-
+
// ok no change
return new NullChange();
}
@@ -148,9 +163,10 @@
private static final String buildImportChangeMsg(ISigilProjectModel sigil,
IPackageImport oldImport, IPackageImport newImport)
{
- return "Updating import " + oldImport.getPackageName() + " version " + oldImport.getVersions() +
- " to " + newImport.getPackageName() + " version " + newImport.getVersions() +
- " in project " + sigil.getSymbolicName() + " version " + sigil.getVersion();
+ return "Updating import " + oldImport.getPackageName() + " version "
+ + oldImport.getVersions() + " to " + newImport.getPackageName() + " version "
+ + newImport.getVersions() + " in project " + sigil.getSymbolicName()
+ + " version " + sigil.getVersion();
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/FileSystemRepositoryWizard.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/FileSystemRepositoryWizard.java
index 87b6c5b..1c27230 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/FileSystemRepositoryWizard.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/FileSystemRepositoryWizard.java
@@ -19,15 +19,13 @@
package org.apache.felix.sigil.eclipse.ui.internal.repository;
-
import org.apache.felix.sigil.eclipse.ui.wizard.repository.RepositoryWizard;
-
public class FileSystemRepositoryWizard extends RepositoryWizard
{
@Override
public void addPages()
{
- addPage( new FileSystemRepositoryWizardPage( this ) );
+ addPage(new FileSystemRepositoryWizardPage(this));
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/FileSystemRepositoryWizardPage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/FileSystemRepositoryWizardPage.java
index 67c56b2..5e5b935 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/FileSystemRepositoryWizardPage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/FileSystemRepositoryWizardPage.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.repository;
-
import java.io.File;
import org.apache.felix.sigil.eclipse.ui.wizard.repository.RepositoryWizard;
@@ -30,54 +29,51 @@
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
-
public class FileSystemRepositoryWizardPage extends RepositoryWizardPage implements IWizardPage
{
private DirectoryFieldEditor dirEditor;
-
- protected FileSystemRepositoryWizardPage( RepositoryWizard parent )
+ protected FileSystemRepositoryWizardPage(RepositoryWizard parent)
{
- super( "File System Repository", parent );
+ super("File System Repository", parent);
}
-
@Override
public void createFieldEditors()
{
- dirEditor = new DirectoryFieldEditor( "dir", "Directory:", getFieldEditorParent() );
- dirEditor.getTextControl( getFieldEditorParent() ).addModifyListener( new ModifyListener()
- {
- public void modifyText( ModifyEvent e )
+ dirEditor = new DirectoryFieldEditor("dir", "Directory:", getFieldEditorParent());
+ dirEditor.getTextControl(getFieldEditorParent()).addModifyListener(
+ new ModifyListener()
{
- checkPageComplete();
- }
- } );
+ public void modifyText(ModifyEvent e)
+ {
+ checkPageComplete();
+ }
+ });
- addField( dirEditor );
- addField( new BooleanFieldEditor( "recurse", "Recurse:", getFieldEditorParent() ) );
+ addField(dirEditor);
+ addField(new BooleanFieldEditor("recurse", "Recurse:", getFieldEditorParent()));
}
-
@Override
protected void checkPageComplete()
{
super.checkPageComplete();
- if ( isPageComplete() )
+ if (isPageComplete())
{
- setPageComplete( dirEditor.getStringValue().length() > 0 );
- if ( isPageComplete() )
+ setPageComplete(dirEditor.getStringValue().length() > 0);
+ if (isPageComplete())
{
- if ( new File( dirEditor.getStringValue() ).isDirectory() )
+ if (new File(dirEditor.getStringValue()).isDirectory())
{
- setPageComplete( true );
- setErrorMessage( null );
+ setPageComplete(true);
+ setErrorMessage(null);
}
else
{
- setPageComplete( false );
- setErrorMessage( "Invalid directory" );
+ setPageComplete(false);
+ setErrorMessage("Invalid directory");
}
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/OSGiInstallRepositoryWizard.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/OSGiInstallRepositoryWizard.java
index acd1434..0afef2e 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/OSGiInstallRepositoryWizard.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/OSGiInstallRepositoryWizard.java
@@ -19,15 +19,13 @@
package org.apache.felix.sigil.eclipse.ui.internal.repository;
-
import org.apache.felix.sigil.eclipse.ui.wizard.repository.RepositoryWizard;
-
public class OSGiInstallRepositoryWizard extends RepositoryWizard
{
@Override
public void addPages()
{
- addPage( new OSGiInstallRepositoryWizardPage( this ) );
+ addPage(new OSGiInstallRepositoryWizardPage(this));
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/OSGiInstallRepositoryWizardPage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/OSGiInstallRepositoryWizardPage.java
index ca142fc..83a1f96 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/OSGiInstallRepositoryWizardPage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/repository/OSGiInstallRepositoryWizardPage.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.repository;
-
import java.util.ArrayList;
import org.apache.felix.sigil.eclipse.SigilCore;
@@ -28,31 +27,29 @@
import org.apache.felix.sigil.eclipse.ui.wizard.repository.RepositoryWizardPage;
import org.eclipse.jface.preference.RadioGroupFieldEditor;
-
public class OSGiInstallRepositoryWizardPage extends RepositoryWizardPage
{
- protected OSGiInstallRepositoryWizardPage( RepositoryWizard parent )
+ protected OSGiInstallRepositoryWizardPage(RepositoryWizard parent)
{
- super( "OSGi Install Repository", parent );
+ super("OSGi Install Repository", parent);
}
-
@Override
public void createFieldEditors()
{
ArrayList<String[]> installs = new ArrayList<String[]>();
- for ( String id : SigilCore.getInstallManager().getInstallIDs() )
+ for (String id : SigilCore.getInstallManager().getInstallIDs())
{
- IOSGiInstall i = SigilCore.getInstallManager().findInstall( id );
- installs.add( new String[]
- { i.getType().getName(), id } );
+ IOSGiInstall i = SigilCore.getInstallManager().findInstall(id);
+ installs.add(new String[] { i.getType().getName(), id });
}
- String[][] strs = installs.toArray( new String[installs.size()][] );
+ String[][] strs = installs.toArray(new String[installs.size()][]);
- RadioGroupFieldEditor editor = new RadioGroupFieldEditor( "id", "Install", 1, strs, getFieldEditorParent() );
+ RadioGroupFieldEditor editor = new RadioGroupFieldEditor("id", "Install", 1,
+ strs, getFieldEditorParent());
- addField( editor );
+ addField(editor);
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/startup/SigilStartup.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/startup/SigilStartup.java
index 595874a..d29655d 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/startup/SigilStartup.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/startup/SigilStartup.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.startup;
-
import java.util.concurrent.atomic.AtomicInteger;
import org.apache.felix.sigil.common.repository.IRepositoryChangeListener;
@@ -35,43 +34,47 @@
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.ui.IStartup;
-
public class SigilStartup implements IStartup
{
public void earlyStartup()
{
final AtomicInteger updateCounter = new AtomicInteger();
-
+
// Register a repository change listener to re-run the resolver when repository changes
- SigilCore.getGlobalRepositoryManager().addRepositoryChangeListener( new IRepositoryChangeListener()
- {
- public void repositoryChanged( RepositoryChangeEvent event )
+ SigilCore.getGlobalRepositoryManager().addRepositoryChangeListener(
+ new IRepositoryChangeListener()
{
- if ( !SigilUI.WORKSPACE_REPOSITORY_ID.equals( event.getRepository().getId() ) ) {
- final int update = updateCounter.incrementAndGet();
-
- Job job = new Job("Pending repository update") {
- @Override
- protected IStatus run(IProgressMonitor monitor)
+ public void repositoryChanged(RepositoryChangeEvent event)
+ {
+ if (!SigilUI.WORKSPACE_REPOSITORY_ID.equals(event.getRepository().getId()))
+ {
+ final int update = updateCounter.incrementAndGet();
+
+ Job job = new Job("Pending repository update")
{
- if ( update == updateCounter.get() ) {
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- ResolveProjectsJob job = new ResolveProjectsJob( workspace );
- job.setSystem( true );
- job.schedule();
+ @Override
+ protected IStatus run(IProgressMonitor monitor)
+ {
+ if (update == updateCounter.get())
+ {
+ IWorkspace workspace = ResourcesPlugin.getWorkspace();
+ ResolveProjectsJob job = new ResolveProjectsJob(
+ workspace);
+ job.setSystem(true);
+ job.schedule();
+ }
+ return Status.OK_STATUS;
}
- return Status.OK_STATUS;
- }
-
- };
- job.setSystem(true);
- job.schedule(100);
- }
- //else {
- // Repository changes are handled by ProjectResourceListener
- //}
- }
- } );
+
+ };
+ job.setSystem(true);
+ job.schedule(100);
+ }
+ //else {
+ // Repository changes are handled by ProjectResourceListener
+ //}
+ }
+ });
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/ModelElementComparator.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/ModelElementComparator.java
index e170fc9..f1a3c70 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/ModelElementComparator.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/ModelElementComparator.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.views;
-
import org.apache.felix.sigil.common.model.osgi.IPackageExport;
import org.apache.felix.sigil.common.model.osgi.IPackageImport;
import org.apache.felix.sigil.common.model.osgi.IRequiredBundle;
@@ -29,7 +28,6 @@
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerComparator;
-
public class ModelElementComparator extends ViewerComparator
{
private static final int EXPORT_GROUP = 0;
@@ -37,18 +35,17 @@
private static final int REQUIRE_GROUP = 2;
private static final int OTHER_GROUP = 4;
-
- public int category( Object element )
+ public int category(Object element)
{
- if ( element instanceof IPackageImport )
+ if (element instanceof IPackageImport)
{
return IMPORT_GROUP;
}
- else if ( element instanceof IPackageExport )
+ else if (element instanceof IPackageExport)
{
return EXPORT_GROUP;
}
- else if ( element instanceof IRequiredBundle )
+ else if (element instanceof IRequiredBundle)
{
return REQUIRE_GROUP;
}
@@ -58,37 +55,36 @@
}
}
-
@SuppressWarnings("unchecked")
@Override
- public int compare( Viewer viewer, Object e1, Object e2 )
+ public int compare(Viewer viewer, Object e1, Object e2)
{
- int cat1 = category( e1 );
- int cat2 = category( e2 );
+ int cat1 = category(e1);
+ int cat2 = category(e2);
- if ( cat1 != cat2 )
+ if (cat1 != cat2)
{
return cat1 - cat2;
}
- if ( cat1 == OTHER_GROUP )
+ if (cat1 == OTHER_GROUP)
{
String name1;
String name2;
- if ( viewer == null || !( viewer instanceof ContentViewer ) )
+ if (viewer == null || !(viewer instanceof ContentViewer))
{
name1 = e1.toString();
name2 = e2.toString();
}
else
{
- IBaseLabelProvider prov = ( ( ContentViewer ) viewer ).getLabelProvider();
- if ( prov instanceof ILabelProvider )
+ IBaseLabelProvider prov = ((ContentViewer) viewer).getLabelProvider();
+ if (prov instanceof ILabelProvider)
{
- ILabelProvider lprov = ( ILabelProvider ) prov;
- name1 = lprov.getText( e1 );
- name2 = lprov.getText( e2 );
+ ILabelProvider lprov = (ILabelProvider) prov;
+ name1 = lprov.getText(e1);
+ name2 = lprov.getText(e2);
}
else
{
@@ -96,23 +92,23 @@
name2 = e2.toString();
}
}
- if ( name1 == null )
+ if (name1 == null)
{
name1 = "";//$NON-NLS-1$
}
- if ( name2 == null )
+ if (name2 == null)
{
name2 = "";//$NON-NLS-1$
}
// use the comparator to compare the strings
- return getComparator().compare( name1, name2 );
+ return getComparator().compare(name1, name2);
}
else
{
- Comparable c1 = ( Comparable ) e1;
- Comparable c2 = ( Comparable ) e2;
- return c1.compareTo( c2 );
+ Comparable c1 = (Comparable) e1;
+ Comparable c2 = (Comparable) e2;
+ return c1.compareTo(c2);
}
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/RepositoryViewPart.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/RepositoryViewPart.java
index 6b7acc8..9a831c0 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/RepositoryViewPart.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/RepositoryViewPart.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.views;
-
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
@@ -61,7 +60,6 @@
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart;
-
public class RepositoryViewPart extends ViewPart implements IRepositoryChangeListener
{
@@ -73,35 +71,35 @@
return "Find Uses";
}
-
@Override
public void run()
{
ISelection s = treeViewer.getSelection();
- if ( !s.isEmpty() )
+ if (!s.isEmpty())
{
- IStructuredSelection sel = ( IStructuredSelection ) s;
- IModelElement e = ( IModelElement ) sel.getFirstElement();
- List<IModelElement> users = ModelHelper.findUsers( e );
+ IStructuredSelection sel = (IStructuredSelection) s;
+ IModelElement e = (IModelElement) sel.getFirstElement();
+ List<IModelElement> users = ModelHelper.findUsers(e);
String msg = null;
- if ( users.isEmpty() )
+ if (users.isEmpty())
{
msg = "No users of " + e;
}
else
{
StringBuilder b = new StringBuilder();
- for ( IModelElement u : users )
+ for (IModelElement u : users)
{
- ISigilBundle bndl = u.getAncestor( ISigilBundle.class );
- b.append( bndl );
- b.append( "->" );
- b.append( u );
- b.append( "\n" );
+ ISigilBundle bndl = u.getAncestor(ISigilBundle.class);
+ b.append(bndl);
+ b.append("->");
+ b.append(u);
+ b.append("\n");
}
msg = b.toString();
}
- MessageDialog.openInformation( getViewSite().getShell(), "Information", msg );
+ MessageDialog.openInformation(getViewSite().getShell(), "Information",
+ msg);
}
}
}
@@ -111,45 +109,43 @@
final IBundleRepository rep;
final IRepositoryModel model;
-
- public RepositoryAction( IBundleRepository rep )
+ public RepositoryAction(IBundleRepository rep)
{
this.rep = rep;
- this.model = SigilCore.getRepositoryConfiguration().findRepository( rep.getId() );
+ this.model = SigilCore.getRepositoryConfiguration().findRepository(
+ rep.getId());
}
-
@Override
public void run()
{
- treeViewer.setInput( rep );
+ treeViewer.setInput(rep);
createMenu();
}
-
@Override
public String getText()
{
String name = model.getName();
- if ( treeViewer.getInput() == rep )
+ if (treeViewer.getInput() == rep)
{
name = "> " + name;
}
return name;
}
-
@Override
public ImageDescriptor getImageDescriptor()
{
Image img = model.getType().getIcon();
- if ( img == null )
+ if (img == null)
{
- return ImageDescriptor.createFromFile( RepositoryViewPart.class, "/icons/repository.gif" );
+ return ImageDescriptor.createFromFile(RepositoryViewPart.class,
+ "/icons/repository.gif");
}
else
{
- return ImageDescriptor.createFromImage( img );
+ return ImageDescriptor.createFromImage(img);
}
}
}
@@ -162,78 +158,72 @@
treeViewer.collapseAll();
}
-
@Override
public String getText()
{
return "Collapse All";
}
-
@Override
public ImageDescriptor getImageDescriptor()
{
- return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_ELCL_COLLAPSEALL);
+ return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(
+ ISharedImages.IMG_ELCL_COLLAPSEALL);
}
}
-
+
class RefreshAction extends Action
{
@Override
public void run()
{
- IBundleRepository rep = ( IBundleRepository ) treeViewer.getInput();
- if ( rep != null )
+ IBundleRepository rep = (IBundleRepository) treeViewer.getInput();
+ if (rep != null)
{
rep.refresh();
treeViewer.refresh();
}
}
-
@Override
public String getText()
{
return "Refresh";
}
-
@Override
public ImageDescriptor getImageDescriptor()
{
-
- return ImageDescriptor.createFromFile( RepositoryViewPart.class, "/icons/bundle-refresh.gif" );
+
+ return ImageDescriptor.createFromFile(RepositoryViewPart.class,
+ "/icons/bundle-refresh.gif");
}
}
private TreeViewer treeViewer;
-
@Override
- public void createPartControl( Composite parent )
+ public void createPartControl(Composite parent)
{
- createBody( parent );
+ createBody(parent);
createMenu();
- SigilCore.getGlobalRepositoryManager().addRepositoryChangeListener( this );
+ SigilCore.getGlobalRepositoryManager().addRepositoryChangeListener(this);
}
-
@Override
public void dispose()
{
- SigilCore.getGlobalRepositoryManager().removeRepositoryChangeListener( this );
+ SigilCore.getGlobalRepositoryManager().removeRepositoryChangeListener(this);
super.dispose();
}
-
private void createMenu()
{
createTopMenu();
createLocalMenu();
}
-
private void createLocalMenu()
{
/*MenuManager menuMgr = new MenuManager();
@@ -244,183 +234,174 @@
getViewSite().registerContextMenu(menuMgr, treeViewer); */
IActionBars bars = getViewSite().getActionBars();
IToolBarManager toolBar = bars.getToolBarManager();
- toolBar.add( new RefreshAction() );
- toolBar.add( new CollapseAction() );
+ toolBar.add(new RefreshAction());
+ toolBar.add(new CollapseAction());
}
-
private void createTopMenu()
{
IActionBars bars = getViewSite().getActionBars();
IMenuManager menu = bars.getMenuManager();
menu.removeAll();
- for ( final IBundleRepository rep : SigilCore.getGlobalRepositoryManager().getRepositories() )
+ for (final IBundleRepository rep : SigilCore.getGlobalRepositoryManager().getRepositories())
{
- if ( treeViewer.getInput() == null )
+ if (treeViewer.getInput() == null)
{
- treeViewer.setInput( rep );
+ treeViewer.setInput(rep);
}
- RepositoryAction action = new RepositoryAction( rep );
- menu.add( action );
+ RepositoryAction action = new RepositoryAction(rep);
+ menu.add(action);
}
}
-
- private void createBody( Composite parent )
+ private void createBody(Composite parent)
{
// components
- Composite control = new Composite( parent, SWT.NONE );
- Tree tree = new Tree( control, SWT.NONE );
+ Composite control = new Composite(parent, SWT.NONE);
+ Tree tree = new Tree(control, SWT.NONE);
// layout
- control.setLayout( new GridLayout( 1, false ) );
- tree.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true, 1, 1 ) );
+ control.setLayout(new GridLayout(1, false));
+ tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
// viewer
- treeViewer = new TreeViewer( tree );
- treeViewer.setContentProvider( new DefaultTreeContentProvider()
+ treeViewer = new TreeViewer(tree);
+ treeViewer.setContentProvider(new DefaultTreeContentProvider()
{
- public Object[] getChildren( Object parentElement )
+ public Object[] getChildren(Object parentElement)
{
- if ( parentElement instanceof ICompoundModelElement )
+ if (parentElement instanceof ICompoundModelElement)
{
- ICompoundModelElement model = ( ICompoundModelElement ) parentElement;
+ ICompoundModelElement model = (ICompoundModelElement) parentElement;
return model.children();
}
return null;
}
-
- public Object getParent( Object element )
+ public Object getParent(Object element)
{
- if ( element instanceof IModelElement )
+ if (element instanceof IModelElement)
{
- IModelElement model = ( IModelElement ) element;
+ IModelElement model = (IModelElement) element;
return model.getParent();
}
return null;
}
-
- public boolean hasChildren( Object element )
+ public boolean hasChildren(Object element)
{
- if ( element instanceof ICompoundModelElement )
+ if (element instanceof ICompoundModelElement)
{
- ICompoundModelElement model = ( ICompoundModelElement ) element;
+ ICompoundModelElement model = (ICompoundModelElement) element;
return model.children().length > 0;
}
return false;
}
-
- public Object[] getElements( Object inputElement )
+ public Object[] getElements(Object inputElement)
{
- IBundleRepository rep = ( IBundleRepository ) inputElement;
- return getBundles( rep );
+ IBundleRepository rep = (IBundleRepository) inputElement;
+ return getBundles(rep);
}
- } );
+ });
- treeViewer.setComparator( new ModelElementComparator() );
+ treeViewer.setComparator(new ModelElementComparator());
- treeViewer.setLabelProvider( new ModelLabelProvider() );
+ treeViewer.setLabelProvider(new ModelLabelProvider());
- treeViewer.addDragSupport( DND.DROP_LINK, new Transfer[]
- { LocalSelectionTransfer.getTransfer() }, new DragSourceAdapter()
- {
- @Override
- public void dragFinished( DragSourceEvent event )
+ treeViewer.addDragSupport(DND.DROP_LINK,
+ new Transfer[] { LocalSelectionTransfer.getTransfer() },
+ new DragSourceAdapter()
{
- // TODO Auto-generated method stub
- super.dragFinished( event );
- }
-
-
- @Override
- public void dragSetData( DragSourceEvent event )
- {
- // TODO Auto-generated method stub
- super.dragSetData( event );
- }
-
-
- @SuppressWarnings("unchecked")
- @Override
- public void dragStart( DragSourceEvent event )
- {
- if ( treeViewer.getSelection().isEmpty() )
+ @Override
+ public void dragFinished(DragSourceEvent event)
{
- IStructuredSelection sel = ( IStructuredSelection ) treeViewer.getSelection();
- for ( Iterator<IModelElement> i = sel.iterator(); i.hasNext(); )
+ // TODO Auto-generated method stub
+ super.dragFinished(event);
+ }
+
+ @Override
+ public void dragSetData(DragSourceEvent event)
+ {
+ // TODO Auto-generated method stub
+ super.dragSetData(event);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void dragStart(DragSourceEvent event)
+ {
+ if (treeViewer.getSelection().isEmpty())
{
- IModelElement e = i.next();
- if ( e instanceof ISigilBundle )
+ IStructuredSelection sel = (IStructuredSelection) treeViewer.getSelection();
+ for (Iterator<IModelElement> i = sel.iterator(); i.hasNext();)
{
- event.data = e;
- }
- else
- {
- event.doit = false;
+ IModelElement e = i.next();
+ if (e instanceof ISigilBundle)
+ {
+ event.data = e;
+ }
+ else
+ {
+ event.doit = false;
+ }
}
}
+ else
+ {
+ event.doit = false;
+ }
}
- else
- {
- event.doit = false;
- }
- }
- } );
+ });
}
-
@Override
public void setFocus()
{
}
-
- public void repositoryChanged( RepositoryChangeEvent event )
+ public void repositoryChanged(RepositoryChangeEvent event)
{
- switch ( event.getType() )
+ switch (event.getType())
{
case ADDED:
createTopMenu();
break;
case CHANGED:
- if ( event.getRepository() == treeViewer.getInput() )
+ if (event.getRepository() == treeViewer.getInput())
{
- SigilUI.runInUI( new Runnable()
+ SigilUI.runInUI(new Runnable()
{
public void run()
{
treeViewer.refresh();
}
- } );
+ });
}
break;
case REMOVED:
- if ( event.getRepository() == treeViewer.getInput() )
+ if (event.getRepository() == treeViewer.getInput())
{
- treeViewer.setInput( null );
+ treeViewer.setInput(null);
}
createTopMenu();
}
}
-
- private Object[] getBundles( IBundleRepository repository )
+ private Object[] getBundles(IBundleRepository repository)
{
final LinkedList<ISigilBundle> bundles = new LinkedList<ISigilBundle>();
- repository.accept( new IRepositoryVisitor()
+ repository.accept(new IRepositoryVisitor()
{
- public boolean visit( ISigilBundle bundle )
+ public boolean visit(ISigilBundle bundle)
{
- bundles.add( bundle );
+ bundles.add(bundle);
return true;
}
- } );
+ });
return bundles.toArray();
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleConnectionHighlighter.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleConnectionHighlighter.java
index 07157b2..0f32001 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleConnectionHighlighter.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleConnectionHighlighter.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.views.resolution;
-
import java.util.Set;
import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
@@ -32,45 +31,42 @@
import org.eclipse.zest.core.widgets.GraphItem;
import org.eclipse.zest.core.widgets.GraphNode;
-
public class BundleConnectionHighlighter implements ISelectionChangedListener
{
private BundleResolverView view;
-
- public BundleConnectionHighlighter( BundleResolverView view )
+ public BundleConnectionHighlighter(BundleResolverView view)
{
this.view = view;
}
-
- public void selectionChanged( SelectionChangedEvent event )
+ public void selectionChanged(SelectionChangedEvent event)
{
ISelection selection = event.getSelection();
- if ( !selection.isEmpty() )
+ if (!selection.isEmpty())
{
- IStructuredSelection str = ( IStructuredSelection ) selection;
+ IStructuredSelection str = (IStructuredSelection) selection;
Object sel = str.getFirstElement();
- if ( sel instanceof ISigilBundle )
+ if (sel instanceof ISigilBundle)
{
- BundleGraph graph = ( BundleGraph ) view.getBundlegraph();
+ BundleGraph graph = (BundleGraph) view.getBundlegraph();
- ISigilBundle selected = ( ISigilBundle ) sel;
- Set<ISigilBundle> connected = graph.getTargets( selected );
+ ISigilBundle selected = (ISigilBundle) sel;
+ Set<ISigilBundle> connected = graph.getTargets(selected);
- highlightLinks( graph, selected, connected );
- highlightBundles( graph, selected, connected );
+ highlightLinks(graph, selected, connected);
+ highlightBundles(graph, selected, connected);
}
- else if ( sel instanceof Link )
+ else if (sel instanceof Link)
{
- GraphConnection c = ( GraphConnection ) findGraphItem( sel );
- if ( c != null )
+ GraphConnection c = (GraphConnection) findGraphItem(sel);
+ if (c != null)
{
c.unhighlight();
- c.setHighlightColor( ColorConstants.blue );
+ c.setHighlightColor(ColorConstants.blue);
c.highlight();
}
}
@@ -81,26 +77,26 @@
}
}
-
- private void highlightBundles( BundleGraph graph, ISigilBundle selected, Set<ISigilBundle> connected )
+ private void highlightBundles(BundleGraph graph, ISigilBundle selected,
+ Set<ISigilBundle> connected)
{
- for ( ISigilBundle bundle : graph.getBundles() )
+ for (ISigilBundle bundle : graph.getBundles())
{
- GraphNode node = ( GraphNode ) findGraphItem( bundle );
- if ( node != null )
+ GraphNode node = (GraphNode) findGraphItem(bundle);
+ if (node != null)
{
node.unhighlight();
- if ( bundle == selected )
+ if (bundle == selected)
{
- node.setHighlightColor( ColorConstants.yellow );
+ node.setHighlightColor(ColorConstants.yellow);
node.highlight();
}
- else if ( view.isDisplayed( BundleResolverView.DEPENDENTS ) )
+ else if (view.isDisplayed(BundleResolverView.DEPENDENTS))
{
- if ( connected.contains( bundle ) )
+ if (connected.contains(bundle))
{
- node.setHighlightColor( ColorConstants.lightBlue );
+ node.setHighlightColor(ColorConstants.lightBlue);
node.highlight();
}
}
@@ -108,21 +104,21 @@
}
}
-
- private void highlightLinks( BundleGraph graph, ISigilBundle selected, Set<ISigilBundle> connected )
+ private void highlightLinks(BundleGraph graph, ISigilBundle selected,
+ Set<ISigilBundle> connected)
{
- for ( Link l : graph.getLinks() )
+ for (Link l : graph.getLinks())
{
- GraphConnection c = ( GraphConnection ) findGraphItem( l );
- if ( c != null )
+ GraphConnection c = (GraphConnection) findGraphItem(l);
+ if (c != null)
{
c.unhighlight();
- if ( view.isDisplayed( BundleResolverView.DEPENDENTS ) )
+ if (view.isDisplayed(BundleResolverView.DEPENDENTS))
{
- if ( l.getSource() == selected && connected.contains( l.getTarget() ) )
+ if (l.getSource() == selected && connected.contains(l.getTarget()))
{
- c.setHighlightColor( ColorConstants.lightBlue );
+ c.setHighlightColor(ColorConstants.lightBlue);
c.highlight();
}
}
@@ -130,14 +126,13 @@
}
}
-
- private GraphItem findGraphItem( Object l )
+ private GraphItem findGraphItem(Object l)
{
try
{
- return view.getGraphViewer().findGraphItem( l );
+ return view.getGraphViewer().findGraphItem(l);
}
- catch ( ArrayIndexOutOfBoundsException e )
+ catch (ArrayIndexOutOfBoundsException e)
{
// temporary fix for issue
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=242523
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraph.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraph.java
index ae28f96..fc8562d 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraph.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraph.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.views.resolution;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -31,7 +30,6 @@
import org.apache.felix.sigil.common.model.IModelElement;
import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
-
public class BundleGraph
{
@@ -39,89 +37,82 @@
private LinkedList<Link> links = new LinkedList<Link>();
private HashSet<ISigilBundle> bundles = new HashSet<ISigilBundle>();
-
- public void startResolution( IModelElement requirement )
+ public void startResolution(IModelElement requirement)
{
}
-
- public void endResolution( IModelElement requirement, ISigilBundle target )
+ public void endResolution(IModelElement requirement, ISigilBundle target)
{
- ISigilBundle source = requirement.getAncestor( ISigilBundle.class );
+ ISigilBundle source = requirement.getAncestor(ISigilBundle.class);
- bundles.add( source );
- bundles.add( target );
+ bundles.add(source);
+ bundles.add(target);
- LinkedList<Link> links = lookup.get( source );
+ LinkedList<Link> links = lookup.get(source);
- if ( links == null )
+ if (links == null)
{
links = new LinkedList<Link>();
- lookup.put( source, links );
+ lookup.put(source, links);
}
Link l = null;
- for ( Link c : links )
+ for (Link c : links)
{
- if ( c.getTarget() == target )
+ if (c.getTarget() == target)
{
l = c;
break;
}
}
- if ( l == null )
+ if (l == null)
{
- l = new Link( source, target );
- links.add( l );
- this.links.add( l );
+ l = new Link(source, target);
+ links.add(l);
+ this.links.add(l);
}
- l.addRequirement( requirement );
+ l.addRequirement(requirement);
}
-
public List<Link> getLinks()
{
return links;
}
-
public Set<ISigilBundle> getBundles()
{
return bundles;
}
-
- public Set<ISigilBundle> getTargets( ISigilBundle bundle )
+ public Set<ISigilBundle> getTargets(ISigilBundle bundle)
{
HashSet<ISigilBundle> targets = new HashSet<ISigilBundle>();
- for ( Link l : getLinks( bundle ) )
+ for (Link l : getLinks(bundle))
{
- targets.add( l.getTarget() );
+ targets.add(l.getTarget());
}
return targets;
}
-
- public List<Link> getLinks( ISigilBundle selected )
+ public List<Link> getLinks(ISigilBundle selected)
{
- List<Link> l = lookup.get( selected );
+ List<Link> l = lookup.get(selected);
return l == null ? Collections.<Link> emptyList() : l;
}
-
- public List<Link> getDependentLinks( ISigilBundle bundle )
+ public List<Link> getDependentLinks(ISigilBundle bundle)
{
- ArrayList<Link> found = new ArrayList<Link>( links.size() );
+ ArrayList<Link> found = new ArrayList<Link>(links.size());
- for ( Link l : links )
+ for (Link l : links)
{
- if ( l.getTarget() == bundle )
+ if (l.getTarget() == bundle)
{
- found.add( l );
+ found.add(l);
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraphContentProvider.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraphContentProvider.java
index d0f9fff..345dcfd 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraphContentProvider.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraphContentProvider.java
@@ -19,43 +19,37 @@
package org.apache.felix.sigil.eclipse.ui.internal.views.resolution;
-
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.zest.core.viewers.IGraphContentProvider;
-
public class BundleGraphContentProvider implements IGraphContentProvider
{
- public Object[] getElements( Object input )
+ public Object[] getElements(Object input)
{
- BundleGraph graph = ( BundleGraph ) input;
+ BundleGraph graph = (BundleGraph) input;
return graph.getLinks().toArray();
}
-
- public Object getDestination( Object element )
+ public Object getDestination(Object element)
{
- Link l = ( Link ) element;
+ Link l = (Link) element;
return l.isSatisfied() ? l.getTarget() : new Link.Unsatisfied();
}
-
- public Object getSource( Object element )
+ public Object getSource(Object element)
{
- Link l = ( Link ) element;
+ Link l = (Link) element;
return l.getSource();
}
-
public void dispose()
{
// TODO Auto-generated method stub
}
-
- public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
{
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraphLabelProvider.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraphLabelProvider.java
index b93cf33..2e090bf 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraphLabelProvider.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraphLabelProvider.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.views.resolution;
-
import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
import org.apache.felix.sigil.eclipse.ui.SigilUI;
import org.eclipse.jface.viewers.LabelProvider;
@@ -27,30 +26,27 @@
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
-
public class BundleGraphLabelProvider extends LabelProvider
{
private BundleResolverView view;
-
- public BundleGraphLabelProvider( BundleResolverView view )
+ public BundleGraphLabelProvider(BundleResolverView view)
{
this.view = view;
}
-
@Override
- public String getText( Object element )
+ public String getText(Object element)
{
- if ( element instanceof Link )
+ if (element instanceof Link)
{
- Link l = ( Link ) element;
- if ( l.isSatisfied() )
+ Link l = (Link) element;
+ if (l.isSatisfied())
{
- if ( view.isDisplayed( BundleResolverView.LINK_LABELS ) )
+ if (view.isDisplayed(BundleResolverView.LINK_LABELS))
{
- return view.getLinkText( ( Link ) element );
+ return view.getLinkText((Link) element);
}
else
{
@@ -59,15 +55,16 @@
}
else
{
- return view.getLinkText( ( Link ) element );
+ return view.getLinkText((Link) element);
}
}
- else if ( element instanceof ISigilBundle )
+ else if (element instanceof ISigilBundle)
{
- ISigilBundle b = ( ISigilBundle ) element;
- return b.getBundleInfo().getSymbolicName() + ": " + b.getBundleInfo().getVersion();
+ ISigilBundle b = (ISigilBundle) element;
+ return b.getBundleInfo().getSymbolicName() + ": "
+ + b.getBundleInfo().getVersion();
}
- else if ( element instanceof Link.Unsatisfied )
+ else if (element instanceof Link.Unsatisfied)
{
return "unsatisfied";
}
@@ -77,18 +74,19 @@
}
}
-
@Override
- public Image getImage( Object element )
+ public Image getImage(Object element)
{
Image result = null;
- if ( element instanceof ISigilBundle )
+ if (element instanceof ISigilBundle)
{
- result = SigilUI.cacheImage( "icons/bundle.gif", BundleGraphLabelProvider.class.getClassLoader() );
+ result = SigilUI.cacheImage("icons/bundle.gif",
+ BundleGraphLabelProvider.class.getClassLoader());
}
- else if ( element instanceof Link.Unsatisfied )
+ else if (element instanceof Link.Unsatisfied)
{
- return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
+ return PlatformUI.getWorkbench().getSharedImages().getImage(
+ ISharedImages.IMG_OBJS_ERROR_TSK);
}
return result;
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraphViewFilter.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraphViewFilter.java
index 9396e4a..353c5bb 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraphViewFilter.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleGraphViewFilter.java
@@ -19,48 +19,44 @@
package org.apache.felix.sigil.eclipse.ui.internal.views.resolution;
-
import org.apache.felix.sigil.common.model.eclipse.ISigilBundle;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
-
public class BundleGraphViewFilter extends ViewerFilter
{
private BundleResolverView view;
-
- public BundleGraphViewFilter( BundleResolverView view )
+ public BundleGraphViewFilter(BundleResolverView view)
{
this.view = view;
}
-
@Override
- public boolean select( Viewer viewer, Object parentElement, Object element )
+ public boolean select(Viewer viewer, Object parentElement, Object element)
{
- if ( !view.isDisplayed( BundleResolverView.LOCAL_LINKS ) )
+ if (!view.isDisplayed(BundleResolverView.LOCAL_LINKS))
{
- if ( element instanceof Link )
+ if (element instanceof Link)
{
- Link l = ( Link ) element;
+ Link l = (Link) element;
return l.getSource() != l.getTarget();
}
}
- if ( !view.isDisplayed( BundleResolverView.SATISFIED ) )
+ if (!view.isDisplayed(BundleResolverView.SATISFIED))
{
- if ( element instanceof Link )
+ if (element instanceof Link)
{
- Link l = ( Link ) element;
+ Link l = (Link) element;
return !l.isSatisfied();
}
- else if ( element instanceof ISigilBundle )
+ else if (element instanceof ISigilBundle)
{
- ISigilBundle bundle = ( ISigilBundle ) element;
- for ( Link l : view.getBundlegraph().getLinks( bundle ) )
+ ISigilBundle bundle = (ISigilBundle) element;
+ for (Link l : view.getBundlegraph().getLinks(bundle))
{
- if ( !l.isSatisfied() )
+ if (!l.isSatisfied())
{
return true;
}
@@ -69,14 +65,14 @@
}
}
- if ( !view.isDisplayed( BundleResolverView.UNSATISFIED ) )
+ if (!view.isDisplayed(BundleResolverView.UNSATISFIED))
{
- if ( element instanceof Link )
+ if (element instanceof Link)
{
- Link l = ( Link ) element;
+ Link l = (Link) element;
return l.isSatisfied();
}
- else if ( element instanceof Link.Unsatisfied )
+ else if (element instanceof Link.Unsatisfied)
{
return false;
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleResolverView.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleResolverView.java
index 2da1a51..8cf101a 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleResolverView.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/BundleResolverView.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.views.resolution;
-
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -60,7 +59,6 @@
import org.eclipse.zest.layouts.algorithms.RadialLayoutAlgorithm;
import org.eclipse.zest.layouts.algorithms.TreeLayoutAlgorithm;
-
public class BundleResolverView extends ViewPart
{
@@ -98,149 +96,140 @@
private String showMsg;
private String hideMsg;
-
- ToggleDisplayAction( String key, String showMsg, String hideMsg )
+ ToggleDisplayAction(String key, String showMsg, String hideMsg)
{
this.key = key;
this.showMsg = showMsg;
this.hideMsg = hideMsg;
- setText( BundleResolverView.this.isDisplayed( key ) ? hideMsg : showMsg );
+ setText(BundleResolverView.this.isDisplayed(key) ? hideMsg : showMsg);
}
-
@Override
public void run()
{
- BundleResolverView.this.setDisplayed( key, !BundleResolverView.this.isDisplayed( key ) );
- setText( BundleResolverView.this.isDisplayed( key ) ? hideMsg : showMsg );
+ BundleResolverView.this.setDisplayed(key,
+ !BundleResolverView.this.isDisplayed(key));
+ setText(BundleResolverView.this.isDisplayed(key) ? hideMsg : showMsg);
}
}
-
- public void setInput( final IModelElement element )
+ public void setInput(final IModelElement element)
{
- if ( current == null || !current.equals( element ) )
+ if (current == null || !current.equals(element))
{
- SigilCore.log( "Set input " + element );
+ SigilCore.log("Set input " + element);
current = element;
redraw();
}
}
-
- public void setDisplayed( String key, boolean b )
+ public void setDisplayed(String key, boolean b)
{
- displayed.put( key, b );
+ displayed.put(key, b);
- if ( key == DEPENDENTS )
+ if (key == DEPENDENTS)
{
int style = LayoutStyles.NO_LAYOUT_NODE_RESIZING;
- viewer.setLayoutAlgorithm( b ? new TreeLayoutAlgorithm( style ) : new RadialLayoutAlgorithm( style ) );
+ viewer.setLayoutAlgorithm(b ? new TreeLayoutAlgorithm(style)
+ : new RadialLayoutAlgorithm(style));
redraw();
}
- else if ( key == OPTIONAL )
+ else if (key == OPTIONAL)
{
redraw();
}
- else if ( key == SATISFIED || key == UNSATISFIED )
+ else if (key == SATISFIED || key == UNSATISFIED)
{
viewer.refresh();
}
}
-
- public boolean isDisplayed( String key )
+ public boolean isDisplayed(String key)
{
- return displayed.get( key );
+ return displayed.get(key);
}
-
@Override
public void setFocus()
{
}
-
@Override
- public void createPartControl( Composite parent )
+ public void createPartControl(Composite parent)
{
init();
- createViewer( parent );
+ createViewer(parent);
createListeners();
createMenu();
}
-
private void init()
{
- displayed.put( LINK_LABELS, false );
- displayed.put( LOCAL_LINKS, false );
- displayed.put( DEPENDENTS, false );
- displayed.put( OPTIONAL, false );
- displayed.put( SATISFIED, true );
- displayed.put( UNSATISFIED, true );
+ displayed.put(LINK_LABELS, false);
+ displayed.put(LOCAL_LINKS, false);
+ displayed.put(DEPENDENTS, false);
+ displayed.put(OPTIONAL, false);
+ displayed.put(SATISFIED, true);
+ displayed.put(UNSATISFIED, true);
}
-
public BundleGraph getBundlegraph()
{
- return ( BundleGraph ) viewer.getInput();
+ return (BundleGraph) viewer.getInput();
}
-
GraphViewer getGraphViewer()
{
return viewer;
}
-
- String getLinkText( Link link )
+ String getLinkText(Link link)
{
StringBuffer buf = new StringBuffer();
- for ( IModelElement e : link.getRequirements() )
+ for (IModelElement e : link.getRequirements())
{
- if ( buf.length() > 0 )
+ if (buf.length() > 0)
{
- buf.append( "\n" );
+ buf.append("\n");
}
- if ( e instanceof IPackageImport )
+ if (e instanceof IPackageImport)
{
- IPackageImport pi = ( IPackageImport ) e;
- buf.append( "import " + pi.getPackageName() + " : " + pi.getVersions() + ": "
- + ( pi.isOptional() ? "optional" : "mandatory" ) );
+ IPackageImport pi = (IPackageImport) e;
+ buf.append("import " + pi.getPackageName() + " : " + pi.getVersions()
+ + ": " + (pi.isOptional() ? "optional" : "mandatory"));
}
- else if ( e instanceof IRequiredBundle )
+ else if (e instanceof IRequiredBundle)
{
- IRequiredBundle rb = ( IRequiredBundle ) e;
- buf.append( "required bundle " + rb.getSymbolicName() + " : " + rb.getVersions() + ": "
- + ( rb.isOptional() ? "optional" : "mandatory" ) );
+ IRequiredBundle rb = (IRequiredBundle) e;
+ buf.append("required bundle " + rb.getSymbolicName() + " : "
+ + rb.getVersions() + ": "
+ + (rb.isOptional() ? "optional" : "mandatory"));
}
}
return buf.toString();
}
-
private synchronized void redraw()
{
final IModelElement element = current;
- if ( job != null )
+ if (job != null)
{
job.cancel();
}
- job = new Job( "Resolving " + current )
+ job = new Job("Resolving " + current)
{
@Override
- protected IStatus run( IProgressMonitor progress )
+ protected IStatus run(IProgressMonitor progress)
{
try
{
- resolve( element, progress );
+ resolve(element, progress);
return Status.OK_STATUS;
}
- catch ( CoreException e )
+ catch (CoreException e)
{
return e.getStatus();
}
@@ -249,151 +238,150 @@
job.schedule();
}
-
- private void resolve( IModelElement element, IProgressMonitor progress ) throws CoreException
+ private void resolve(IModelElement element, IProgressMonitor progress)
+ throws CoreException
{
final BundleGraph graph = new BundleGraph();
- IResolutionMonitor monitor = new ResolutionMonitorAdapter( progress )
+ IResolutionMonitor monitor = new ResolutionMonitorAdapter(progress)
{
@Override
- public void startResolution( IModelElement requirement )
+ public void startResolution(IModelElement requirement)
{
- graph.startResolution( requirement );
+ graph.startResolution(requirement);
}
-
@Override
- public void endResolution( IModelElement requirement, ISigilBundle provider )
+ public void endResolution(IModelElement requirement, ISigilBundle provider)
{
- graph.endResolution( requirement, provider );
+ graph.endResolution(requirement, provider);
}
};
- ISigilProjectModel project = findProject( element );
- IRepositoryManager repository = SigilCore.getRepositoryManager( project );
+ ISigilProjectModel project = findProject(element);
+ IRepositoryManager repository = SigilCore.getRepositoryManager(project);
int options = ResolutionConfig.IGNORE_ERRORS;
- if ( isDisplayed( DEPENDENTS ) )
+ if (isDisplayed(DEPENDENTS))
{
options |= ResolutionConfig.INCLUDE_DEPENDENTS;
}
- if ( isDisplayed( OPTIONAL ) )
+ if (isDisplayed(OPTIONAL))
{
options |= ResolutionConfig.INCLUDE_OPTIONAL;
}
- ResolutionConfig config = new ResolutionConfig( options );
+ ResolutionConfig config = new ResolutionConfig(options);
try
{
- repository.getBundleResolver().resolve( element, config, monitor );
+ repository.getBundleResolver().resolve(element, config, monitor);
}
- catch ( ResolutionException e )
+ catch (ResolutionException e)
{
- throw SigilCore.newCoreException( "Failed to resolve " + element, e );
+ throw SigilCore.newCoreException("Failed to resolve " + element, e);
}
- SigilUI.runInUI( new Runnable()
+ SigilUI.runInUI(new Runnable()
{
public void run()
{
- viewer.setInput( graph );
+ viewer.setInput(graph);
addCustomUIElements();
}
- } );
+ });
}
-
- private static ISigilProjectModel findProject( IModelElement element )
+ private static ISigilProjectModel findProject(IModelElement element)
{
- if ( element == null )
+ if (element == null)
{
return null;
}
- if ( element instanceof ISigilProjectModel )
+ if (element instanceof ISigilProjectModel)
{
- return ( ISigilProjectModel ) element;
+ return (ISigilProjectModel) element;
}
- return element.getAncestor( ISigilProjectModel.class );
+ return element.getAncestor(ISigilProjectModel.class);
}
-
@SuppressWarnings("unchecked")
private void addCustomUIElements()
{
- if ( !isDisplayed( LINK_LABELS ) )
+ if (!isDisplayed(LINK_LABELS))
{
- for ( GraphConnection c : ( List<GraphConnection> ) viewer.getGraphControl().getConnections() )
+ for (GraphConnection c : (List<GraphConnection>) viewer.getGraphControl().getConnections())
{
- if ( c.getData() instanceof Link )
+ if (c.getData() instanceof Link)
{
- c.setTooltip( buildToolTip( ( Link ) c.getData() ) );
+ c.setTooltip(buildToolTip((Link) c.getData()));
}
}
}
}
-
- private IFigure buildToolTip( Link link )
+ private IFigure buildToolTip(Link link)
{
Label l = new Label();
- l.setText( getLinkText( link ) );
+ l.setText(getLinkText(link));
return l;
}
-
- private void createViewer( Composite parent )
+ private void createViewer(Composite parent)
{
- parent.setLayout( new FillLayout() );
- viewer = new GraphViewer( parent, SWT.H_SCROLL | SWT.V_SCROLL );
+ parent.setLayout(new FillLayout());
+ viewer = new GraphViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL);
IContentProvider contentProvider = new BundleGraphContentProvider();
- viewer.setContentProvider( contentProvider );
- viewer.setLabelProvider( new BundleGraphLabelProvider( this ) );
- viewer.addFilter( new BundleGraphViewFilter( this ) );
+ viewer.setContentProvider(contentProvider);
+ viewer.setLabelProvider(new BundleGraphLabelProvider(this));
+ viewer.addFilter(new BundleGraphViewFilter(this));
int style = LayoutStyles.NO_LAYOUT_NODE_RESIZING;
- viewer.setLayoutAlgorithm( isDisplayed( DEPENDENTS ) ? new TreeLayoutAlgorithm( style )
- : new RadialLayoutAlgorithm( style ) );
- viewer.addSelectionChangedListener( new BundleConnectionHighlighter( this ) );
- viewer.setInput( new BundleGraph() );
+ viewer.setLayoutAlgorithm(isDisplayed(DEPENDENTS) ? new TreeLayoutAlgorithm(style)
+ : new RadialLayoutAlgorithm(style));
+ viewer.addSelectionChangedListener(new BundleConnectionHighlighter(this));
+ viewer.setInput(new BundleGraph());
}
-
private void createMenu()
{
IActionBars action = getViewSite().getActionBars();
- action.getMenuManager().add( new ToggleDisplayAction( LINK_LABELS, SHOW_LINK_LABELS, HIDE_LINK_LABELS ) );
- action.getMenuManager().add( new ToggleDisplayAction( LOCAL_LINKS, SHOW_LOCAL_LINKS, HIDE_LOCAL_LINKS ) );
- action.getMenuManager().add( new ToggleDisplayAction( DEPENDENTS, SHOW_DEPENDENTS, HIDE_DEPENDENTS ) );
- action.getMenuManager().add( new ToggleDisplayAction( OPTIONAL, SHOW_OPTIONAL, HIDE_OPTIONAL ) );
- action.getMenuManager().add( new ToggleDisplayAction( SATISFIED, SHOW_SATISFIED, HIDE_SATISFIED ) );
- action.getMenuManager().add( new ToggleDisplayAction( UNSATISFIED, SHOW_UNSATISFIED, HIDE_UNSATISFIED ) );
+ action.getMenuManager().add(
+ new ToggleDisplayAction(LINK_LABELS, SHOW_LINK_LABELS, HIDE_LINK_LABELS));
+ action.getMenuManager().add(
+ new ToggleDisplayAction(LOCAL_LINKS, SHOW_LOCAL_LINKS, HIDE_LOCAL_LINKS));
+ action.getMenuManager().add(
+ new ToggleDisplayAction(DEPENDENTS, SHOW_DEPENDENTS, HIDE_DEPENDENTS));
+ action.getMenuManager().add(
+ new ToggleDisplayAction(OPTIONAL, SHOW_OPTIONAL, HIDE_OPTIONAL));
+ action.getMenuManager().add(
+ new ToggleDisplayAction(SATISFIED, SHOW_SATISFIED, HIDE_SATISFIED));
+ action.getMenuManager().add(
+ new ToggleDisplayAction(UNSATISFIED, SHOW_UNSATISFIED, HIDE_UNSATISFIED));
action.updateActionBars();
}
-
private void createListeners()
{
- IPartService ps = ( IPartService ) getViewSite().getService( IPartService.class );
- ps.addPartListener( new EditorViewPartListener( this ) );
- viewer.getGraphControl().addControlListener( new ControlAdapter()
+ IPartService ps = (IPartService) getViewSite().getService(IPartService.class);
+ ps.addPartListener(new EditorViewPartListener(this));
+ viewer.getGraphControl().addControlListener(new ControlAdapter()
{
@Override
- public void controlResized( ControlEvent e )
+ public void controlResized(ControlEvent e)
{
- Graph g = ( Graph ) e.getSource();
+ Graph g = (Graph) e.getSource();
int x = g.getSize().x;
int y = g.getSize().y;
- if ( lastX != x || lastY != y )
+ if (lastX != x || lastY != y)
{
lastX = x;
lastY = y;
redraw();
}
}
- } );
+ });
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/EditorViewPartListener.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/EditorViewPartListener.java
index 3480193..32fc147 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/EditorViewPartListener.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/EditorViewPartListener.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.views.resolution;
-
import org.apache.felix.sigil.eclipse.SigilCore;
import org.apache.felix.sigil.eclipse.model.project.ISigilProjectModel;
import org.eclipse.core.resources.IProject;
@@ -30,86 +29,75 @@
import org.eclipse.ui.IPartListener2;
import org.eclipse.ui.IWorkbenchPartReference;
-
public class EditorViewPartListener implements IPartListener2
{
private BundleResolverView bundleResolverView;
-
- public EditorViewPartListener( BundleResolverView bundleResolverView )
+ public EditorViewPartListener(BundleResolverView bundleResolverView)
{
this.bundleResolverView = bundleResolverView;
}
-
- public void partActivated( IWorkbenchPartReference partRef )
+ public void partActivated(IWorkbenchPartReference partRef)
{
- checkRef( partRef );
+ checkRef(partRef);
}
-
- public void partBroughtToTop( IWorkbenchPartReference partRef )
+ public void partBroughtToTop(IWorkbenchPartReference partRef)
{
// no action
}
-
- public void partClosed( IWorkbenchPartReference partRef )
+ public void partClosed(IWorkbenchPartReference partRef)
{
// no action
}
-
- public void partDeactivated( IWorkbenchPartReference partRef )
+ public void partDeactivated(IWorkbenchPartReference partRef)
{
// no action
}
-
- public void partHidden( IWorkbenchPartReference partRef )
+ public void partHidden(IWorkbenchPartReference partRef)
{
// no action
}
-
- public void partInputChanged( IWorkbenchPartReference partRef )
+ public void partInputChanged(IWorkbenchPartReference partRef)
{
// no action
}
-
- public void partOpened( IWorkbenchPartReference partRef )
+ public void partOpened(IWorkbenchPartReference partRef)
{
// no action
}
-
- public void partVisible( IWorkbenchPartReference partRef )
+ public void partVisible(IWorkbenchPartReference partRef)
{
// no action
}
-
- private void checkRef( IWorkbenchPartReference partRef )
+ private void checkRef(IWorkbenchPartReference partRef)
{
IEditorPart editor = partRef.getPage().getActiveEditor();
- if ( editor != null )
+ if (editor != null)
{
IEditorInput input = editor.getEditorInput();
- if ( input instanceof IFileEditorInput )
+ if (input instanceof IFileEditorInput)
{
- IFileEditorInput f = ( IFileEditorInput ) input;
+ IFileEditorInput f = (IFileEditorInput) input;
IProject project = f.getFile().getProject();
try
{
- ISigilProjectModel model = SigilCore.create( project );
- if ( model != null )
+ ISigilProjectModel model = SigilCore.create(project);
+ if (model != null)
{
- bundleResolverView.setInput( model );
+ bundleResolverView.setInput(model);
}
}
- catch ( CoreException e )
+ catch (CoreException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/Link.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/Link.java
index b0c21fc..fe77cc4 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/Link.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/views/resolution/Link.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.views.resolution;
-
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
@@ -30,7 +29,6 @@
import org.apache.felix.sigil.common.model.osgi.IPackageImport;
import org.apache.felix.sigil.common.model.osgi.IRequiredBundle;
-
public class Link
{
public static class Unsatisfied
@@ -45,13 +43,13 @@
private static final Comparator<IModelElement> comparator = new Comparator<IModelElement>()
{
- public int compare( IModelElement o1, IModelElement o2 )
+ public int compare(IModelElement o1, IModelElement o2)
{
- if ( o1 instanceof IRequiredBundle )
+ if (o1 instanceof IRequiredBundle)
{
- if ( o2 instanceof IRequiredBundle )
+ if (o2 instanceof IRequiredBundle)
{
- return compareBundles( ( IRequiredBundle ) o1, ( IRequiredBundle ) o2 );
+ return compareBundles((IRequiredBundle) o1, (IRequiredBundle) o2);
}
else
{
@@ -60,25 +58,24 @@
}
else
{
- if ( o2 instanceof IRequiredBundle )
+ if (o2 instanceof IRequiredBundle)
{
return 1;
}
else
{
- return compareNonBundles( o1, o2 );
+ return compareNonBundles(o1, o2);
}
}
}
-
- private int compareNonBundles( IModelElement o1, IModelElement o2 )
+ private int compareNonBundles(IModelElement o1, IModelElement o2)
{
- if ( o1 instanceof IPackageImport )
+ if (o1 instanceof IPackageImport)
{
- if ( o2 instanceof IPackageImport )
+ if (o2 instanceof IPackageImport)
{
- return compareImports( ( IPackageImport ) o1, ( IPackageImport ) o2 );
+ return compareImports((IPackageImport) o1, (IPackageImport) o2);
}
else
{
@@ -87,7 +84,7 @@
}
else
{
- if ( o2 instanceof IPackageImport )
+ if (o2 instanceof IPackageImport)
{
return 1;
}
@@ -98,81 +95,71 @@
}
}
-
- private int compareImports( IPackageImport o1, IPackageImport o2 )
+ private int compareImports(IPackageImport o1, IPackageImport o2)
{
- return o1.getPackageName().compareTo( o2.getPackageName() );
+ return o1.getPackageName().compareTo(o2.getPackageName());
}
-
- private int compareBundles( IRequiredBundle o1, IRequiredBundle o2 )
+ private int compareBundles(IRequiredBundle o1, IRequiredBundle o2)
{
- return o1.getSymbolicName().compareTo( o2.getSymbolicName() );
+ return o1.getSymbolicName().compareTo(o2.getSymbolicName());
}
};
-
- public Link( ISigilBundle source, ISigilBundle target )
+ public Link(ISigilBundle source, ISigilBundle target)
{
this.source = source;
this.target = target;
}
-
public ISigilBundle getSource()
{
return source;
}
-
public ISigilBundle getTarget()
{
return target;
}
-
public boolean isSatisfied()
{
return target != null;
}
-
- public void addRequirement( IModelElement requirement )
+ public void addRequirement(IModelElement requirement)
{
- requirements.add( requirement );
- Collections.sort( requirements, comparator );
+ requirements.add(requirement);
+ Collections.sort(requirements, comparator);
}
-
public String toString()
{
return "Link[" + source + "->" + target + "]";
}
-
public List<IModelElement> getRequirements()
{
return requirements;
}
-
public boolean isOptional()
{
- for ( IModelElement e : requirements )
+ for (IModelElement e : requirements)
{
- if ( e instanceof IPackageImport )
+ if (e instanceof IPackageImport)
{
- IPackageImport pi = ( IPackageImport ) e;
- if ( !pi.isOptional() )
+ IPackageImport pi = (IPackageImport) e;
+ if (!pi.isOptional())
{
return false;
}
}
- else if ( e instanceof IRequiredBundle )
+ else if (e instanceof IRequiredBundle)
{
- IRequiredBundle rb = ( IRequiredBundle ) e;
- if ( !rb.isOptional() )
+ IRequiredBundle rb = (IRequiredBundle) e;
+ if (!rb.isOptional())
{
return false;
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/wizard/SigilNewResourceWizard.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/wizard/SigilNewResourceWizard.java
index 16a5353..128a803 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/wizard/SigilNewResourceWizard.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/wizard/SigilNewResourceWizard.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.wizard;
-
import org.eclipse.core.resources.IFile;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Display;
@@ -30,7 +29,6 @@
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
-
/**
* @author dave
*
@@ -38,27 +36,27 @@
public abstract class SigilNewResourceWizard extends BasicNewResourceWizard implements INewWizard
{
- protected void selectRevealAndShow( IFile file )
+ protected void selectRevealAndShow(IFile file)
{
- selectAndReveal( file );
+ selectAndReveal(file);
// Open editor on new file.
IWorkbenchWindow dw = getWorkbench().getActiveWorkbenchWindow();
try
{
- if ( dw != null )
+ if (dw != null)
{
IWorkbenchPage page = dw.getActivePage();
- if ( page != null )
+ if (page != null)
{
- IDE.openEditor( page, file, true );
+ IDE.openEditor(page, file, true);
}
}
}
- catch ( PartInitException e )
+ catch (PartInitException e)
{
- MessageDialog.openError( Display.getCurrent().getActiveShell(), "Initialisation error", "Failed to open "
- + file );
+ MessageDialog.openError(Display.getCurrent().getActiveShell(),
+ "Initialisation error", "Failed to open " + file);
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/wizard/WorkspaceContentProvider.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/wizard/WorkspaceContentProvider.java
index 6ae5dc4..d60c7a8 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/wizard/WorkspaceContentProvider.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/internal/wizard/WorkspaceContentProvider.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.internal.wizard;
-
import java.util.ArrayList;
import java.util.List;
@@ -32,78 +31,75 @@
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
-
public class WorkspaceContentProvider implements ITreeContentProvider
{
private final boolean includeNonSigil;
private final boolean includeClosed;
-
- public WorkspaceContentProvider( boolean includeNonSigil, boolean includeClosed )
+ public WorkspaceContentProvider(boolean includeNonSigil, boolean includeClosed)
{
this.includeNonSigil = includeNonSigil;
this.includeClosed = includeClosed;
}
-
- public Object[] getChildren( Object parentElement )
+ public Object[] getChildren(Object parentElement)
{
Object[] result = null;
- if ( parentElement instanceof IWorkspace )
+ if (parentElement instanceof IWorkspace)
{
- IProject[] projects = ( ( IWorkspace ) parentElement ).getRoot().getProjects();
- if ( includeNonSigil && includeClosed )
+ IProject[] projects = ((IWorkspace) parentElement).getRoot().getProjects();
+ if (includeNonSigil && includeClosed)
{
result = projects;
}
else
{
- List<IProject> includedProjects = new ArrayList<IProject>( projects.length );
- for ( IProject project : projects )
+ List<IProject> includedProjects = new ArrayList<IProject>(projects.length);
+ for (IProject project : projects)
{
- if ( !includeClosed && !project.isOpen() )
+ if (!includeClosed && !project.isOpen())
{
continue;
}
- if ( !includeNonSigil )
+ if (!includeNonSigil)
{
try
{
- if ( project.getNature( SigilCore.NATURE_ID ) == null )
+ if (project.getNature(SigilCore.NATURE_ID) == null)
{
continue;
}
}
- catch ( CoreException e )
+ catch (CoreException e)
{
continue;
}
}
- includedProjects.add( project );
+ includedProjects.add(project);
}
- result = includedProjects.toArray( new IProject[includedProjects.size()] );
+ result = includedProjects.toArray(new IProject[includedProjects.size()]);
}
}
- else if ( parentElement instanceof IContainer )
+ else if (parentElement instanceof IContainer)
{
try
{
- IResource[] members = ( ( IContainer ) parentElement ).members();
- List<IResource> children = new ArrayList<IResource>( members.length );
- for ( int i = 0; i < members.length; i++ )
+ IResource[] members = ((IContainer) parentElement).members();
+ List<IResource> children = new ArrayList<IResource>(members.length);
+ for (int i = 0; i < members.length; i++)
{
- if ( members[i].getType() != IResource.FILE )
+ if (members[i].getType() != IResource.FILE)
{
- children.add( members[i] );
+ children.add(members[i]);
}
}
- result = children.toArray( new IResource[children.size()] );
+ result = children.toArray(new IResource[children.size()]);
}
- catch ( CoreException e )
+ catch (CoreException e)
{
// Shouldn't happen
}
@@ -112,35 +108,30 @@
return result;
}
-
- public Object getParent( Object element )
+ public Object getParent(Object element)
{
- if ( element instanceof IResource )
+ if (element instanceof IResource)
{
- return ( ( IResource ) element ).getParent();
+ return ((IResource) element).getParent();
}
return null;
}
-
- public boolean hasChildren( Object element )
+ public boolean hasChildren(Object element)
{
- return ( element instanceof IContainer ) && ( ( IContainer ) element ).isAccessible();
+ return (element instanceof IContainer) && ((IContainer) element).isAccessible();
}
-
- public Object[] getElements( Object inputElement )
+ public Object[] getElements(Object inputElement)
{
- return getChildren( inputElement );
+ return getChildren(inputElement);
}
-
public void dispose()
{
}
-
- public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
{
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/AccumulatorAdapter.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/AccumulatorAdapter.java
index b017ec3..e44a064 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/AccumulatorAdapter.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/AccumulatorAdapter.java
@@ -19,22 +19,19 @@
package org.apache.felix.sigil.eclipse.ui.util;
-
import java.util.Collection;
import java.util.LinkedList;
-
public abstract class AccumulatorAdapter<E> implements IAccumulator<E>
{
- public void addElement( E element )
+ public void addElement(E element)
{
LinkedList<E> list = new LinkedList<E>();
- list.add( element );
- addElements( list );
+ list.add(element);
+ addElements(list);
};
-
- public void addElements( Collection<? extends E> elements )
+ public void addElements(Collection<? extends E> elements)
{
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/BackgroundLoadingSelectionDialog.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/BackgroundLoadingSelectionDialog.java
index e70c93e..52e90f9 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/BackgroundLoadingSelectionDialog.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/BackgroundLoadingSelectionDialog.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.util;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -71,24 +70,23 @@
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.progress.IJobRunnable;
-
public class BackgroundLoadingSelectionDialog<E> extends TitleAreaDialog implements IAccumulator<E>
{
private final ILabelProvider DEFAULT_LABEL_PROVIDER = new LabelProvider()
{
@SuppressWarnings("unchecked")
- public String getText( Object element )
+ public String getText(Object element)
{
String result;
- if ( element instanceof WrappedContentProposal<?> )
+ if (element instanceof WrappedContentProposal<?>)
{
- WrappedContentProposal<E> contentProposal = (org.apache.felix.sigil.eclipse.ui.util.WrappedContentProposal<E> ) element;
+ WrappedContentProposal<E> contentProposal = (org.apache.felix.sigil.eclipse.ui.util.WrappedContentProposal<E>) element;
result = contentProposal.getLabel();
}
else
{
- result = descriptor.getLabel( ( E ) element );
+ result = descriptor.getLabel((E) element);
}
return result;
}
@@ -96,13 +94,12 @@
private final IElementDescriptor<E> DEFAULT_DESCRIPTOR = new IElementDescriptor<E>()
{
- public String getLabel( E element )
+ public String getLabel(E element)
{
- return getName( element );
+ return getName(element);
}
-
- public String getName( E element )
+ public String getName(E element)
{
return element == null ? "null" : element.toString();
}
@@ -124,25 +121,22 @@
private HashMap<String, IJobRunnable> background = new HashMap<String, IJobRunnable>();
-
- public BackgroundLoadingSelectionDialog( Shell parentShell, String selectionLabel, boolean multi )
+ public BackgroundLoadingSelectionDialog(Shell parentShell, String selectionLabel, boolean multi)
{
- super( parentShell );
+ super(parentShell);
elements = new ArrayList<E>();
this.selectionLabel = selectionLabel;
this.multi = multi;
}
-
- public void setFilter( IFilter<? super E> filter )
+ public void setFilter(IFilter<? super E> filter)
{
this.filter = filter;
}
-
- public void setDescriptor( final IElementDescriptor<? super E> descriptor )
+ public void setDescriptor(final IElementDescriptor<? super E> descriptor)
{
- if ( descriptor != null )
+ if (descriptor != null)
{
this.descriptor = descriptor;
}
@@ -152,22 +146,19 @@
}
}
-
public IElementDescriptor<? super E> getDescriptor()
{
return descriptor;
}
-
- public void setComparator( Comparator<? super E> comparator )
+ public void setComparator(Comparator<? super E> comparator)
{
this.comparator = comparator;
}
-
- public void setLabelProvider( ILabelProvider labelProvider )
+ public void setLabelProvider(ILabelProvider labelProvider)
{
- if ( labelProvider != null )
+ if (labelProvider != null)
{
this.labelProvider = labelProvider;
}
@@ -177,13 +168,11 @@
}
}
-
- public void addBackgroundJob( String name, IJobRunnable job )
+ public void addBackgroundJob(String name, IJobRunnable job)
{
- background.put( name, job );
+ background.put(name, job);
}
-
@Override
public int open()
{
@@ -194,216 +183,211 @@
}
finally
{
- for ( Job j : jobs )
+ for (Job j : jobs)
{
j.cancel();
}
}
}
-
private Job[] scheduleJobs()
{
- if ( background.isEmpty() )
+ if (background.isEmpty())
{
- return new Job[]
- {};
+ return new Job[] {};
}
else
{
- ArrayList<Job> jobs = new ArrayList<Job>( background.size() );
- for ( Map.Entry<String, IJobRunnable> e : background.entrySet() )
+ ArrayList<Job> jobs = new ArrayList<Job>(background.size());
+ for (Map.Entry<String, IJobRunnable> e : background.entrySet())
{
final IJobRunnable run = e.getValue();
- Job job = new Job( e.getKey() )
+ Job job = new Job(e.getKey())
{
@Override
- protected IStatus run( IProgressMonitor monitor )
+ protected IStatus run(IProgressMonitor monitor)
{
- return run.run( monitor );
+ return run.run(monitor);
}
};
job.schedule();
}
- return jobs.toArray( new Job[jobs.size()] );
+ return jobs.toArray(new Job[jobs.size()]);
}
}
-
@Override
- protected Control createDialogArea( Composite parent )
+ protected Control createDialogArea(Composite parent)
{
// Create Controls
- Composite container = ( Composite ) super.createDialogArea( parent );
- Composite composite = new Composite( container, SWT.NONE );
+ Composite container = (Composite) super.createDialogArea(parent);
+ Composite composite = new Composite(container, SWT.NONE);
- new Label( composite, SWT.NONE ).setText( selectionLabel );
+ new Label(composite, SWT.NONE).setText(selectionLabel);
ContentProposalAdapter proposalAdapter = null;
Text txtSelection = null;
Table table = null;
- if ( multi )
+ if (multi)
{
- table = new Table( composite, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER );
- viewer = new TableViewer( table );
- viewer.setContentProvider( new ArrayContentProvider() );
- viewer.addFilter( new ViewerFilter()
+ table = new Table(composite, SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER);
+ viewer = new TableViewer(table);
+ viewer.setContentProvider(new ArrayContentProvider());
+ viewer.addFilter(new ViewerFilter()
{
- public boolean select( Viewer viewer, Object parentElement, Object element )
+ public boolean select(Viewer viewer, Object parentElement, Object element)
{
@SuppressWarnings("unchecked")
- E castedElement = ( E ) element;
- return filter == null || filter.select( castedElement );
+ E castedElement = (E) element;
+ return filter == null || filter.select(castedElement);
}
- } );
- if ( comparator != null )
+ });
+ if (comparator != null)
{
- viewer.setSorter( new ViewerSorter()
+ viewer.setSorter(new ViewerSorter()
{
@Override
- public int compare( Viewer viewer, Object o1, Object o2 )
+ public int compare(Viewer viewer, Object o1, Object o2)
{
@SuppressWarnings("unchecked")
- E e1 = ( E ) o1;
+ E e1 = (E) o1;
@SuppressWarnings("unchecked")
- E e2 = ( E ) o2;
- return comparator.compare( e1, e2 );
+ E e2 = (E) o2;
+ return comparator.compare(e1, e2);
}
- } );
+ });
}
- synchronized ( elements )
+ synchronized (elements)
{
- viewer.setInput( elements );
+ viewer.setInput(elements);
}
- if ( labelProvider != null )
+ if (labelProvider != null)
{
- viewer.setLabelProvider( labelProvider );
+ viewer.setLabelProvider(labelProvider);
}
}
else
{
- txtSelection = new Text( composite, SWT.BORDER );
- ControlDecoration selectionDecor = new ControlDecoration( txtSelection, SWT.LEFT | SWT.TOP );
+ txtSelection = new Text(composite, SWT.BORDER);
+ ControlDecoration selectionDecor = new ControlDecoration(txtSelection,
+ SWT.LEFT | SWT.TOP);
FieldDecoration proposalDecor = FieldDecorationRegistry.getDefault().getFieldDecoration(
- FieldDecorationRegistry.DEC_CONTENT_PROPOSAL );
- selectionDecor.setImage( proposalDecor.getImage() );
- selectionDecor.setDescriptionText( proposalDecor.getDescription() );
+ FieldDecorationRegistry.DEC_CONTENT_PROPOSAL);
+ selectionDecor.setImage(proposalDecor.getImage());
+ selectionDecor.setDescriptionText(proposalDecor.getDescription());
- ExclusionContentProposalProvider<E> proposalProvider = new ExclusionContentProposalProvider<E>( elements,
- filter, descriptor );
+ ExclusionContentProposalProvider<E> proposalProvider = new ExclusionContentProposalProvider<E>(
+ elements, filter, descriptor);
- proposalAdapter = new ContentProposalAdapter( txtSelection, new TextContentAdapter(), proposalProvider,
- null, null );
- proposalAdapter.setProposalAcceptanceStyle( ContentProposalAdapter.PROPOSAL_REPLACE );
- if ( labelProvider != null )
+ proposalAdapter = new ContentProposalAdapter(txtSelection,
+ new TextContentAdapter(), proposalProvider, null, null);
+ proposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE);
+ if (labelProvider != null)
{
- proposalAdapter.setLabelProvider( labelProvider );
+ proposalAdapter.setLabelProvider(labelProvider);
}
- if ( selectedName != null )
+ if (selectedName != null)
{
- txtSelection.setText( selectedName );
+ txtSelection.setText(selectedName);
}
}
updateSelection();
updateButtons();
// Hookup listeners
- if ( proposalAdapter != null )
+ if (proposalAdapter != null)
{
- proposalAdapter.addContentProposalListener( new IContentProposalListener()
+ proposalAdapter.addContentProposalListener(new IContentProposalListener()
{
- public void proposalAccepted( IContentProposal proposal )
+ public void proposalAccepted(IContentProposal proposal)
{
@SuppressWarnings("unchecked")
- WrappedContentProposal<E> valueProposal = (org.apache.felix.sigil.eclipse.ui.util.WrappedContentProposal<E> ) proposal;
+ WrappedContentProposal<E> valueProposal = (org.apache.felix.sigil.eclipse.ui.util.WrappedContentProposal<E>) proposal;
E selected = valueProposal.getElement();
- selection = new ArrayList<E>( 1 );
- selection.add( selected );
+ selection = new ArrayList<E>(1);
+ selection.add(selected);
- elementSelected( selected );
+ elementSelected(selected);
updateButtons();
}
- } );
+ });
}
- if ( txtSelection != null )
+ if (txtSelection != null)
{
- txtSelection.addModifyListener( new ModifyListener()
+ txtSelection.addModifyListener(new ModifyListener()
{
- public void modifyText( ModifyEvent e )
+ public void modifyText(ModifyEvent e)
{
- selectedName = ( ( Text ) e.widget ).getText();
+ selectedName = ((Text) e.widget).getText();
updateButtons();
}
- } );
+ });
}
- if ( viewer != null )
+ if (viewer != null)
{
- viewer.addSelectionChangedListener( new ISelectionChangedListener()
+ viewer.addSelectionChangedListener(new ISelectionChangedListener()
{
- public void selectionChanged( SelectionChangedEvent event )
+ public void selectionChanged(SelectionChangedEvent event)
{
- IStructuredSelection sel = ( IStructuredSelection ) event.getSelection();
- selection = new ArrayList<E>( sel.size() );
- for ( Iterator<?> iter = sel.iterator(); iter.hasNext(); )
+ IStructuredSelection sel = (IStructuredSelection) event.getSelection();
+ selection = new ArrayList<E>(sel.size());
+ for (Iterator<?> iter = sel.iterator(); iter.hasNext();)
{
@SuppressWarnings("unchecked")
- E element = ( E ) iter.next();
- selection.add( element );
+ E element = (E) iter.next();
+ selection.add(element);
}
updateButtons();
}
- } );
- viewer.addOpenListener( new IOpenListener()
+ });
+ viewer.addOpenListener(new IOpenListener()
{
- public void open( OpenEvent event )
+ public void open(OpenEvent event)
{
- if ( canComplete() )
+ if (canComplete())
{
- setReturnCode( IDialogConstants.OK_ID );
+ setReturnCode(IDialogConstants.OK_ID);
close();
}
}
- } );
+ });
}
// Layout
- composite.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
- if ( multi )
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ if (multi)
{
- composite.setLayout( new GridLayout( 1, false ) );
- GridData layoutTable = new GridData( SWT.FILL, SWT.FILL, true, true );
+ composite.setLayout(new GridLayout(1, false));
+ GridData layoutTable = new GridData(SWT.FILL, SWT.FILL, true, true);
layoutTable.heightHint = 200;
- table.setLayoutData( layoutTable );
+ table.setLayoutData(layoutTable);
}
else
{
- composite.setLayout( new GridLayout( 2, false ) );
- txtSelection.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
+ composite.setLayout(new GridLayout(2, false));
+ txtSelection.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
}
return container;
}
-
- protected void elementSelected( E selection )
+ protected void elementSelected(E selection)
{
}
-
@Override
- protected Control createButtonBar( Composite parent )
+ protected Control createButtonBar(Composite parent)
{
- Control bar = super.createButtonBar( parent );
+ Control bar = super.createButtonBar(parent);
updateButtons();
return bar;
}
-
/**
* Can be called from any thread
*/
@@ -414,24 +398,23 @@
public void run()
{
Shell shell = getShell();
- if ( shell != null && !shell.isDisposed() )
+ if (shell != null && !shell.isDisposed())
{
- Button okButton = getButton( IDialogConstants.OK_ID );
- if ( okButton != null && !okButton.isDisposed() )
+ Button okButton = getButton(IDialogConstants.OK_ID);
+ if (okButton != null && !okButton.isDisposed())
{
- okButton.setEnabled( canComplete() );
+ okButton.setEnabled(canComplete());
}
}
}
};
Shell shell = getShell();
- if ( shell != null )
+ if (shell != null)
{
- onUIThread( shell, updateButtonsRunnable );
+ onUIThread(shell, updateButtonsRunnable);
}
}
-
/**
* Subclasses may override but must call super.canComplete
* @return
@@ -440,60 +423,58 @@
{
boolean result = false;
- if ( selection != null )
+ if (selection != null)
{
- if ( multi )
+ if (multi)
{
result = selection.size() > 0;
}
else
{
E sel = getSelectedElement();
- result = sel != null && descriptor.getName( sel ).equals( selectedName );
+ result = sel != null && descriptor.getName(sel).equals(selectedName);
}
}
return result;
}
-
- public final void addElement( E added )
+ public final void addElement(E added)
{
- addElements( Collections.singleton( added ) );
+ addElements(Collections.singleton(added));
}
-
/**
* Can be called from any thread
*/
- public final void addElements( Collection<? extends E> added )
+ public final void addElements(Collection<? extends E> added)
{
final LinkedList<E> toAdd = new LinkedList<E>();
- synchronized ( elements )
+ synchronized (elements)
{
- for ( E e : added )
+ for (E e : added)
{
- if ( !elements.contains( e ) )
+ if (!elements.contains(e))
{
- elements.add( e );
- toAdd.add( e );
+ elements.add(e);
+ toAdd.add(e);
}
}
- Collections.sort( elements, comparator );
+ Collections.sort(elements, comparator);
}
- if ( viewer != null )
+ if (viewer != null)
{
- onUIThread( viewer.getControl(), new Runnable()
+ onUIThread(viewer.getControl(), new Runnable()
{
public void run()
{
- if ( !viewer.getControl().isDisposed() )
+ if (!viewer.getControl().isDisposed())
{
- viewer.add( toAdd.toArray() );
+ viewer.add(toAdd.toArray());
viewer.refresh();
}
}
- } );
+ });
}
else
{
@@ -503,23 +484,22 @@
updateButtons();
}
-
protected void updateSelection()
{
- onUIThread( getShell(), new Runnable()
+ onUIThread(getShell(), new Runnable()
{
public void run()
{
- if ( selectedName != null )
+ if (selectedName != null)
{
ArrayList<E> newSelection = new ArrayList<E>();
- synchronized ( elements )
+ synchronized (elements)
{
- for ( E e : elements )
+ for (E e : elements)
{
- if ( selectedName.equals( descriptor.getName( e ) ) )
+ if (selectedName.equals(descriptor.getName(e)))
{
- newSelection.add( e );
+ newSelection.add(e);
break;
}
}
@@ -530,24 +510,23 @@
{
selection = Collections.emptyList();
}
- if ( viewer != null && !viewer.getControl().isDisposed() )
+ if (viewer != null && !viewer.getControl().isDisposed())
{
- viewer.setSelection( selection.isEmpty() ? StructuredSelection.EMPTY : new StructuredSelection(
- selection ) );
+ viewer.setSelection(selection.isEmpty() ? StructuredSelection.EMPTY
+ : new StructuredSelection(selection));
}
}
- } );
+ });
}
-
- private static final void onUIThread( Control control, Runnable r )
+ private static final void onUIThread(Control control, Runnable r)
{
- if ( control != null && !control.isDisposed() )
+ if (control != null && !control.isDisposed())
{
try
{
Display display = control.getDisplay();
- if ( Thread.currentThread() == display.getThread() )
+ if (Thread.currentThread() == display.getThread())
{
// We are on the UI thread already, just do the work
r.run();
@@ -555,12 +534,12 @@
else
{
// Not on the UI thread, need to bung over the runnable
- display.asyncExec( r );
+ display.asyncExec(r);
}
}
- catch ( SWTError e )
+ catch (SWTError e)
{
- if ( e.code == SWT.ERROR_WIDGET_DISPOSED )
+ if (e.code == SWT.ERROR_WIDGET_DISPOSED)
{
// ignore
}
@@ -572,60 +551,57 @@
}
}
-
public String getSelectedName()
{
return selectedName;
}
-
- public void setSelectedName( String selectedName )
+ public void setSelectedName(String selectedName)
{
this.selectedName = selectedName;
boolean change = false;
- if ( selectedName == null )
+ if (selectedName == null)
{
- if ( selection != null && !selection.isEmpty() )
+ if (selection != null && !selection.isEmpty())
{
change = true;
}
}
else
{
- if ( selection == null )
+ if (selection == null)
{
change = true;
}
- else if ( selection.size() != 1 || !descriptor.getLabel( selection.get( 0 ) ).equals( selectedName ) )
+ else if (selection.size() != 1
+ || !descriptor.getLabel(selection.get(0)).equals(selectedName))
{
change = true;
}
}
- if ( change )
+ if (change)
{
updateSelection();
updateButtons();
}
}
-
public List<E> getSelectedElements()
{
return selection;
}
-
public E getSelectedElement()
{
E result;
- if ( selection == null || selection.isEmpty() )
+ if (selection == null || selection.isEmpty())
{
result = null;
}
else
{
- result = selection.get( 0 );
+ result = selection.get(0);
}
return result;
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ColumnModelLabelProvider.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ColumnModelLabelProvider.java
index ecf680d..375e572 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ColumnModelLabelProvider.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ColumnModelLabelProvider.java
@@ -19,28 +19,24 @@
package org.apache.felix.sigil.eclipse.ui.util;
-
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.swt.graphics.Image;
-
public class ColumnModelLabelProvider extends ColumnLabelProvider
{
private ModelLabelProvider provider = new ModelLabelProvider();
-
@Override
- public Image getImage( Object element )
+ public Image getImage(Object element)
{
- return provider.getImage( element );
+ return provider.getImage(element);
}
-
@Override
- public String getText( Object element )
+ public String getText(Object element)
{
- return provider.getText( element );
+ return provider.getText(element);
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultContentProvider.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultContentProvider.java
index f17eaec..88c46e3 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultContentProvider.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultContentProvider.java
@@ -19,11 +19,9 @@
package org.apache.felix.sigil.eclipse.ui.util;
-
import org.eclipse.jface.viewers.IContentProvider;
import org.eclipse.jface.viewers.Viewer;
-
public class DefaultContentProvider implements IContentProvider
{
@@ -31,8 +29,7 @@
{
}
-
- public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
{
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultLabelProvider.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultLabelProvider.java
index 18a1e17..c6800c5 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultLabelProvider.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultLabelProvider.java
@@ -19,32 +19,27 @@
package org.apache.felix.sigil.eclipse.ui.util;
-
import org.eclipse.jface.viewers.IBaseLabelProvider;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
-
public abstract class DefaultLabelProvider implements IBaseLabelProvider, ILabelProvider
{
- public boolean isLabelProperty( Object element, String property )
+ public boolean isLabelProperty(Object element, String property)
{
return false;
}
-
public void dispose()
{
}
-
- public void addListener( ILabelProviderListener listener )
+ public void addListener(ILabelProviderListener listener)
{
}
-
- public void removeListener( ILabelProviderListener listener )
+ public void removeListener(ILabelProviderListener listener)
{
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultTableProvider.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultTableProvider.java
index defe741..48234c6 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultTableProvider.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultTableProvider.java
@@ -19,12 +19,10 @@
package org.apache.felix.sigil.eclipse.ui.util;
-
import java.util.Collection;
import org.eclipse.jface.viewers.IStructuredContentProvider;
-
public abstract class DefaultTableProvider extends DefaultContentProvider implements IStructuredContentProvider
{
@@ -39,25 +37,25 @@
*
* @throws IllegalArgumentException if the element cannot be converted.
*/
- public Object[] toArray( Object inputElement )
+ public Object[] toArray(Object inputElement)
{
- if ( inputElement == null )
+ if (inputElement == null)
{
- return new Object[]
- {};
+ return new Object[] {};
}
- else if ( inputElement instanceof Collection )
+ else if (inputElement instanceof Collection)
{
- Collection<?> col = ( Collection<?> ) inputElement;
+ Collection<?> col = (Collection<?>) inputElement;
return col.toArray();
}
- else if ( inputElement.getClass().isArray() )
+ else if (inputElement.getClass().isArray())
{
- return ( Object[] ) inputElement;
+ return (Object[]) inputElement;
}
else
{
- throw new IllegalArgumentException( "Invalid inputElement " + inputElement.getClass() );
+ throw new IllegalArgumentException("Invalid inputElement "
+ + inputElement.getClass());
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultTreeContentProvider.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultTreeContentProvider.java
index f7487db..5b6580e 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultTreeContentProvider.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/DefaultTreeContentProvider.java
@@ -19,10 +19,8 @@
package org.apache.felix.sigil.eclipse.ui.util;
-
import org.eclipse.jface.viewers.ITreeContentProvider;
-
public abstract class DefaultTreeContentProvider extends DefaultContentProvider implements ITreeContentProvider
{
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ExclusionContentProposalProvider.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ExclusionContentProposalProvider.java
index 96a3e10..5348801 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ExclusionContentProposalProvider.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ExclusionContentProposalProvider.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.util;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
@@ -31,7 +30,6 @@
import org.eclipse.jface.fieldassist.IContentProposal;
import org.eclipse.jface.fieldassist.IContentProposalProvider;
-
public class ExclusionContentProposalProvider<T> implements IContentProposalProvider
{
@@ -39,46 +37,44 @@
private final IFilter<? super T> filter;
private final IElementDescriptor<? super T> descriptor;
-
- public ExclusionContentProposalProvider( Collection<? extends T> elements, IFilter<? super T> filter,
- IElementDescriptor<? super T> descriptor )
+ public ExclusionContentProposalProvider(Collection<? extends T> elements, IFilter<? super T> filter, IElementDescriptor<? super T> descriptor)
{
this.elements = elements;
this.filter = filter;
this.descriptor = descriptor;
}
-
- public IContentProposal[] getProposals( String contents, int position )
+ public IContentProposal[] getProposals(String contents, int position)
{
- String matchString = contents.substring( 0, position );
- Pattern pattern = GlobCompiler.compile( matchString );
+ String matchString = contents.substring(0, position);
+ Pattern pattern = GlobCompiler.compile(matchString);
// Get a snapshot of the elements
T[] elementArray;
- synchronized ( elements )
+ synchronized (elements)
{
@SuppressWarnings("unchecked")
- T[] temp = ( T[] ) elements.toArray();
+ T[] temp = (T[]) elements.toArray();
elementArray = temp;
}
List<IContentProposal> result = new ArrayList<IContentProposal>();
- for ( T element : elementArray )
+ for (T element : elementArray)
{
- if ( filter == null || filter.select( element ) )
+ if (filter == null || filter.select(element))
{
- IContentProposal proposal = WrappedContentProposal.newInstance( element, descriptor );
- Matcher matcher = pattern.matcher( proposal.getContent() );
- if ( matcher.find() )
+ IContentProposal proposal = WrappedContentProposal.newInstance(element,
+ descriptor);
+ Matcher matcher = pattern.matcher(proposal.getContent());
+ if (matcher.find())
{
- result.add( proposal );
+ result.add(proposal);
}
}
}
- return result.toArray( new IContentProposal[result.size()] );
+ return result.toArray(new IContentProposal[result.size()]);
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ExportedPackageFinder.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ExportedPackageFinder.java
index e48d682..65eab4f 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ExportedPackageFinder.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ExportedPackageFinder.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.util;
-
import java.util.ArrayList;
import java.util.List;
@@ -33,46 +32,44 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.ui.progress.IJobRunnable;
-
public class ExportedPackageFinder implements IJobRunnable
{
private final IAccumulator<? super IPackageExport> accumulator;
private final ISigilProjectModel sigil;
-
- public ExportedPackageFinder( ISigilProjectModel sigil, IAccumulator<? super IPackageExport> accumulator )
+ public ExportedPackageFinder(ISigilProjectModel sigil, IAccumulator<? super IPackageExport> accumulator)
{
this.sigil = sigil;
this.accumulator = accumulator;
}
-
- public IStatus run( final IProgressMonitor monitor )
+ public IStatus run(final IProgressMonitor monitor)
{
- final List<IPackageExport> exports = new ArrayList<IPackageExport>( ResourcesDialogHelper.UPDATE_BATCH_SIZE );
+ final List<IPackageExport> exports = new ArrayList<IPackageExport>(
+ ResourcesDialogHelper.UPDATE_BATCH_SIZE);
final IModelWalker walker = new IModelWalker()
{
- public boolean visit( IModelElement element )
+ public boolean visit(IModelElement element)
{
- if ( element instanceof IPackageExport )
+ if (element instanceof IPackageExport)
{
- IPackageExport pkgExport = ( IPackageExport ) element;
- exports.add( pkgExport );
+ IPackageExport pkgExport = (IPackageExport) element;
+ exports.add(pkgExport);
- if ( exports.size() >= ResourcesDialogHelper.UPDATE_BATCH_SIZE )
+ if (exports.size() >= ResourcesDialogHelper.UPDATE_BATCH_SIZE)
{
- accumulator.addElements( exports );
+ accumulator.addElements(exports);
exports.clear();
}
}
return !monitor.isCanceled();
}
};
- SigilCore.getRepositoryManager( sigil ).visit( walker );
- if ( exports.size() > 0 )
+ SigilCore.getRepositoryManager(sigil).visit(walker);
+ if (exports.size() > 0)
{
- accumulator.addElements( exports );
+ accumulator.addElements(exports);
}
return Status.OK_STATUS;
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/FileUtils.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/FileUtils.java
index 5e15831..51160e0 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/FileUtils.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/FileUtils.java
@@ -19,36 +19,34 @@
package org.apache.felix.sigil.eclipse.ui.util;
-
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
-
public class FileUtils
{
- public static void loadFile( Shell shell, Text text, String msg, boolean isDirectory )
+ public static void loadFile(Shell shell, Text text, String msg, boolean isDirectory)
{
- if ( isDirectory )
+ if (isDirectory)
{
- DirectoryDialog dialog = new DirectoryDialog( shell, SWT.NONE );
- dialog.setMessage( msg );
+ DirectoryDialog dialog = new DirectoryDialog(shell, SWT.NONE);
+ dialog.setMessage(msg);
String value = dialog.open();
- if ( value != null )
+ if (value != null)
{
- text.setText( value );
+ text.setText(value);
}
}
else
{
- FileDialog dialog = new FileDialog( shell, SWT.NONE );
- dialog.setText( msg );
+ FileDialog dialog = new FileDialog(shell, SWT.NONE);
+ dialog.setText(msg);
String value = dialog.open();
- if ( value != null )
+ if (value != null)
{
- text.setText( value );
+ text.setText(value);
}
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IAccumulator.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IAccumulator.java
index 5ee046e..daa5f15 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IAccumulator.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IAccumulator.java
@@ -19,14 +19,11 @@
package org.apache.felix.sigil.eclipse.ui.util;
-
import java.util.Collection;
-
public interface IAccumulator<E>
{
- public void addElement( E element );
+ public void addElement(E element);
-
- public void addElements( Collection<? extends E> elements );
+ public void addElements(Collection<? extends E> elements);
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IElementDescriptor.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IElementDescriptor.java
index 463f888..57aadc9 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IElementDescriptor.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IElementDescriptor.java
@@ -19,14 +19,12 @@
package org.apache.felix.sigil.eclipse.ui.util;
-
public interface IElementDescriptor<E>
{
/**
* Return the short identifying name of the element.
*/
- String getName( E element );
-
+ String getName(E element);
/**
* Return a label for the element, including the name but possibly supplying
@@ -35,5 +33,5 @@
* @param element
* @return
*/
- String getLabel( E element );
+ String getLabel(E element);
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IExportToImportConverter.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IExportToImportConverter.java
index 8f51f10..1ddc6fe 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IExportToImportConverter.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IExportToImportConverter.java
@@ -19,8 +19,7 @@
package org.apache.felix.sigil.eclipse.ui.util;
-
public interface IExportToImportConverter<E, I>
{
- I convert( E exportElement );
+ I convert(E exportElement);
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IFilter.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IFilter.java
index f8a7e79..0d33c3a 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IFilter.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IFilter.java
@@ -19,8 +19,7 @@
package org.apache.felix.sigil.eclipse.ui.util;
-
public interface IFilter<T>
{
- boolean select( T element );
+ boolean select(T element);
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IValidationListener.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IValidationListener.java
index fb47833..e325c5e 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IValidationListener.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/IValidationListener.java
@@ -19,10 +19,9 @@
package org.apache.felix.sigil.eclipse.ui.util;
-
public interface IValidationListener
{
- void validationMessage( String message, int level );
+ void validationMessage(String message, int level);
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ModelLabelProvider.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ModelLabelProvider.java
index e1a54c7..74fbcf5 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ModelLabelProvider.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ModelLabelProvider.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.util;
-
import java.util.Set;
import org.apache.felix.sigil.common.model.IModelElement;
@@ -41,40 +40,39 @@
import org.eclipse.swt.graphics.Image;
import org.osgi.framework.Version;
-
public class ModelLabelProvider extends LabelProvider
{
private volatile Set<? extends IModelElement> unresolvedElements = null;
-
- public Image getImage( Object element )
+ public Image getImage(Object element)
{
- boolean unresolved = ( unresolvedElements == null ) ? false : unresolvedElements.contains( element );
+ boolean unresolved = (unresolvedElements == null) ? false
+ : unresolvedElements.contains(element);
- if ( element instanceof ISigilBundle || element instanceof IBundleModelElement )
+ if (element instanceof ISigilBundle || element instanceof IBundleModelElement)
{
return findBundle();
}
- else if ( element instanceof IRequiredBundle )
+ else if (element instanceof IRequiredBundle)
{
- boolean optional = ( ( IRequiredBundle ) element ).isOptional();
- return findRequiredBundle( optional, unresolved );
+ boolean optional = ((IRequiredBundle) element).isOptional();
+ return findRequiredBundle(optional, unresolved);
}
- else if ( element instanceof IPackageImport )
+ else if (element instanceof IPackageImport)
{
- boolean optional = ( ( IPackageImport ) element ).isOptional();
- return findPackageImport( optional, unresolved );
+ boolean optional = ((IPackageImport) element).isOptional();
+ return findPackageImport(optional, unresolved);
}
- else if ( element instanceof IPackageExport )
+ else if (element instanceof IPackageExport)
{
return findPackageExport();
}
- else if ( element instanceof IPackageFragmentRoot )
+ else if (element instanceof IPackageFragmentRoot)
{
- IPackageFragmentRoot root = ( IPackageFragmentRoot ) element;
+ IPackageFragmentRoot root = (IPackageFragmentRoot) element;
try
{
- if ( root.getKind() == IPackageFragmentRoot.K_SOURCE )
+ if (root.getKind() == IPackageFragmentRoot.K_SOURCE)
{
return findPackage();
}
@@ -83,154 +81,154 @@
return findBundle();
}
}
- catch ( JavaModelException e )
+ catch (JavaModelException e)
{
- SigilCore.error( "Failed to inspect package fragment root", e );
+ SigilCore.error("Failed to inspect package fragment root", e);
}
}
- else if ( element instanceof IClasspathEntry )
+ else if (element instanceof IClasspathEntry)
{
return findPackage();
}
- if ( element instanceof IBundleRepository )
+ if (element instanceof IBundleRepository)
{
- IBundleRepository rep = ( IBundleRepository ) element;
- IRepositoryModel config = SigilCore.getRepositoryConfiguration().findRepository( rep.getId() );
+ IBundleRepository rep = (IBundleRepository) element;
+ IRepositoryModel config = SigilCore.getRepositoryConfiguration().findRepository(
+ rep.getId());
return config.getType().getIcon();
}
return null;
}
-
- public String getText( Object element )
+ public String getText(Object element)
{
- if ( element instanceof ISigilBundle )
+ if (element instanceof ISigilBundle)
{
- ISigilBundle bundle = ( ISigilBundle ) element;
- return bundle.getBundleInfo().getSymbolicName() + " " + bundle.getBundleInfo().getVersion();
+ ISigilBundle bundle = (ISigilBundle) element;
+ return bundle.getBundleInfo().getSymbolicName() + " "
+ + bundle.getBundleInfo().getVersion();
}
- if ( element instanceof IBundleModelElement )
+ if (element instanceof IBundleModelElement)
{
- IBundleModelElement bundle = ( IBundleModelElement ) element;
+ IBundleModelElement bundle = (IBundleModelElement) element;
return bundle.getSymbolicName();
}
- if ( element instanceof IRequiredBundle )
+ if (element instanceof IRequiredBundle)
{
- IRequiredBundle req = ( IRequiredBundle ) element;
+ IRequiredBundle req = (IRequiredBundle) element;
return req.getSymbolicName() + " " + req.getVersions();
}
- if ( element instanceof IPackageImport )
+ if (element instanceof IPackageImport)
{
- IPackageImport req = ( IPackageImport ) element;
+ IPackageImport req = (IPackageImport) element;
return req.getPackageName() + " " + req.getVersions();
}
- if ( element instanceof IPackageExport )
+ if (element instanceof IPackageExport)
{
- IPackageExport pe = ( IPackageExport ) element;
+ IPackageExport pe = (IPackageExport) element;
Version rawVersion = pe.getRawVersion();
- return rawVersion != null ? pe.getPackageName() + " " + rawVersion : pe.getPackageName();
+ return rawVersion != null ? pe.getPackageName() + " " + rawVersion
+ : pe.getPackageName();
}
- if ( element instanceof IResource )
+ if (element instanceof IResource)
{
- IResource resource = ( IResource ) element;
+ IResource resource = (IResource) element;
return resource.getName();
}
- if ( element instanceof IPackageFragment )
+ if (element instanceof IPackageFragment)
{
- IPackageFragment f = ( IPackageFragment ) element;
+ IPackageFragment f = (IPackageFragment) element;
return f.getElementName();
}
- if ( element instanceof IPackageFragmentRoot )
+ if (element instanceof IPackageFragmentRoot)
{
- IPackageFragmentRoot f = ( IPackageFragmentRoot ) element;
+ IPackageFragmentRoot f = (IPackageFragmentRoot) element;
try
{
return f.getUnderlyingResource().getName();
}
- catch ( JavaModelException e )
+ catch (JavaModelException e)
{
return "unknown";
}
}
- if ( element instanceof IClasspathEntry )
+ if (element instanceof IClasspathEntry)
{
- IClasspathEntry cp = ( IClasspathEntry ) element;
+ IClasspathEntry cp = (IClasspathEntry) element;
return cp.getPath().toString();
}
- if ( element instanceof IBundleRepository )
+ if (element instanceof IBundleRepository)
{
- IBundleRepository rep = ( IBundleRepository ) element;
- IRepositoryModel config = SigilCore.getRepositoryConfiguration().findRepository( rep.getId() );
+ IBundleRepository rep = (IBundleRepository) element;
+ IRepositoryModel config = SigilCore.getRepositoryConfiguration().findRepository(
+ rep.getId());
return config.getName();
}
return element.toString();
}
-
private Image findPackage()
{
- return cacheImage( "icons/package.gif" );
+ return cacheImage("icons/package.gif");
}
-
- private Image findPackageImport( boolean optional, boolean unresolved )
+ private Image findPackageImport(boolean optional, boolean unresolved)
{
String path;
- if ( optional )
+ if (optional)
{
- path = unresolved ? "icons/import-package-optional-error.gif" : "icons/import-package-optional.gif";
+ path = unresolved ? "icons/import-package-optional-error.gif"
+ : "icons/import-package-optional.gif";
}
else
{
- path = unresolved ? "icons/import-package-error.gif" : "icons/import-package.gif";
+ path = unresolved ? "icons/import-package-error.gif"
+ : "icons/import-package.gif";
}
- return cacheImage( path );
+ return cacheImage(path);
}
-
private Image findPackageExport()
{
- return cacheImage( "icons/export-package.gif" );
+ return cacheImage("icons/export-package.gif");
}
-
private Image findBundle()
{
- return cacheImage( "icons/bundle.gif" );
+ return cacheImage("icons/bundle.gif");
}
-
- private Image findRequiredBundle( boolean optional, boolean unresolved )
+ private Image findRequiredBundle(boolean optional, boolean unresolved)
{
String path;
- if ( optional )
+ if (optional)
{
- path = unresolved ? "icons/require-bundle-optional-error.gif" : "icons/require-bundle-optional.gif";
+ path = unresolved ? "icons/require-bundle-optional-error.gif"
+ : "icons/require-bundle-optional.gif";
}
else
{
- path = unresolved ? "icons/require-bundle-error.gif" : "icons/require-bundle.gif";
+ path = unresolved ? "icons/require-bundle-error.gif"
+ : "icons/require-bundle.gif";
}
- return cacheImage( path );
+ return cacheImage(path);
}
-
- private static Image cacheImage( String path )
+ private static Image cacheImage(String path)
{
- return SigilUI.cacheImage( path, ModelLabelProvider.class.getClassLoader() );
+ return SigilUI.cacheImage(path, ModelLabelProvider.class.getClassLoader());
}
-
- public void setUnresolvedElements( Set<? extends IModelElement> elements )
+ public void setUnresolvedElements(Set<? extends IModelElement> elements)
{
this.unresolvedElements = elements;
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/PackageFilter.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/PackageFilter.java
index e5c460b..5aa3c03 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/PackageFilter.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/PackageFilter.java
@@ -19,41 +19,36 @@
package org.apache.felix.sigil.eclipse.ui.util;
-
import java.util.HashSet;
import java.util.Set;
import org.apache.felix.sigil.common.model.osgi.IPackageExport;
import org.apache.felix.sigil.common.model.osgi.IPackageImport;
-
public class PackageFilter implements IFilter<IPackageImport>
{
private Set<String> names = new HashSet<String>();
-
- public PackageFilter( String[] packageNames )
+ public PackageFilter(String[] packageNames)
{
- for ( String name : packageNames )
+ for (String name : packageNames)
{
- names.add( name );
+ names.add(name);
}
}
-
- public PackageFilter( IPackageExport[] packages )
+ public PackageFilter(IPackageExport[] packages)
{
- for ( IPackageExport packageExport : packages )
+ for (IPackageExport packageExport : packages)
{
- names.add( packageExport.getPackageName() );
+ names.add(packageExport.getPackageName());
}
}
-
- public boolean select( IPackageImport element )
+ public boolean select(IPackageImport element)
{
- return !names.contains( element.getPackageName() );
+ return !names.contains(element.getPackageName());
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ProjectUtils.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ProjectUtils.java
index 79aa846..73ffa6c 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ProjectUtils.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ProjectUtils.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.util;
-
import java.util.concurrent.Callable;
import org.apache.felix.sigil.eclipse.SigilCore;
@@ -30,26 +29,24 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.actions.WorkspaceModifyOperation;
-
public class ProjectUtils
{
- public static boolean runTaskWithRebuildCheck( final Runnable task, Shell shell )
+ public static boolean runTaskWithRebuildCheck(final Runnable task, Shell shell)
{
- return runTaskWithRebuildCheck( new Callable<Boolean>()
+ return runTaskWithRebuildCheck(new Callable<Boolean>()
{
public Boolean call() throws Exception
{
task.run();
return true;
}
- }, shell );
+ }, shell);
}
-
- public static boolean runTaskWithRebuildCheck( Callable<Boolean> callable, Shell shell )
+ public static boolean runTaskWithRebuildCheck(Callable<Boolean> callable, Shell shell)
{
- int result = checkRebuild( shell );
- if ( result == IDialogConstants.CANCEL_ID )
+ int result = checkRebuild(shell);
+ if (result == IDialogConstants.CANCEL_ID)
{
return false;
}
@@ -57,18 +54,18 @@
{
try
{
- if ( Boolean.TRUE == callable.call() )
+ if (Boolean.TRUE == callable.call())
{
- if ( result == IDialogConstants.YES_ID )
+ if (result == IDialogConstants.YES_ID)
{
- SigilUI.runWorkspaceOperation( new WorkspaceModifyOperation()
+ SigilUI.runWorkspaceOperation(new WorkspaceModifyOperation()
{
@Override
- protected void execute( IProgressMonitor monitor )
+ protected void execute(IProgressMonitor monitor)
{
- SigilCore.rebuildAllBundleDependencies( monitor );
+ SigilCore.rebuildAllBundleDependencies(monitor);
}
- }, shell );
+ }, shell);
}
return true;
}
@@ -77,25 +74,25 @@
return false;
}
}
- catch ( Exception e )
+ catch (Exception e)
{
- SigilCore.error( "Failed to run caller", e );
+ SigilCore.error("Failed to run caller", e);
return false;
}
}
}
-
- private static int checkRebuild( Shell shell )
+ private static int checkRebuild(Shell shell)
{
- if ( SigilCore.getRoot().getProjects().isEmpty() )
+ if (SigilCore.getRoot().getProjects().isEmpty())
{
return IDialogConstants.NO_ID;
}
else
{
return OptionalPrompt.optionallyPromptWithCancel(
- SigilCore.PREFERENCES_REBUILD_PROJECTS, "Rebuild", "Do you wish to rebuild all Sigil projects", shell );
+ SigilCore.PREFERENCES_REBUILD_PROJECTS, "Rebuild",
+ "Do you wish to rebuild all Sigil projects", shell);
}
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ResourceReviewDialog.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ResourceReviewDialog.java
index a5c2729..acabd9a 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ResourceReviewDialog.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ResourceReviewDialog.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.util;
-
import java.util.Collection;
import org.apache.felix.sigil.common.model.IModelElement;
@@ -40,7 +39,6 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
-
public class ResourceReviewDialog<T extends IModelElement> extends TitleAreaDialog
{
@@ -49,80 +47,76 @@
private TableViewer viewer;
-
- public ResourceReviewDialog( Shell parentShell, String title, Collection<T> resources )
+ public ResourceReviewDialog(Shell parentShell, String title, Collection<T> resources)
{
- super( parentShell );
+ super(parentShell);
this.title = title;
this.resources = resources;
}
-
public Collection<T> getResources()
{
return resources;
}
-
@Override
- protected Control createDialogArea( Composite parent )
+ protected Control createDialogArea(Composite parent)
{
- setTitle( title );
+ setTitle(title);
// Create controls
- Composite container = ( Composite ) super.createDialogArea( parent );
- Composite composite = new Composite( container, SWT.NONE );
- Table table = new Table( composite, SWT.BORDER | SWT.VIRTUAL );
+ Composite container = (Composite) super.createDialogArea(parent);
+ Composite composite = new Composite(container, SWT.NONE);
+ Table table = new Table(composite, SWT.BORDER | SWT.VIRTUAL);
- final Button remove = new Button( composite, SWT.PUSH );
- remove.setText( "Remove" );
- remove.setEnabled( false );
+ final Button remove = new Button(composite, SWT.PUSH);
+ remove.setText("Remove");
+ remove.setEnabled(false);
- remove.addSelectionListener( new SelectionAdapter()
+ remove.addSelectionListener(new SelectionAdapter()
{
@Override
- public void widgetSelected( SelectionEvent e )
+ public void widgetSelected(SelectionEvent e)
{
handleRemove();
}
- } );
+ });
- viewer = new TableViewer( table );
- viewer.setContentProvider( new DefaultTableProvider()
+ viewer = new TableViewer(table);
+ viewer.setContentProvider(new DefaultTableProvider()
{
- public Object[] getElements( Object inputElement )
+ public Object[] getElements(Object inputElement)
{
- return toArray( inputElement );
+ return toArray(inputElement);
}
- } );
+ });
- viewer.setInput( resources );
- viewer.addSelectionChangedListener( new ISelectionChangedListener()
+ viewer.setInput(resources);
+ viewer.addSelectionChangedListener(new ISelectionChangedListener()
{
- public void selectionChanged( SelectionChangedEvent event )
+ public void selectionChanged(SelectionChangedEvent event)
{
- remove.setEnabled( !event.getSelection().isEmpty() );
+ remove.setEnabled(!event.getSelection().isEmpty());
}
- } );
+ });
// layout
- composite.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
- composite.setLayout( new GridLayout( 2, false ) );
- GridData tableLayoutData = new GridData( SWT.FILL, SWT.FILL, true, true, 1, 4 );
+ composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ composite.setLayout(new GridLayout(2, false));
+ GridData tableLayoutData = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 4);
tableLayoutData.heightHint = 150;
- table.setLayoutData( tableLayoutData );
+ table.setLayoutData(tableLayoutData);
return container;
}
-
private void handleRemove()
{
ISelection s = viewer.getSelection();
- if ( !s.isEmpty() )
+ if (!s.isEmpty())
{
- IStructuredSelection sel = ( IStructuredSelection ) s;
- resources.remove( sel.getFirstElement() );
+ IStructuredSelection sel = (IStructuredSelection) s;
+ resources.remove(sel.getFirstElement());
viewer.refresh();
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ResourcesDialogHelper.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ResourcesDialogHelper.java
index 6ef3710..a9b1b3c 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ResourcesDialogHelper.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/ResourcesDialogHelper.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.util;
-
import java.util.ArrayList;
import java.util.Collection;
@@ -51,39 +50,39 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.progress.IJobRunnable;
-
public class ResourcesDialogHelper
{
static final int UPDATE_BATCH_SIZE = 100;
-
- public static BackgroundLoadingSelectionDialog<String> createClassSelectDialog( Shell shell, String title,
- final ISigilProjectModel project, String selected, final String ifaceOrParentClass )
+ public static BackgroundLoadingSelectionDialog<String> createClassSelectDialog(
+ Shell shell, String title, final ISigilProjectModel project, String selected,
+ final String ifaceOrParentClass)
{
- final BackgroundLoadingSelectionDialog<String> dialog = new BackgroundLoadingSelectionDialog<String>( shell,
- "Class Name", true );
+ final BackgroundLoadingSelectionDialog<String> dialog = new BackgroundLoadingSelectionDialog<String>(
+ shell, "Class Name", true);
IJobRunnable job = new IJobRunnable()
{
- public IStatus run( IProgressMonitor monitor )
+ public IStatus run(IProgressMonitor monitor)
{
try
{
- for ( IJavaElement e : JavaHelper.findTypes( project.getJavaModel(),
- IJavaElement.PACKAGE_FRAGMENT ) )
+ for (IJavaElement e : JavaHelper.findTypes(project.getJavaModel(),
+ IJavaElement.PACKAGE_FRAGMENT))
{
- IPackageFragment root = ( IPackageFragment ) e;
- if ( project.isInBundleClasspath( root ) )
+ IPackageFragment root = (IPackageFragment) e;
+ if (project.isInBundleClasspath(root))
{
- for ( IJavaElement e1 : JavaHelper.findTypes( root, IJavaElement.COMPILATION_UNIT,
- IJavaElement.CLASS_FILE ) )
+ for (IJavaElement e1 : JavaHelper.findTypes(root,
+ IJavaElement.COMPILATION_UNIT, IJavaElement.CLASS_FILE))
{
- ITypeRoot typeRoot = ( ITypeRoot ) e1;
- IType type = ( IType ) JavaHelper.findType( typeRoot, IJavaElement.TYPE );
- if ( JavaHelper.isAssignableTo( ifaceOrParentClass, type ) )
+ ITypeRoot typeRoot = (ITypeRoot) e1;
+ IType type = (IType) JavaHelper.findType(typeRoot,
+ IJavaElement.TYPE);
+ if (JavaHelper.isAssignableTo(ifaceOrParentClass, type))
{
- dialog.addElement( type.getFullyQualifiedName() );
+ dialog.addElement(type.getFullyQualifiedName());
}
}
}
@@ -91,7 +90,7 @@
return Status.OK_STATUS;
}
- catch ( JavaModelException e )
+ catch (JavaModelException e)
{
return e.getStatus();
}
@@ -99,88 +98,89 @@
};
- dialog.addBackgroundJob( "Scanning for activators in project", job );
+ dialog.addBackgroundJob("Scanning for activators in project", job);
return dialog;
}
-
- public static NewResourceSelectionDialog<IPackageExport> createImportDialog( Shell shell, String title,
- ISigilProjectModel sigil, final IPackageImport selected, final Collection<IPackageImport> existing )
+ public static NewResourceSelectionDialog<IPackageExport> createImportDialog(
+ Shell shell, String title, ISigilProjectModel sigil,
+ final IPackageImport selected, final Collection<IPackageImport> existing)
{
final Set<String> existingNames = new HashSet<String>();
- for ( IPackageImport existingImport : existing )
+ for (IPackageImport existingImport : existing)
{
- existingNames.add( existingImport.getPackageName() );
+ existingNames.add(existingImport.getPackageName());
}
final NewResourceSelectionDialog<IPackageExport> dialog = new NewResourceSelectionDialog<IPackageExport>(
- shell, "Package Name:", false );
+ shell, "Package Name:", false);
- dialog.setFilter( new IFilter<IPackageModelElement>()
+ dialog.setFilter(new IFilter<IPackageModelElement>()
{
- public boolean select( IPackageModelElement element )
+ public boolean select(IPackageModelElement element)
{
- return !existingNames.contains( element.getPackageName() );
+ return !existingNames.contains(element.getPackageName());
}
- } );
+ });
- dialog.setComparator( new Comparator<IPackageExport>()
+ dialog.setComparator(new Comparator<IPackageExport>()
{
- public int compare( IPackageExport o1, IPackageExport o2 )
+ public int compare(IPackageExport o1, IPackageExport o2)
{
- return o1.compareTo( o2 );
+ return o1.compareTo(o2);
}
- } );
+ });
- dialog.setDescriptor( new IElementDescriptor<IPackageExport>()
+ dialog.setDescriptor(new IElementDescriptor<IPackageExport>()
{
- public String getLabel( IPackageExport element )
+ public String getLabel(IPackageExport element)
{
- return getName( element ) + " (" + element.getVersion().toString() + ")";
+ return getName(element) + " (" + element.getVersion().toString() + ")";
}
-
- public String getName( IPackageExport element )
+ public String getName(IPackageExport element)
{
return element.getPackageName();
}
- } );
+ });
- dialog.setLabelProvider( new WrappedContentProposalLabelProvider<IPackageExport>( dialog.getDescriptor() ) );
+ dialog.setLabelProvider(new WrappedContentProposalLabelProvider<IPackageExport>(
+ dialog.getDescriptor()));
- if ( selected != null )
+ if (selected != null)
{
- dialog.setSelectedName( selected.getPackageName() );
- dialog.setVersions( selected.getVersions() );
- dialog.setOptional( selected.isOptional() );
+ dialog.setSelectedName(selected.getPackageName());
+ dialog.setVersions(selected.getVersions());
+ dialog.setOptional(selected.isOptional());
}
- IJobRunnable job = new ExportedPackageFinder( sigil, dialog );
- dialog.addBackgroundJob( "Scanning for exports in workspace", job );
+ IJobRunnable job = new ExportedPackageFinder(sigil, dialog);
+ dialog.addBackgroundJob("Scanning for exports in workspace", job);
return dialog;
}
-
- public static NewPackageExportDialog createNewExportDialog( Shell shell, String title,
- final IPackageExport selected, final ISigilProjectModel project, boolean multiSelect )
+ public static NewPackageExportDialog createNewExportDialog(Shell shell, String title,
+ final IPackageExport selected, final ISigilProjectModel project,
+ boolean multiSelect)
{
IFilter<IJavaElement> selectFilter = new IFilter<IJavaElement>()
{
- public boolean select( IJavaElement e )
+ public boolean select(IJavaElement e)
{
- if ( selected != null && e.getElementName().equals( selected.getPackageName() ) )
+ if (selected != null
+ && e.getElementName().equals(selected.getPackageName()))
{
return true;
}
- if ( e.getElementName().trim().length() > 0 && isLocal( e ) )
+ if (e.getElementName().trim().length() > 0 && isLocal(e))
{
- for ( IPackageExport p : project.getBundle().getBundleInfo().getExports() )
+ for (IPackageExport p : project.getBundle().getBundleInfo().getExports())
{
- if ( p.getPackageName().equals( e.getElementName() ) )
+ if (p.getPackageName().equals(e.getElementName()))
{
return false;
}
@@ -194,150 +194,151 @@
}
}
-
- private boolean isLocal( IJavaElement java )
+ private boolean isLocal(IJavaElement java)
{
try
{
- switch ( java.getElementType() )
+ switch (java.getElementType())
{
case IJavaElement.PACKAGE_FRAGMENT:
- IPackageFragment fragment = ( IPackageFragment ) java;
+ IPackageFragment fragment = (IPackageFragment) java;
return fragment.containsJavaResources();
default:
- throw new IllegalStateException( "Unexpected resource type " + java );
+ throw new IllegalStateException("Unexpected resource type "
+ + java);
}
}
- catch ( JavaModelException e )
+ catch (JavaModelException e)
{
- SigilCore.error( "Failed to inspect java element ", e );
+ SigilCore.error("Failed to inspect java element ", e);
return false;
}
}
};
- final NewPackageExportDialog dialog = new NewPackageExportDialog( shell, multiSelect );
- dialog.setFilter( selectFilter );
+ final NewPackageExportDialog dialog = new NewPackageExportDialog(shell,
+ multiSelect);
+ dialog.setFilter(selectFilter);
- dialog.setProjectVersion( project.getVersion() );
- if ( selected != null )
+ dialog.setProjectVersion(project.getVersion());
+ if (selected != null)
{
- dialog.setSelectedName( selected.getPackageName() );
- dialog.setVersion( selected.getRawVersion() );
+ dialog.setSelectedName(selected.getPackageName());
+ dialog.setVersion(selected.getRawVersion());
}
IJobRunnable job = new IJobRunnable()
{
- public IStatus run( IProgressMonitor monitor )
+ public IStatus run(IProgressMonitor monitor)
{
try
{
- ArrayList<IPackageFragment> list = new ArrayList<IPackageFragment>( UPDATE_BATCH_SIZE );
- for ( IJavaElement e : JavaHelper.findTypes( project.getJavaModel(),
- IJavaElement.PACKAGE_FRAGMENT ) )
+ ArrayList<IPackageFragment> list = new ArrayList<IPackageFragment>(
+ UPDATE_BATCH_SIZE);
+ for (IJavaElement e : JavaHelper.findTypes(project.getJavaModel(),
+ IJavaElement.PACKAGE_FRAGMENT))
{
- IPackageFragment root = ( IPackageFragment ) e;
- if ( project.isInBundleClasspath( root ) )
+ IPackageFragment root = (IPackageFragment) e;
+ if (project.isInBundleClasspath(root))
{
- list.add( root );
- if ( list.size() >= UPDATE_BATCH_SIZE )
+ list.add(root);
+ if (list.size() >= UPDATE_BATCH_SIZE)
{
- dialog.addElements( list );
+ dialog.addElements(list);
list.clear();
}
}
}
- if ( !list.isEmpty() )
+ if (!list.isEmpty())
{
- dialog.addElements( list );
+ dialog.addElements(list);
}
return Status.OK_STATUS;
}
- catch ( JavaModelException e )
+ catch (JavaModelException e)
{
return e.getStatus();
}
}
};
- dialog.addBackgroundJob( "Scanning for packages in project", job );
+ dialog.addBackgroundJob("Scanning for packages in project", job);
return dialog;
}
-
- public static NewResourceSelectionDialog<IBundleModelElement> createRequiredBundleDialog( Shell shell,
- String title, final ISigilProjectModel sigil, final IRequiredBundle selected,
- final Collection<IRequiredBundle> existing )
+ public static NewResourceSelectionDialog<IBundleModelElement> createRequiredBundleDialog(
+ Shell shell, String title, final ISigilProjectModel sigil,
+ final IRequiredBundle selected, final Collection<IRequiredBundle> existing)
{
final Set<String> existingNames = new HashSet<String>();
- for ( IRequiredBundle existingBundle : existing )
+ for (IRequiredBundle existingBundle : existing)
{
- existingNames.add( existingBundle.getSymbolicName() );
+ existingNames.add(existingBundle.getSymbolicName());
}
final NewResourceSelectionDialog<IBundleModelElement> dialog = new NewResourceSelectionDialog<IBundleModelElement>(
- shell, "Bundle:", false );
+ shell, "Bundle:", false);
- dialog.setDescriptor( new IElementDescriptor<IBundleModelElement>()
+ dialog.setDescriptor(new IElementDescriptor<IBundleModelElement>()
{
- public String getLabel( IBundleModelElement element )
+ public String getLabel(IBundleModelElement element)
{
- return getName( element ) + " (" + element.getVersion() + ")";
+ return getName(element) + " (" + element.getVersion() + ")";
}
-
- public String getName( IBundleModelElement element )
+ public String getName(IBundleModelElement element)
{
return element.getSymbolicName();
}
- } );
+ });
- dialog
- .setLabelProvider( new WrappedContentProposalLabelProvider<IBundleModelElement>( dialog.getDescriptor() ) );
+ dialog.setLabelProvider(new WrappedContentProposalLabelProvider<IBundleModelElement>(
+ dialog.getDescriptor()));
- dialog.setFilter( new IFilter<IBundleModelElement>()
+ dialog.setFilter(new IFilter<IBundleModelElement>()
{
- public boolean select( IBundleModelElement element )
+ public boolean select(IBundleModelElement element)
{
- return !existingNames.contains( element.getSymbolicName() );
+ return !existingNames.contains(element.getSymbolicName());
}
- } );
+ });
- dialog.setComparator( new Comparator<IBundleModelElement>()
+ dialog.setComparator(new Comparator<IBundleModelElement>()
{
- public int compare( IBundleModelElement o1, IBundleModelElement o2 )
+ public int compare(IBundleModelElement o1, IBundleModelElement o2)
{
- return o1.getSymbolicName().compareTo( o2.getSymbolicName() );
+ return o1.getSymbolicName().compareTo(o2.getSymbolicName());
}
- } );
+ });
- if ( selected != null )
+ if (selected != null)
{
- dialog.setSelectedName( selected.getSymbolicName() );
- dialog.setVersions( selected.getVersions() );
- dialog.setOptional( selected.isOptional() );
+ dialog.setSelectedName(selected.getSymbolicName());
+ dialog.setVersions(selected.getVersions());
+ dialog.setOptional(selected.isOptional());
}
IJobRunnable job = new IJobRunnable()
{
- public IStatus run( final IProgressMonitor monitor )
+ public IStatus run(final IProgressMonitor monitor)
{
- final List<IBundleModelElement> bundles = new ArrayList<IBundleModelElement>( UPDATE_BATCH_SIZE );
+ final List<IBundleModelElement> bundles = new ArrayList<IBundleModelElement>(
+ UPDATE_BATCH_SIZE);
final IModelWalker walker = new IModelWalker()
{
//int count = 0;
- public boolean visit( IModelElement element )
+ public boolean visit(IModelElement element)
{
- if ( element instanceof IBundleModelElement )
+ if (element instanceof IBundleModelElement)
{
- IBundleModelElement b = ( IBundleModelElement ) element;
- bundles.add( b );
+ IBundleModelElement b = (IBundleModelElement) element;
+ bundles.add(b);
- if ( bundles.size() >= UPDATE_BATCH_SIZE )
+ if (bundles.size() >= UPDATE_BATCH_SIZE)
{
- dialog.addElements( bundles );
+ dialog.addElements(bundles);
bundles.clear();
}
// no need to recurse further.
@@ -346,16 +347,16 @@
return !monitor.isCanceled();
}
};
- SigilCore.getRepositoryManager( sigil ).visit( walker );
- if ( !bundles.isEmpty() )
+ SigilCore.getRepositoryManager(sigil).visit(walker);
+ if (!bundles.isEmpty())
{
- dialog.addElements( bundles );
+ dialog.addElements(bundles);
}
return Status.OK_STATUS;
}
};
- dialog.addBackgroundJob( "Scanning for bundles in workspace", job );
+ dialog.addBackgroundJob("Scanning for bundles in workspace", job);
return dialog;
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/SingletonSelection.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/SingletonSelection.java
index 6a83e37..2784d35 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/SingletonSelection.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/SingletonSelection.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.util;
-
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
@@ -27,53 +26,44 @@
import org.eclipse.jface.viewers.IStructuredSelection;
-
@SuppressWarnings("unchecked")
public class SingletonSelection implements IStructuredSelection
{
private final Object singleton;
-
- public SingletonSelection( Object singleton )
+ public SingletonSelection(Object singleton)
{
this.singleton = singleton;
}
-
public Object getFirstElement()
{
return singleton;
}
-
public Iterator iterator()
{
- return Collections.singleton( singleton ).iterator();
+ return Collections.singleton(singleton).iterator();
}
-
public int size()
{
return 1;
}
-
public Object[] toArray()
{
- return new Object[]
- { singleton };
+ return new Object[] { singleton };
}
-
public List toList()
{
- ArrayList list = new ArrayList( 1 );
- list.add( singleton );
+ ArrayList list = new ArrayList(1);
+ list.add(singleton);
return list;
}
-
public boolean isEmpty()
{
return false;
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/UIHelper.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/UIHelper.java
index a79697a..347a6b7 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/UIHelper.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/UIHelper.java
@@ -2,25 +2,27 @@
public class UIHelper
{
- public static <T> IElementDescriptor<T> getDefaultElementDescriptor() {
+ public static <T> IElementDescriptor<T> getDefaultElementDescriptor()
+ {
return new IElementDescriptor<T>()
{
- public String getLabel( T element )
+ public String getLabel(T element)
{
return element == null ? "null" : element.toString();
}
-
- public String getName( T element )
+ public String getName(T element)
{
- return getLabel( element );
+ return getLabel(element);
}
};
}
-
- public static <T> IFilter<T> getDefaultFilter() {
- return new IFilter<T> () {
- public boolean select( T element )
+
+ public static <T> IFilter<T> getDefaultFilter()
+ {
+ return new IFilter<T>()
+ {
+ public boolean select(T element)
{
return true;
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/WrappedContentProposal.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/WrappedContentProposal.java
index aafb2c0..ec44762 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/WrappedContentProposal.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/WrappedContentProposal.java
@@ -19,60 +19,51 @@
package org.apache.felix.sigil.eclipse.ui.util;
-
import org.eclipse.jface.fieldassist.IContentProposal;
-
public class WrappedContentProposal<T> implements IContentProposal
{
private final T element;
private final IElementDescriptor<? super T> descriptor;
-
- private WrappedContentProposal( T element, IElementDescriptor<? super T> descriptor )
+ private WrappedContentProposal(T element, IElementDescriptor<? super T> descriptor)
{
this.element = element;
this.descriptor = descriptor;
}
-
- public static <T> WrappedContentProposal<T> newInstance( T element, IElementDescriptor<? super T> descriptor )
+ public static <T> WrappedContentProposal<T> newInstance(T element,
+ IElementDescriptor<? super T> descriptor)
{
- return new WrappedContentProposal<T>( element, descriptor );
+ return new WrappedContentProposal<T>(element, descriptor);
}
-
public String getContent()
{
- return descriptor.getName( element );
+ return descriptor.getName(element);
}
-
public int getCursorPosition()
{
return 0;
}
-
public String getDescription()
{
return null;
}
-
public String getLabel()
{
- return descriptor.getLabel( element );
+ return descriptor.getLabel(element);
}
-
public T getElement()
{
return element;
}
-
@Override
public String toString()
{
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/WrappedContentProposalLabelProvider.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/WrappedContentProposalLabelProvider.java
index b4c4b67..9e1d46f 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/WrappedContentProposalLabelProvider.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/util/WrappedContentProposalLabelProvider.java
@@ -19,53 +19,47 @@
package org.apache.felix.sigil.eclipse.ui.util;
-
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
-
public class WrappedContentProposalLabelProvider<E> extends LabelProvider
{
private final IElementDescriptor<? super E> descriptor;
private final ModelLabelProvider projectLabelProvider;
-
- public WrappedContentProposalLabelProvider( IElementDescriptor<? super E> descriptor )
+ public WrappedContentProposalLabelProvider(IElementDescriptor<? super E> descriptor)
{
this.descriptor = descriptor;
projectLabelProvider = new ModelLabelProvider();
}
-
@SuppressWarnings("unchecked")
- private E adapt( Object element )
+ private E adapt(Object element)
{
E result;
- if ( element instanceof WrappedContentProposal<?> )
+ if (element instanceof WrappedContentProposal<?>)
{
- WrappedContentProposal<?> proposal = (org.apache.felix.sigil.eclipse.ui.util.WrappedContentProposal<?> ) element;
- result = ( E ) proposal.getElement();
+ WrappedContentProposal<?> proposal = (org.apache.felix.sigil.eclipse.ui.util.WrappedContentProposal<?>) element;
+ result = (E) proposal.getElement();
}
else
{
- result = ( E ) element;
+ result = (E) element;
}
return result;
}
-
@Override
- public Image getImage( Object element )
+ public Image getImage(Object element)
{
- Object value = adapt( element );
- return projectLabelProvider.getImage( value );
+ Object value = adapt(element);
+ return projectLabelProvider.getImage(value);
}
-
@Override
- public String getText( Object element )
+ public String getText(Object element)
{
- return descriptor.getLabel( adapt( element ) );
+ return descriptor.getLabel(adapt(element));
}
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/project/SigilProjectWizard.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/project/SigilProjectWizard.java
index 07fdd73..3284e4e 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/project/SigilProjectWizard.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/project/SigilProjectWizard.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.wizard.project;
-
import org.apache.felix.sigil.eclipse.SigilCore;
import org.apache.felix.sigil.eclipse.ui.internal.wizard.SigilNewResourceWizard;
import org.eclipse.core.resources.IFile;
@@ -41,7 +40,6 @@
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
-
/**
* @author dave
*
@@ -54,50 +52,48 @@
private String name;
- public static final IPath SIGIL_PROJECT_PATH = new Path( SigilCore.SIGIL_PROJECT_FILE );
+ public static final IPath SIGIL_PROJECT_PATH = new Path(SigilCore.SIGIL_PROJECT_FILE);
private IConfigurationElement config;
-
- public void init( IWorkbench workbench, IStructuredSelection currentSelection )
+ public void init(IWorkbench workbench, IStructuredSelection currentSelection)
{
- super.init( workbench, currentSelection );
+ super.init(workbench, currentSelection);
firstPage = new SigilProjectWizardFirstPage();
- firstPage.setInitialProjectName( name );
- secondPage = new SigilProjectWizardSecondPage( firstPage );
+ firstPage.setInitialProjectName(name);
+ secondPage = new SigilProjectWizardSecondPage(firstPage);
- addPage( firstPage );
- addPage( secondPage );
+ addPage(firstPage);
+ addPage(secondPage);
}
-
- private void finishPage( IProgressMonitor monitor ) throws CoreException, InterruptedException
+ private void finishPage(IProgressMonitor monitor) throws CoreException,
+ InterruptedException
{
- secondPage.performFinish( monitor );
+ secondPage.performFinish(monitor);
IProject newProject = firstPage.getProjectHandle();
- if ( newProject != null && newProject.exists() )
+ if (newProject != null && newProject.exists())
{
- IFile file = newProject.getFile( SigilProjectWizard.SIGIL_PROJECT_PATH );
+ IFile file = newProject.getFile(SigilProjectWizard.SIGIL_PROJECT_PATH);
- selectRevealAndShow( file );
+ selectRevealAndShow(file);
// don't do this check for now - see FELIX-1924
-// new Job( "Check OSGi Install" )
-// {
-// @Override
-// protected IStatus run( IProgressMonitor monitor )
-// {
-// // prompt for osgi home if not already set.
-// SigilCore.getInstallManager().getDefaultInstall();
-// return Status.OK_STATUS;
-// }
-// }.schedule();
+ // new Job( "Check OSGi Install" )
+ // {
+ // @Override
+ // protected IStatus run( IProgressMonitor monitor )
+ // {
+ // // prompt for osgi home if not already set.
+ // SigilCore.getInstallManager().getDefaultInstall();
+ // return Status.OK_STATUS;
+ // }
+ // }.schedule();
}
}
-
/* (non-Javadoc)
* @see org.eclipse.jface.wizard.Wizard#performFinish()
*/
@@ -108,46 +104,43 @@
IWorkspaceRunnable op = new IWorkspaceRunnable()
{
- public void run( IProgressMonitor monitor ) throws CoreException
+ public void run(IProgressMonitor monitor) throws CoreException
{
try
{
- finishPage( monitor );
+ finishPage(monitor);
}
- catch ( InterruptedException e )
+ catch (InterruptedException e)
{
- throw new OperationCanceledException( e.getMessage() );
+ throw new OperationCanceledException(e.getMessage());
}
}
};
try
{
- workspace.run( op, Job.getJobManager().createProgressGroup() );
+ workspace.run(op, Job.getJobManager().createProgressGroup());
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- SigilCore.error( "Failed to complete project wizard", e );
+ SigilCore.error("Failed to complete project wizard", e);
return false;
}
- BasicNewProjectResourceWizard.updatePerspective( config );
+ BasicNewProjectResourceWizard.updatePerspective(config);
return true;
}
-
- public void setName( String name )
+ public void setName(String name)
{
this.name = name;
}
-
public String getName()
{
return name;
}
-
@Override
public boolean performCancel()
{
@@ -155,9 +148,8 @@
return super.performCancel();
}
-
- public void setInitializationData( IConfigurationElement config, String propertyName, Object data )
- throws CoreException
+ public void setInitializationData(IConfigurationElement config, String propertyName,
+ Object data) throws CoreException
{
this.config = config;
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/project/SigilProjectWizardFirstPage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/project/SigilProjectWizardFirstPage.java
index ec7e27a..19fdd13 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/project/SigilProjectWizardFirstPage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/project/SigilProjectWizardFirstPage.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.wizard.project;
-
import org.apache.felix.sigil.common.osgi.VersionTable;
import org.apache.felix.sigil.eclipse.ui.internal.views.RepositoryViewPart;
import org.eclipse.core.resources.IWorkspace;
@@ -41,7 +40,6 @@
import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
import org.osgi.framework.Version;
-
/**
* @author dave
*
@@ -50,7 +48,7 @@
{
private volatile String description = "";
- private volatile Version version = VersionTable.getVersion( 1, 0, 0 );
+ private volatile Version version = VersionTable.getVersion(1, 0, 0);
private volatile String vendor = "";
private volatile String name = "";
@@ -59,26 +57,24 @@
private Text txtVendor;
private Text txtName;
-
public SigilProjectWizardFirstPage()
{
- super( "newSigilProjectPage" );
- setTitle( "Sigil Project" );
- setDescription( "Create a new Sigil project" );
- setImageDescriptor( ImageDescriptor.createFromFile( RepositoryViewPart.class, "/icons/logo64x64.gif" ) );
+ super("newSigilProjectPage");
+ setTitle("Sigil Project");
+ setDescription("Create a new Sigil project");
+ setImageDescriptor(ImageDescriptor.createFromFile(RepositoryViewPart.class,
+ "/icons/logo64x64.gif"));
}
-
public boolean isInWorkspace()
{
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IPath defaultDefaultLocation = workspace.getRoot().getLocation();
- return defaultDefaultLocation.isPrefixOf( getLocationPath() );
+ return defaultDefaultLocation.isPrefixOf(getLocationPath());
}
-
@Override
public boolean isPageComplete()
{
@@ -86,54 +82,56 @@
return result;
}
-
@Override
- public void createControl( Composite parent )
+ public void createControl(Composite parent)
{
FieldDecoration infoDecor = FieldDecorationRegistry.getDefault().getFieldDecoration(
- FieldDecorationRegistry.DEC_INFORMATION );
+ FieldDecorationRegistry.DEC_INFORMATION);
// Create controls
- super.createControl( parent );
- Composite control = ( Composite ) getControl();
+ super.createControl(parent);
+ Composite control = (Composite) getControl();
- Group grpProjectSettings = new Group( control, SWT.NONE );
- grpProjectSettings.setText( "Project Settings" );
+ Group grpProjectSettings = new Group(control, SWT.NONE);
+ grpProjectSettings.setText("Project Settings");
- new Label( grpProjectSettings, SWT.NONE ).setText( "Version:" );
- txtVersion = new Text( grpProjectSettings, SWT.BORDER );
+ new Label(grpProjectSettings, SWT.NONE).setText("Version:");
+ txtVersion = new Text(grpProjectSettings, SWT.BORDER);
- new Label( grpProjectSettings, SWT.NONE ).setText( "Name:" );
- txtName = new Text( grpProjectSettings, SWT.BORDER );
+ new Label(grpProjectSettings, SWT.NONE).setText("Name:");
+ txtName = new Text(grpProjectSettings, SWT.BORDER);
- ControlDecoration txtNameDecor = new ControlDecoration( txtName, SWT.LEFT | SWT.CENTER );
- txtNameDecor.setImage( infoDecor.getImage() );
- txtNameDecor.setDescriptionText( "Defines a human-readable name for the bundle" );
+ ControlDecoration txtNameDecor = new ControlDecoration(txtName, SWT.LEFT
+ | SWT.CENTER);
+ txtNameDecor.setImage(infoDecor.getImage());
+ txtNameDecor.setDescriptionText("Defines a human-readable name for the bundle");
- new Label( grpProjectSettings, SWT.NONE ).setText( "Description:" );
- txtDescription = new Text( grpProjectSettings, SWT.BORDER );
+ new Label(grpProjectSettings, SWT.NONE).setText("Description:");
+ txtDescription = new Text(grpProjectSettings, SWT.BORDER);
- ControlDecoration txtDescDecor = new ControlDecoration( txtDescription, SWT.LEFT | SWT.CENTER );
- txtDescDecor.setImage( infoDecor.getImage() );
- txtDescDecor.setDescriptionText( "Defines a short human-readable description for the bundle" );
+ ControlDecoration txtDescDecor = new ControlDecoration(txtDescription, SWT.LEFT
+ | SWT.CENTER);
+ txtDescDecor.setImage(infoDecor.getImage());
+ txtDescDecor.setDescriptionText("Defines a short human-readable description for the bundle");
- new Label( grpProjectSettings, SWT.NONE ).setText( "Provider:" );
- txtVendor = new Text( grpProjectSettings, SWT.BORDER );
+ new Label(grpProjectSettings, SWT.NONE).setText("Provider:");
+ txtVendor = new Text(grpProjectSettings, SWT.BORDER);
- ControlDecoration txtVendorDecor = new ControlDecoration( txtVendor, SWT.LEFT | SWT.CENTER );
- txtVendorDecor.setImage( infoDecor.getImage() );
- txtVendorDecor.setDescriptionText( "The name of the company, organisation or individual providing the bundle" );
+ ControlDecoration txtVendorDecor = new ControlDecoration(txtVendor, SWT.LEFT
+ | SWT.CENTER);
+ txtVendorDecor.setImage(infoDecor.getImage());
+ txtVendorDecor.setDescriptionText("The name of the company, organisation or individual providing the bundle");
// Set values
- txtDescription.setText( description );
- txtVersion.setText( version.toString() );
- txtVendor.setText( vendor );
- txtName.setText( name );
+ txtDescription.setText(description);
+ txtVersion.setText(version.toString());
+ txtVendor.setText(vendor);
+ txtName.setText(name);
// Add listeners
ModifyListener txtModListener = new ModifyListener()
{
- public void modifyText( ModifyEvent e )
+ public void modifyText(ModifyEvent e)
{
description = txtDescription.getText();
vendor = txtVendor.getText();
@@ -142,59 +140,54 @@
validateSettings();
}
};
- txtDescription.addModifyListener( txtModListener );
- txtVersion.addModifyListener( txtModListener );
- txtVendor.addModifyListener( txtModListener );
- txtName.addModifyListener( txtModListener );
+ txtDescription.addModifyListener(txtModListener);
+ txtVersion.addModifyListener(txtModListener);
+ txtVendor.addModifyListener(txtModListener);
+ txtName.addModifyListener(txtModListener);
// Layout
- control.setLayout( new GridLayout() );
- grpProjectSettings.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
- grpProjectSettings.setLayout( new GridLayout( 2, false ) );
- txtDescription.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
- txtVersion.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
- txtVendor.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
- txtName.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, false ) );
+ control.setLayout(new GridLayout());
+ grpProjectSettings.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ grpProjectSettings.setLayout(new GridLayout(2, false));
+ txtDescription.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ txtVersion.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ txtVendor.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
+ txtName.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
}
-
private void validateSettings()
{
try
{
- version = VersionTable.getVersion( txtVersion.getText() );
+ version = VersionTable.getVersion(txtVersion.getText());
}
- catch ( IllegalArgumentException e )
+ catch (IllegalArgumentException e)
{
version = null;
- setErrorMessage( "Invalid version" );
- setPageComplete( false );
+ setErrorMessage("Invalid version");
+ setPageComplete(false);
return;
}
- setErrorMessage( null );
- setPageComplete( true );
+ setErrorMessage(null);
+ setPageComplete(true);
}
-
public Version getVersion()
{
return version;
}
-
public String getVendor()
{
return vendor;
}
-
public String getDescription()
{
return description;
}
-
public String getName()
{
return name;
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/project/SigilProjectWizardSecondPage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/project/SigilProjectWizardSecondPage.java
index 3ab5b22..90c434a 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/project/SigilProjectWizardSecondPage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/project/SigilProjectWizardSecondPage.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.wizard.project;
-
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
@@ -48,7 +47,6 @@
import org.eclipse.jdt.ui.wizards.JavaCapabilityConfigurationPage;
import org.osgi.framework.Version;
-
/**
* @author dave
*
@@ -61,18 +59,16 @@
private URI currentProjectLocation;
private boolean created;
-
- public SigilProjectWizardSecondPage( SigilProjectWizardFirstPage firstPage )
+ public SigilProjectWizardSecondPage(SigilProjectWizardFirstPage firstPage)
{
this.firstPage = firstPage;
}
-
@Override
- public void setVisible( boolean visible )
+ public void setVisible(boolean visible)
{
- super.setVisible( visible );
- if ( visible )
+ super.setVisible(visible);
+ if (visible)
{
changeToNewProject();
}
@@ -82,69 +78,66 @@
}
}
-
@Override
protected boolean useNewSourcePage()
{
return true;
}
-
- protected void performFinish( IProgressMonitor monitor ) throws CoreException, InterruptedException
+ protected void performFinish(IProgressMonitor monitor) throws CoreException,
+ InterruptedException
{
changeToNewProject();
- updateProject( monitor );
+ updateProject(monitor);
}
-
private void changeToNewProject()
{
- if ( !created )
+ if (!created)
{
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRunnable op = new IWorkspaceRunnable()
{
- public void run( IProgressMonitor monitor ) throws CoreException
+ public void run(IProgressMonitor monitor) throws CoreException
{
try
{
- updateProject( monitor );
+ updateProject(monitor);
}
- catch ( InterruptedException e )
+ catch (InterruptedException e)
{
- throw new OperationCanceledException( e.getMessage() );
+ throw new OperationCanceledException(e.getMessage());
}
}
};
try
{
- workspace.run( op, Job.getJobManager().createProgressGroup() );
- setErrorMessage( null );
- setPageComplete( true );
+ workspace.run(op, Job.getJobManager().createProgressGroup());
+ setErrorMessage(null);
+ setPageComplete(true);
created = true;
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- SigilCore.error( "Failed to run workspace job", e );
+ SigilCore.error("Failed to run workspace job", e);
}
}
}
-
private void removeProject()
{
- if ( currentProject == null || !currentProject.exists() )
+ if (currentProject == null || !currentProject.exists())
{
return;
}
IWorkspaceRunnable op = new IWorkspaceRunnable()
{
- public void run( IProgressMonitor monitor ) throws CoreException
+ public void run(IProgressMonitor monitor) throws CoreException
{
- doRemoveProject( monitor );
+ doRemoveProject(monitor);
}
};
@@ -152,11 +145,11 @@
try
{
- workspace.run( op, Job.getJobManager().createProgressGroup() );
+ workspace.run(op, Job.getJobManager().createProgressGroup());
}
- catch ( CoreException e )
+ catch (CoreException e)
{
- SigilCore.error( "Failed to run workspace job", e );
+ SigilCore.error("Failed to run workspace job", e);
}
finally
{
@@ -164,8 +157,8 @@
}
}
-
- private void updateProject( IProgressMonitor monitor ) throws CoreException, InterruptedException
+ private void updateProject(IProgressMonitor monitor) throws CoreException,
+ InterruptedException
{
currentProject = firstPage.getProjectHandle();
currentProjectLocation = getProjectLocationURI();
@@ -175,58 +168,58 @@
String vendor = firstPage.getVendor();
String name = firstPage.getName();
- createProject( currentProject, currentProjectLocation, monitor );
+ createProject(currentProject, currentProjectLocation, monitor);
IPath src = createSourcePath();
IPath output = getOutputLocation();
- if ( output.segmentCount() == 0 )
+ if (output.segmentCount() == 0)
{
- output = new Path( currentProject.getName() ).append( "build" ).append( "classes" );
+ output = new Path(currentProject.getName()).append("build").append("classes");
}
- IClasspathEntry[] entries = getProjectClassPath( src );
+ IClasspathEntry[] entries = getProjectClassPath(src);
- SigilCore.makeSigilProject( currentProject, monitor );
+ SigilCore.makeSigilProject(currentProject, monitor);
- init( JavaCore.create( currentProject ), output.makeRelative(), entries, false );
+ init(JavaCore.create(currentProject), output.makeRelative(), entries, false);
- configureJavaProject( new SubProgressMonitor( monitor, 3 ) );
+ configureJavaProject(new SubProgressMonitor(monitor, 3));
- configureSigilProject( currentProject, description, projectVersion, vendor, name, src, monitor );
+ configureSigilProject(currentProject, description, projectVersion, vendor, name,
+ src, monitor);
}
-
private IPath createSourcePath() throws CoreException
{
IPath projectPath = currentProject.getFullPath();
- IPath src = new Path( "src" );
- IFolder f = currentProject.getFolder( src );
- if ( !f.getLocation().toFile().exists() )
+ IPath src = new Path("src");
+ IFolder f = currentProject.getFolder(src);
+ if (!f.getLocation().toFile().exists())
{
- f.create( true, true, null );
+ f.create(true, true, null);
}
- return projectPath.append( src );
+ return projectPath.append(src);
}
-
- final void doRemoveProject( IProgressMonitor monitor ) throws CoreException
+ final void doRemoveProject(IProgressMonitor monitor) throws CoreException
{
- final boolean noProgressMonitor = ( currentProjectLocation == null ); // inside workspace
+ final boolean noProgressMonitor = (currentProjectLocation == null); // inside workspace
- if ( monitor == null || noProgressMonitor )
+ if (monitor == null || noProgressMonitor)
{
monitor = new NullProgressMonitor();
}
- monitor.beginTask( "Remove project", 3 );
+ monitor.beginTask("Remove project", 3);
try
{
try
{
- boolean removeContent = currentProject.isSynchronized( IResource.DEPTH_INFINITE );
- currentProject.delete( removeContent, false, new SubProgressMonitor( monitor, 2 ) );
+ boolean removeContent = currentProject.isSynchronized(IResource.DEPTH_INFINITE);
+ currentProject.delete(removeContent, false, new SubProgressMonitor(
+ monitor, 2));
}
finally
@@ -240,19 +233,18 @@
}
}
-
- private IClasspathEntry[] getProjectClassPath( IPath src ) throws CoreException
+ private IClasspathEntry[] getProjectClassPath(IPath src) throws CoreException
{
List<IClasspathEntry> cpEntries = new ArrayList<IClasspathEntry>();
- cpEntries.add( JavaCore.newSourceEntry( src ) );
- cpEntries.addAll( Arrays.asList( getDefaultClasspathEntry() ) );
- cpEntries.add( JavaCore.newContainerEntry( new Path( SigilCore.CLASSPATH_CONTAINER_PATH ) ) );
- IClasspathEntry[] entries = cpEntries.toArray( new IClasspathEntry[cpEntries.size()] );
+ cpEntries.add(JavaCore.newSourceEntry(src));
+ cpEntries.addAll(Arrays.asList(getDefaultClasspathEntry()));
+ cpEntries.add(JavaCore.newContainerEntry(new Path(
+ SigilCore.CLASSPATH_CONTAINER_PATH)));
+ IClasspathEntry[] entries = cpEntries.toArray(new IClasspathEntry[cpEntries.size()]);
return entries;
}
-
private IClasspathEntry[] getDefaultClasspathEntry()
{
IClasspathEntry[] defaultJRELibrary = PreferenceConstants.getDefaultJRELibrary();
@@ -270,47 +262,45 @@
return defaultJRELibrary;
}
-
- private void configureSigilProject( IProject project, String description, Version projectVersion,
- String vendorName, String bundleName, IPath src, IProgressMonitor monitor ) throws CoreException
+ private void configureSigilProject(IProject project, String description,
+ Version projectVersion, String vendorName, String bundleName, IPath src,
+ IProgressMonitor monitor) throws CoreException
{
- ISigilProjectModel sigil = SigilCore.create( project );
- IClasspathEntry cp = JavaCore.newSourceEntry( src );
- String encodedClasspath = sigil.getJavaModel().encodeClasspathEntry( cp );
+ ISigilProjectModel sigil = SigilCore.create(project);
+ IClasspathEntry cp = JavaCore.newSourceEntry(src);
+ String encodedClasspath = sigil.getJavaModel().encodeClasspathEntry(cp);
ISigilBundle bundle = sigil.getBundle();
- bundle.addClasspathEntry( encodedClasspath );
+ bundle.addClasspathEntry(encodedClasspath);
- if ( description != null )
+ if (description != null)
{
- bundle.getBundleInfo().setDescription( description );
+ bundle.getBundleInfo().setDescription(description);
}
- if ( projectVersion != null )
+ if (projectVersion != null)
{
- bundle.setVersion( projectVersion );
+ bundle.setVersion(projectVersion);
}
- if ( vendorName != null )
+ if (vendorName != null)
{
- bundle.getBundleInfo().setVendor( vendorName );
+ bundle.getBundleInfo().setVendor(vendorName);
}
- if ( bundleName != null )
+ if (bundleName != null)
{
- bundle.getBundleInfo().setName( bundleName );
+ bundle.getBundleInfo().setName(bundleName);
}
- sigil.save( monitor );
+ sigil.save(monitor);
}
-
private URI getProjectLocationURI() throws CoreException
{
- if ( firstPage.isInWorkspace() )
+ if (firstPage.isInWorkspace())
{
return null;
}
return firstPage.getLocationURI();
}
-
@Override
public boolean isPageComplete()
{
@@ -318,10 +308,9 @@
return result;
}
-
protected void performCancel()
{
- if ( currentProject != null )
+ if (currentProject != null)
{
removeProject();
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/repository/RepositoryWizard.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/repository/RepositoryWizard.java
index 9b06878..eeda6b5 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/repository/RepositoryWizard.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/repository/RepositoryWizard.java
@@ -19,40 +19,35 @@
package org.apache.felix.sigil.eclipse.ui.wizard.repository;
-
import org.apache.felix.sigil.eclipse.model.repository.IRepositoryModel;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.Wizard;
-
public class RepositoryWizard extends Wizard
{
private IRepositoryModel model;
-
@Override
public boolean performFinish()
{
- for ( IWizardPage page : getPages() )
+ for (IWizardPage page : getPages())
{
- if ( page instanceof RepositoryWizardPage )
+ if (page instanceof RepositoryWizardPage)
{
- RepositoryWizardPage rwp = ( RepositoryWizardPage ) page;
+ RepositoryWizardPage rwp = (RepositoryWizardPage) page;
rwp.storeFields();
}
}
return true;
}
-
public IRepositoryModel getModel()
{
return model;
}
-
- public void init( IRepositoryModel model )
+ public void init(IRepositoryModel model)
{
this.model = model;
}
diff --git a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/repository/RepositoryWizardPage.java b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/repository/RepositoryWizardPage.java
index 200d31c..0a89a61 100644
--- a/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/repository/RepositoryWizardPage.java
+++ b/sigil/eclipse/ui/src/org/apache/felix/sigil/eclipse/ui/wizard/repository/RepositoryWizardPage.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.eclipse.ui.wizard.repository;
-
import java.util.ArrayList;
import org.apache.felix.sigil.eclipse.model.repository.IRepositoryModel;
@@ -32,7 +31,6 @@
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
-
public abstract class RepositoryWizardPage extends WizardPage
{
@@ -40,93 +38,86 @@
private ArrayList<FieldEditor> editors = new ArrayList<FieldEditor>();
private RepositoryWizard wizard;
-
- protected RepositoryWizardPage( String pageName, RepositoryWizard parent )
+ protected RepositoryWizardPage(String pageName, RepositoryWizard parent)
{
- super( pageName );
- setTitle( pageName );
+ super(pageName);
+ setTitle(pageName);
this.wizard = parent;
}
-
public abstract void createFieldEditors();
-
- public void addField( FieldEditor editor )
+ public void addField(FieldEditor editor)
{
- editors.add( editor );
+ editors.add(editor);
}
-
- public void createControl( Composite parent )
+ public void createControl(Composite parent)
{
- Composite control = new Composite( parent, SWT.NONE );
- setControl( control );
+ Composite control = new Composite(parent, SWT.NONE);
+ setControl(control);
- if ( getModel().getType().isDynamic() )
+ if (getModel().getType().isDynamic())
{
- nameEditor = new StringFieldEditor( "name", "Name:", control );
- nameEditor.setStringValue( getModel().getName() );
- nameEditor.getTextControl( getFieldEditorParent() ).addModifyListener( new ModifyListener()
- {
- public void modifyText( ModifyEvent e )
+ nameEditor = new StringFieldEditor("name", "Name:", control);
+ nameEditor.setStringValue(getModel().getName());
+ nameEditor.getTextControl(getFieldEditorParent()).addModifyListener(
+ new ModifyListener()
{
- checkPageComplete();
- }
- } );
+ public void modifyText(ModifyEvent e)
+ {
+ checkPageComplete();
+ }
+ });
}
createFieldEditors();
int cols = nameEditor == null ? 0 : nameEditor.getNumberOfControls();
- for ( FieldEditor e : editors )
+ for (FieldEditor e : editors)
{
- cols = Math.max( cols, e.getNumberOfControls() );
+ cols = Math.max(cols, e.getNumberOfControls());
}
- control.setLayout( new GridLayout( cols, false ) );
+ control.setLayout(new GridLayout(cols, false));
- if ( nameEditor != null )
+ if (nameEditor != null)
{
- nameEditor.fillIntoGrid( getFieldEditorParent(), cols );
+ nameEditor.fillIntoGrid(getFieldEditorParent(), cols);
}
- for ( FieldEditor e : editors )
+ for (FieldEditor e : editors)
{
- e.fillIntoGrid( getFieldEditorParent(), cols );
- e.setPreferenceStore( getModel().getPreferences() );
+ e.fillIntoGrid(getFieldEditorParent(), cols);
+ e.setPreferenceStore(getModel().getPreferences());
e.load();
}
checkPageComplete();
}
-
protected void checkPageComplete()
{
- if ( nameEditor != null )
+ if (nameEditor != null)
{
- setPageComplete( nameEditor.getStringValue().length() > 0 );
+ setPageComplete(nameEditor.getStringValue().length() > 0);
}
}
-
public IRepositoryModel getModel()
{
return wizard.getModel();
}
-
protected Composite getFieldEditorParent()
{
- return ( Composite ) getControl();
+ return (Composite) getControl();
}
-
public void storeFields()
{
- getModel().setName( nameEditor.getStringValue() );
- for ( FieldEditor e : editors )
+ getModel().setName(nameEditor.getStringValue());
+ for (FieldEditor e : editors)
{
e.store();
}
diff --git a/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/GlobCompiler.java b/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/GlobCompiler.java
index 4f47962..ff64cd1 100644
--- a/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/GlobCompiler.java
+++ b/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/GlobCompiler.java
@@ -19,44 +19,42 @@
package org.apache.felix.sigil.utils;
-
import java.util.regex.Pattern;
-
public class GlobCompiler
{
- public static final Pattern compile( String glob )
+ public static final Pattern compile(String glob)
{
char[] chars = glob.toCharArray();
- if ( chars.length > 0 )
+ if (chars.length > 0)
{
- StringBuilder builder = new StringBuilder( chars.length + 5 );
+ StringBuilder builder = new StringBuilder(chars.length + 5);
- builder.append( '^' );
+ builder.append('^');
- for ( char c : chars )
+ for (char c : chars)
{
- switch ( c )
+ switch (c)
{
case '*':
- builder.append( ".*" );
+ builder.append(".*");
break;
case '.':
- builder.append( "\\." );
+ builder.append("\\.");
break;
case '$':
- builder.append( "\\$" );
+ builder.append("\\$");
break;
default:
- builder.append( c );
+ builder.append(c);
}
}
- return Pattern.compile( builder.toString() );
+ return Pattern.compile(builder.toString());
}
else
{
- return Pattern.compile( glob );
+ return Pattern.compile(glob);
}
}
}
diff --git a/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/PathHelper.java b/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/PathHelper.java
index f40929d..2cb2772 100644
--- a/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/PathHelper.java
+++ b/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/PathHelper.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.utils;
-
import java.io.File;
import java.util.List;
import java.util.regex.Pattern;
@@ -27,23 +26,23 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
-
public class PathHelper
{
- public static void scanFiles( List<IPath> paths, IPath path, String pattern, boolean recurse )
+ public static void scanFiles(List<IPath> paths, IPath path, String pattern,
+ boolean recurse)
{
- Pattern p = GlobCompiler.compile( pattern );
+ Pattern p = GlobCompiler.compile(pattern);
- for ( File f : path.toFile().listFiles() )
+ for (File f : path.toFile().listFiles())
{
- if ( f.isDirectory() && recurse )
+ if (f.isDirectory() && recurse)
{
- scanFiles( paths, new Path( f.getAbsolutePath() ), pattern, recurse );
+ scanFiles(paths, new Path(f.getAbsolutePath()), pattern, recurse);
}
- else if ( f.isFile() && p.matcher( f.getName() ).matches() )
+ else if (f.isFile() && p.matcher(f.getName()).matches())
{
- paths.add( new Path( f.getAbsolutePath() ) );
+ paths.add(new Path(f.getAbsolutePath()));
}
}
}
diff --git a/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/SigilUtils.java b/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/SigilUtils.java
index 51524e1..480d102 100644
--- a/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/SigilUtils.java
+++ b/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/SigilUtils.java
@@ -19,25 +19,23 @@
package org.apache.felix.sigil.utils;
-
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.content.IContentType;
-
public final class SigilUtils
{
private SigilUtils()
{
}
-
- public static boolean isResourceType( IResource resource, String type )
+ public static boolean isResourceType(IResource resource, String type)
{
- IContentType[] types = Platform.getContentTypeManager().findContentTypesFor( resource.getName() );
- for ( IContentType contentType : types )
+ IContentType[] types = Platform.getContentTypeManager().findContentTypesFor(
+ resource.getName());
+ for (IContentType contentType : types)
{
- if ( contentType.getId().equals( type ) )
+ if (contentType.getId().equals(type))
{
return true;
}
diff --git a/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/properties/EditorPropertyTester.java b/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/properties/EditorPropertyTester.java
index a94f511..647a317 100644
--- a/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/properties/EditorPropertyTester.java
+++ b/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/properties/EditorPropertyTester.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.utils.properties;
-
import org.apache.felix.sigil.utils.SigilUtils;
import org.eclipse.core.expressions.PropertyTester;
import org.eclipse.core.resources.IFile;
@@ -28,26 +27,26 @@
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IWorkbenchPart;
-
public class EditorPropertyTester extends PropertyTester
{
- public boolean test( Object receiver, String property, Object[] args, Object expectedValue )
+ public boolean test(Object receiver, String property, Object[] args,
+ Object expectedValue)
{
- IWorkbenchPart part = ( IWorkbenchPart ) receiver;
+ IWorkbenchPart part = (IWorkbenchPart) receiver;
boolean result = false;
- if ( part instanceof IEditorPart )
+ if (part instanceof IEditorPart)
{
- IEditorInput input = ( ( IEditorPart ) part ).getEditorInput();
- if ( input instanceof IFileEditorInput )
+ IEditorInput input = ((IEditorPart) part).getEditorInput();
+ if (input instanceof IFileEditorInput)
{
- IFile file = ( ( IFileEditorInput ) input ).getFile();
+ IFile file = ((IFileEditorInput) input).getFile();
- if ( "isEditorOfType".equals( property ) )
+ if ("isEditorOfType".equals(property))
{
- result = SigilUtils.isResourceType( file, ( String ) expectedValue );
+ result = SigilUtils.isResourceType(file, (String) expectedValue);
}
}
}
diff --git a/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/properties/PartKindPropertyTester.java b/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/properties/PartKindPropertyTester.java
index 92653b1..d48542b 100644
--- a/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/properties/PartKindPropertyTester.java
+++ b/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/properties/PartKindPropertyTester.java
@@ -19,28 +19,27 @@
package org.apache.felix.sigil.utils.properties;
-
import org.eclipse.core.expressions.PropertyTester;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPart;
-
public class PartKindPropertyTester extends PropertyTester
{
- public boolean test( Object receiver, String property, Object[] args, Object expectedValue )
+ public boolean test(Object receiver, String property, Object[] args,
+ Object expectedValue)
{
- IWorkbenchPart part = ( IWorkbenchPart ) receiver;
+ IWorkbenchPart part = (IWorkbenchPart) receiver;
Object value;
- if ( "partKind".equals( property ) )
+ if ("partKind".equals(property))
{
- if ( part instanceof IEditorPart )
+ if (part instanceof IEditorPart)
{
value = "editor";
}
- else if ( part instanceof IViewPart )
+ else if (part instanceof IViewPart)
{
value = "view";
}
@@ -49,7 +48,7 @@
value = null;
}
}
- else if ( "partId".equals( property ) )
+ else if ("partId".equals(property))
{
value = part.getSite().getId();
}
@@ -58,7 +57,7 @@
value = null;
}
- return expectedValue.equals( value );
+ return expectedValue.equals(value);
}
}
diff --git a/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/properties/ResourceTypePropertyTester.java b/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/properties/ResourceTypePropertyTester.java
index 3c35b5d..13c13f3 100644
--- a/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/properties/ResourceTypePropertyTester.java
+++ b/sigil/eclipse/utils/src/org/apache/felix/sigil/utils/properties/ResourceTypePropertyTester.java
@@ -19,33 +19,33 @@
package org.apache.felix.sigil.utils.properties;
-
import org.eclipse.core.expressions.PropertyTester;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.content.IContentType;
-
public class ResourceTypePropertyTester extends PropertyTester
{
- public boolean test( Object receiver, String property, Object[] args, Object expectedValue )
+ public boolean test(Object receiver, String property, Object[] args,
+ Object expectedValue)
{
- if ( !( receiver instanceof IResource ) )
+ if (!(receiver instanceof IResource))
{
return false;
}
boolean result = false;
- IResource resource = ( IResource ) receiver;
- if ( "isResourceOfType".equals( property ) )
+ IResource resource = (IResource) receiver;
+ if ("isResourceOfType".equals(property))
{
- IContentType[] types = Platform.getContentTypeManager().findContentTypesFor( resource.getName() );
+ IContentType[] types = Platform.getContentTypeManager().findContentTypesFor(
+ resource.getName());
- for ( IContentType type : types )
+ for (IContentType type : types)
{
- if ( type.getId().equals( expectedValue ) )
+ if (type.getId().equals(expectedValue))
{
result = true;
break;
diff --git a/sigil/gogo/junit/src/org/apache/felix/sigil/gogo/junit/Activator.java b/sigil/gogo/junit/src/org/apache/felix/sigil/gogo/junit/Activator.java
index c722374..cee4020 100644
--- a/sigil/gogo/junit/src/org/apache/felix/sigil/gogo/junit/Activator.java
+++ b/sigil/gogo/junit/src/org/apache/felix/sigil/gogo/junit/Activator.java
@@ -33,37 +33,40 @@
public class Activator implements BundleActivator
{
- public void start( final BundleContext ctx ) throws Exception
+ public void start(final BundleContext ctx) throws Exception
{
final Hashtable props = new Hashtable();
props.put(CommandProcessor.COMMAND_SCOPE, "sigil");
props.put(CommandProcessor.COMMAND_FUNCTION, new String[] { "junit" });
-
- ServiceTracker tracker = new ServiceTracker(ctx, JUnitService.class.getName(), null) {
+
+ ServiceTracker tracker = new ServiceTracker(ctx, JUnitService.class.getName(),
+ null)
+ {
private Map<ServiceReference, ServiceRegistration> regs;
@Override
- public Object addingService( ServiceReference reference )
+ public Object addingService(ServiceReference reference)
{
- JUnitService svc = ( JUnitService ) super.addingService( reference );
- ServiceRegistration reg = ctx.registerService( SigilJunit.class.getName(), new SigilJunit(svc), props );
+ JUnitService svc = (JUnitService) super.addingService(reference);
+ ServiceRegistration reg = ctx.registerService(SigilJunit.class.getName(),
+ new SigilJunit(svc), props);
regs.put(reference, reg);
return svc;
}
@Override
- public void removedService( ServiceReference reference, Object service )
+ public void removedService(ServiceReference reference, Object service)
{
- ServiceRegistration reg = regs.remove( reference );
+ ServiceRegistration reg = regs.remove(reference);
reg.unregister();
- super.removedService( reference, service );
+ super.removedService(reference, service);
}
-
+
};
tracker.open();
}
- public void stop( BundleContext ctx ) throws Exception
+ public void stop(BundleContext ctx) throws Exception
{
}
diff --git a/sigil/gogo/junit/src/org/apache/felix/sigil/gogo/junit/PrintListener.java b/sigil/gogo/junit/src/org/apache/felix/sigil/gogo/junit/PrintListener.java
index 9bcad4a..627dcda 100644
--- a/sigil/gogo/junit/src/org/apache/felix/sigil/gogo/junit/PrintListener.java
+++ b/sigil/gogo/junit/src/org/apache/felix/sigil/gogo/junit/PrintListener.java
@@ -22,30 +22,35 @@
import junit.framework.Test;
import junit.framework.TestListener;
-public class PrintListener implements TestListener {
+public class PrintListener implements TestListener
+{
- public PrintListener() {
+ public PrintListener()
+ {
}
- public void startTest(Test test) {
- System.out.println( "Start " + test );
+ public void startTest(Test test)
+ {
+ System.out.println("Start " + test);
System.out.flush();
}
- public void endTest(Test test) {
- System.out.println( "End " + test );
+ public void endTest(Test test)
+ {
+ System.out.println("End " + test);
System.out.flush();
}
-
- public void addError(Test test, Throwable t) {
- System.out.println( "Error " + test );
+ public void addError(Test test, Throwable t)
+ {
+ System.out.println("Error " + test);
t.printStackTrace(System.out);
System.out.flush();
}
- public void addFailure(Test test, AssertionFailedError error) {
- System.out.println( "Failure " + test + ": " + error.getMessage() );
+ public void addFailure(Test test, AssertionFailedError error)
+ {
+ System.out.println("Failure " + test + ": " + error.getMessage());
System.out.flush();
}
}
diff --git a/sigil/gogo/junit/src/org/apache/felix/sigil/gogo/junit/SigilJunit.java b/sigil/gogo/junit/src/org/apache/felix/sigil/gogo/junit/SigilJunit.java
index dd55e4a..f13839e 100644
--- a/sigil/gogo/junit/src/org/apache/felix/sigil/gogo/junit/SigilJunit.java
+++ b/sigil/gogo/junit/src/org/apache/felix/sigil/gogo/junit/SigilJunit.java
@@ -39,82 +39,99 @@
public class SigilJunit
{
private static final Options OPTIONS;
-
- static {
+
+ static
+ {
OPTIONS = new Options();
OPTIONS.addOption("d", "dir", true, "Directory to write ant test results to");
- OPTIONS.addOption("q", "quiet", false, "Run tests quietly, i.e. don't print steps to console" );
+ OPTIONS.addOption("q", "quiet", false,
+ "Run tests quietly, i.e. don't print steps to console");
}
-
+
private final JUnitService service;
-
- public SigilJunit(JUnitService service) {
+
+ public SigilJunit(JUnitService service)
+ {
this.service = service;
}
- public boolean junit(String[] args) throws IOException, ParseException {
+ public boolean junit(String[] args) throws IOException, ParseException
+ {
Parser p = new GnuParser();
CommandLine cmd = p.parse(OPTIONS, args);
String[] cargs = cmd.getArgs();
- if ( cargs.length == 0 ) {
- for ( String t : service.getTests() ) {
- System.out.println( "\t" + t );
+ if (cargs.length == 0)
+ {
+ for (String t : service.getTests())
+ {
+ System.out.println("\t" + t);
System.out.flush();
}
return true;
}
- else {
- boolean quiet = cmd.hasOption( 'q' );
+ else
+ {
+ boolean quiet = cmd.hasOption('q');
String d = cmd.getOptionValue('d');
File dir = null;
- if ( d != null ) {
+ if (d != null)
+ {
dir = new File(d);
dir.mkdirs();
- System.out.println( "Writing results to " + dir.getAbsolutePath() );
+ System.out.println("Writing results to " + dir.getAbsolutePath());
System.out.flush();
}
- return runTests( cargs, quiet, dir );
+ return runTests(cargs, quiet, dir);
}
}
-
- private boolean runTests(String[] args, boolean quiet, File dir) throws IOException {
+
+ private boolean runTests(String[] args, boolean quiet, File dir) throws IOException
+ {
int count = 0;
int failures = 0;
int errors = 0;
- for ( String t : args ) {
- TestSuite[] tests = findTests( t );
- if ( tests.length == 0 ) {
- System.err.println( "No tests found for " + t );
+ for (String t : args)
+ {
+ TestSuite[] tests = findTests(t);
+ if (tests.length == 0)
+ {
+ System.err.println("No tests found for " + t);
}
- else {
- for ( TestSuite test : tests ) {
+ else
+ {
+ for (TestSuite test : tests)
+ {
TestResult result = new TestResult();
- if ( !quiet ) {
- result.addListener( new PrintListener());
+ if (!quiet)
+ {
+ result.addListener(new PrintListener());
}
-
+
JUnitTest antTest = null;
FileOutputStream fout = null;
XMLJUnitResultFormatter formatter = null;
-
- if ( dir != null ) {
+
+ if (dir != null)
+ {
antTest = new JUnitTest(t, false, false, true);
-
+
formatter = new XMLJUnitResultFormatter();
formatter.startTestSuite(antTest);
-
+
String name = "TEST-" + test.getName() + ".xml";
-
- File f = new File( dir, name );
- fout = new FileOutputStream( f );
+
+ File f = new File(dir, name);
+ fout = new FileOutputStream(f);
formatter.setOutput(fout);
result.addListener(formatter);
}
-
+
test.run(result);
-
- if ( dir != null ) {
- antTest.setCounts(result.runCount(), result.failureCount(), result.errorCount());
+
+ if (dir != null)
+ {
+ antTest.setCounts(result.runCount(), result.failureCount(),
+ result.errorCount());
formatter.endTestSuite(antTest);
fout.flush();
fout.close();
@@ -125,57 +142,68 @@
}
}
}
-
- System.out.println( "Ran " + count + " tests. " + failures + " failures " + errors + " errors." );
+
+ System.out.println("Ran " + count + " tests. " + failures + " failures " + errors
+ + " errors.");
System.out.flush();
-
+
return failures + errors == 0;
}
- private TestSuite[] findTests(String t) {
- if ( t.contains("*" ) ) {
+ private TestSuite[] findTests(String t)
+ {
+ if (t.contains("*"))
+ {
Pattern p = compile(t);
LinkedList<TestSuite> tests = new LinkedList<TestSuite>();
- for ( String n : service.getTests() ) {
- if ( p.matcher(n).matches() ) {
- tests.add( service.createTest(n) );
+ for (String n : service.getTests())
+ {
+ if (p.matcher(n).matches())
+ {
+ tests.add(service.createTest(n));
}
}
- return tests.toArray( new TestSuite[tests.size()] );
+ return tests.toArray(new TestSuite[tests.size()]);
}
- else {
+ else
+ {
TestSuite test = service.createTest(t);
return test == null ? new TestSuite[0] : new TestSuite[] { test };
}
}
- public static final Pattern compile(String glob) {
+ public static final Pattern compile(String glob)
+ {
char[] chars = glob.toCharArray();
- if ( chars.length > 0 ) {
+ if (chars.length > 0)
+ {
StringBuilder builder = new StringBuilder(chars.length + 5);
-
+
builder.append('^');
-
- for (char c : chars) {
- switch ( c ) {
- case '*':
- builder.append(".*");
- break;
- case '.':
- builder.append("\\.");
- break;
- case '$':
- builder.append( "\\$" );
- break;
- default:
- builder.append( c );
+
+ for (char c : chars)
+ {
+ switch (c)
+ {
+ case '*':
+ builder.append(".*");
+ break;
+ case '.':
+ builder.append("\\.");
+ break;
+ case '$':
+ builder.append("\\$");
+ break;
+ default:
+ builder.append(c);
}
}
-
+
return Pattern.compile(builder.toString());
}
- else {
+ else
+ {
return Pattern.compile(glob);
}
- }
+ }
}
diff --git a/sigil/ivy/resolver/src/org/apache/felix/sigil/ant/BundleInfoTask.java b/sigil/ivy/resolver/src/org/apache/felix/sigil/ant/BundleInfoTask.java
index 9b53cee..ad5bbb4 100644
--- a/sigil/ivy/resolver/src/org/apache/felix/sigil/ant/BundleInfoTask.java
+++ b/sigil/ivy/resolver/src/org/apache/felix/sigil/ant/BundleInfoTask.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.ant;
-
import java.io.File;
import java.io.IOException;
import java.util.jar.JarFile;
@@ -28,7 +27,6 @@
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
-
public class BundleInfoTask extends Task
{
private File bundle;
@@ -36,51 +34,52 @@
private String property;
private String defaultValue;
-
@Override
public void execute() throws BuildException
{
- if ( bundle == null )
- throw new BuildException( "missing attribute: bundle" );
- if ( header == null )
- throw new BuildException( "missing attribute: header" );
+ if (bundle == null)
+ throw new BuildException("missing attribute: bundle");
+ if (header == null)
+ throw new BuildException("missing attribute: header");
JarFile jar = null;
-
+
try
{
- jar = new JarFile( bundle, false );
+ jar = new JarFile(bundle, false);
Manifest mf = jar.getManifest();
- String value = mf.getMainAttributes().getValue( header );
- if ( property == null )
+ String value = mf.getMainAttributes().getValue(header);
+ if (property == null)
{
- log( header + "=" + value );
+ log(header + "=" + value);
}
else
{
- if ( "Bundle-SymbolicName".equals( header ) && value != null )
+ if ("Bundle-SymbolicName".equals(header) && value != null)
{
// remove singleton flag
- int semi = value.indexOf( ';' );
- if ( semi > 0 )
- value = value.substring( 0, semi );
+ int semi = value.indexOf(';');
+ if (semi > 0)
+ value = value.substring(0, semi);
}
- if ( value == null )
+ if (value == null)
{
value = defaultValue;
}
- if ( value != null )
+ if (value != null)
{
- getProject().setNewProperty( property, value );
+ getProject().setNewProperty(property, value);
}
}
}
- catch ( IOException e )
+ catch (IOException e)
{
- throw new BuildException( "Failed to access bundle", e );
+ throw new BuildException("Failed to access bundle", e);
}
- finally {
- if ( jar != null ) {
+ finally
+ {
+ if (jar != null)
+ {
try
{
jar.close();
@@ -94,26 +93,22 @@
}
}
-
- public void setBundle( String bundle )
+ public void setBundle(String bundle)
{
- this.bundle = new File( bundle );
+ this.bundle = new File(bundle);
}
-
- public void setHeader( String header )
+ public void setHeader(String header)
{
this.header = header;
}
-
- public void setProperty( String property )
+ public void setProperty(String property)
{
this.property = property;
}
-
- public void setDefaultValue( String defaultValue )
+ public void setDefaultValue(String defaultValue)
{
this.defaultValue = defaultValue;
}
diff --git a/sigil/ivy/resolver/src/org/apache/felix/sigil/ant/BundleTask.java b/sigil/ivy/resolver/src/org/apache/felix/sigil/ant/BundleTask.java
index 712f372..ab2c4c2 100644
--- a/sigil/ivy/resolver/src/org/apache/felix/sigil/ant/BundleTask.java
+++ b/sigil/ivy/resolver/src/org/apache/felix/sigil/ant/BundleTask.java
@@ -130,7 +130,7 @@
log(id + ": " + count(nErr, "error") + ", " + count(nWarn, "warning")
+ msg);
}
-
+
if (revision != null)
{
// FIXME: hopefully if we have multiple bundles they all have the same version
diff --git a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/BldRepositoryManager.java b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/BldRepositoryManager.java
index 9670dcd..28d3e36 100644
--- a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/BldRepositoryManager.java
+++ b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/BldRepositoryManager.java
@@ -60,7 +60,7 @@
{
continue;
}
-
+
String optStr = repo.getProperty("optional", "false");
boolean optional = Boolean.parseBoolean(optStr.trim());
@@ -98,7 +98,8 @@
}
int level = Integer.parseInt(repo.getProperty(
- IRepositoryConfig.REPOSITORY_LEVEL, Integer.toString(IBundleRepository.NORMAL_PRIORITY)));
+ IRepositoryConfig.REPOSITORY_LEVEL,
+ Integer.toString(IBundleRepository.NORMAL_PRIORITY)));
try
{
diff --git a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/BldResolver.java b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/BldResolver.java
index 48ddd12d..1e33b66 100644
--- a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/BldResolver.java
+++ b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/BldResolver.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.ivy;
-
import java.util.Map;
import java.util.Properties;
@@ -31,7 +30,6 @@
import org.apache.felix.sigil.common.repository.ResolutionConfig;
import org.apache.felix.sigil.common.repository.ResolutionException;
-
public class BldResolver implements IBldResolver
{
private Map<String, Properties> repos;
@@ -43,75 +41,72 @@
{
BldCore.init();
}
- catch ( Exception e )
+ catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
};
-
- public BldResolver( Map<String, Properties> repos )
+ public BldResolver(Map<String, Properties> repos)
{
this.repos = repos;
}
-
- public IResolution resolve( IModelElement element, boolean transitive )
+ public IResolution resolve(IModelElement element, boolean transitive)
{
int options = ResolutionConfig.IGNORE_ERRORS | ResolutionConfig.INCLUDE_OPTIONAL;
- if ( transitive )
+ if (transitive)
options |= ResolutionConfig.INCLUDE_DEPENDENTS;
- ResolutionConfig config = new ResolutionConfig( options );
+ ResolutionConfig config = new ResolutionConfig(options);
try
{
- return resolve( element, config );
+ return resolve(element, config);
}
- catch ( ResolutionException e )
+ catch (ResolutionException e)
{
- throw new IllegalStateException( "eek! this shouldn't happen when ignoreErrors=true", e );
+ throw new IllegalStateException(
+ "eek! this shouldn't happen when ignoreErrors=true", e);
}
}
-
- public IResolution resolveOrFail( IModelElement element, boolean transitive ) throws ResolutionException
+ public IResolution resolveOrFail(IModelElement element, boolean transitive)
+ throws ResolutionException
{
int options = 0;
- if ( transitive )
+ if (transitive)
options |= ResolutionConfig.INCLUDE_DEPENDENTS;
- ResolutionConfig config = new ResolutionConfig( options );
- return resolve( element, config );
+ ResolutionConfig config = new ResolutionConfig(options);
+ return resolve(element, config);
}
-
- private IResolution resolve( IModelElement element, ResolutionConfig config ) throws ResolutionException
+ private IResolution resolve(IModelElement element, ResolutionConfig config)
+ throws ResolutionException
{
- if ( manager == null )
+ if (manager == null)
{
- manager = new BldRepositoryManager( repos );
+ manager = new BldRepositoryManager(repos);
}
IResolutionMonitor ivyMonitor = new IResolutionMonitor()
{
- public void endResolution( IModelElement requirement, ISigilBundle sigilBundle )
+ public void endResolution(IModelElement requirement, ISigilBundle sigilBundle)
{
- Log.debug( "Resolved " + requirement + " -> " + sigilBundle );
+ Log.debug("Resolved " + requirement + " -> " + sigilBundle);
}
-
public boolean isCanceled()
{
return false;
}
-
- public void startResolution( IModelElement requirement )
+ public void startResolution(IModelElement requirement)
{
- Log.verbose( "Resolving " + requirement );
+ Log.verbose("Resolving " + requirement);
}
};
- return manager.getBundleResolver().resolve( element, config, ivyMonitor );
+ return manager.getBundleResolver().resolve(element, config, ivyMonitor);
}
}
diff --git a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/FindUtil.java b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/FindUtil.java
index 911a8c8..2a6c7cd 100644
--- a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/FindUtil.java
+++ b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/FindUtil.java
@@ -29,9 +29,10 @@
{
static final String WILD_ANY = "[^.]?.*";
static final String WILD_ONE = "[^.]?[^;]*"; // WILD_ONE.endsWith(WILD_ANY) == false
-
+
// example pattern: ${repository}/projects/abc*/*/project.sigil
- public static Collection<File> findFiles(File workingDir, String pattern) throws IOException
+ public static Collection<File> findFiles(File workingDir, String pattern)
+ throws IOException
{
int star = pattern.indexOf("*");
if (star == -1)
@@ -49,7 +50,8 @@
String[] patterns = regex.split("/");
TreeSet<File> list = new TreeSet<File>();
- File root = slash == -1 ? workingDir : new File(pattern.substring(0, slash)).getAbsoluteFile();
+ File root = slash == -1 ? workingDir
+ : new File(pattern.substring(0, slash)).getAbsoluteFile();
if (root.isDirectory())
{
diff --git a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/IBldResolver.java b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/IBldResolver.java
index e338349..f39693d 100644
--- a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/IBldResolver.java
+++ b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/IBldResolver.java
@@ -19,16 +19,14 @@
package org.apache.felix.sigil.ivy;
-
import org.apache.felix.sigil.common.model.IModelElement;
import org.apache.felix.sigil.common.repository.IResolution;
import org.apache.felix.sigil.common.repository.ResolutionException;
-
public interface IBldResolver
{
- IResolution resolveOrFail( IModelElement element, boolean transitive ) throws ResolutionException;
+ IResolution resolveOrFail(IModelElement element, boolean transitive)
+ throws ResolutionException;
-
- IResolution resolve( IModelElement element, boolean transitive );
+ IResolution resolve(IModelElement element, boolean transitive);
}
diff --git a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/Log.java b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/Log.java
index 45171b5..7237ac2 100644
--- a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/Log.java
+++ b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/Log.java
@@ -19,10 +19,8 @@
package org.apache.felix.sigil.ivy;
-
import org.apache.ivy.util.Message;
-
// ensure common prefix to all sigil messages
public class Log
{
@@ -30,45 +28,40 @@
private static final boolean highlight = false;
-
- public static void error( String msg )
+ public static void error(String msg)
{
- if ( highlight )
- Message.deprecated( PREFIX + "[error] " + msg );
- Message.error( PREFIX + msg );
+ if (highlight)
+ Message.deprecated(PREFIX + "[error] " + msg);
+ Message.error(PREFIX + msg);
}
-
- public static void warn( String msg )
+ public static void warn(String msg)
{
- if ( highlight )
- Message.deprecated( PREFIX + "[warn] " + msg );
+ if (highlight)
+ Message.deprecated(PREFIX + "[warn] " + msg);
else
- Message.warn( PREFIX + msg );
+ Message.warn(PREFIX + msg);
}
-
- public static void info( String msg )
+ public static void info(String msg)
{
- if ( highlight )
- Message.deprecated( PREFIX + "[info] " + msg );
+ if (highlight)
+ Message.deprecated(PREFIX + "[info] " + msg);
else
- Message.info( PREFIX + msg );
+ Message.info(PREFIX + msg);
}
-
- public static void verbose( String msg )
+ public static void verbose(String msg)
{
- Message.verbose( PREFIX + "[verbose] " + msg );
+ Message.verbose(PREFIX + "[verbose] " + msg);
}
-
- public static void debug( String msg )
+ public static void debug(String msg)
{
- if ( highlight )
- Message.deprecated( PREFIX + "[debug] " + msg );
+ if (highlight)
+ Message.deprecated(PREFIX + "[debug] " + msg);
else
- Message.debug( PREFIX + msg );
+ Message.debug(PREFIX + msg);
}
}
diff --git a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/ProjectRepository.java b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/ProjectRepository.java
index 703dabe..75a21fa 100644
--- a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/ProjectRepository.java
+++ b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/ProjectRepository.java
@@ -248,7 +248,8 @@
for (IBldBundle bb : project.getBundles())
{
- IBundleModelElement info = ModelElementFactory.getInstance().newModelElement(IBundleModelElement.class);
+ IBundleModelElement info = ModelElementFactory.getInstance().newModelElement(
+ IBundleModelElement.class);
for (IPackageExport pexport : bb.getExports())
{
@@ -274,15 +275,18 @@
Version version = VersionTable.getVersion(bb.getVersion());
info.setVersion(version);
- ISigilBundle pb = ModelElementFactory.getInstance().newModelElement(ISigilBundle.class);
+ ISigilBundle pb = ModelElementFactory.getInstance().newModelElement(
+ ISigilBundle.class);
pb.setBundleInfo(info);
-
+
Map<Object, Object> meta = new HashMap<Object, Object>();
ModuleDescriptor md = SigilParser.instance().parseDescriptor(uri.toURL());
- if ( !bb.getId().equals( md.getModuleRevisionId().getName() ) )
+ if (!bb.getId().equals(md.getModuleRevisionId().getName()))
{ // non-default artifact
- for ( Artifact a : md.getAllArtifacts() ) {
- if ( a.getName().equals( bb.getId() ) ) {
+ for (Artifact a : md.getAllArtifacts())
+ {
+ if (a.getName().equals(bb.getId()))
+ {
meta.put(Artifact.class, a);
break;
}
@@ -291,7 +295,7 @@
meta.put(ModuleDescriptor.class, md);
pb.setMeta(meta);
-
+
list.add(pb);
Log.debug("ProjectRepository: added " + pb);
Log.debug("ProjectRepository: exports " + bb.getExports());
diff --git a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/ProjectRepositoryProvider.java b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/ProjectRepositoryProvider.java
index e081344..026d981 100644
--- a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/ProjectRepositoryProvider.java
+++ b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/ProjectRepositoryProvider.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.ivy;
-
import java.util.HashMap;
import java.util.Properties;
@@ -27,25 +26,24 @@
import org.apache.felix.sigil.common.repository.IRepositoryProvider;
import org.apache.felix.sigil.common.repository.RepositoryException;
-
public class ProjectRepositoryProvider implements IRepositoryProvider
{
private static HashMap<String, ProjectRepository> cache = new HashMap<String, ProjectRepository>();
-
- public IBundleRepository createRepository( String id, Properties properties ) throws RepositoryException
+ public IBundleRepository createRepository(String id, Properties properties)
+ throws RepositoryException
{
- ProjectRepository repository = cache.get( id );
+ ProjectRepository repository = cache.get(id);
- if ( repository == null )
+ if (repository == null)
{
- String pattern = properties.getProperty( "pattern" );
- if ( pattern == null )
+ String pattern = properties.getProperty("pattern");
+ if (pattern == null)
{
- throw new RepositoryException( "property 'pattern' not specified." );
+ throw new RepositoryException("property 'pattern' not specified.");
}
- repository = new ProjectRepository( id, pattern );
- cache.put( id, repository );
+ repository = new ProjectRepository(id, pattern);
+ cache.put(id, repository);
}
return repository;
diff --git a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilParser.java b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilParser.java
index e7eb9fe..faf7b23 100644
--- a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilParser.java
+++ b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilParser.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.ivy;
-
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
@@ -61,111 +60,102 @@
import org.apache.ivy.plugins.repository.url.URLResource;
import org.apache.ivy.plugins.resolver.DependencyResolver;
-
public class SigilParser implements ModuleDescriptorParser
{
private static DelegateParser instance;
-
// used by ProjectRepository
static synchronized DelegateParser instance()
{
- if ( instance == null )
- throw new IllegalStateException( "SigilParser is not instantiated." );
-
+ if (instance == null)
+ throw new IllegalStateException("SigilParser is not instantiated.");
+
return instance;
}
-
public SigilParser()
{
- synchronized(SigilParser.class) {
- if ( instance == null )
+ synchronized (SigilParser.class)
+ {
+ if (instance == null)
{
instance = new DelegateParser();
}
}
}
-
/**
* In IvyDE, IvyContext is not available, so we can't find the SigilResolver.
* This allows us to construct one.
* @deprecated temporary to support IvyDE
*/
- public void setConfig( String config )
+ public void setConfig(String config)
{
instance.config = config;
}
-
/**
* sets delegate parser.
* If not set, we delegate to the default Ivy parser.
* @param type name returned by desired parser's getType() method.
*/
- public void setDelegateType( String type )
+ public void setDelegateType(String type)
{
- for ( ModuleDescriptorParser parser : ModuleDescriptorParserRegistry.getInstance().getParsers() )
+ for (ModuleDescriptorParser parser : ModuleDescriptorParserRegistry.getInstance().getParsers())
{
- if ( parser.getType().equals( type ) )
+ if (parser.getType().equals(type))
{
instance.delegate = parser;
break;
}
}
- if ( instance.delegate == null )
+ if (instance.delegate == null)
{
- throw new IllegalArgumentException( "Can't find parser delegateType=" + type );
+ throw new IllegalArgumentException("Can't find parser delegateType=" + type);
}
}
-
/**
* sets default file name the delegate parser accepts.
* If not set, defaults to "ivy.xml".
* @param name
*/
- public void setDelegateFile( String name )
+ public void setDelegateFile(String name)
{
instance.ivyFile = name;
}
-
/**
* sets the dependencies to keep from the delegate parser.
* If not set, all existing dependencies are dropped.
* @param regex pattern matching dependency names to keep.
*/
- public void setKeepDependencies( String regex )
+ public void setKeepDependencies(String regex)
{
- instance.keepDependencyPattern = Pattern.compile( regex );
+ instance.keepDependencyPattern = Pattern.compile(regex);
}
-
/**
* reduce level of info logging.
* @param quiet
*/
- public void setQuiet( String quiet )
+ public void setQuiet(String quiet)
{
- instance.quiet = Boolean.parseBoolean( quiet );
+ instance.quiet = Boolean.parseBoolean(quiet);
}
-
/**
* sets the SigilResolver we use.
* If not set, we use the first SigilResolver we find.
* @param name
*/
- public void setResolver( String name )
+ public void setResolver(String name)
{
instance.resolverName = name;
}
-
/**
* adds override element: <override name="X" pattern="Y" replace="Z"/>. Overrides
* Ivy variables using a pattern substitution on the resource directory path.
@@ -177,58 +167,53 @@
* the ivy:buildlist task won't work without this workaround.
*/
// e.g. <override name="ant.project.name" pattern=".*/([^/]+)/([^/]+)$" replace="$1-$2"/>
- public void addConfiguredOverride( Map<String, String> var )
+ public void addConfiguredOverride(Map<String, String> var)
{
- final String name = var.get( "name" );
- final String regex = var.get( "pattern" );
- final String replace = var.get( "replace" );
+ final String name = var.get("name");
+ final String regex = var.get("pattern");
+ final String replace = var.get("replace");
- if ( name == null || regex == null || replace == null )
- throw new IllegalArgumentException( "override must contain name, pattern and replace attributes." );
+ if (name == null || regex == null || replace == null)
+ throw new IllegalArgumentException(
+ "override must contain name, pattern and replace attributes.");
- instance.varRegex.put( name, Pattern.compile( regex ) );
- instance.varReplace.put( name, replace );
+ instance.varRegex.put(name, Pattern.compile(regex));
+ instance.varReplace.put(name, replace);
}
-
// implement ModuleDescriptorParser interface by delegation to singleton instance.
- public boolean accept( Resource res )
+ public boolean accept(Resource res)
{
- return instance.accept( res );
+ return instance.accept(res);
}
-
- public Artifact getMetadataArtifact( ModuleRevisionId mrid, Resource res )
+ public Artifact getMetadataArtifact(ModuleRevisionId mrid, Resource res)
{
- return instance.getMetadataArtifact( mrid, res );
+ return instance.getMetadataArtifact(mrid, res);
}
-
public String getType()
{
return instance.getType();
}
-
- public ModuleDescriptor parseDescriptor( ParserSettings settings, URL xmlURL, boolean validate )
- throws ParseException, IOException
+ public ModuleDescriptor parseDescriptor(ParserSettings settings, URL xmlURL,
+ boolean validate) throws ParseException, IOException
{
- return instance.parseDescriptor( settings, xmlURL, validate );
+ return instance.parseDescriptor(settings, xmlURL, validate);
}
-
- public ModuleDescriptor parseDescriptor( ParserSettings settings, URL xmlURL, Resource res, boolean validate )
- throws ParseException, IOException
+ public ModuleDescriptor parseDescriptor(ParserSettings settings, URL xmlURL,
+ Resource res, boolean validate) throws ParseException, IOException
{
- return instance.parseDescriptor( settings, xmlURL, res, validate );
+ return instance.parseDescriptor(settings, xmlURL, res, validate);
}
-
- public void toIvyFile( InputStream source, Resource res, File destFile, ModuleDescriptor md )
- throws ParseException, IOException
+ public void toIvyFile(InputStream source, Resource res, File destFile,
+ ModuleDescriptor md) throws ParseException, IOException
{
- instance.toIvyFile( source, res, destFile, md );
+ instance.toIvyFile(source, res, destFile, md);
}
/**
@@ -256,188 +241,187 @@
private boolean quiet;
private String config;
-
@Override
- public boolean accept( Resource res )
+ public boolean accept(Resource res)
{
- boolean accept = ( res instanceof SigilResolver.SigilIvy )
- || res.getName().endsWith( "/" + SIGIL_BUILDLIST )
- || ( ( instance.getSigilURI( res ) != null ) && ( ( instance.delegate != null ? instance.delegate
- .accept( res ) : false ) || super.accept( res ) ) );
- if ( accept )
- Log.verbose( "accepted: " + res );
+ boolean accept = (res instanceof SigilResolver.SigilIvy)
+ || res.getName().endsWith("/" + SIGIL_BUILDLIST)
+ || ((instance.getSigilURI(res) != null) && ((instance.delegate != null ? instance.delegate.accept(res)
+ : false) || super.accept(res)));
+ if (accept)
+ Log.verbose("accepted: " + res);
return accept;
}
-
@Override
- public void toIvyFile( InputStream source, Resource res, File destFile, ModuleDescriptor md )
- throws ParseException, IOException
+ public void toIvyFile(InputStream source, Resource res, File destFile,
+ ModuleDescriptor md) throws ParseException, IOException
{
- Log.verbose( "writing resource: " + res + " toIvyFile: " + destFile );
+ Log.verbose("writing resource: " + res + " toIvyFile: " + destFile);
// source allows us to keep layout and comments,
// but this doesn't work if source is not ivy.xml.
// So just write file directly from descriptor.
try
{
- XmlModuleDescriptorWriter.write( md, destFile );
+ XmlModuleDescriptorWriter.write(md, destFile);
}
finally
{
- if ( source != null )
+ if (source != null)
source.close();
}
}
-
@Override
- public ModuleDescriptor parseDescriptor( ParserSettings settings, URL xmlURL, boolean validate )
- throws ParseException, IOException
+ public ModuleDescriptor parseDescriptor(ParserSettings settings, URL xmlURL,
+ boolean validate) throws ParseException, IOException
{
- return parseDescriptor( settings, xmlURL, new URLResource( xmlURL ), validate );
+ return parseDescriptor(settings, xmlURL, new URLResource(xmlURL), validate);
}
-
@Override
- public ModuleDescriptor parseDescriptor( ParserSettings settings, URL xmlURL, Resource res, boolean validate )
- throws ParseException, IOException
+ public ModuleDescriptor parseDescriptor(ParserSettings settings, URL xmlURL,
+ Resource res, boolean validate) throws ParseException, IOException
{
String cacheKey = xmlURL.toString() + settings.hashCode();
- DefaultModuleDescriptor dmd = augmentedCache.get( cacheKey );
+ DefaultModuleDescriptor dmd = augmentedCache.get(cacheKey);
- if ( dmd == null )
+ if (dmd == null)
{
- dmd = rawCache.get( cacheKey );
- if ( dmd == null )
+ dmd = rawCache.get(cacheKey);
+ if (dmd == null)
{
- dmd = delegateParse( settings, xmlURL, res, validate );
+ dmd = delegateParse(settings, xmlURL, res, validate);
}
- if ( !quiet )
- Log.info( "augmenting module=" + dmd.getModuleRevisionId().getName() + " ant.project.name="
- + settings.substitute( "${ant.project.name}" ) );
+ if (!quiet)
+ Log.info("augmenting module=" + dmd.getModuleRevisionId().getName()
+ + " ant.project.name="
+ + settings.substitute("${ant.project.name}"));
- addDependenciesToDescriptor( res, dmd );
- augmentedCache.put( cacheKey, dmd );
+ addDependenciesToDescriptor(res, dmd);
+ augmentedCache.put(cacheKey, dmd);
- Log.verbose( "augmented dependencies: " + Arrays.asList( dmd.getDependencies() ) );
+ Log.verbose("augmented dependencies: "
+ + Arrays.asList(dmd.getDependencies()));
}
return dmd;
}
-
// used by ProjectRepository
- ModuleDescriptor parseDescriptor( URL projectURL ) throws ParseException, IOException
+ ModuleDescriptor parseDescriptor(URL projectURL) throws ParseException,
+ IOException
{
- if ( defaultSettings == null )
+ if (defaultSettings == null)
{
Ivy ivy = IvyContext.getContext().peekIvy();
- if ( ivy == null )
- throw new IllegalStateException( "can't get default settings - no ivy context." );
+ if (ivy == null)
+ throw new IllegalStateException(
+ "can't get default settings - no ivy context.");
defaultSettings = ivy.getSettings();
}
- URL ivyURL = new URL( projectURL, ivyFile );
+ URL ivyURL = new URL(projectURL, ivyFile);
String cacheKey = ivyURL.toString() + defaultSettings.hashCode();
- DefaultModuleDescriptor dmd = rawCache.get( cacheKey );
+ DefaultModuleDescriptor dmd = rawCache.get(cacheKey);
- if ( dmd == null )
+ if (dmd == null)
{
- URLResource res = new URLResource( ivyURL );
+ URLResource res = new URLResource(ivyURL);
// Note: this doesn't contain the augmented dependencies, which is OK,
// since the ProjectRepository only needs the id and status.
- dmd = delegateParse( defaultSettings, ivyURL, res, false );
- rawCache.put( cacheKey, dmd );
+ dmd = delegateParse(defaultSettings, ivyURL, res, false);
+ rawCache.put(cacheKey, dmd);
}
return dmd;
}
-
- private DefaultModuleDescriptor delegateParse( ParserSettings settings, URL xmlURL, Resource res,
- boolean validate ) throws ParseException, IOException
+ private DefaultModuleDescriptor delegateParse(ParserSettings settings,
+ URL xmlURL, Resource res, boolean validate) throws ParseException,
+ IOException
{
String resName = res.getName();
- if ( resName.endsWith( "/" + SIGIL_BUILDLIST ) )
+ if (resName.endsWith("/" + SIGIL_BUILDLIST))
{
- String name = resName.substring( 0, resName.length() - SIGIL_BUILDLIST.length() );
- res = res.clone( name + ivyFile );
- xmlURL = new URL( xmlURL, ivyFile );
+ String name = resName.substring(0, resName.length()
+ - SIGIL_BUILDLIST.length());
+ res = res.clone(name + ivyFile);
+ xmlURL = new URL(xmlURL, ivyFile);
}
- if ( settings instanceof IvySettings )
+ if (settings instanceof IvySettings)
{
- IvySettings ivySettings = ( IvySettings ) settings;
- String dir = new File( res.getName() ).getParent();
+ IvySettings ivySettings = (IvySettings) settings;
+ String dir = new File(res.getName()).getParent();
- for ( String name : varRegex.keySet() )
+ for (String name : varRegex.keySet())
{
- Pattern regex = varRegex.get( name );
- String replace = varReplace.get( name );
+ Pattern regex = varRegex.get(name);
+ String replace = varReplace.get(name);
- String value = regex.matcher( dir ).replaceAll( replace );
+ String value = regex.matcher(dir).replaceAll(replace);
- Log.debug( "overriding variable " + name + "=" + value );
- ivySettings.setVariable( name, value );
+ Log.debug("overriding variable " + name + "=" + value);
+ ivySettings.setVariable(name, value);
}
}
ModuleDescriptor md = null;
- if ( delegate == null || !delegate.accept( res ) )
+ if (delegate == null || !delegate.accept(res))
{
- md = super.parseDescriptor( settings, xmlURL, res, validate );
+ md = super.parseDescriptor(settings, xmlURL, res, validate);
}
else
{
- md = delegate.parseDescriptor( settings, xmlURL, res, validate );
+ md = delegate.parseDescriptor(settings, xmlURL, res, validate);
}
- return mungeDescriptor( md, res );
+ return mungeDescriptor(md, res);
}
-
/**
* clones descriptor and removes dependencies, as descriptor MUST have
* 'this' as the parser given to its constructor.
* Only dependency names matched by keepDependencyPattern are kept,
* as we're going to add our own dependencies later.
*/
- private DefaultModuleDescriptor mungeDescriptor( ModuleDescriptor md, Resource res )
+ private DefaultModuleDescriptor mungeDescriptor(ModuleDescriptor md, Resource res)
{
- if ( ( md instanceof DefaultModuleDescriptor ) && ( md.getParser() == this )
- && ( KEEP_ALL.equals( keepDependencyPattern ) ) )
+ if ((md instanceof DefaultModuleDescriptor) && (md.getParser() == this)
+ && (KEEP_ALL.equals(keepDependencyPattern)))
{
- return ( DefaultModuleDescriptor ) md;
+ return (DefaultModuleDescriptor) md;
}
- DefaultModuleDescriptor dmd = new DefaultModuleDescriptor( this, res );
+ DefaultModuleDescriptor dmd = new DefaultModuleDescriptor(this, res);
- dmd.setModuleRevisionId( md.getModuleRevisionId() );
- dmd.setPublicationDate( md.getPublicationDate() );
+ dmd.setModuleRevisionId(md.getModuleRevisionId());
+ dmd.setPublicationDate(md.getPublicationDate());
- for ( Configuration c : md.getConfigurations() )
+ for (Configuration c : md.getConfigurations())
{
String conf = c.getName();
- dmd.addConfiguration( c );
+ dmd.addConfiguration(c);
- for ( Artifact a : md.getArtifacts( conf ) )
+ for (Artifact a : md.getArtifacts(conf))
{
- dmd.addArtifact( conf, a );
+ dmd.addArtifact(conf, a);
}
}
- if ( keepDependencyPattern != null )
+ if (keepDependencyPattern != null)
{
- for ( DependencyDescriptor dependency : md.getDependencies() )
+ for (DependencyDescriptor dependency : md.getDependencies())
{
String name = dependency.getDependencyId().getName();
- if ( keepDependencyPattern.matcher( name ).matches() )
+ if (keepDependencyPattern.matcher(name).matches())
{
- dmd.addDependency( dependency );
+ dmd.addDependency(dependency);
}
}
}
@@ -445,119 +429,123 @@
return dmd;
}
-
/*
* find URI to Sigil project file. This assumes that it is in the same
* directory as the ivy file.
*/
- private URI getSigilURI( Resource res )
+ private URI getSigilURI(Resource res)
{
URI uri = null;
- if ( res instanceof URLResource )
+ if (res instanceof URLResource)
{
- URL url = ( ( URLResource ) res ).getURL();
- uri = URI.create( url.toString() ).resolve( IBldProject.PROJECT_FILE );
+ URL url = ((URLResource) res).getURL();
+ uri = URI.create(url.toString()).resolve(IBldProject.PROJECT_FILE);
try
{
InputStream stream = uri.toURL().openStream(); // check file
// exists
stream.close();
}
- catch ( IOException e )
+ catch (IOException e)
{
uri = null;
}
}
- else if ( res instanceof FileResource )
+ else if (res instanceof FileResource)
{
- uri = ( ( FileResource ) res ).getFile().toURI().resolve( IBldProject.PROJECT_FILE );
- if ( !( new File( uri ).exists() ) )
+ uri = ((FileResource) res).getFile().toURI().resolve(
+ IBldProject.PROJECT_FILE);
+ if (!(new File(uri).exists()))
uri = null;
}
return uri;
}
-
/*
* add sigil dependencies to ModuleDescriptor.
*/
- private void addDependenciesToDescriptor( Resource res, DefaultModuleDescriptor md ) throws IOException
+ private void addDependenciesToDescriptor(Resource res, DefaultModuleDescriptor md)
+ throws IOException
{
// FIXME: transitive should be configurable
final boolean transitive = true; // ivy default is true
final boolean changing = false;
final boolean force = false;
- URI uri = getSigilURI( res );
- if ( uri == null )
+ URI uri = getSigilURI(res);
+ if (uri == null)
return;
IBldProject project;
- project = BldFactory.getProject( uri );
+ project = BldFactory.getProject(uri);
IBundleModelElement requirements = project.getDependencies();
- Log.verbose( "requirements: " + Arrays.asList( requirements.children() ) );
+ Log.verbose("requirements: " + Arrays.asList(requirements.children()));
// preserve version range for Require-Bundle
// XXX: synthesise bundle version range corresponding to package version ranges?
HashMap<String, VersionRange> versions = new HashMap<String, VersionRange>();
- for ( IModelElement child : requirements.children() )
+ for (IModelElement child : requirements.children())
{
- if ( child instanceof IRequiredBundle )
+ if (child instanceof IRequiredBundle)
{
- IRequiredBundle bundle = ( IRequiredBundle ) child;
- versions.put( bundle.getSymbolicName(), bundle.getVersions() );
+ IRequiredBundle bundle = (IRequiredBundle) child;
+ versions.put(bundle.getSymbolicName(), bundle.getVersions());
}
}
IBldResolver resolver = findResolver();
- if ( resolver == null )
+ if (resolver == null)
{
// this can happen in IvyDE, but it retries and is OK next time.
- Log.warn( "failed to find resolver - IvyContext not yet available." );
+ Log.warn("failed to find resolver - IvyContext not yet available.");
return;
}
- IResolution resolution = resolver.resolve( requirements, false );
- Log.verbose( "resolution: " + resolution.getBundles() );
+ IResolution resolution = resolver.resolve(requirements, false);
+ Log.verbose("resolution: " + resolution.getBundles());
ModuleRevisionId masterMrid = md.getModuleRevisionId();
DefaultDependencyDescriptor dd;
ModuleRevisionId mrid;
- for ( ISigilBundle bundle : resolution.getBundles() )
+ for (ISigilBundle bundle : resolution.getBundles())
{
IBundleModelElement info = bundle.getBundleInfo();
String name = info.getSymbolicName();
- if ( "system bundle".equals(name) )
+ if ("system bundle".equals(name))
{
// e.g. SystemProvider with framework=null
- Log.verbose( "Discarding system bundle" );
+ Log.verbose("Discarding system bundle");
continue;
}
- ModuleDescriptor bmd = (ModuleDescriptor) bundle.getMeta().get(ModuleDescriptor.class);
- if ( bmd != null )
+ ModuleDescriptor bmd = (ModuleDescriptor) bundle.getMeta().get(
+ ModuleDescriptor.class);
+ if (bmd != null)
{
ModuleRevisionId bmrid = bmd.getModuleRevisionId();
String org = bmrid.getOrganisation();
- if ( org == null )
+ if (org == null)
org = masterMrid.getOrganisation();
String module = bmrid.getName();
String rev = "latest." + bmd.getStatus();
- mrid = ModuleRevisionId.newInstance( org, module, rev );
-
- dd = new SigilDependencyDescriptor( md, mrid, force, changing, transitive );
+ mrid = ModuleRevisionId.newInstance(org, module, rev);
+
+ dd = new SigilDependencyDescriptor(md, mrid, force, changing,
+ transitive);
Artifact artifact = (Artifact) bundle.getMeta().get(Artifact.class);
- if ( artifact != null ) {
- dd.addDependencyArtifact( mrid.getName(), new DefaultDependencyArtifactDescriptor( dd, artifact.getName(), "jar",
- "jar", null, null ) );
+ if (artifact != null)
+ {
+ dd.addDependencyArtifact(mrid.getName(),
+ new DefaultDependencyArtifactDescriptor(dd,
+ artifact.getName(), "jar", "jar", null, null));
}
}
else
@@ -568,133 +556,140 @@
// VersionRange version = versions.get( name );
// String rev = version != null ? version.toString() : info.getVersion().toString();
String rev = info.getVersion().toString();
- mrid = ModuleRevisionId.newInstance( SigilResolver.ORG_SIGIL, name, rev );
- dd = new SigilDependencyDescriptor( md, mrid, force, changing, transitive );
+ mrid = ModuleRevisionId.newInstance(SigilResolver.ORG_SIGIL, name,
+ rev);
+ dd = new SigilDependencyDescriptor(md, mrid, force, changing,
+ transitive);
}
int nDeps = 0;
boolean foundDefault = false;
// TODO: make dependency configurations configurable SIGIL-176
- for ( String conf : md.getConfigurationsNames() )
+ for (String conf : md.getConfigurationsNames())
{
- if ( conf.equals( "default" ) )
+ if (conf.equals("default"))
{
foundDefault = true;
}
- else if ( md.getArtifacts( conf ).length == 0 )
+ else if (md.getArtifacts(conf).length == 0)
{
- dd.addDependencyConfiguration( conf, conf + "(default)" );
+ dd.addDependencyConfiguration(conf, conf + "(default)");
nDeps++;
}
}
- if ( nDeps > 0 )
+ if (nDeps > 0)
{
- if ( foundDefault )
- dd.addDependencyConfiguration( "default", "default" );
+ if (foundDefault)
+ dd.addDependencyConfiguration("default", "default");
}
else
{
- dd.addDependencyConfiguration( "*", "*" ); // all configurations
+ dd.addDependencyConfiguration("*", "*"); // all configurations
}
- md.addDependency( dd );
+ md.addDependency(dd);
}
boolean resolved = true;
- for ( IModelElement child : requirements.children() )
+ for (IModelElement child : requirements.children())
{
- ISigilBundle provider = resolution.getProvider( child );
- if ( provider == null )
+ ISigilBundle provider = resolution.getProvider(child);
+ if (provider == null)
{
resolved = false;
// this is parse phase, so only log verbose message.
// error is produced during resolution phase.
- Log.verbose( "WARN: can't resolve: " + child );
+ Log.verbose("WARN: can't resolve: " + child);
String name;
String version;
- if ( child instanceof IRequiredBundle )
+ if (child instanceof IRequiredBundle)
{
- IRequiredBundle rb = ( IRequiredBundle ) child;
+ IRequiredBundle rb = (IRequiredBundle) child;
name = rb.getSymbolicName();
version = rb.getVersions().toString();
}
else
{
- IPackageImport pi = ( IPackageImport ) child;
+ IPackageImport pi = (IPackageImport) child;
name = "import!" + pi.getPackageName();
version = pi.getVersions().toString();
}
- mrid = ModuleRevisionId.newInstance( "!" + SigilResolver.ORG_SIGIL, name, version );
- dd = new SigilDependencyDescriptor( md, mrid, force, changing, transitive );
- dd.addDependencyConfiguration( "*", "*" ); // all
+ mrid = ModuleRevisionId.newInstance("!" + SigilResolver.ORG_SIGIL,
+ name, version);
+ dd = new SigilDependencyDescriptor(md, mrid, force, changing,
+ transitive);
+ dd.addDependencyConfiguration("*", "*"); // all
// configurations
- md.addDependency( dd );
+ md.addDependency(dd);
}
}
- if ( !resolved )
+ if (!resolved)
{
// Ivy does not show warnings or errors logged from parse phase, until after resolution.
// but <buildlist> ant task doesn't do resolution, so errors would be silently ignored.
// Hence, we must use Message.info to ensure this failure is seen.
- if ( !quiet )
- Log.info( "WARN: resolution failed in: " + masterMrid.getName() + ". Use -v for details." );
+ if (!quiet)
+ Log.info("WARN: resolution failed in: " + masterMrid.getName()
+ + ". Use -v for details.");
}
}
-
/*
* find named resolver, or first resolver that implements IBldResolver.
*/
private IBldResolver findResolver()
{
- if ( resolver == null )
+ if (resolver == null)
{
Ivy ivy = IvyContext.getContext().peekIvy();
- if ( ivy != null )
+ if (ivy != null)
{
- if ( resolverName != null )
+ if (resolverName != null)
{
- DependencyResolver r = ivy.getSettings().getResolver( resolverName );
- if ( r == null )
+ DependencyResolver r = ivy.getSettings().getResolver(resolverName);
+ if (r == null)
{
- throw new Error( "SigilParser: resolver \"" + resolverName + "\" not defined." );
+ throw new Error("SigilParser: resolver \"" + resolverName
+ + "\" not defined.");
}
- else if ( r instanceof IBldResolver )
+ else if (r instanceof IBldResolver)
{
- resolver = ( IBldResolver ) r;
+ resolver = (IBldResolver) r;
}
else
{
- throw new Error( "SigilParser: resolver \"" + resolverName + "\" is not a SigilResolver." );
+ throw new Error("SigilParser: resolver \"" + resolverName
+ + "\" is not a SigilResolver.");
}
}
else
{
- for ( Object r : ivy.getSettings().getResolvers() )
+ for (Object r : ivy.getSettings().getResolvers())
{
- if ( r instanceof IBldResolver )
+ if (r instanceof IBldResolver)
{
- resolver = ( IBldResolver ) r;
+ resolver = (IBldResolver) r;
break;
}
}
}
- if ( resolver == null )
+ if (resolver == null)
{
- throw new Error( "SigilParser: can't find SigilResolver. Check ivysettings.xml." );
+ throw new Error(
+ "SigilParser: can't find SigilResolver. Check ivysettings.xml.");
}
}
- else if ( config != null )
+ else if (config != null)
{
- Log.warn( "creating duplicate resolver to support IvyDE." );
+ Log.warn("creating duplicate resolver to support IvyDE.");
resolver = new SigilResolver();
- ( ( SigilResolver ) resolver ).setConfig( config );
+ ((SigilResolver) resolver).setConfig(config);
}
}
return resolver;
@@ -709,9 +704,8 @@
*/
class SigilDependencyDescriptor extends DefaultDependencyDescriptor
{
- public SigilDependencyDescriptor( DefaultModuleDescriptor md, ModuleRevisionId mrid, boolean force,
- boolean changing, boolean transitive )
+ public SigilDependencyDescriptor(DefaultModuleDescriptor md, ModuleRevisionId mrid, boolean force, boolean changing, boolean transitive)
{
- super( md, mrid, force, changing, transitive );
+ super(md, mrid, force, changing, transitive);
}
}
\ No newline at end of file
diff --git a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilResolver.java b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilResolver.java
index e1e243a..36cca28 100644
--- a/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilResolver.java
+++ b/sigil/ivy/resolver/src/org/apache/felix/sigil/ivy/SigilResolver.java
@@ -19,7 +19,6 @@
package org.apache.felix.sigil.ivy;
-
import static java.lang.String.format;
import java.io.File;
@@ -56,7 +55,6 @@
import org.apache.ivy.plugins.resolver.util.ResolvedResource;
import org.apache.ivy.util.FileUtil;
-
/**
* This resolver is able to work with Sigil repositories.
* It does not allow publishing.
@@ -71,7 +69,6 @@
private boolean extractBCP = false;
private Map<String, Resource> resourcesCache = new HashMap<String, Resource>();
-
/**
* no-args constructor required by Ivy.
*
@@ -86,121 +83,115 @@
{
}
-
- public void setConfig( String config )
+ public void setConfig(String config)
{
this.config = config;
}
-
/**
* if true, resolver extracts any jars embedded in Bundle-ClassPath.
*/
- public void setExtractBCP( String extract )
+ public void setExtractBCP(String extract)
{
- this.extractBCP = Boolean.parseBoolean( extract );
+ this.extractBCP = Boolean.parseBoolean(extract);
}
-
private IBldResolver getResolver()
{
- if ( resolver == null )
+ if (resolver == null)
{
- if ( config == null )
+ if (config == null)
{
- throw new Error( "SigilResolver: not configured. Specify config=\"PATH\" in ivysettings.xml." );
+ throw new Error(
+ "SigilResolver: not configured. Specify config=\"PATH\" in ivysettings.xml.");
}
try
{
URI uri;
- File file = new File( config );
+ File file = new File(config);
- if ( file.isAbsolute() )
+ if (file.isAbsolute())
{
uri = file.toURI();
}
else
{
- URI cwd = new File( "." ).toURI();
- uri = cwd.resolve( config );
+ URI cwd = new File(".").toURI();
+ uri = cwd.resolve(config);
}
- Map<String, Properties> repositories = BldFactory.getConfig( uri ).getRepositoryConfig();
- resolver = new BldResolver( repositories );
+ Map<String, Properties> repositories = BldFactory.getConfig(uri).getRepositoryConfig();
+ resolver = new BldResolver(repositories);
}
- catch ( IOException e )
+ catch (IOException e)
{
- throw new Error( "SigilResolver: failed to configure: " + e );
+ throw new Error("SigilResolver: failed to configure: " + e);
}
}
return resolver;
}
-
- public IResolution resolveOrFail( IModelElement element, boolean transitive ) throws ResolutionException
+ public IResolution resolveOrFail(IModelElement element, boolean transitive)
+ throws ResolutionException
{
- return getResolver().resolveOrFail( element, transitive );
+ return getResolver().resolveOrFail(element, transitive);
}
-
- public IResolution resolve( IModelElement element, boolean transitive )
+ public IResolution resolve(IModelElement element, boolean transitive)
{
- return getResolver().resolve( element, transitive );
+ return getResolver().resolve(element, transitive);
}
-
public String getTypeName()
{
return "sigil";
}
-
/*
* synthesize an ivy descriptor for a Sigil dependency. called after Sigil
* resolution, so descriptor already contains resolved version.
*/
- public ResolvedResource findIvyFileRef( DependencyDescriptor dd, ResolveData data )
+ public ResolvedResource findIvyFileRef(DependencyDescriptor dd, ResolveData data)
{
ResolvedResource ref = null;
ModuleRevisionId id = dd.getDependencyRevisionId();
- if ( !id.getOrganisation().equals( ORG_SIGIL ) )
+ if (!id.getOrganisation().equals(ORG_SIGIL))
{
return null;
}
- ISigilBundle bundle = resolve( id );
- if ( bundle == null )
+ ISigilBundle bundle = resolve(id);
+ if (bundle == null)
{
- Log.error( "Failed to find bundle for module " + id );
+ Log.error("Failed to find bundle for module " + id);
return null;
}
String symbolicName = id.getName();
String version = bundle.getVersion().toString();
- Resource res = new SigilIvy( extractBCP ? bundle : null, symbolicName, version );
- ref = new ResolvedResource( res, version );
+ Resource res = new SigilIvy(extractBCP ? bundle : null, symbolicName, version);
+ ref = new ResolvedResource(res, version);
- Log.debug( format( "findIvyFileRef: dd=%s => ref=%s", dd, ref ) );
+ Log.debug(format("findIvyFileRef: dd=%s => ref=%s", dd, ref));
return ref;
}
-
@Override
- protected ResolvedResource findArtifactRef( Artifact artifact, Date date )
+ protected ResolvedResource findArtifactRef(Artifact artifact, Date date)
{
String name = artifact.getName();
ModuleRevisionId id = artifact.getModuleRevisionId();
- if ( !id.getOrganisation().equals( ORG_SIGIL ) )
+ if (!id.getOrganisation().equals(ORG_SIGIL))
{
return null;
}
- ISigilBundle bundle = resolve( id );
- if ( bundle == null )
+ ISigilBundle bundle = resolve(id);
+ if (bundle == null)
{
return null;
}
@@ -211,33 +202,33 @@
try
{
- URL url = ( uri != null ) ? uri.toURL() : bundle.getLocation().toURL();
- if ( name.contains( "!" ) )
+ URL url = (uri != null) ? uri.toURL() : bundle.getLocation().toURL();
+ if (name.contains("!"))
{
- String[] split = name.split( "!" );
- url = new URL( "jar:" + url + "!/" + split[1] + "." + artifact.getExt() );
+ String[] split = name.split("!");
+ url = new URL("jar:" + url + "!/" + split[1] + "." + artifact.getExt());
}
- res = new URLResource( url );
+ res = new URLResource(url);
}
- catch ( MalformedURLException e )
+ catch (MalformedURLException e)
{
- System.out.println( "Oops! " + e );
+ System.out.println("Oops! " + e);
}
String version = bundle.getVersion().toString();
- ResolvedResource ref = new ResolvedResource( res, version );
+ ResolvedResource ref = new ResolvedResource(res, version);
- Log.debug( format( "findArtifactRef: artifact=%s, date=%s => ref=%s", artifact, date, ref ) );
+ Log.debug(format("findArtifactRef: artifact=%s, date=%s => ref=%s", artifact,
+ date, ref));
return ref;
}
-
- private ISigilBundle resolve( ModuleRevisionId id )
+ private ISigilBundle resolve(ModuleRevisionId id)
{
String revision = id.getRevision();
String range = revision;
- if ( revision.indexOf( ',' ) < 0 )
+ if (revision.indexOf(',') < 0)
{
// SigilParser has already resolved the revision from the import
// version range.
@@ -247,83 +238,80 @@
range = "[" + revision + "," + revision + "]";
}
- IRequiredBundle bundle = ModelElementFactory.getInstance().newModelElement(IRequiredBundle.class);
- bundle.setSymbolicName( id.getName() );
- bundle.setVersions( VersionRange.parseVersionRange( range ) );
+ IRequiredBundle bundle = ModelElementFactory.getInstance().newModelElement(
+ IRequiredBundle.class);
+ bundle.setSymbolicName(id.getName());
+ bundle.setVersions(VersionRange.parseVersionRange(range));
- Log.verbose( "searching for " + bundle );
+ Log.verbose("searching for " + bundle);
try
{
- IResolution resolution = resolveOrFail( bundle, false );
- ISigilBundle[] bundles = resolution.getBundles().toArray( new ISigilBundle[0] );
- if ( bundles.length == 1 )
+ IResolution resolution = resolveOrFail(bundle, false);
+ ISigilBundle[] bundles = resolution.getBundles().toArray(new ISigilBundle[0]);
+ if (bundles.length == 1)
{
return bundles[0];
}
}
- catch ( ResolutionException e )
+ catch (ResolutionException e)
{
- Log.warn( e.getMessage() );
+ Log.warn(e.getMessage());
return null;
}
return null;
}
-
/*
* Implement BasicResolver abstract methods
*/
@Override
- protected long get( Resource res, File dest ) throws IOException
+ protected long get(Resource res, File dest) throws IOException
{
- FileUtil.copy( res.openStream(), dest, null );
+ FileUtil.copy(res.openStream(), dest, null);
long len = res.getContentLength();
- Log.debug( format( "get(%s, %s) = %d", res, dest, len ) );
+ Log.debug(format("get(%s, %s) = %d", res, dest, len));
return len;
}
-
@Override
- public Resource getResource( String source ) throws IOException
+ public Resource getResource(String source) throws IOException
{
- source = encode( source );
- Resource res = resourcesCache.get( source );
- if ( res == null )
+ source = encode(source);
+ Resource res = resourcesCache.get(source);
+ if (res == null)
{
- res = new URLResource( new URL( source ) );
- resourcesCache.put( source, res );
+ res = new URLResource(new URL(source));
+ resourcesCache.put(source, res);
}
- Log.debug( format( "SIGIL: getResource(%s) = %d", source, res ) );
+ Log.debug(format("SIGIL: getResource(%s) = %d", source, res));
return res;
}
-
- private static String encode( String source )
+ private static String encode(String source)
{
- return source.trim().replaceAll( " ", "%20" );
+ return source.trim().replaceAll(" ", "%20");
}
-
@SuppressWarnings("unchecked")
@Override
- protected Collection findNames( Map tokenValues, String token )
+ protected Collection findNames(Map tokenValues, String token)
{
- throw new Error( "SigilResolver: findNames not supported." );
+ throw new Error("SigilResolver: findNames not supported.");
}
-
- public void publish( Artifact artifact, File src, boolean overwrite ) throws IOException
+ public void publish(Artifact artifact, File src, boolean overwrite)
+ throws IOException
{
- throw new Error( "SigilResolver: publish not supported." );
+ throw new Error("SigilResolver: publish not supported.");
}
-
- public void beginPublishTransaction( ModuleRevisionId module, boolean overwrite ) throws IOException
+ public void beginPublishTransaction(ModuleRevisionId module, boolean overwrite)
+ throws IOException
{
// stop publish attempts being silently ignored.
- throw new Error( "SigilResolver: publish not supported." );
+ throw new Error("SigilResolver: publish not supported.");
}
/*
@@ -335,13 +323,11 @@
private String name;
private boolean exists = true;
-
private SigilIvy()
{
}
-
- public SigilIvy( ISigilBundle bundle, String module, String rev )
+ public SigilIvy(ISigilBundle bundle, String module, String rev)
{
this.name = "sigil!" + module + "#" + rev;
@@ -350,29 +336,29 @@
String status = "release";
String pub = "20080912162859";
- content.append( "<ivy-module version=\"1.0\">\n" );
+ content.append("<ivy-module version=\"1.0\">\n");
- content.append( format(
- "<info organisation=\"%s\" module=\"%s\" revision=\"%s\" status=\"%s\" publication=\"%s\"/>\n", org,
- module, rev, status, pub ) );
+ content.append(format(
+ "<info organisation=\"%s\" module=\"%s\" revision=\"%s\" status=\"%s\" publication=\"%s\"/>\n",
+ org, module, rev, status, pub));
- String bcp = readBundleClassPath( bundle );
- if ( bcp != null )
+ String bcp = readBundleClassPath(bundle);
+ if (bcp != null)
{
- content.append( "<publications>\n" );
- for ( String j : bcp.split( ",\\s*" ) )
+ content.append("<publications>\n");
+ for (String j : bcp.split(",\\s*"))
{
- if ( j.equals( "." ) )
+ if (j.equals("."))
{
- content.append( "<artifact/>\n" );
+ content.append("<artifact/>\n");
}
- else if ( j.endsWith( ".jar" ) && bundleContains( bundle, j ) )
+ else if (j.endsWith(".jar") && bundleContains(bundle, j))
{
- j = j.substring( 0, j.length() - 4 );
- content.append( format( "<artifact name=\"%s!%s\"/>\n", module, j ) );
+ j = j.substring(0, j.length() - 4);
+ content.append(format("<artifact name=\"%s!%s\"/>\n", module, j));
}
}
- content.append( "</publications>\n" );
+ content.append("</publications>\n");
}
// TODO: add dependencies?
@@ -381,39 +367,38 @@
// revConstraint="[1.2,1.3)"/>
// </dependencies>
- content.append( "</ivy-module>\n" );
+ content.append("</ivy-module>\n");
}
-
- private boolean bundleContains( ISigilBundle bundle, String j )
+ private boolean bundleContains(ISigilBundle bundle, String j)
{
InputStream is = null;
try
{
- URL url = getURL( bundle );
+ URL url = getURL(bundle);
is = url.openStream();
- JarInputStream js = new JarInputStream( is, false );
+ JarInputStream js = new JarInputStream(is, false);
JarEntry entry;
- while ( ( entry = js.getNextJarEntry() ) != null )
+ while ((entry = js.getNextJarEntry()) != null)
{
- if ( j.equals( entry.getName() ) )
+ if (j.equals(entry.getName()))
{
return true;
}
}
}
- catch ( IOException e )
+ catch (IOException e)
{
}
finally
{
- if ( is != null )
+ if (is != null)
{
try
{
is.close();
}
- catch ( IOException e2 )
+ catch (IOException e2)
{
}
}
@@ -421,34 +406,33 @@
return false;
}
-
- private String readBundleClassPath( ISigilBundle bundle )
+ private String readBundleClassPath(ISigilBundle bundle)
{
- if ( bundle == null )
+ if (bundle == null)
return null;
InputStream is = null;
try
{
- URL url = getURL( bundle );
+ URL url = getURL(bundle);
is = url.openStream();
- JarInputStream js = new JarInputStream( is, false );
+ JarInputStream js = new JarInputStream(is, false);
Manifest m = js.getManifest();
- if ( m != null )
- return ( String ) m.getMainAttributes().getValue( "Bundle-ClassPath" );
+ if (m != null)
+ return (String) m.getMainAttributes().getValue("Bundle-ClassPath");
}
- catch ( IOException e )
+ catch (IOException e)
{
}
finally
{
- if ( is != null )
+ if (is != null)
{
try
{
is.close();
}
- catch ( IOException e2 )
+ catch (IOException e2)
{
}
}
@@ -457,77 +441,72 @@
return null;
}
-
- private URL getURL( ISigilBundle bundle ) throws MalformedURLException
+ private URL getURL(ISigilBundle bundle) throws MalformedURLException
{
URI uri = bundle.getBundleInfo().getUpdateLocation();
- if ( uri != null ) {
+ if (uri != null)
+ {
return uri.toURL();
}
- else {
+ else
+ {
File path = bundle.getLocation();
- if ( path == null ) {
- throw new NullPointerException( "Missing location for " + bundle.getSymbolicName() );
+ if (path == null)
+ {
+ throw new NullPointerException("Missing location for "
+ + bundle.getSymbolicName());
}
return path.toURI().toURL();
}
}
-
public String toString()
{
return "SigilIvy[" + name + "]";
}
-
// clone is used to read checksum files
// so clone(getName() + ".sha1").exists() should be false
- public Resource clone( String cloneName )
+ public Resource clone(String cloneName)
{
- Log.debug( "SigilIvy: clone: " + cloneName );
+ Log.debug("SigilIvy: clone: " + cloneName);
SigilIvy clone = new SigilIvy();
clone.name = cloneName;
clone.exists = false;
return clone;
}
-
public boolean exists()
{
return exists;
}
-
public long getContentLength()
{
return content.length();
}
-
public long getLastModified()
{
// TODO Auto-generated method stub
- Log.debug( "NOT IMPLEMENTED: getLastModified" );
+ Log.debug("NOT IMPLEMENTED: getLastModified");
return 0;
}
-
public String getName()
{
return name;
}
-
public boolean isLocal()
{
return false;
}
-
@SuppressWarnings("deprecation")
public InputStream openStream() throws IOException
{
- return new java.io.StringBufferInputStream( content.toString() );
+ return new java.io.StringBufferInputStream(content.toString());
}
}
}