Java Code Examples for org.eclipse.jface.viewers.ListViewer#setContentProvider()

The following examples show how to use org.eclipse.jface.viewers.ListViewer#setContentProvider() . 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: N4JSTestedProjectWizardPage.java    From n4js with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public void createControl(Composite parent) {
	Composite listComposite = new Composite(parent, NONE);
	listComposite.setLayout(new FillLayout());

	ListViewer projectListViewer = new ListViewer(listComposite, SWT.BORDER | SWT.MULTI);
	projectListViewer.setContentProvider(ArrayContentProvider.getInstance());
	projectListViewer.setInput(getNonTestProjects());

	// Data binding
	DataBindingContext databindingContext = new DataBindingContext();
	parent.addDisposeListener(e -> databindingContext.dispose());

	databindingContext.bindList(ViewerProperties.multipleSelection().observe(projectListViewer),
			PojoProperties.list(N4JSProjectInfo.class, N4JSProjectInfo.TESTED_PROJECT_PROP_NAME)
					.observe(projectInfo));

	setControl(listComposite);
}
 
Example 2
Source File: OutlineDialog.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createObjectListViewer(final Composite viewersComposite) {
    objectListViewer = new ListViewer(viewersComposite);
    objectListViewer.getList().setLayoutData(GridDataFactory.fillDefaults().hint(100,200).create());
    objectListViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
    objectListViewer.setContentProvider(new ArrayContentProvider());
    objectListViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            final IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            final EObject selectedObject = (EObject)selection.getFirstElement();
            final OutlineFilter filter =(OutlineFilter) outline.getFilters()[0];
            filter.setElementToDisplay(selectedObject);
            if (outline!=null){
                outline.refresh(true);
            }
        }
    });
    objectListViewer.setInput(elementToDisplay);
}
 
Example 3
Source File: TransitionOrderingPropertySection.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected void createList(final Composite mainComposite) {
    final List list = getWidgetFactory().createList(mainComposite, SWT.BORDER | SWT.V_SCROLL);
    list.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 90).create());
    listViewer = new ListViewer(list);
    listViewer.setContentProvider(new ObservableListContentProvider<Element>());
    listViewer.setLabelProvider(new LabelProvider(){
        @Override
        public String getText(final Object element) {
            if(element != null && element instanceof Connection){
                final String transitionName = ((Connection) element).getName();
                return transitionName +" -- "+((Connection) element).getTarget().getName();
            }
            return super.getText(element);
        }
    });
    listViewer.addSelectionChangedListener(new ISelectionChangedListener() {
        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            updateButtonsEnablement();
        }
    });
}
 
Example 4
Source File: SVNWizardPage.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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 5
Source File: UnansweredDocumentsView.java    From slr-toolkit with Eclipse Public License 1.0 6 votes vote down vote up
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 6
Source File: TaskOverview.java    From codeexamples-eclipse with Eclipse Public License 1.0 6 votes vote down vote up
@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 7
Source File: DocumentPropertySection.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private ListViewer createList(final Composite mainComposite) {
    final List list = getWidgetFactory().createList(mainComposite,
            SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI);
    list.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    final ListViewer documentListViewer = new ListViewer(list);
    documentListViewer.setLabelProvider(new ElementForIdLabelProvider());
    documentListViewer.setContentProvider(new ObservableListContentProvider());
    documentListViewer.addDoubleClickListener(this);
    documentListViewer.addSelectionChangedListener(this);
    documentListViewer.getList().addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.keyCode == SWT.DEL) {
                e.doit = false;
                removeDocuments();
            }
        }
    });

    return documentListViewer;
}
 
