felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dsav...@apache.org
Subject svn commit: r796467 [19/25] - in /felix/trunk/sigil: common/core.tests/src/org/apache/felix/sigil/core/ common/core/src/org/apache/felix/sigil/bnd/ common/core/src/org/apache/felix/sigil/config/ common/core/src/org/apache/felix/sigil/core/ common/core/...
Date Tue, 21 Jul 2009 18:51:41 GMT
Modified: felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/LibraryConfigurationDialog.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/LibraryConfigurationDialog.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/LibraryConfigurationDialog.java (original)
+++ felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/LibraryConfigurationDialog.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,7 @@
 
 package org.apache.felix.sigil.ui.eclipse.ui.preferences;
 
+
 import java.util.Comparator;
 import java.util.Iterator;
 import java.util.TreeSet;
@@ -57,244 +58,294 @@
 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) {
-			return o1.getPackageName().compareTo(o2.getPackageName());
-		}
-	};
-	
-	private String name;
-	private Version version;
-	private TreeSet<IPackageImport> packageImports = new TreeSet<IPackageImport>(COMPARATOR);
-	
-	private boolean editOnly;
-
-	private TableViewer viewer;
-	private Text txtName;
-	private Text txtVersion;
-	
-	public LibraryConfigurationDialog(Shell parentShell) {
-		super(parentShell);
-		name = "";
-		version = Version.emptyVersion;
-	}
-
-	public LibraryConfigurationDialog(Shell parentShell, ILibrary lib) {
-		super(parentShell);
-		editOnly = true;
-		name = lib.getName();
-		version = lib.getVersion();
-		packageImports.addAll(  lib.getImports() );
-	}
-	
-	@Override
-	protected Control createDialogArea(Composite par) {
-		setTitle("Add Library");
-		Composite container = (Composite) super.createDialogArea(par);
-		
-		Composite topPanel = new Composite(container, SWT.NONE);
-				
-		new Label(topPanel, SWT.NONE).setText("Name");
-		
-		txtName = new Text(topPanel, SWT.BORDER);
-		txtName.setEditable( !editOnly );
-		if(name != null) txtName.setText(name);
-		
-		new Label(topPanel, SWT.NONE).setText("Version");
-		
-		txtVersion = new Text(topPanel, SWT.BORDER);
-		txtVersion.setText( version.toString() );
-		txtVersion.setEditable( !editOnly );
-		
-		Composite bottomPanel = new Composite(container, SWT.NONE);
-		
-		Table table = new Table(bottomPanel, SWT.BORDER);
-		table.setSize( new Point( 300, 200 ) );
-		
-		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 remove = new Button(bottomPanel, SWT.PUSH);
-		remove.setText("Remove");
-		remove.setEnabled(false);
-		
-		updateState();
-		
-		// Hookup Listeners
-		txtName.addModifyListener(new ModifyListener() {
-			public void modifyText(ModifyEvent e) {
-				updateState();
-			}
-		});
-		txtVersion.addModifyListener(new ModifyListener() {
-			public void modifyText(ModifyEvent e) {
-				updateState();
-			}
-		});
-		add.addSelectionListener( new SelectionAdapter() {
-			public void widgetSelected(SelectionEvent e) {
-				handleAdd();
-			}
-		});
-		edit.addSelectionListener( new SelectionAdapter() {
-			public void widgetSelected(SelectionEvent e) {
-				handleEdit();
-			}
-		});
-		remove.addSelectionListener( new SelectionAdapter() {
-			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));
-		
-		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() {
-			@Override
-			public String getText(Object element) {
-				IPackageImport pi = (IPackageImport) element;
-				return pi.getPackageName() + " " + pi.getVersions();
-			}			
-		});
-		viewer.addSelectionChangedListener( new ISelectionChangedListener() {
-			public void selectionChanged(SelectionChangedEvent event) {
-				edit.setEnabled(!event.getSelection().isEmpty());
-				remove.setEnabled(!event.getSelection().isEmpty());
-			}
-		});
-		viewer.setContentProvider( new DefaultTableProvider() {
-			public Object[] getElements(Object inputElement) {
-				return toArray(inputElement);
-			}
-		} );
-
-		viewer.setInput(packageImports);
-		return container;
-	}
-	
-	private void updateState() {
-		String error = null;
-		String warning = null;
-		
-		name = txtName.getText();
-		
-		try {
-			version = new Version(txtVersion.getText());
-			if(version.getQualifier().indexOf('_') > -1) {
-				warning = "The use of underscores in a version qualifier is discouraged.";
-			}
-		} catch (IllegalArgumentException e) {
-			version = null;
-			error = "Invalid version format";
-		}
-		
-		Button okButton = getButton(IDialogConstants.OK_ID);
-		if(okButton != null && !okButton.isDisposed()) okButton.setEnabled(allowOkay());
-		
-		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) {
-		Button button = super.createButton(parent, id, label, defaultButton);
-		if(id == IDialogConstants.OK_ID) {
-			button.setEnabled(allowOkay());
-		}
-		return button;
-	}
-	
-	private void handleAdd() {
-		/*NewResourceSelectionDialog<? extends IPackageModelElement> dialog = ResourcesDialogHelper.createImportDialog(getShell(), "Add Imported Package", null, packageImports);
-		if ( dialog.open() == Window.OK ) {
-			IPackageImport pi = ModelElementFactory.getInstance().newModelElement(IPackageImport.class);
-			pi.setPackageName(dialog.getSelectedName());
-			pi.setVersions(dialog.getSelectedVersions());
-			pi.setOptional(dialog.isOptional());
-			
-			packageImports.add(pi);
-			viewer.refresh();
-		}*/
-	}
-
-	private void handleEdit() {
-		/*IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
-		
-		boolean changed = false;
-		
-		if ( !selection.isEmpty() ) {
-			for ( Iterator<IPackageImport> i = selection.iterator(); i.hasNext(); ) {	
-				IPackageImport packageImport = i.next();
-				NewResourceSelectionDialog<? extends IPackageModelElement> dialog = ResourcesDialogHelper.createImportDialog( getShell(), "Edit Imported Package", packageImport, packageImports );
-				dialog.setVersions( packageImport.getVersions() );
-				dialog.setOptional(packageImport.isOptional());
-				if ( dialog.open() == Window.OK ) {
-					changed = true;
-					String packageName = dialog.getSelectedName();
-					VersionRange versionRange = dialog.getSelectedVersions();
-					
-					IPackageImport newImport = ModelElementFactory.getInstance().newModelElement(IPackageImport.class);
-					newImport.setPackageName(packageName);
-					newImport.setVersions(versionRange);
-					newImport.setOptional(dialog.isOptional());
-					
-					packageImports.remove(packageImport);
-					packageImports.add(newImport);
-				}
-			}
-		}
-		
-		if ( changed ) {
-			viewer.refresh();
-		} */
-	}
-
-	private void handleRemove() {
-		IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
-
-		if ( !selection.isEmpty() ) {
-			for ( Iterator<IPackageImport> i = selection.iterator(); i.hasNext(); ) {			
-				packageImports.remove( i.next() );
-			}		
-			
-			viewer.refresh();
-		}
-	}
-
-	public ILibrary getLibrary() {
-		ILibrary library = ModelElementFactory.getInstance().newModelElement(ILibrary.class);
-		
-		library.setName(name);
-		library.setVersion(version);
-		
-		for (IPackageImport pi : packageImports) {
-			library.addImport(pi);
-		}
-		
-		return library;
-	}
+public class LibraryConfigurationDialog extends TitleAreaDialog
+{
+
+    private static final Comparator<IPackageImport> COMPARATOR = new Comparator<IPackageImport>()
+    {
+        public int compare( IPackageImport o1, IPackageImport o2 )
+        {
+            return o1.getPackageName().compareTo( o2.getPackageName() );
+        }
+    };
+
+    private String name;
+    private Version version;
+    private TreeSet<IPackageImport> packageImports = new TreeSet<IPackageImport>( COMPARATOR );
+
+    private boolean editOnly;
+
+    private TableViewer viewer;
+    private Text txtName;
+    private Text txtVersion;
+
+
+    public LibraryConfigurationDialog( Shell parentShell )
+    {
+        super( parentShell );
+        name = "";
+        version = Version.emptyVersion;
+    }
+
+
+    public LibraryConfigurationDialog( Shell parentShell, ILibrary lib )
+    {
+        super( parentShell );
+        editOnly = true;
+        name = lib.getName();
+        version = lib.getVersion();
+        packageImports.addAll( lib.getImports() );
+    }
+
+
+    @Override
+    protected Control createDialogArea( Composite par )
+    {
+        setTitle( "Add Library" );
+        Composite container = ( Composite ) super.createDialogArea( par );
+
+        Composite topPanel = new Composite( container, SWT.NONE );
+
+        new Label( topPanel, SWT.NONE ).setText( "Name" );
+
+        txtName = new Text( topPanel, SWT.BORDER );
+        txtName.setEditable( !editOnly );
+        if ( name != null )
+            txtName.setText( name );
+
+        new Label( topPanel, SWT.NONE ).setText( "Version" );
+
+        txtVersion = new Text( topPanel, SWT.BORDER );
+        txtVersion.setText( version.toString() );
+        txtVersion.setEditable( !editOnly );
+
+        Composite bottomPanel = new Composite( container, SWT.NONE );
+
+        Table table = new Table( bottomPanel, SWT.BORDER );
+        table.setSize( new Point( 300, 200 ) );
+
+        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 remove = new Button( bottomPanel, SWT.PUSH );
+        remove.setText( "Remove" );
+        remove.setEnabled( false );
+
+        updateState();
+
+        // Hookup Listeners
+        txtName.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                updateState();
+            }
+        } );
+        txtVersion.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                updateState();
+            }
+        } );
+        add.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                handleAdd();
+            }
+        } );
+        edit.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                handleEdit();
+            }
+        } );
+        remove.addSelectionListener( new SelectionAdapter()
+        {
+            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 ) );
+
+        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()
+        {
+            @Override
+            public String getText( Object element )
+            {
+                IPackageImport pi = ( IPackageImport ) element;
+                return pi.getPackageName() + " " + pi.getVersions();
+            }
+        } );
+        viewer.addSelectionChangedListener( new ISelectionChangedListener()
+        {
+            public void selectionChanged( SelectionChangedEvent event )
+            {
+                edit.setEnabled( !event.getSelection().isEmpty() );
+                remove.setEnabled( !event.getSelection().isEmpty() );
+            }
+        } );
+        viewer.setContentProvider( new DefaultTableProvider()
+        {
+            public Object[] getElements( Object inputElement )
+            {
+                return toArray( inputElement );
+            }
+        } );
+
+        viewer.setInput( packageImports );
+        return container;
+    }
+
+
+    private void updateState()
+    {
+        String error = null;
+        String warning = null;
+
+        name = txtName.getText();
+
+        try
+        {
+            version = new Version( txtVersion.getText() );
+            if ( version.getQualifier().indexOf( '_' ) > -1 )
+            {
+                warning = "The use of underscores in a version qualifier is discouraged.";
+            }
+        }
+        catch ( IllegalArgumentException e )
+        {
+            version = null;
+            error = "Invalid version format";
+        }
+
+        Button okButton = getButton( IDialogConstants.OK_ID );
+        if ( okButton != null && !okButton.isDisposed() )
+            okButton.setEnabled( allowOkay() );
+
+        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 )
+    {
+        Button button = super.createButton( parent, id, label, defaultButton );
+        if ( id == IDialogConstants.OK_ID )
+        {
+            button.setEnabled( allowOkay() );
+        }
+        return button;
+    }
+
+
+    private void handleAdd()
+    {
+        /*NewResourceSelectionDialog<? extends IPackageModelElement> dialog = ResourcesDialogHelper.createImportDialog(getShell(), "Add Imported Package", null, packageImports);
+        if ( dialog.open() == Window.OK ) {
+        	IPackageImport pi = ModelElementFactory.getInstance().newModelElement(IPackageImport.class);
+        	pi.setPackageName(dialog.getSelectedName());
+        	pi.setVersions(dialog.getSelectedVersions());
+        	pi.setOptional(dialog.isOptional());
+        	
+        	packageImports.add(pi);
+        	viewer.refresh();
+        }*/
+    }
+
+
+    private void handleEdit()
+    {
+        /*IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
+        
+        boolean changed = false;
+        
+        if ( !selection.isEmpty() ) {
+        	for ( Iterator<IPackageImport> i = selection.iterator(); i.hasNext(); ) {	
+        		IPackageImport packageImport = i.next();
+        		NewResourceSelectionDialog<? extends IPackageModelElement> dialog = ResourcesDialogHelper.createImportDialog( getShell(), "Edit Imported Package", packageImport, packageImports );
+        		dialog.setVersions( packageImport.getVersions() );
+        		dialog.setOptional(packageImport.isOptional());
+        		if ( dialog.open() == Window.OK ) {
+        			changed = true;
+        			String packageName = dialog.getSelectedName();
+        			VersionRange versionRange = dialog.getSelectedVersions();
+        			
+        			IPackageImport newImport = ModelElementFactory.getInstance().newModelElement(IPackageImport.class);
+        			newImport.setPackageName(packageName);
+        			newImport.setVersions(versionRange);
+        			newImport.setOptional(dialog.isOptional());
+        			
+        			packageImports.remove(packageImport);
+        			packageImports.add(newImport);
+        		}
+        	}
+        }
+        
+        if ( changed ) {
+        	viewer.refresh();
+        } */
+    }
+
+
+    private void handleRemove()
+    {
+        IStructuredSelection selection = ( IStructuredSelection ) viewer.getSelection();
+
+        if ( !selection.isEmpty() )
+        {
+            for ( Iterator<IPackageImport> i = selection.iterator(); i.hasNext(); )
+            {
+                packageImports.remove( i.next() );
+            }
+
+            viewer.refresh();
+        }
+    }
+
+
+    public ILibrary getLibrary()
+    {
+        ILibrary library = ModelElementFactory.getInstance().newModelElement( ILibrary.class );
+
+        library.setName( name );
+        library.setVersion( version );
+
+        for ( IPackageImport pi : packageImports )
+        {
+            library.addImport( pi );
+        }
+
+        return library;
+    }
 
 }

