Java Code Examples for org.eclipse.jface.databinding.viewers.ViewersObservables#observeSingleSelection()

The following examples show how to use org.eclipse.jface.databinding.viewers.ViewersObservables#observeSingleSelection() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OperationsPropertySection.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void createContent(final Composite parent) {
    final EMFDataBindingContext context = new EMFDataBindingContext();

    final Composite mainComposite = getWidgetFactory().createComposite(parent);
    mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(15, 15).create());
    mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    operationComposite = createViewer(mainComposite);
    operationComposite.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    operationComposite.setContext(context);
    IObservableValue diagramSelectionObservable = ViewersObservables.observeSingleSelection(selectionProvider);
    operationComposite.setInput(CustomEMFEditObservables.observeDetailList(Realm.getDefault(),
            diagramSelectionObservable, ProcessPackage.Literals.OPERATION_CONTAINER__OPERATIONS));

    context.bindValue(diagramSelectionObservable, ViewersObservables.observeSingleSelection(operationComposite));

}
 
Example 2
Source File: IterationPropertySection.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createInputForCardinalityGroup(final TabbedPropertySheetWidgetFactory widgetFactory,
        final Composite dataContent) {
    final Group inputGroup = widgetFactory.createGroup(dataContent, Messages.input);
    inputGroup.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    inputGroup.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).spacing(5, 3).create());

    final Label label = widgetFactory.createLabel(inputGroup, Messages.numberOfInstancesToCreate, SWT.NONE);
    label.setLayoutData(GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).create());
    final ExpressionViewer cardinalityExpression = new ExpressionViewer(inputGroup, SWT.BORDER, widgetFactory);
    cardinalityExpression.getControl()
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create());
    cardinalityExpression.addFilter(new AvailableExpressionTypeFilter(
            new String[] { ExpressionConstants.CONSTANT_TYPE, ExpressionConstants.VARIABLE_TYPE,
                    ExpressionConstants.PARAMETER_TYPE, ExpressionConstants.SCRIPT_TYPE }));
    cardinalityExpression.setExpressionNameResolver(new DefaultExpressionNameResolver("numberOfInstancesToCreate"));
    final IObservableValue selectionObservable = ViewersObservables.observeSingleSelection(selectionProvider);
    context.bindValue(ViewersObservables.observeInput(cardinalityExpression), selectionObservable);
    context.bindValue(ViewersObservables.observeSingleSelection(cardinalityExpression),
            CustomEMFEditObservables.observeDetailValue(Realm.getDefault(), selectionObservable,
                    ProcessPackage.Literals.MULTI_INSTANTIABLE__CARDINALITY_EXPRESSION));
}
 
Example 3
Source File: ConnectorImplementationWizard.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected IWizardPage getDefinitionSelectionWizardPage(
		List<ConnectorImplementation> existingImplementation) {
	return new AbstractDefinitionSelectionImpementationWizardPage(implWorkingCopy,existingImplementation,((IDefinitionRepositoryStore) defStore).getDefinitions(),getSelectionPageTitle(),getSelectionPageDescription(),messageProvider){

		@Override
		protected ITreeContentProvider getContentProvider() {
			return new UniqueConnectorDefinitionContentProvider();
		}

		@Override
		protected ITreeContentProvider getCustomContentProvider() {
			return new UniqueConnectorDefinitionContentProvider(true);
		}

		@Override
		protected void bindValue() {
			final IViewerObservableValue observeSingleSelection = ViewersObservables.observeSingleSelection(explorer.getRightTableViewer());
			context.bindValue(observeSingleSelection, EMFObservables.observeValue(implementation, ConnectorImplementationPackage.Literals.CONNECTOR_IMPLEMENTATION__DEFINITION_ID),defIdStrategy,defModelStrategy) ;
			context.bindValue(ViewersObservables.observeSingleSelection(versionCombo), EMFObservables.observeValue(implementation, ConnectorImplementationPackage.Literals.CONNECTOR_IMPLEMENTATION__DEFINITION_VERSION));
		}

	};
}
 
