protected DataBindingContext initDataBindings() { DataBindingContext bindingContext = new DataBindingContext(); // ObservableListContentProvider listContentProvider = new ObservableListContentProvider(); IObservableMap[] observeMaps = BeansObservables.observeMaps( listContentProvider.getKnownElements(), ApprovalMini.class, new String[] { "idApproval1", "approval1LetterDate", "apprMinisRef", "minisapprLetterDate", "minisapprRef", "letterdatetoDept", "refapprtoDept", "monthAppr", "quarterYear", "yearAppr", "filename", "attachment", "caseID" }); tableViewer.setLabelProvider(new ObservableMapLabelProvider(observeMaps)); tableViewer.setContentProvider(listContentProvider); // approvalMiniList = Properties.selfList(ApprovalMini.class).observe(approvalMinis); tableViewer.setInput(approvalMiniList); // return bindingContext; }
protected DataBindingContext initDataBindings() { DataBindingContext bindingContext = new DataBindingContext(); // ObservableListContentProvider listContentProvider = new ObservableListContentProvider(); IObservableMap observeMap = PojoObservables.observeMap( listContentProvider.getKnownElements(), SettingNote.class, "name"); checkboxTableViewer.setLabelProvider(new ObservableMapLabelProvider(observeMap)); checkboxTableViewer.setContentProvider(listContentProvider); // IObservableList categoryNotesObserveList = EMFProperties.list(StorynotesPackage.Literals.CATEGORY__NOTES).observe(category); checkboxTableViewer.setInput(categoryNotesObserveList); // return bindingContext; }
protected void createDataComposite(final Composite parent) { createViewerHeaderLabel(parent); final Composite buttonsComposite = getWidgetFactory().createPlainComposite(parent, SWT.NONE); buttonsComposite.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).create()); buttonsComposite.setLayout( GridLayoutFactory.fillDefaults().numColumns(1).spacing(0, 3).create()); createAddDataButton(buttonsComposite); updateDataButton = createEditDataButton(buttonsComposite); removeDataButton = createRemoveDataButton(buttonsComposite); promoteDataButton = createMoveDataButton(buttonsComposite); dataTableViewer = new TableViewer( parent, SWT.BORDER | SWT.MULTI | SWT.NO_FOCUS | SWT.H_SCROLL | SWT.V_SCROLL); dataTableViewer.getTable().setLayout(GridLayoutFactory.fillDefaults().create()); dataTableViewer .getTable() .setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, SWTBotConstants.SWTBOT_ID_PROCESS_DATA_LIST); getWidgetFactory().adapt(dataTableViewer.getTable(), false, false); dataTableViewer .getTable() .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(200, 100).create()); dataTableViewer.setSorter(new ViewerSorter()); dataTableViewer.addDoubleClickListener(this); final ObservableListContentProvider contentProvider = new ObservableListContentProvider(); dataTableViewer.setContentProvider(contentProvider); dataTableViewer.addFilter(hideBusinessObjectData()); // create the label provider including monitoring // of the changes of the labels final IObservableSet knownElements = contentProvider.getKnownElements(); final IObservableMap[] labelMaps = EMFObservables.observeMaps( knownElements, new EStructuralFeature[] { ProcessPackage.Literals.ELEMENT__NAME, ProcessPackage.Literals.DATA__DATA_TYPE }); dataTableViewer.setLabelProvider(new DataStyledTreeLabelProvider(labelMaps)); }
/** * * (non-Javadoc) * * @see * org.eclipse.jface.databinding.viewers.ObservableListContentProvider#inputChanged * (org.eclipse.jface.viewers.Viewer, * java.lang.Object, java.lang.Object) */ @SuppressWarnings("unchecked") @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { listenerSupport.unhookAllTargets(); if (observableList != null) { observableList.removeListChangeListener(listener); observableList = null; } super.inputChanged(viewer, oldInput, newInput); this.viewer = (StructuredViewer) viewer; observableList = (ObservableList) newInput; if (observableList != null) { observableList.addListChangeListener(listener); for (Iterator iterator = observableList.iterator(); iterator.hasNext(); ) { listenerSupport.hookListener(iterator.next()); } } }
@Override public TabItem doCreateForm( TabFolder folder, EditingDomain domain, DataBindingContext dbc, IObservableValue master) { TabItem item = new TabItem(folder, SWT.NONE); IValueProperty textProp = WidgetProperties.text(); dbc.bindValue( textProp.observe(item), EMFEditObservables.observeDetailValue( Realm.getDefault(), domain, master, EXTLibraryPackage.Literals.LIBRARY__WRITERS), new UpdateValueStrategy(), new UpdateValueStrategy().setConverter(new LengthConverter())); Composite comp = new Composite(folder, SWT.NONE); TableColumnLayout layout = new TableColumnLayout(); comp.setLayout(layout); TableViewer writerViewer = new TableViewer( comp, SWT.FULL_SELECTION | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI); writerViewer.getTable().setHeaderVisible(true); writerViewer.getTable().setLinesVisible(true); ObservableListContentProvider cp = new ObservableListContentProvider(); writerViewer.setContentProvider(cp); CondiditionalTemplate[] tpl = new CondiditionalTemplate[3]; tpl[0] = new CondiditionalTemplate("${0}") { @Override public boolean isTemplate(EObject element) { return element instanceof Writer && ((Writer) element).getFirstName() != null; } }; tpl[1] = new CondiditionalTemplate("${0}") { @Override public boolean isTemplate(EObject element) { return element instanceof Writer && ((Writer) element).getLastName() != null; } }; tpl[2] = new CondiditionalTemplate("-") { @Override public boolean isTemplate(EObject element) { return true; } }; EStructuralFeature[] features = new EStructuralFeature[3]; features[0] = EXTLibraryPackage.Literals.PERSON__FIRST_NAME; features[1] = EXTLibraryPackage.Literals.PERSON__LAST_NAME; IObservableMap[] map = EMFEditObservables.observeMaps(domain, cp.getKnownElements(), features); TableViewerColumn c = new TableViewerColumn(writerViewer, SWT.NONE); c.getColumn().setText("Firstname"); layout.setColumnData(c.getColumn(), new ColumnWeightData(1, 120)); c.setLabelProvider( new ObservableColumnLabelProvider( new IObservableMap[] {map[0]}, Arrays.asList(tpl[0], tpl[2]))); c = new TableViewerColumn(writerViewer, SWT.NONE); c.getColumn().setText("Lastname"); layout.setColumnData(c.getColumn(), new ColumnWeightData(1, 120)); c.setLabelProvider( new ObservableColumnLabelProvider( new IObservableMap[] {map[1]}, Arrays.asList(tpl[1], tpl[2]))); MenuManager mgr = new MenuManager(); writerViewer.getControl().setMenu(mgr.createContextMenu(writerViewer.getControl())); getSite() .registerContextMenu( "org.eclipse.emf.examples.library.databinding.writer", mgr, writerViewer); writerViewer.setInput( EMFEditObservables.observeDetailList( Realm.getDefault(), domain, master, EXTLibraryPackage.Literals.LIBRARY__WRITERS)); item.setControl(comp); return item; }
@Override public void createPartControl(Composite parent) { final IActionBars actionBars = getViewSite().getActionBars(); IToolBarManager toolbar = actionBars.getToolBarManager(); mSymbolEntryText = new TextContributionItem(""); // $NON-NLS-1$ toolbar.add(mSymbolEntryText); toolbar.add(new AddSymbolAction(mSymbolEntryText, this)); final Table table = new Table(parent, SWT.MULTI | SWT.FULL_SELECTION | SWT.V_SCROLL | SWT.BORDER); table.setHeaderVisible(true); mViewer = new TableViewer(table); GridDataFactory.defaultsFor(table).applyTo(table); final MarketDataItemComparator comparator = new MarketDataItemComparator(); mViewer.setComparator(comparator); SelectionListener listener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { // determine new sort column and direction TableColumn sortColumn = table.getSortColumn(); TableColumn currentColumn = (TableColumn) e.widget; final int index = table.indexOf(currentColumn); int dir = table.getSortDirection(); if (sortColumn == currentColumn) { dir = dir == SWT.UP ? SWT.DOWN : SWT.UP; } else { table.setSortColumn(currentColumn); dir = SWT.UP; } table.setSortDirection(dir); comparator.setSort(dir == SWT.UP ? 1 : -1); comparator.setIndex(index); mViewer.refresh(); } }; // create columns, using FIXFieldLocalizer to preserve backwards // compatibility TableViewerColumn symbolColumn = new TableViewerColumn( mViewer, createColumn( table, FIXFieldLocalizer.getLocalizedFIXFieldName(Symbol.class.getSimpleName()), SWT.LEFT, listener)); symbolColumn.setEditingSupport(new SymbolEditingSupport()); createColumn( table, FIXFieldLocalizer.getLocalizedFIXFieldName(LastPx.class.getSimpleName()), SWT.RIGHT, listener); createColumn( table, FIXFieldLocalizer.getLocalizedFIXFieldName(LastQty.class.getSimpleName()), SWT.RIGHT, listener); createColumn( table, FIXFieldLocalizer.getLocalizedFIXFieldName(BidSize.class.getSimpleName()), SWT.RIGHT, listener); createColumn( table, FIXFieldLocalizer.getLocalizedFIXFieldName(BidPx.class.getSimpleName()), SWT.RIGHT, listener); createColumn( table, FIXFieldLocalizer.getLocalizedFIXFieldName(OfferPx.class.getSimpleName()), SWT.RIGHT, listener); createColumn( table, FIXFieldLocalizer.getLocalizedFIXFieldName(OfferSize.class.getSimpleName()), SWT.RIGHT, listener); // restore table state if it exists if (mViewState != null) { ColumnState.restore(table, mViewState); for (TableColumn column : table.getColumns()) { if (column.getWidth() == 0) { column.setResizable(false); } } } registerContextMenu(); getSite().setSelectionProvider(mViewer); ObservableListContentProvider content = new ObservableListContentProvider(); mViewer.setContentProvider(content); IObservableSet domain = content.getKnownElements(); IObservableMap[] maps = new IObservableMap[] { BeansObservables.observeMap(domain, MarketDataViewItem.class, "symbol"), // $NON-NLS-1$ createCompositeMap( domain, "latestTick", MDPackage.Literals.MD_LATEST_TICK__PRICE), // $NON-NLS-1$ createCompositeMap( domain, "latestTick", MDPackage.Literals.MD_LATEST_TICK__SIZE), // $NON-NLS-1$ createCompositeMap( domain, "topOfBook", MDPackage.Literals.MD_TOP_OF_BOOK__BID_SIZE), // $NON-NLS-1$ createCompositeMap( domain, "topOfBook", MDPackage.Literals.MD_TOP_OF_BOOK__BID_PRICE), // $NON-NLS-1$ createCompositeMap( domain, "topOfBook", MDPackage.Literals.MD_TOP_OF_BOOK__ASK_PRICE), // $NON-NLS-1$ createCompositeMap( domain, "topOfBook", MDPackage.Literals.MD_TOP_OF_BOOK__ASK_SIZE) // $NON-NLS-1$ }; mViewer.setLabelProvider(new ObservableMapLabelProvider(maps)); mViewer.setUseHashlookup(true); mItems = WritableList.withElementType(MarketDataViewItem.class); mViewer.setInput(mItems); }
public void createControl(final Composite parent) { DataBindingContext dbc = new DataBindingContext(); Composite container = new Composite(parent, SWT.NONE); container.setLayout(new GridLayout(1, true)); setControl(container); tableViewer = new TableViewer(container, SWT.BORDER | SWT.FULL_SELECTION); tableViewer.getTable().setLinesVisible(true); tableViewer.getTable().setHeaderVisible(true); tableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH)); tableViewer .getTable() .setFont(new Font(Display.getDefault(), new FontData("Arial", 10, SWT.NONE))); TableViewerColumn column = new TableViewerColumn(tableViewer, SWT.NONE); column.getColumn().setText("Predicate"); column.getColumn().setWidth(225); column.setEditingSupport( new PredicateEditingSupport( tableViewer, dbc, "predicate", getBControl().getVisualization(), getShell())); column = new TableViewerColumn(tableViewer, SWT.NONE); column.getColumn().setText("Edit"); column.getColumn().setWidth(225); column.setEditingSupport(new AnimationScriptEditingSupport(tableViewer)); ObservableListContentProvider contentProvider = new ObservableListContentProvider(); tableViewer.setContentProvider(contentProvider); tableViewer.setLabelProvider( new ObservableMapLabelProvider( BeansObservables.observeMaps( contentProvider.getKnownElements(), new String[] {"predicate"})) { @Override public String getColumnText(Object element, int columnIndex) { if (columnIndex == 1) { return "Edit Scheduler"; } return super.getColumnText(element, columnIndex); } @Override public Image getColumnImage(Object element, int columnIndex) { return null; } }); final WritableList input = new WritableList( ((ExecuteAnimationScript) getScheduler()).getList(), AnimationScriptObject.class); tableViewer.setInput(input); Composite comp = new Composite(container, SWT.NONE); comp.setLayout(new RowLayout()); comp.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END)); Button btRemove = new Button(comp, SWT.PUSH); btRemove.setText("Remove"); btRemove.setImage(BMotionStudioImage.getImage(EditorImageRegistry.IMG_ICON_DELETE)); btRemove.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (tableViewer.getSelection().isEmpty()) { return; } AnimationScriptObject obj = (AnimationScriptObject) ((IStructuredSelection) tableViewer.getSelection()).getFirstElement(); input.remove(obj); } }); Button btAdd = new Button(comp, SWT.PUSH); btAdd.setText("Add"); btAdd.setImage(BMotionStudioImage.getImage(EditorImageRegistry.IMG_ICON_ADD)); btAdd.addSelectionListener( new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { AnimationScriptObject obj = new AnimationScriptObject(""); input.add(obj); } }); }