Modified: felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/LibraryPreferencePage.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/LibraryPreferencePage.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/LibraryPreferencePage.java (original)
+++ felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/LibraryPreferencePage.java Tue Jul 21 18:51:33 2009
@@ -17,8 +17,9 @@
  * under the License.
  */
 
-package org.apache.felix.sigil.ui.eclipse.ui.preferences;
-
+package org.apache.felix.sigil.ui.eclipse.ui.preferences;
+
+
 import java.util.Comparator;
 import java.util.Iterator;
 import java.util.TreeSet;
@@ -27,8 +28,8 @@
 import org.apache.felix.sigil.model.eclipse.ILibrary;
 import org.apache.felix.sigil.ui.eclipse.ui.util.DefaultTableProvider;
 import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferencePage;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.IStructuredSelection;
 import org.eclipse.jface.viewers.LabelProvider;
@@ -36,208 +37,257 @@
 import org.eclipse.jface.viewers.SelectionChangedEvent;
 import org.eclipse.jface.viewers.ISelectionChangedListener;
 import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
+import org.eclipse.swt.SWT;
 import org.eclipse.swt.events.SelectionAdapter;
 import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Table;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-
-public class LibraryPreferencePage extends PreferencePage implements
-		IWorkbenchPreferencePage {
-
-	private TreeSet<ILibrary> libraries;
-	private TableViewer libraryView;
-	
-	private Table table;
-	private Button btnAdd;
-	private Button btnEdit;
-	private Button btnRemove;
-	
-	public void init(IWorkbench workbench) {
-	}
-	
-	@Override
-	protected Control createContents(Composite 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( "," ) ) {
-			prefs.setToDefault(key);
-		}
-		
-		StringBuffer keys = new StringBuffer();
-		
-		for ( ILibrary lib : libraries ) {
-			throw new IllegalStateException( "XXX-FIXME-XXX");
-		}
-		
-		prefs.setValue( SigilCore.LIBRARY_KEYS_PREF, keys.toString() );
-		
-		return true;
-	}
-	
-	private Control initContents(Composite parent) {
-		Composite control = new Composite(parent, SWT.NONE);
-		control.setFont(parent.getFont());
-		
-		GridLayout grid = new GridLayout(3, false);
-		control.setLayout(grid);
-		
-		initRepositories(control);
-		
-		return control;
-	}
-	
-	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 );
-		//table.setFont(control.getFont());
-		btnAdd = new Button(composite, SWT.PUSH);
-		btnAdd.setText("Add...");
-		//add.setFont(control.getFont());
-		btnEdit = new Button(composite, SWT.PUSH);
-		btnEdit.setText("Edit...");
-		//edit.setFont(control.getFont());
-		btnRemove = new Button(composite, SWT.PUSH);
-		btnRemove.setText("Remove");
-		//remove.setFont(control.getFont());
-		
-		// Table Model
-		libraries = new TreeSet<ILibrary>(new Comparator<ILibrary> () {
-			public int compare(ILibrary l1, ILibrary l2) {
-				int c = l1.getName().compareTo( l2.getName() );
-				if ( c == 0 ) {
-					c = l1.getVersion().compareTo( l2.getVersion() );
-				}
-				return c;
-			}
-		});
-		libraryView = new TableViewer(table);
-		libraryView.setLabelProvider(new LabelProvider() {
-			public String getText(Object element) {
-				ILibrary rep = (ILibrary) element;
-				return rep.getName() + " " + rep.getVersion();
-			}			
-		});
-		libraryView.setContentProvider( new DefaultTableProvider() {
-			public Object[] getElements(Object inputElement) {
-				return toArray(inputElement);
-			}
-		} );
-		libraryView.setInput(libraries);
-		
-		// Initialize controls
-		updateButtonStates();
-		
-		// Hookup Listeners
-		libraryView.addSelectionChangedListener( new ISelectionChangedListener() {
-			public void selectionChanged(SelectionChangedEvent event) {
-				updateButtonStates();
-			}
-		});
-		btnAdd.addSelectionListener( new SelectionAdapter() {
-			public void widgetSelected(SelectionEvent e) {
-				handleAdd();
-			}
-		});
-		btnEdit.addSelectionListener( new SelectionAdapter() {
-			public void widgetSelected(SelectionEvent e) {
-				handleEdit();
-			}
-		});
-		btnRemove.addSelectionListener( new SelectionAdapter() {
-			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());
-	}
-	
-	private void updateButtonStates() {
-		ISelection sel = libraryView.getSelection();
-		btnEdit.setEnabled(!sel.isEmpty());
-		btnRemove.setEnabled(!sel.isEmpty());
-	}
-	
-
-	private void handleAdd() {
-		LibraryConfigurationDialog d = new LibraryConfigurationDialog(getShell());
-		if ( d.open() == Window.OK ) {
-			libraries.add(d.getLibrary());
-			libraryView.refresh();
-		}
-	}
-
-	private void handleEdit() {
-		IStructuredSelection sel = (IStructuredSelection) libraryView.getSelection();
-		boolean change = false;
-		
-		
-		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 ) {
-				libraries.remove(lib);
-				libraries.add(d.getLibrary());
-				change = true;
-			}
-		}
-		
-		if ( change ) {
-			libraryView.refresh();
-		}
-	}
-
-	private void handleRemove() {
-		IStructuredSelection sel = (IStructuredSelection) libraryView.getSelection();
-		for ( @SuppressWarnings("unchecked") Iterator<ILibrary> i = sel.iterator(); i.hasNext(); ) {
-			libraries.remove(i);
-		}
-		libraryView.refresh();
-	}
-
-	private void loadPreferences() {
-		IPreferenceStore prefs = getPreferenceStore();
-		String keys = prefs.getString( SigilCore.LIBRARY_KEYS_PREF );
-		if ( keys.trim().length() > 0 ) {
-			for ( String key : keys.split( "," ) ) {
-				String libStr = prefs.getString(key);
-				// XXX-FIXME-XXX parse library string
-				// lib = parse(libstr);
-				// libraries.add(lib);
-			}
-			libraryView.refresh();
-		}
-	}
-}
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+
+public class LibraryPreferencePage extends PreferencePage implements IWorkbenchPreferencePage
+{
+
+    private TreeSet<ILibrary> libraries;
+    private TableViewer libraryView;
+
+    private Table table;
+    private Button btnAdd;
+    private Button btnEdit;
+    private Button btnRemove;
+
+
+    public void init( IWorkbench workbench )
+    {
+    }
+
+
+    @Override
+    protected Control createContents( Composite 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( "," ) )
+        {
+            prefs.setToDefault( key );
+        }
+
+        StringBuffer keys = new StringBuffer();
+
+        for ( ILibrary lib : libraries )
+        {
+            throw new IllegalStateException( "XXX-FIXME-XXX" );
+        }
+
+        prefs.setValue( SigilCore.LIBRARY_KEYS_PREF, keys.toString() );
+
+        return true;
+    }
+
+
+    private Control initContents( Composite parent )
+    {
+        Composite control = new Composite( parent, SWT.NONE );
+        control.setFont( parent.getFont() );
+
+        GridLayout grid = new GridLayout( 3, false );
+        control.setLayout( grid );
+
+        initRepositories( control );
+
+        return control;
+    }
+
+
+    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 );
+        //table.setFont(control.getFont());
+        btnAdd = new Button( composite, SWT.PUSH );
+        btnAdd.setText( "Add..." );
+        //add.setFont(control.getFont());
+        btnEdit = new Button( composite, SWT.PUSH );
+        btnEdit.setText( "Edit..." );
+        //edit.setFont(control.getFont());
+        btnRemove = new Button( composite, SWT.PUSH );
+        btnRemove.setText( "Remove" );
+        //remove.setFont(control.getFont());
+
+        // Table Model
+        libraries = new TreeSet<ILibrary>( new Comparator<ILibrary>()
+        {
+            public int compare( ILibrary l1, ILibrary l2 )
+            {
+                int c = l1.getName().compareTo( l2.getName() );
+                if ( c == 0 )
+                {
+                    c = l1.getVersion().compareTo( l2.getVersion() );
+                }
+                return c;
+            }
+        } );
+        libraryView = new TableViewer( table );
+        libraryView.setLabelProvider( new LabelProvider()
+        {
+            public String getText( Object element )
+            {
+                ILibrary rep = ( ILibrary ) element;
+                return rep.getName() + " " + rep.getVersion();
+            }
+        } );
+        libraryView.setContentProvider( new DefaultTableProvider()
+        {
+            public Object[] getElements( Object inputElement )
+            {
+                return toArray( inputElement );
+            }
+        } );
+        libraryView.setInput( libraries );
+
+        // Initialize controls
+        updateButtonStates();
+
+        // Hookup Listeners
+        libraryView.addSelectionChangedListener( new ISelectionChangedListener()
+        {
+            public void selectionChanged( SelectionChangedEvent event )
+            {
+                updateButtonStates();
+            }
+        } );
+        btnAdd.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                handleAdd();
+            }
+        } );
+        btnEdit.addSelectionListener( new SelectionAdapter()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                handleEdit();
+            }
+        } );
+        btnRemove.addSelectionListener( new SelectionAdapter()
+        {
+            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() );
+    }
+
+
+    private void updateButtonStates()
+    {
+        ISelection sel = libraryView.getSelection();
+        btnEdit.setEnabled( !sel.isEmpty() );
+        btnRemove.setEnabled( !sel.isEmpty() );
+    }
+
+
+    private void handleAdd()
+    {
+        LibraryConfigurationDialog d = new LibraryConfigurationDialog( getShell() );
+        if ( d.open() == Window.OK )
+        {
+            libraries.add( d.getLibrary() );
+            libraryView.refresh();
+        }
+    }
+
+
+    private void handleEdit()
+    {
+        IStructuredSelection sel = ( IStructuredSelection ) libraryView.getSelection();
+        boolean change = false;
+
+        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 )
+            {
+                libraries.remove( lib );
+                libraries.add( d.getLibrary() );
+                change = true;
+            }
+        }
+
+        if ( change )
+        {
+            libraryView.refresh();
+        }
+    }
+
+
+    private void handleRemove()
+    {
+        IStructuredSelection sel = ( IStructuredSelection ) libraryView.getSelection();
+        for ( @SuppressWarnings("unchecked")
+        Iterator<ILibrary> i = sel.iterator(); i.hasNext(); )
+        {
+            libraries.remove( i );
+        }
+        libraryView.refresh();
+    }
+
+
+    private void loadPreferences()
+    {
+        IPreferenceStore prefs = getPreferenceStore();
+        String keys = prefs.getString( SigilCore.LIBRARY_KEYS_PREF );
+        if ( keys.trim().length() > 0 )
+        {
+            for ( String key : keys.split( "," ) )
+            {
+                String libStr = prefs.getString( key );
+                // XXX-FIXME-XXX parse library string
+                // lib = parse(libstr);
+                // libraries.add(lib);
+            }
+            libraryView.refresh();
+        }
+    }
+}