Example 4
Source File: DataWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private String getSelectedReturnType() {
    if (data.isMultiple()) {
        return multipleReturnType;
    }
    final IViewerObservableValue selectedType = ViewersObservables.observeSingleSelection(typeCombo);
    final DataType type = (DataType) selectedType.getValue();
    if (type instanceof JavaType) {
        final String className = ((JavaObjectData) data).getClassName();
        if (className == null || className.isEmpty()) {
            return String.class.getName();
        }
        return className;
    } else if (type != null) {
        final String technicalTypeFor = DataUtil
                .getTechnicalTypeFor(ModelHelper.getMainProcess(container), type.getName()).replace(
                        Messages.dataTechnicalTypeLabel + " ", "");
        if (technicalTypeFor.isEmpty()) {
            return String.class.getName();
        }
        return technicalTypeFor;
    }
    return null;

}
 
Example 5
Source File: SelectDataWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public void createDocumentTableViewerComposite(final Composite parent, final DataBindingContext dbc) {
    documentTableViewerComposite = new Composite(parent, SWT.NONE);
    documentTableViewerComposite.setLayout(GridLayoutFactory.swtDefaults().create());
    documentTableViewerComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    final TableViewer documentTableViewer = new TableViewer(documentTableViewerComposite,
            SWT.BORDER | SWT.SINGLE | SWT.NO_FOCUS | SWT.H_SCROLL
                    | SWT.V_SCROLL);
    documentTableViewer.getTable()
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(200, 100).create());
    final ObservableListContentProvider contentProvider = new ObservableListContentProvider();
    documentTableViewer.setContentProvider(contentProvider);
    documentTableViewer.setLabelProvider(new DocumentStyledLabelProvider());
    documentTableViewer.setInput(new WritableList(availableDocuments, ProcessPackage.Literals.DOCUMENT));
    final IViewerObservableValue observeSingleSelection = ViewersObservables
            .observeSingleSelection(documentTableViewer);
    dbc.bindValue(observeSingleSelection, selectedDataObservable,
            updateValueStrategy().withValidator(createDefaultValueAlreadyDefinedValidator()).create(), null);
    documentButton.addSelectionListener(createDocumentSelectionAdapter());
}
 
Example 6
Source File: FileContractInputSelectionComposite.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public void bindControl(final Document document, final EObject context, final EMFDataBindingContext emfDataBindingContext) {
    checkArgument(document != null);
    checkArgument(context != null);
    checkArgument(emfDataBindingContext != null);
    final IObservableValue observeInput = ViewersObservables.observeInput(getContractInputComboViewer());
    final IObservableValue multipleDocumentObervable = EMFObservables.observeValue(document, ProcessPackage.Literals.DOCUMENT__MULTIPLE);
    emfDataBindingContext.bindValue(observeInput,
            multipleDocumentObervable,
            neverUpdateValueStrategy().create(),
            updateValueStrategy().withConverter(toInputList(document, context)).create());

    final IViewerObservableValue observeSingleSelection = ViewersObservables.observeSingleSelection(getContractInputComboViewer());
    ControlDecorationSupport.create(emfDataBindingContext.bindValue(observeSingleSelection,
            EMFObservables.observeValue(document, ProcessPackage.Literals.DOCUMENT__CONTRACT_INPUT)), SWT.LEFT);
    emfDataBindingContext.addValidationStatusProvider(createContractInputParameter(document, observeInput, observeSingleSelection));
}
 
Example 7
Source File: RolesWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void configureViewer(final StructuredViewer viewer) {

    final TableViewer roleTableViewer = (TableViewer) viewer;
    final Table table = roleTableViewer.getTable();

    roleSingleSelectionObservable = ViewersObservables.observeSingleSelection(getViewer());
    roleSingleSelectionObservable.addValueChangeListener(new IValueChangeListener() {

        @Override
        public void handleValueChange(final ValueChangeEvent event) {
            final Role selectedRole = (Role) event.diff.getNewValue();
            final boolean isSelectedRole = selectedRole != null;
            setControlEnabled(getInfoGroup(), isSelectedRole);
            roleMemberShips.clear();
            for (final Membership m : membershipList) {
                if (Objects.equals(selectedRole.getName(),m.getRoleName())) {
                    roleMemberShips.add(m);
                }
            }
        }
    });

    addNameColumn(roleTableViewer);

    addDisplayNameColumn(roleTableViewer);

    addDescriptionColumn(roleTableViewer);

    addTableColumLayout(table);

    if (roleList != null && getViewer() != null) {
        getViewer().setInput(roleList);
    }

}
 
