Java Code Examples for org.eclipse.jface.viewers.ComboViewer#setInput()
The following examples show how to use
org.eclipse.jface.viewers.ComboViewer#setInput() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ComposeModeControl.java From depan with Apache License 2.0 | 6 votes |
public ComposeModeControl(Composite parent) { super(parent, SWT.NONE); setLayout(new FillLayout()); viewer = new ComboViewer(this, SWT.READ_ONLY | SWT.FLAT); viewer.setContentProvider(new ArrayContentProvider()); viewer.setLabelProvider(CONTROL_LABEL_PROVIDER); viewer.setComparator(new AlphabeticSorter(new ViewerObjectToString() { @Override public String getString(Object object) { return CONTROL_LABEL_PROVIDER.getText(object); } })); viewer.setInput(ComposeMode.values()); listener = new ControlSelectionChangedListener(); viewer.addSelectionChangedListener(listener); }
Example 2
Source File: AppEngineStandardWizardPage.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
@Override protected void createRuntimeField(Composite composite) { Label runtimeLabel = new Label(composite, SWT.LEAD); runtimeLabel.setText(Messages.getString("app.engine.standard.project.runtimetype")); //$NON-NLS-1$ runtimeField = new ComboViewer(composite, SWT.READ_ONLY); runtimeField.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return ((AppEngineRuntime) element).getLabel(); } }); runtimeField.setContentProvider(ArrayContentProvider.getInstance()); runtimeField.setInput(AppEngineRuntime.STANDARD_RUNTIMES); runtimeField.setSelection(new StructuredSelection(DEFAULT_RUNTIME), true); runtimeField.addPostSelectionChangedListener(event -> revalidate()); }
Example 3
Source File: MiniSelector.java From google-cloud-eclipse with Apache License 2.0 | 6 votes |
private void create(Composite parent) { displayExecutor = DisplayExecutor.create(parent.getDisplay()); comboViewer = new ComboViewer(parent, SWT.READ_ONLY | SWT.DROP_DOWN); comboViewer.setComparator(new ViewerComparator()); comboViewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { if (element instanceof GcpProject) { GcpProject project = (GcpProject) element; return project.getName() + " (" + project.getId() + ")"; } return super.getText(element); } }); comboViewer.setContentProvider(ArrayContentProvider.getInstance()); comboViewer.setInput(EMPTY_PROJECTS); parent.addDisposeListener(new DisposeListener() { @Override public void widgetDisposed(DisposeEvent event) { cancelFetch(); } }); fetch(); }
Example 4
Source File: SectionList.java From olca-app with Mozilla Public License 2.0 | 6 votes |
private void createComponentViewer(Composite composite) { UI.formLabel(composite, toolkit, M.Component); componentViewer = new ComboViewer(composite); UI.gridData(componentViewer.getControl(), false, false).widthHint = 250; componentViewer.setContentProvider(ArrayContentProvider .getInstance()); componentViewer.setLabelProvider(new ComponentLabel()); componentViewer.setInput(ReportComponent.values()); componentViewer.addSelectionChangedListener((evt) -> { ReportComponent c = Viewers.getFirst(evt.getSelection()); if (c == null || c == ReportComponent.NONE) model.componentId = null; else model.componentId = c.getId(); editor.setDirty(true); }); if (model.componentId != null) componentViewer.setSelection(new StructuredSelection( ReportComponent.getForId(model.componentId))); }
Example 5
Source File: CostDialog.java From olca-app with Mozilla Public License 2.0 | 5 votes |
private void setCurrencyContent(ComboViewer combo) { combo.setContentProvider(ArrayContentProvider.getInstance()); CurrencyDao dao = new CurrencyDao(Database.get()); List<Currency> all = dao.getAll(); Collections.sort(all, (c1, c2) -> Strings.compare(c1.name, c2.name)); combo.setInput(all); currency = exchange.currency; if (currency == null) currency = dao.getReferenceCurrency(); if (currency != null) { combo.setSelection(new StructuredSelection(currency)); exchange.currency = currency; } }
Example 6
Source File: GeneratePropertiesPage.java From Pydev with Eclipse Public License 1.0 | 5 votes |
private ComboViewer createComboViewer(Composite comboComp) { ComboViewer v = new ComboViewer(comboComp); v.setContentProvider(this.strategyProvider); v.setLabelProvider(new LabelProvider()); v.setInput(""); return v; }
Example 7
Source File: ConverterUtil.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
public static void bindValue(DataBindingContext context,ComboViewer comboViewer, ConverterViewModel model) { // ViewerSupport.bind(comboViewer, BeansObservables.observeList( // model, "supportTypes", String.class), // Properties.selfValue(String.class)); // // // context.bindValue(ViewersObservables // .observeSingleSelection(comboViewer), BeansObservables // .observeValue(model, // "selectedType")); // ObservableListContentProvider viewerContentProvider=new ObservableListContentProvider(); comboViewer.setContentProvider(new ArrayContentProvider()); comboViewer.setComparator(new ViewerComparator()); // IObservableMap[] attributeMaps = BeansObservables.observeMaps( // viewerContentProvider.getKnownElements(), // ConverterBean.class, new String[] { "description" }); // comboViewer.setLabelProvider(new ObservableMapLabelProvider( // attributeMaps)); // comboViewer.setInput(Observables.staticObservableList(model.getSupportTypes(),ConverterBean.class)); comboViewer.setInput(model.getSupportTypes()); IViewerObservableValue selection=ViewersObservables.observeSingleSelection(comboViewer); IObservableValue observableValue=BeansObservables.observeDetailValue(selection, "name", ConverterBean.class); context.bindValue(observableValue, BeansObservables .observeValue(model, "selectedType")); }
Example 8
Source File: FindingsDetailComposite.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
public void createObservationComposite(){ Label lblType = new Label(compositeType, SWT.NONE); lblType.setText("Datentyp"); lblType.setLayoutData(minGd); comboInputData = new ComboViewer(compositeType, SWT.BORDER | SWT.READ_ONLY); ObservableListContentProvider contentProvider = new ObservableListContentProvider(); comboInputData.setContentProvider(contentProvider); comboInputData.setLabelProvider(new ObservableMapLabelProvider( EMFProperties.value(ModelPackage.Literals.INPUT_DATA_NUMERIC__DATA_TYPE) .observeDetail(contentProvider.getKnownElements()))); comboInputData.setContentProvider(ArrayContentProvider.getInstance()); comboInputData.setLabelProvider(new ComboInputDataTypeLabelProvider()); comboInputData.setInput(DataType.VALUES); compositeInputData = new Composite(compositeType, SWT.NONE); compositeInputData.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); GridLayout gl = new GridLayout(2, false); gl.marginHeight = 0; gl.marginWidth = 0; compositeInputData.setLayout(gl); comboInputData.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event){ updateInputData( (DataType) ((StructuredSelection) event.getSelection()).getFirstElement()); updateSize(); } }); }
Example 9
Source File: JointDataSetPage.java From birt with Eclipse Public License 1.0 | 5 votes |
/** * create right composite for page * * @param composite */ private void createRightGroup( Composite composite ) { rightGroup = new Group( composite, SWT.NONE ); rightGroup.setLayout( new FormLayout( ) ); rightGroup.setLayoutData( new GridData( GridData.FILL_BOTH ) ); FormData data = new FormData( ); data.top = new FormAttachment( 0, 5 ); data.left = new FormAttachment( 0, 5 ); data.right = new FormAttachment( 100, -5 ); data.bottom = new FormAttachment( 10, -5 ); rightDataSetChooser = new ComboViewer( rightGroup, SWT.DROP_DOWN | SWT.READ_ONLY ); rightDataSetChooser.getControl( ).setLayoutData( data ); DataSetComboProvider provider = new DataSetComboProvider( ); rightDataSetChooser.setContentProvider( provider ); rightDataSetChooser.setLabelProvider( provider ); rightDataSetChooser.setInput( dataSetList ); rightDataSetChooser.addSelectionChangedListener( this ); data = new FormData( ); data.top = new FormAttachment( rightDataSetChooser.getControl( ), 10 ); data.left = new FormAttachment( 0, 5 ); data.right = new FormAttachment( 100, -5 ); data.bottom = new FormAttachment( 100, -5 ); rightColumnList = new ListViewer( rightGroup, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER ); rightColumnList.getControl( ).setLayoutData( data ); ColumnProvider colProvider = new ColumnProvider( ); rightColumnList.setContentProvider( colProvider ); rightColumnList.setLabelProvider( colProvider ); rightColumnList.addSelectionChangedListener( this ); }
Example 10
Source File: ConstructorFieldPage.java From Pydev with Eclipse Public License 1.0 | 5 votes |
private ComboViewer createComboViewer(Composite comboComp) { ComboViewer v = new ComboViewer(comboComp); v.setContentProvider(this.strategyProvider); v.setLabelProvider(new LabelProvider()); v.setInput(""); return v; }
Example 11
Source File: ConverterUtil.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
public static void bindValue(DataBindingContext context,ComboViewer comboViewer, ConverterViewModel model) { // ViewerSupport.bind(comboViewer, BeansObservables.observeList( // model, "supportTypes", String.class), // Properties.selfValue(String.class)); // // // context.bindValue(ViewersObservables // .observeSingleSelection(comboViewer), BeansObservables // .observeValue(model, // "selectedType")); // ObservableListContentProvider viewerContentProvider=new ObservableListContentProvider(); comboViewer.setContentProvider(new ArrayContentProvider()); comboViewer.setComparator(new ViewerComparator()); // IObservableMap[] attributeMaps = BeansObservables.observeMaps( // viewerContentProvider.getKnownElements(), // ConverterBean.class, new String[] { "description" }); // comboViewer.setLabelProvider(new ObservableMapLabelProvider( // attributeMaps)); // comboViewer.setInput(Observables.staticObservableList(model.getSupportTypes(),ConverterBean.class)); comboViewer.setInput(model.getSupportTypes()); IViewerObservableValue selection=ViewersObservables.observeSingleSelection(comboViewer); IObservableValue observableValue=BeansObservables.observeDetailValue(selection, "name", ConverterBean.class); context.bindValue(observableValue, BeansObservables .observeValue(model, "selectedType")); }
Example 12
Source File: NewCheckCatalogWizardPage.java From dsl-devkit with Eclipse Public License 1.0 | 5 votes |
/** * Creates the grammars controls. * * @param composite * the composite */ private void createGrammarsControls(final Composite composite) { Label generatorConfigLabel = new Label(composite, SWT.NONE); generatorConfigLabel.setText(Messages.GRAMMAR_FIELD_NAME_LABEL); Combo generatorConfigurationField = new Combo(composite, SWT.READ_ONLY); GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1); data.widthHint = PAGE_WIDTH_HINT; // prevents shrinking of combo view generatorConfigurationField.setLayoutData(data); generatorConfigurationField.setFont(composite.getFont()); ComboViewer grammars = new ComboViewer(generatorConfigurationField); grammars.setContentProvider(new ArrayContentProvider()); grammars.setLabelProvider(new LabelProvider() { @Override public String getText(final Object object) { if (object instanceof Grammar) { return new GrammarHelper((Grammar) object).getLabelName(); } return super.getText(object); } }); grammars.setInput(resourceUtil.getGrammars()); // React to the selection of the viewer // Note that the viewer return the real object and not just a string // representation grammars.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(final SelectionChangedEvent event) { if (event.getSelection() instanceof StructuredSelection) { grammar = (Grammar) ((StructuredSelection) event.getSelection()).getFirstElement(); grammarStatus = validateGrammarAccess(); handleFieldChanged(GRAMMAR); } } }); grammars.setSelection(null); // no pre-defined grammar to be used, forces the user to make a decision about which language to target }
Example 13
Source File: ConverterUtil.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
/** * 对下拉列表和转换器列表进行绑定 * @param context * @param comboViewer * @param model * ; */ public static void bindValue(DataBindingContext context, ComboViewer comboViewer, ConverterViewModel model) { // ViewerSupport.bind(comboViewer, BeansObservables.observeList( // model, "supportTypes", String.class), // Properties.selfValue(String.class)); // // // context.bindValue(ViewersObservables // .observeSingleSelection(comboViewer), BeansObservables // .observeValue(model, // "selectedType")); // ObservableListContentProvider viewerContentProvider=new ObservableListContentProvider(); comboViewer.setContentProvider(new ArrayContentProvider()); comboViewer.setComparator(new ViewerComparator()); // IObservableMap[] attributeMaps = BeansObservables.observeMaps( // viewerContentProvider.getKnownElements(), // ConverterBean.class, new String[] { "description" }); // comboViewer.setLabelProvider(new ObservableMapLabelProvider( // attributeMaps)); // comboViewer.setInput(Observables.staticObservableList(model.getSupportTypes(),ConverterBean.class)); comboViewer.setInput(model.getSupportTypes()); IViewerObservableValue selection = ViewersObservables.observeSingleSelection(comboViewer); IObservableValue observableValue = BeansObservables.observeDetailValue(selection, PROPERTIES_NAME, null); context.bindValue(observableValue, BeansObservables.observeValue(model, PROPERTIES_SELECTED_TYPE)); }
Example 14
Source File: ActivityTypeSelectionGridPropertySectionContribution.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private void createActivitySelectionCombo(Composite parent, TabbedPropertySheetWidgetFactory widgetFactory) { combo = new ComboViewer(parent, SWT.READ_ONLY); combo.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); combo.setContentProvider(new ArrayContentProvider()); combo.setLabelProvider(new LabelProvider()); combo.setInput(new String[]{ACTIVITY_TYPE__TASK,ACTIVITY_TYPE__SYSTEM,ACTIVITY_TYPE__CALL_ACTVITY,ACTIVITY_TYPE__RECEIVE_TASK,ACTIVITY_TYPE__SEND_TASK,ACTIVITY_TYPE__SERVICE_TASK,ACTIVITY_TYPE__SCRIPT_TASK}); combo.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent arg0) { if (toBeConverted()) { EClass targetEClass = getTargetEClass(); IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor() ; if(editor instanceof ProcessDiagramEditor){ node = (GraphicalEditPart) ((IStructuredSelection)((ProcessDiagramEditor)editor).getDiagramGraphicalViewer().getSelection()).getFirstElement() ; GMFTools.convert(targetEClass, node, new BonitaNodesElementTypeResolver(),GMFTools.PROCESS_DIAGRAM); for(IViewReference vr : PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences() ){ if(vr.getId().startsWith("org.bonitasoft.studio.views.properties")){ IViewPart viewPart = vr.getView(false) ; if(viewPart != null){ IPropertySheetPage page = (IPropertySheetPage) viewPart.getAdapter(IPropertySheetPage.class); if(page != null){ page.selectionChanged(editor, ((ProcessDiagramEditor)editor).getDiagramGraphicalViewer().getSelection()); } } } } } } } }); }
Example 15
Source File: ColumnFilterDialog.java From nebula with Eclipse Public License 2.0 | 4 votes |
@Override protected void createExtendedArea(Composite parent) { super.createExtendedArea(parent); if (column.getSortDataType() == SortDataType.Date) { widgetComp = new Composite(parent, SWT.NONE); widgetComp.setLayout(new GridLayout(6, false)); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; widgetComp.setLayoutData(gd); Label label = new Label(widgetComp, SWT.NONE); label.setText("Date Match: "); dateRangeTypeCombo = new ComboViewer(widgetComp, SWT.NONE); dateRangeTypeCombo.setContentProvider(new ArrayContentProvider()); dateRangeTypeCombo.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return ((DateRangeType) element).getDisplayName(); } }); dateRangeTypeCombo.setInput(DateRangeType.values()); dateRangeTypeCombo.addSelectionChangedListener(event -> { String text2 = dateRangeTypeCombo.getCombo().getText(); dateRangeType = DateRangeType.get(text2); updateDate2Composite(); }); date1Widget = new DateTime(widgetComp, SWT.CALENDAR); date1Widget.addListener(SWT.Selection, e-> setDate1Selection()); // set initial date Calendar cal = Calendar.getInstance(); cal.set(date1Widget.getYear(), date1Widget.getMonth(), date1Widget.getDay(), 0, 0); date1 = cal.getTime(); time1Widget = new DateTime(widgetComp, SWT.TIME); time1Widget.addListener(SWT.Selection, e-> setDate1Selection()); time1Widget.setHours(0); time1Widget.setMinutes(0); time1Widget.setSeconds(0); } }
Example 16
Source File: CodingSelectionComposite.java From elexis-3-core with Eclipse Public License 1.0 | 4 votes |
public CodingSelectionComposite(Composite parent, int style){ super(parent, style); GridLayout gridLayout = new GridLayout(2, false); gridLayout.marginHeight = 0; gridLayout.marginWidth = 0; setLayout(gridLayout); systemCombo = new ComboViewer(this); systemCombo.setContentProvider(new ArrayContentProvider()); systemCombo.setLabelProvider(new LabelProvider() { @Override public String getText(Object element){ return super.getText(element); } }); systemCombo.setInput(CodingServiceComponent.getService().getAvailableCodeSystems().stream() .filter(system -> !system.equals(CodingSystem.ELEXIS_LOCAL_CODESYSTEM.getSystem())) .collect(Collectors.toList())); systemCombo.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(SelectionChangedEvent event){ if (proposalProvider != null) { ISelection selection = event.getSelection(); if (selection instanceof StructuredSelection && !selection.isEmpty()) { proposalProvider .setSelectedSystem(Optional .of((String) ((StructuredSelection) selection).getFirstElement())); } else { proposalProvider.setSelectedSystem(Optional.empty()); } } } }); selectionTxt = new Text(this, SWT.BORDER); selectionTxt.setMessage("Coding selektieren"); selectionTxt.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); proposalProvider = new CodingContentProposalProvider(); ContentProposalAdapter toAddressProposalAdapter = new ContentProposalAdapter(selectionTxt, new TextContentAdapter(), proposalProvider, null, null); toAddressProposalAdapter.addContentProposalListener(new IContentProposalListener() { @Override public void proposalAccepted(IContentProposal proposal){ selectionTxt.setText(proposal.getContent()); proposalProvider.getCodingForProposal(proposal) .ifPresent(iCoding -> selectedCode = Optional.of(iCoding)); selectionTxt.setSelection(selectionTxt.getText().length()); Object[] listeners = selectionListeners.getListeners(); for (Object object : listeners) { SelectionChangedEvent selectionEvent = new SelectionChangedEvent(CodingSelectionComposite.this, getSelection()); ((ISelectionChangedListener) object).selectionChanged(selectionEvent); } } }); MenuManager menuManager = new MenuManager(); menuManager.add(new Action("Lokalen Code anlegen") { @Override public void run(){ TransientCoding transientCoding = new TransientCoding( CodingSystem.ELEXIS_LOCAL_CODESYSTEM.getSystem(), selectionTxt.getSelectionText(), ""); CodingEditDialog editDialog = new CodingEditDialog(transientCoding, getShell()); if (editDialog.open() == CodingEditDialog.OK) { CodingServiceComponent.getService().addLocalCoding(transientCoding); // trigger reload of code system setCodeSystem(CodingSystem.ELEXIS_LOCAL_CODESYSTEM.getSystem()); } } @Override public boolean isEnabled(){ ISelection systemSelection = systemCombo.getSelection(); if (systemSelection instanceof StructuredSelection) { Object codeSystem = ((StructuredSelection) systemSelection).getFirstElement(); if(codeSystem instanceof String && codeSystem.equals(CodingSystem.ELEXIS_LOCAL_CODESYSTEM.getSystem()) ) { String text = selectionTxt.getSelectionText(); return text != null && !text.isEmpty(); } } return false; } }); menuManager.addMenuListener(new IMenuListener() { @Override public void menuAboutToShow(IMenuManager manager){ IContributionItem[] items = manager.getItems(); for (IContributionItem iContributionItem : items) { iContributionItem.update(); } } }); selectionTxt.setMenu(menuManager.createContextMenu(selectionTxt)); }
Example 17
Source File: ConditionComposite.java From elexis-3-core with Eclipse Public License 1.0 | 4 votes |
public ConditionComposite(ConditionCategory category, Composite parent, int style){ super(parent, style); setLayout(new GridLayout(1, false)); this.category = category; condition = Optional.empty(); statusViewer = new ComboViewer(this); statusViewer.setContentProvider(new ArrayContentProvider()); statusViewer.setInput(ConditionStatus.values()); statusViewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element){ if (element instanceof ConditionStatus) { return ((ConditionStatus) element).getLocalized(); } return super.getText(element); } }); startTxt = new Text(this, SWT.BORDER); startTxt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); startTxt.setMessage("Beginn Datum oder Beschreibung"); endTxt = new Text(this, SWT.BORDER); endTxt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); endTxt.setMessage("Ende Datum oder Beschreibung"); textOrCodingFolder = new TabFolder(this, SWT.NONE); TabItem textItem = new TabItem(textOrCodingFolder, SWT.NONE, 0); textItem.setText("Text"); textTxt = new Text(textOrCodingFolder, SWT.MULTI | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL); textItem.setControl(textTxt); TabItem codingItem = new TabItem(textOrCodingFolder, SWT.NONE, 1); codingItem.setText("Kodierung"); codingComposite = new CodingListComposite(textOrCodingFolder, SWT.NONE); codingComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); codingItem.setControl(codingComposite); GridData folderGd = new GridData(GridData.FILL_BOTH); textOrCodingFolder.setLayoutData(folderGd); notesComposite = new NoteListComposite(this, SWT.NONE); notesComposite.showTitle(true); notesComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); initDataBinding(); }
Example 18
Source File: QueryExpressionEditor.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
private void createQueryComboViewer(final Composite composite, final IObservableList observeQueryList) { final Composite queryComposite = new Composite(composite, SWT.NONE); queryComposite.setLayoutData(GridDataFactory.fillDefaults().create()); queryComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).spacing(0, 2).create()); final Label queryLabel = new Label(queryComposite, SWT.NONE); queryLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).create()); queryLabel.setText(Messages.queries); final ComboViewer queryCombo = new ComboViewer(queryComposite, SWT.READ_ONLY | SWT.BORDER); queryCombo.getControl().setLayoutData( GridDataFactory.fillDefaults().grab(true, false).hint(150, SWT.DEFAULT).create()); queryCombo.setLabelProvider(new LabelProvider() { @Override public String getText(final Object element) { if (element instanceof Expression) { String name = ((Expression) element).getName(); if (name.indexOf(".") != -1) { name = name.substring(name.indexOf(".") + 1, name.length()); } return name; } return super.getText(element); } }); queryCombo.setContentProvider(new ObservableListContentProvider()); queryCombo.setInput(observeQueryList); observeQuerySingleSelection = ViewersObservables.observeSingleSelection(queryCombo); observeBOSingleSelection.addValueChangeListener(new IValueChangeListener() { @Override public void handleValueChange(final ValueChangeEvent event) { if (event.diff.getOldValue() != null && observeQuerySingleSelection.getValue() == null) { observeQuerySingleSelection.setValue(observeQueryList.get(0)); } } }); }
Example 19
Source File: CatchEventEventSelectionContribution.java From bonita-studio with GNU General Public License v2.0 | 4 votes |
@Override public void createControl(final Composite composite, final TabbedPropertySheetWidgetFactory widgetFactory, final ExtensibleGridPropertySection extensibleGridPropertySection) { combo = new ComboViewer(composite, SWT.NONE); combo.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); combo.setLabelProvider(new EventLabelProvider()); combo.setContentProvider(ArrayContentProvider.getInstance()); combo.addFilter(new ViewerFilter() { @Override public boolean select(final Viewer viewer, final Object parentElement, final Object element) { if (element instanceof EventObject) { final ThrowMessageEvent source = ((Message) element).getSource(); if (eObject != null) { if (source != null) { final AbstractProcess parentProcessOfSourceMessage = ModelHelper.getParentProcess(source); if (parentProcessOfSourceMessage != null && parentProcessOfSourceMessage.equals(ModelHelper.getParentProcess(eObject))) { return false; } } } } return true; } }); final List<Message> events = retrievePossibleMessageEvents(); combo.setInput(events); if (eObject.getEvent() != null) { combo.getCombo().setText(eObject.getEvent()); oldEventName = combo.getCombo().getText(); } combo.addSelectionChangedListener(new ISelectionChangedListener() { @Override public void selectionChanged(final SelectionChangedEvent arg0) { handleSelectionChanged(); } }); combo.getCombo().addListener(SWT.Modify, new Listener() { @Override public void handleEvent(final Event event) { handleSelectionChanged(); } }); }
Example 20
Source File: SimpleFileSetsEditor.java From eclipse-cs with GNU Lesser General Public License v2.1 | 4 votes |
/** * {@inheritDoc} */ @Override public Control createContents(Composite parent) throws CheckstylePluginException { mController = new Controller(); // group composite containing the config settings Group configArea = new Group(parent, SWT.NULL); configArea.setText(Messages.SimpleFileSetsEditor_titleSimpleConfig); configArea.setLayout(new FormLayout()); this.mBtnManageConfigs = new Button(configArea, SWT.PUSH); this.mBtnManageConfigs.setText(Messages.SimpleFileSetsEditor_btnManageConfigs); this.mBtnManageConfigs.addSelectionListener(mController); FormData fd = new FormData(); fd.top = new FormAttachment(0, 3); fd.right = new FormAttachment(100, -3); this.mBtnManageConfigs.setLayoutData(fd); mComboViewer = new ComboViewer(configArea); mComboViewer.getCombo().setVisibleItemCount(10); mComboViewer.setContentProvider(new CheckConfigurationContentProvider()); mComboViewer.setLabelProvider(new CheckConfigurationLabelProvider()); mComboViewer.setComparator(new CheckConfigurationViewerSorter()); mComboViewer.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); mComboViewer.addSelectionChangedListener(mController); fd = new FormData(); fd.left = new FormAttachment(0, 3); fd.top = new FormAttachment(0, 3); fd.right = new FormAttachment(mBtnManageConfigs, -3, SWT.LEFT); // fd.right = new FormAttachment(100, -3); mComboViewer.getCombo().setLayoutData(fd); // Description Label lblConfigDesc = new Label(configArea, SWT.LEFT); lblConfigDesc.setText(Messages.SimpleFileSetsEditor_lblDescription); fd = new FormData(); fd.left = new FormAttachment(0, 3); fd.top = new FormAttachment(mComboViewer.getCombo(), 3, SWT.BOTTOM); fd.right = new FormAttachment(100, -3); lblConfigDesc.setLayoutData(fd); this.mTxtConfigDescription = new Text(configArea, SWT.LEFT | SWT.WRAP | SWT.MULTI | SWT.READ_ONLY | SWT.BORDER | SWT.VERTICAL); fd = new FormData(); fd.left = new FormAttachment(0, 3); fd.top = new FormAttachment(lblConfigDesc, 0, SWT.BOTTOM); fd.right = new FormAttachment(100, -3); fd.bottom = new FormAttachment(100, -3); this.mTxtConfigDescription.setLayoutData(fd); // init the check configuration combo mComboViewer.setInput(mPropertyPage.getProjectConfigurationWorkingCopy()); if (mDefaultFileSet.getCheckConfig() != null) { mComboViewer.setSelection(new StructuredSelection(mDefaultFileSet.getCheckConfig())); } return configArea; }