List of usage examples for org.springframework.ide.eclipse.boot.wizard.content ContentType getDisplayName
public String getDisplayName()
From source file:org.springframework.ide.eclipse.boot.wizard.guides.ChooseTypedContentSection.java
@Override public void createContents(Composite page) { // PT 130652465 - Avoid downloading content (i.e. network I/O) in the UI thread. // Solution: downloading/prefetch content in the background to avoid blocking the UI in case // it takes a long time. prefetchProvidersAndContent();//from w ww. java 2 s. c o m Composite field = new Composite(page, SWT.NONE); int cols = sectionLabel == null ? 1 : 2; GridLayout layout = GridLayoutFactory.fillDefaults().numColumns(cols).create(); field.setLayout(layout); searchBox = new Text(field, SWT.SINGLE | SWT.BORDER | SWT.SEARCH | SWT.ICON_CANCEL); searchBox.setMessage("Type pattern to match"); Label fieldNameLabel = null; if (sectionLabel != null) { fieldNameLabel = new Label(field, SWT.NONE); fieldNameLabel.setText(sectionLabel); } treeviewer = new TreeViewer(field, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL); treeviewer.addFilter(filter = new ChoicesFilter()); treeviewer.setLabelProvider(labelProvider); treeviewer.setContentProvider(contentProvider); treeviewer.setInput(content); treeviewer.expandAll(); GridDataFactory grabHor = GridDataFactory.fillDefaults().grab(true, false); GridDataFactory fixHeight = GridDataFactory.fillDefaults().hint(SWT.DEFAULT, 200); grabHor.applyTo(field); grabHor.applyTo(searchBox); fixHeight.applyTo(treeviewer.getControl()); if (fieldNameLabel != null) { GridDataFactory.fillDefaults().align(SWT.BEGINNING, SWT.BEGINNING).applyTo(fieldNameLabel); } whenVisible(treeviewer.getControl(), new Runnable() { public void run() { GSContent preSelect = selection.selection.getValue(); if (preSelect != null) { treeviewer.setSelection(new StructuredSelection(preSelect), true); } else { treeviewer.setSelection(StructuredSelection.EMPTY, true); } if (initialFilterText != null) { searchBox.setText(initialFilterText); updateFilter(); } if (category != null) { //System.out.println(category); ContentType<?> expand = null; ContentType<?>[] contentTypes = content.getTypes(); for (ContentType<?> contentType : contentTypes) { //TODO: Miles(?) Searching by display name seems like a bad idea if (contentType.getDisplayName().equals(category)) { expand = contentType; break; } } if (expand != null) { treeviewer.setExpandedElements(new Object[] { expand }); } } } }); treeviewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { ISelection sel = treeviewer.getSelection(); if (sel.isEmpty()) { setSelection(null); } else if (sel instanceof IStructuredSelection) { IStructuredSelection ss = (IStructuredSelection) sel; setSelection(ss.getFirstElement()); } else { //Not expecting anything else. So ignore. } } private void setSelection(Object e) { if (e == null) { selection.selection.setValue(null); rawSelection.setValue(null); } else { rawSelection.setValue(e); if (e instanceof GSContent) { selection.selection.setValue((GSContent) e); } } } }); searchBox.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { updateFilter(); } }); }