Example 8
Source File: RelationFieldDetailsControl.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createRelationKindCombo() {
    ComboViewer relationComboViewer = new ComboViewer(this, SWT.BORDER | SWT.READ_ONLY);
    relationComboViewer.getControl()
            .setLayoutData(GridDataFactory.fillDefaults().hint(400, SWT.DEFAULT).indent(0, -5).create());
    relationComboViewer.setContentProvider(ArrayContentProvider.getInstance());
    relationComboViewer.setLabelProvider(new LabelProviderBuilder<RelationType>()
            .withTextProvider(type -> Objects.equals(type, RelationType.AGGREGATION)
                    ? Messages.aggregation
                    : Messages.composition)
            .createLabelProvider());
    relationComboViewer.setInput(RelationType.values());

    IObservableValue<RelationType> selection = ViewersObservables.observeSingleSelection(relationComboViewer);
    IObservableValue<RelationType> relationTypeObservable = EMFObservables.observeDetailValue(Realm.getDefault(),
            selectedFieldObservable, BusinessDataModelPackage.Literals.RELATION_FIELD__TYPE);

    relationTypeObservable.addValueChangeListener(e -> {
        if (selectedFieldObservable.getValue() != null && e.diff.getOldValue() != null && e.diff.getNewValue() != null) {
            RelationField oldValue = (RelationField) EcoreUtil.copy(selectedFieldObservable.getValue());
            oldValue.setType(e.diff.getOldValue());
            DiffElement diffElement = new DiffElement(Event.UPDATE_ATTRIBUTE_TYPE, oldValue,
                    selectedFieldObservable.getValue());
            diffElement.addProperty(AttributeEditionControl.PARENT_QUALIFIED_NAME,
                    formPage.observeBusinessObjectSelected().getValue().getQualifiedName());
            formPage.refactorAccessControl(diffElement);
        }
    });
    ctx.bindValue(selection, relationTypeObservable);
}
 
Example 9
Source File: DataWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void bindDefaultValueViewer() {
    defaultValueViewer.setExpressionNatureProvider(ExpressionContentProvider.getInstance());
    defaultValueViewer.setExample("");
    final DataType dataType = data.getDataType();
    if (dataType instanceof DateType) {
        defaultValueViewer.setExpressionNatureProvider(new NowDateExpressionNatureProvider());
        defaultValueViewer.setExample(Messages.dateFormatLabel);
    } else if (dataType instanceof EnumType) {
        defaultValueViewer.setExpressionNatureProvider(new OptionsExpressionNatureProvider((EnumType) dataType));
    } else if (dataType instanceof BooleanType) {
        defaultValueViewer.setExpressionNatureProvider(new BooleanExpressionNatureProvider());
    }

    if (data.getDefaultValue() == null) {
        data.setDefaultValue(ExpressionFactory.eINSTANCE.createExpression());
    }

    final Expression exp = data.getDefaultValue();
    final String expType = exp.getType();
    if (!(ExpressionConstants.VARIABLE_TYPE.equals(expType)
            || ExpressionConstants.PARAMETER_TYPE.equals(expType))) {
        exp.setReturnType(getSelectedReturnType());
    }

    defaultValueViewer.setInput(data);
    observeSingleSelectionDefaultValueExpression = ViewersObservables.observeSingleSelection(defaultValueViewer);
    emfDatabindingContext.bindValue(observeSingleSelectionDefaultValueExpression,
            EMFObservables.observeValue(data, ProcessPackage.Literals.DATA__DEFAULT_VALUE));
}
 
Example 10
Source File: ConverterUtil.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 对下拉列表和转换器列表进行绑定
 * @param context
 * @param comboViewer
 * @param model
 *            ;
 */
