org.eclipse.jface.viewers.LabelProvider Java Examples
The following examples show how to use
org.eclipse.jface.viewers.LabelProvider.
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: FilteredDefinitionSelectionDialog.java From tlaplus with MIT License | 6 votes |
/** * Creates a label provider for the detail section below the list<br> * The label provider prints out the name of operation definition and the module the operation is defined in */ private ILabelProvider getDetailLabelProvider() { return new LabelProvider() { public String getText(Object element) { if (element instanceof OpDefNode) { OpDefNode node = (OpDefNode) element; return node.getSource().getName().toString() + ((node.getSource().getOriginallyDefinedInModuleNode() != null) ? " : " + node.getSource().getOriginallyDefinedInModuleNode().getName().toString() : ""); } return super.getText(element); } }; }
Example #2
Source File: BindingGroupDescriptorProvider.java From birt with Eclipse Public License 1.0 | 6 votes |
public ILabelProvider getDataSetLabelProvider( ) { return new LabelProvider( ) { public String getText( Object element ) { BindingInfo info = (BindingInfo) element; String datasetName = info.getBindingValue( ); if ( !info.isDataSet( ) ) { if ( !NONE.equals( datasetName ) ) { datasetName += Messages.getString("BindingGroupDescriptorProvider.Flag.DataModel"); //$NON-NLS-1$ } } return datasetName; } }; }
Example #3
Source File: ContractPropertySectionTest.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Test public void should_bindAddChildButtonEnablement_convert_boolean_value() throws Exception { section.init(new WritableValue(aContract().build(), Contract.class)); final Button button = new Button(parent, SWT.PUSH); final TableViewer inputsTableViewer = new TableViewer(parent); inputsTableViewer.setLabelProvider(new LabelProvider()); inputsTableViewer.setContentProvider(ArrayContentProvider.getInstance()); final ContractInput textParentInput = ProcessFactory.eINSTANCE.createContractInput(); textParentInput.setType(ContractInputType.TEXT); final ContractInput complexParentInput = ProcessFactory.eINSTANCE.createContractInput(); complexParentInput.setType(ContractInputType.COMPLEX); inputsTableViewer.setInput(Arrays.asList(textParentInput, complexParentInput)); section.bindAddChildButtonEnablement(button, inputsTableViewer); assertThat(button.isEnabled()).isFalse(); assertThat(inputsTableViewer.getSelection().isEmpty()).isTrue(); inputsTableViewer.setSelection(new StructuredSelection(textParentInput)); assertThat(button.isEnabled()).isFalse(); assertThat(inputsTableViewer.getSelection().isEmpty()).isFalse(); inputsTableViewer.setSelection(new StructuredSelection(complexParentInput)); assertThat(button.isEnabled()).isTrue(); }
Example #4
Source File: SelectElementDialog.java From Pydev with Eclipse Public License 1.0 | 6 votes |
public static <T> T selectOne(List<T> items, LabelProvider labelProvider, String message) { Shell activeShell = Display.getCurrent().getActiveShell(); SelectElementDialog dialog = new SelectElementDialog(activeShell, labelProvider); dialog.setTitle("Select One"); dialog.setMessage(message); dialog.setElements(items.toArray()); dialog.setMultipleSelection(false); int returnCode = dialog.open(); if (returnCode == Window.OK) { return (T) dialog.getFirstResult(); } return null; }
Example #5
Source File: PageComponentSwitchBuilder.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
public ExpressionViewer createTextControl(final Composite composite, final Text object, final IExpressionNatureProvider expressionProvider, final LabelProvider autoCompletionLabelProvider) { final Input input = getConnectorInput(object.getInputName()); if (input != null) { final ConnectorParameter parameter = connectorConfigurationSupport.getConnectorParameter(object.getInputName(), object, input); if (parameter != null) { createFieldLabel(composite, SWT.CENTER, object.getId(), input.isMandatory()); return buildExpressionViewer(composite, object, expressionProvider, input, parameter, autoCompletionLabelProvider); } } else { //Should we create a label to warn final user? BonitaStudioLog.log("WARNING: No input found with name " + object.getInputName()); } return null; }
Example #6
Source File: ExcelFileSelectionWizardPage.java From birt with Eclipse Public License 1.0 | 6 votes |
/** * Create the top composite of the page * * @param composite * @param label */ private void createTopComposite( Composite composite, Label label ) { FormData data = new FormData( ); data.left = new FormAttachment( label, 5 ); data.right = new FormAttachment( 40, -5 ); worksheetsCombo = new ComboViewer( composite, SWT.BORDER | SWT.READ_ONLY ); worksheetsCombo.getControl( ).setLayoutData( data ); worksheetsCombo.setContentProvider( new ArrayContentProvider( ) ); worksheetsCombo.addSelectionChangedListener( this ); worksheetsCombo.setLabelProvider( new LabelProvider( ) { public String getText( Object element ) { return getFileName( element ); } } ); data = new FormData( ); data.left = new FormAttachment( worksheetsCombo.getControl( ), 5 ); data.top = new FormAttachment( 0, 5 ); }
Example #7
Source File: TaskOverview.java From codeexamples-eclipse with Eclipse Public License 1.0 | 6 votes |
@Override public void createPartControl(Composite parent) { viewer = new ListViewer(parent); viewer.setContentProvider(ArrayContentProvider.getInstance()); viewer.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { Task p = (Task) element; return p.getSummary(); }; }); viewer.setInput(TaskService.getInstance().getTasks()); getSite().setSelectionProvider(viewer); hookDoubleClickCommand(); }
Example #8
Source File: N4JSHierarchicalNameComputerHelper.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * Calculate the hierarchically qualified name of an EObject. * * @param eob * the EObject to calculate hierarchically name for * @param labelProvider * the label provider that knows how to display EObject instances * * @return the hierarchical name. */ public static String calculateHierarchicalDisplayName(EObject eob, LabelProvider labelProvider, boolean includeRoot) { // Calculate hierarchical logical name, e.g. C/m String text = labelProvider.getText(eob); EObject currContainer = eob.eContainer(); while (currContainer != null) { if (isShowable(currContainer)) { text = labelProvider.getText(currContainer) + DELIMITER + text; } currContainer = currContainer.eContainer(); if (currContainer != null && !includeRoot && currContainer instanceof Script) break; } return text; }
Example #9
Source File: ColumnViewerBuilder.java From n4js with Eclipse Public License 1.0 | 6 votes |
/** * Creates a new {@link TableViewer table viewer} builder with the given list of table column labels. * * @param columnLabels * a list of table column labels to use for the new table viewer. Cannot be {@code null}. Must not be * empty. * */ protected ColumnViewerBuilder(final List<String> columnLabels, final CP contentProvider) { this.columnLabels = checkNotNull(columnLabels, "columnLabels"); this.contentProvider = checkNotNull(contentProvider, "contentProvider"); checkArgument(!this.columnLabels.isEmpty(), "Empty column labels are not allowed. At least one column should be specified."); headerVisible = true; linesVisible = true; useHashlookup = false; labelProvider = new LabelProvider(); multipleSelection = false; fullSelection = true; resizable = true; hasBorder = false; moveable = true; }
Example #10
Source File: CostDialog.java From olca-app with Mozilla Public License 2.0 | 6 votes |
private void createCurrencyRow(Composite body, FormToolkit tk) { Combo widget = UI.formCombo(body, tk, M.Currency); currencyCombo = new ComboViewer(widget); currencyCombo.setLabelProvider(new LabelProvider() { @Override public String getText(Object obj) { if (!(obj instanceof Currency)) return super.getText(obj); return ((Currency) obj).name; } }); setCurrencyContent(currencyCombo); currencyCombo.addSelectionChangedListener(e -> { currency = Viewers.getFirst(e.getSelection()); exchange.currency = currency; updateCurrencyLabels(); }); UI.filler(body, tk); }
Example #11
Source File: DotnetTestTab.java From aCute with Eclipse Public License 2.0 | 6 votes |
private void displayMethodSelectorDialog() { ElementListSelectionDialog dialog = new ElementListSelectionDialog(classBrowseButton.getShell(), new LabelProvider()); dialog.setTitle(NLS.bind(Messages.DotnetTestTab_methodSelection_title, classText.getText())); dialog.setMessage(Messages.DotnetTestTab_methodSelection_message); List<String> methods = testMethods.get(classText.getText()); if(methods!=null) { dialog.setElements(methods.toArray()); } dialog.open(); String selected = (String) dialog.getFirstResult(); if (selected != null) { methodText.setText(selected); setDirty(true); updateLaunchConfigurationDialog(); } }
Example #12
Source File: UnansweredDocumentsView.java From slr-toolkit with Eclipse Public License 1.0 | 6 votes |
public UnansweredDocumentsView(Composite parent, IWorkbenchPartSite site, Supplier<Questionnaire> questionnaireSupplier, Supplier<IProject> projectSupplier) { this.questionnaireSupplier = questionnaireSupplier; this.projectSupplier = projectSupplier; incompleteDocumentsLabel = new Label(parent, 0); incompleteDocumentsLabel.setText(TEMPLATE_ANSWERS_COMPLETE); incompleteDocumentsLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false, 2, 1)); incompleteDocumentsList = new ListViewer(parent, SWT.V_SCROLL); GridData gd = new GridData(SWT.BEGINNING, SWT.BEGINNING, false, false, 2, 1); gd.heightHint = (int) (((org.eclipse.swt.widgets.List) incompleteDocumentsList.getControl()).getItemHeight() * 4); gd.widthHint = 300; incompleteDocumentsList.getControl().setLayoutData(gd); incompleteDocumentsList.getControl().setVisible(false); incompleteDocumentsList.setSorter(new ViewerSorter()); incompleteDocumentsList.setContentProvider(ArrayContentProvider.getInstance()); incompleteDocumentsList.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return ((Document) element).getKey(); } }); site.setSelectionProvider(incompleteDocumentsList); }
Example #13
Source File: CListTable.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
private void createTable(Composite parent) { tableViewer = new TableViewer(parent, SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION); tableViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); tableViewer.setContentProvider(ArrayContentProvider.getInstance()); tableViewer.setLabelProvider(new LabelProvider()); tableViewer.setComparator(new ViewerComparator()); tableViewer.setInput(items); tableViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { updateStates(); } }); updateStates(); }
Example #14
Source File: SVNWizardPage.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * Creates a ListViewer whose input is an array of IFiles. * * @param parent the parent of the viewer * @param title the text for the title label * @param heightHint the nominal height of the list * @return the created list viewer */ public ListViewer createFileListViewer(Composite parent, String title, int heightHint) { createLabel(parent, title); ListViewer listViewer = new ListViewer(parent, SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); listViewer.setContentProvider(new IStructuredContentProvider() { public Object[] getElements(Object inputElement) { return (Object[]) inputElement; } public void dispose() { } public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } }); listViewer.setLabelProvider(new LabelProvider() { public String getText(Object element) { return ((IFile) element).getFullPath().toString(); } }); listViewer.setSorter(new WorkbenchViewerSorter()); GridData data = new GridData(GridData.FILL_BOTH); data.heightHint = heightHint; listViewer.getList().setLayoutData(data); return listViewer; }
Example #15
Source File: ChooseRootUrlDialog.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * * @param parent * @param url : the url from which we want to get the root url */ public ChooseRootUrlDialog(Shell parent, SVNUrl url) { super(parent); this.url = url; List list = new ArrayList(); // we want the user can select "no root url", ie a blank url list.add(""); // we cannot add null, we would have a NullPointerException //$NON-NLS-1$ SVNUrl possibleRoot = this.url; while (possibleRoot != null) { list.add(possibleRoot); possibleRoot = possibleRoot.getParent(); } setTitle(Policy.bind("ChooseRootUrlDialog.rootUrlDialogTitle")); //$NON-NLS-1$ setAddCancelButton(true); setLabelProvider(new LabelProvider()); setMessage(Policy.bind("ChooseRootUrlDialog.chooseRootUrl")); //$NON-NLS-1$ setContentProvider(new ListContentProvider()); setInput(list); }
Example #16
Source File: DotnetTestTab.java From aCute with Eclipse Public License 2.0 | 6 votes |
private void displayClassSelectorDialog() { ElementListSelectionDialog dialog = new ElementListSelectionDialog(classBrowseButton.getShell(), new LabelProvider()); dialog.setTitle(Messages.DotnetTestTab_classSelection_title); dialog.setMessage(Messages.DotnetTestTab_classSelection_message); dialog.setElements(testMethods.keySet().toArray()); dialog.open(); String selected = (String) dialog.getFirstResult(); if (selected != null) { methodBrowseButton.setEnabled(true); methodLabel.setEnabled(true); methodText.setEnabled(true); classText.setText(selected); setDirty(true); updateLaunchConfigurationDialog(); } }
Example #17
Source File: AbstractActorsPropertySection.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private void createActorComboViewer(final Composite mainComposite) { actorComboViewer = new ComboViewer(mainComposite, SWT.SINGLE | SWT.BORDER | SWT.READ_ONLY) ; actorComboViewer.getCombo().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()) ; actorComboViewer.setContentProvider(new ArrayContentProvider()) ; actorComboViewer.setLabelProvider(new LabelProvider(){ @Override public String getText(final Object element) { if(element instanceof Actor){ String doc = ((Actor) element).getDocumentation() ; if(doc != null && !doc.isEmpty()){ doc = " -- "+ doc ; }else{ doc = "" ; } return ((Actor) element).getName() + doc ; } return super.getText(element); } }); }
Example #18
Source File: GroupsWizardPage.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected void configureViewer(final StructuredViewer viewer) { viewer.setLabelProvider(new LabelProvider() { @Override public String getText(final Object element) { final String displayName = ((org.bonitasoft.studio.actors.model.organization.Group) element).getDisplayName(); if (displayName == null || displayName.isEmpty()) { return ((org.bonitasoft.studio.actors.model.organization.Group) element).getName(); } return displayName; } }); if (groupList != null && getViewer() != null) { getViewer().setInput(groupList); ((TreeViewer) getViewer()).expandAll(); } }
Example #19
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 #20
Source File: StatechartPropertySection.java From statecharts with Eclipse Public License 1.0 | 6 votes |
protected void createDomainCombo(Composite leftColumn) { Label label = getToolkit().createLabel(leftColumn, "Statechart domain"); GridDataFactory.fillDefaults().span(2, 1).align(SWT.FILL, SWT.CENTER).applyTo(label); domainCombo = new ComboViewer(leftColumn); GridDataFactory.fillDefaults().span(1, 1).align(SWT.FILL, SWT.CENTER).applyTo(domainCombo.getCombo()); Label spacer = getToolkit().createLabel(leftColumn, ""); GridDataFactory.fillDefaults().applyTo(spacer); domainCombo.setContentProvider(new ArrayContentProvider()); domainCombo.setLabelProvider(new LabelProvider() { @Override public String getText(Object element) { return ((IDomain) element).getName(); } }); List<IDomain> domains = DomainRegistry.getDomains(); for (IDomain domainDescriptor : domains) { domainCombo.add(domainDescriptor); } if (domains.size() <= 1) { domainCombo.getControl().setEnabled(false); } }
Example #21
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 #22
Source File: ViewerConfigurer.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
/** * Default constructor creating a viewer with a control field and button. * * @param cnp * @param lp * @param cfp * @param bp * @param wp */ public ViewerConfigurer(ICommonViewerContentProvider cnp, LabelProvider lp, ControlFieldProvider cfp, ButtonProvider bp, WidgetProvider wp){ contentProvider = cnp; labelProvider = (lp == null) ? new DefaultLabelProvider() : lp; controlFieldProvider = cfp; buttonProvider = bp; widgetProvider = wp; }
Example #23
Source File: ContractPropertySectionTest.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
@Test public void should_bindRemoveButtonEnablement_convert_boolean_value() throws Exception { section.init(new WritableValue(aContract().build(), Contract.class)); final Button removeButton = new Button(parent, SWT.PUSH); final TableViewer inputsTableViewer = new TableViewer(parent); inputsTableViewer.setLabelProvider(new LabelProvider()); inputsTableViewer.setContentProvider(ArrayContentProvider.getInstance()); inputsTableViewer.setInput(Arrays.asList("item")); section.bindRemoveButtonEnablement(removeButton, inputsTableViewer); assertThat(removeButton.isEnabled()).isFalse(); assertThat(inputsTableViewer.getSelection().isEmpty()).isTrue(); inputsTableViewer.setSelection(new StructuredSelection("item")); assertThat(removeButton.isEnabled()).isTrue(); assertThat(inputsTableViewer.getSelection().isEmpty()).isFalse(); }
Example #24
Source File: QueryExpressionEditor.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private void createBusinessObjectComboViewer(final Composite composite, final IObservableList observeBoList) { final Composite boComposite = new Composite(composite, SWT.NONE); boComposite.setLayoutData(GridDataFactory.fillDefaults().create()); boComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).margins(0, 0).spacing(0, 2).create()); final Label boLabel = new Label(boComposite, SWT.NONE); boLabel.setLayoutData(GridDataFactory.fillDefaults().align(SWT.LEFT, SWT.CENTER).create()); boLabel.setText(Messages.businessObject); final ComboViewer boCombo = new ComboViewer(boComposite, SWT.READ_ONLY | SWT.BORDER); boCombo.getControl().setLayoutData( GridDataFactory.fillDefaults().grab(true, false).minSize(100, SWT.DEFAULT).create()); boCombo.setLabelProvider(new LabelProvider() { @Override public String getText(final Object element) { if (element instanceof BusinessObjectExpressionQuery) { return ((BusinessObjectExpressionQuery) element).getQualifiedName(); } return super.getText(element); } }); boCombo.setContentProvider(new ObservableListContentProvider()); boCombo.setInput(observeBoList); observeBOSingleSelection = ViewersObservables.observeSingleSelection(boCombo); }
Example #25
Source File: ILocalizedEnumLabelProvider.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
public static IBaseLabelProvider getInstance(){ synchronized (LabelProvider.class) { if (instance == null) { instance = new ILocalizedEnumLabelProvider(); } return instance; } }
Example #26
Source File: EntryPropertySection.java From statecharts with Eclipse Public License 1.0 | 5 votes |
private void createEntryKindControl(Composite parent) { Label kindLabel = getToolkit().createLabel(parent, "Entry Kind: "); GridDataFactory.fillDefaults().applyTo(kindLabel); entryKindViewer = new ComboViewer(parent, SWT.READ_ONLY | SWT.SINGLE); entryKindViewer.setContentProvider(new ArrayContentProvider()); entryKindViewer.setLabelProvider(new LabelProvider()); entryKindViewer.setInput(EntryKind.values()); GridDataFactory.fillDefaults().grab(true, false) .applyTo(entryKindViewer.getControl()); }
Example #27
Source File: ChoicePropertySection.java From statecharts with Eclipse Public License 1.0 | 5 votes |
protected void createChoiceKindViewer(Composite parent) { Label label = getToolkit().createLabel(parent, "Choice kind:"); GridDataFactory.fillDefaults().applyTo(label); choiceKindViewer = new ComboViewer(parent); GridDataFactory.fillDefaults().grab(true, false).applyTo(choiceKindViewer.getControl()); choiceKindViewer.setContentProvider(new ArrayContentProvider()); choiceKindViewer.setLabelProvider(new LabelProvider()); choiceKindViewer.setInput(ChoiceKind.values()); }
Example #28
Source File: SelectConnectorImplementationWizardPage.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public SelectConnectorImplementationWizardPage(String pageTitle, String pageDescription, IContentProvider contentProvider, LabelProvider labelProvider, IRepositoryStore<? extends IRepositoryFileStore> iRepositoryStore, SourceRepositoryStore<? extends AbstractFileStore> sourceRepositoryStore) { super(SelectConnectorImplementationWizardPage.class.getName()); setTitle(pageTitle); setDescription(pageDescription); this.contentProvider = contentProvider; this.labelProvider = labelProvider; this.implStore = iRepositoryStore; this.sourceStore = sourceRepositoryStore; }
Example #29
Source File: CdtProjectFieldEditor.java From ghidra with Apache License 2.0 | 5 votes |
@Override protected String changePressed() { ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), new LabelProvider()); dialog.setTitle("CDT project selection"); dialog.setMessage("Select an open CDT project:"); dialog.setElements(CdtUtils.getCDTProjects().stream().map(p -> p.getName()).toArray()); dialog.open(); Object[] result = dialog.getResult(); if (result != null && result.length > 0 && result[0] instanceof String) { return (String) result[0]; } return null; }
Example #30
Source File: BaseLaunchShortcut.java From goclipse with Eclipse Public License 1.0 | 5 votes |
protected LabelProvider createLaunchTargetLabelProvider() { return new LabelProvider() { @Override public String getText(Object element) { ILaunchable launchable = (ILaunchable) element; return launchable.getFullLabel(); } }; }