List of usage examples for org.eclipse.jface.viewers ComboViewer add
public void add(Object... elements)
From source file:de.jwi.ostendoplugin.views.ComboInputDialog.java
License:Open Source License
@Override protected Control createDialogArea(Composite parent) { Composite composite = (Composite) super.createDialogArea(parent); ComboViewer comboViewer = new ComboViewer(composite, 0); comboViewer.add(data); return composite; }
From source file:net.enilink.komma.edit.ui.wizards.RefactorMoveWizard.java
License:Open Source License
protected void createPages() { selectModelPage = new WizardPage("Select Target Model") { @Override/*w ww . j a v a 2 s .com*/ public void createControl(Composite parent) { Composite composite = new Composite(parent, SWT.NONE); composite.setLayout(new GridLayout()); Label label = new Label(composite, SWT.NONE); label.setText("Select target model:"); final Combo combo = new Combo(composite, SWT.DROP_DOWN); final ComboViewer cViewer = new ComboViewer(combo); cViewer.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { targetModel = (IModel) cViewer.getElementAt(combo.getSelectionIndex()); setPageComplete(true); } }); // get potential target models from list of active editors IEditorReference[] openEditors = workbench.getActiveWorkbenchWindow().getActivePage() .getEditorReferences(); for (IEditorReference ref : openEditors) { IEditorPart editor = ref.getEditor(true); if (editor != null && editor != workbench.getActiveWorkbenchWindow().getActivePage().getActiveEditor()) { IModel model = (IModel) editor.getAdapter(IModel.class); if (model != null) { cViewer.add(model); } } } final Button keepNamespaceButton = new Button(composite, SWT.CHECK); keepNamespaceButton.setSelection(keepNamespace); keepNamespaceButton.setText("Keep namespaces"); keepNamespaceButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { keepNamespace = keepNamespaceButton.getSelection(); } }); setDescription("Select the target model from the list of open editors."); setControl(composite); setPageComplete(false); } }; showPreviewPage = new RefactorPreviewPage("Preview") { @Override public Collection<Change> collectChanges() { changes = new RefactoringProcessor(domain).createMoveChanges(currentSelection.toList(), targetModel, keepNamespace); return changes; } }; }
From source file:org.bbaw.pdr.ae.view.control.customSWTWidges.RelationEditorLine.java
License:Open Source License
/** * Sets the combo viewer by string./* w w w . j a v a 2s. c o m*/ * @param cv the cv * @param s the s */ private void setComboViewerByString(final ComboViewer cv, final String s) { if (cv.getInput() instanceof HashMap<?, ?>) { @SuppressWarnings("unchecked") HashMap<String, ConfigData> inputs = (HashMap<String, ConfigData>) cv.getInput(); if (inputs.containsKey(s)) { // System.out.println("contains key s " + s); for (String key : inputs.keySet()) { if (key.equals(s)) { ConfigData cd = inputs.get(key); if (cd instanceof ConfigItem && ((ConfigItem) cd).isIgnore()) { ((ConfigItem) cd).setReadAlthoughIgnored(true); cv.setInput(inputs); } cv.setSelection(new StructuredSelection(cd)); return; } } } } ConfigItem ci = new ConfigItem(); ci.setValue(s); ci.setLabel(s); cv.add(ci); StructuredSelection selection = new StructuredSelection(ci); cv.setSelection(selection); }
From source file:org.bbaw.pdr.ae.view.control.dialogs.SelectObjectDialog.java
License:Open Source License
/** * Sets the combo viewer by string.//from w w w. jav a2s .c o m * @param cv the cv * @param s the s */ private void setComboViewerByString(final ComboViewer cv, final String s) { if (cv.getInput() instanceof HashMap<?, ?>) { // System.out.println("has input and is hashmap"); @SuppressWarnings("unchecked") HashMap<String, ConfigData> inputs = (HashMap<String, ConfigData>) cv.getInput(); if (inputs.containsKey(s)) { // System.out.println("contains key s " + s); for (String key : inputs.keySet()) { if (key.equals(s)) { ConfigData cd = inputs.get(key); if (cd instanceof ConfigItem && ((ConfigItem) cd).isIgnore()) { ((ConfigItem) cd).setReadAlthoughIgnored(true); cv.setInput(inputs); } cv.setSelection(new StructuredSelection(cd)); return; } } } } ConfigItem ci = new ConfigItem(); ci.setValue(s); ci.setLabel(s); cv.add(ci); StructuredSelection selection = new StructuredSelection(ci); cv.setSelection(selection); }
From source file:org.bbaw.pdr.ae.view.main.dialogs.AdvancedSearchDialog.java
License:Open Source License
/** * Sets the combo viewer by string.//from w ww . ja va 2 s .co m * @param cv the cv * @param s the s */ private void setComboViewerByString(final ComboViewer cv, final String s) { if (cv.getInput() instanceof HashMap<?, ?>) { // System.out.println("has input and is hashmap"); //$NON-NLS-1$ @SuppressWarnings("unchecked") HashMap<String, ConfigData> inputs = (HashMap<String, ConfigData>) cv.getInput(); if (inputs.containsKey(s)) { // System.out.println("contains key s " + s); //$NON-NLS-1$ for (String key : inputs.keySet()) { if (key.equals(s)) { ConfigData cd = inputs.get(key); if (cd instanceof ConfigItem && ((ConfigItem) cd).isIgnore()) { ((ConfigItem) cd).setReadAlthoughIgnored(true); cv.setInput(inputs); } cv.setSelection(new StructuredSelection(cd)); return; } } } } ConfigItem ci = new ConfigItem(); ci.setValue(s); ci.setLabel(s); cv.add(ci); StructuredSelection selection = new StructuredSelection(ci); cv.setSelection(selection); }
From source file:org.eclipse.bpmn2.modeler.ui.property.MainPropertiesComposite.java
License:Open Source License
private void createSingleItemEditor(final EStructuralFeature reference, Object eGet, Collection values) { final ComboViewer combo = new ComboViewer(this, SWT.BORDER); Combo c = combo.getCombo();//from w w w . j a v a 2s .com combo.setLabelProvider(LABEL_PROVIDER); c.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1)); toolkit.adapt(c, true, true); widgets.add(c); List<Object> l = null; if (values != null) { l = Arrays.asList(values.toArray()); } else if (modelHandler != null) { l = (List<Object>) modelHandler.getAll(reference.getEType().getInstanceClass()); } combo.add(""); combo.add(l.toArray()); if (eGet != null) { combo.setSelection(new StructuredSelection(eGet)); } combo.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { ISelection selection = combo.getSelection(); if (selection instanceof StructuredSelection) { Object firstElement = ((StructuredSelection) selection).getFirstElement(); if (firstElement instanceof EObject) { updateEObject(firstElement); } else if (firstElement instanceof GatewayDirection) { updateGatewayDirection(firstElement); } else { updateEObject(null); } } } public void updateEObject(final Object result) { TransactionalEditingDomain domain = bpmn2Editor.getEditingDomain(); domain.getCommandStack().execute(new RecordingCommand(domain) { @Override protected void doExecute() { be.eSet(reference, result); } }); } public void updateGatewayDirection(final Object result) { TransactionalEditingDomain domain = bpmn2Editor.getEditingDomain(); domain.getCommandStack().execute(new RecordingCommand(domain) { @Override protected void doExecute() { GatewayDirection direction = (GatewayDirection) result; be.eSet(reference, direction); } }); } }); }
From source file:org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs.AbstractIconDialogWithScopeAndFilter.java
License:Open Source License
@Override protected void createOptions(Composite compOptions) { super.createOptions(compOptions); Label lblMaxSize = new Label(compOptions, SWT.NONE); lblMaxSize.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false)); lblMaxSize.setText(Messages.AbstractIconDialogWithScopeAndFilter_maxDisplayedImageSize); final ComboViewer cv = new ComboViewer(compOptions); cv.getCombo().setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false, 1, 1)); cv.add(10); cv.add(20);//from www . j a v a2s .com cv.add(30); cv.add(50); cv.add(100); cv.add(150); cv.add(200); maxDisplayedImageSize = 30; cv.setSelection(new StructuredSelection(maxDisplayedImageSize)); cv.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { maxDisplayedImageSize = (Integer) ((IStructuredSelection) cv.getSelection()).getFirstElement(); rebuildViewer(); refreshSearch(); // combo viewer cannot make rows smaller, so we will need to // rebuild it in that case. } }); }
From source file:org.eclipse.osee.framework.ui.skynet.search.ArtifactSearchPage.java
License:Open Source License
private void createRelationSearchControls(Composite optionsComposite) { Composite relationControls = new Composite(optionsComposite, SWT.NONE); relationControls.setLayout(new GridLayout(2, true)); final ComboViewer relationTypeList = new ComboViewer(relationControls, SWT.DROP_DOWN | SWT.READ_ONLY); relationTypeList.setContentProvider(new SearchContentProvider()); relationTypeList.setLabelProvider(new SearchLabelProvider()); relationTypeList.setSorter(new SearchSorter()); final ComboViewer relationSideList = new ComboViewer(relationControls, SWT.DROP_DOWN | SWT.READ_ONLY); relationSideList.setContentProvider(new SearchContentProvider()); relationSideList.setLabelProvider(new StringSearchLabelProvider()); try {//w w w. j a v a 2 s . co m for (RelationType linkDescriptor : RelationTypeManager.getValidTypes(getSelectedBranch())) { relationTypeList.add(linkDescriptor); relationTypeList.setData(linkDescriptor.getName(), linkDescriptor); } } catch (OseeCoreException ex) { OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, ex); } relationTypeList.getCombo().addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { relationSideList.getCombo().removeAll(); RelationType linkDescriptor = (RelationType) relationTypeList .getData(relationTypeList.getCombo().getText()); relationSideList.add(linkDescriptor.getSideAName()); relationSideList.add(linkDescriptor.getSideBName()); relationSideList.add("-Either-"); relationSideList.getCombo().select(0); } }); relationTypeList.getCombo().setVisibleItemCount(Math.min(relationTypeList.getCombo().getItemCount(), 15)); if (relationTypeList.getCombo().getItemCount() > 0) { // ensure we don't get a null pointer // exception when there are no relation types in the db relationTypeList.getCombo().select(0); RelationType linkDescriptor = (RelationType) relationTypeList .getData(relationTypeList.getCombo().getText()); relationSideList.add(linkDescriptor.getSideAName()); relationSideList.add(linkDescriptor.getSideBName()); relationSideList.add("-Either-"); relationSideList.getCombo().select(0); } addToSearchTypeList(new InRelationFilter(relationControls, relationTypeList, relationSideList)); addToSearchTypeList(new NotInRelationFilter(relationControls, relationTypeList, relationSideList)); }
From source file:org.eclipse.osee.framework.ui.skynet.search.ArtifactSearchPage.java
License:Open Source License
private void createAttributeSearchControls(Composite optionsComposite) { Composite attributeControls = new Composite(optionsComposite, SWT.NONE); attributeControls.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); attributeControls.setLayout(new GridLayout(2, false)); Label typeLabel = new Label(attributeControls, SWT.HORIZONTAL); typeLabel.setText("Attribute Type:"); final ComboViewer attributeTypeList = new ComboViewer(attributeControls, SWT.DROP_DOWN | SWT.READ_ONLY); attributeTypeList.setContentProvider(new SearchContentProvider()); attributeTypeList.setLabelProvider(new SearchLabelProvider()); attributeTypeList.setSorter(new SearchSorter()); Label valueLabel = new Label(attributeControls, SWT.HORIZONTAL); valueLabel.setText("Attribute Value:"); Text attributeValue = new Text(attributeControls, SWT.BORDER); attributeValue.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); try {//from ww w . ja va 2 s .co m for (IAttributeType type : AttributeTypeManager.getValidAttributeTypes(getSelectedBranch())) { attributeTypeList.add(type); attributeTypeList.setData(type.getName(), type); } } catch (Exception ex) { OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, "Error encountered while getting list of attribute types", ex); } attributeTypeList.getCombo().setVisibleItemCount(Math.min(attributeTypeList.getCombo().getItemCount(), 15)); attributeTypeList.getCombo().select(lastAttributeTypeListSelected); attributeTypeList.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { lastAttributeTypeListSelected = attributeTypeList.getCombo().getSelectionIndex(); } }); attributeValue.addModifyListener(new ModifyListener() { @Override public void modifyText(ModifyEvent e) { addButton.setEnabled(ATTRIBUTE_VALUE_FILTER.isValid()); } }); new Label(attributeControls, SWT.NONE); // spacerLabelSoTheNextOneWillBeInColumnTwo ATTRIBUTE_VALUE_FILTER = new AttributeValueFilter(attributeControls, attributeTypeList, attributeValue); addToSearchTypeList(ATTRIBUTE_VALUE_FILTER); }
From source file:org.eclipse.osee.framework.ui.skynet.search.ArtifactSearchPage.java
License:Open Source License
private void createAttributeExistsControls(Composite optionsComposite) { Composite attributeControls = new Composite(optionsComposite, SWT.NONE); attributeControls.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); attributeControls.setLayout(new GridLayout(2, false)); Label typeLabel = new Label(attributeControls, SWT.HORIZONTAL); typeLabel.setText("Attribute Type:"); final ComboViewer attributeTypeList = new ComboViewer(attributeControls, SWT.DROP_DOWN | SWT.READ_ONLY); attributeTypeList.setContentProvider(new SearchContentProvider()); attributeTypeList.setLabelProvider(new SearchLabelProvider()); attributeTypeList.setSorter(new SearchSorter()); try {//from ww w . ja v a 2s.c om for (IAttributeType type : AttributeTypeManager.getValidAttributeTypes(getSelectedBranch())) { attributeTypeList.add(type); attributeTypeList.setData(type.getName(), type); } } catch (Exception ex) { OseeLog.log(Activator.class, OseeLevel.SEVERE_POPUP, "Error encountered while getting list of attribute types", ex); } attributeTypeList.getCombo().setVisibleItemCount(Math.min(attributeTypeList.getCombo().getItemCount(), 15)); attributeTypeList.getCombo().select(lastAttributeTypeListSelected); attributeTypeList.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event) { lastAttributeTypeListSelected = attributeTypeList.getCombo().getSelectionIndex(); } }); addToSearchTypeList(new AttributeExistsFilter(attributeControls, attributeTypeList)); }