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

The following examples show how to use org.eclipse.jface.viewers.ListViewer#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: 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: 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 3
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 4
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 5
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 6
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 7
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 8
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 9
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 10
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;
}