org.eclipse.jface.databinding.viewers.ViewersObservables Java Examples

The following examples show how to use org.eclipse.jface.databinding.viewers.ViewersObservables. 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: 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 #2
Source File: SelectDataWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public void createBusinessVariableTableViewerComposite(final Composite parent, final DataBindingContext dbc) {
    businessVariableTableViewerComposite = new Composite(parent, SWT.NONE);
    businessVariableTableViewerComposite.setLayout(GridLayoutFactory.swtDefaults().create());
    businessVariableTableViewerComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    final TableViewer businessDataTableViewer = new TableViewer(businessVariableTableViewerComposite,
            SWT.BORDER | SWT.SINGLE | SWT.NO_FOCUS | SWT.H_SCROLL
                    | SWT.V_SCROLL);
    businessDataTableViewer.getTable().setLayout(GridLayoutFactory.fillDefaults().create());
    businessDataTableViewer.getTable()
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(200, 100).create());
    final ObservableListContentProvider contentProvider = new ObservableListContentProvider();
    businessDataTableViewer.setContentProvider(contentProvider);
    final IObservableSet knownElements = contentProvider.getKnownElements();
    final IObservableMap[] labelMaps = EMFObservables.observeMaps(knownElements,
            new EStructuralFeature[] { ProcessPackage.Literals.ELEMENT__NAME,
                    ProcessPackage.Literals.DATA__MULTIPLE,
                    ProcessPackage.Literals.JAVA_OBJECT_DATA__CLASS_NAME });
    businessDataTableViewer
            .setLabelProvider(new BusinessObjectDataStyledLabelProvider(businessObjectStore, labelMaps));
    businessDataTableViewer
            .setInput(new WritableList(availableBusinessData, ProcessPackage.Literals.BUSINESS_OBJECT_DATA));
    final IViewerObservableValue observeSingleSelection = ViewersObservables
            .observeSingleSelection(businessDataTableViewer);
    dbc.bindValue(observeSingleSelection, selectedDataObservable);
    businessVariableButton.addSelectionListener(createBusinessVariableSelectionAdapter());
}
 
Example #3
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 #4
Source File: SelectJarsDialog.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {
    Control control = super.createDialogArea(parent);

    UpdateValueStrategy selectionStartegy = new UpdateValueStrategy() ;
    selectionStartegy.setAfterGetValidator(new IValidator() {

        @Override
        public IStatus validate(Object value) {
            if( value == null){
                return ValidationStatus.error("Selection is empty") ;
            }
            return Status.OK_STATUS;
        }
    }) ;

    context.bindList(ViewersObservables.observeMultiSelection(tableViewer), PojoProperties.list(SelectJarsDialog.class,"selectedJars").observe(this)) ;
    context.bindValue(ViewersObservables.observeSingleSelection(tableViewer), PojoProperties.value(SelectJarsDialog.class,"selectedJar").observe(this), selectionStartegy, null) ;

    return control ;
}
 
Example #5
Source File: ContractPropertySection.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected void bindGenerateButtonEnablement(final Button button) {
    final ISWTObservableValue observeEnabled = WidgetProperties.enabled().observe(button);

    final IObservableValue observeVariables = CustomEMFEditObservables.observeDetailValue(Realm.getDefault(),
            ViewersObservables.observeSingleSelection(poolSelectionProvider),
            ProcessPackage.Literals.DATA_AWARE__DATA);
    final IObservableValue observeDocuments = CustomEMFEditObservables.observeDetailValue(Realm.getDefault(),
            ViewersObservables.observeSingleSelection(poolSelectionProvider),
            ProcessPackage.Literals.POOL__DOCUMENTS);
    context.bindValue(observeEnabled, observeVariables,
            neverUpdateValueStrategy().create(),
            updateValueStrategy()
                    .withConverter(createObserveVariableToEnableButtonConverter(observeDocuments)).create());
    context.bindValue(observeEnabled, observeDocuments, neverUpdateValueStrategy().create(),
            UpdateStrategyFactory.updateValueStrategy()
                    .withConverter(createObserveDocumentToEnableButtonConverter(observeVariables)).create());
}
 
