Exemplo n.º 1
0
  @Override
  public void bind(final IEMFEditContext context) {
    super.bind(context);

    final IEMFEditListProperty emfProperty =
        EMFEditProperties.list(getEditingDomain(), getEFeature());
    fModelObservable = emfProperty.observeDetail(getBaseObservable());
    ((IObserving) fModelObservable).getObserved();

    fWidget.viewer.setInput(fModelObservable);
    fButtonGroup.connectTo(fWidget.viewer, fModelObservable, null);

    register(fWidget.table, IEFPropertyExpressions.EOBJECT_LIST_ID);
    fSelectionProvider = new ElementSourceSelectionProvider(fWidget.viewer, this);
    ViewerUtil.setSelectionProvider(fWidget.table, fSelectionProvider);

    {
      final int operations = (DND.DROP_DEFAULT | DND.DROP_COPY | DND.DROP_MOVE);
      final Transfer[] transfers = new Transfer[] {LocalTransfer.getInstance()};
      fWidget.viewer.addDragSupport(operations, transfers, new ViewerDragAdapter(fWidget.viewer));
      fWidget.viewer.addDropSupport(
          operations,
          transfers,
          new EditingDomainViewerDropAdapter(getEditingDomain(), fWidget.viewer));
    }

    fSingleSelectionObservable = ViewersObservables.observeSinglePostSelection(fWidget.viewer);

    fButtonGroup.updateState();
  }
  private void createImportModelControl(final Composite parent) {
    final Label label = new Label(parent, SWT.NONE);
    label.setText(Messages.getString("ImportAttachmentsPreviewPage.7")); // $NON-NLS-1$

    final ComboViewer viewer = new ComboViewer(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new LabelProvider());
    viewer.setInput(ImportMode.values());

    final IViewerObservableValue target = ViewersObservables.observeSinglePostSelection(viewer);
    final IObservableValue model =
        BeansObservables.observeValue(m_data, DocumentsAttachmentsData.PROPERTY_IMPORT_MODE);
    m_binding.bindValue(target, model);

    // TRICKY: we need to refresh the table when the import mode changes, in order
    // to show the gray state correctly
    model.addValueChangeListener(
        new IValueChangeListener() {
          @Override
          public void handleValueChange(final ValueChangeEvent event) {
            handleImportModeChanged();
          }
        });
  }