List of usage examples for org.eclipse.jface.databinding.swt SWTObservables getRealm
@Deprecated public static Realm getRealm(final Display display)
From source file:org.gumtree.gumnix.sics.batch.ui.views.SicsVariableView.java
License:Open Source License
@Override public void createPartControl(Composite parent, SicsVariableCommand command) { GridLayoutFactory.fillDefaults().margins(0, 0).spacing(10, SWT.DEFAULT).numColumns(2).applyTo(parent); /********************************************************************* * Sics variable selection/*w w w. j av a 2s. c om*/ *********************************************************************/ final String[] sicsVariables = SicsBatchUIUtils.getSicsVariables(); comboViewer = new ComboViewer(parent, SWT.READ_ONLY); comboViewer.setContentProvider(new ArrayContentProvider()); comboViewer.setLabelProvider(new LabelProvider()); comboViewer.setInput(sicsVariables); comboViewer.setSorter(new ViewerSorter()); comboViewer.getCombo().setVisibleItemCount(20); GridDataFactory.swtDefaults().hint(WIDTH_COMBO, SWT.DEFAULT).indent(0, 2).applyTo(comboViewer.getCombo()); /********************************************************************* * Argument *********************************************************************/ text = getToolkit().createText(parent, "", SWT.BORDER); text.setToolTipText("Enter sics variable argument"); GridDataFactory.fillDefaults().indent(0, 2).grab(true, false).applyTo(text); // Check empty field final ControlDecoration controlDec = new ControlDecoration(text, SWT.LEFT | SWT.BOTTOM); final FieldDecoration fieldDec = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_ERROR); text.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if ((text.getText() == null) || text.getText().length() == 0) { controlDec.setImage(fieldDec.getImage()); controlDec.setDescriptionText("SICS variable argument is empty"); controlDec.show(); } else { controlDec.hide(); } } }); /********************************************************************* * Data binding *********************************************************************/ Realm.runWithDefault(SWTObservables.getRealm(Display.getDefault()), new Runnable() { public void run() { bindingContext = new DataBindingContext(); bindingContext.bindValue(SWTObservables.observeSelection(comboViewer.getCombo()), BeansObservables.observeValue(getCommand(), "sicsVariable"), new UpdateValueStrategy(), new UpdateValueStrategy()); bindingContext.bindValue(SWTObservables.observeText(text, SWT.Modify), BeansObservables.observeValue(getCommand(), "value"), new UpdateValueStrategy(), new UpdateValueStrategy()); // Set Default selection (only works after the binding is set) if (getCommand().getSicsVariable() == null) { if (comboViewer.getCombo().getItemCount() > 0) { comboViewer.setSelection(new StructuredSelection( comboViewer.getCombo().getItem(comboViewer.getCombo().getItemCount() - 1))); } } } }); }
From source file:org.gumtree.gumnix.sics.internal.ui.batch.ValidationDialog.java
License:Open Source License
private void createConnnectionConfigArea(Composite parent) { parent.setLayout(new GridLayout(2, false)); Label label = new Label(parent, SWT.NONE); label.setText("Host: "); hostText = new Text(parent, SWT.SINGLE | SWT.BORDER); hostText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); // getBindingContext().bind(hostText, new Property(getConnectionContext(), "host"), null); label = new Label(parent, SWT.NONE); label.setText("Port: "); portText = new Text(parent, SWT.SINGLE | SWT.BORDER); portText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); // getBindingContext().bind(portText, new Property(getConnectionContext(), "port"), null); label = new Label(parent, SWT.NONE); label.setText("Login: "); loginText = new Text(parent, SWT.SINGLE | SWT.BORDER); loginText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); // getBindingContext().bind(loginText, new Property(getConnectionContext(), "login"), null); Label passwordLabel = new Label(parent, SWT.NONE); passwordLabel.setText("Password: "); passwordText = new Text(parent, SWT.SINGLE | SWT.BORDER | SWT.PASSWORD); passwordText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); // getBindingContext().bind(passwordText, new Property(getConnectionContext(), "password"), null); // Eclipse 3.3 databinding Realm.runWithDefault(SWTObservables.getRealm(PlatformUI.getWorkbench().getDisplay()), new Runnable() { public void run() { DataBindingContext bindingContext = new DataBindingContext(); bindingContext.bindValue(SWTObservables.observeText(hostText, SWT.Modify), BeansObservables.observeValue(getConnectionContext(), "host"), new UpdateValueStrategy(), new UpdateValueStrategy()); bindingContext.bindValue(SWTObservables.observeText(portText, SWT.Modify), BeansObservables.observeValue(getConnectionContext(), "port"), new UpdateValueStrategy(), new UpdateValueStrategy()); bindingContext.bindValue(SWTObservables.observeText(loginText, SWT.Modify), BeansObservables.observeValue(getConnectionContext(), "login"), new UpdateValueStrategy(), new UpdateValueStrategy()); bindingContext.bindValue(SWTObservables.observeText(passwordText, SWT.Modify), BeansObservables.observeValue(getConnectionContext(), "password"), new UpdateValueStrategy(), new UpdateValueStrategy()); }// w ww.j av a 2 s .c o m }); }
From source file:org.gumtree.gumnix.sics.internal.ui.login.InstrumentSpecificLoginDialog.java
License:Open Source License
protected Control createDialogArea(Composite parent) { mainComposite = (Composite) super.createDialogArea(parent); Composite imageArea = new Composite(mainComposite, SWT.NONE); imageArea.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true)); createImage(imageArea);//from w w w.ja v a 2 s . c o m Composite optionArea = new Composite(mainComposite, SWT.NONE); optionArea.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); createHiddenOptions(optionArea); Composite loginArea = new Composite(mainComposite, SWT.NONE); loginArea.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); createLoginBar(loginArea); // Bind GUI for Eclipse 3.3 Realm.runWithDefault(SWTObservables.getRealm(PlatformUI.getWorkbench().getDisplay()), new Runnable() { public void run() { DataBindingContext bindingContext = new DataBindingContext(); bindingContext.bindValue(SWTObservables.observeText(hostText, SWT.Modify), BeansObservables.observeValue(getConnectionContext(), "host"), new UpdateValueStrategy(), new UpdateValueStrategy()); bindingContext.bindValue(SWTObservables.observeText(portText, SWT.Modify), BeansObservables.observeValue(getConnectionContext(), "port"), new UpdateValueStrategy(), new UpdateValueStrategy()); bindingContext.bindValue(SWTObservables.observeText(passwordText, SWT.Modify), BeansObservables.observeValue(getConnectionContext(), "password"), new UpdateValueStrategy(), new UpdateValueStrategy()); } }); passwordText.setFocus(); getShell().setText("Login"); setTitle("Welcome to the " + SicsCoreProperties.INSTRUMENT_NAME.getValue() + " instrument server!"); if (getInitialErrorMessage() != null) { setErrorMessage(getInitialErrorMessage()); } return mainComposite; }
From source file:org.gumtree.gumnix.sics.internal.ui.SicsTelnetConfigPart.java
License:Open Source License
public void createControlPart(Composite parent) { super.createControlPart(parent); Label label = new Label(parent, SWT.NONE); label.setText("Login: "); final Text loginText = new Text(parent, SWT.BORDER); loginText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); // getBindingContext().bind(loginText, new Property(getConnectionContext(), "login"), null); label = new Label(parent, SWT.NONE); label.setText("Password: "); final Text passwordText = new Text(parent, SWT.BORDER | SWT.PASSWORD); passwordText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); // getBindingContext().bind(passwordText, new Property(getConnectionContext(), "password"), null); // Eclipse 3.3 databinding Realm.runWithDefault(SWTObservables.getRealm(PlatformUI.getWorkbench().getDisplay()), new Runnable() { public void run() { DataBindingContext bindingContext = new DataBindingContext(); bindingContext.bindValue(SWTObservables.observeText(loginText, SWT.Modify), BeansObservables.observeValue(getConnectionContext(), "login"), new UpdateValueStrategy(), new UpdateValueStrategy()); bindingContext.bindValue(SWTObservables.observeText(passwordText, SWT.Modify), BeansObservables.observeValue(getConnectionContext(), "password"), new UpdateValueStrategy(), new UpdateValueStrategy()); }// w ww . j a va 2 s . c om }); }
From source file:org.gumtree.ui.terminal.support.telnet.TelnetConfigPart.java
License:Open Source License
public void createControlPart(Composite parent) { this.parent = parent; parent.setLayout(new GridLayout(2, false)); Label label = new Label(parent, SWT.NONE); label.setText("Host: "); final Text hostText = new Text(parent, SWT.BORDER); hostText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); // getBindingContext().bind(hostText, new Property(getConnectionContext(), "host"), null); label = new Label(parent, SWT.NONE); label.setText("Port: "); final Text portText = new Text(parent, SWT.BORDER); portText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); // getBindingContext().bind(portText, new Property(getConnectionContext(), "port"), null); // Databinding in Eclipse 3.3 Realm.runWithDefault(SWTObservables.getRealm(PlatformUI.getWorkbench().getDisplay()), new Runnable() { public void run() { DataBindingContext bindingContext = new DataBindingContext(); bindingContext.bindValue(SWTObservables.observeText(hostText, SWT.Modify), BeansObservables.observeValue(getConnectionContext(), "host"), new UpdateValueStrategy(), new UpdateValueStrategy()); bindingContext.bindValue(SWTObservables.observeText(portText, SWT.Modify), BeansObservables.observeValue(getConnectionContext(), "port"), new UpdateValueStrategy(), new UpdateValueStrategy()); }/*from w w w . j av a2 s . c o m*/ }); }
From source file:org.gumtree.workflow.ui.views.ParametersBasedTaskView.java
License:Open Source License
public void createPartControl(final Composite parent) { Realm.runWithDefault(SWTObservables.getRealm(Display.getDefault()), new Runnable() { public void run() { DataBindingContext bindingContext = new DataBindingContext(); GridLayoutFactory.swtDefaults().numColumns(3).applyTo(parent); for (Entry<String, Object> entry : parameters.entrySet()) { if (entry.getValue() instanceof Number || entry.getValue() instanceof String) { // Support number and text createLabel(parent, entry.getKey()); Text text = getToolkit().createText(parent, ""); if (units.containsKey(entry.getKey())) { GridDataFactory.fillDefaults().grab(true, false).applyTo(text); getToolkit().createLabel(parent, " " + units.get(entry.getKey())); } else { GridDataFactory.fillDefaults().grab(true, false).span(2, 0).applyTo(text); }/* ww w . j av a 2s .co m*/ bindingContext.bindValue(SWTObservables.observeText(text, SWT.Modify), ParametersObservables.observeValue(parameters, entry.getKey()), new UpdateValueStrategy(), new UpdateValueStrategy()); } else if (entry.getValue().getClass().isEnum()) { // Support enum createLabel(parent, entry.getKey()); ComboViewer comboViewer = new ComboViewer(parent, SWT.READ_ONLY); comboViewer.setContentProvider(new ArrayContentProvider()); comboViewer.setLabelProvider(new LabelProvider()); comboViewer.setInput(entry.getValue().getClass().getEnumConstants()); GridDataFactory.fillDefaults().grab(true, false).span(2, 0) .applyTo(comboViewer.getControl()); bindingContext.bindValue(SWTObservables.observeSelection(comboViewer.getControl()), ParametersObservables.observeValue(parameters, entry.getKey()), new UpdateValueStrategy(), new UpdateValueStrategy()); } } } }); }
From source file:org.marketcetera.photon.commons.ui.databinding.DataBindingContextCaveatTest.java
@Test public void test() throws Exception { new ExpectedFailure<AssertionFailedException>( "assertion failed: This operation must be run within the observable's realm") { @Override/*from w ww . j av a 2 s .c om*/ protected void run() throws Exception { final Exchanger<IObservableList> mModelExchanger = new Exchanger<IObservableList>(); final CountDownLatch mModelReadyToDispose = new CountDownLatch(1); ExecutorService executor = Executors.newSingleThreadExecutor(); Future<?> future = executor.submit(new Runnable() { @Override public void run() { try { ThreadRealm realm = new ThreadRealm(); realm.init(Thread.currentThread()); WritableList model = new WritableList(realm, new ArrayList<Object>(), String.class); mModelExchanger.exchange(model); mModelReadyToDispose.await(); model.dispose(); // throws AssertionFailedException } catch (InterruptedException e) { throw new RuntimeException(e); } } }); Display d = new Display(); Realm.runWithDefault(SWTObservables.getRealm(d), new Runnable() { @Override public void run() { try { WritableList target = WritableList.withElementType(String.class); DataBindingContext dbc = new DataBindingContext(); dbc.bindList(target, mModelExchanger.exchange(null)); mModelReadyToDispose.countDown(); } catch (InterruptedException e) { throw new RuntimeException(e); } } }); try { future.get(); // propagates the AssertionFailedException } catch (ExecutionException e) { throw (Exception) e.getCause(); } finally { executor.shutdownNow(); d.dispose(); } } }; }
From source file:org.marketcetera.photon.test.SimpleUIRunner.java
@Override protected void runEventLoop(final Display display, final CountDownLatch ready) { ready.countDown();/*www . j a va 2 s .com*/ Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable() { @Override public void run() { while (!mShutDown) { try { if (!display.readAndDispatch()) { display.sleep(); } } catch (Throwable t) { setAsyncThrowable(t); } } } }); }
From source file:org.multicore_association.shim.edit.actions.PreferencesAction.java
License:MIT License
/** * @see org.eclipse.jface.action.Action#run() *//*from w w w . j av a 2 s . c om*/ @Override public void run() { // Set pages to PreferenceManager. final PreferenceManager pm = new PreferenceManager(); final ComponentsPreferencePage page1 = new ComponentsPreferencePage(); PreferenceNode pnode1 = new PreferenceNode(page1.getTitle()); pnode1.setPage(page1); pm.addToRoot(pnode1); MasterComponentPreferencePage page2 = new MasterComponentPreferencePage(); PreferenceNode pnode2 = new PreferenceNode(page2.getTitle()); pnode2.setPage(page2); pm.addTo(page1.getTitle(), pnode2); SlaveComponentPreferencePage page3 = new SlaveComponentPreferencePage(); PreferenceNode pnode3 = new PreferenceNode(page3.getTitle()); pnode3.setPage(page3); pm.addTo(page1.getTitle(), pnode3); ComponentSetPreferencePage page4 = new ComponentSetPreferencePage(); PreferenceNode pnode4 = new PreferenceNode(page4.getTitle()); pnode4.setPage(page4); pm.addTo(page1.getTitle(), pnode4); AddressSpacePreferencePage page5 = new AddressSpacePreferencePage(); PreferenceNode pnode5 = new PreferenceNode(page5.getTitle()); pnode5.setPage(page5); pm.addToRoot(pnode5); CommunicationSetPreferencePage page6 = new CommunicationSetPreferencePage(); PreferenceNode pnode6 = new PreferenceNode(page6.getTitle()); pnode6.setPage(page6); pm.addToRoot(pnode6); CachePreferencePage page7 = new CachePreferencePage(); PreferenceNode pnode7 = new PreferenceNode(page7.getTitle()); pnode7.setPage(page7); pm.addToRoot(pnode7); AccessTypePreferencePage page8 = new AccessTypePreferencePage(); PreferenceNode pnode8 = new PreferenceNode(page8.getTitle()); pnode8.setPage(page8); pm.addToRoot(pnode8); PerformancePreferencePage page9 = new PerformancePreferencePage(); PreferenceNode pnode9 = new PreferenceNode(page9.getTitle()); pnode9.setPage(page9); pm.addToRoot(pnode9); LatencyPreferencePage page10 = new LatencyPreferencePage(); PreferenceNode pnode10 = new PreferenceNode(page10.getTitle()); pnode10.setPage(page10); pm.addTo(page9.getTitle(), pnode10); PitchPreferencePage page11 = new PitchPreferencePage(); PreferenceNode pnode11 = new PreferenceNode(page11.getTitle()); pnode11.setPage(page11); pm.addTo(page9.getTitle(), pnode11); WizardInputPreferencePage page00 = new WizardInputPreferencePage(); PreferenceNode pnode00 = new PreferenceNode(page00.getTitle()); pnode00.setPage(page00); pm.addToRoot(pnode00); // starts the wizard. final Display display = Display.getDefault(); Realm.runWithDefault(SWTObservables.getRealm(display), new Runnable() { /** * @see java.lang.Runnable#run() */ @Override public void run() { final PreferenceDialog dialog = new PreferenceDialog(display.getActiveShell(), pm); dialog.setSelectedNode(page1.getTitle()); dialog.setMinimumPageSize(640, 480); // if you want to expand PreferenceDialog's TreeViewer, // call 'create' method. dialog.create(); dialog.getTreeViewer().expandAll(); dialog.open(); } }); }
From source file:org.multicore_association.shim.edit.gui.jface.SHIMEditJFaceApplicationWindow.java
License:MIT License
/** * Creates an action to create a new SHIM Data. *//* ww w . ja va 2 s . co m*/ private void createNewAction() { actionNew = new Action("New@Ctrl+N") { /** * @see org.eclipse.jface.action.Action#run() */ @Override public void run() { log.finest("[Action] New start"); createNewDataWizard = new CreateNewDataWizard(); createNewDataWizard.setComponentTreeViewer(shimComponentTreeViewer); createNewDataWizard.setAddressSpaceTreeViewer(shimAddressSpaceTreeViewer); createNewDataWizard.setCommunicationTreeViewer(shimCommunicationTreeViewer); Realm.runWithDefault(SWTObservables.getRealm(rootShell.getDisplay()), new Runnable() { /** * @see java.lang.Runnable#run() */ @Override public void run() { shimWizardDialog = new WizardDialog(rootShell, createNewDataWizard); int open = shimWizardDialog.open(); if (open == 0) { actionSave.setEnabled(true); actionSaveAs.setEnabled(true); remakeAddressSpaceAction.setEnabled(true); remakeCommunicationsAction.setEnabled(true); actionChangeDisplay.setEnabled(true); actionSearch.setEnabled(true); SystemConfiguration system = ShimModelManager.getCurrentScd(); inputPanelSystemConfiguration.setInput(system); StackLayout stack = (StackLayout) compositeSystem.getLayout(); stack.topControl = inputPanelSystemConfiguration; compositeSystem.layout(); defaultPathName = null; rootShell.setText(CommonConstants.API_NAME); } } }); } }; }