Example #6
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 #7
Source File: PageComponentSwitchBuilder.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private ExpressionViewer buildExpressionViewer(final Composite composite, final Text object,
        final IExpressionNatureProvider expressionProvider,
        final Input input, final ConnectorParameter parameter, final LabelProvider autoCompletionLabelProvider) {
    final ExpressionViewer viewer = new ExpressionViewer(composite, SWT.BORDER);
    viewer.setIsPageFlowContext(isPageFlowContext);
    viewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    viewer.setExpressionNameResolver(new ConnectorInputNameResolver(parameter.getKey()));
    final String example = messageProvider.getFieldExample(definition, object.getId());
    if (!Strings.isNullOrEmpty(example)) {
        viewer.setExample(example);
    }
    viewer.setContext(container);
    if (autoCompletionLabelProvider != null) {
        viewer.setAutocomplitionLabelProvider(autoCompletionLabelProvider);
    }
    handleExpressionProvider(expressionProvider, viewer);
    handleMandatory(object, input, viewer);
    handleDocumentsOption(object, viewer);
    viewer.setInput(parameter);
    handleDescription(object, viewer);
    context.bindValue(ViewersObservables.observeSingleSelection(viewer),
            EMFObservables.observeValue(parameter,
                    ConnectorConfigurationPackage.Literals.CONNECTOR_PARAMETER__EXPRESSION));
    return viewer;
}
 
Example #8
Source File: InputParametersMappingSection.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private ExpressionViewer createInputMappingExpressionViewer(final Composite outputMappingControl,
        final InputMapping mapping) {
    final ExpressionViewer srcCombo = new ExpressionViewer(outputMappingControl, SWT.BORDER, getWidgetFactory());
    srcCombo.getControl().setLayoutData(GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false)
            .hint(250, SWT.DEFAULT).create());
    srcCombo.addFilter(
            new AvailableExpressionTypeFilter(ExpressionConstants.CONSTANT_TYPE, ExpressionConstants.VARIABLE_TYPE,
                    ExpressionConstants.SCRIPT_TYPE, ExpressionConstants.PARAMETER_TYPE,
                    ExpressionConstants.DOCUMENT_TYPE));

    dbc.bindValue(ViewersObservables.observeInput(srcCombo),
            ViewersObservables.observeSingleSelection(selectionProvider));
    if (mapping.getProcessSource() == null) {
        getEditingDomain().getCommandStack().execute(
                SetCommand.create(getEditingDomain(), mapping, ProcessPackage.Literals.INPUT_MAPPING__PROCESS_SOURCE,
                        ExpressionHelper.createConstantExpression("", String.class.getName())));
    }
    dbc.bindValue(ViewersObservables.observeSingleSelection(srcCombo),
            EMFObservables.observeValue(mapping, ProcessPackage.Literals.INPUT_MAPPING__PROCESS_SOURCE));
    return srcCombo;
}
 
Example #9
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 #10
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 #11
Source File: CheckboxRepositoryTreeViewer.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public void bindTree(final DataBindingContext context,
        IObservableList<IRepositoryStore<? extends IRepositoryFileStore>> stores) {
    inputObservable = stores;
    setInput(inputObservable);
    this.checkedElementsObservable = ViewersObservables.observeCheckedElements(this, Object.class);
    context.addValidationStatusProvider(new MultiValidator() {

        @Override
        protected IStatus validate() {
            if (checkedElementsObservable.isEmpty()) {
                return ValidationStatus.error(Messages.selectAtLeastOneArtifact);
            }
            return ValidationStatus.ok();
        }
    });
    collapseAll();
}
 