public static void bindValue(DataBindingContext context, ComboViewer comboViewer, ConverterViewModel model) {
	// ViewerSupport.bind(comboViewer, BeansObservables.observeList(
	// model, "supportTypes", String.class),
	// Properties.selfValue(String.class));
	//		
	//
	// context.bindValue(ViewersObservables
	// .observeSingleSelection(comboViewer), BeansObservables
	// .observeValue(model,
	// "selectedType"));

	// ObservableListContentProvider viewerContentProvider=new ObservableListContentProvider();
	comboViewer.setContentProvider(new ArrayContentProvider());
	comboViewer.setComparator(new ViewerComparator());
	// IObservableMap[] attributeMaps = BeansObservables.observeMaps(
	// viewerContentProvider.getKnownElements(),
	// ConverterBean.class, new String[] { "description" });
	// comboViewer.setLabelProvider(new ObservableMapLabelProvider(
	// attributeMaps));
	// comboViewer.setInput(Observables.staticObservableList(model.getSupportTypes(),ConverterBean.class));

	comboViewer.setInput(model.getSupportTypes());
	IViewerObservableValue selection = ViewersObservables.observeSingleSelection(comboViewer);
	IObservableValue observableValue = BeansObservables.observeDetailValue(selection, PROPERTIES_NAME, null);
	context.bindValue(observableValue, BeansObservables.observeValue(model, PROPERTIES_SELECTED_TYPE));
}
 
Example 11
Source File: ProjectSettingLanguagePage.java    From tmxeditor8 with GNU General Public License v2.0 5 votes vote down vote up
private void initDataBindings() {
	DataBindingContext ctx = new DataBindingContext();

	IObservableValue widgetValue = ViewersObservables.observeSingleSelection(srcLangComboViewer);
	IObservableValue modelValue = BeanProperties.value(ProjectInfoBean.class, "sourceLang").observe(projCfgBean);
	ctx.bindValue(widgetValue, modelValue, null, null);
}
 
Example 12
Source File: ConditionComposite.java    From elexis-3-core with Eclipse Public License 1.0 5 votes vote down vote up
private void initDataBinding(){
	transientConditionValue = new WritableValue();
	DataBindingContext bindingContext = new DataBindingContext();
	
	IObservableValue targetObservable =
		ViewersObservables.observeSingleSelection(statusViewer);
	IObservableValue modelObservable = PojoObservables
		.observeDetailValue(transientConditionValue, "status", TransientCondition.class);
	bindingContext.bindValue(targetObservable, modelObservable);
	
	targetObservable = SWTObservables.observeText(startTxt, SWT.Modify);
	modelObservable = PojoObservables.observeDetailValue(transientConditionValue, "start",
		TransientCondition.class);
	bindingContext.bindValue(targetObservable, modelObservable);
	
	targetObservable = SWTObservables.observeText(endTxt, SWT.Modify);
	modelObservable = PojoObservables.observeDetailValue(transientConditionValue, "end",
		TransientCondition.class);
	bindingContext.bindValue(targetObservable, modelObservable);
	
	targetObservable = SWTObservables.observeText(textTxt, SWT.Modify);
	modelObservable =
		PojoObservables.observeDetailValue(transientConditionValue, "text",
			TransientCondition.class);
	bindingContext.bindValue(targetObservable, modelObservable);
	
	setCondition(null);
}
 
Example 13
Source File: ConverterUtil.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
public static void bindValue(DataBindingContext context,ComboViewer comboViewer,
			ConverterViewModel model) {
//		ViewerSupport.bind(comboViewer, BeansObservables.observeList(
//				model, "supportTypes", String.class),
//				Properties.selfValue(String.class));
//		
//
//		context.bindValue(ViewersObservables
//				.observeSingleSelection(comboViewer), BeansObservables
//				.observeValue(model,
//						"selectedType"));
		
//		ObservableListContentProvider viewerContentProvider=new ObservableListContentProvider();
		comboViewer.setContentProvider(new ArrayContentProvider());
		comboViewer.setComparator(new ViewerComparator());
//		IObservableMap[] attributeMaps = BeansObservables.observeMaps(
//				viewerContentProvider.getKnownElements(),
//				ConverterBean.class, new String[] { "description" });
//		comboViewer.setLabelProvider(new ObservableMapLabelProvider(
//		attributeMaps));
//		comboViewer.setInput(Observables.staticObservableList(model.getSupportTypes(),ConverterBean.class));
		
		comboViewer.setInput(model.getSupportTypes());
		IViewerObservableValue selection=ViewersObservables.observeSingleSelection(comboViewer);
		IObservableValue observableValue=BeansObservables.observeDetailValue(selection, "name", ConverterBean.class);
		context.bindValue(observableValue, BeansObservables
				.observeValue(model,
						"selectedType"));
	}
 
Example 14
Source File: ConverterUtil.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 对下拉列表和转换器列表进行绑定
 * @param context
 * @param comboViewer
 * @param model
 *            ;
 */