Example 8
Source File: FileStoreSelectDialog.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createListViewer(final Composite listComposite) {
    fileStoreListViewer = new ListViewer(listComposite, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
    fileStoreListViewer.getList().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(400, 300).create());
    fileStoreListViewer.setContentProvider(new ArrayContentProvider());
    fileStoreListViewer.setLabelProvider(new FileStoreLabelProvider());
    final IRepositoryStore<?> ars = (IRepositoryStore<?>) RepositoryManager.getInstance()
            .getRepositoryStore(getRepositoryStoreClass());
    fileStoreListViewer.setInput(ars.getChildren());
    fileStoreListViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            final boolean empty = event.getSelection().isEmpty();
            getButton(IDialogConstants.OK_ID).setEnabled(!empty);
            removeButton.setEnabled(!empty);
            selected = (AbstractFileStore) ((IStructuredSelection) event.getSelection()).getFirstElement();
        }
    });
    fileStoreListViewer.getList().setFocus();
}
 
Example 9
Source File: JointDataSetPage.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * create left composite for page
 * 
 * @param composite
 */
private void createLeftGroup( Composite composite )
{
	leftGroup = new Group( composite, SWT.NONE );
	leftGroup.setLayout( new FormLayout( ) );
	leftGroup.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 );

	leftDataSetChooser = new ComboViewer( leftGroup, SWT.DROP_DOWN
			| SWT.READ_ONLY );
	leftDataSetChooser.getCombo( ).setLayoutData( data );
	DataSetComboProvider provider = new DataSetComboProvider( );
	leftDataSetChooser.setContentProvider( provider );
	leftDataSetChooser.setLabelProvider( provider );
	leftDataSetChooser.setInput( dataSetList );
	leftDataSetChooser.addSelectionChangedListener( this );

	data = new FormData( );

	data.top = new FormAttachment( leftDataSetChooser.getCombo( ), 10 );
	data.left = new FormAttachment( 0, 5 );
	data.right = new FormAttachment( 100, -5 );
	data.bottom = new FormAttachment( 100, -5 );

	leftColumnList = new ListViewer( leftGroup, SWT.V_SCROLL
			| SWT.H_SCROLL
			| SWT.BORDER );
	leftColumnList.getControl( ).setLayoutData( data );
	ColumnProvider colProvider = new ColumnProvider( );
	leftColumnList.setContentProvider( colProvider );
	leftColumnList.setLabelProvider( colProvider );
	leftColumnList.addSelectionChangedListener( this );

}
 
Example 10
Source File: CatchLinkEventSectionContribution.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
   public void createControl(final Composite composite, final TabbedPropertySheetWidgetFactory widgetFactory,
    final ExtensibleGridPropertySection extensibleGridPropertySection) {
list = new ListViewer(composite, SWT.BORDER | SWT.V_SCROLL);
list.getControl().setLayoutData(GridDataFactory.fillDefaults().hint(200, 55).grab(true, false).create());
list.setLabelProvider(new LinkLabelProvider());
list.setContentProvider(ArrayContentProvider.getInstance());

list.setInput(catchLinkElement.getFrom());
   }
 
Example 11
Source File: GroovyEditorDocumentationDialogTray.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createFunctionCategories(final Composite parent) {
    final Composite catComposite = new Composite(parent, SWT.NONE);
    catComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
    catComposite.setLayout(new GridLayout(1, true));

    groovyHelpLinkFactory.createGroovyHelpLink(catComposite);

    final Label catTitle = new Label(catComposite, SWT.NONE);
    catTitle.setText(Messages.categoriesTitle);

    categoriesList = new ListViewer(catComposite, SWT.BORDER | SWT.V_SCROLL | SWT.SINGLE);
    categoriesList.setLabelProvider(new CategoryLabelProvider());
    categoriesList.setContentProvider(new FunctionCategoriesProvider());
    categoriesList.setInput(
            FunctionsRepositoryFactory.getFunctionCatgories(RepositoryManager.getInstance().getCurrentRepository()));
    categoriesList.getList().setSelection(0);
    final int categorieMinheight = categoriesList.getList().getItemHeight() * categoriesList.getList().getItemCount();
    categoriesList.getList().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).hint(SWT.DEFAULT, categorieMinheight).create());
    categoriesList.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(final SelectionChangedEvent event) {
            final IFunctionCategory cat = (IFunctionCategory) ((IStructuredSelection) event.getSelection()).getFirstElement();
            functionsList.getViewer().setInput(cat);
        }
    });
}
 