Example #12
Source File: PoolDataSection.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 Composite mainComposite = getWidgetFactory().createComposite(parent);
    mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).equalWidth(true).create());
    mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    context = new EMFDataBindingContext();
    BusinessObjectModelRepositoryStore businessObjectModelRepositoryStore = repositoryAccessor.getRepositoryStore(BusinessObjectModelRepositoryStore.class);
    businessDataComposite = new BusinessDataViewer(mainComposite, getWidgetFactory(), ProcessPackage.Literals.DATA_AWARE__DATA,
            businessObjectModelRepositoryStore);
    repositoryAccessor.getWorkspace().addResourceChangeListener(businessDataComposite);
    businessDataComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    businessDataComposite.bindControl(context, ViewersObservables.observeSingleSelection(selectionProvider));

    final ProcessDataViewer processDataViewer = new ProcessDataViewer(mainComposite, getWidgetFactory(), ProcessPackage.Literals.DATA_AWARE__DATA,
            new DataWizardFactory(ProcessPackage.Literals.DATA_AWARE__DATA));
    processDataViewer.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    processDataViewer.bindControl(context, ViewersObservables.observeSingleSelection(selectionProvider));
}
 
Example #13
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 #14
Source File: MessageIdExpressionEditor.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void bindExpression(EMFDataBindingContext dataBindingContext, EObject context, Expression inputExpression, ViewerFilter[] filters,
        ExpressionViewer expressionViewer) {
    this.inputExpression = inputExpression;
    IObservableValue nameModelObservable = EMFObservables.observeValue(inputExpression, ExpressionPackage.Literals.EXPRESSION__NAME);
    IObservableValue contentModelObservable = EMFObservables.observeValue(inputExpression, ExpressionPackage.Literals.EXPRESSION__CONTENT);

    Set<String> input = new HashSet<String>();
    IExpressionProvider provider = ExpressionProviderService.getInstance().getExpressionProvider(ExpressionConstants.MESSAGE_ID_TYPE);
    for (Expression e : provider.getExpressions(context)) {
        input.add(e.getName());
    }
    viewer.setInput(input);

    dataBindingContext.bindValue(SWTObservables.observeText(valueText, SWT.Modify), nameModelObservable);
    dataBindingContext.bindValue(SWTObservables.observeText(valueText, SWT.Modify), contentModelObservable);
    dataBindingContext.bindValue(ViewersObservables.observeSingleSelection(viewer), nameModelObservable);
    dataBindingContext.bindValue(ViewersObservables.observeSingleSelection(viewer), contentModelObservable);
}
 
Example #15
Source File: OutputParametersMappingSection.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void addOutputMappingControl(final Composite parent) {
    final Composite composite = getWidgetFactory().createComposite(parent);
    composite.setLayout(GridLayoutFactory.fillDefaults().create());
    composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    outputMappingControl = new MagicComposite(composite, SWT.NONE);
    outputMappingControl.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    getWidgetFactory().adapt(outputMappingControl);
    outputMappingControl.setLayout(GridLayoutFactory.fillDefaults().numColumns(4).margins(0, 0).create());

    final Label targetParameterLabel = getWidgetFactory().createLabel(outputMappingControl,
            Messages.dataFromCalledProcess);
    targetParameterLabel.setLayoutData(GridDataFactory.swtDefaults().span(2, 1).indent(15, 0).create());
    final Control sourceParameterLabel = getWidgetFactory().createLabel(outputMappingControl,
            Messages.dataInRootProcess);
    sourceParameterLabel.setLayoutData(GridDataFactory.swtDefaults().span(2, 1).create());

    final IObservableValue inputMappibngsObservable = CustomEMFEditObservables.observeDetailValue(Realm.getDefault(),
            ViewersObservables.observeSingleSelection(selectionProvider),
            ProcessPackage.Literals.CALL_ACTIVITY__OUTPUT_MAPPINGS);
    dbc.bindValue(SWTObservables.observeVisible(sourceParameterLabel), inputMappibngsObservable,
            neverUpdateValueStrategy().create(), updateValueStrategy().withConverter(hideIfEmpty()).create());
    dbc.bindValue(SWTObservables.observeVisible(targetParameterLabel), inputMappibngsObservable,
            neverUpdateValueStrategy().create(), updateValueStrategy().withConverter(hideIfEmpty()).create());

    final Button addLineButton = getWidgetFactory().createButton(composite, Messages.Add, SWT.FLAT);
    addLineButton.setLayoutData(
            GridDataFactory.swtDefaults().hint(IDialogConstants.BUTTON_WIDTH, SWT.DEFAULT).indent(15, 0).create());
    addLineButton.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY,
            SWTBotConstants.SWTBOT_ID_CALLACTIVITY_MAPPING_ADD_OUTPUT);
    addLineButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(final Event event) {
            createOutputMapping(null, null);
            refreshScrolledComposite(parent);
        }
    });

}
 