public static void bindValue(DataBindingContext context, ComboViewer comboViewer, ConverterViewModel model) {
	// ViewerSupport.bind(comboViewer, BeansObservables.observeList(
	// model, "supportTypes", String.class),
	// Properties.selfValue(String.class));
	//		
	//
	// context.bindValue(ViewersObservables
	// .observeSingleSelection(comboViewer), BeansObservables
	// .observeValue(model,
	// "selectedType"));

	// ObservableListContentProvider viewerContentProvider=new ObservableListContentProvider();
	comboViewer.setContentProvider(new ArrayContentProvider());
	comboViewer.setComparator(new ViewerComparator());
	// IObservableMap[] attributeMaps = BeansObservables.observeMaps(
	// viewerContentProvider.getKnownElements(),
	// ConverterBean.class, new String[] { "description" });
	// comboViewer.setLabelProvider(new ObservableMapLabelProvider(
	// attributeMaps));
	// comboViewer.setInput(Observables.staticObservableList(model.getSupportTypes(),ConverterBean.class));

	comboViewer.setInput(model.getSupportTypes());
	IViewerObservableValue selection = ViewersObservables.observeSingleSelection(comboViewer);
	IObservableValue observableValue = BeansObservables.observeDetailValue(selection, PROPERTIES_NAME, null);
	context.bindValue(observableValue, BeansObservables.observeValue(model, PROPERTIES_SELECTED_TYPE));
}
 
Example 15
Source File: ProjectSettingLanguagePage.java    From translationstudio8 with GNU General Public License v2.0 5 votes vote down vote up
private void initDataBindings() {
	DataBindingContext ctx = new DataBindingContext();

	IObservableValue widgetValue = ViewersObservables.observeSingleSelection(srcLangComboViewer);
	IObservableValue modelValue = BeanProperties.value(ProjectInfoBean.class, "sourceLang").observe(projCfgBean);
	ctx.bindValue(widgetValue, modelValue, null, null);
}
 
Example 16
Source File: GroupsWizardPage.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected StructuredViewer createViewer(final Composite parent) {
    final FilteredTree fileredTree = new FilteredTree(parent, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION, new PatternFilter(), true);
    ((Text) ((Composite) fileredTree.getChildren()[0]).getChildren()[0]).setMessage(Messages.search);
    fileredTree.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).minSize(200, 200).create());
    fileredTree.getViewer().setContentProvider(new GroupContentProvider());
    fileredTree.forceFocus();

    groupSingleSelectionObservable = ViewersObservables.observeSingleSelection(fileredTree.getViewer());
    groupSingleSelectionObservable.addValueChangeListener(new IValueChangeListener() {

        private final Adapter groupAdapter = new AdapterImpl() {

            /*
             * (non-Javadoc)
             * @see org.eclipse.emf.common.notify.impl.AdapterImpl#notifyChanged(org.eclipse.emf.common.notify.Notification)
             */
            @Override
            public void notifyChanged(Notification notification) {
                switch (notification.getFeatureID(org.bonitasoft.studio.actors.model.organization.Group.class)) {
                    case OrganizationPackage.GROUP__NAME:
                        handleGroupNameChange(notification);
                        break;
                    default:
                        break;
                }
                super.notifyChanged(notification);
            }
        };

        @Override
        public void handleValueChange(final ValueChangeEvent event) {
            final org.bonitasoft.studio.actors.model.organization.Group previousGroup = (org.bonitasoft.studio.actors.model.organization.Group) event.diff
                    .getOldValue();
            if (previousGroup != null) {
                previousGroup.eAdapters().remove(groupAdapter);
            }
            final org.bonitasoft.studio.actors.model.organization.Group selectedGroup = (org.bonitasoft.studio.actors.model.organization.Group) event.diff
                    .getNewValue();

            if (selectedGroup != null) {
                setControlEnabled(getInfoGroup(), true);
                selectedGroup.eAdapters().add(groupAdapter);
                addSubGroupButton.setEnabled(true);
            } else {
                addSubGroupButton.setEnabled(false);
                setControlEnabled(getInfoGroup(), false);
            }

        }
    });

    return fileredTree.getViewer();
}
 