Example 12
Source File: JointDataSetPage.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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 13
Source File: WorkspaceMergeDialog.java    From MergeProcessor with Apache License 2.0 5 votes vote down vote up
/**
 * Create the table viewer for showing warnings.
 * 
 * @param parent the parent composite of the table viewer
 * @return the table viewer
 */
private static ListViewer createWarningsTableViewer(final Composite parent) {
	final Composite composite = new Composite(parent, SWT.NONE);
	composite.setLayout(new FillLayout());
	GridDataFactory.fillDefaults().span(2, 1).grab(true, true).exclude(true).applyTo(composite);
	final ListViewer tableViewer = new ListViewer(composite);
	tableViewer.setContentProvider(ArrayContentProvider.getInstance());
	tableViewer.setLabelProvider(new LabelProvider());
	return tableViewer;
}
 
Example 14
Source File: ConfigurationFormToolkit.java    From neoscada with Eclipse Public License 1.0 5 votes vote down vote up
public void createListSection ( final ScrolledForm form, final ConfigurationEditorInput input, final String attribute, final String label, final String delimiter, final String pattern )
{
    final IObservableList list = StringSplitListObservable.observeString ( Observables.observeMapEntry ( input.getDataMap (), attribute, String.class ), delimiter, pattern );

    // section

    final Section section = this.toolkit.createSection ( form.getBody (), ExpandableComposite.TITLE_BAR );
    section.setText ( label );

    final Composite client = this.toolkit.createComposite ( section, SWT.NONE );
    section.setClient ( client );
    this.toolkit.paintBordersFor ( client );

    client.setLayout ( new GridLayout ( 1, true ) );
    final GridData gd = new GridData ( GridData.FILL_BOTH );
    gd.horizontalSpan = 2;
    section.setLayoutData ( gd );

    // fields
    final ListViewer viewer = new ListViewer ( client );

    viewer.setContentProvider ( new ObservableListContentProvider () );
    viewer.setInput ( list );

    viewer.getControl ().setLayoutData ( new GridData ( GridData.FILL_BOTH ) );

    viewer.setSorter ( new ViewerSorter () );
}
 
Example 15
Source File: AnnotateView.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Show the annotation view.
 * @param svnFile
 * @param svnAnnotateBlocks
 * @param contents
 * @param useHistoryView
 * @throws PartInitException
 */
public void showAnnotations(ISVNRemoteFile svnFile, Collection svnAnnotateBlocks, InputStream contents, boolean useHistoryView) throws PartInitException {

	// Disconnect from old annotation editor
	disconnect();
	
	// Remove old viewer
	Control[] oldChildren = top.getChildren();
	if (oldChildren != null) {
		for (int i = 0; i < oldChildren.length; i++) {
			oldChildren[i].dispose();
		}
	}

	viewer = new ListViewer(top, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL);
	viewer.setContentProvider(new ArrayContentProvider());
	viewer.setLabelProvider(new LabelProvider());
	viewer.addSelectionChangedListener(this);
	viewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));

	PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), IHelpContextIds.ANNOTATIONS_VIEW);

	top.layout();
	
	this.svnFile = svnFile;
	this.contents = contents;
	this.svnAnnotateBlocks = svnAnnotateBlocks;
	page = SVNUIPlugin.getActivePage();
	viewer.setInput(svnAnnotateBlocks);
	editor = (ITextEditor) openEditor();
	IDocumentProvider provider = editor.getDocumentProvider();
	document = provider.getDocument(editor.getEditorInput());

	setPartName(Policy.bind("SVNAnnotateView.showFileAnnotation", new Object[] {svnFile.getName()})); //$NON-NLS-1$
	setTitleToolTip(svnFile.getName());
	
	if (!useHistoryView) {
		return;
	}

	// Get hook to the HistoryView
	historyView = (IHistoryView)page.showView(ISVNUIConstants.HISTORY_VIEW_ID);
	if (historyView != null) {
		historyView.showHistoryFor(svnFile);
	}
}
 
