List of usage examples for org.eclipse.jface.viewers ComboViewer ComboViewer
public ComboViewer(Composite parent, int style)
From source file:eu.esdihumboldt.hale.ui.common.definition.editors.EnumerationEditor.java
License:Open Source License
/** * Creates an editor that only allows values from the given enumeration. * /* w ww . ja v a 2 s.c o m*/ * @param parent the parent composite * @param enumerationValues the enumeration values */ public EnumerationEditor(Composite parent, Collection<String> enumerationValues) { this.enumerationValues = enumerationValues; viewer = new ComboViewer(parent, SWT.READ_ONLY | SWT.BORDER); viewer.setContentProvider(ArrayContentProvider.getInstance()); viewer.setInput(enumerationValues); viewer.setSelection(new StructuredSelection(enumerationValues.iterator().next())); }
From source file:eu.esdihumboldt.hale.ui.common.editors.BooleanEditor.java
License:Open Source License
/** * Create a boolean attribute editor/*from ww w . j a v a 2 s.c om*/ * * @param parent the parent composite */ public BooleanEditor(Composite parent) { super(); combo = new ComboViewer(parent, SWT.READ_ONLY); combo.setContentProvider(ArrayContentProvider.getInstance()); combo.setLabelProvider(new LabelProvider()); combo.setInput(new Object[] { Boolean.TRUE, Boolean.FALSE }); // default selection combo.setSelection(new StructuredSelection(Boolean.FALSE)); value = Boolean.FALSE; combo.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { Boolean newValue = (Boolean) ((IStructuredSelection) event.getSelection()).getFirstElement(); fireValueChanged(VALUE, value, newValue); value = newValue; } }); }
From source file:eu.esdihumboldt.hale.ui.functions.core.ClassificationMappingParameterPage.java
License:Open Source License
/** * @see eu.esdihumboldt.hale.ui.HaleWizardPage#createContent(org.eclipse.swt.widgets.Composite) *//*from w w w . ja v a 2s .c o m*/ @Override protected void createContent(Composite page) { page.setLayout(GridLayoutFactory.swtDefaults().numColumns(4).create()); // not classified action notClassifiedActionComposite = new Composite(page, SWT.NONE); notClassifiedActionComposite.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 4, 1)); notClassifiedActionComposite .setLayout(GridLayoutFactory.swtDefaults().numColumns(4).margins(0, 0).create()); Label notClassifiedActionLabel = new Label(notClassifiedActionComposite, SWT.NONE); notClassifiedActionLabel.setText("For unmapped source values"); notClassifiedActionLabel.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); notClassifiedActionViewer = new ComboViewer(notClassifiedActionComposite, SWT.DROP_DOWN | SWT.READ_ONLY); notClassifiedActionViewer.getControl().setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); notClassifiedActionViewer.setContentProvider(ArrayContentProvider.getInstance()); notClassifiedActionViewer.setInput(notClassifiedActionOptions); notClassifiedActionViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { if (notClassifiedActionOptions .indexOf(((IStructuredSelection) event.getSelection()).getFirstElement()) == 2) createFixedValueInputButton(null); else removeFixedValueInputButton(); } }); notClassifiedActionViewer.setSelection(new StructuredSelection(notClassifiedActionOptions.get(0))); if (notClassifiedAction != null) { if (notClassifiedAction.equals("source")) notClassifiedActionViewer.setSelection(new StructuredSelection(notClassifiedActionOptions.get(1))); else if (notClassifiedAction.startsWith("fixed:")) { notClassifiedActionViewer.setSelection(new StructuredSelection(notClassifiedActionOptions.get(2))); createFixedValueInputButton(notClassifiedAction.substring(6)); } } // Tabs tabs = new TabFolder(page, SWT.NONE); tabs.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); // The manualTab for the manual way to specify something like a // lookupTable manualItem = new TabItem(tabs, SWT.NONE); manualItem.setText("Explicit"); manualItem.setControl(createManualTabControl(tabs)); // FromFileTab to load lookupTable from file fromFileItem = new TabItem(tabs, SWT.NONE); fromFileItem.setText("From file"); fromFileItem.setControl(createFromFileTabControl(tabs)); if (selectedLookupTableID != null) { tabs.setSelection(fromFileItem); } }
From source file:eu.esdihumboldt.hale.ui.functions.core.ClassificationMappingParameterPage.java
License:Open Source License
private Control createFromFileTabControl(Composite tabParent) { // Parent composite for fromFileTab Composite item2Content = new Composite(tabParent, SWT.NONE); item2Content.setLayout(new GridLayout()); // Label to descripe what the user should do Label l = new Label(item2Content, SWT.NONE); l.setText("Select the project lookup table resource you want to use for the classification:"); // Get the Lookuptable Service final LookupService lookupService = HaleUI.getServiceProvider().getService(LookupService.class); // Composite for comboViewerComposite and Button Composite parent = new Composite(item2Content, SWT.NONE); parent.setLayout(new GridLayout(2, false)); parent.setLayoutData(new GridData(SWT.FILL, SWT.NONE, true, false)); // Description Label description = new Label(item2Content, SWT.WRAP); description.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); description.setText(""); description.setVisible(false);/*from w ww . j a v a 2s . c o m*/ // label with warning message Composite warnComp = new Composite(item2Content, SWT.NONE); GridLayoutFactory.swtDefaults().numColumns(2).applyTo(warnComp); GridDataFactory.fillDefaults().grab(true, false).applyTo(warnComp); Label warnImage = new Label(warnComp, SWT.NONE); warnImage.setImage(PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK)); GridDataFactory.swtDefaults().align(SWT.CENTER, SWT.BEGINNING).applyTo(warnImage); Label warn = new Label(warnComp, SWT.WRAP); warn.setText( "Classifications from a file resource will not function in another project where the alignment with the classification is imported or used as a base alignment.\n" + "If unsure, use the 'Explicit' mode instead and use the option to load the classification from a file."); GridDataFactory.swtDefaults().align(SWT.FILL, SWT.BEGINNING).grab(true, false).hint(300, SWT.DEFAULT) .applyTo(warn); // Composite for ComboViewer Composite viewerComposite = new Composite(parent, SWT.NONE); viewerComposite.setLayout(new FillLayout()); GridData layoutData = new GridData(SWT.FILL, SWT.NONE, true, false); viewerComposite.setLayoutData(GridDataFactory.copyData(layoutData)); // ComboViewer lookupTableComboViewer = new ComboViewer(viewerComposite, SWT.READ_ONLY); lookupTableComboViewer.setContentProvider(ArrayContentProvider.getInstance()); lookupTableComboViewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element instanceof String) { return lookupService.getTable((String) element).getName(); } return null; } }); lookupTableComboViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { // Show the description for the selected lookupTable IStructuredSelection selection = (IStructuredSelection) event.getSelection(); String desc = lookupService.getTable(selection.getFirstElement().toString()).getDescription(); if (desc != null) { description.setText("Description: " + desc); } else { description.setText(""); } if (!description.isVisible()) { description.setVisible(true); } } }); lookupTableComboViewer.setInput(lookupService.getTableIDs()); if (selectedLookupTableID != null) { lookupTableComboViewer.setSelection(new StructuredSelection(selectedLookupTableID), true); } // Button to load a lookupTable if no one is loaded final Button browseButton = new Button(parent, SWT.PUSH); browseButton.setText("Add..."); browseButton.addSelectionListener(new SelectionListener() { @Override public void widgetSelected(SelectionEvent e) { IOWizardAction action = new IOWizardAction("eu.esdihumboldt.hale.lookup.import"); action.run(); action.dispose(); // Refresh the viewer lookupTableComboViewer.setInput(lookupService.getTableIDs()); } @Override public void widgetDefaultSelected(SelectionEvent e) { // nothing to do here } }); return item2Content; }
From source file:eu.esdihumboldt.hale.ui.functions.inspire.GeographicalNamePage.java
License:Open Source License
private void createSpellingGroup(Composite parent, PropertyFunction function) { // define Spelling Group composite Group configurationGroup = new Group(parent, SWT.NONE); configurationGroup.setText(SPELLING_GROUP_TEXT); configurationGroup.setLayout(GridLayoutFactory.fillDefaults().create()); GridData configurationAreaGD = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL); configurationAreaGD.grabExcessHorizontalSpace = true; configurationAreaGD.grabExcessVerticalSpace = true; configurationGroup.setLayoutData(configurationAreaGD); configurationGroup.setSize(configurationGroup.computeSize(SWT.DEFAULT, SWT.DEFAULT)); configurationGroup.setFont(parent.getFont()); final Composite configurationComposite = new Composite(configurationGroup, SWT.NONE); GridData configurationLayoutData = new GridData(GridData.GRAB_HORIZONTAL | GridData.FILL_HORIZONTAL); configurationLayoutData.grabExcessHorizontalSpace = true; configurationComposite.setLayoutData(configurationLayoutData); GridLayout spellingLayout = new GridLayout(); spellingLayout.numColumns = 2;/*from w w w . j av a 2s . c o m*/ spellingLayout.makeColumnsEqualWidth = false; spellingLayout.marginWidth = 0; spellingLayout.marginHeight = 0; spellingLayout.horizontalSpacing = 8; configurationComposite.setLayout(spellingLayout); // init spelling types if it doesn't exists // or get the known information about the cell to be edited if (getSpellings() == null || getSpellings().size() == 0) { spellings = new ArrayList<SpellingType>(); ListMultimap<String, ? extends Entity> source = getWizard().getUnfinishedCell().getSource(); if (source != null) { for (Entity item : source.values()) { int i = 0; Definition<?> entity = item.getDefinition().getDefinition(); if (entity instanceof PropertyDefinition) { SpellingType sp = new SpellingType((PropertyDefinition) entity); // set the same script value if you had a value before if (scripts != null && i < scripts.size()) { sp.setScript(scripts.get(i)); } else { // else set the default value sp.setScript(ISO_CODE_ENG); } // set the same transliteration value if you had a value // before if (trans != null && i < trans.size()) { sp.setTransliteration(trans.get(i)); } else { // else set the default value sp.setTransliteration(""); } spellings.add(sp); } i++; } } } else { // after initialization of the spellings ArrayList<PropertyDefinition> temp = new ArrayList<PropertyDefinition>(); ArrayList<SpellingType> templist = getSpellings(); // we have to create a new spellings list because a live // modification of the combo box input would occur an error spellings = new ArrayList<SpellingType>(); for (int i = 0; i < templist.size(); i++) { temp.add(templist.get(i).getProperty()); if (scripts != null && trans != null && i < scripts.size() && scripts.get(i) != null && i < trans.size() && trans.get(i) != null) { templist.get(i).setScript(scripts.get(i)); templist.get(i).setTransliteration(trans.get(i)); } } for (Entity item : getWizard().getUnfinishedCell().getSource().values()) { Definition<?> entity = item.getDefinition().getDefinition(); if (entity instanceof PropertyDefinition) { PropertyDefinition propDef = (PropertyDefinition) entity; for (SpellingType st : templist) { // if the spelling already exists just add the full // spelling configuration (text, script, // transliteration) to the new spellings list if (propDef.equals(st.getProperty())) { spellings.add(st); } } // if the spelling didn't exist before add a new spelling // with default values if (!temp.contains(propDef)) { SpellingType sp = new SpellingType(propDef); sp.setScript(ISO_CODE_ENG); sp.setTransliteration(""); spellings.add(sp); } } } } // Text final Label nameSpellingTextLabel = new Label(configurationComposite, SWT.NONE); nameSpellingTextLabel.setText(SPELLING_TEXT_LABEL_TEXT); this.nameSpellingText = new ComboViewer(configurationComposite, SWT.DROP_DOWN | SWT.READ_ONLY); this.nameSpellingText.getControl().setLayoutData(configurationLayoutData); this.nameSpellingText.setContentProvider(ArrayContentProvider.getInstance()); this.nameSpellingText.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element instanceof SpellingType) { return ((SpellingType) element).getProperty().getName().getLocalPart(); } return super.getText(element); } }); this.nameSpellingText.setInput(spellings); // default set selection to the first element on the list if (!spellings.isEmpty()) { this.activeSpelling = spellings.iterator().next(); this.nameSpellingText.setSelection(new StructuredSelection(activeSpelling)); } // set active spelling nameSpellingText.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { if (!event.getSelection().isEmpty() && event.getSelection() instanceof IStructuredSelection) { SpellingType selected = (SpellingType) ((IStructuredSelection) event.getSelection()) .getFirstElement(); String script = ISO_CODE_ENG; String transliteration = ""; //$NON-NLS-1$ activeSpelling = selected; if (activeSpelling.getScript() != null && !activeSpelling.getScript().equals("")) //$NON-NLS-1$ script = activeSpelling.getScript(); if (activeSpelling.getTransliteration() != null && !activeSpelling.getTransliteration().equals("")) //$NON-NLS-1$ transliteration = activeSpelling.getTransliteration(); nameSpellingScript.setText(script); nameSpellingTransliteration.setText(transliteration); } } }); // Script final Label nameSpellingScriptLabel = new Label(configurationComposite, SWT.NONE); nameSpellingScriptLabel.setText(SCRIPT_LABEL_TEXT); configureParameterLabel(nameSpellingScriptLabel, PROPERTY_SCRIPT, function); this.nameSpellingScript = new Text(configurationComposite, SWT.BORDER | SWT.SINGLE); this.nameSpellingScript.setLayoutData(configurationLayoutData); this.nameSpellingScript.setEnabled(true); this.nameSpellingScript.setTabs(0); String script = "eng"; //$NON-NLS-1$ // read script from the active spelling if (activeSpelling != null && activeSpelling.getScript() != null) script = activeSpelling.getScript(); // set default value for script this.nameSpellingScript.setText(script); this.nameSpellingScript.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { activeSpelling.setScript(nameSpellingScript.getText()); } }); // Transliteration final Label nameSpellingTransliterationLabel = new Label(configurationComposite, SWT.NONE); nameSpellingTransliterationLabel.setText(TRANSLITERATION_LABEL_TEXT); configureParameterLabel(nameSpellingTransliterationLabel, PROPERTY_TRANSLITERATION, function); this.nameSpellingTransliteration = new Text(configurationComposite, SWT.BORDER | SWT.SINGLE); this.nameSpellingTransliteration.setLayoutData(configurationLayoutData); this.nameSpellingTransliteration.setEnabled(true); this.nameSpellingTransliteration.setTabs(0); // read script from the active spelling String transliteration = ""; //$NON-NLS-1$ if (activeSpelling != null && activeSpelling.getTransliteration() != null) transliteration = activeSpelling.getTransliteration(); // set default value for transliteration this.nameSpellingTransliteration.setText(transliteration); this.nameSpellingTransliteration.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { activeSpelling.setTransliteration(nameSpellingTransliteration.getText()); } }); }
From source file:eu.esdihumboldt.hale.ui.io.instance.exportconfig.SaveConfigurationInstanceExportPage.java
License:Open Source License
@Override protected void createContent(Composite page) { // set grid layout with two columns page.setLayout(new GridLayout(2, false)); // create name text field Label labelName = new Label(page, SWT.NONE); labelName.setText("Name:"); labelName.setLayoutData(GridDataFactory.swtDefaults().align(SWT.END, SWT.CENTER).create()); name = new Text(page, SWT.BORDER | SWT.SINGLE); // add listener to set page complete if name is inserted name.addModifyListener(new ModifyListener() { @Override//from w ww.jav a2 s. c om public void modifyText(ModifyEvent e) { update(); } }); name.setLayoutData(GridDataFactory.swtDefaults().align(SWT.FILL, SWT.BEGINNING).grab(true, false).create()); // create description text field Label labelDesc = new Label(page, SWT.NONE); labelDesc.setText("Description:"); labelDesc.setLayoutData(GridDataFactory.swtDefaults().align(SWT.END, SWT.CENTER).create()); description = new Text(page, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL); // add listener to set page complete if description is inserted description.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { update(); } }); GridData data = GridDataFactory.swtDefaults().align(SWT.FILL, SWT.BEGINNING).grab(true, false).create(); data.heightHint = 75; description.setLayoutData(data); // create viewer for possible content types Label labelConf = new Label(page, SWT.NONE); labelConf.setText("Format:"); labelConf.setLayoutData(GridDataFactory.swtDefaults().align(SWT.END, SWT.CENTER).create()); fileFormats = new ComboViewer(page, SWT.DROP_DOWN | SWT.READ_ONLY | SWT.BORDER); data = GridDataFactory.fillDefaults().grab(true, false).create(); // adapt viewer to size of current font fileFormats.getControl().setLayoutData(data); fileFormats.setContentProvider(ArrayContentProvider.getInstance()); fileFormats.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element instanceof IContentType) { return ((IContentType) element).getName(); } return super.getText(element); } }); // process current selection ISelection selection = fileFormats.getSelection(); setPageComplete(!selection.isEmpty()); // process selection changes fileFormats.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { ISelection selection = event.getSelection(); updateContentType(selection); update(); } }); update(); }
From source file:eu.esdihumboldt.hale.ui.io.instance.FileValidateTarget.java
License:Open Source License
@Override public void createControls(Composite parent) { super.createControls(parent); // page has a 3-column grid layout Group validatorGroup = new Group(parent, SWT.NONE); validatorGroup.setText("Validation"); validatorGroup.setLayoutData(GridDataFactory.swtDefaults().align(SWT.FILL, SWT.BEGINNING).grab(true, false) .span(3, 1).indent(8, 10).create()); validatorGroup.setLayout(GridLayoutFactory.swtDefaults().numColumns(1).margins(10, 8).create()); Label vabel = new Label(validatorGroup, SWT.NONE); vabel.setText("Please select a validator if you want to validate the exported file"); vabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false)); validators = new ComboViewer(validatorGroup, SWT.DROP_DOWN | SWT.READ_ONLY); validators.getControl().setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false)); validators.setContentProvider(ArrayContentProvider.getInstance()); validators.setLabelProvider(new LabelProvider() { @Override// w w w .ja v a 2s . c om public String getText(Object element) { if (element instanceof IOProviderDescriptor) { return ((IOProviderDescriptor) element).getDisplayName(); } return super.getText(element); } }); updateInput(); // process selection changes validators.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { ISelection selection = event.getSelection(); updateWizard(selection); } }); getWizard().addIOWizardListener(this); }
From source file:eu.esdihumboldt.hale.ui.io.instance.InstanceSelectTargetPage.java
License:Open Source License
/** * @see ExportSelectTargetPage#createContent(Composite) *//*from ww w . j ava 2s . c o m*/ @Override protected void createContent(Composite page) { super.createContent(page); // page has a 3-column grid layout Group validatorGroup = new Group(page, SWT.NONE); validatorGroup.setText("Validation"); validatorGroup.setLayoutData(GridDataFactory.swtDefaults().align(SWT.FILL, SWT.BEGINNING).grab(true, false) .span(3, 1).indent(8, 10).create()); validatorGroup.setLayout(GridLayoutFactory.swtDefaults().numColumns(1).margins(10, 8).create()); Label vabel = new Label(validatorGroup, SWT.NONE); vabel.setText("Please select a validator if you want to validate the exported file"); vabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false)); validators = new ComboViewer(validatorGroup, SWT.DROP_DOWN | SWT.READ_ONLY); validators.getControl().setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false)); validators.setContentProvider(ArrayContentProvider.getInstance()); validators.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element instanceof IOProviderDescriptor) { return ((IOProviderDescriptor) element).getDisplayName(); } return super.getText(element); } }); updateInput(); // process selection changes validators.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { ISelection selection = event.getSelection(); updateWizard(selection); } }); getWizard().addIOWizardListener(this); }
From source file:eu.esdihumboldt.hale.ui.io.instance.ValidatorSelectionDialog.java
License:Open Source License
/** * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) *//*w w w . j a v a 2 s . c o m*/ @Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); GridData data = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER); data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH); composite.setLayoutData(data); Label label = new Label(composite, SWT.NONE); label.setText("Please select a validator if you want to validate the exported file"); label.setLayoutData(GridDataFactory.swtDefaults().span(3, 1).align(SWT.BEGINNING, SWT.BEGINNING).create()); validators = new ComboViewer(composite, SWT.DROP_DOWN | SWT.READ_ONLY); validators.getControl().setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false)); validators.setContentProvider(ArrayContentProvider.getInstance()); validators.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element instanceof IOProviderDescriptor) { return ((IOProviderDescriptor) element).getDisplayName(); } return super.getText(element); } }); validators.setInput(input); validators.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { selection = event.getSelection(); } }); return composite; }
From source file:eu.esdihumboldt.hale.ui.io.source.AbstractProviderSource.java
License:Open Source License
/** * Create the provider selector combo viewer. Once created it can be * retrieved using {@link #getProviders()}. This should be called in * {@link #createControls(Composite)}.// w w w .j a va 2 s . c o m * * @param parent the parent composite * @return the created combo viewer */ protected ComboViewer createProviders(Composite parent) { // create provider combo providers = new ComboViewer(parent, SWT.DROP_DOWN | SWT.READ_ONLY); providers.setContentProvider(ArrayContentProvider.getInstance()); providers.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element instanceof IOProviderDescriptor) { return ((IOProviderDescriptor) element).getDisplayName(); } return super.getText(element); } }); // process selection changes providers.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { onProviderSelectionChanged(event); } }); return providers; }