Example 17
Source File: IterationPropertySection.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private Composite createStandardLoopContent(final Composite stackedComposite,
        final TabbedPropertySheetWidgetFactory widgetFactory) {
    final Composite standardLoopComposite = widgetFactory.createPlainComposite(stackedComposite, SWT.NONE);
    standardLoopComposite
            .setLayout(GridLayoutFactory.fillDefaults().numColumns(3).extendedMargins(0, 0, 10, 0).create());

    widgetFactory.createLabel(standardLoopComposite, "", SWT.NONE);// FILLER

    final Well well = new Well(standardLoopComposite, Messages.processScopeVariableWarning, widgetFactory,
            IStatus.WARNING);
    well.setLayoutData(GridDataFactory.swtDefaults().grab(false, false).span(2, 1).create());

    widgetFactory.createLabel(standardLoopComposite, "", SWT.NONE);// FILLER

    final Button testAfterButton = widgetFactory.createButton(standardLoopComposite, Messages.testAfterLabel,
            SWT.RADIO);
    testAfterButton.setLayoutData(GridDataFactory.swtDefaults().create());

    final Button testBefore = widgetFactory.createButton(standardLoopComposite, Messages.testBeforeLabel,
            SWT.RADIO);
    testBefore.setLayoutData(GridDataFactory.swtDefaults().create());

    final SelectObservableValue testEventObservable = new SelectObservableValue(Boolean.class);
    testEventObservable.addOption(Boolean.FALSE, SWTObservables.observeSelection(testAfterButton));
    testEventObservable.addOption(Boolean.TRUE, SWTObservables.observeSelection(testBefore));

    final IObservableValue selectionObservable = ViewersObservables.observeSingleSelection(selectionProvider);
    context.bindValue(testEventObservable, CustomEMFEditObservables.observeDetailValue(Realm.getDefault(),
            selectionObservable, ProcessPackage.Literals.MULTI_INSTANTIABLE__TEST_BEFORE));

    widgetFactory.createLabel(standardLoopComposite, Messages.loopConditionLabel)
            .setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create());

    final ExpressionViewer loopConditionExpressionViewer = new ExpressionViewer(standardLoopComposite, SWT.BORDER,
            widgetFactory);

    loopConditionExpressionViewer.getControl()
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create());
    loopConditionExpressionViewer.addFilter(new AvailableExpressionTypeFilter(
            new String[] { ExpressionConstants.CONSTANT_TYPE, ExpressionConstants.VARIABLE_TYPE,
                    ExpressionConstants.PARAMETER_TYPE, ExpressionConstants.SCRIPT_TYPE }));
    loopConditionExpressionViewer.addFilter(new DisplayEngineExpressionWithName(new String[] {
            org.bonitasoft.engine.expression.ExpressionConstants.LOOP_COUNTER.getEngineConstantName() }));
    loopConditionExpressionViewer.addFilter(new OnlyProcessDataViewerFilter());
    loopConditionExpressionViewer.setExpressionNameResolver(new DefaultExpressionNameResolver("loopWhile"));
    context.bindValue(ViewersObservables.observeInput(loopConditionExpressionViewer), selectionObservable);
    context.bindValue(ViewersObservables.observeSingleSelection(loopConditionExpressionViewer),
            CustomEMFEditObservables.observeDetailValue(Realm.getDefault(), selectionObservable,
                    ProcessPackage.Literals.MULTI_INSTANTIABLE__LOOP_CONDITION));

    widgetFactory.createLabel(standardLoopComposite, Messages.maximumLoopLabel)
            .setLayoutData(GridDataFactory.fillDefaults().align(SWT.END, SWT.CENTER).create());

    final ExpressionViewer maximumLoopExpressionViewer = new ExpressionViewer(standardLoopComposite, SWT.BORDER,
            widgetFactory);
    maximumLoopExpressionViewer.getControl()
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(2, 1).create());
    maximumLoopExpressionViewer.addFilter(new AvailableExpressionTypeFilter(
            new String[] { ExpressionConstants.CONSTANT_TYPE, ExpressionConstants.VARIABLE_TYPE,
                    ExpressionConstants.PARAMETER_TYPE, ExpressionConstants.SCRIPT_TYPE }));
    maximumLoopExpressionViewer.setMessage(Messages.optionalLabel);
    maximumLoopExpressionViewer.addFilter(new OnlyProcessDataViewerFilter());
    maximumLoopExpressionViewer.setExpressionNameResolver(new DefaultExpressionNameResolver("maximumLoop"));
    context.bindValue(ViewersObservables.observeInput(maximumLoopExpressionViewer), selectionObservable);
    context.bindValue(ViewersObservables.observeSingleSelection(maximumLoopExpressionViewer),
            CustomEMFEditObservables.observeDetailValue(Realm.getDefault(), selectionObservable,
                    ProcessPackage.Literals.MULTI_INSTANTIABLE__LOOP_MAXIMUM));

    return standardLoopComposite;
}
 