Example #16
Source File: InputParametersMappingSection.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void addInputMappingControl(final Composite parent) {
    final Composite composite = getWidgetFactory().createComposite(parent);
    composite.setLayout(GridLayoutFactory.fillDefaults().create());
    composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    inputMappingControl = new MagicComposite(composite, SWT.NONE);
    inputMappingControl.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    getWidgetFactory().adapt(inputMappingControl);
    inputMappingControl.setLayout(GridLayoutFactory.fillDefaults().numColumns(4).margins(0, 0).create());

    final Label sourceParameterLabel = getWidgetFactory().createLabel(inputMappingControl, Messages.dataFromRootProcess);
    sourceParameterLabel.setLayoutData(GridDataFactory.swtDefaults().span(2, 1).indent(15, 0).create());

    final Label targetParameterLabel = getWidgetFactory().createLabel(inputMappingControl, Messages.dataInCalledProcess);
    targetParameterLabel.setLayoutData(GridDataFactory.swtDefaults().span(2, 1).create());

    final IObservableValue inputMappibngsObservable = CustomEMFEditObservables.observeDetailValue(Realm.getDefault(),
            ViewersObservables.observeSingleSelection(selectionProvider),
            ProcessPackage.Literals.CALL_ACTIVITY__INPUT_MAPPINGS);
    dbc.bindValue(SWTObservables.observeVisible(sourceParameterLabel), inputMappibngsObservable,
            neverUpdateValueStrategy().create(), updateValueStrategy().withConverter(hideIfEmpty()).create());
    dbc.bindValue(SWTObservables.observeVisible(targetParameterLabel), inputMappibngsObservable,
            neverUpdateValueStrategy().create(), updateValueStrategy().withConverter(hideIfEmpty()).create());

    final Button addLineButton = getWidgetFactory().createButton(composite, Messages.Add, SWT.FLAT);
    addLineButton.setLayoutData(
            GridDataFactory.swtDefaults().hint(IDialogConstants.BUTTON_WIDTH, SWT.DEFAULT).indent(15, 0).create());
    addLineButton.setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY,
            SWTBotConstants.SWTBOT_ID_CALLACTIVITY_MAPPING_ADD_INPUT);
    addLineButton.addListener(SWT.Selection, new Listener() {

        @Override
        public void handleEvent(final Event event) {
            createInputMapping(null, InputMappingAssignationType.CONTRACT_INPUT, null);
            refreshScrolledComposite(parent);
        }
    });

}
 
Example #17
Source File: ExpectedDurationPropertySectionContribution.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void createControl(Composite composite, TabbedPropertySheetWidgetFactory widgetFactory,
        final ExtensibleGridPropertySection page) {
    context = new EMFDataBindingContext();
    final ExpressionViewer viewer = new ExpressionViewer(composite, SWT.BORDER , widgetFactory);
    viewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).indent(5, 0).create());
    viewer.setMessage(Messages.dueDateCalculationHint);
    viewer.setExpressionNameResolver(new DefaultExpressionNameResolver("dueDateCalculation"));
    viewer.addFilter(new AvailableExpressionTypeFilter(ExpressionConstants.CONSTANT_TYPE,ExpressionConstants.VARIABLE_TYPE,ExpressionConstants.SCRIPT_TYPE,ExpressionConstants.PARAMETER_TYPE));
    context.bindValue(ViewersObservables.observeInput(viewer),  ViewersObservables.observeSingleSelection(selectionProvider));
    context.bindValue(ViewersObservables.observeSingleSelection(viewer), 
            CustomEMFEditObservables.observeDetailValue(Realm.getDefault(), ViewersObservables.observeSingleSelection(selectionProvider), ProcessPackage.Literals.TASK__EXPECTED_DURATION));
}
 