Modified: felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/OptionalPrompt.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/OptionalPrompt.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/OptionalPrompt.java (original)
+++ felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/OptionalPrompt.java Tue Jul 21 18:51:33 2009
@@ -19,58 +19,76 @@
 
 package org.apache.felix.sigil.ui.eclipse.ui.preferences;
 
+
 import org.apache.felix.sigil.eclipse.preferences.PromptablePreference;
 import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.jface.dialogs.MessageDialogWithToggle;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.swt.widgets.Shell;
 
-public class OptionalPrompt {
-	public static boolean optionallyPrompt(IPreferenceStore prefStore, String prefName, String title, String text, Shell parentShell) {
-		boolean result = false;
-		
-		PromptablePreference value = PromptablePreference.valueOf(prefStore.getString(prefName));
-		switch(value) {
-		case Always:
-			result = true;
-			break;
-		case Never:
-			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()) {
-				// User said don't ask again... take the current answer as the new preference
-				prefStore.setValue(prefName, result ? PromptablePreference.Always.name() : PromptablePreference.Never.name());
-			}
-		}
-		
-		return result;
-	}
-	
-	public static int optionallyPromptWithCancel(IPreferenceStore prefStore, String prefName, String title, String text, Shell parentShell) {
-		int result = IDialogConstants.NO_ID;
-		
-		PromptablePreference value = PromptablePreference.valueOf(prefStore.getString(prefName));
-		switch(value) {
-		case Always:
-			result = IDialogConstants.YES_ID;
-			break;
-		case Never:
-			result = IDialogConstants.NO_ID;
-			break;
-		case Prompt:
-			MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoCancelQuestion(parentShell, title, text, "Do not ask this again", false, null, null);
-			result = dialog.getReturnCode();
-			if ( result != IDialogConstants.CANCEL_ID ) {
-				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());
-				}
-			}
-		}
-		
-		return result;
-	}
+
+public class OptionalPrompt
+{
+    public static boolean optionallyPrompt( IPreferenceStore prefStore, String prefName, String title, String text,
+        Shell parentShell )
+    {
+        boolean result = false;
+
+        PromptablePreference value = PromptablePreference.valueOf( prefStore.getString( prefName ) );
+        switch ( value )
+        {
+            case Always:
+                result = true;
+                break;
+            case Never:
+                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() )
+                {
+                    // User said don't ask again... take the current answer as the new preference
+                    prefStore.setValue( prefName, result ? PromptablePreference.Always.name()
+                        : PromptablePreference.Never.name() );
+                }
+        }
+
+        return result;
+    }
+
+
+    public static int optionallyPromptWithCancel( IPreferenceStore prefStore, String prefName, String title,
+        String text, Shell parentShell )
+    {
+        int result = IDialogConstants.NO_ID;
+
+        PromptablePreference value = PromptablePreference.valueOf( prefStore.getString( prefName ) );
+        switch ( value )
+        {
+            case Always:
+                result = IDialogConstants.YES_ID;
+                break;
+            case Never:
+                result = IDialogConstants.NO_ID;
+                break;
+            case Prompt:
+                MessageDialogWithToggle dialog = MessageDialogWithToggle.openYesNoCancelQuestion( parentShell, title,
+                    text, "Do not ask this again", false, null, null );
+                result = dialog.getReturnCode();
+                if ( result != IDialogConstants.CANCEL_ID )
+                {
+                    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() );
+                    }
+                }
+        }
+
+        return result;
+    }
 }