Example 18
Source File: EObjectSelectionProviderSection.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
protected IObservableValue getEObjectObservable() {
    if (selectionObservable == null) {
        selectionObservable = ViewersObservables.observeSingleSelection(this);
    }
    return selectionObservable;
}
 
Example 19
Source File: QueryExpressionEditor.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private void createQueryComboViewer(final Composite composite, final IObservableList observeQueryList) {
    final Composite queryComposite = new Composite(composite, SWT.NONE);
    queryComposite.setLayoutData(GridDataFactory.fillDefaults().create());
    queryComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).spacing(0, 2).create());

    final Label queryLabel = new Label(queryComposite, SWT.NONE);
    queryLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).create());
    queryLabel.setText(Messages.queries);

    final ComboViewer queryCombo = new ComboViewer(queryComposite, SWT.READ_ONLY | SWT.BORDER);
    queryCombo.getControl().setLayoutData(
            GridDataFactory.fillDefaults().grab(true, false).hint(150, SWT.DEFAULT).create());
    queryCombo.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(final Object element) {
            if (element instanceof Expression) {
                String name = ((Expression) element).getName();
                if (name.indexOf(".") != -1) {
                    name = name.substring(name.indexOf(".") + 1, name.length());
                }
                return name;
            }
            return super.getText(element);
        }
    });
    queryCombo.setContentProvider(new ObservableListContentProvider());

    queryCombo.setInput(observeQueryList);

    observeQuerySingleSelection = ViewersObservables.observeSingleSelection(queryCombo);
    observeBOSingleSelection.addValueChangeListener(new IValueChangeListener() {

        @Override
        public void handleValueChange(final ValueChangeEvent event) {
            if (event.diff.getOldValue() != null && observeQuerySingleSelection.getValue() == null) {
                observeQuerySingleSelection.setValue(observeQueryList.get(0));
            }
        }
    });
}
 
Example 20
Source File: StammDatenComposite.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
protected void initDataBindings(){
	DataBindingContext bindingContext = new DataBindingContext();
	
	Text[] control =
		{
			txtTitleFront, txtFirstName, txtFamilyName, txtTitleBack, txtZIP, txtCity,
			txtStreet, txtTelefon, txtTelefon2, txtFax, txtEmail, txtWebsite, txtMobil,
			txtNotes
		};
	String[] property =
		{
			"titel", "description2", "description1", "titelSuffix", "zip", "city", "street",
			"phone1", "phone2", "fax", "email", "website", "mobile", "comment"
		};
	
	for (int i = 0; i < control.length; i++) {
		bindValue(control[i], property[i], bindingContext);
	}
	
	// DateTime
	// TODO
	//		IObservableValue dateTimeObserveWidget = SWTObservables.observeSelection(dateTimeDob);
	//		IObservableValue dateTimeObserveValue =
	//			BeansObservables.observeDetailValue(contactObservable, "dateOfBirth",
	//				org.joda.time.DateTime.class);
	//		UpdateValueStrategy targetToModel = new UpdateValueStrategy();
	//		targetToModel.setConverter(new DateDateTimeConverter());
	//		UpdateValueStrategy modelToTarget = new UpdateValueStrategy();
	//		modelToTarget.setConverter(new DateTimeDateConverter());
	//		bindingContext.bindValue(dateTimeObserveWidget, dateTimeObserveValue, targetToModel,
	//			modelToTarget);
	
	// Warum liegt denn hier Stroh rum?
	IObservableValue sexObserver = ViewersObservables.observeSingleSelection(comboViewerSex);
	bindingContext.bindValue(sexObserver,
		BeansObservables.observeDetailValue(contactObservable, "gender", ContactGender.class),
		null, null);
	
	IObservableValue countryObserver =
		ViewersObservables.observeSingleSelection(comboViewerCountry);
	bindingContext.bindValue(countryObserver,
		BeansObservables.observeDetailValue(contactObservable, "country", Country.class),
		null, null);
}