Example #18
Source File: IterationPropertySection.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createCompletionConditionViewer(final TabbedPropertySheetWidgetFactory widgetFactory,
        final Composite multiInstanceComposite) {
    final Composite completionComposite = widgetFactory.createPlainComposite(multiInstanceComposite, SWT.NONE);
    completionComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(3, 1).create());
    completionComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 0).create());
    final Label label = widgetFactory.createLabel(completionComposite,
            Messages.multiInstance_completionConditionLabel);
    label.setLayoutData(GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).create());
    final ExpressionViewer completionConditionViewer = new ExpressionViewer(completionComposite, SWT.BORDER,
            widgetFactory);
    completionConditionViewer
            .setExpressionNameResolver(new DefaultExpressionNameResolver("earlyCompletionCondition"));
    completionConditionViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    completionConditionViewer.addFilter(new CompletionConditionFilter(selectionProvider));
    completionConditionViewer.addFilter(new DisplayEngineExpressionWithName(new String[] {
            org.bonitasoft.engine.expression.ExpressionConstants.NUMBER_OF_ACTIVE_INSTANCES.getEngineConstantName(),
            org.bonitasoft.engine.expression.ExpressionConstants.NUMBER_OF_COMPLETED_INSTANCES
                    .getEngineConstantName(),
            org.bonitasoft.engine.expression.ExpressionConstants.NUMBER_OF_INSTANCES.getEngineConstantName(),
            org.bonitasoft.engine.expression.ExpressionConstants.NUMBER_OF_TERMINATED_INSTANCES
                    .getEngineConstantName() }));
    completionConditionViewer.setMessage(Messages.multiInstance_completionConditionDescription);

    final IObservableValue selectionObservable = ViewersObservables.observeSingleSelection(selectionProvider);
    context.bindValue(ViewersObservables.observeInput(completionConditionViewer), selectionObservable);
    context.bindValue(ViewersObservables.observeSingleSelection(completionConditionViewer),
            CustomEMFEditObservables.observeDetailValue(Realm.getDefault(), selectionObservable,
                    ProcessPackage.Literals.MULTI_INSTANTIABLE__COMPLETION_CONDITION));
}
 