Modified: felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/ProjectDependentPreferencesPage.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/ProjectDependentPreferencesPage.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/ProjectDependentPreferencesPage.java (original)
+++ felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/ProjectDependentPreferencesPage.java Tue Jul 21 18:51:33 2009
@@ -19,31 +19,43 @@
 
 package org.apache.felix.sigil.ui.eclipse.ui.preferences;
 
+
 import org.apache.felix.sigil.ui.eclipse.ui.util.ProjectUtils;
 import org.eclipse.jface.preference.PreferencePage;
 
-public abstract class ProjectDependentPreferencesPage extends PreferencePage {
 
-	public ProjectDependentPreferencesPage(String title) {
-		super(title);
-	}
-
-	@Override
-	public boolean performOk() {
-		if ( isDirty() ) {
-			return ProjectUtils.runTaskWithRebuildCheck(new Runnable() {
-				public void run() {
-					doSave();
-				}
-				
-			}, getShell());
-		}
-		else {
-			return true;
-		}
-	}
+public abstract class ProjectDependentPreferencesPage extends PreferencePage
+{
+
+    public ProjectDependentPreferencesPage( String title )
+    {
+        super( title );
+    }
+
+
+    @Override
+    public boolean performOk()
+    {
+        if ( isDirty() )
+        {
+            return ProjectUtils.runTaskWithRebuildCheck( new Runnable()
+            {
+                public void run()
+                {
+                    doSave();
+                }
+
+            }, getShell() );
+        }
+        else
+        {
+            return true;
+        }
+    }
+
+
+    protected abstract void doSave();
 
-	protected abstract void doSave();
 
-	protected abstract boolean isDirty();
+    protected abstract boolean isDirty();
 }

Modified: felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/SigilPreferencePage.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/SigilPreferencePage.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/SigilPreferencePage.java (original)
+++ felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/SigilPreferencePage.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,7 @@
 
 package org.apache.felix.sigil.ui.eclipse.ui.preferences;
 
+
 import org.apache.felix.sigil.eclipse.SigilCore;
 import org.apache.felix.sigil.eclipse.preferences.PromptablePreference;
 import org.eclipse.jface.preference.FieldEditorPreferencePage;
@@ -27,33 +28,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);
-		
-		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);
-		
-		addField(rebuildExpField);		
-	}
-	
-	@Override
-	protected IPreferenceStore doGetPreferenceStore() {
-		return SigilCore.getDefault().getPreferenceStore();
-	}
+public class SigilPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage
+{
 
-	public void init(IWorkbench workbench) {
-	}
+    @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 );
+
+        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 );
+
+        addField( rebuildExpField );
+    }
+
+
+    @Override
+    protected IPreferenceStore doGetPreferenceStore()
+    {
+        return SigilCore.getDefault().getPreferenceStore();
+    }
+
+
+    public void init( IWorkbench workbench )
+    {
+    }
 
 }