Example 16
Source File: N4JSNewProjectWizardCreationPage.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
private Composite initLibraryOptionsUI(DataBindingContext dbc, Composite parent) {
	// Additional library project options
	final Group libraryProjectOptionsGroup = new Group(parent, NONE);
	libraryProjectOptionsGroup
			.setLayout(GridLayoutFactory.fillDefaults().margins(12, 5).numColumns(2).equalWidth(false).create());

	emptyPlaceholder(libraryProjectOptionsGroup);

	final Button createGreeterFileButton = new Button(libraryProjectOptionsGroup, CHECK);
	createGreeterFileButton.setText("Create a greeter file");
	createGreeterFileButton.setLayoutData(GridDataFactory.fillDefaults().create());

	new Label(libraryProjectOptionsGroup, SWT.NONE).setText("Implementation ID:");
	final Text implementationIdText = new Text(libraryProjectOptionsGroup, BORDER);
	implementationIdText.setLayoutData(fillDefaults().align(FILL, SWT.CENTER).grab(true, false).create());

	final Label implementedProjectsLabel = new Label(libraryProjectOptionsGroup, SWT.NONE);
	implementedProjectsLabel.setText("Implemented projects:");
	implementedProjectsLabel
			.setLayoutData(GridDataFactory.fillDefaults().grab(false, true).align(SWT.LEFT, SWT.TOP).create());

	final ListViewer apiViewer = new ListViewer(libraryProjectOptionsGroup, BORDER | MULTI);
	apiViewer.getControl().setLayoutData(fillDefaults().align(FILL, FILL).grab(true, true).span(1, 1).create());
	apiViewer.setContentProvider(ArrayContentProvider.getInstance());
	apiViewer.setInput(getAvailableApiProjectNames());

	initApiViewerBinding(dbc, apiViewer);
	initImplementationIdBinding(dbc, implementationIdText);
	initDefaultCreateGreeterBindings(dbc, createGreeterFileButton);

	// Invalidate on change
	apiViewer.addSelectionChangedListener(e -> {
		setPageComplete(validatePage());
	});
	// Invalidate on change
	implementationIdText.addModifyListener(e -> {
		setPageComplete(validatePage());
	});

	return libraryProjectOptionsGroup;
}
 
Example 17
Source File: HL7LabImportRulesPreferencePage.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Create contents of the preference page.
 * 
 * @param parent
 */
@Override
public Control createContents(Composite parent){
	Composite container = new Composite(parent, SWT.NULL);
	container.setLayout(new GridLayout(1, false));
	
	Composite composite = new Composite(container, SWT.NONE);
	composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	composite.setLayout(new GridLayout(2, false));
	
	Label lblLabNoPathFlagMeansNonPath = new Label(composite, SWT.WRAP);
	lblLabNoPathFlagMeansNonPath
		.setText(Messages.HL7LabImportRulesPreferencePage_lblLabImportRulesHeader_text);
	
	ToolBarManager toolbarmgr = new ToolBarManager();
	toolbarmgr.add(new AddMissingPathFlagMeansNonPathLaboratoryAction());
	toolbarmgr.add(new RemoveMissingPathFlagMeansNonPathLaboratoryAction());
	ToolBar toolbar = toolbarmgr.createControl(composite);
	toolbar.setLayoutData(new GridData(SWT.RIGHT, SWT.TOP, false, false));
	new Label(composite, SWT.NONE);
	
	labMPathMNonPathListViewer = new ListViewer(composite, SWT.BORDER | SWT.V_SCROLL);
	labMPathMNonPathListViewer.setContentProvider(ArrayContentProvider.getInstance());
	labMPathMNonPathListViewer.setLabelProvider(new LabelProvider() {
		@Override
		public String getText(Object element){
			if (element instanceof Kontakt) {
				return ((Kontakt) element).getLabel();
			}
			return super.getText(element);
		}
	});
	GridData gridData = new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1);
	gridData.heightHint = 80;
	labMPathMNonPathListViewer.getList()
		.setLayoutData(gridData);

	labMPathMNonPathListViewer.setInput(findAllLabsWithPathFlagMissingMeansNonPathologic());
	
	return container;
}