Example #19
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 #20
Source File: IterationPropertySection.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private SelectObservableValue createRecurrenceTypeRadioGroup(final Composite composite,
        final TabbedPropertySheetWidgetFactory widgetFactory) {
    final Composite recurrenceTypeComposite = widgetFactory.createPlainComposite(composite, SWT.NONE);
    recurrenceTypeComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(4).create());
    recurrenceTypeComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());

    final Button noneRadio = widgetFactory.createButton(recurrenceTypeComposite, Messages.noneLabel, SWT.RADIO);
    noneRadio.setLayoutData(GridDataFactory.fillDefaults().create());

    final Button standardRadio = widgetFactory.createButton(recurrenceTypeComposite, Messages.standardLoop,
            SWT.RADIO);
    standardRadio.setLayoutData(GridDataFactory.fillDefaults().create());
    standardRadio.setImage(Pics.getImage("decoration/loop.png"));

    final Button parallelMultiRadio = widgetFactory.createButton(recurrenceTypeComposite,
            Messages.parallelMultinstantition, SWT.RADIO);
    parallelMultiRadio.setLayoutData(GridDataFactory.fillDefaults().create());
    parallelMultiRadio.setImage(Pics.getImage("decoration/parallel_multiInstance.png"));

    final Button sequentialMultiRadio = widgetFactory.createButton(recurrenceTypeComposite,
            Messages.sequentialMultinstantition, SWT.RADIO);
    sequentialMultiRadio.setLayoutData(GridDataFactory.fillDefaults().create());
    sequentialMultiRadio.setImage(Pics.getImage("decoration/sequential_multiInstance.png"));

    final SelectObservableValue recurrenceTypeObservable = new SelectObservableValue(MultiInstanceType.class);
    recurrenceTypeObservable.addOption(MultiInstanceType.NONE, SWTObservables.observeSelection(noneRadio));
    recurrenceTypeObservable.addOption(MultiInstanceType.STANDARD, SWTObservables.observeSelection(standardRadio));
    recurrenceTypeObservable.addOption(MultiInstanceType.PARALLEL,
            SWTObservables.observeSelection(parallelMultiRadio));
    recurrenceTypeObservable.addOption(MultiInstanceType.SEQUENTIAL,
            SWTObservables.observeSelection(sequentialMultiRadio));

    context.bindValue(recurrenceTypeObservable,
            CustomEMFEditObservables.observeDetailValue(Realm.getDefault(),
                    ViewersObservables.observeSingleSelection(selectionProvider),
                    ProcessPackage.Literals.MULTI_INSTANTIABLE__TYPE));

    return recurrenceTypeObservable;
}
 
Example #21
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 #22
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 #23
Source File: ContractPropertySection.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void createContent(final Composite parent) {
    final IObservableValue observeContractValue = CustomEMFEditObservables.observeDetailValue(Realm.getDefault(),
            ViewersObservables.observeSingleSelection(selectionProvider),
            ProcessPackage.Literals.CONTRACT_CONTAINER__CONTRACT);
    init(observeContractValue);

    final CTabFolder tabFolder = getWidgetFactory().createTabFolder(parent, SWT.TOP);
    tabFolder.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    getWidgetFactory().adapt(tabFolder);

    final CTabItem inputTabItem = getWidgetFactory().createTabItem(tabFolder, SWT.NULL);
    inputTabItem.setText(Messages.inputTabLabel);
    final Composite inputComposite = getWidgetFactory().createComposite(tabFolder);
    inputComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    inputComposite.setLayout(GridLayoutFactory.fillDefaults().margins(15, 10).numColumns(2).extendedMargins(5, 0, 0, 5)
                    .spacing(LayoutConstants.getSpacing().x, 15).create());

    createInputTabContent(inputComposite, observeContractValue);

    inputTabItem.setControl(inputComposite);

    final Composite constraintComposite = getWidgetFactory().createComposite(tabFolder);
    constraintComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    constraintComposite.setLayout(GridLayoutFactory.fillDefaults().margins(15, 10).numColumns(2).extendedMargins(5, 0, 0, 5)
            .spacing(LayoutConstants.getSpacing().x, 15).create());

    createConstraintTabContent(constraintComposite, observeContractValue);

    final CTabItem constraintTabItem = getWidgetFactory().createTabItem(tabFolder, SWT.NULL);
    constraintTabItem.setText(Messages.constraintsTabLabel);
    constraintTabItem.setControl(constraintComposite);
    tabFolder.setSelection(0);
}
 