Modified: felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/VersionsPreferencePage.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/VersionsPreferencePage.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/VersionsPreferencePage.java (original)
+++ felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/VersionsPreferencePage.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,7 @@
 
 package org.apache.felix.sigil.ui.eclipse.ui.preferences;
 
+
 import org.apache.felix.sigil.eclipse.SigilCore;
 import org.apache.felix.sigil.model.common.VersionRange;
 import org.apache.felix.sigil.model.common.VersionRangeBoundingRule;
@@ -43,326 +44,394 @@
 import org.eclipse.ui.IWorkbenchPreferencePage;
 import org.osgi.framework.Version;
 
-public class VersionsPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
 
-	private static final Version SAMPLE_VERSION = new Version(1, 2, 3, "qualifier");
+public class VersionsPreferencePage extends PreferencePage implements IWorkbenchPreferencePage
+{
+
+    private static final Version SAMPLE_VERSION = new Version( 1, 2, 3, "qualifier" );
 
-	private IWorkbench workbench;
+    private IWorkbench workbench;
 
-	private Button btnLowerBoundExact;
-	private Button btnLowerBoundMicro;
-	private Button btnLowerBoundMinor;
-	private Button btnLowerBoundMajor;
-	private Button btnLowerBoundAny;
-
-	private Button btnUpperBoundExact;
-	private Button btnUpperBoundMicro;
-	private Button btnUpperBoundMinor;
-	private Button btnUpperBoundMajor;
-	private Button btnUpperBoundAny;
-
-	private Text txtSampleVersion;
-	private Label lblCalculatedRange;
-	private Text txtMatchVersion;
-	private Label lblMatchResult;
-	
-	private VersionRangeBoundingRule lowerBoundRule;
-	private VersionRangeBoundingRule upperBoundRule;
-
-	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\"");
-	}
-	
-	@Override
-	protected Control createContents(Composite parent) {
-		// Create controls
-		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 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)");
-		
-		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);
-
-		// Initialize controls
-		loadPreferences(false);
-		updateRadioButtons();
-		
-		txtSampleVersion.setText(sampleVersion.toString());
-		updateCalculatedRange();
-
-		// Add listeners
-		SelectionListener buttonListener = new SelectionListener() {
-			public void widgetSelected(SelectionEvent e) {
-				readRadioButtons();
-				updateCalculatedRange();
-			}
-
-			public void widgetDefaultSelected(SelectionEvent e) {
-				readRadioButtons();
-				updateCalculatedRange();
-			}
-		};
-		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);
-		
-		txtSampleVersion.addModifyListener(new ModifyListener() {
-			public void modifyText(ModifyEvent e) {
-				try {
-					sampleVersion = new Version(txtSampleVersion.getText());
-				} catch (IllegalArgumentException x) {
-					sampleVersion = null;
-				}
-				updateCalculatedRange();
-			}
-		});
-		txtMatchVersion.addModifyListener(new ModifyListener() {
-			public void modifyText(ModifyEvent e) {
-				try {
-					matchVersion = new Version(txtMatchVersion.getText());
-				} catch (IllegalArgumentException x) {
-					matchVersion = null;
-				}
-				updateCalculatedRange();
-			}
-		});
-
-		// Layout
-		GridLayout layout = new GridLayout(1, false);
-		layout.verticalSpacing = 20;
-		composite.setLayout(layout);
-
-		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));
-		
-		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));
-
-		return composite;
-	}
-
-	private void loadPreferences(boolean useDefaults) {
-		IPreferenceStore prefs = getPreferenceStore();
-		String lowerBoundStr;
-		if(useDefaults) {
-			lowerBoundStr = prefs.getDefaultString(SigilCore.DEFAULT_VERSION_LOWER_BOUND);
-		} else {
-			lowerBoundStr = prefs.getString(SigilCore.DEFAULT_VERSION_LOWER_BOUND);
-		}
-		
-		String upperBoundStr;
-		if(useDefaults) {
-			upperBoundStr = prefs.getDefaultString(SigilCore.DEFAULT_VERSION_UPPER_BOUND);
-		} else {
-			upperBoundStr = prefs.getString(SigilCore.DEFAULT_VERSION_UPPER_BOUND);
-		}
-		
-		lowerBoundRule = VersionRangeBoundingRule.valueOf(lowerBoundStr);
-		upperBoundRule = VersionRangeBoundingRule.valueOf(upperBoundStr);
-	}
-
-	private void updateRadioButtons() {
-		switch (lowerBoundRule) {
-		case Exact:
-			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);
-			break;
-		case Minor:
-			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);
-			break;
-		case Any:
-			btnLowerBoundExact.setSelection(false);
-			btnLowerBoundMicro.setSelection(false);
-			btnLowerBoundMinor.setSelection(false);
-			btnLowerBoundMajor.setSelection(false);
-			btnLowerBoundAny.setSelection(true);
-			break;
-		}
-
-		switch (upperBoundRule) {
-		case Exact:
-			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);
-			break;
-		case Minor:
-			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);
-			break;
-		case Any:
-			btnUpperBoundExact.setSelection(false);
-			btnUpperBoundMicro.setSelection(false);
-			btnUpperBoundMinor.setSelection(false);
-			btnUpperBoundMajor.setSelection(false);
-			btnUpperBoundAny.setSelection(true);
-		}
-	}
-
-	private void readRadioButtons() {
-		if (btnLowerBoundExact.getSelection()) {
-			lowerBoundRule = VersionRangeBoundingRule.Exact;
-		} else if (btnLowerBoundMicro.getSelection()) {
-			lowerBoundRule = VersionRangeBoundingRule.Micro;
-		} else if (btnLowerBoundMinor.getSelection()) {
-			lowerBoundRule = VersionRangeBoundingRule.Minor;
-		} else if (btnLowerBoundMajor.getSelection()) {
-			lowerBoundRule = VersionRangeBoundingRule.Major;
-		} else if(btnLowerBoundAny.getSelection()) {
-			lowerBoundRule = VersionRangeBoundingRule.Any;
-		}
-
-		if (btnUpperBoundExact.getSelection()) {
-			upperBoundRule = VersionRangeBoundingRule.Exact;
-		} else if (btnUpperBoundMicro.getSelection()) {
-			upperBoundRule = VersionRangeBoundingRule.Micro;
-		} else if (btnUpperBoundMinor.getSelection()) {
-			upperBoundRule = VersionRangeBoundingRule.Minor;
-		} else if (btnUpperBoundMajor.getSelection()) {
-			upperBoundRule = VersionRangeBoundingRule.Major;
-		} else if(btnUpperBoundAny.getSelection()) {
-			upperBoundRule = VersionRangeBoundingRule.Any;
-		}
-	}
-
-	private void updateCalculatedRange() {
-		VersionRange range;
-		String rangeStr;
-		String matchResult;
-		
-		if(sampleVersion == null) {
-			range = null;
-			rangeStr = "";
-		} else {
-			range = VersionRange.newInstance(sampleVersion, lowerBoundRule, upperBoundRule);
-			rangeStr = range.toString();
-		}
-		lblCalculatedRange.setText(rangeStr);
-		
-		if(matchVersion == null || range == null) {
-			matchResult = "";
-		} else {
-			matchResult = range.contains(matchVersion) ? "MATCH!" : "No Match";
-		}
-		lblMatchResult.setText(matchResult);
-	}
-
-	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());
-
-		return true;
-	}
-	
-	@Override
-	protected void performDefaults() {
-		super.performDefaults();
-		loadPreferences(true);
-		updateRadioButtons();
-		updateCalculatedRange();
-	}
+    private Button btnLowerBoundExact;
+    private Button btnLowerBoundMicro;
+    private Button btnLowerBoundMinor;
+    private Button btnLowerBoundMajor;
+    private Button btnLowerBoundAny;
+
+    private Button btnUpperBoundExact;
+    private Button btnUpperBoundMicro;
+    private Button btnUpperBoundMinor;
+    private Button btnUpperBoundMajor;
+    private Button btnUpperBoundAny;
+
+    private Text txtSampleVersion;
+    private Label lblCalculatedRange;
+    private Text txtMatchVersion;
+    private Label lblMatchResult;
+
+    private VersionRangeBoundingRule lowerBoundRule;
+    private VersionRangeBoundingRule upperBoundRule;
+
+    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\"" );
+    }
+
+
+    @Override
+    protected Control createContents( Composite parent )
+    {
+        // Create controls
+        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 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)" );
+
+        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 );
+
+        // Initialize controls
+        loadPreferences( false );
+        updateRadioButtons();
+
+        txtSampleVersion.setText( sampleVersion.toString() );
+        updateCalculatedRange();
+
+        // Add listeners
+        SelectionListener buttonListener = new SelectionListener()
+        {
+            public void widgetSelected( SelectionEvent e )
+            {
+                readRadioButtons();
+                updateCalculatedRange();
+            }
+
+
+            public void widgetDefaultSelected( SelectionEvent e )
+            {
+                readRadioButtons();
+                updateCalculatedRange();
+            }
+        };
+        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 );
+
+        txtSampleVersion.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                try
+                {
+                    sampleVersion = new Version( txtSampleVersion.getText() );
+                }
+                catch ( IllegalArgumentException x )
+                {
+                    sampleVersion = null;
+                }
+                updateCalculatedRange();
+            }
+        } );
+        txtMatchVersion.addModifyListener( new ModifyListener()
+        {
+            public void modifyText( ModifyEvent e )
+            {
+                try
+                {
+                    matchVersion = new Version( txtMatchVersion.getText() );
+                }
+                catch ( IllegalArgumentException x )
+                {
+                    matchVersion = null;
+                }
+                updateCalculatedRange();
+            }
+        } );
+
+        // Layout
+        GridLayout layout = new GridLayout( 1, false );
+        layout.verticalSpacing = 20;
+        composite.setLayout( layout );
+
+        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 ) );
+
+        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 ) );
+
+        return composite;
+    }
+
+
+    private void loadPreferences( boolean useDefaults )
+    {
+        IPreferenceStore prefs = getPreferenceStore();
+        String lowerBoundStr;
+        if ( useDefaults )
+        {
+            lowerBoundStr = prefs.getDefaultString( SigilCore.DEFAULT_VERSION_LOWER_BOUND );
+        }
+        else
+        {
+            lowerBoundStr = prefs.getString( SigilCore.DEFAULT_VERSION_LOWER_BOUND );
+        }
+
+        String upperBoundStr;
+        if ( useDefaults )
+        {
+            upperBoundStr = prefs.getDefaultString( SigilCore.DEFAULT_VERSION_UPPER_BOUND );
+        }
+        else
+        {
+            upperBoundStr = prefs.getString( SigilCore.DEFAULT_VERSION_UPPER_BOUND );
+        }
+
+        lowerBoundRule = VersionRangeBoundingRule.valueOf( lowerBoundStr );
+        upperBoundRule = VersionRangeBoundingRule.valueOf( upperBoundStr );
+    }
+
+
+    private void updateRadioButtons()
+    {
+        switch ( lowerBoundRule )
+        {
+            case Exact:
+                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 );
+                break;
+            case Minor:
+                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 );
+                break;
+            case Any:
+                btnLowerBoundExact.setSelection( false );
+                btnLowerBoundMicro.setSelection( false );
+                btnLowerBoundMinor.setSelection( false );
+                btnLowerBoundMajor.setSelection( false );
+                btnLowerBoundAny.setSelection( true );
+                break;
+        }
+
+        switch ( upperBoundRule )
+        {
+            case Exact:
+                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 );
+                break;
+            case Minor:
+                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 );
+                break;
+            case Any:
+                btnUpperBoundExact.setSelection( false );
+                btnUpperBoundMicro.setSelection( false );
+                btnUpperBoundMinor.setSelection( false );
+                btnUpperBoundMajor.setSelection( false );
+                btnUpperBoundAny.setSelection( true );
+        }
+    }
+
+
+    private void readRadioButtons()
+    {
+        if ( btnLowerBoundExact.getSelection() )
+        {
+            lowerBoundRule = VersionRangeBoundingRule.Exact;
+        }
+        else if ( btnLowerBoundMicro.getSelection() )
+        {
+            lowerBoundRule = VersionRangeBoundingRule.Micro;
+        }
+        else if ( btnLowerBoundMinor.getSelection() )
+        {
+            lowerBoundRule = VersionRangeBoundingRule.Minor;
+        }
+        else if ( btnLowerBoundMajor.getSelection() )
+        {
+            lowerBoundRule = VersionRangeBoundingRule.Major;
+        }
+        else if ( btnLowerBoundAny.getSelection() )
+        {
+            lowerBoundRule = VersionRangeBoundingRule.Any;
+        }
+
+        if ( btnUpperBoundExact.getSelection() )
+        {
+            upperBoundRule = VersionRangeBoundingRule.Exact;
+        }
+        else if ( btnUpperBoundMicro.getSelection() )
+        {
+            upperBoundRule = VersionRangeBoundingRule.Micro;
+        }
+        else if ( btnUpperBoundMinor.getSelection() )
+        {
+            upperBoundRule = VersionRangeBoundingRule.Minor;
+        }
+        else if ( btnUpperBoundMajor.getSelection() )
+        {
+            upperBoundRule = VersionRangeBoundingRule.Major;
+        }
+        else if ( btnUpperBoundAny.getSelection() )
+        {
+            upperBoundRule = VersionRangeBoundingRule.Any;
+        }
+    }
+
+
+    private void updateCalculatedRange()
+    {
+        VersionRange range;
+        String rangeStr;
+        String matchResult;
+
+        if ( sampleVersion == null )
+        {
+            range = null;
+            rangeStr = "";
+        }
+        else
+        {
+            range = VersionRange.newInstance( sampleVersion, lowerBoundRule, upperBoundRule );
+            rangeStr = range.toString();
+        }
+        lblCalculatedRange.setText( rangeStr );
+
+        if ( matchVersion == null || range == null )
+        {
+            matchResult = "";
+        }
+        else
+        {
+            matchResult = range.contains( matchVersion ) ? "MATCH!" : "No Match";
+        }
+        lblMatchResult.setText( matchResult );
+    }
+
+
+    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() );
+
+        return true;
+    }
+
+
+    @Override
+    protected void performDefaults()
+    {
+        super.performDefaults();
+        loadPreferences( true );
+        updateRadioButtons();
+        updateCalculatedRange();
+    }
 
 }

