List of usage examples for org.eclipse.jface.viewers ComboViewer ComboViewer
public ComboViewer(Composite parent, int style)
From source file:at.bestsolution.efxclipse.tooling.jdt.ui.internal.editors.AddIconDialog.java
License:Open Source License
@Override protected Control createDialogContent(final Composite parent) { o = ParametersFactory.eINSTANCE.createIcon(); Composite area = new Composite(parent, SWT.NONE); area.setLayout(new GridLayout(1, false)); area.setLayoutData(new GridData(GridData.FILL_BOTH)); getShell().setText("Add icon"); setTitle("Add icon"); setMessage("Enter informations about the icon to add"); Composite container = new Composite(area, SWT.NONE); container.setLayout(new GridLayout(2, false)); container.setLayoutData(new GridData(GridData.FILL_BOTH)); IViewerValueProperty selProp = ViewerProperties.singleSelection(); IWidgetValueProperty tProp = WidgetProperties.text(SWT.Modify); {/*from w w w . j a va 2 s. c om*/ Label l = new Label(container, SWT.NONE); l.setText("Kind:"); ComboViewer v = new ComboViewer(container, SWT.READ_ONLY); v.setLabelProvider(new LabelProvider()); v.setContentProvider(ArrayContentProvider.getInstance()); v.setInput(IconType.VALUES); IEMFValueProperty prop = EMFEditProperties.value(editingDomain, ICON__KIND); dbContext.bindValue(selProp.observe(v), prop.observe(o), new EMFUpdateValueStrategy(EMFUpdateValueStrategy.POLICY_ON_REQUEST), new EMFUpdateValueStrategy()); } { Label l = new Label(container, SWT.NONE); l.setText("URL*:"); tUrl = new Text(container, SWT.BORDER); tUrl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); IEMFValueProperty prop = EMFEditProperties.value(editingDomain, ICON__HREF); dbContext.bindValue(tProp.observeDelayed(DELAY, tUrl), prop.observe(o), new EMFUpdateValueStrategy(EMFUpdateValueStrategy.POLICY_ON_REQUEST), new EMFUpdateValueStrategy()); } { Label l = new Label(container, SWT.NONE); l.setText("Depth:"); ComboViewer v = new ComboViewer(container, SWT.READ_ONLY); v.setLabelProvider(new LabelProvider()); v.setContentProvider(ArrayContentProvider.getInstance()); // TODO not hard coded here v.setInput(new String[] { "8", "24", "32" }); IEMFValueProperty prop = EMFEditProperties.value(editingDomain, ICON__DEPTH); dbContext.bindValue(selProp.observe(v), prop.observe(o), new EMFUpdateValueStrategy(EMFUpdateValueStrategy.POLICY_ON_REQUEST), new EMFUpdateValueStrategy()); } { Label l = new Label(container, SWT.NONE); l.setText("Width:"); tWidth = new Text(container, SWT.BORDER); tWidth.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); IEMFValueProperty prop = EMFEditProperties.value(editingDomain, ICON__WIDTH); dbContext.bindValue(tProp.observeDelayed(DELAY, tWidth), prop.observe(o), new EMFUpdateValueStrategy(EMFUpdateValueStrategy.POLICY_ON_REQUEST), new EMFUpdateValueStrategy()); } { Label l = new Label(container, SWT.NONE); l.setText("Height:"); tHeight = new Text(container, SWT.BORDER); tHeight.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); IEMFValueProperty prop = EMFEditProperties.value(editingDomain, ICON__HEIGHT); dbContext.bindValue(tProp.observeDelayed(DELAY, tHeight), prop.observe(o), new EMFUpdateValueStrategy(EMFUpdateValueStrategy.POLICY_ON_REQUEST), new EMFUpdateValueStrategy()); } return area; }
From source file:at.bestsolution.efxclipse.tooling.jdt.ui.internal.editors.AddSplashDialog.java
License:Open Source License
@Override protected Control createDialogContent(final Composite parent) { o = ParametersFactory.eINSTANCE.createSplash(); Composite area = new Composite(parent, SWT.NONE); area.setLayout(new GridLayout(1, false)); area.setLayoutData(new GridData(GridData.FILL_BOTH)); getShell().setText("Add splash icon"); setTitle("Add splash"); setMessage("Enter informations about the splash to add"); Composite container = new Composite(area, SWT.NONE); container.setLayout(new GridLayout(2, false)); container.setLayoutData(new GridData(GridData.FILL_BOTH)); IViewerValueProperty selProp = ViewerProperties.singleSelection(); IWidgetValueProperty tProp = WidgetProperties.text(SWT.Modify); {/*from w w w . ja v a2 s . c om*/ Label l = new Label(container, SWT.NONE); l.setText("Mode*:"); ComboViewer v = new ComboViewer(container, SWT.READ_ONLY); v.setLabelProvider(new LabelProvider()); v.setContentProvider(ArrayContentProvider.getInstance()); v.setInput(SplashMode.values()); IEMFValueProperty prop = EMFEditProperties.value(editingDomain, SPLASH__MODE); dbContext.bindValue(selProp.observe(v), prop.observe(o), new EMFUpdateValueStrategy(EMFUpdateValueStrategy.POLICY_ON_REQUEST), new EMFUpdateValueStrategy()); } { Label l = new Label(container, SWT.NONE); l.setText("URL*:"); tUrl = new Text(container, SWT.BORDER); tUrl.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); IEMFValueProperty prop = EMFEditProperties.value(editingDomain, SPLASH__HREF); dbContext.bindValue(tProp.observeDelayed(DELAY, tUrl), prop.observe(o), new EMFUpdateValueStrategy(EMFUpdateValueStrategy.POLICY_ON_REQUEST), new EMFUpdateValueStrategy()); } return area; }
From source file:at.bestsolution.persistence.emap.ecoregenerator.GeneratorOptionsDialog.java
License:Open Source License
@Override protected final Control createDialogArea(final Composite parent) { Composite area = new Composite(parent, SWT.NONE); area.setLayout(new GridLayout(1, false)); area.setLayoutData(new GridData(GridData.FILL_BOTH)); getShell().setText(Messages.GeneratorOptionsDialog_shellTitle); setTitle(Messages.GeneratorOptionsDialog_title); Composite container = new Composite(area, SWT.NONE); container.setLayout(new GridLayout(3, false)); container.setLayoutData(new GridData(GridData.FILL_BOTH)); {/* w w w .jav a 2 s. co m*/ Label l = new Label(container, SWT.NONE); l.setText(Messages.GeneratorOptionsDialog_emapProject); projectsViewer = new ComboViewer(container, SWT.READ_ONLY); projectsViewer.setLabelProvider(new LabelProvider() { @Override public String getText(final Object element) { if (element == null) { return ""; //$NON-NLS-1$ } else { return ((IProject) element).getName(); } } }); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; projectsViewer.getCombo().setLayoutData(gd); projectsViewer.setContentProvider(ArrayContentProvider.getInstance()); projectsViewer.setInput(projects); projectsViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent event) { selectedFolder = null; ISelection s = event.getSelection(); if (s instanceof StructuredSelection && !s.isEmpty()) { selectedProject = (IProject) ((StructuredSelection) s).getFirstElement(); selectedFolder = selectedProject .getFolder("/src/" + selectedProject.getName().replace('.', '/')); tFolder.setText(selectedFolder.getFullPath().toString()); } } }); } { Label l = new Label(container, SWT.NONE); l.setText(Messages.GeneratorOptionsDialog_rootFolder); tFolder = new Text(container, SWT.READ_ONLY | SWT.BORDER); tFolder.setEditable(false); GridData gd = new GridData(GridData.FILL_HORIZONTAL); tFolder.setLayoutData(gd); Button b = new Button(container, SWT.NONE); b.setText(Messages.GeneratorOptionsDialog_buttonFolder); b.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { if (selectedProject != null) { ILabelProvider lp = new WorkbenchLabelProvider(); ITreeContentProvider cp = new WorkbenchContentProvider(); Class<?>[] acceptedClasses = new Class[] { IFolder.class }; ViewerFilter filter = new TypedViewerFilter(acceptedClasses); FolderSelectionDialog dialog = new FolderSelectionDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), lp, cp); dialog.setTitle(Messages.GeneratorOptionsDialog_outputDirectory); dialog.setMessage(Messages.GeneratorOptionsDialog_selectOutputDirectory); dialog.addFilter(filter); dialog.setInput(selectedProject); if (dialog.open() == Window.OK) { selectedFolder = (IFolder) dialog.getFirstResult(); tFolder.setText(selectedFolder.getFullPath().toString()); } } } }); if (!projects.isEmpty()) { projectsViewer.setSelection(new StructuredSelection(projects.get(0))); } } return area; }
From source file:at.medevit.elexis.gdt.ui.dialog.NeueUntersuchungAnfordernDialog.java
License:Open Source License
/** * Create contents of the dialog.// ww w . jav a 2 s.co m * * @param parent */ @Override protected Control createDialogArea(Composite parent) { setTitleImage(ResourceManager.getPluginImage("at.medevit.elexis.gdt", "rsc/icons/TitleIcon6302.png")); setMessage("GDT Satznachricht 6302"); setTitle("Neue Untersuchung anfordern"); Composite area = (Composite) super.createDialogArea(parent); Composite container = new Composite(area, SWT.NONE); container.setLayout(new GridLayout(4, true)); container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); Label lblZiel = new Label(container, SWT.NONE); lblZiel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblZiel.setText("Ziel"); comboViewerTarget = new ComboViewer(container, SWT.NONE); Combo combo = comboViewerTarget.getCombo(); combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1)); comboViewerTarget.setContentProvider(ArrayContentProvider.getInstance()); comboViewerTarget.setLabelProvider(new ComboViewerCommPartner()); List<IGDTCommunicationPartner> commPartners = GDTCommPartnerCollector.getRegisteredCommPartners(); comboViewerTarget.setInput(commPartners); comboViewerTarget.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) comboViewerTarget.getSelection(); IGDTCommunicationPartner cp = (IGDTCommunicationPartner) selection.getFirstElement(); commPartner = cp; txtIDReceiver.setText(cp.getIDReceiver()); if (cp.getOutgoingDefaultCharset() >= 0) gdt6302.setValue(GDTConstants.FELDKENNUNG_VERWENDETER_ZEICHENSATZ, cp.getOutgoingDefaultCharset() + ""); supported8402values = cp.getSupported8402values(); supported8402valuesDescription = cp.getSupported8402valuesDescription(); if (supported8402values != null && supported8402valuesDescription != null) { contentProposalProvider8402.setProposals(supported8402values, supported8402valuesDescription, cp.getSupported8402valuesDetailDescription()); } } }); Label lblGdtidEmpfnger = new Label(container, SWT.NONE); lblGdtidEmpfnger.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblGdtidEmpfnger.setText("ID Empfnger"); txtIDReceiver = new Text(container, SWT.BORDER); txtIDReceiver.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); txtIDReceiver.setTextLimit(8); Label lblGdtidSender = new Label(container, SWT.NONE); lblGdtidSender.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblGdtidSender.setText("ID Sender"); txtIDSender = new Text(container, SWT.BORDER); txtIDSender.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); txtIDSender.setTextLimit(8); Label lblNewLabel = new Label(container, SWT.NONE); GridData gd_lblNewLabel = new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1); gd_lblNewLabel.heightHint = 5; lblNewLabel.setLayoutData(gd_lblNewLabel); Group groupPatient = new Group(container, SWT.NONE); groupPatient.setText("Notwendige Patienten-Daten"); groupPatient.setLayout(new GridLayout(5, false)); groupPatient.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 4, 1)); Label lblPatientKennung = new Label(groupPatient, SWT.NONE); lblPatientKennung.setText("Nummer/Kennung"); txtPatientenKennung = new Text(groupPatient, SWT.BORDER); txtPatientenKennung.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); txtPatientenKennung.setTextLimit(10); new Label(groupPatient, SWT.NONE); Label lblGeburtsdatum = new Label(groupPatient, SWT.NONE); lblGeburtsdatum.setText("Geburtsdatum"); dateTimeBirthday = new DateTime(groupPatient, SWT.BORDER | SWT.DROP_DOWN); dateTimeBirthday.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Label lblPatientNachname = new Label(groupPatient, SWT.NONE); lblPatientNachname.setText("Nachname"); txtPatientNachname = new Text(groupPatient, SWT.BORDER); txtPatientNachname.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); txtPatientNachname.setTextLimit(28); new Label(groupPatient, SWT.NONE); Label lblPatientVorname = new Label(groupPatient, SWT.NONE); lblPatientVorname.setText("Vorname"); txtPatientVorname = new Text(groupPatient, SWT.BORDER); txtPatientVorname.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); txtPatientVorname.setTextLimit(28); Group grpGeraeteSpezifisch = new Group(container, SWT.None); grpGeraeteSpezifisch.setLayout(new GridLayout(4, true)); grpGeraeteSpezifisch.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1)); grpGeraeteSpezifisch.setText("Testbezogene Daten"); Label lblGuvk = new Label(grpGeraeteSpezifisch, SWT.NONE); lblGuvk.setToolTipText("Gerte und verfahrensspezifisches Kennfeld (8402)"); lblGuvk.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1)); lblGuvk.setText("GuvK"); txtGuVK = new Text(grpGeraeteSpezifisch, SWT.BORDER); txtGuVK.setTextLimit(6); txtGuVK.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); contentProposalProvider8402 = new Feld8402ContentProposalProvider(new String[] {}, new String[] {}, new String[] {}); guvkAdapter = new ContentProposalAdapter(txtGuVK, new TextContentAdapter(), contentProposalProvider8402, null, null); guvkAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); Label lblTestident = new Label(grpGeraeteSpezifisch, SWT.NONE); lblTestident.setToolTipText("Test-Identifizierung (8410)"); lblTestident.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, true, false, 1, 1)); lblTestident.setText("Test-Ident"); txtTestIdent = new Text(grpGeraeteSpezifisch, SWT.BORDER); txtTestIdent.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); txtTestIdent.setTextLimit(20); Group grpOptionaleDaten = new Group(container, SWT.NONE); grpOptionaleDaten.setText("Optionale Patienten-Daten"); grpOptionaleDaten.setLayout(new GridLayout(5, false)); grpOptionaleDaten.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 4, 1)); Label lblTitel = new Label(grpOptionaleDaten, SWT.NONE); lblTitel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblTitel.setText("Titel"); txtTitel = new Text(grpOptionaleDaten, SWT.BORDER); txtTitel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); new Label(grpOptionaleDaten, SWT.NONE); Label lblGeschlecht = new Label(grpOptionaleDaten, SWT.NONE); lblGeschlecht.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblGeschlecht.setText("Geschlecht"); comboViewerGeschlecht = new ComboViewer(grpOptionaleDaten, SWT.NONE); Combo comboGeschlecht = comboViewerGeschlecht.getCombo(); comboViewerGeschlecht.setContentProvider(ArrayContentProvider.getInstance()); comboViewerGeschlecht.setInput(new String[] { GDTConstants.SEX_MALE + "", GDTConstants.SEX_FEMALE + "" }); comboViewerGeschlecht.setLabelProvider(new ComboViewerGeschlechtLabelProvider()); comboGeschlecht.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Label lblVersichertennr = new Label(grpOptionaleDaten, SWT.NONE); lblVersichertennr.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblVersichertennr.setText("Versicherten-Nr."); txtVersichertenNr = new Text(grpOptionaleDaten, SWT.BORDER); txtVersichertenNr.setTextLimit(12); txtVersichertenNr.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); new Label(grpOptionaleDaten, SWT.NONE); Label lblVersichertenart = new Label(grpOptionaleDaten, SWT.NONE); lblVersichertenart.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblVersichertenart.setText("Versichertenart"); comboViewerVersichertenart = new ComboViewer(grpOptionaleDaten, SWT.NONE); Combo comboVersichertenart = comboViewerVersichertenart.getCombo(); comboVersichertenart.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); comboViewerVersichertenart.setContentProvider(ArrayContentProvider.getInstance()); comboViewerVersichertenart.setInput(new String[] { GDTConstants.VERSICHERTENART_FAMILIENVERSICHERTER + "", GDTConstants.VERSICHERTENART_MITGLIED + "", GDTConstants.VERSICHERTENART_RENTNER + "" }); comboViewerVersichertenart.setLabelProvider(new ComboViewerVersichertenartLabelProvider()); Label lblStrasse = new Label(grpOptionaleDaten, SWT.NONE); lblStrasse.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblStrasse.setText("Strasse"); txtStrasse = new Text(grpOptionaleDaten, SWT.BORDER); txtStrasse.setTextLimit(28); txtStrasse.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); new Label(grpOptionaleDaten, SWT.NONE); Label lblOrt = new Label(grpOptionaleDaten, SWT.NONE); lblOrt.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblOrt.setText("Ort"); txtOrt = new Text(grpOptionaleDaten, SWT.BORDER); txtOrt.setTextLimit(30); txtOrt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Label lblGroesse = new Label(grpOptionaleDaten, SWT.NONE); lblGroesse.setToolTipText("Gre in cm"); lblGroesse.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblGroesse.setText("Gre"); txtGroesse = new Text(grpOptionaleDaten, SWT.BORDER); txtGroesse.setTextLimit(10); txtGroesse.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); new Label(grpOptionaleDaten, SWT.NONE); Label lblGewicht = new Label(grpOptionaleDaten, SWT.NONE); lblGewicht.setToolTipText("Gewicht in kg"); lblGewicht.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblGewicht.setText("Gewicht"); txtGewicht = new Text(grpOptionaleDaten, SWT.BORDER); txtGewicht.setTextLimit(10); txtGewicht.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Label lblMuttersprache = new Label(grpOptionaleDaten, SWT.NONE); lblMuttersprache.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblMuttersprache.setText("Muttersprache"); txtMuttersprache = new Text(grpOptionaleDaten, SWT.BORDER); txtMuttersprache.setTextLimit(60); txtMuttersprache.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); new Label(grpOptionaleDaten, SWT.NONE); new Label(grpOptionaleDaten, SWT.NONE); new Label(grpOptionaleDaten, SWT.NONE); initDataBindings(); if (commPartners != null && commPartners.size() > 0) { comboViewerTarget.setSelection(new StructuredSelection(commPartners.get(0))); if (targetIdSelection != null) { int idx = 0; for (IGDTCommunicationPartner igdtCommunicationPartner : commPartners) { if (igdtCommunicationPartner instanceof IGDTCommunicationPartnerProvider) { String id = ((IGDTCommunicationPartnerProvider) igdtCommunicationPartner).getId(); if (id.equals(targetIdSelection)) { comboViewerTarget.setSelection(new StructuredSelection(commPartners.get(idx))); break; } } idx++; } } } return area; }
From source file:at.medevit.elexis.gdt.ui.dialog.StammdatenUebermittelnDialog.java
License:Open Source License
/** * Create contents of the dialog./* w ww . j a v a 2 s. c o m*/ * * @param parent */ @Override protected Control createDialogArea(Composite parent) { setTitleImage(ResourceManager.getPluginImage("at.medevit.elexis.gdt", "rsc/icons/TitleIcon6301.png")); setMessage("GDT Satznachricht 6301"); setTitle("Stammdaten bermitteln"); Composite area = (Composite) super.createDialogArea(parent); Composite container = new Composite(area, SWT.NONE); container.setLayout(new GridLayout(4, true)); container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); Label lblZiel = new Label(container, SWT.NONE); lblZiel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblZiel.setText("Ziel"); comboViewerTarget = new ComboViewer(container, SWT.NONE); Combo combo = comboViewerTarget.getCombo(); combo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1)); comboViewerTarget.setContentProvider(ArrayContentProvider.getInstance()); comboViewerTarget.setLabelProvider(new ComboViewerCommPartner()); List<IGDTCommunicationPartner> commPartners = GDTCommPartnerCollector.getRegisteredCommPartners(); comboViewerTarget.setInput(commPartners); comboViewerTarget.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection) comboViewerTarget.getSelection(); IGDTCommunicationPartner cp = (IGDTCommunicationPartner) selection.getFirstElement(); commPartner = cp; txtIDReceiver.setText(cp.getIDReceiver()); if (cp.getOutgoingDefaultCharset() >= 0) gdt6301.setValue(GDTConstants.FELDKENNUNG_VERWENDETER_ZEICHENSATZ, cp.getOutgoingDefaultCharset() + ""); } }); Label lblGdtidEmpfnger = new Label(container, SWT.NONE); lblGdtidEmpfnger.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblGdtidEmpfnger.setText("ID Empfnger"); txtIDReceiver = new Text(container, SWT.BORDER); txtIDReceiver.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); txtIDReceiver.setTextLimit(8); Label lblGdtidSender = new Label(container, SWT.NONE); lblGdtidSender.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblGdtidSender.setText("ID Sender"); txtIDSender = new Text(container, SWT.BORDER); txtIDSender.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); txtIDSender.setTextLimit(8); Label lblNewLabel = new Label(container, SWT.NONE); GridData gd_lblNewLabel = new GridData(SWT.FILL, SWT.CENTER, true, false, 4, 1); gd_lblNewLabel.heightHint = 5; lblNewLabel.setLayoutData(gd_lblNewLabel); Group groupPatient = new Group(container, SWT.NONE); groupPatient.setText("Notwendige Patienten-Daten"); groupPatient.setLayout(new GridLayout(5, false)); groupPatient.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 4, 1)); Label lblPatientKennung = new Label(groupPatient, SWT.NONE); lblPatientKennung.setText("Nummer/Kennung"); txtPatientenKennung = new Text(groupPatient, SWT.BORDER); txtPatientenKennung.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); txtPatientenKennung.setTextLimit(10); new Label(groupPatient, SWT.NONE); Label lblGeburtsdatum = new Label(groupPatient, SWT.NONE); lblGeburtsdatum.setText("Geburtsdatum"); dateTimeBirthday = new DateTime(groupPatient, SWT.BORDER | SWT.DROP_DOWN); dateTimeBirthday.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Label lblPatientNachname = new Label(groupPatient, SWT.NONE); lblPatientNachname.setText("Nachname"); txtPatientNachname = new Text(groupPatient, SWT.BORDER); txtPatientNachname.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); txtPatientNachname.setTextLimit(28); new Label(groupPatient, SWT.NONE); Label lblPatientVorname = new Label(groupPatient, SWT.NONE); lblPatientVorname.setText("Vorname"); txtPatientVorname = new Text(groupPatient, SWT.BORDER); txtPatientVorname.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); txtPatientVorname.setTextLimit(28); Group grpOptionaleDaten = new Group(container, SWT.NONE); grpOptionaleDaten.setText("Optionale Patienten-Daten"); grpOptionaleDaten.setLayout(new GridLayout(5, false)); grpOptionaleDaten.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 4, 1)); Label lblTitel = new Label(grpOptionaleDaten, SWT.NONE); lblTitel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblTitel.setText("Titel"); txtTitel = new Text(grpOptionaleDaten, SWT.BORDER); txtTitel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); new Label(grpOptionaleDaten, SWT.NONE); Label lblGeschlecht = new Label(grpOptionaleDaten, SWT.NONE); lblGeschlecht.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblGeschlecht.setText("Geschlecht"); comboViewerGeschlecht = new ComboViewer(grpOptionaleDaten, SWT.NONE); Combo comboGeschlecht = comboViewerGeschlecht.getCombo(); comboViewerGeschlecht.setContentProvider(ArrayContentProvider.getInstance()); comboViewerGeschlecht.setInput(new String[] { GDTConstants.SEX_MALE + "", GDTConstants.SEX_FEMALE + "" }); comboViewerGeschlecht.setLabelProvider(new ComboViewerGeschlechtLabelProvider()); comboGeschlecht.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Label lblVersichertennr = new Label(grpOptionaleDaten, SWT.NONE); lblVersichertennr.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblVersichertennr.setText("Versicherten-Nr."); txtVersichertenNr = new Text(grpOptionaleDaten, SWT.BORDER); txtVersichertenNr.setTextLimit(12); txtVersichertenNr.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); new Label(grpOptionaleDaten, SWT.NONE); Label lblVersichertenart = new Label(grpOptionaleDaten, SWT.NONE); lblVersichertenart.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblVersichertenart.setText("Versichertenart"); comboViewerVersichertenart = new ComboViewer(grpOptionaleDaten, SWT.NONE); Combo comboVersichertenart = comboViewerVersichertenart.getCombo(); comboVersichertenart.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); comboViewerVersichertenart.setContentProvider(ArrayContentProvider.getInstance()); comboViewerVersichertenart.setInput(new String[] { GDTConstants.VERSICHERTENART_FAMILIENVERSICHERTER + "", GDTConstants.VERSICHERTENART_MITGLIED + "", GDTConstants.VERSICHERTENART_RENTNER + "" }); comboViewerVersichertenart.setLabelProvider(new ComboViewerVersichertenartLabelProvider()); Label lblStrasse = new Label(grpOptionaleDaten, SWT.NONE); lblStrasse.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblStrasse.setText("Strasse"); txtStrasse = new Text(grpOptionaleDaten, SWT.BORDER); txtStrasse.setTextLimit(28); txtStrasse.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); new Label(grpOptionaleDaten, SWT.NONE); Label lblOrt = new Label(grpOptionaleDaten, SWT.NONE); lblOrt.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblOrt.setText("Ort"); txtOrt = new Text(grpOptionaleDaten, SWT.BORDER); txtOrt.setTextLimit(30); txtOrt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Label lblGroesse = new Label(grpOptionaleDaten, SWT.NONE); lblGroesse.setToolTipText("Gre in cm"); lblGroesse.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblGroesse.setText("Gre"); txtGroesse = new Text(grpOptionaleDaten, SWT.BORDER); txtGroesse.setTextLimit(10); txtGroesse.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); new Label(grpOptionaleDaten, SWT.NONE); Label lblGewicht = new Label(grpOptionaleDaten, SWT.NONE); lblGewicht.setToolTipText("Gewicht in kg"); lblGewicht.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblGewicht.setText("Gewicht"); txtGewicht = new Text(grpOptionaleDaten, SWT.BORDER); txtGewicht.setTextLimit(10); txtGewicht.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); Label lblMuttersprache = new Label(grpOptionaleDaten, SWT.NONE); lblMuttersprache.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblMuttersprache.setText("Muttersprache"); txtMuttersprache = new Text(grpOptionaleDaten, SWT.BORDER); txtMuttersprache.setTextLimit(60); txtMuttersprache.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); new Label(grpOptionaleDaten, SWT.NONE); new Label(grpOptionaleDaten, SWT.NONE); new Label(grpOptionaleDaten, SWT.NONE); initDataBindings(); if (commPartners != null && commPartners.size() > 0) { comboViewerTarget.setSelection(new StructuredSelection(commPartners.get(0))); if (preSelCommPartner != null) { for (IGDTCommunicationPartner gdtCommPartner : commPartners) { if (preSelCommPartner.equals(gdtCommPartner.getClass().getName())) { comboViewerTarget.setSelection(new StructuredSelection(gdtCommPartner)); } } } else if (targetIdSelection != null) { int idx = 0; for (IGDTCommunicationPartner igdtCommunicationPartner : commPartners) { if (igdtCommunicationPartner instanceof IGDTCommunicationPartnerProvider) { String id = ((IGDTCommunicationPartnerProvider) igdtCommunicationPartner).getId(); if (id.equals(targetIdSelection)) { comboViewerTarget.setSelection(new StructuredSelection(commPartners.get(idx))); break; } } idx++; } } } return area; }
From source file:at.medevit.menus.dialog.AddPersonDialog.java
License:Open Source License
/** * Create contents of the dialog.//from w w w. j a v a 2 s .co m * @param parent */ @Override protected Control createDialogArea(Composite parent) { setMessage("Add a new person to the system."); setTitle("Add person"); Composite area = (Composite) super.createDialogArea(parent); Composite container = new Composite(area, SWT.NONE); container.setLayout(new GridLayout(2, false)); container.setLayoutData(new GridData(GridData.FILL_BOTH)); txtFirstname = new Text(container, SWT.BORDER); txtFirstname.setMessage("firstname"); txtFirstname.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); txtLastname = new Text(container, SWT.BORDER); txtLastname.setMessage("lastname"); txtLastname.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); ComboViewer comboViewer = new ComboViewer(container, SWT.NONE); comboGender = comboViewer.getCombo(); comboGender.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); comboViewer.setContentProvider(ArrayContentProvider.getInstance()); comboViewer.setInput(Gender.VALUES); comboViewer.setSelection(new StructuredSelection(Gender.MALE)); new Label(container, SWT.NONE); return area; }
From source file:au.gov.ansto.bragg.kowari.exp.command.SimpleNDParameter.java
License:Open Source License
@Override public void createParameterUI(final Composite parent, final AbstractScanCommandView commandView, final FormToolkit toolkit) { GridLayoutFactory.swtDefaults().margins(0, 0).spacing(6, 4).numColumns(9).applyTo(parent); // GridLayoutFactory.swtDefaults().numColumns(6).applyTo(parent); Label dragLabel = toolkit.createLabel(parent, "\u2022"); dragLabel.setCursor(parent.getDisplay().getSystemCursor(SWT.CURSOR_HAND)); final ComboViewer scanVariableCombo = new ComboViewer(parent, SWT.READ_ONLY); scanVariableCombo.setContentProvider(new ArrayContentProvider()); scanVariableCombo.setLabelProvider(new LabelProvider()); scanVariableCombo.setSorter(new ViewerSorter()); scanVariableCombo.setInput(SicsBatchUIUtils.getSicsDrivableIds()); GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.TOP).hint(WIDTH_COMBO, SWT.DEFAULT) .applyTo(scanVariableCombo.getCombo()); // GridDataFactory.fillDefaults().grab(true, false).applyTo(scanVariableCombo.getCombo()); // GridDataFactory.swtDefaults().hint(WIDTH_COMBO, SWT.DEFAULT).applyTo(scanVariableCombo.getCombo()); addSelectionValidator(scanVariableCombo.getCombo(), ParameterValidator.notEmptyValidator); final Text startPositionText = toolkit.createText(parent, ""); // GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.TOP).hint(WIDTH_PARAMETER, SWT.DEFAULT).applyTo(startPositionText); // GridData data = new GridData(); // data.grabExcessHorizontalSpace = true; // data.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING; // data.heightHint = SWT.DEFAULT; // startPositionText.setLayoutData(data); GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.TOP).hint(WIDTH_PARAMETER_LONG, SWT.DEFAULT) .applyTo(startPositionText); addValidator(startPositionText, ParameterValidator.floatValidator); final Text finishPositionText = toolkit.createText(parent, ""); GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.TOP).hint(WIDTH_PARAMETER_LONG, SWT.DEFAULT) .applyTo(finishPositionText); addValidator(finishPositionText, ParameterValidator.floatValidator); final Text stepSizeBox = toolkit.createText(parent, ""); GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.TOP).hint(WIDTH_PARAMETER_LONG, SWT.DEFAULT) .applyTo(stepSizeBox);//from w w w. j a va 2 s. c om addValidator(stepSizeBox, ParameterValidator.floatValidator); final Text nostepsText = toolkit.createText(parent, ""); GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.TOP).hint(WIDTH_PARAMETER_LONG, SWT.DEFAULT) .applyTo(nostepsText); addValidator(nostepsText, ParameterValidator.integerValidator); final Button multiFileButton = toolkit.createButton(parent, "multiple_files", SWT.RADIO); GridDataFactory.swtDefaults().hint(80, SWT.DEFAULT).applyTo(multiFileButton); multiFileButton.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent arg0) { firePropertyChange("multiple files", null, true); } @Override public void widgetDefaultSelected(SelectionEvent arg0) { } }); startPositionText.addKeyListener(new KeyListener() { @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyPressed(KeyEvent arg0) { if (arg0.keyCode == SWT.KEYPAD_CR || arg0.keyCode == SWT.CR) finishPositionText.setFocus(); } }); finishPositionText.addKeyListener(new KeyListener() { @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyPressed(KeyEvent arg0) { if (arg0.keyCode == SWT.KEYPAD_CR || arg0.keyCode == SWT.CR) stepSizeBox.setFocus(); } }); stepSizeBox.addKeyListener(new KeyListener() { @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyPressed(KeyEvent arg0) { if (arg0.keyCode == SWT.KEYPAD_CR || arg0.keyCode == SWT.CR) { nostepsText.setFocus(); } } }); nostepsText.addKeyListener(new KeyListener() { @Override public void keyReleased(KeyEvent arg0) { } @Override public void keyPressed(KeyEvent arg0) { if (arg0.keyCode == SWT.KEYPAD_CR || arg0.keyCode == SWT.CR) { parent.setFocus(); nostepsText.setFocus(); } } }); Realm.runWithDefault(SWTObservables.getRealm(Display.getDefault()), new Runnable() { public void run() { DataBindingContext bindingContext = new DataBindingContext(); bindingContext.bindValue(ViewersObservables.observeSingleSelection(scanVariableCombo), BeansObservables.observeValue(getInstance(), "scanVariable"), new UpdateValueStrategy(), new UpdateValueStrategy()); bindingContext.bindValue(SWTObservables.observeText(startPositionText, SWT.FocusOut), BeansObservables.observeValue(getInstance(), "startPosition"), new UpdateValueStrategy(), new UpdateValueStrategy()); bindingContext.bindValue(SWTObservables.observeText(finishPositionText, SWT.FocusOut), BeansObservables.observeValue(getInstance(), "finishPosition"), new UpdateValueStrategy(), new UpdateValueStrategy()); bindingContext.bindValue(SWTObservables.observeText(stepSizeBox, SWT.FocusOut), BeansObservables.observeValue(getInstance(), "stepSize"), new UpdateValueStrategy(), new UpdateValueStrategy()); bindingContext.bindValue(SWTObservables.observeText(nostepsText, SWT.FocusOut), BeansObservables.observeValue(getInstance(), "numberOfPoints"), new UpdateValueStrategy(), new UpdateValueStrategy()); bindingContext.bindValue(SWTObservables.observeSelection(multiFileButton), BeansObservables.observeValue(getInstance(), "doCreateFile"), new UpdateValueStrategy(), new UpdateValueStrategy()); } }); final AbstractScanCommand command = commandView.getCommand(); final Button addButton = toolkit.createButton(parent, "", SWT.PUSH); GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.TOP).hint(18, 18).applyTo(addButton); try { addButton.setImage(SicsBatchUIUtils.getBatchEditorImage("ADD")); } catch (FileNotFoundException e2) { LoggerFactory.getLogger(this.getClass()).error("can not find ADD image", e2); } addButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { addNewParameter(command); commandView.refreshParameterComposite(); // notifyPropertyChanged(newCommand, null); } }); final Button removeButton = toolkit.createButton(parent, "", SWT.PUSH); GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.TOP).hint(18, 18).applyTo(removeButton); try { removeButton.setImage(SicsBatchUIUtils.getBatchEditorImage("REMOVE")); } catch (FileNotFoundException e1) { LoggerFactory.getLogger(this.getClass()).error("can not find REMOVE image", e1); } removeButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { removeParameter(command); commandView.refreshParameterComposite(); } }); // initDnD(command, this); // } // // private void initDnD(final AbstractScanCommand command, final AbstractScanParameter parameter) { int operations = DND.DROP_MOVE; DragSource dragSource = new DragSource(dragLabel, operations); LocalSelectionTransfer transferObject = LocalSelectionTransfer.getTransfer(); Transfer[] types = new Transfer[] { transferObject }; dragSource.setTransfer(types); final SimpleNDParameter child = this; dragSource.addDragListener(new DragSourceAdapter() { @Override public void dragFinished(DragSourceEvent event) { LocalSelectionTransfer.getTransfer().setSelection(null); } @Override public void dragSetData(DragSourceEvent event) { if (LocalSelectionTransfer.getTransfer().isSupportedType(event.dataType)) { DndTransferData transferData = new DndTransferData(); transferData.setParent(command); transferData.setChild(child); LocalSelectionTransfer.getTransfer().setSelection(new StructuredSelection(transferData)); } } }); }
From source file:au.gov.ansto.bragg.kowari.exp.command.SingleADParameter.java
License:Open Source License
@Override public void createParameterUI(Composite parent, final AbstractScanCommandView commandView, final FormToolkit toolkit) { GridLayoutFactory.swtDefaults().margins(0, 0).spacing(6, 4).numColumns(7).applyTo(parent); // GridLayoutFactory.swtDefaults().numColumns(6).applyTo(parent); final Label dragLabel = toolkit.createLabel(parent, "\u2022"); dragLabel.setCursor(parent.getDisplay().getSystemCursor(SWT.CURSOR_HAND)); final ComboViewer scanVariableCombo = new ComboViewer(parent, SWT.READ_ONLY); scanVariableCombo.setContentProvider(new ArrayContentProvider()); scanVariableCombo.setLabelProvider(new LabelProvider()); scanVariableCombo.setSorter(new ViewerSorter()); scanVariableCombo.setInput(SicsBatchUIUtils.getSicsDrivableIds()); GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.TOP).hint(WIDTH_COMBO, SWT.DEFAULT) .applyTo(scanVariableCombo.getCombo()); addSelectionValidator(scanVariableCombo.getCombo(), ParameterValidator.notEmptyValidator); // GridDataFactory.fillDefaults().grab(true, false).applyTo(scanVariableCombo.getCombo()); // GridDataFactory.swtDefaults().hint(WIDTH_COMBO, SWT.DEFAULT).applyTo(scanVariableCombo.getCombo()); final Text startPositionText = toolkit.createText(parent, ""); // GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.TOP).hint(WIDTH_PARAMETER, SWT.DEFAULT).applyTo(startPositionText); // GridData data = new GridData(); // data.grabExcessHorizontalSpace = true; // data.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING; // data.heightHint = SWT.DEFAULT; // startPositionText.setLayoutData(data); GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.TOP).hint(WIDTH_PARAMETER_LONG, SWT.DEFAULT) .applyTo(startPositionText); addValidator(startPositionText, ParameterValidator.floatValidator); final Text finishPositionText = toolkit.createText(parent, ""); GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.TOP).hint(WIDTH_PARAMETER_LONG, SWT.DEFAULT) .applyTo(finishPositionText); addValidator(finishPositionText, ParameterValidator.floatValidator); final Text stepSizeText = toolkit.createText(parent, ""); GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.TOP).hint(WIDTH_PARAMETER_LONG, SWT.DEFAULT) .applyTo(stepSizeText);/*from w w w .j ava 2 s.c om*/ addValidator(stepSizeText, ParameterValidator.floatValidator); Realm.runWithDefault(SWTObservables.getRealm(Display.getDefault()), new Runnable() { public void run() { DataBindingContext bindingContext = new DataBindingContext(); bindingContext.bindValue(ViewersObservables.observeSingleSelection(scanVariableCombo), BeansObservables.observeValue(getInstance(), "scanVariable"), new UpdateValueStrategy(), new UpdateValueStrategy()); bindingContext.bindValue(SWTObservables.observeText(startPositionText, SWT.Modify), BeansObservables.observeValue(getInstance(), "startPosition"), new UpdateValueStrategy() { /* (non-Javadoc) * @see org.eclipse.core.databinding.UpdateValueStrategy#convert(java.lang.Object) */ @Override public Object convert(Object value) { if ("*".equals(String.valueOf(value))) return Float.NaN; else return super.convert(value); } @Override public IStatus validateAfterGet(Object value) { if ("*".equals(value)) { return Status.OK_STATUS; } return super.validateAfterGet(value); } }, new UpdateValueStrategy() { /* (non-Javadoc) * @see org.eclipse.core.databinding.UpdateValueStrategy#convert(java.lang.Object) */ @Override public Object convert(Object value) { if (value instanceof Float) if (Float.isNaN((Float) value)) return "*"; else super.convert(value); return super.convert(value); } @Override public IStatus validateAfterGet(Object value) { if ("*".equals(value)) { return Status.OK_STATUS; } return super.validateAfterGet(value); } }); bindingContext.bindValue(SWTObservables.observeText(finishPositionText, SWT.Modify), BeansObservables.observeValue(getInstance(), "finishPosition"), new UpdateValueStrategy() { /* (non-Javadoc) * @see org.eclipse.core.databinding.UpdateValueStrategy#convert(java.lang.Object) */ @Override public Object convert(Object value) { if ("*".equals(String.valueOf(value))) return Float.NaN; else return super.convert(value); } }, new UpdateValueStrategy() { /* (non-Javadoc) * @see org.eclipse.core.databinding.UpdateValueStrategy#convert(java.lang.Object) */ @Override public Object convert(Object value) { if (value instanceof Float) if (Float.isNaN((Float) value)) return "*"; else super.convert(value); return super.convert(value); } }); bindingContext.bindValue(SWTObservables.observeText(stepSizeText, SWT.Modify), BeansObservables.observeValue(getInstance(), "stepSize"), new UpdateValueStrategy(), new UpdateValueStrategy()); } }); final AbstractScanCommand command = commandView.getCommand(); Button addButton = toolkit.createButton(parent, "", SWT.PUSH); GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.TOP).hint(18, 18).applyTo(addButton); try { addButton.setImage(SicsBatchUIUtils.getBatchEditorImage("ADD")); } catch (FileNotFoundException e2) { LoggerFactory.getLogger(this.getClass()).error("can not find ADD image", e2); } addButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { addNewParameter(command); commandView.refreshParameterComposite(); // notifyPropertyChanged(newCommand, null); } }); Button removeButton = toolkit.createButton(parent, "", SWT.PUSH); GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.TOP).hint(18, 18).applyTo(removeButton); try { removeButton.setImage(SicsBatchUIUtils.getBatchEditorImage("REMOVE")); } catch (FileNotFoundException e1) { LoggerFactory.getLogger(this.getClass()).error("can not find REMOVE image", e1); } removeButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { removeParameter(command); commandView.refreshParameterComposite(); } }); DragSource dragSource = new DragSource(dragLabel, DND.DROP_MOVE); dragSource.setTransfer(new Transfer[] { LocalSelectionTransfer.getTransfer() }); final SingleADParameter child = this; dragSource.addDragListener(new DragSourceAdapter() { @Override public void dragFinished(DragSourceEvent event) { LocalSelectionTransfer.getTransfer().setSelection(null); } @Override public void dragSetData(DragSourceEvent event) { if (LocalSelectionTransfer.getTransfer().isSupportedType(event.dataType)) { DndTransferData transferData = new DndTransferData(); transferData.setParent(parentParameter); transferData.setChild(child); LocalSelectionTransfer.getTransfer().setSelection(new StructuredSelection(transferData)); } } }); }
From source file:au.gov.ansto.bragg.kowari.exp.command.SinglePositionParameter.java
License:Open Source License
@Override public void createParameterUI(Composite parent, final AbstractScanCommandView commandView, final FormToolkit toolkit) { GridLayoutFactory.swtDefaults().margins(0, 0).spacing(6, 4).numColumns(4).applyTo(parent); // GridLayoutFactory.swtDefaults().numColumns(6).applyTo(parent); final ComboViewer scanVariableCombo = new ComboViewer(parent, SWT.READ_ONLY); scanVariableCombo.setContentProvider(new ArrayContentProvider()); scanVariableCombo.setLabelProvider(new LabelProvider()); scanVariableCombo.setSorter(new ViewerSorter()); scanVariableCombo.setInput(SicsBatchUIUtils.getSicsDrivableIds()); GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.TOP).hint(WIDTH_COMBO, SWT.DEFAULT) .applyTo(scanVariableCombo.getCombo()); // GridDataFactory.fillDefaults().grab(true, false).applyTo(scanVariableCombo.getCombo()); // GridDataFactory.swtDefaults().hint(WIDTH_COMBO, SWT.DEFAULT).applyTo(scanVariableCombo.getCombo()); final Text positionText = toolkit.createText(parent, ""); // GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.TOP).hint(WIDTH_PARAMETER, SWT.DEFAULT).applyTo(startPositionText); // GridData data = new GridData(); // data.grabExcessHorizontalSpace = true; // data.verticalAlignment = GridData.VERTICAL_ALIGN_BEGINNING; // data.heightHint = SWT.DEFAULT; // startPositionText.setLayoutData(data); GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.TOP).hint(WIDTH_PARAMETER_LONG, SWT.DEFAULT) .applyTo(positionText);//from w ww . j a va 2 s. com addValidator(positionText, ParameterValidator.floatValidator); Realm.runWithDefault(SWTObservables.getRealm(Display.getDefault()), new Runnable() { public void run() { DataBindingContext bindingContext = new DataBindingContext(); bindingContext.bindValue(ViewersObservables.observeSingleSelection(scanVariableCombo), BeansObservables.observeValue(getInstance(), "scanVariable"), new UpdateValueStrategy(), new UpdateValueStrategy()); bindingContext.bindValue(SWTObservables.observeText(positionText, SWT.Modify), BeansObservables.observeValue(getInstance(), "position"), new UpdateValueStrategy(), new UpdateValueStrategy()); } }); final AbstractScanCommand command = commandView.getCommand(); Button addButton = toolkit.createButton(parent, "", SWT.PUSH); GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.TOP).hint(18, 18).applyTo(addButton); try { addButton.setImage(SicsBatchUIUtils.getBatchEditorImage("ADD")); } catch (FileNotFoundException e2) { LoggerFactory.getLogger(this.getClass()).error("can not find ADD image", e2); } addButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { addNewParameter(command); commandView.refreshParameterComposite(); // notifyPropertyChanged(newCommand, null); } }); Button removeButton = toolkit.createButton(parent, "", SWT.PUSH); GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.TOP).hint(18, 18).applyTo(removeButton); try { removeButton.setImage(SicsBatchUIUtils.getBatchEditorImage("REMOVE")); } catch (FileNotFoundException e1) { LoggerFactory.getLogger(this.getClass()).error("can not find REMOVE image", e1); } removeButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { removeParameter(command); commandView.refreshParameterComposite(); } }); }
From source file:au.gov.ansto.bragg.kowari.exp.commandView.AdvancedScanCommandView.java
License:Open Source License
@Override protected void createPartControl(Composite parent, final AbstractScanCommand command) { super.createPartControl(parent, command); GridLayoutFactory.swtDefaults().numColumns(3).applyTo(parent); // Label titleLabel = getToolkit().createLabel(parent, command.getCommandName()); // titleLabel.setFont(new Font(titleLabel.getFont().getDevice(), new FontData[]{new FontData("Courier New", 10, SWT.BOLD)})); // GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.TOP).indent(0, 12).applyTo(titleLabel); // GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.TOP).applyTo(titleLabel); parameterComposite = getToolkit().createComposite(parent); GridLayoutFactory.swtDefaults().margins(0, 0).numColumns(5).applyTo(parameterComposite); GridDataFactory.swtDefaults().indent(2, 0).align(SWT.BEGINNING, SWT.TOP).applyTo(parameterComposite); if (command.getParameterList().size() == 0) { AdvancedParameter parameter = new AdvancedParameter(); // parameter.setScanVariable("sx"); command.insertParameter(parameter); }//from w w w. j a va2s. c om // GridLayoutFactory.swtDefaults().spacing(3, 3).applyTo(parameterComposite); for (AbstractScanParameter parameter : command.getParameterList()) { parameter.createParameterUI(parameterComposite, this, getToolkit()); } final ComboViewer modeCombo = new ComboViewer(parent, SWT.READ_ONLY); modeCombo.setContentProvider(new ArrayContentProvider()); modeCombo.setLabelProvider(new LabelProvider()); modeCombo.setSorter(new ViewerSorter()); modeCombo.setInput(new String[] { "time", "count" }); GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.TOP).indent(0, 10) .hint(AbstractScanParameter.WIDTH_PARAMETER_SHORT, SWT.DEFAULT).applyTo(modeCombo.getCombo()); final Text presetText = getToolkit().createText(parent, ""); // GridDataFactory.fillDefaults().align(SWT.CENTER, SWT.CENTER).applyTo(presetText); // GridDataFactory.fillDefaults().grab(true, false).applyTo(presetText); GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.TOP).indent(0, 10) .hint(AbstractScanParameter.WIDTH_PARAMETER_LONG, SWT.DEFAULT).applyTo(presetText); addValidator(presetText, ParameterValidator.floatValidator); Realm.runWithDefault(SWTObservables.getRealm(Display.getDefault()), new Runnable() { public void run() { DataBindingContext bindingContext = new DataBindingContext(); bindingContext.bindValue(ViewersObservables.observeSingleSelection(modeCombo), BeansObservables.observeValue(command, "scan_mode"), new UpdateValueStrategy(), new UpdateValueStrategy()); bindingContext.bindValue(SWTObservables.observeText(presetText, SWT.Modify), BeansObservables.observeValue(command, "preset"), new UpdateValueStrategy(), new UpdateValueStrategy()); } }); // DropTarget dropTarget = new DropTarget(parameterComposite, DND.DROP_MOVE); // dropTarget.setTransfer(new Transfer[]{LocalSelectionTransfer.getTransfer()}); // dropTarget.addDropListener(new DropTargetAdapter(){ // @Override // public void drop(DropTargetEvent event) { // if (event.data instanceof IStructuredSelection) { // DndTransferData transferData = (DndTransferData) ( // (StructuredSelection) event.data).getFirstElement(); // Object parent = transferData.getParent(); // Object child = transferData.getChild(); // if (parent == command){ // Point relativePoint = parameterComposite.toControl( // new Point(event.x, event.y)); // int index = 0; // for (Control control : parameterComposite.getChildren()){ // if (control instanceof Group){ // if (relativePoint.y < (control.getBounds().y // + control.getBounds().height)) { // break; // } // index++; // } // } // if (child instanceof AdvancedParameter) { // AdvancedParameter parameter = (AdvancedParameter) child; // int currentIndex = command.indexOfParameter(parameter); // if (currentIndex == index) { // return; // } // command.removeParameter(parameter); // command.insertParameter(index, parameter); // refreshParameterComposite(); // } // } // } // } // }); }