Example #24
Source File: QueryExpressionEditor.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createBusinessObjectComboViewer(final Composite composite, final IObservableList observeBoList) {
    final Composite boComposite = new Composite(composite, SWT.NONE);
    boComposite.setLayoutData(GridDataFactory.fillDefaults().create());
    boComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).spacing(0, 2).create());

    final Label boLabel = new Label(boComposite, SWT.NONE);
    boLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).create());
    boLabel.setText(Messages.businessObject);

    final ComboViewer boCombo = new ComboViewer(boComposite, SWT.READ_ONLY | SWT.BORDER);
    boCombo.getControl().setLayoutData(
            GridDataFactory.fillDefaults().grab(true, false).minSize(100, SWT.DEFAULT).create());
    boCombo.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(final Object element) {
            if (element instanceof BusinessObjectExpressionQuery) {
                return ((BusinessObjectExpressionQuery) element).getQualifiedName();
            }
            return super.getText(element);
        }
    });
    boCombo.setContentProvider(new ObservableListContentProvider());

    boCombo.setInput(observeBoList);

    observeBOSingleSelection = ViewersObservables.observeSingleSelection(boCombo);
}
 
Example #25
Source File: BusinessObjectDataWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void createBusinessObjectTypeControl(final Composite mainComposite,
        final EMFDataBindingContext ctx) {
    final Label businessObjectLabel = new Label(mainComposite, SWT.NONE);
    businessObjectLabel.setLayoutData(fillDefaults().align(SWT.END, SWT.CENTER).create());
    businessObjectLabel.setText(Messages.businessObject + " *");

    final Composite comboComposite = new Composite(mainComposite, SWT.NONE);
    comboComposite.setLayout(GridLayoutFactory.fillDefaults().margins(0, 0).create());
    comboComposite.setLayoutData(fillDefaults().grab(true, false).create());

    final ComboViewer businessObjectComboViewer = new ComboViewer(comboComposite, SWT.READ_ONLY | SWT.BORDER);
    businessObjectComboViewer.getControl().setLayoutData(fillDefaults().grab(true, false).create());
    businessObjectComboViewer.setContentProvider(new ObservableListContentProvider());
    businessObjectComboViewer.setLabelProvider(businessObjectLabelProvider());

    final IObservableList<BusinessObject> businessObjectsObservableList = new WritableList(getAllBusinessObjects(),
            BusinessObject.class);

    final IViewerObservableValue observeSingleSelection = ViewersObservables
            .observeSingleSelection(businessObjectComboViewer);
    businessObjectComboViewer.setInput(businessObjectsObservableList);

    classNameObservable = EMFObservables.observeValue(businessObjectData,
            ProcessPackage.Literals.JAVA_OBJECT_DATA__CLASS_NAME);
    ctx.bindValue(observeSingleSelection,
            classNameObservable,
            updateValueStrategy().withConverter(businessObjectToFQN())
                    .withValidator(mandatoryValidator(Messages.businessObject))
                    .create(),
            updateValueStrategy().withConverter(fqnToBusinessObject())
                    .create());

    defaultValueReturnTypeObservable = EMFObservables.observeValue(businessObjectData.getDefaultValue(),
            ExpressionPackage.Literals.EXPRESSION__RETURN_TYPE);

    final String className = businessObjectData.getClassName();
    if ((className == null || className.isEmpty()) && !businessObjectsObservableList.isEmpty()) {
        observeSingleSelection.setValue(businessObjectsObservableList.get(0));
    }
}
 
Example #26
Source File: ContractPropertySection.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void bindAddChildButtonEnablement(final Button button, final Viewer viewer) {
    context.bindValue(WidgetProperties.enabled().observe(button),
            ViewersObservables.observeSingleSelection(viewer),
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER),
            emptySelectionAndComplexTypeToBooleanStrategy());

    context.bindValue(
            WidgetProperties.enabled().observe(button),
            EMFObservables.observeDetailValue(Realm.getDefault(), ViewersObservables.observeSingleSelection(viewer),
                    ProcessPackage.Literals.CONTRACT_INPUT__TYPE),
            new UpdateValueStrategy(UpdateValueStrategy.POLICY_NEVER),
            complexTypeToBooleanStrategy());
}
 
Example #27
Source File: DatabaseConnectorDriversWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void bindButtonWithViewer(Button button, TableViewer viewer) {
    UpdateValueStrategy modelToTarget = new UpdateValueStrategy();
    modelToTarget.setConverter(new Converter(Object.class, Boolean.class) {

        @Override
        public Object convert(Object fromObject) {
            return fromObject != null;
        }

    });
    context.bindValue(SWTObservables.observeEnabled(button), ViewersObservables.observeSingleSelection(viewer), null,
            modelToTarget);
}
 