Modified: felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/installs/OSGiInstallsPreferencePage.java
URL: http://svn.apache.org/viewvc/felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/installs/OSGiInstallsPreferencePage.java?rev=796467&r1=796466&r2=796467&view=diff
==============================================================================
--- felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/installs/OSGiInstallsPreferencePage.java (original)
+++ felix/trunk/sigil/eclipse/ui/src/org/apache/felix/sigil/ui/eclipse/ui/preferences/installs/OSGiInstallsPreferencePage.java Tue Jul 21 18:51:33 2009
@@ -19,6 +19,7 @@
 
 package org.apache.felix.sigil.ui.eclipse.ui.preferences.installs;
 
+
 import java.util.HashMap;
 import java.util.UUID;
 
@@ -52,250 +53,322 @@
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchPreferencePage;
 
-public class OSGiInstallsPreferencePage extends ProjectDependentPreferencesPage implements
-		IWorkbenchPreferencePage {
 
-	private class Install {
-		private String id;
-		private String location;
-		private IOSGiInstallType type;
-		
-		private Install(String id, String location) {
-			this.id = id;
-			this.location = location;
-		}
-
-		private IOSGiInstallType getType() {
-			if ( type == null ) {
-				type = SigilCore.getInstallManager().findInstallType(location);
-			}
-			return type;
-		}
-	}
-
-	private HashMap<String, Install> installs = new HashMap<String, Install>();
-	private CheckboxTableViewer viewer;
-	private boolean changed;
-	
-	public OSGiInstallsPreferencePage() {
-		super("OSGi Installs");
-	}
-	
-	public void init(IWorkbench workbench) {
-	}
-
-
-	@Override
-	protected Control createContents(Composite parent) {
-		Composite control = new Composite(parent, SWT.NONE);
-		
-		buildComponents(control);
-		
-		load();
-		
-		checkValid();
-		
-		return control;
-	}
-
-	@Override
-	protected boolean isDirty() {
-		return changed;
-	}
-
-	
-	private void buildComponents(Composite control) {
-		new Label(control, SWT.NONE).setText("Installs:");
-		new Label(control, SWT.NONE); // padding
-		
-		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() {
-			@Override
-			public void widgetSelected(SelectionEvent e) {
-				add();
-			}			
-		});
-		
-		final Button remove = new Button(control, SWT.PUSH);
-		remove.setEnabled(false);
-		remove.setText("Remove");
-		remove.addSelectionListener( new SelectionAdapter() {
-			@Override
-			public void widgetSelected(SelectionEvent e) {
-				remove();
-			}			
-		});
-		
-		// viewers
-		viewer = new CheckboxTableViewer(table);
-		viewer.setContentProvider( new DefaultTableProvider() {
-			public Object[] getElements(Object inputElement) {
-				return toArray(inputElement);
-			}			
-		});
-				
-		viewer.setLabelProvider( new LabelProvider() {
-			@Override
-			public String getText(Object element) {
-				Install i = (Install) element;
-				IOSGiInstallType type = i.getType();
-				if ( type == null ) {
-					return "<invalid> [" + i.location + "]";
-				}
-				else {
-					return type.getName() + " " + type.getVersion() + " [" + i.location + "]";
-				}
-			}
-
-			@Override
-			public Image getImage(Object element) {
-				Install i = (Install) element;
-				IOSGiInstallType type = i.getType();
-				
-				if (type == null) {
-					return null;
-				} else {
-				return type.getIcon();
-				}
-			}			
-		});
-		
-		viewer.addSelectionChangedListener( new ISelectionChangedListener() {
-			public void selectionChanged(SelectionChangedEvent event) {
-				boolean enabled = !event.getSelection().isEmpty();
-				remove.setEnabled(enabled );
-			}
-		});
-		
-		viewer.addCheckStateListener( new ICheckStateListener () {
-			public void checkStateChanged(CheckStateChangedEvent event) {
-				if ( event.getChecked() ) {
-					changed = true;
-				}
-				viewer.setCheckedElements( new Object[] { event.getElement() } );
-			}
-		});
-		
-		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));		
-	}
-
-	private void load() {
-		String pref = getPreferenceStore().getString(SigilCore.OSGI_INSTALLS);
-		if ( pref != null && pref.length() > 0 ) {
-			for ( String id : pref.split(",") ) {
-				String loc = getPreferenceStore().getString( SigilCore.OSGI_INSTALL_PREFIX + id );
-				installs.put( id, new Install( id, loc ) );
-			}
-		}
-		
-		viewer.refresh();
-		
-		if ( !installs.isEmpty() ) {
-			String defId = getPreferenceStore().getString( SigilCore.OSGI_DEFAULT_INSTALL_ID );
-			if ( defId == null || defId.trim().length() == 0 ) {
-				viewer.setCheckedElements( new Object[] { installs.values().iterator().next() } );
-			}
-			else {
-				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 ) {
-			for ( String id : pref.split(",") ) {
-				getPreferenceStore().setToDefault( SigilCore.OSGI_INSTALL_PREFIX + id );
-			}
-		}
-		
-		// store new configs
-		if ( installs.isEmpty() ) {
-			getPreferenceStore().setToDefault(SigilCore.OSGI_INSTALLS);
-			getPreferenceStore().setToDefault(SigilCore.OSGI_DEFAULT_INSTALL_ID);
-		}
-		else {
-			StringBuffer buf = new StringBuffer();
-			for (Install i : installs.values() ) {
-				if ( buf.length() > 0 ) {
-					buf.append(",");
-				}
-				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);
-		}
-		changed = false;
-	}
-
-	private boolean isOK() {
-		return installs.isEmpty() || viewer.getCheckedElements().length > 0;
-	}
-	
-	private void add() {
-		Shell shell = SigilUI.getActiveWorkbenchShell();
-		DirectoryDialog dialog = new DirectoryDialog(shell);
-		String dir = dialog.open();
-		if ( dir != null ) {
-			Install install = new Install( UUID.randomUUID().toString(), dir );
-			if ( install.getType() == null ) {
-				MessageDialog.openError(shell, "Error", "Invalid OSGi install directory" );
-			}
-			else {
-				boolean empty = installs.isEmpty();
-				
-				installs.put( install.id, install );
-				viewer.refresh();
-				
-				if ( empty ) {
-					viewer.setCheckedElements( new Object[] { install } );
-				}
-				
-				checkValid();
-				changed = true;
-			}
-		}
-	}
-
-	private void checkValid() {
-		if ( isOK() ) {
-			setErrorMessage(null);
-			setValid(true);
-		}
-		else {
-			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);
-		viewer.refresh();
-		if ( def && installs.size() > 0 ) {
-			viewer.setCheckedElements( new Object[] { installs.values().iterator().next() } );
-		}
-		checkValid();
-		changed = true;
-	}
-
-	@Override
-	protected IPreferenceStore doGetPreferenceStore() {
-		return SigilCore.getDefault().getPreferenceStore();
-	}
+public class OSGiInstallsPreferencePage extends ProjectDependentPreferencesPage implements IWorkbenchPreferencePage
+{
+
+    private class Install
+    {
+        private String id;
+        private String location;
+        private IOSGiInstallType type;
+
+
+        private Install( String id, String location )
+        {
+            this.id = id;
+            this.location = location;
+        }
+
+
+        private IOSGiInstallType getType()
+        {
+            if ( type == null )
+            {
+                type = SigilCore.getInstallManager().findInstallType( location );
+            }
+            return type;
+        }
+    }
+
+    private HashMap<String, Install> installs = new HashMap<String, Install>();
+    private CheckboxTableViewer viewer;
+    private boolean changed;
+
+
+    public OSGiInstallsPreferencePage()
+    {
+        super( "OSGi Installs" );
+    }
+
+
+    public void init( IWorkbench workbench )
+    {
+    }
+
+
+    @Override
+    protected Control createContents( Composite parent )
+    {
+        Composite control = new Composite( parent, SWT.NONE );
+
+        buildComponents( control );
+
+        load();
+
+        checkValid();
+
+        return control;
+    }
+
+
+    @Override
+    protected boolean isDirty()
+    {
+        return changed;
+    }
+
+
+    private void buildComponents( Composite control )
+    {
+        new Label( control, SWT.NONE ).setText( "Installs:" );
+        new Label( control, SWT.NONE ); // padding
+
+        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()
+        {
+            @Override
+            public void widgetSelected( SelectionEvent e )
+            {
+                add();
+            }
+        } );
+
+        final Button remove = new Button( control, SWT.PUSH );
+        remove.setEnabled( false );
+        remove.setText( "Remove" );
+        remove.addSelectionListener( new SelectionAdapter()
+        {
+            @Override
+            public void widgetSelected( SelectionEvent e )
+            {
+                remove();
+            }
+        } );
+
+        // viewers
+        viewer = new CheckboxTableViewer( table );
+        viewer.setContentProvider( new DefaultTableProvider()
+        {
+            public Object[] getElements( Object inputElement )
+            {
+                return toArray( inputElement );
+            }
+        } );
+
+        viewer.setLabelProvider( new LabelProvider()
+        {
+            @Override
+            public String getText( Object element )
+            {
+                Install i = ( Install ) element;
+                IOSGiInstallType type = i.getType();
+                if ( type == null )
+                {
+                    return "<invalid> [" + i.location + "]";
+                }
+                else
+                {
+                    return type.getName() + " " + type.getVersion() + " [" + i.location + "]";
+                }
+            }
+
+
+            @Override
+            public Image getImage( Object element )
+            {
+                Install i = ( Install ) element;
+                IOSGiInstallType type = i.getType();
+
+                if ( type == null )
+                {
+                    return null;
+                }
+                else
+                {
+                    return type.getIcon();
+                }
+            }
+        } );
+
+        viewer.addSelectionChangedListener( new ISelectionChangedListener()
+        {
+            public void selectionChanged( SelectionChangedEvent event )
+            {
+                boolean enabled = !event.getSelection().isEmpty();
+                remove.setEnabled( enabled );
+            }
+        } );
+
+        viewer.addCheckStateListener( new ICheckStateListener()
+        {
+            public void checkStateChanged( CheckStateChangedEvent event )
+            {
+                if ( event.getChecked() )
+                {
+                    changed = true;
+                }
+                viewer.setCheckedElements( new Object[]
+                    { event.getElement() } );
+            }
+        } );
+
+        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 ) );
+    }
+
+
+    private void load()
+    {
+        String pref = getPreferenceStore().getString( SigilCore.OSGI_INSTALLS );
+        if ( pref != null && pref.length() > 0 )
+        {
+            for ( String id : pref.split( "," ) )
+            {
+                String loc = getPreferenceStore().getString( SigilCore.OSGI_INSTALL_PREFIX + id );
+                installs.put( id, new Install( id, loc ) );
+            }
+        }
+
+        viewer.refresh();
+
+        if ( !installs.isEmpty() )
+        {
+            String defId = getPreferenceStore().getString( SigilCore.OSGI_DEFAULT_INSTALL_ID );
+            if ( defId == null || defId.trim().length() == 0 )
+            {
+                viewer.setCheckedElements( new Object[]
+                    { installs.values().iterator().next() } );
+            }
+            else
+            {
+                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 )
+        {
+            for ( String id : pref.split( "," ) )
+            {
+                getPreferenceStore().setToDefault( SigilCore.OSGI_INSTALL_PREFIX + id );
+            }
+        }
+
+        // store new configs
+        if ( installs.isEmpty() )
+        {
+            getPreferenceStore().setToDefault( SigilCore.OSGI_INSTALLS );
+            getPreferenceStore().setToDefault( SigilCore.OSGI_DEFAULT_INSTALL_ID );
+        }
+        else
+        {
+            StringBuffer buf = new StringBuffer();
+            for ( Install i : installs.values() )
+            {
+                if ( buf.length() > 0 )
+                {
+                    buf.append( "," );
+                }
+                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 );
+        }
+        changed = false;
+    }
+
+
+    private boolean isOK()
+    {
+        return installs.isEmpty() || viewer.getCheckedElements().length > 0;
+    }
+
+
+    private void add()
+    {
+        Shell shell = SigilUI.getActiveWorkbenchShell();
+        DirectoryDialog dialog = new DirectoryDialog( shell );
+        String dir = dialog.open();
+        if ( dir != null )
+        {
+            Install install = new Install( UUID.randomUUID().toString(), dir );
+            if ( install.getType() == null )
+            {
+                MessageDialog.openError( shell, "Error", "Invalid OSGi install directory" );
+            }
+            else
+            {
+                boolean empty = installs.isEmpty();
+
+                installs.put( install.id, install );
+                viewer.refresh();
+
+                if ( empty )
+                {
+                    viewer.setCheckedElements( new Object[]
+                        { install } );
+                }
+
+                checkValid();
+                changed = true;
+            }
+        }
+    }
+
+
+    private void checkValid()
+    {
+        if ( isOK() )
+        {
+            setErrorMessage( null );
+            setValid( true );
+        }
+        else
+        {
+            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 );
+        viewer.refresh();
+        if ( def && installs.size() > 0 )
+        {
+            viewer.setCheckedElements( new Object[]
+                { installs.values().iterator().next() } );
+        }
+        checkValid();
+        changed = true;
+    }
+
+
+    @Override
+    protected IPreferenceStore doGetPreferenceStore()
+    {
+        return SigilCore.getDefault().getPreferenceStore();
+    }
 }



Mime
View raw message