List of usage examples for org.eclipse.jface.fieldassist IContentProposalListener IContentProposalListener
IContentProposalListener
From source file:at.medevit.elexis.impfplan.ui.dialogs.SupplementVaccinationDialog.java
License:Open Source License
/** * Create contents of the dialog./*ww w .jav a2 s . co m*/ * * @param parent */ @Override protected Control createDialogArea(Composite parent) { setTitle("Impfung nachtragen"); setTitleImage( ResourceManager.getPluginImage("at.medevit.elexis.impfplan.ui", "rsc/icons/vaccination_logo.png")); Patient selectedPatient = ElexisEventDispatcher.getSelectedPatient(); setMessage(pat.getLabel()); 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)); Group mainGroup = new Group(container, SWT.NONE); mainGroup.setFont(SWTResourceManager.getFont("Noto Sans", 9, SWT.BOLD)); mainGroup.setText("Pflicht Angaben"); GridLayout gd_MainGroup = new GridLayout(2, false); mainGroup.setLayout(gd_MainGroup); mainGroup.setLayoutData(new GridData(GridData.FILL_BOTH)); Label lblVerabreichungsdatum = new Label(mainGroup, SWT.NONE); lblVerabreichungsdatum.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblVerabreichungsdatum.setText("Datum"); dateOfAdministration = new DateTime(mainGroup, SWT.BORDER | SWT.DROP_DOWN); dateOfAdministration.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { selDate.set(dateOfAdministration.getYear(), dateOfAdministration.getMonth(), dateOfAdministration.getDay()); if (selDate.isBefore(patBDay)) { SWTHelper.showInfo("Patient noch nicht geboren", "Das von Ihnen gewhlte Datum liegt vor der Geburt des Patienten."); dateOfAdministration.setYear(patBDay.get(TimeTool.YEAR)); dateOfAdministration.setMonth(patBDay.get(TimeTool.MONTH)); dateOfAdministration.setDay(patBDay.get(TimeTool.DAY_OF_MONTH)); } } }); { // article name Label lblArtikelname = new Label(mainGroup, SWT.NONE); lblArtikelname.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblArtikelname.setText("Artikelname"); txtArticleName = new Text(mainGroup, SWT.BORDER); txtArticleName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); txtArticleName.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { articleString = txtArticleName.getText(); } }); PersistentObjectProposalProvider<ArtikelstammItem> aopp = new PersistentObjectProposalProvider<>( ArtikelstammItem.class, ArtikelstammItem.FLD_ATC, Query.LIKE, "J07%"); ContentProposalAdapter articleProposalAdapter = new ContentProposalAdapter(txtArticleName, new TextContentAdapter(), aopp, null, null); articleProposalAdapter.addContentProposalListener(new IContentProposalListener() { @SuppressWarnings("unchecked") @Override public void proposalAccepted(IContentProposal proposal) { PersistentObjectContentProposal<ArtikelstammItem> prop = (PersistentObjectContentProposal<ArtikelstammItem>) proposal; txtArticleName.setText(prop.getLabel()); articleString = prop.getPersistentObject().storeToString(); /** * could be useful to define vacc. against at some point, but not needed in the * current version */ // txtArticleEAN.setText(prop.getPersistentObject().getEAN()); // txtAtcCode.setText(prop.getPersistentObject().getATCCode()); } }); } new Label(container, SWT.NONE); Group optionalGroup = new Group(container, SWT.NONE); optionalGroup.setFont(SWTResourceManager.getFont("Noto Sans", 9, SWT.BOLD)); optionalGroup.setText("Optionale Angaben"); optionalGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); optionalGroup.setLayout(new GridLayout(2, false)); { // administrating contact Label lblAdministratingContact = new Label(optionalGroup, SWT.NONE); lblAdministratingContact.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblAdministratingContact.setText("Nachtrag von"); txtAdministrator = new Text(optionalGroup, SWT.BORDER); administratorString = mandant.storeToString(); txtAdministrator.setText(mandant.getMandantLabel()); txtAdministrator.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { administratorString = txtAdministrator.getText(); } }); txtAdministrator.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); PersistentObjectProposalProvider<Mandant> mopp = new PersistentObjectProposalProvider<Mandant>( Mandant.class) { @Override public String getLabelForObject(Mandant a) { return a.getMandantLabel(); } }; ContentProposalAdapter mandatorProposalAdapter = new ContentProposalAdapter(txtAdministrator, new TextContentAdapter(), mopp, null, null); mandatorProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); mandatorProposalAdapter.addContentProposalListener(new IContentProposalListener() { @Override public void proposalAccepted(IContentProposal proposal) { PersistentObjectContentProposal<Mandant> prop = (PersistentObjectContentProposal<Mandant>) proposal; administratorString = prop.getPersistentObject().storeToString(); } }); Label lblLotNo = new Label(optionalGroup, SWT.NONE); lblLotNo.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); lblLotNo.setText("Lot-Nr"); txtLotNo = new Text(optionalGroup, SWT.BORDER); txtLotNo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); } /** * could be useful to define vacc. against at some point, but not needed in the current * version */ // Label lblArtikelEan = new Label(optionalGroup, SWT.NONE); // lblArtikelEan.setSize(60, 15); // lblArtikelEan.setText("Artikel EAN"); // // txtArticleEAN = new Text(optionalGroup, SWT.BORDER); // txtArticleEAN.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); // txtArticleEAN.setSize(348, 21); // // Label lblAtccode = new Label(optionalGroup, SWT.NONE); // lblAtccode.setSize(56, 15); // lblAtccode.setText("ATC-Code"); // // txtAtcCode = new Text(optionalGroup, SWT.BORDER); // txtAtcCode.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); // txtAtcCode.setSize(314, 21); Group expiredGroup = new Group(container, SWT.NONE); expiredGroup.setFont(SWTResourceManager.getFont("Noto Sans", 9, SWT.BOLD)); expiredGroup.setText("Bei nicht mehr erhltlichen Impfstoffen"); expiredGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); expiredGroup.setLayout(new GridLayout(2, false)); { Label lblVaccAgainst = new Label(expiredGroup, SWT.NONE); lblVaccAgainst.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false, 1, 1)); lblVaccAgainst.setText("Impfung gegen Krankheit(en)"); vect = new VaccinationEffectCheckboxTreeViewer(container, SWT.BORDER, vaccAgainst); } return area; }
From source file:bndtools.editor.contents.GeneralInfoPart.java
License:Open Source License
private void createSection(Section section, FormToolkit toolkit) { section.setText("Basic Information"); KeyStroke assistKeyStroke = null; try {/*www . j a va2 s. com*/ assistKeyStroke = KeyStroke.getInstance("Ctrl+Space"); } catch (ParseException x) { // Ignore } FieldDecoration contentAssistDecoration = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); Composite composite = toolkit.createComposite(section); section.setClient(composite); toolkit.createLabel(composite, "Version:"); txtVersion = toolkit.createText(composite, "", SWT.BORDER); ToolTips.setupMessageAndToolTipFromSyntax(txtVersion, Constants.BUNDLE_VERSION); Hyperlink linkActivator = toolkit.createHyperlink(composite, "Activator:", SWT.NONE); txtActivator = toolkit.createText(composite, "", SWT.BORDER); ToolTips.setupMessageAndToolTipFromSyntax(txtActivator, Constants.BUNDLE_ACTIVATOR); toolkit.createLabel(composite, "Declarative Services:"); cmbComponents = new Combo(composite, SWT.READ_ONLY); // Content Proposal for the Activator field ContentProposalAdapter activatorProposalAdapter = null; ActivatorClassProposalProvider proposalProvider = new ActivatorClassProposalProvider(); activatorProposalAdapter = new ContentProposalAdapter(txtActivator, new TextContentAdapter(), proposalProvider, assistKeyStroke, UIConstants.autoActivationCharacters()); activatorProposalAdapter.addContentProposalListener(proposalProvider); activatorProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); activatorProposalAdapter.setLabelProvider(new JavaContentProposalLabelProvider()); activatorProposalAdapter.setAutoActivationDelay(1000); // Decorator for the Activator field ControlDecoration decorActivator = new ControlDecoration(txtActivator, SWT.LEFT | SWT.CENTER, composite); decorActivator.setImage(contentAssistDecoration.getImage()); decorActivator.setMarginWidth(3); if (assistKeyStroke == null) { decorActivator.setDescriptionText("Content Assist is available. Start typing to activate"); } else { decorActivator.setDescriptionText( MessageFormat.format("Content Assist is available. Press {0} or start typing to activate", assistKeyStroke.format())); } decorActivator.setShowOnlyOnFocus(true); decorActivator.setShowHover(true); // Decorator for the Components combo ControlDecoration decorComponents = new ControlDecoration(cmbComponents, SWT.LEFT | SWT.CENTER, composite); decorComponents.setImage(FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_INFORMATION).getImage()); decorComponents.setMarginWidth(3); decorComponents.setDescriptionText("Use Java annotations to detect Declarative Service Components."); decorComponents.setShowOnlyOnFocus(false); decorComponents.setShowHover(true); // Listeners txtVersion.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { lock.ifNotModifying(new Runnable() { @Override public void run() { addDirtyProperty(Constants.BUNDLE_VERSION); } }); } }); cmbComponents.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { lock.ifNotModifying(new Runnable() { @Override public void run() { ComponentChoice old = componentChoice; int index = cmbComponents.getSelectionIndex(); if (index >= 0 && index < ComponentChoice.values().length) { componentChoice = ComponentChoice.values()[cmbComponents.getSelectionIndex()]; if (old != componentChoice) { addDirtyProperty(aQute.bnd.osgi.Constants.SERVICE_COMPONENT); addDirtyProperty(aQute.bnd.osgi.Constants.DSANNOTATIONS); if (old == null) { cmbComponents.remove(ComponentChoice.values().length); } } } } }); } }); txtActivator.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent ev) { lock.ifNotModifying(new Runnable() { @Override public void run() { addDirtyProperty(Constants.BUNDLE_ACTIVATOR); } }); } }); linkActivator.addHyperlinkListener(new HyperlinkAdapter() { @Override public void linkActivated(HyperlinkEvent ev) { String activatorClassName = txtActivator.getText(); if (activatorClassName != null && activatorClassName.length() > 0) { try { IJavaProject javaProject = getJavaProject(); if (javaProject == null) return; IType activatorType = javaProject.findType(activatorClassName); if (activatorType != null) { JavaUI.openInEditor(activatorType, true, true); } } catch (PartInitException e) { ErrorDialog.openError(getManagedForm().getForm().getShell(), "Error", null, new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, MessageFormat.format("Error opening an editor for activator class '{0}'.", activatorClassName), e)); } catch (JavaModelException e) { ErrorDialog.openError(getManagedForm().getForm().getShell(), "Error", null, new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, MessageFormat.format( "Error searching for activator class '{0}'.", activatorClassName), e)); } } } }); activatorProposalAdapter.addContentProposalListener(new IContentProposalListener() { @Override public void proposalAccepted(IContentProposal proposal) { if (proposal instanceof JavaContentProposal) { String selectedPackageName = ((JavaContentProposal) proposal).getPackageName(); if (!model.isIncludedPackage(selectedPackageName)) { model.addPrivatePackage(selectedPackageName); } } } }); // Layout GridLayout layout = new GridLayout(2, false); layout.horizontalSpacing = 15; composite.setLayout(layout); GridData gd = new GridData(SWT.FILL, SWT.TOP, true, false); txtVersion.setLayoutData(gd); txtActivator.setLayoutData(gd); cmbComponents.setLayoutData(gd); }
From source file:bndtools.editor.pkgpatterns.PkgPatternsDetailsPage.java
License:Open Source License
public void createContents(Composite parent) { FormToolkit toolkit = getManagedForm().getToolkit(); FieldDecoration assistDecor = FieldDecorationRegistry.getDefault() .getFieldDecoration(FieldDecorationRegistry.DEC_CONTENT_PROPOSAL); KeyStroke assistKeyStroke = null; try {// ww w. j av a 2s . c o m assistKeyStroke = KeyStroke.getInstance("Ctrl+Space"); } catch (ParseException x) { // Ignore } Section mainSection = toolkit.createSection(parent, Section.TITLE_BAR); mainSection.setText(title); mainComposite = toolkit.createComposite(mainSection); mainSection.setClient(mainComposite); toolkit.createLabel(mainComposite, "Pattern:"); txtName = toolkit.createText(mainComposite, "", SWT.BORDER); ControlDecoration decPattern = new ControlDecoration(txtName, SWT.LEFT | SWT.TOP, mainComposite); decPattern.setImage(assistDecor.getImage()); decPattern.setDescriptionText(MessageFormat.format( "Content assist is available. Press {0} or start typing to activate", assistKeyStroke.format())); decPattern.setShowHover(true); decPattern.setShowOnlyOnFocus(true); PkgPatternsProposalProvider proposalProvider = new PkgPatternsProposalProvider( new FormPartJavaSearchContext(this)); ContentProposalAdapter patternProposalAdapter = new ContentProposalAdapter(txtName, new TextContentAdapter(), proposalProvider, assistKeyStroke, UIConstants.autoActivationCharacters()); patternProposalAdapter.addContentProposalListener(proposalProvider); patternProposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_IGNORE); patternProposalAdapter.setAutoActivationDelay(1000); patternProposalAdapter.setLabelProvider(new PkgPatternProposalLabelProvider()); patternProposalAdapter.addContentProposalListener(new IContentProposalListener() { public void proposalAccepted(IContentProposal proposal) { PkgPatternProposal patternProposal = (PkgPatternProposal) proposal; String toInsert = patternProposal.getContent(); int currentPos = txtName.getCaretPosition(); txtName.setSelection(patternProposal.getReplaceFromPos(), currentPos); txtName.insert(toInsert); txtName.setSelection(patternProposal.getCursorPosition()); } }); toolkit.createLabel(mainComposite, "Version:"); txtVersion = toolkit.createText(mainComposite, "", SWT.BORDER); /* * Section attribsSection = toolkit.createSection(parent, Section.TITLE_BAR | Section.TWISTIE); * attribsSection.setText("Extra Attributes"); Composite attribsComposite = * toolkit.createComposite(attribsSection); */ // Listeners txtName.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (!modifyLock.isUnderModification()) { if (selectedClauses.size() == 1) { selectedClauses.get(0).setName(txtName.getText()); if (listPart != null) { listPart.updateLabels(selectedClauses); listPart.validate(); } markDirty(); } } } }); txtVersion.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { if (!modifyLock.isUnderModification()) { String text = txtVersion.getText(); if (text.length() == 0) text = null; for (HeaderClause clause : selectedClauses) { clause.getAttribs().put(Constants.VERSION_ATTRIBUTE, text); } if (listPart != null) { listPart.updateLabels(selectedClauses); listPart.validate(); } markDirty(); } } }); // Layout GridData gd; parent.setLayout(new GridLayout()); mainSection.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); mainComposite.setLayout(new GridLayout(2, false)); gd = new GridData(SWT.FILL, SWT.TOP, true, false); gd.horizontalIndent = 5; gd.widthHint = 100; txtName.setLayoutData(gd); gd = new GridData(SWT.FILL, SWT.TOP, true, false); gd.horizontalIndent = 5; gd.widthHint = 100; txtVersion.setLayoutData(gd); }
From source file:ch.elexis.core.ui.contacts.controls.StammDatenComposite.java
License:Open Source License
public StammDatenComposite(Composite parent, int style) { super(parent, style); decorator = PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator(); tdlp = new TableDecoratingLabelProvider( new ContactSelectorObservableMapLabelProvider(new ObservableMap[] {}), decorator); setLayout(new GridLayout(6, false)); { // HEADER//from w w w. j a v a 2s . c o m compositeHeader = new Composite(this, SWT.NONE); compositeHeader.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 6, 1)); compositeHeader.setLayout(new GridLayout(3, false)); lblContactType = new Label(compositeHeader, SWT.NONE); lblHeadline = new Label(compositeHeader, SWT.NONE); lblHeadline.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); lblCode = new Label(compositeHeader, SWT.NONE); GridData gd_lblCode = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_lblCode.widthHint = 40; lblCode.setLayoutData(gd_lblCode); } { // TYPE_PERSON - Title prefix txtTitleFront = new Text(this, SWT.BORDER); gd_txtTitleFront = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_txtTitleFront.widthHint = 60; txtTitleFront.setLayoutData(gd_txtTitleFront); txtTitleFront.setMessage("Titel"); ContentProposalAdapter cpaTitleFront = new ContentProposalAdapter(txtTitleFront, new TextContentAdapter(), new TitleProposalProvider(TitleProposalProvider.TITLE_POSITION_PREFIX), null, null); cpaTitleFront.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); } txtFirstName = new Text(this, SWT.BORDER); txtFirstName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); txtFamilyName = new Text(this, SWT.BORDER); txtFamilyName.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); { // TYPE_PERSON - Title back txtTitleBack = new Text(this, SWT.BORDER); gd_txtTitleBack = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1); gd_txtTitleBack.widthHint = 60; txtTitleBack.setLayoutData(gd_txtTitleBack); txtTitleBack.setMessage("Titel"); ContentProposalAdapter cpaTitleBack = new ContentProposalAdapter(txtTitleBack, new TextContentAdapter(), new TitleProposalProvider(TitleProposalProvider.TITLE_POSITION_SUFFIX), null, null); cpaTitleBack.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); } { // TYPE_PERSON - Sex comboViewerSex = new ComboViewer(this, SWT.NONE); gd_comboSex = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1); comboViewerSex.getCombo().setLayoutData(gd_comboSex); comboViewerSex.setContentProvider(ArrayContentProvider.getInstance()); comboViewerSex.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { switch ((ContactGender) element) { case FEMALE: return "W"; case MALE: return "M"; case UNDEFINED: return "X"; default: return "?"; } } }); comboViewerSex.setInput(ContactGender.values()); } { // TYPE_PERSON - Birthday dateTimeDob = new DateTime(this, SWT.BORDER | SWT.LONG); gd_dateTimeDob = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1); dateTimeDob.setLayoutData(gd_dateTimeDob); } Group grpAddress = new Group(this, SWT.NONE); grpAddress.setLayout(new GridLayout(3, false)); grpAddress.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 7, 1)); grpAddress.setText("Adresse"); { // TODO: Default selection according to current Mandant's country comboViewerCountry = new ComboViewer(grpAddress, SWT.NONE); GridData gd_combo_1 = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1); gd_combo_1.widthHint = 55; comboViewerCountry.getCombo().setLayoutData(gd_combo_1); comboViewerCountry.setContentProvider(ArrayContentProvider.getInstance()); comboViewerCountry.setInput(Country.values()); comboViewerCountry.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { Country selCountry = (Country) ((StructuredSelection) event.getSelection()).getFirstElement(); if (selCountry == Country.NDF) { comboViewerCountry.getCombo() .setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_RED)); ContactGeonames.setCountry(null); } else { comboViewerCountry.getCombo() .setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK)); ContactGeonames.setCountry(selCountry); } } }); } { txtCity = new Text(grpAddress, SWT.BORDER); txtCity.setMessage("Ortschaft"); txtCity.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); ContentProposalAdapter cpaCity = new ContentProposalAdapter(txtCity, new TextContentAdapter(), cityIP, null, null); cpaCity.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); cpaCity.addContentProposalListener(new IContentProposalListener() { @Override public void proposalAccepted(IContentProposal proposal) { txtZIP.setText(cityIP.findZipForCityName(proposal.getContent())); } }); } { // ZIP txtZIP = new Text(grpAddress, SWT.BORDER); txtZIP.setMessage("PLZ"); txtZIP.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1)); txtZIP.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { String currZip = ((Text) e.widget).getText(); if (currZip == null || currZip.length() < 4) return; streetIP.setZip(currZip); } }); ContentProposalAdapter cpaZip = new ContentProposalAdapter(txtZIP, new TextContentAdapter(), zipIP, null, null); cpaZip.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); cpaZip.addContentProposalListener(new IContentProposalListener() { @Override public void proposalAccepted(IContentProposal proposal) { txtCity.setText(zipIP.findCityNameForZip(proposal.getContent())); } }); } Label lblImageCountry = new Label(grpAddress, SWT.NONE); GridData gd_lblImageCountry = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1); gd_lblImageCountry.widthHint = 55; lblImageCountry.setLayoutData(gd_lblImageCountry); { txtStreet = new Text(grpAddress, SWT.BORDER); txtStreet.setMessage("Strasse, Hausnummer"); txtStreet.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); ContentProposalAdapter cpaStreet = new ContentProposalAdapter(txtStreet, new TextContentAdapter(), streetIP, null, null); cpaStreet.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); } Group grpKontaktdaten = new Group(this, SWT.NONE); grpKontaktdaten.setText("Kontaktdaten"); grpKontaktdaten.setLayout(new GridLayout(4, false)); grpKontaktdaten.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 7, 1)); Label lblImgPhone = new Label(grpKontaktdaten, SWT.NONE); lblImgPhone.setImage(Images.IMG_TELEPHONE.getImage()); lblImgPhone.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); txtTelefon = new Text(grpKontaktdaten, SWT.BORDER); txtTelefon.setMessage("Telefon-Nummer"); txtTelefon.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); txtTelefon.addFocusListener(preDialFocuListener); Label lblImgePhone2 = new Label(grpKontaktdaten, SWT.NONE); lblImgePhone2.setImage(Images.IMG_TELEPHONE.getImage()); lblImgePhone2.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); txtTelefon2 = new Text(grpKontaktdaten, SWT.BORDER); txtTelefon2.setMessage("Telefon-Nummer"); txtTelefon2.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); txtTelefon2.addFocusListener(preDialFocuListener); Label lblImgMobilePhone = new Label(grpKontaktdaten, SWT.NONE); lblImgMobilePhone.setImage(Images.IMG_MOBILEPHONE.getImage()); lblImgMobilePhone.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); txtMobil = new Text(grpKontaktdaten, SWT.BORDER); txtMobil.setMessage("Handy-Nummer"); txtMobil.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); txtMobil.addFocusListener(preDialFocuListener); Label lblImgFax = new Label(grpKontaktdaten, SWT.NONE); lblImgFax.setImage(Images.IMG_FAX.getImage()); lblImgFax.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); txtFax = new Text(grpKontaktdaten, SWT.BORDER); txtFax.setMessage("Fax-Nummer"); txtFax.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); txtFax.addFocusListener(preDialFocuListener); btnEmail = new Button(grpKontaktdaten, SWT.FLAT); btnEmail.setImage(Images.IMG_MAIL.getImage()); btnEmail.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); btnEmail.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { try { URI uriMailTo = new URI("mailto", txtEmail.getText(), null); Desktop.getDesktop().mail(uriMailTo); } catch (URISyntaxException | IOException ex) { log.warn("Error opening URI", ex); } } }); txtEmail = new Text(grpKontaktdaten, SWT.BORDER); txtEmail.setMessage("E-Mail Adresse"); txtEmail.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); btnWebsite = new Button(grpKontaktdaten, SWT.FLAT); btnWebsite.setImage(Images.IMG_WEB.getImage()); btnWebsite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1)); btnWebsite.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { try { URI uriURL = new URI(txtWebsite.getText()); if (!uriURL.isAbsolute()) { uriURL = new URI("http://" + txtWebsite.getText()); } Desktop.getDesktop().browse(uriURL); } catch (URISyntaxException | IOException ex) { log.warn("Error opening URI", ex); } } }); txtWebsite = new Text(grpKontaktdaten, SWT.BORDER); txtWebsite.setMessage("Webseite"); txtWebsite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1)); { // Notes Group grpNotes = new Group(this, SWT.NONE); grpNotes.setLayout(new GridLayout(1, false)); grpNotes.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 7, 1)); grpNotes.setText("Notizen"); txtNotes = new Text(grpNotes, SWT.V_SCROLL | SWT.WRAP); GridData gd_txtNotes = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1); gd_txtNotes.heightHint = (int) (5 * txtNotes.getFont().getFontData()[0].height); txtNotes.setLayoutData(gd_txtNotes); } initDataBindings(); }
From source file:com.rcpcompany.uibindings.internal.handlers.QuickFixHandler.java
License:Open Source License
@Override public Object execute(ExecutionEvent event) throws ExecutionException { // LogUtils.debug(this, "hello"); if (Activator.getDefault().TRACE_HANDLERS) { LogUtils.debug(this, ""); }//ww w .j a va2 s. com final IValueBinding binding = (IValueBinding) HandlerUtil.getVariable(event, Constants.SOURCES_ACTIVE_BINDING); if (binding == null) { Display.getDefault().beep(); throw new ExecutionException("Quickfixes not supported for control"); } final ValueBindingMessageImageDecorator decorator = binding .getService(ValueBindingMessageImageDecorator.class); if (decorator == null) { Display.getDefault().beep(); throw new ExecutionException("Quickfixes not supported for control"); } final List<IQuickfixProposal> quickfixes = decorator.getQuickfixes(); if (quickfixes == null || quickfixes.size() == 0) return null; if (quickfixes.size() == 1 && IManager.Factory.getManager().isAutoApplySingleQuickfix()) { quickfixes.get(0).apply(); return null; } final IQuickfixProposal[] quickfixArray = quickfixes.toArray(new IQuickfixProposal[quickfixes.size()]); final IContentProposalProvider proposalProvider = new IContentProposalProvider() { @Override public IContentProposal[] getProposals(String contents, int position) { return quickfixArray; } }; final MyContentProposalAdapter proposalAdapter = new MyContentProposalAdapter(binding.getControl(), new MyControlContentAdapter(), proposalProvider); proposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_IGNORE); proposalAdapter.addContentProposalListener(new IContentProposalListener() { @Override public void proposalAccepted(IContentProposal proposal) { Assert.isNotNull(proposal); final IQuickfixProposal quickfix = (IQuickfixProposal) proposal; quickfix.apply(); } }); proposalAdapter.setLabelProvider(new MyQuickfixLabelProvider()); proposalAdapter.open(); return null; }
From source file:com.rcpcompany.uibindings.internal.utils.BindingMessagesPopup.java
License:Open Source License
/** * Constructs and returns a new message popup. * //from w ww. j a va 2 s . c om * @param control the control that should have the popup assiciated. * @param messages the messages to show */ public BindingMessagesPopup(Control control) { super(control, new MyControlContentAdapter(), null, null, null); setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_IGNORE); addContentProposalListener(new IContentProposalListener() { @Override public void proposalAccepted(IContentProposal proposal) { Assert.isNotNull(proposal); final IBindingMessage message = ((MyContentProposal) proposal).getMessage(); message.getBinding().setFocus(); } }); setLabelProvider(new MyQuickfixLabelProvider()); }
From source file:com.vectrace.MercurialEclipse.dialogs.RevisionChooserPanel.java
License:Open Source License
/** * Adds field assistance to the revision text field. *//* ww w . jav a2 s. c o m*/ private void setupRevisionFieldAssistance() { contentAssist = new ContentAssistCommandAdapter(text, new TextContentAdapter(), new RevisionContentProposalProvider(dataLoader), null, null, true); contentAssist.setAutoActivationDelay(300); contentAssist.setPopupSize(new Point(320, 240)); contentAssist.setPropagateKeys(true); contentAssist.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); contentAssist.addContentProposalListener(new IContentProposalListener() { public void proposalAccepted(IContentProposal proposal) { tag = null; branch = null; bookmark = null; String changeSetId = proposal.getContent().split(" ", 2)[0]; //$NON-NLS-1$ try { data.changeSet = LocalChangesetCache.getInstance().get(dataLoader.getHgRoot(), changeSetId); } catch (HgException e) { data.changeSet = null; String message = Messages.getString("RevisionChooserDialog.error.loadChangeset1", changeSetId); //$NON-NLS-1$ logError(message, e); } } }); }
From source file:com.vectrace.MercurialEclipse.history.MercurialHistoryPage.java
License:Open Source License
/** * Adds field assistance to the revision text field. */// w w w . j a v a2 s. c om private void setupRevisionFieldAssistance() { proposalProvider = new HistoryContentProposalProvider(this); ContentAssistCommandAdapter contentAssist = new ContentAssistCommandAdapter(gotoText, new TextContentAdapter(), proposalProvider, null, null, true); // uncomment to open popup immediately on typing first character into the text field // contentAssist.setAutoActivationCharacters(null); contentAssist.setAutoActivationDelay(300); contentAssist.setPropagateKeys(true); contentAssist.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_REPLACE); contentAssist.addContentProposalListener(new IContentProposalListener2() { public void proposalPopupOpened(ContentProposalAdapter adapter) { fetchEntireHistory(true); } public void proposalPopupClosed(ContentProposalAdapter adapter) { fetchEntireHistory(false); } }); contentAssist.addContentProposalListener(new IContentProposalListener() { public void proposalAccepted(IContentProposal proposal) { if (proposal instanceof RevisionContentProposal) { selectProposal(proposal); } else { // try to find something guessAndSelectVersion(proposal.getContent()); } } }); }
From source file:hydrograph.ui.graph.canvas.search.ComponentSearchUtility.java
License:Apache License
/** * Added listeners/* w w w . ja v a 2 s. c o m*/ */ private void initializeListneres() { assistText.addKeyListener(new KeyListener() { @Override public void keyReleased(KeyEvent e) { if (e.keyCode == SWT.ESC) { disposeAssistText(); } } @Override public void keyPressed(KeyEvent e) { } }); assistText.addFocusListener(new FocusListener() { @Override public void focusLost(FocusEvent e) { if (!contentProposalAdapter.isProposalPopupOpen()) { disposeAssistText(); } } @Override public void focusGained(FocusEvent e) { } }); contentProposalAdapter.addContentProposalListener(new IContentProposalListener2() { @Override public void proposalPopupOpened(ContentProposalAdapter adapter) { } @Override public void proposalPopupClosed(ContentProposalAdapter adapter) { if (assistText != null && !assistText.isFocusControl()) { disposeAssistText(); } } }); contentProposalAdapter.addContentProposalListener(new IContentProposalListener() { @Override public void proposalAccepted(IContentProposal proposal) { acceptProposal(); } }); }
From source file:net.enilink.komma.edit.ui.util.SearchWidget.java
License:Open Source License
/** * Creates the search text and adds listeners. This method calls * {@link #doCreateSearchText(Composite)} to create the text control. * Subclasses should override {@link #doCreateSearchText(Composite)} instead * of overriding this method./*from ww w .java 2 s .co m*/ * * @param parent * <code>Composite</code> of the search text */ protected void createSearchText(Composite parent) { searchText = doCreateSearchText(parent); searchText.addFocusListener(new FocusAdapter() { /* * (non-Javadoc) * * @see * org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt * .events.FocusEvent) */ public void focusGained(FocusEvent e) { /* * Running in an asyncExec because the selectAll() does not * appear to work when using mouse to give focus to text. */ Display display = searchText.getDisplay(); display.asyncExec(new Runnable() { public void run() { if (!searchText.isDisposed()) { if (getInitialText().equals(searchText.getText().trim())) { searchText.selectAll(); } } } }); } }); searchText.addSelectionListener(new SelectionAdapter() { @Override public void widgetDefaultSelected(SelectionEvent e) { doSearch(searchText.getText()); } }); searchText.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false)); // content proposals for searching class ObjectProposal extends ContentProposal { Object object; ObjectProposal(Object object) { super(""); this.object = object; } } ContentProposalAdapter proposalAdapter = new ContentProposalAdapter(searchText, new TextContentAdapter(), new IContentProposalProvider() { @Override public IContentProposal[] getProposals(String contents, int position) { Collection<Object> results = findElements(contents); List<IContentProposal> proposals = new ArrayList<IContentProposal>(); for (Object result : results) { proposals.add(new ObjectProposal(result)); } return proposals.toArray(new IContentProposal[proposals.size()]); } }, null, null); proposalAdapter.setAutoActivationDelay(750); proposalAdapter.setProposalAcceptanceStyle(ContentProposalAdapter.PROPOSAL_IGNORE); proposalAdapter.addContentProposalListener(new IContentProposalListener() { @Override public void proposalAccepted(IContentProposal proposal) { viewer.setSelection(new StructuredSelection(((ObjectProposal) proposal).object), true); } }); proposalAdapter.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { ILabelProvider labelProvider = getLabelProvider(); return labelProvider != null ? labelProvider.getText(((ObjectProposal) element).object) : super.getText(element); } @Override public Image getImage(Object element) { ILabelProvider labelProvider = getLabelProvider(); return labelProvider != null ? labelProvider.getImage(((ObjectProposal) element).object) : super.getImage(element); } }); }