Example #28
Source File: DatabaseConnectorOutputWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected Composite createSingleOuputControl(final Composite parent,
        final EMFDataBindingContext context) {
    final Composite mainComposite = new Composite(parent, SWT.NONE);
    mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).margins(20, 20).create());

    Operation singleModeOuputOperation = getOuputOperationFor(SINGLE_RESULT_OUTPUT);
    if (singleModeOuputOperation == null) {
        singleModeOuputOperation = createDefaultOutput(SINGLE_RESULT_OUTPUT, getDefinition());
        getConnector().getOutputs().add(singleModeOuputOperation);
    }

    final ReadOnlyExpressionViewer targetDataExpressionViewer = new ReadOnlyExpressionViewer(mainComposite, SWT.BORDER,
            null, null, ExpressionPackage.Literals.OPERATION__LEFT_OPERAND);
    targetDataExpressionViewer.getControl()
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, false).hint(250, SWT.DEFAULT).create());
    final IExpressionNatureProvider storageExpressionProvider = getStorageExpressionProvider();
    if (storageExpressionProvider != null) {
        targetDataExpressionViewer.setExpressionNatureProvider(storageExpressionProvider);
    }
    targetDataExpressionViewer.addFilter(leftFilter);
    targetDataExpressionViewer.setContext(getElementContainer());
    targetDataExpressionViewer.setInput(singleModeOuputOperation);

    context.bindValue(ViewersObservables.observeSingleSelection(targetDataExpressionViewer),
            EMFObservables.observeValue(singleModeOuputOperation, ExpressionPackage.Literals.OPERATION__LEFT_OPERAND));

    final Label takeValueOfLabel = new Label(mainComposite, SWT.NONE);
    takeValueOfLabel.setLayoutData(GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).create());
    takeValueOfLabel.setText(Messages.takeValueOf);

    singleColumnText = new Text(mainComposite, SWT.BORDER | SWT.READ_ONLY);
    singleColumnText.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());

    return mainComposite;
}
 
Example #29
Source File: MoveConnectorWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createProcessTreeControl(final EMFDataBindingContext dbc, final Composite parent) {
    final Label label = new Label(parent, SWT.NONE);
    label.setLayoutData(GridDataFactory.swtDefaults().span(2, 1).create());
    label.setText(Messages.chooseTargetStepOrProcess);

    final TreeViewer processTreeViewer = new FilteredTree(parent, SWT.BORDER | SWT.SINGLE, new PatternFilter(), true).getViewer();
    processTreeViewer.getControl().getParent().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(2, 1).hint(SWT.DEFAULT, 300).create());
    processTreeViewer.setLabelProvider(new ElementLabelProvider(adapterFactory));
    processTreeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
    processTreeViewer.addFilter(new ConnectableElementViewerFilter(sourceProcess));
    processTreeViewer.setInput(ModelHelper.getMainProcess(sourceProcess));
    processTreeViewer.expandAll();
    dbc.bindValue(ViewersObservables.observeSingleSelection(processTreeViewer), targetLocationObservable,
            updateValueStrategy().withValidator(selectionValidator()).create(), null);
}
 
Example #30
Source File: InternalMappingComposite.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public void doBindControl(final DataBindingContext context, final IObservableValue formMappingObservable) {
    context.bindValue(ViewersObservables.observeInput(targetFormExpressionViewer), formMappingObservable);
    context.bindValue(ViewersObservables.observeSingleSelection(targetFormExpressionViewer),
            CustomEMFEditObservables.observeDetailValue(Realm.getDefault(), formMappingObservable,
                    ProcessPackage.Literals.FORM_MAPPING__TARGET_FORM));
    doBindInfo(context, formMappingObservable);
}