List of usage examples for org.eclipse.jface.databinding.swt SWTObservables observeSelection
@Deprecated public static ISWTObservableValue observeSelection(Control control)
control
. From source file:org.bonitasoft.studio.properties.sections.timer.cron.CronEditor.java
License:Open Source License
protected void createWeeklyTab(TabFolder tablFolder) { final TabItem item = new TabItem(tablFolder, SWT.NONE); item.setText(Messages.weekly);// w ww . ja va2 s. co m final Composite weeklyContent = new Composite(tablFolder, SWT.NONE); weeklyContent.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); weeklyContent.setLayout(GridLayoutFactory.fillDefaults().numColumns(4).margins(15, 10).create()); final Button mondayButton = new Button(weeklyContent, SWT.CHECK); mondayButton.setText(Messages.monday); context.bindValue(SWTObservables.observeSelection(mondayButton), PojoProperties.value("onMonday").observe(cronExpression)); final Button tuesdayButton = new Button(weeklyContent, SWT.CHECK); tuesdayButton.setText(Messages.tuesday); context.bindValue(SWTObservables.observeSelection(tuesdayButton), PojoProperties.value("onTuesday").observe(cronExpression)); final Button wednesdayButton = new Button(weeklyContent, SWT.CHECK); wednesdayButton.setText(Messages.wednesday); context.bindValue(SWTObservables.observeSelection(wednesdayButton), PojoProperties.value("onWednesday").observe(cronExpression)); final Button thursdayButton = new Button(weeklyContent, SWT.CHECK); thursdayButton.setText(Messages.thursday); context.bindValue(SWTObservables.observeSelection(thursdayButton), PojoProperties.value("onThursday").observe(cronExpression)); final Button fridayButton = new Button(weeklyContent, SWT.CHECK); fridayButton.setText(Messages.friday); context.bindValue(SWTObservables.observeSelection(fridayButton), PojoProperties.value("onFriday").observe(cronExpression)); final Button saturdayButton = new Button(weeklyContent, SWT.CHECK); saturdayButton.setText(Messages.saturday); context.bindValue(SWTObservables.observeSelection(saturdayButton), PojoProperties.value("onSaturday").observe(cronExpression)); final Button sundayButton = new Button(weeklyContent, SWT.CHECK); sundayButton.setText(Messages.sunday); context.bindValue(SWTObservables.observeSelection(sundayButton), PojoProperties.value("onSunday").observe(cronExpression)); final IObservableValue hourObservable = PojoProperties.value("atHourInWeek").observe(cronExpression); final IObservableValue minuteObservable = PojoProperties.value("atMinuteInWeek").observe(cronExpression); final IObservableValue secondObservable = PojoProperties.value("atSecondInWeek").observe(cronExpression); createStartTimeComposite(weeklyContent, hourObservable, minuteObservable, secondObservable) .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(4, 1).create()); item.setControl(weeklyContent); }
From source file:org.bonitasoft.studio.properties.sections.timer.cron.CronEditor.java
License:Open Source License
protected void createDailyTab(TabFolder tablFolder) { final TabItem item = new TabItem(tablFolder, SWT.NONE); item.setText(Messages.daily);/* w ww .ja v a 2 s .c o m*/ final Composite dailyContent = new Composite(tablFolder, SWT.NONE); dailyContent.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); dailyContent.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(15, 10).create()); final Button everyRadio = new Button(dailyContent, SWT.RADIO); everyRadio.setLayoutData(GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).create()); everyRadio.setText(Messages.every); context.bindValue(SWTObservables.observeSelection(everyRadio), PojoProperties.value("useEveryDayForDaily").observe(cronExpression)); final Composite everyComposite = new Composite(dailyContent, SWT.NONE); everyComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).indent(-65, 0).create()); everyComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 0).create()); final Text dayText = new Text(everyComposite, SWT.BORDER | SWT.SINGLE); dayText.setLayoutData(GridDataFactory.fillDefaults().hint(70, SWT.DEFAULT).create()); UpdateValueStrategy dayFrequencyStrategy = new UpdateValueStrategy(); dayFrequencyStrategy.setAfterGetValidator(dotValidator); dayFrequencyStrategy.setConverter(StringToNumberConverter.toInteger(true)); dayFrequencyStrategy.setBeforeSetValidator(new FrequencyValidator()); context.bindValue(SWTObservables.observeText(dayText, SWT.Modify), PojoProperties.value("dayFrequencyForDaily").observe(cronExpression), dayFrequencyStrategy, null); final Label dayLabel = new Label(everyComposite, SWT.NONE); dayLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).create()); dayLabel.setText(Messages.dayLabel); final Button everyWeekDayRadio = new Button(dailyContent, SWT.RADIO); everyWeekDayRadio.setLayoutData(GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).create()); everyWeekDayRadio.setText(Messages.everyWeekDay); final Label filler = new Label(dailyContent, SWT.NONE); filler.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); final IObservableValue hourObservable = PojoProperties.value("atHourInDay").observe(cronExpression); final IObservableValue minuteObservable = PojoProperties.value("atMinuteInDay").observe(cronExpression); final IObservableValue secondObservable = PojoProperties.value("atSecondInDay").observe(cronExpression); createStartTimeComposite(dailyContent, hourObservable, minuteObservable, secondObservable); item.setControl(dailyContent); }
From source file:org.bonitasoft.studio.properties.sections.timer.cron.CronEditor.java
License:Open Source License
protected void createHourlyTab(TabFolder tablFolder) { final TabItem item = new TabItem(tablFolder, SWT.NONE); item.setText(Messages.hourly);/*from ww w .j av a2 s . c o m*/ final Composite hourlyContent = new Composite(tablFolder, SWT.NONE); hourlyContent.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); hourlyContent.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(15, 10).create()); final Button everyRadio = new Button(hourlyContent, SWT.RADIO); everyRadio.setLayoutData(GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).create()); everyRadio.setText(Messages.every); context.bindValue(SWTObservables.observeSelection(everyRadio), PojoProperties.value("useEveryHour").observe(cronExpression)); final Composite everyComposite = new Composite(hourlyContent, SWT.NONE); everyComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); everyComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 0).create()); final Text minuteText = new Text(everyComposite, SWT.BORDER | SWT.SINGLE); minuteText.setLayoutData(GridDataFactory.fillDefaults().hint(70, SWT.DEFAULT).create()); UpdateValueStrategy hourFrequencyStrategy = new UpdateValueStrategy(); hourFrequencyStrategy.setAfterGetValidator(dotValidator); hourFrequencyStrategy.setConverter(StringToNumberConverter.toInteger(true)); hourFrequencyStrategy.setBeforeSetValidator(new FrequencyValidator()); context.bindValue(SWTObservables.observeText(minuteText, SWT.Modify), PojoProperties.value("hourFrequencyForHourly").observe(cronExpression), hourFrequencyStrategy, null); final Label minuteLabel = new Label(everyComposite, SWT.NONE); minuteLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).create()); minuteLabel.setText(Messages.hourLabel); final Button atRadio = new Button(hourlyContent, SWT.RADIO); atRadio.setLayoutData(GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.CENTER).create()); atRadio.setText(Messages.at); final Composite atComposite = new Composite(hourlyContent, SWT.NONE); atComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); atComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(3).margins(0, 0).create()); final Combo hourCombo = new Combo(atComposite, SWT.READ_ONLY | SWT.BORDER); hourCombo.setItems(HOURS_IN_DAY); UpdateValueStrategy hourStrategy = new UpdateValueStrategy(); hourStrategy.setConverter(StringToNumberConverter.toInteger(true)); UpdateValueStrategy hourStrategy2 = new UpdateValueStrategy(); NumberFormat formatter = new DecimalFormat("#00"); hourStrategy2.setConverter(NumberToStringConverter.fromInteger(formatter, true)); context.bindValue(SWTObservables.observeText(hourCombo), PojoProperties.value("atHour").observe(cronExpression), hourStrategy, hourStrategy2); final Combo minuteCombo = new Combo(atComposite, SWT.READ_ONLY | SWT.BORDER); minuteCombo.setItems(MINUTES_IN_HOURS); UpdateValueStrategy minuteStrategy = new UpdateValueStrategy(); minuteStrategy.setConverter(StringToNumberConverter.toInteger(true)); UpdateValueStrategy minuteStrategy2 = new UpdateValueStrategy(); minuteStrategy2.setConverter(NumberToStringConverter.fromInteger(formatter, true)); context.bindValue(SWTObservables.observeText(minuteCombo), PojoProperties.value("atMinute").observe(cronExpression), minuteStrategy, minuteStrategy2); final Combo secondCombo = new Combo(atComposite, SWT.READ_ONLY | SWT.BORDER); secondCombo.setItems(MINUTES_IN_HOURS); final IObservableValue secondObservable = PojoProperties.value("atSecond").observe(cronExpression); UpdateValueStrategy secondStrategy = new UpdateValueStrategy(); secondStrategy.setConverter(StringToNumberConverter.toInteger(true)); UpdateValueStrategy secondStrategy2 = new UpdateValueStrategy(); secondStrategy2.setConverter(NumberToStringConverter.fromInteger(formatter, true)); context.bindValue(SWTObservables.observeText(secondCombo), secondObservable, secondStrategy, secondStrategy2); item.setControl(hourlyContent); }
From source file:org.bonitasoft.studio.scripting.provider.ScriptExpressionEditor.java
License:Open Source License
@Override public void bindExpression(EMFDataBindingContext dataBindingContext, EObject context, Expression inputExpression, ViewerFilter[] filters, ExpressionViewer viewer) { this.inputExpression = inputExpression; IObservableValue nameModelObservable = EMFObservables.observeValue(inputExpression, ExpressionPackage.Literals.EXPRESSION__NAME); IObservableValue interpreterModelObservable = EMFObservables.observeValue(inputExpression, ExpressionPackage.Literals.EXPRESSION__INTERPRETER); // IObservableValue propagationModelObservable = EMFObservables.observeValue(inputExpression, ExpressionPackage.Literals.EXPRESSION__PROPAGATE_VARIABLE_CHANGE) ; UpdateValueStrategy opposite = new UpdateValueStrategy(); opposite.setConverter(new Converter(Boolean.class, Boolean.class) { @Override/* w w w. j av a 2s . c o m*/ public Object convert(Object fromObject) { return !(Boolean) fromObject; } }); UpdateValueStrategy targetToModel = new UpdateValueStrategy(); targetToModel.setAfterConvertValidator(new EmptyInputValidator(Messages.name)); ControlDecorationSupport .create(dataBindingContext.bindValue(SWTObservables.observeText(expressionNameText, SWT.Modify), nameModelObservable, targetToModel, null), SWT.LEFT); dataBindingContext.bindValue(SWTObservables.observeSelection(expressionInterpreterCombo), interpreterModelObservable); nameModelObservable.addValueChangeListener(new IValueChangeListener() { @Override public void handleValueChange(ValueChangeEvent arg0) { fireSelectionChanged(); } }); editor.bindExpression(dataBindingContext, context, inputExpression, filters, viewer); if (inputExpression.getReturnType() != null) { typeCombo.setInput(inputExpression.getReturnType()); } else { typeCombo.setInput(new Object()); } returnTypeModelObservable = EMFObservables.observeValue(inputExpression, ExpressionPackage.Literals.EXPRESSION__RETURN_TYPE); dataBindingContext.bindValue(ViewersObservables.observeSingleSelection(typeCombo), returnTypeModelObservable); dataBindingContext.bindValue(SWTObservables.observeText(typeCombo.getCombo()), returnTypeModelObservable); typeCombo.getCombo().setEnabled(!inputExpression.isReturnTypeFixed()); browseClassesButton.setEnabled(!inputExpression.isReturnTypeFixed()); }
From source file:org.bonitasoft.studio.simulation.properties.contributions.ContigousContribution.java
License:Open Source License
public void createControl(Composite composite, TabbedPropertySheetWidgetFactory widgetFactory, ExtensibleGridPropertySection extensibleGridPropertySection) { composite.setLayout(new FillLayout()); Button button = widgetFactory.createButton(composite, "", SWT.CHECK); ControlDecoration hint = new ControlDecoration(button, SWT.RIGHT | SWT.TOP); hint.setImage(Pics.getImage(PicsConstants.hint)); hint.setDescriptionText(Messages.contigousContributionHint); context = new EMFDataBindingContext(); context.bindValue(SWTObservables.observeSelection(button), EMFEditObservables.observeValue(editingDomain, eObject, SimulationPackage.Literals.SIMULATION_ACTIVITY__CONTIGOUS)); }
From source file:org.bonitasoft.studio.simulation.properties.contributions.ExclusiveOutgoingTransitionContribution.java
License:Open Source License
public void createControl(Composite composite, TabbedPropertySheetWidgetFactory widgetFactory, ExtensibleGridPropertySection extensibleGridPropertySection) { composite.setLayout(new FillLayout()); Button button = widgetFactory.createButton(composite, "", SWT.CHECK); if (eObject instanceof XORGateway) { button.setEnabled(false);/*www . j ava 2 s . co m*/ } ControlDecoration hint = new ControlDecoration(button, SWT.RIGHT | SWT.TOP); hint.setImage(Pics.getImage(PicsConstants.hint)); hint.setDescriptionText(Messages.exclusiveOutgoingContributionHint); context = new EMFDataBindingContext(); context.bindValue(SWTObservables.observeSelection(button), EMFEditObservables.observeValue(editingDomain, eObject, SimulationPackage.Literals.SIMULATION_ACTIVITY__EXCLUSIVE_OUTGOING_TRANSITION)); }
From source file:org.bonitasoft.studio.simulation.properties.contributions.LoopContribution.java
License:Open Source License
@Override public void createControl(Composite composite, TabbedPropertySheetWidgetFactory widgetFactory, ExtensibleGridPropertySection extensibleGridPropertySection) { SimulationTransition transition;// w w w .jav a 2s.c om if (((Activity) eObject).getLoopTransition() == null) { transition = SimulationFactory.eINSTANCE.createSimulationTransition(); editingDomain.getCommandStack().execute(new SetCommand(editingDomain, eObject, SimulationPackage.Literals.SIMULATION_ACTIVITY__LOOP_TRANSITION, transition)); } else { transition = ((Activity) eObject).getLoopTransition(); } composite.setLayout(new GridLayout(2, false)); Composite radioComposite = widgetFactory.createComposite(composite); radioComposite.setLayout(new FillLayout()); radioComposite.setLayoutData(GridDataFactory.fillDefaults().create()); Button expressionRadio = widgetFactory.createButton(radioComposite, "Expression", SWT.RADIO); Button probaRadio = widgetFactory.createButton(radioComposite, "Probability", SWT.RADIO); final Composite stackComposite = widgetFactory.createComposite(composite); stackComposite.setLayoutData(GridDataFactory.fillDefaults().hint(300, SWT.DEFAULT).create()); final StackLayout stackLayout = new StackLayout(); stackComposite.setLayout(stackLayout); final Composite probaComposite = widgetFactory.createComposite(stackComposite); FillLayout layout = new FillLayout(); layout.marginWidth = 10; probaComposite.setLayout(layout); Text probaText = widgetFactory.createText(probaComposite, "", SWT.BORDER); ControlDecoration controlDecoration = new ControlDecoration(probaText, SWT.LEFT | SWT.TOP); FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR); controlDecoration.setImage(fieldDecoration.getImage()); controlDecoration.setDescriptionText(Messages.mustBeAPercentage); final Composite expressionComposite = widgetFactory.createComposite(stackComposite); FillLayout layout2 = new FillLayout(); layout2.marginWidth = 10; expressionComposite.setLayout(layout2); ExpressionViewer expressionText = new ExpressionViewer(expressionComposite, SWT.BORDER, widgetFactory, editingDomain, SimulationPackage.Literals.SIMULATION_TRANSITION__EXPRESSION); Expression selection = transition.getExpression(); if (selection == null) { selection = ExpressionFactory.eINSTANCE.createExpression(); editingDomain.getCommandStack().execute(SetCommand.create(editingDomain, transition, SimulationPackage.Literals.SIMULATION_TRANSITION__EXPRESSION, selection)); } context.bindValue(ViewerProperties.singleSelection().observe(expressionText), EMFEditProperties.value(editingDomain, SimulationPackage.Literals.SIMULATION_TRANSITION__EXPRESSION) .observe(eObject)); expressionText.setInput(eObject); boolean useExpression = transition.isUseExpression(); if (useExpression) { stackLayout.topControl = expressionComposite; } else { stackLayout.topControl = probaComposite; } expressionRadio.setSelection(useExpression); probaRadio.setSelection(!useExpression); expressionRadio.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (((Button) e.getSource()).getSelection()) { stackLayout.topControl = expressionComposite; } else { stackLayout.topControl = probaComposite; } stackComposite.layout(); } }); context = new EMFDataBindingContext(); context.bindValue(SWTObservables.observeSelection(expressionRadio), EMFEditObservables.observeValue( editingDomain, transition, SimulationPackage.Literals.SIMULATION_TRANSITION__USE_EXPRESSION)); context.bindValue(SWTObservables.observeText(probaText, SWT.Modify), EMFEditObservables.observeValue(editingDomain, transition, SimulationPackage.Literals.SIMULATION_TRANSITION__PROBABILITY), new UpdateValueStrategy() .setConverter( StringToNumberConverter.toDouble(BonitaNumberFormat.getPercentInstance(), false)) .setAfterGetValidator(new WrappingValidator(controlDecoration, new StringToDoubleValidator(StringToNumberConverter .toDouble(BonitaNumberFormat.getPercentInstance(), false)))), new UpdateValueStrategy().setConverter( NumberToStringConverter.fromDouble(BonitaNumberFormat.getPercentInstance(), false))); }
From source file:org.bonitasoft.studio.simulation.properties.contributions.TransitionDataContribution.java
License:Open Source License
@Override public void createControl(Composite composite, TabbedPropertySheetWidgetFactory widgetFactory, ExtensibleGridPropertySection extensibleGridPropertySection) { composite.setLayout(new GridLayout(2, false)); Composite radioComposite = widgetFactory.createComposite(composite); radioComposite.setLayout(new FillLayout()); radioComposite.setLayoutData(GridDataFactory.fillDefaults().create()); Button expressionRadio = widgetFactory.createButton(radioComposite, "Expression", SWT.RADIO); Button probaRadio = widgetFactory.createButton(radioComposite, "Probability", SWT.RADIO); final Composite stackComposite = widgetFactory.createComposite(composite); stackComposite.setLayoutData(GridDataFactory.fillDefaults().create()); final StackLayout stackLayout = new StackLayout(); stackComposite.setLayout(stackLayout); final Composite probaComposite = widgetFactory.createComposite(stackComposite); probaComposite.setLayoutData(GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).create()); GridLayout layout = new GridLayout(1, false); layout.marginWidth = 10;/* www .j av a 2 s. c o m*/ probaComposite.setLayout(layout); Text probaText = widgetFactory.createText(probaComposite, "", SWT.BORDER); probaText.setLayoutData( GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).hint(50, SWT.DEFAULT).create()); ControlDecoration controlDecoration = new ControlDecoration(probaText, SWT.LEFT | SWT.TOP); FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR); controlDecoration.setImage(fieldDecoration.getImage()); controlDecoration.setDescriptionText(Messages.mustBeAPercentage); final Composite expressionComposite = widgetFactory.createComposite(stackComposite); GridLayout layout2 = new GridLayout(2, false); layout2.marginWidth = 10; expressionComposite.setLayout(layout2); ExpressionViewer expressionText = new ExpressionViewer(expressionComposite, SWT.BORDER, widgetFactory, editingDomain, SimulationPackage.Literals.SIMULATION_TRANSITION__EXPRESSION); expressionText.getControl().setLayoutData( GridDataFactory.fillDefaults().align(SWT.FILL, SWT.CENTER).hint(250, SWT.DEFAULT).create()); expressionText.addFilter(new AvailableExpressionTypeFilter( new String[] { ExpressionConstants.VARIABLE_TYPE, ExpressionConstants.GROOVY, ExpressionConstants.CONSTANT_TYPE, ExpressionConstants.PARAMETER_TYPE })); Expression selection = ((SimulationTransition) eObject).getExpression(); if (selection == null) { selection = ExpressionFactory.eINSTANCE.createExpression(); editingDomain.getCommandStack().execute(SetCommand.create(editingDomain, eObject, SimulationPackage.Literals.SIMULATION_TRANSITION__EXPRESSION, selection)); } if (context != null) { context.dispose(); } context = new EMFDataBindingContext(); context.bindValue(ViewerProperties.singleSelection().observe(expressionText), EMFEditProperties.value(editingDomain, SimulationPackage.Literals.SIMULATION_TRANSITION__EXPRESSION) .observe(eObject)); expressionText.setInput(eObject); Button createDataButton = new Button(expressionComposite, SWT.FLAT); createDataButton.setText(Messages.createSimulationData); createDataButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { AddSimulationDataWizard wiz = new AddSimulationDataWizard(ModelHelper.getParentProcess(eObject), editingDomain); WizardDialog dialog = new WizardDialog(Display.getDefault().getActiveShell(), wiz); if (dialog.open() == WizardDialog.OK) { // expressionText.reset() ; // expressionText.setText(GroovyUtil.GROOVY_PREFIX + wiz.getCreatedData().getName() + GroovyUtil.GROOVY_SUFFIX); } } }); boolean useExpression = ((SimulationTransition) eObject).isUseExpression(); if (useExpression) { stackLayout.topControl = expressionComposite; } else { stackLayout.topControl = probaComposite; } expressionRadio.setSelection(useExpression); probaRadio.setSelection(!useExpression); expressionRadio.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if (((Button) e.getSource()).getSelection()) { stackLayout.topControl = expressionComposite; } else { stackLayout.topControl = probaComposite; } stackComposite.layout(); } }); context = new EMFDataBindingContext(); context.bindValue(SWTObservables.observeSelection(expressionRadio), EMFEditObservables.observeValue( editingDomain, eObject, SimulationPackage.Literals.SIMULATION_TRANSITION__USE_EXPRESSION)); context.bindValue(SWTObservables.observeText(probaText, SWT.Modify), EMFEditObservables.observeValue(editingDomain, eObject, SimulationPackage.Literals.SIMULATION_TRANSITION__PROBABILITY), new UpdateValueStrategy() .setConverter( StringToNumberConverter.toDouble(BonitaNumberFormat.getPercentInstance(), false)) .setAfterGetValidator(new WrappingValidator(controlDecoration, new StringToDoubleValidator(StringToNumberConverter .toDouble(BonitaNumberFormat.getPercentInstance(), false)))), new UpdateValueStrategy().setConverter( NumberToStringConverter.fromDouble(BonitaNumberFormat.getPercentInstance(), false))); if (eObject instanceof Connection) { if (((Connection) eObject).getSource() instanceof CatchLinkEvent) { radioComposite.setEnabled(false); probaText.setEnabled(false); } } }
From source file:org.bonitasoft.studio.simulation.wizards.AddResourceAssignmentWizardPage.java
License:Open Source License
public void createControl(Composite parent) { context = new DataBindingContext(); Composite mainComposite = new Composite(parent, SWT.NONE); mainComposite.setLayout(new GridLayout(3, false)); Label resourceIDLabel = new Label(mainComposite, SWT.NONE); resourceIDLabel.setText(Messages.resourceName); combo = new Combo(mainComposite, SWT.READ_ONLY); for (IRepositoryFileStore artifact : resourceStore.getChildren()) { combo.add(artifact.getDisplayName()); }//from www. ja va 2s .c o m if (combo.getItemCount() > 0) { combo.select(0); } if (resourceUsage != null && resourceUsage.getResourceID() != null) { combo.setText(resourceUsage.getResourceID()); } combo.setLayoutData(GridDataFactory.swtDefaults().hint(150, SWT.DEFAULT).create()); createResourceButton = new Button(mainComposite, SWT.FLAT); createResourceButton.setText(Messages.create); createResourceButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { EditSimulationResourceWizard wiz = new EditSimulationResourceWizard(); if (new WizardDialog(Display.getCurrent().getActiveShell(), wiz).open() == WizardDialog.OK) { combo.removeAll(); for (IRepositoryFileStore artifact : resourceStore.getChildren()) { combo.add(artifact.getDisplayName()); } combo.setText(wiz.getArtifact().getDisplayName()); getContainer().updateButtons(); } } }); Label quantityLabel = new Label(mainComposite, SWT.NONE); quantityLabel.setText(Messages.quantity); quantityText = new Text(mainComposite, SWT.BORDER); quantityText.setLayoutData(GridDataFactory.swtDefaults().hint(130, SWT.DEFAULT).span(2, 1).create()); if (resourceUsage != null) { quantityText.setText(String.valueOf(resourceUsage.getQuantity())); } else { quantityText.setText("1");//$NON-NLS-1$ } Label durationLabel = new Label(mainComposite, SWT.NONE); durationLabel.setText(Messages.duration); Composite radioComposite = new Composite(mainComposite, SWT.NONE); radioComposite .setLayoutData(GridDataFactory.swtDefaults().hint(SWT.DEFAULT, SWT.DEFAULT).span(2, 1).create()); radioComposite.setLayout(new GridLayout(2, false)); useActivity = new Button(radioComposite, SWT.RADIO); useActivity.setText(Messages.AddResourceAssignmentWizardPage_useActivity); Button useCustom = new Button(radioComposite, SWT.RADIO); useCustom.setText(Messages.AddResourceAssignmentWizardPage_useCustom); if (resourceUsage != null) { useActivity.setSelection(resourceUsage.isUseActivityDuration()); useCustom.setSelection(!resourceUsage.isUseActivityDuration()); } else { useActivity.setSelection(true); useCustom.setSelection(false); } durationWidget = new DurationComposite(mainComposite, false, false, true, true, true, true, null); durationWidget.setLayoutData(GridDataFactory.fillDefaults().span(3, 1).create()); if (activity != null) { durationWidget.setMaxDuration(activity.getExecutionTime()); if (resourceUsage != null) { durationWidget.setDuration(resourceUsage.getDuration()); } else { durationWidget.setDuration(activity.getExecutionTime()); } } context.bindValue(SWTObservables.observeVisible(durationWidget), SWTObservables.observeSelection(useCustom)); setControl(mainComposite); getContainer().updateButtons(); }
From source file:org.bonitasoft.studio.simulation.wizards.AddSimulationDataWizardPage.java
License:Open Source License
@Override public void createControl(Composite parent) { final Composite composite = new Composite(parent, SWT.NONE); context = new DataBindingContext(); WizardPageSupport.create(this, context); composite.setLayout(new GridLayout(2, false)); createNameAndDescription(composite); createTypeCombo(composite);//from w ww .jav a 2 s.c o m configStackComposite = new Composite(composite, SWT.NONE); sLayout = new StackLayout(); configStackComposite.setLayout(sLayout); configStackComposite.setLayoutData( GridDataFactory.fillDefaults().grab(true, true).span(2, 1).hint(SWT.DEFAULT, 200).create()); Composite booleanComposite = createBooleanConfigurationComposite(configStackComposite); configCompositeMap.put(SimulationPackage.eINSTANCE.getSimulationBoolean(), booleanComposite); Composite literalsComposite = createLiteralsConfigurationComposite(configStackComposite); configCompositeMap.put(SimulationPackage.eINSTANCE.getSimulationLiteralData(), literalsComposite); Composite numberComposite = createNumberConfigurationComposite(configStackComposite); configCompositeMap.put(SimulationPackage.eINSTANCE.getSimulationNumberData(), numberComposite); context.bindValue(SWTObservables.observeVisible(configStackComposite), SWTObservables.observeSelection(isExpressionBased), null, new UpdateValueStrategy().setConverter( new org.eclipse.core.databinding.conversion.Converter(Boolean.class, Boolean.class) { @Override public Object convert(Object fromObject) { return !((Boolean) fromObject); } })); /* So like that it forces call to isPageCOmplete after that the model is updated. * what would be even better it to implement validator on each related bindings instead of doing the work in isPageComplete * */ WizardPageSupport.create(this, context); changeDataConfigurationComposite( (EClass) ((IStructuredSelection) datatypeCombo.getSelection()).getFirstElement()); setControl(composite); }