1 11 package org.eclipse.jface.internal.databinding.provisional.viewers; 12 13 import org.eclipse.jface.internal.databinding.internal.viewers.AbstractListViewerObservableCollectionWithLabels; 14 import org.eclipse.jface.internal.databinding.internal.viewers.StructuredViewerObservableValue; 15 import org.eclipse.jface.internal.databinding.internal.viewers.TableViewerObservableCollectionWithLabels; 16 import org.eclipse.jface.internal.databinding.provisional.description.Property; 17 import org.eclipse.jface.internal.databinding.provisional.factories.IObservableFactory; 18 import org.eclipse.jface.internal.databinding.provisional.observable.IObservable; 19 import org.eclipse.jface.viewers.AbstractListViewer; 20 import org.eclipse.jface.viewers.StructuredViewer; 21 import org.eclipse.jface.viewers.TableViewer; 22 23 45 final public class ViewersObservableFactory implements IObservableFactory { 46 47 50 public ViewersObservableFactory() { 51 } 52 53 58 public ViewersObservableFactory(int updateTime) { 59 } 60 61 public IObservable createObservable(Object description) { 62 if (description instanceof Property) { 63 Object object = ((Property) description).getObject(); 64 Object attribute = ((Property) description).getPropertyID(); 65 if (object instanceof StructuredViewer 66 && ViewersProperties.SINGLE_SELECTION.equals(attribute)) { 67 return new StructuredViewerObservableValue( 68 (StructuredViewer) object, (String ) attribute); 69 } else if (object instanceof AbstractListViewer 70 && ViewersProperties.SINGLE_SELECTION.equals(attribute)) 71 return new StructuredViewerObservableValue( 72 (AbstractListViewer) object, (String ) attribute); 73 else if (object instanceof AbstractListViewer 74 && ViewersProperties.CONTENT.equals(attribute)) 75 return new AbstractListViewerObservableCollectionWithLabels( 76 (AbstractListViewer) object); 77 else if (object instanceof TableViewer 78 && ViewersProperties.CONTENT.equals(attribute)) { 79 return new TableViewerObservableCollectionWithLabels( 80 (TableViewer) object); 81 } 82 } else if (description instanceof AbstractListViewer) { 83 return new AbstractListViewerObservableCollectionWithLabels( 84 (AbstractListViewer) description); 85 } else if (description instanceof TableViewer) { 86 return new TableViewerObservableCollectionWithLabels( 87 (TableViewer) description); 88 } 89 return null; 90 } 91 } 92 | Popular Tags |