List of usage examples for org.eclipse.jface.viewers ComboViewer getControl
@Override
public Control getControl()
From source file:org.bonitasoft.studio.businessobject.ui.expression.QueryExpressionEditor.java
License:Open Source License
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//from w w w . j a va 2s. c o m public String getText(final Object element) { if (element instanceof BusinessObjectExpressionQuery) { return NamingUtils.getSimpleName(((BusinessObjectExpressionQuery) element).getQualifiedName()); } return super.getText(element); } }); boCombo.setContentProvider(new ObservableListContentProvider()); boCombo.setInput(observeBoList); observeBOSingleSelection = ViewersObservables.observeSingleSelection(boCombo); }
From source file:org.bonitasoft.studio.businessobject.ui.wizard.BusinessObjectDataWizardPage.java
License:Open Source License
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().numColumns(2).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 WritableList businessObjectsObservableList = new WritableList(getAllBusinessObjects(), BusinessObject.class); final IViewerObservableValue observeSingleSelection = ViewersObservables .observeSingleSelection(businessObjectComboViewer); createNewBusinessObjectLink(comboComposite, businessObjectsObservableList, observeSingleSelection); 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)); }/* w w w. j a v a2 s. c om*/ }
From source file:org.bonitasoft.studio.businessobject.ui.wizard.control.AttributesTabItemControl.java
License:Open Source License
private Composite createRelationFieldDetailContent(final Group detailGroup, final DataBindingContext ctx, final IViewerObservableValue attributeSelectionObservable, final IViewerObservableValue viewerObservableValue) { final Composite composite = new Composite(detailGroup, SWT.NONE); composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); composite//www . ja va 2s .c om .setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(10, 10).spacing(15, 10).create()); final Label relationKindLabel = new Label(composite, SWT.NONE); relationKindLabel.setLayoutData(GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).create()); relationKindLabel.setText(Messages.relation); final ControlDecoration controlDecoration = new ControlDecoration(relationKindLabel, SWT.RIGHT); controlDecoration.setDescriptionText(Messages.realtionTooltip); controlDecoration.setImage(Pics.getImage(PicsConstants.hint)); controlDecoration.setMarginWidth(-2); final ComboViewer relationComboViewer = new ComboViewer(composite, SWT.BORDER | SWT.READ_ONLY); relationComboViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); relationComboViewer.setContentProvider(ArrayContentProvider.getInstance()); relationComboViewer.setLabelProvider(new RelationKindLabelProvider()); relationComboViewer.setInput(RelationField.Type.values()); ctx.bindValue(ViewersObservables.observeSingleSelection(relationComboViewer), PojoObservables.observeDetailValue(attributeSelectionObservable, "type", Type.class)); new Label(composite, SWT.NONE); final Composite lazyRadioComposite = new Composite(composite, SWT.NONE); lazyRadioComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); lazyRadioComposite .setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 0).spacing(25, 0).create()); final Button lazyRadio = new Button(lazyRadioComposite, SWT.RADIO); lazyRadio.setLayoutData(GridDataFactory.swtDefaults().grab(false, false).create()); lazyRadio.setText(Messages.loadOnDemand); final ControlDecoration lazyDecorator = new ControlDecoration(lazyRadio, SWT.RIGHT); lazyDecorator.setImage(Pics.getImage(PicsConstants.hint)); lazyDecorator.setDescriptionText(Messages.loadOnDemandHint); lazyDecorator.setMarginWidth(-5); final Button eagerRadio = new Button(lazyRadioComposite, SWT.RADIO); eagerRadio.setLayoutData(GridDataFactory.swtDefaults().grab(false, false).create()); eagerRadio.setText(Messages.alwaysLoad); final ControlDecoration eagerDecorator = new ControlDecoration(eagerRadio, SWT.RIGHT); eagerDecorator.setImage(Pics.getImage(PicsConstants.hint)); eagerDecorator.setMarginWidth(-5); viewerObservableValue.addValueChangeListener(new IValueChangeListener() { @Override public void handleValueChange(final ValueChangeEvent event) { final BusinessObject bo = (BusinessObject) event.diff.getNewValue(); if (bo != null) { eagerDecorator.setDescriptionText(Messages.bind(Messages.alwaysLoadHint, NamingUtils.getSimpleName(bo.getQualifiedName()))); } } }); final SelectObservableValue radioGroupObservable = new SelectObservableValue(FetchType.class); radioGroupObservable.addOption(FetchType.LAZY, SWTObservables.observeSelection(lazyRadio)); radioGroupObservable.addOption(FetchType.EAGER, SWTObservables.observeSelection(eagerRadio)); ctx.bindValue(radioGroupObservable, PojoObservables.observeDetailValue(attributeSelectionObservable, "fetchType", FetchType.class)); return composite; }
From source file:org.bonitasoft.studio.businessobject.ui.wizard.QueryWizardPage.java
License:Open Source License
@Override public void createControl(final Composite parent) { final DataBindingContext ctx = new DataBindingContext(); final Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(10, 10).create()); composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); final Link queryLabel = new Link(composite, SWT.NO_FOCUS); queryLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).create()); queryLabel.setText(Messages.queryLink); queryLabel.addSelectionListener(new SelectionAdapter() { @Override/*from w ww .ja va 2s . c o m*/ public void widgetSelected(final SelectionEvent e) { performHelp(); } }); final StyledText queryText = createQueryText(composite); queryText.setFont(getMonospaceFont()); queryText.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(300, 120).create()); if (query.getContent() == null || query.getContent().isEmpty()) { final String queryExample = createQueryExample(businessObject); query.setContent(queryExample); if (query.getQueryParameters().isEmpty()) { for (final Field f : businessObject.getFields()) { if (f instanceof SimpleField) { query.addQueryParameter(f.getName(), ((SimpleField) f).getType().getClazz().getName()); } } } } final UpdateValueStrategy targetStrategy = new UpdateValueStrategy(); targetStrategy.setAfterGetValidator(new IValidator() { @Override public IStatus validate(final Object value) { if (value == null || value.toString().trim().isEmpty()) { return ValidationStatus.error(Messages.emptyQueryError); } return checkParametersUsage(value.toString()); } }); final UpdateValueStrategy strategy = new UpdateValueStrategy(); strategy.setAfterGetValidator(new IValidator() { @Override public IStatus validate(final Object value) { return checkParametersUsage(value.toString()); } }); queryBinding = ctx.bindValue(SWTObservables.observeText(queryText, SWT.Modify), PojoObservables.observeValue(getQuery(), "content"), targetStrategy, strategy); final Label queryParamLabel = new Label(composite, SWT.NONE); queryParamLabel .setLayoutData(GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.FILL).indent(0, 10).create()); queryParamLabel.setText(Messages.parameters); final ControlDecoration controlDecoration = new ControlDecoration(queryParamLabel, SWT.RIGHT); controlDecoration.setImage(Pics.getImage(PicsConstants.hint)); controlDecoration.setDescriptionText(Messages.jpqlParametersHint); controlDecoration.setShowOnlyOnFocus(false); createQueryParametersTable(composite, ctx); final Label queryResultTypeLabel = new Label(composite, SWT.NONE); queryResultTypeLabel .setLayoutData(GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).indent(0, 5).create()); queryResultTypeLabel.setText(Messages.queryResultType); final ComboViewer resultTypeViewer = createReturnTypeComboViewer(composite); resultTypeViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); resultTypeViewer.setContentProvider(ArrayContentProvider.getInstance()); resultTypeViewer.setLabelProvider(new LabelProvider() { @Override public String getText(final Object element) { final String className = element.toString(); if (List.class.getName().equals(className)) { return Messages.multipleReturnType; } else if (Long.class.getName().equals(className)) { return className + " (COUNT,SUM...etc)"; } else if (Double.class.getName().equals(className)) { return className + " (AVG...etc)"; } else if (businessObject.getQualifiedName().equals(className)) { return Messages.bind(Messages.single, businessObject.getQualifiedName()); } return super.getText(element); } }); resultTypeViewer.setInput(getSupportedReturnTypes(businessObject)); final IViewerObservableValue returnTypeSelectionObservable = ViewersObservables .observeSingleSelection(resultTypeViewer); ctx.bindValue(returnTypeSelectionObservable, PojoObservables.observeValue(getQuery(), "returnType")); returnTypeSelectionObservable.addValueChangeListener(new IValueChangeListener() { @Override public void handleValueChange(final ValueChangeEvent event) { queryBinding.validateTargetToModel(); } }); WizardPageSupport.create(this, ctx); setControl(composite); }
From source file:org.bonitasoft.studio.businessobject.ui.wizard.ReadOnlyQueryWizardPage.java
License:Open Source License
@Override protected ComboViewer createReturnTypeComboViewer(Composite composite) { ComboViewer returnTypeComboViewer = super.createReturnTypeComboViewer(composite); returnTypeComboViewer.getControl().setEnabled(false); return returnTypeComboViewer; }
From source file:org.bonitasoft.studio.decision.ui.DecisionTableWizardPage.java
License:Open Source License
/** * @param gridPlaceholder //from w w w . ja va 2 s . c o m * @param gridPlaceHolder * @return */ public Composite createGrid(final Composite gridPlaceholder) { gridPlaceholder.setBackgroundMode(SWT.INHERIT_FORCE); int nbColumns = 7; // Edit, delete, up, down, space (on the left) + arrow & Action (on the right); int nbMaxConditions = 0; for (DecisionTableLine line : decisionTable.getLines()) { nbMaxConditions = Math.max(line.getConditions().size(), nbMaxConditions); } if (nbMaxConditions > 0) { nbColumns += 2 * nbMaxConditions - 1; } final GridLayout layout = new GridLayout(nbColumns, false); gridPlaceholder.setLayout(layout); gridPlaceholder.setLayoutData(new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false)); { Composite filler = new Composite(gridPlaceholder, SWT.NONE); GridData fillerLayoutData = new GridData(0, 0); fillerLayoutData.horizontalSpan = 5; filler.setLayoutData(fillerLayoutData); // TITLE if (nbMaxConditions > 0) { Label conditionsLabel = new Label(gridPlaceholder, SWT.NONE); conditionsLabel.setText(Messages.conditions); conditionsLabel .setBackground(zebraGridPaintListener.getColorForControl(gridPlaceholder, conditionsLabel)); conditionsLabel.setLayoutData( new GridData(SWT.CENTER, SWT.NONE, false, false, 2 * nbMaxConditions - 1, 1)); } new Composite(gridPlaceholder, SWT.NONE).setLayoutData(new GridData(0, 0)); Label decisionLabel = new Label(gridPlaceholder, SWT.NONE); decisionLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.FILL) .grab(false, false).span(1, 1).create()); decisionLabel.setText(Messages.decision); decisionLabel.setBackground(zebraGridPaintListener.getColorForControl(gridPlaceholder, decisionLabel)); } final GridData iconButtonLayoutData = new GridData(SWT.RIGHT, SWT.CENTER, false, false); iconButtonLayoutData.heightHint = DELETE_SIZE; iconButtonLayoutData.widthHint = DELETE_SIZE; final GridData oneCellFillerLayoutData = new GridData(0, 0); final GridData andLayoutData = new GridData(SWT.FILL, SWT.CENTER, false, false); for (int i = 0; i < decisionTable.getLines().size(); i++) { final int index = i; final DecisionTableLine line = decisionTable.getLines().get(i); if (line != toEditLine) { Composite editLineComposite = createImageButton(gridPlaceholder, Pics.getImage(PicsConstants.edit)); editLineComposite.setBackground( zebraGridPaintListener.getColorForControl(gridPlaceholder, editLineComposite)); editLineComposite.setLayoutData(iconButtonLayoutData); editLineComposite.setToolTipText(Messages.editRow); editLineComposite.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { toEditLine = line; lineWorkingCopy = EcoreUtil.copy(toEditLine); updateLineButton.setEnabled(true); zebraGridPaintListener.setSelectedRow(index); refresh(true, true); } }); } else { new Composite(gridPlaceholder, SWT.NONE).setLayoutData(new GridData(0, 0)); } Composite deleteLineComposite = createImageButton(gridPlaceholder, Pics.getImage(PicsConstants.remove)); deleteLineComposite .setBackground(zebraGridPaintListener.getColorForControl(gridPlaceholder, deleteLineComposite)); deleteLineComposite.setLayoutData(iconButtonLayoutData); deleteLineComposite.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { if (MessageDialog.openConfirm(gridPlaceholder.getShell(), Messages.deleteLineTitle, Messages.deleteLineMessage)) { deleteLine(line); } } }); if (index != 0) { Composite lineUpComposite = createImageButton(gridPlaceholder, Pics.getImage(PicsConstants.arrowUp)); lineUpComposite .setBackground(zebraGridPaintListener.getColorForControl(gridPlaceholder, lineUpComposite)); lineUpComposite.setLayoutData(iconButtonLayoutData); lineUpComposite.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { decisionTable.getLines().remove(index); decisionTable.getLines().add(index - 1, line); zebraGridPaintListener.setSelectedRow(decisionTable.getLines().indexOf(line)); refreshGrid(); } }); } else { new Composite(gridPlaceholder, SWT.NONE).setLayoutData(oneCellFillerLayoutData); } if (i != decisionTable.getLines().size() - 1) { Composite lineDownComposite = createImageButton(gridPlaceholder, Pics.getImage(PicsConstants.arrowDown)); lineDownComposite.setBackground( zebraGridPaintListener.getColorForControl(gridPlaceholder, lineDownComposite)); lineDownComposite.setLayoutData(iconButtonLayoutData); lineDownComposite.addMouseListener(new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { decisionTable.getLines().remove(index); decisionTable.getLines().add(index + 1, line); zebraGridPaintListener.setSelectedRow(decisionTable.getLines().indexOf(line)); refreshGrid(); } }); } else { new Composite(gridPlaceholder, SWT.NONE).setLayoutData(oneCellFillerLayoutData); } if (!line.getConditions().isEmpty()) { new Composite(gridPlaceholder, SWT.NONE).setLayoutData(new GridData(0, 20)); } Label andLabel = null; for (Expression cond : line.getConditions()) { Label condLabel = new Label(gridPlaceholder, SWT.NONE); condLabel.setBackground(zebraGridPaintListener.getColorForControl(gridPlaceholder, condLabel)); String stringCondition = cond.getContent(); if (stringCondition.length() > 15) { condLabel.setToolTipText(stringCondition); stringCondition = stringCondition.substring(0, 12) + "..."; } condLabel.setText(stringCondition); andLabel = new Label(gridPlaceholder, SWT.NONE); andLabel.setText(Messages.and); andLabel.setForeground(GRAY); andLabel.setLayoutData(andLayoutData); andLabel.setBackground(zebraGridPaintListener.getColorForControl(gridPlaceholder, andLabel)); } if (andLabel != null) { andLabel.dispose(); } if (line.getConditions().size() < nbMaxConditions) { Composite filler = new Composite(gridPlaceholder, SWT.NONE); int nbColumnsToFill = 0; if (line.getConditions().isEmpty()) { nbColumnsToFill = 2 * (nbMaxConditions - line.getConditions().size()) - 1; } else { nbColumnsToFill = 2 * (nbMaxConditions - line.getConditions().size()); } GridData gd = new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false, nbColumnsToFill, 1); gd.widthHint = gd.heightHint = 0; filler.setLayoutData(gd); } if (line.getConditions().isEmpty()) { Label condLabel = new Label(gridPlaceholder, SWT.NONE); condLabel.setBackground(zebraGridPaintListener.getColorForControl(gridPlaceholder, condLabel)); condLabel.setText(Messages.noConditionDefined); condLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1)); } Composite arrow = createImageButton(gridPlaceHolder, Pics.getImage(PicsConstants.arrowRight)); arrow.setBackground(zebraGridPaintListener.getColorForControl(gridPlaceholder, arrow)); final GridData arrowlayoutData = new GridData(16, 16); arrowlayoutData.horizontalAlignment = SWT.RIGHT; arrowlayoutData.grabExcessHorizontalSpace = true; arrow.setLayoutData(arrowlayoutData); final ComboViewer lineValueCombo = new ComboViewer(gridPlaceholder, SWT.READ_ONLY); lineValueCombo.setContentProvider(new ArrayContentProvider()); if (wizard.getActionsComparer() != null) { lineValueCombo.setComparer(wizard.getActionsComparer()); } lineValueCombo.setLabelProvider(wizard.getActionLabelProvider()); lineValueCombo.setInput(wizard.getPossibleLineActions()); lineValueCombo.setSelection(new StructuredSelection(line.getAction())); lineValueCombo.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent arg0) { final DecisionTableAction action = EcoreUtil .copy((DecisionTableAction) ((IStructuredSelection) lineValueCombo.getSelection()) .getFirstElement()); line.setAction(action); } }); lineValueCombo.getControl().setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); } { // ADD LINE Link addRowLink = new Link(gridPlaceholder, SWT.TRANSPARENT); addRowLink.setText("<A>" + Messages.addRow + "</A>"); addRowLink.setBackground(zebraGridPaintListener.getColorForControl(gridPlaceholder, addRowLink)); addRowLink.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 5, 1)); // Edit, up, down, delete addRowLink.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { DecisionTableLine newRow = DecisionFactory.eINSTANCE.createDecisionTableLine(); newRow.setAction(EcoreUtil.copy(wizard.getPossibleLineActions()[0])); decisionTable.getLines().add(newRow); toEditLine = newRow; lineWorkingCopy = EcoreUtil.copy(newRow); updateLineButton.setEnabled(true); zebraGridPaintListener.setSelectedRow(decisionTable.getLines().indexOf(newRow)); refresh(true, true); } }); Composite filler = new Composite(gridPlaceholder, SWT.NONE); final GridData layoutData = new GridData(SWT.FILL, SWT.NONE, false, false, 2 * nbMaxConditions + 1, 1); layoutData.heightHint = layoutData.heightHint = 0; filler.setLayoutData(layoutData); } { // DEFAULT Label defaultLabel = new Label(gridPlaceholder, SWT.NONE); defaultLabel.setText(Messages.defaultLine); defaultLabel.setBackground(zebraGridPaintListener.getColorForControl(gridPlaceholder, defaultLabel)); defaultLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 5, 1)); // Edit, up, down, delete if (nbMaxConditions > 0) { Composite filler = new Composite(gridPlaceholder, SWT.NONE); final GridData layoutData = new GridData(SWT.DEFAULT, SWT.DEFAULT, false, false, 2 * nbMaxConditions - 1, 1); layoutData.heightHint = layoutData.widthHint = 0; filler.setLayoutData(layoutData); } Composite arrow = createImageButton(gridPlaceHolder, Pics.getImage(PicsConstants.arrowRight)); arrow.setBackground(zebraGridPaintListener.getColorForControl(gridPlaceholder, arrow)); final GridData arrowlayoutData = new GridData(16, 16); arrowlayoutData.horizontalAlignment = SWT.END; arrowlayoutData.grabExcessHorizontalSpace = true; arrow.setLayoutData(arrowlayoutData); final ComboViewer defaultValueCombo = new ComboViewer(gridPlaceholder, SWT.READ_ONLY); defaultValueCombo.setContentProvider(new ArrayContentProvider()); if (wizard.getActionsComparer() != null) { defaultValueCombo.setComparer(wizard.getActionsComparer()); } defaultValueCombo.setLabelProvider(wizard.getActionLabelProvider()); defaultValueCombo.setInput(wizard.getPossibleDefaultTableActions()); if (decisionTable.getDefaultAction() != null) { defaultValueCombo.setSelection(new StructuredSelection(decisionTable.getDefaultAction())); } defaultValueCombo.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent arg0) { final DecisionTableAction action = EcoreUtil.copy( (DecisionTableAction) ((IStructuredSelection) arg0.getSelection()).getFirstElement()); decisionTable.setDefaultAction(action); } }); defaultValueCombo.getControl().setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); } return gridPlaceholder; }
From source file:org.bonitasoft.studio.properties.form.sections.actions.contributions.WidgetModifierContribution.java
License:Open Source License
public void createControl(Composite composite, TabbedPropertySheetWidgetFactory widgetFactory, ExtensibleGridPropertySection extensibleGridPropertySection) { dataBindingContext = new EMFDataBindingContext(); composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); composite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).create()); final ComboViewer modifiersCombo = new ComboViewer(composite, SWT.READ_ONLY | SWT.BORDER); modifiersCombo.getControl().setLayoutData(GridDataFactory.fillDefaults().indent(5, 0).create()); modifiersCombo.setLabelProvider(new LabelProvider()); modifiersCombo.setContentProvider(new ArrayContentProvider()); modifiersCombo.setSorter(new ViewerSorter()); modifiersCombo.setInput(getAvailableModifiersFor(widget)); modifiersCombo.addSelectionChangedListener(this); final ControlDecoration deco = new ControlDecoration(modifiersCombo.getControl(), SWT.LEFT); deco.setDescriptionText(Messages.modifierDescription); deco.setImage(Pics.getImage(PicsConstants.hint)); deco.setMarginWidth(2);//from www .j ava2 s. c om deco.setShowOnlyOnFocus(false); dataBindingContext.bindValue(ViewersObservables.observeSingleSelection(modifiersCombo), EMFEditObservables .observeValue(editingDomain, widget, FormPackage.Literals.WIDGET__RETURN_TYPE_MODIFIER)); }
From source file:org.bonitasoft.studio.properties.sections.iteration.IterationPropertySection.java
License:Open Source License
private void createOutputGroup(final TabbedPropertySheetWidgetFactory widgetFactory, final Composite dataContent) { final Composite outputComposite = widgetFactory.createPlainComposite(dataContent, SWT.NONE); outputComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).indent(0, 20).create()); outputComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).create()); final Button storeOutputButton = widgetFactory.createButton(outputComposite, Messages.storeOutputResult, SWT.CHECK);/*from w ww.ja v a 2 s.c o m*/ storeOutputButton.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); final ISWTObservableValue observeStoreOutputSelection = SWTObservables.observeSelection(storeOutputButton); final IObservableValue selectionObservable = ViewersObservables.observeSingleSelection(selectionProvider); context.bindValue(observeStoreOutputSelection, CustomEMFEditObservables.observeDetailValue( Realm.getDefault(), selectionObservable, ProcessPackage.Literals.MULTI_INSTANTIABLE__STORE_OUTPUT)); final Group outputGroup = widgetFactory.createGroup(outputComposite, Messages.output); outputGroup.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); outputGroup.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).spacing(5, 3).create()); final Label outputDatalabel = widgetFactory.createLabel(outputGroup, Messages.outputData); outputDatalabel.setLayoutData(GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).create()); final ComboViewer outputDataComboViewer = createComboViewer(widgetFactory, outputGroup, new ObservableListContentProviderWithProposalListenersForActivity()); outputDataComboViewer.getControl().setLayoutData( GridDataFactory.fillDefaults().grab(true, false).hint(200, SWT.DEFAULT).indent(5, 0).create()); outputDataComboViewer.setSorter(new DataViewerSorter()); final IViewerObservableValue observeSingleSelection = ViewersObservables .observeSingleSelection(outputDataComboViewer); final IObservableValue observeDataValue = CustomEMFEditObservables.observeDetailValue(Realm.getDefault(), selectionObservable, ProcessPackage.Literals.MULTI_INSTANTIABLE__OUTPUT_DATA); selectionObservable.addValueChangeListener( createInputValueChanged(outputDataComboViewer, observeSingleSelection, observeDataValue, true)); context.bindValue(observeSingleSelection, observeDataValue); outputDataComboViewer .addSelectionChangedListener(createComboSelectionListener(outputDataComboViewer, true)); final Label label = widgetFactory.createLabel(outputGroup, ""); label.setImage(Pics.getImage("icon-arrow-down.png")); label.setLayoutData(GridDataFactory.fillDefaults().span(3, 1).align(SWT.CENTER, SWT.CENTER).create()); final Label outputListlabel = widgetFactory.createLabel(outputGroup, Messages.outputList); outputListlabel.setLayoutData(GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).create()); final ComboViewer outputListComboViewer = createComboViewer(widgetFactory, outputGroup, new ObservableListContentProviderWithProposalListenersForPool()); outputListComboViewer.getControl().setLayoutData( GridDataFactory.fillDefaults().grab(true, false).hint(200, SWT.DEFAULT).indent(5, 0).create()); outputListComboViewer.addFilter(new ListDataFilter()); outputListComboViewer.setSorter(new DataViewerSorter()); final IObservableValue observeDetailValue = CustomEMFEditObservables.observeDetailValue(Realm.getDefault(), selectionObservable, ProcessPackage.Literals.MULTI_INSTANTIABLE__LIST_DATA_CONTAINING_OUTPUT_RESULTS); final IViewerObservableValue observeSingleSelection2 = ViewersObservables .observeSingleSelection(outputListComboViewer); selectionObservable.addValueChangeListener( createInputValueChanged(outputListComboViewer, observeSingleSelection2, observeDetailValue, false)); context.bindValue(observeSingleSelection2, observeDetailValue); context.bindValue(PojoObservables.observeValue(new RecursiveControlEnablement(outputGroup), "enabled"), observeStoreOutputSelection); outputListComboViewer .addSelectionChangedListener(createComboSelectionListener(outputListComboViewer, false)); }
From source file:org.bonitasoft.studio.properties.sections.iteration.IterationPropertySection.java
License:Open Source License
private void createInputForDataGroup(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 inputListlabel = widgetFactory.createLabel(inputGroup, Messages.inputList + " *"); inputListlabel.setLayoutData(GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).create()); final ControlDecoration inputListlabelDecoration = new ControlDecoration(inputListlabel, SWT.RIGHT); inputListlabelDecoration.setMarginWidth(-3); inputListlabelDecoration.setDescriptionText(Messages.inputListHint); inputListlabelDecoration.setImage(Pics.getImage(PicsConstants.hint)); final ComboViewer inputListComboViewer = createComboViewer(widgetFactory, inputGroup, new ObservableListContentProviderWithProposalListenersForPool()); inputListComboViewer.getControl().setLayoutData( GridDataFactory.fillDefaults().grab(true, false).hint(200, SWT.DEFAULT).indent(5, 0).create()); inputListComboViewer.addFilter(new ListDataFilter()); inputListComboViewer.setSorter(new DataViewerSorter()); final IViewerObservableValue observeSingleSelection = ViewersObservables .observeSingleSelection(inputListComboViewer); final IObservableValue selectionObservable = ViewersObservables.observeSingleSelection(selectionProvider); final IObservableValue observeInputCollectionValue = CustomEMFEditObservables.observeDetailValue( Realm.getDefault(), selectionObservable, ProcessPackage.Literals.MULTI_INSTANTIABLE__COLLECTION_DATA_TO_MULTI_INSTANTIATE); selectionObservable.addValueChangeListener(createInputValueChanged(inputListComboViewer, observeSingleSelection, observeInputCollectionValue, false)); inputListComboViewer.addSelectionChangedListener(createComboSelectionListener(inputListComboViewer, false)); inputListComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override// ww w .j a va2s . co m public void selectionChanged(final SelectionChangedEvent event) { updateReturnTypeFromSelectedInputCollection(inputListComboViewer); } }); context.bindValue(observeSingleSelection, observeInputCollectionValue); final Label label = widgetFactory.createLabel(inputGroup, ""); label.setImage(Pics.getImage("icon-arrow-down.png")); label.setLayoutData(GridDataFactory.fillDefaults().span(3, 1).align(SWT.CENTER, SWT.CENTER).create()); final Label ieratorLabel = widgetFactory.createLabel(inputGroup, Messages.iterator + " *"); ieratorLabel.setLayoutData(GridDataFactory.swtDefaults().align(SWT.RIGHT, SWT.CENTER).create()); final ControlDecoration ieratorLabelDecoration = new ControlDecoration(ieratorLabel, SWT.RIGHT); ieratorLabelDecoration.setDescriptionText(Messages.iteratorHint); ieratorLabelDecoration.setImage(Pics.getImage(PicsConstants.hint)); ieratorLabelDecoration.setMarginWidth(-3); createIteratorControl(widgetFactory, inputGroup, ieratorLabelDecoration); }
From source file:org.bonitasoft.studio.properties.sections.loop.MultiInstantiationPropertyContribution.java
License:Open Source License
protected ComboViewer createChooser(TabbedPropertySheetWidgetFactory widgetFactory, Composite inputOutputDataComposite) { final ComboViewer comboViewer = new ComboViewer( new Combo(inputOutputDataComposite, SWT.BORDER | SWT.READ_ONLY)); comboViewer.setContentProvider(new ObservableListContentProvider()); comboViewer.setLabelProvider(new DataLabelProvider()); comboViewer.getControl() .setLayoutData(GridDataFactory.fillDefaults().grab(true, false).indent(5, 0).create()); ToolBar toolBar = new ToolBar(inputOutputDataComposite, SWT.FLAT); widgetFactory.adapt(toolBar);// w ww .jav a 2 s .com ToolItem toolItem = new ToolItem(toolBar, SWT.FLAT); toolItem.setImage(Pics.getImage(PicsConstants.clear)); toolItem.setToolTipText(Messages.clearSelection); toolItem.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { super.widgetSelected(e); comboViewer.setSelection(new StructuredSelection()); } }); return comboViewer; }