List of usage examples for org.eclipse.jface.databinding.swt WidgetProperties visible
public static IWidgetValueProperty visible()
From source file:ch.acanda.eclipse.pmd.wizard.AddRuleSetConfigurationWizardPage.java
License:Open Source License
private DataBindingContext initDataBindings() { final DataBindingContext bindingContext = new DataBindingContext(); ////from w w w . ja va2s.c o m final IObservableValue locationObserveText = SWTObservables.observeDelayedValue(200, SWTObservables.observeText(location, SWT.Modify)); final IObservableValue locationObserveValue = BeansObservables.observeValue(controller.getModel(), "location"); bindingContext.bindValue(locationObserveText, locationObserveValue, null, null); // final ObservableListContentProvider rulesContentProvider = new ObservableListContentProvider(); final IObservableMap rulesObserveMap = PojoObservables.observeMap(rulesContentProvider.getKnownElements(), Rule.class, "name"); tableViewer.setLabelProvider(new ObservableMapLabelProvider(rulesObserveMap)); tableViewer.setContentProvider(rulesContentProvider); // final IObservableList rulesObserveList = BeansObservables.observeList(Realm.getDefault(), controller.getModel(), "rules"); tableViewer.setInput(rulesObserveList); // final IObservableValue nameObserveTextObserveWidget = SWTObservables.observeDelayedValue(100, SWTObservables.observeText(name, SWT.Modify)); final IObservableValue controllergetModelNameObserveValue = BeansObservables .observeValue(controller.getModel(), "name"); bindingContext.bindValue(nameObserveTextObserveWidget, controllergetModelNameObserveValue, null, null); // final IObservableValue observeVisibleBrowseObserveWidget = WidgetProperties.visible().observe(browse); final IObservableValue browseEnabledControllergetModelObserveValue = BeanProperties.value("browseEnabled") .observe(controller.getModel()); bindingContext.bindValue(observeVisibleBrowseObserveWidget, browseEnabledControllergetModelObserveValue, null, null); // return bindingContext; }
From source file:org.goko.common.bindings.AbstractController.java
License:Open Source License
/** * Enables/disable the source when the property is respectively true/false * @param source the UI object//from w w w . jav a 2s .c o m * @param property the name of the property * @throws GkException GkException */ public void addVisibleBinding(Widget source, String property) throws GkException { verifyGetter(dataModel, property); verifySetter(dataModel, property); IObservableValue target = WidgetProperties.visible().observe(source); IObservableValue model = BeansObservables.observeValue(dataModel, property); Binding binding = bindingContext.bindValue(target, model); bindings.add(binding); }
From source file:org.jboss.tools.openshift.internal.ui.server.ServerSettingsWizardPage.java
License:Open Source License
private void createInfoControls(Composite container, ServerSettingsWizardPageModel model, DataBindingContext dbc) {//from w w w.java2s . c om Composite composite = new Composite(container, SWT.NONE); GridDataFactory.fillDefaults().span(4, 1).applyTo(composite); GridLayoutFactory.fillDefaults().numColumns(2).applyTo(composite); ValueBindingBuilder.bind(WidgetProperties.visible().observe(composite)) .to(BeanProperties.value(ServerSettingsWizardPageModel.PROPERTY_OC_BINARY_STATUS).observe(model)) .converting(new Converter(IStatus.class, Boolean.class) { @Override public Object convert(Object fromObject) { return !((IStatus) fromObject).isOK(); } }).in(dbc); Label label = new Label(composite, SWT.NONE); ValueBindingBuilder.bind(WidgetProperties.image().observe(label)) .to(BeanProperties.value(ServerSettingsWizardPageModel.PROPERTY_OC_BINARY_STATUS).observe(model)) .converting(new Converter(IStatus.class, Image.class) { @Override public Object convert(Object fromObject) { switch (((IStatus) fromObject).getSeverity()) { case IStatus.WARNING: return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING); case IStatus.ERROR: return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR); } return null; } }).in(dbc); Link link = new Link(composite, SWT.WRAP); ValueBindingBuilder.bind(WidgetProperties.text().observe(link)) .to(BeanProperties.value(ServerSettingsWizardPageModel.PROPERTY_OC_BINARY_STATUS).observe(model)) .converting(new Converter(IStatus.class, String.class) { @Override public Object convert(Object fromObject) { return ((IStatus) fromObject).getMessage(); } }).in(dbc); link.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { if ("download".equals(e.text)) { new BrowserUtility().checkedCreateExternalBrowser(DOWNLOAD_INSTRUCTIONS_URL, OpenShiftUIActivator.PLUGIN_ID, OpenShiftUIActivator.getDefault().getLog()); } else { int rc = PreferencesUtil.createPreferenceDialogOn(getShell(), OPEN_SHIFT_PREFERENCE_PAGE_ID, new String[] { OPEN_SHIFT_PREFERENCE_PAGE_ID }, null).open(); if (rc == Dialog.OK) { new Job("Checking oc binary") { @Override protected IStatus run(IProgressMonitor monitor) { OCBinary ocBinary = OCBinary.getInstance(); boolean valid = ocBinary.isCompatibleForPublishing(monitor); ServerSettingsWizardPage.this.model .setOCBinaryStatus(getOCBinaryStatus(valid, ocBinary.getLocation())); return Status.OK_STATUS; } }.schedule(); } } } }); GridDataFactory.fillDefaults().hint(600, SWT.DEFAULT).applyTo(link); MultiValidator validator = new MultiValidator() { @Override protected IStatus validate() { IObservableValue<IStatus> observable = BeanProperties .value(ServerSettingsWizardPageModel.PROPERTY_OC_BINARY_STATUS).observe(model); Status status = (Status) observable.getValue(); switch (status.getSeverity()) { case IStatus.ERROR: return OpenShiftUIActivator.statusFactory() .errorStatus(OpenShiftUIMessages.OCBinaryErrorMessage); case IStatus.WARNING: return OpenShiftUIActivator.statusFactory() .warningStatus(OpenShiftUIMessages.OCBinaryWarningMessage); } return status; } }; dbc.addValidationStatusProvider(validator); }
From source file:org.jboss.tools.openshift.internal.ui.wizard.newapp.ApplicationSourceListPage.java
License:Open Source License
private void createDetailsGroup(Composite parent, DataBindingContext dbc) { // details// w w w . j a va2s.c o m Group detailsGroup = new Group(parent, SWT.NONE); detailsGroup.setText("Details"); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, false).span(3, 1).hint(SWT.DEFAULT, 106) .applyTo(detailsGroup); GridLayoutFactory.fillDefaults().margins(10, 6).spacing(2, 2) //TODO fix margins .applyTo(detailsGroup); Composite detailsContainer = new Composite(detailsGroup, SWT.NONE); GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).applyTo(detailsContainer); new ApplicationSourceDetailViews( BeanProperties.value(IApplicationSourceListPageModel.PROPERTY_SELECTED_APP_SOURCE).observe(model), null, detailsContainer, dbc).createControls(); // detail resources button Button btnDetails = new Button(detailsGroup, SWT.NONE); btnDetails.setText("Defined Resources..."); GridDataFactory.fillDefaults().align(SWT.RIGHT, SWT.CENTER).applyTo(btnDetails); IObservableValue selectedTemplate = BeanProperties .value(IApplicationSourceListPageModel.PROPERTY_SELECTED_APP_SOURCE).observe(model); ValueBindingBuilder.bind(WidgetProperties.visible().observe(btnDetails)).notUpdatingParticipant() .to(selectedTemplate).converting(new Converter(Object.class, Boolean.class) { @Override public Object convert(Object fromObject) { return fromObject != null && ResourceKind.TEMPLATE .equals(((IApplicationSource) fromObject).getSource().getKind()); } }).in(dbc); btnDetails.addSelectionListener(onDefinedResourcesClicked()); }
From source file:uk.ac.stfc.isis.ibex.ui.banner.widgets.Indicator.java
License:Open Source License
private void bind(IndicatorModel model) { DataBindingContext bindingContext = new DataBindingContext(); bindingContext.bindValue(WidgetProperties.text().observe(text), BeanProperties.value("value").observe(model.text())); bindingContext.bindValue(WidgetProperties.foreground().observe(text), BeanProperties.value("value").observe(model.color())); bindingContext.bindValue(WidgetProperties.visible().observe(text), BeanProperties.value("value").observe(model.availability())); }
From source file:uk.ac.stfc.isis.ibex.ui.blocks.groups.Group.java
License:Open Source License
/** * Provides the display of groups./*from ww w .java 2 s . co m*/ * * @param parent a widget which will be the parent of the new instance * @param style the style of widget to construct * @param group the group to be displayed * @param panel The panel that shows the groups and blocks. */ public Group(Composite parent, int style, DisplayGroup group, GroupsPanel panel) { super(parent, style | SWT.BORDER); // Add the blocks to the list if they are visible, or if // showHiddenBlocks is true List<DisplayBlock> blocksList = new ArrayList<>(); for (DisplayBlock block : group.blocks()) { if (block.getIsVisible() || panel.showHiddenBlocks()) { blocksList.add(block); } } // Calculate number of columns we need, each column holding one block // with a name and value int numberOfColumns = (blocksList.size() - 1) / NUMBER_OF_ROWS + 1; // For each block we need three columns in the grid layout, one for // name, one for value, one for // run control status, and for every column but the last we need a // divider label column GridLayout layout = new GridLayout(NUMBER_OF_FIELDS * numberOfColumns + (numberOfColumns - 1), false); layout.verticalSpacing = 5; this.setLayout(layout); this.setBackground(WHITE); // In the first column put the title in title = labelMaker(this, SWT.NONE, group.name(), "", null); Font titleFont = getEditedLabelFont(title, 10, SWT.BOLD); title.setFont(titleFont); // For the title row, fill with blanks for (int i = 0; i < (NUMBER_OF_FIELDS + 1) * numberOfColumns - 2; i++) { labelMaker(this, SWT.NONE, "", "", titleFont); } DataBindingContext bindingContext = new DataBindingContext(); // Loop over the rows and columns. The GridLayout is filled with labels // across rows first, then moving on to // the next column. So blank labels need to be inserted so that columns // are always filled. for (int i = 0; i < NUMBER_OF_ROWS; i++) { for (int j = 0; j < numberOfColumns; j++) { int position = i + j * NUMBER_OF_ROWS; if (position >= blocksList.size()) { // put blank labels in these name and value columns for (int k = 0; k < NUMBER_OF_FIELDS; k++) { labelMaker(this, SWT.NONE, "", "", null); } break; } DisplayBlock currentBlock = blocksList.get(position); GroupsMenu fullMenu = new GroupsMenu(panel, new BlocksMenu(currentBlock)); Label blockName = labelMaker(this, SWT.NONE, currentBlock.getName() + ": ", currentBlock.getDescription(), null); blockName.setMenu(fullMenu.get()); blockName.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1)); // additional container to hold value label to draw a border around it Composite valueContainer = new Composite(this, SWT.CENTER); GridLayout valueContainerLayout = new GridLayout(1, false); valueContainerLayout.marginWidth = 2; valueContainerLayout.marginHeight = 2; valueContainerLayout.verticalSpacing = 0; valueContainerLayout.horizontalSpacing = 0; valueContainer.setLayout(valueContainerLayout); GridData gdValueContainer = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1); gdValueContainer.widthHint = 79; gdValueContainer.heightHint = 19; valueContainer.setLayoutData(gdValueContainer); Label blockValue = labelMaker(valueContainer, SWT.RIGHT, currentBlock.getValue(), currentBlock.getDescription(), null); blockValue.setMenu(fullMenu.get()); GridData gdValue = new GridData(SWT.CENTER, SWT.NONE, false, false, 1, 1); gdValue.widthHint = 75; blockValue.setLayoutData(gdValue); blockValue.setVisible(true); valueContainer.pack(); Label blockStatus = labelMaker(this, SWT.CENTER, "", "Run Control Status", null); FontDescriptor boldDescriptor = FontDescriptor.createFrom(blockStatus.getFont()).setStyle(SWT.BOLD); Font boldFont = boldDescriptor.createFont(blockStatus.getDisplay()); blockStatus.setFont(boldFont); GridData gdStatus = new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1); gdStatus.widthHint = 17; blockStatus.setLayoutData(gdStatus); if (j < numberOfColumns - 1) { // insert divider label labelMaker(this, SWT.NONE, " | ", "", null); } bindingContext.bindValue(WidgetProperties.text().observe(blockValue), BeanProperties.value("value").observe(currentBlock)); bindingContext.bindValue(WidgetProperties.visible().observe(blockStatus), BeanProperties.value("enabled").observe(currentBlock)); UpdateValueStrategy symbolStrategy = new UpdateValueStrategy(); symbolStrategy.setConverter(new RunControlSymbolConverter()); bindingContext.bindValue(WidgetProperties.text().observe(blockStatus), BeanProperties.value("runcontrolState").observe(currentBlock), null, symbolStrategy); UpdateValueStrategy fgColourStrategy = new UpdateValueStrategy(); fgColourStrategy.setConverter(new RunControlForegroundColourConverter()); bindingContext.bindValue(WidgetProperties.foreground().observe(blockStatus), BeanProperties.value("runcontrolState").observe(currentBlock), null, fgColourStrategy); UpdateValueStrategy bgColourStrategy = new UpdateValueStrategy(); bgColourStrategy.setConverter(new RunControlBackgroundColourConverter()); bindingContext.bindValue(WidgetProperties.background().observe(blockStatus), BeanProperties.value("runcontrolState").observe(currentBlock), null, bgColourStrategy); UpdateValueStrategy borderStrategy = new UpdateValueStrategy(); borderStrategy.setConverter(new BlockStatusBorderColourConverter()); bindingContext.bindValue(WidgetProperties.background().observe(valueContainer), BeanProperties.value("blockState").observe(currentBlock), null, borderStrategy); } } }
From source file:uk.ac.stfc.isis.ibex.ui.configserver.editing.macros.IocMacroDetailsPanel.java
License:Open Source License
/** * Called when changing IOCs. Should reset everything such as name, * selection etc.// w w w . j a v a 2 s .co m * * @param macros * The macros to display of the current IOC * @param canEdit * If the IOC is editable */ public void setMacros(Collection<Macro> macros, boolean canEdit) { this.macro = null; DataBindingContext bindingContext = new DataBindingContext(); valueValidator = new MacroValueValidator(macro, macroValueErrorLabel); valueStrategy.setBeforeSetValidator(valueValidator); setValueEditable(false); setEnabled(canEdit); bindingContext.bindValue(WidgetProperties.visible().observe(errorIconLabel), BeanProperties.value(MacroValueValidator.SHOW_WARNING_ICON).observe(valueValidator)); displayMacrosTable.setRows(macros); displayMacrosTable.deselectAll(); name.setText(""); }
From source file:uk.ac.stfc.isis.ibex.ui.configserver.editing.summary.SummaryPanel.java
License:Open Source License
private void setBindings() { DataBindingContext bindingContext = new DataBindingContext(); UpdateValueStrategy descValidator = new UpdateValueStrategy(); // Set validator if not saving a new config if (!config.getIsNew()) { BlockServerNameValidator configDescriptionRules = Configurations.getInstance() .variables().configDescriptionRules.getValue(); descValidator.setBeforeSetValidator( new SummaryDescriptionValidator(messageDisplayer, configDescriptionRules)); }/*from w w w . j a va 2s .co m*/ UpdateValueStrategy notConverter = new UpdateValueStrategy() { @Override public Object convert(Object value) { return !(Boolean) value; } }; bindingContext.bindValue(WidgetProperties.enabled().observe(txtName), BeanProperties.value("isNew").observe(config)); bindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(txtName), BeanProperties.value("name").observe(config)); bindingContext.bindValue(WidgetProperties.text(SWT.Modify).observe(txtDescription), BeanProperties.value("description").observe(config), descValidator, null); bindingContext.bindValue(WidgetProperties.selection().observe(cmboSynoptic.getCombo()), BeanProperties.value("synoptic").observe(config)); bindingContext.bindValue(WidgetProperties.visible().observe(lblDateCreated), BeanProperties.value("isNew").observe(config), null, notConverter); bindingContext.bindValue(WidgetProperties.visible().observe(lblDateModified), BeanProperties.value("isNew").observe(config), null, notConverter); bindingContext.bindValue(WidgetProperties.text().observe(lblDateCreatedField), BeanProperties.value("dateCreated").observe(config)); bindingContext.bindValue(WidgetProperties.text().observe(lblDateModifiedField), BeanProperties.value("dateModified").observe(config)); bindingContext.bindValue(WidgetProperties.visible().observe(lblSynoptic), BeanProperties.value("isComponent").observe(config), null, notConverter); bindingContext.bindValue(WidgetProperties.visible().observe(cmboSynoptic.getCombo()), BeanProperties.value("isComponent").observe(config), null, notConverter); }
From source file:uk.ac.stfc.isis.ibex.ui.dashboard.widgets.Banner.java
License:Open Source License
private void bind(BannerModel model) { DataBindingContext bindingContext = new DataBindingContext(); bindingContext.bindValue(WidgetProperties.text().observe(bannerText), BeanProperties.value("value").observe(model.bannerText())); bindingContext.bindValue(WidgetProperties.background().observe(this), BeanProperties.value("value").observe(model.background())); bindingContext.bindValue(WidgetProperties.text().observe(runNumber), BeanProperties.value("value").observe(model.runNumber())); bindingContext.bindValue(WidgetProperties.text().observe(shutter), BeanProperties.value("value").observe(model.shutter())); bindingContext.bindValue(WidgetProperties.visible().observe(simMode), BeanProperties.value("value").observe(model.daeSimMode())); }
From source file:uk.ac.stfc.isis.ibex.ui.synoptic.editor.pv.PvDetailView.java
License:Open Source License
private void bind(PvDetailViewModel model) { UpdateValueStrategy notConverter = new UpdateValueStrategy() { @Override//from w ww. j a v a 2s. c om public Object convert(Object value) { return !(Boolean) value; } }; DataBindingContext bindingContext = new DataBindingContext(); bindingContext.bindValue(WidgetProperties.visible().observe(selectionComposite), BeanProperties.value("selectionVisible").observe(model)); bindingContext.bindValue(WidgetProperties.visible().observe(noSelectionComposite), BeanProperties.value("selectionVisible").observe(model), null, notConverter); bindingContext.bindValue(SWTObservables.observeText(txtName, SWT.Modify), BeanProperties.value("pvName").observe(model)); bindingContext.bindValue(SWTObservables.observeText(txtAddress, SWT.Modify), BeanProperties.value("pvAddress").observe(model)); bindingContext.bindValue(ViewersObservables.observeSingleSelection(cmboMode), BeanProperties.value("pvMode").observe(model)); }