backup work in progress related to FELIX-1324
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@814605 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/sigil/eclipse/runtime/sigil.properties b/sigil/eclipse/runtime/sigil.properties
index 4c4738e..45f2b4d 100644
--- a/sigil/eclipse/runtime/sigil.properties
+++ b/sigil/eclipse/runtime/sigil.properties
@@ -13,21 +13,30 @@
src, \
-imports: \
- org.apache.felix.sigil.common.runtime;version=0.9.0, \
- org.apache.felix.sigil.eclipse;version=0.9.0, \
+ org.apache.felix.sigil.common.runtime, \
+ org.apache.felix.sigil.eclipse, \
org.apache.felix.sigil.eclipse.install, \
+ org.apache.felix.sigil.model, \
+ org.apache.felix.sigil.model.eclipse, \
+ org.apache.felix.sigil.model.osgi, \
+ org.apache.felix.sigil.repository, \
+ org.apache.felix.sigil.ui.eclipse.ui, \
+ org.apache.felix.sigil.ui.eclipse.ui.util, \
+ org.apache.felix.sigil.utils, \
org.eclipse.core.resources, \
org.eclipse.jdt.debug.ui.launchConfigurations, \
+ org.eclipse.jface.fieldassist, \
org.eclipse.jface.viewers, \
- org.eclipse.swt.graphics, \
- org.eclipse.swt.widgets, \
+ org.osgi.framework, \
-requires: \
+ org.eclipse.core.jobs;version=3.4.1, \
org.eclipse.core.runtime;version=3.4.0, \
org.eclipse.debug.core;version=3.4.1, \
org.eclipse.debug.ui;version=3.4.2, \
org.eclipse.equinox.common;version=3.4.0, \
org.eclipse.jdt.launching;version=3.4.1, \
+ org.eclipse.swt;version=3.4.2, \
org.eclipse.ui.workbench;version=3.4.2, \
# end
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 5a86712..a02902c 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
@@ -28,12 +28,6 @@
public class LaunchHelper {
public static IOSGiInstall getInstall(ILaunchConfiguration config) {
-// OSGiInstall install = new OSGiInstall( "felix" );
-// OSGiInstallType type = new OSGiInstallType();
-// type.setMainClass( "org.apache.felix.main.Main" );
-// type.setClassPath( new String[] { "/Users/dave/development/felix-trunk/main/target/org.apache.felix.main-1.9.0-SNAPSHOT.jar" } );
-// install.setType( type );
-// return install;
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
new file mode 100644
index 0000000..de377b1
--- /dev/null
+++ b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/FilteredModelView.java
@@ -0,0 +1,254 @@
+package org.apache.felix.sigil.eclipse.runtime.config;
+
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.felix.sigil.ui.eclipse.ui.SigilUI;
+import org.apache.felix.sigil.ui.eclipse.ui.util.DefaultLabelProvider;
+import org.apache.felix.sigil.ui.eclipse.ui.util.IElementDescriptor;
+import org.apache.felix.sigil.ui.eclipse.ui.util.IFilter;
+import org.apache.felix.sigil.ui.eclipse.ui.util.UIHelper;
+import org.eclipse.jface.viewers.ArrayContentProvider;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyAdapter;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+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>();
+ private ArrayList<T> elements = new ArrayList<T>();
+ private IElementDescriptor<T> elementDescriptor = UIHelper.getDefaultElementDescriptor();
+ private IFilter<T> filter = UIHelper.getDefaultFilter();
+ private StructuredViewer viewer;
+ private String txt = "";
+
+
+ public FilteredModelView( Composite parent, int style )
+ {
+ super( parent, style );
+ initLayout();
+ }
+
+ public List<T> getSelectedElements()
+ {
+ return selected;
+ }
+
+
+ public List<T> getElements()
+ {
+ return elements;
+ }
+
+ public void addElement( T element )
+ {
+ elements.add( element );
+ refresh();
+ }
+
+
+ public void addElements( Collection<T> elements )
+ {
+ this.elements.addAll( elements );
+ refresh();
+ }
+
+
+ public void removeElement( T element )
+ {
+ elements.remove( element );
+ refresh();
+ }
+
+
+ public void removeElements( Collection<T> elements )
+ {
+ this.elements.removeAll( elements );
+ refresh();
+ }
+
+ public void refresh()
+ {
+ SigilUI.runInUI( new Runnable() {
+
+ public void run()
+ {
+ viewer.refresh();
+ }
+ });
+ }
+
+ public void addChangeListener( IChangeListener listener ) {
+
+ }
+
+ private void initLayout()
+ {
+ Text bundleTxt = createSelectionBox( 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 ) );
+
+ setLayout( new GridLayout( 1, false ) );
+ }
+
+
+ private Control createViewBox( Composite parent )
+ {
+ Table table = new Table( this, SWT.MULTI );
+
+ viewer = createViewer( table );
+
+ viewer.setContentProvider( new ArrayContentProvider() );
+
+ viewer.addSelectionChangedListener( new ISelectionChangedListener()
+ {
+ @SuppressWarnings("unchecked")
+ public void selectionChanged( SelectionChangedEvent event )
+ {
+ if ( event.getSelection().isEmpty() )
+ {
+ selected.clear();
+ }
+ else
+ {
+ IStructuredSelection sel = ( IStructuredSelection ) event.getSelection();
+ System.out.println( "Selected " + sel.toList() );
+ selected.addAll( sel.toList() );
+ }
+ }
+ } );
+
+ viewer.setInput( elements );
+
+ viewer.setFilters( new ViewerFilter[]
+ { new ViewerFilter()
+ {
+ @SuppressWarnings("unchecked")
+ @Override
+ public boolean select( Viewer viewer, Object parentElement, Object element )
+ {
+ if ( filter.select( ( T ) element ) )
+ {
+ String name = elementDescriptor.getName( ( T ) element );
+ return name.startsWith( txt );
+ }
+ else
+ {
+ return false;
+ }
+ }
+ } } );
+
+ return table;
+ }
+
+
+ protected StructuredViewer createViewer( Table table )
+ {
+ TableViewer tableViewer = new TableViewer( table );
+
+ tableViewer.setLabelProvider( new DefaultLabelProvider() {
+
+ public Image getImage( Object arg0 )
+ {
+ return null;
+ }
+
+ @SuppressWarnings("unchecked")
+ public String getText( Object element )
+ {
+ return elementDescriptor.getLabel( ( T ) element );
+ }
+
+ });
+
+ return tableViewer;
+ }
+
+
+ private Text createSelectionBox( Composite parent )
+ {
+ final Text txtSelection = new Text( parent, SWT.SEARCH );
+
+ txtSelection.addKeyListener( new KeyAdapter()
+ {
+ @Override
+ 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(
+ FieldDecorationRegistry.DEC_CONTENT_PROPOSAL );
+ selectionDecor.setImage( proposalDecor.getImage() );
+ selectionDecor.setDescriptionText( proposalDecor.getDescription() );
+
+ ExclusionContentProposalProvider<T> proposalProvider = new ExclusionContentProposalProvider<T>(
+ elements, filter, elementDescriptor );
+
+ ContentProposalAdapter proposalAdapter = new ContentProposalAdapter( txtSelection, new TextContentAdapter(),
+ proposalProvider, null, null );
+
+ proposalAdapter.addContentProposalListener( new IContentProposalListener() {
+ public void proposalAccepted( IContentProposal proposal )
+ {
+ WrappedContentProposal<T> valueProposal = (org.apache.felix.sigil.ui.eclipse.ui.util.WrappedContentProposal<T> ) proposal;
+ T selected = valueProposal.getElement();
+ selection = new ArrayList<E>( 1 );
+ selection.add( selected );
+ }
+ });
+
+ proposalAdapter.setProposalAcceptanceStyle( ContentProposalAdapter.PROPOSAL_REPLACE );
+
+ */
+
+ public void setElementDescriptor( IElementDescriptor<T> elementDescriptor )
+ {
+ if ( elementDescriptor == null )
+ {
+ elementDescriptor = UIHelper.getDefaultElementDescriptor();
+ }
+ this.elementDescriptor = elementDescriptor;
+ }
+
+
+ public void setFilter( IFilter<T> filter )
+ {
+ if ( filter == null )
+ {
+ filter = UIHelper.getDefaultFilter();
+ }
+ this.filter = filter;
+ }
+
+
+}
diff --git a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/IChangeListener.java b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/IChangeListener.java
new file mode 100644
index 0000000..7d23203
--- /dev/null
+++ b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/IChangeListener.java
@@ -0,0 +1,6 @@
+package org.apache.felix.sigil.eclipse.runtime.config;
+
+public interface IChangeListener
+{
+
+}
diff --git a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/OSGiConfigurationView.java b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/OSGiConfigurationView.java
index 0af9ba6..19edfbc 100644
--- a/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/OSGiConfigurationView.java
+++ b/sigil/eclipse/runtime/src/org/apache/felix/sigil/eclipse/runtime/config/OSGiConfigurationView.java
@@ -19,15 +19,36 @@
package org.apache.felix.sigil.eclipse.runtime.config;
+
+import org.apache.felix.sigil.eclipse.SigilCore;
+import org.apache.felix.sigil.model.IModelElement;
+import org.apache.felix.sigil.model.IModelWalker;
+import org.apache.felix.sigil.model.eclipse.ISigilBundle;
+import org.apache.felix.sigil.ui.eclipse.ui.util.IElementDescriptor;
+import org.apache.felix.sigil.ui.eclipse.ui.util.IFilter;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.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.widgets.Button;
import org.eclipse.swt.widgets.Composite;
+
/**
* @author dave
*
*/
public class OSGiConfigurationView extends Composite
{
+ private Job job;
+ private FilteredModelView<ISigilBundle> available;
+ private FilteredModelView<ISigilBundle> selected;
/**
* @param parent
@@ -35,17 +56,143 @@
*/
public OSGiConfigurationView( Composite parent, OSGiLaunchConfigurationTab osGiLaunchConfigurationTab )
{
- super(parent, SWT.NONE);
+ super( parent, SWT.NONE );
initLayout();
}
+
+ @Override
+ public void dispose()
+ {
+ if ( job != null ) {
+ job.cancel();
+ }
+
+ super.dispose();
+ }
+
+
/**
*
*/
private void initLayout()
{
- // TODO Auto-generated method stub
+ // components
+ Composite left = new Composite( this, SWT.NONE );
+ Composite middle = new Composite(this, SWT.NONE);
+ Composite right = new Composite(this, SWT.NONE);
+
+ available = new FilteredModelView<ISigilBundle>(left, SWT.NONE);
+ selected = new FilteredModelView<ISigilBundle>(right, SWT.NONE);
+ Button addBtn = new Button( middle, SWT.PUSH );
+ addBtn.setText( "->" );
+ Button removeBtn = new Button( middle, SWT.PUSH );
+ removeBtn.setText( "<-" );
+
+ // customisations
+ addBtn.addSelectionListener( new SelectionAdapter()
+ {
+ @Override
+ public void widgetSelected( SelectionEvent e )
+ {
+ handleAdd();
+ }
+ } );
+
+ removeBtn.addSelectionListener( new SelectionAdapter()
+ {
+ @Override
+ public void widgetSelected( SelectionEvent e )
+ {
+ handleRemove();
+ }
+ } );
+
+ IElementDescriptor<ISigilBundle> descriptor = new IElementDescriptor<ISigilBundle>()
+ {
+ public String getLabel( ISigilBundle element )
+ {
+ return element.getSymbolicName() + " version " + element.getVersion();
+ }
+
+
+ public String getName( ISigilBundle element )
+ {
+ return element.getSymbolicName();
+ }
+ };
+
+ available.setElementDescriptor( descriptor );
+ selected.setElementDescriptor( descriptor );
+
+ available.setFilter( new IFilter<ISigilBundle>() {
+ public boolean select( ISigilBundle element )
+ {
+ return !selected.getElements().contains( element );
+ }
+ } );
+
+ // layout
+ available.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
+ selected.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
+
+ left.setLayout( new GridLayout( 1, false ) );
+ middle.setLayout( new GridLayout( 1, false ) );
+ right.setLayout( new GridLayout( 1, false ) );
+
+ left.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
+ middle.setLayoutData( new GridData( SWT.FILL, SWT.FILL, false, true ) );
+ right.setLayoutData( new GridData( SWT.FILL, SWT.FILL, true, true ) );
+
+ setLayout( new GridLayout( 3, false ) );
+
+ startSearch(available);
}
+ private void startSearch(final FilteredModelView<ISigilBundle> view) {
+ job = new Job( "Finding bundles" )
+ {
+ @Override
+ protected IStatus run( final IProgressMonitor monitor )
+ {
+ SigilCore.getGlobalRepositoryManager().visit( new IModelWalker()
+ {
+ public boolean visit( IModelElement element )
+ {
+ if ( element instanceof ISigilBundle )
+ {
+ ISigilBundle sb = ( ISigilBundle ) element;
+
+ view.addElement( sb );
+
+ return false;
+ }
+ else
+ {
+ return !monitor.isCanceled();
+ }
+ }
+ } );
+
+ return monitor.isCanceled() ? Status.CANCEL_STATUS : Status.OK_STATUS;
+ }
+ };
+ job.schedule();
+ }
+
+
+ private void handleAdd()
+ {
+ selected.addElements( available.getSelectedElements() );
+ available.refresh();
+ }
+
+ private void handleRemove()
+ {
+ selected.removeElements( selected.getSelectedElements() );
+ available.refresh();
+ }
+
+
}