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

The following examples show how to use org.eclipse.jface.viewers.CheckboxTreeViewer#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: CheckNodeTreeView.java    From depan with Apache License 2.0 6 votes vote down vote up
@Override
protected CheckboxTreeViewer createTreeViewer(Composite parent) {
  int style = SWT.VIRTUAL | SWT.FULL_SELECTION | SWT.BORDER
      | SWT.H_SCROLL | SWT.V_SCROLL;
  CheckboxTreeViewer result = new CheckboxTreeViewer(parent, style);
  result.setLabelProvider(new WorkbenchLabelProvider());
  result.setContentProvider(new BaseWorkbenchContentProvider());
  result.setComparator(new NodeWrapperTreeSorter());

  result.addCheckStateListener(new ICheckStateListener() {
    @Override
    public void checkStateChanged(CheckStateChangedEvent event) {
      if (recursiveTreeSelect) {
        tree.setSubtreeChecked(event.getElement(), event.getChecked());
      }
    }
  });

  tree = result;
  return result;
}
 
Example 2
Source File: CheckboxTreeAndListGroup.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 *	Creates this group's tree viewer.
 * @param parent parent composite
 * @param width the width
 * @param height the height
 */
protected void createTreeViewer(Composite parent, int width, int height) {
	Tree tree= new Tree(parent, SWT.CHECK | SWT.BORDER);
	GridData data= new GridData(GridData.FILL_BOTH);
	data.widthHint= width;
	data.heightHint= height;
	tree.setLayoutData(data);

	fTreeViewer= new CheckboxTreeViewer(tree);
	fTreeViewer.setUseHashlookup(true);
	fTreeViewer.setContentProvider(fTreeContentProvider);
	fTreeViewer.setLabelProvider(fTreeLabelProvider);
	fTreeViewer.addTreeListener(this);
	fTreeViewer.addCheckStateListener(this);
	fTreeViewer.addSelectionChangedListener(this);
}
 
Example 3
Source File: MultipleFolderSelectionDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates the tree viewer.
 *
 * @param parent the parent composite
 * @return the tree viewer
 */
protected CheckboxTreeViewer createTreeViewer(Composite parent) {
	fViewer = new CheckboxTreeViewer(parent, SWT.BORDER);

	fViewer.setContentProvider(fContentProvider);
	fViewer.setLabelProvider(fLabelProvider);
	fViewer.addCheckStateListener(new ICheckStateListener() {
		public void checkStateChanged(CheckStateChangedEvent event) {
			updateOKStatus();
		}
	});

	fViewer.setComparator(new ResourceComparator(ResourceComparator.NAME));
	if (fFilters != null) {
		for (int i = 0; i != fFilters.size(); i++)
			fViewer.addFilter(fFilters.get(i));
	}

	fViewer.setInput(fInput);

	return fViewer;
}
 
Example 4
Source File: LevelViewDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void createLevelViewer( Composite parent )
{
	levelViewer = new CheckboxTreeViewer( parent, SWT.SINGLE | SWT.BORDER );

	GridData gd = new GridData( GridData.FILL_BOTH );
	gd.widthHint = 340;
	gd.heightHint = 250;
	levelViewer.getTree( ).setLayoutData( gd );

	levelViewer.setContentProvider( new CubeContentProvider( ) );
	levelViewer.setLabelProvider( new CubeLabelProvider( ) );
	levelViewer.addCheckStateListener( new ICheckStateListener( ) {

		public void checkStateChanged( CheckStateChangedEvent event )
		{

			LevelHandle item = (LevelHandle) event.getElement( );
			if ( event.getChecked( ) )
			{
				if ( !showLevels.contains( item ) )
					showLevels.add( item );
			}
			else
			{
				if ( showLevels.contains( item ) )
					showLevels.remove( item );
			}

			checkOKButtonStatus( );
		}

	} );
}
 
Example 5
Source File: ModelCheckBoxTree.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
public void drawOn(Composite comp, FormToolkit tk) {
	tree = new CheckboxTreeViewer(comp,
			SWT.VIRTUAL | SWT.MULTI | SWT.BORDER);
	tree.setUseHashlookup(true);
	tree.setContentProvider(new NavigationContentProvider());
	tree.setLabelProvider(new NavigationLabelProvider(false));
	tree.setComparator(new NavigationComparator());
	tree.addFilter(new ModelTypeFilter(types));
	tree.addCheckStateListener(this);
	ColumnViewerToolTipSupport.enableFor(tree);
	if (tk != null) {
		tk.adapt(tree.getTree());
	}

	// compute a height hint
	GridData data = UI.gridData(tree.getTree(), true, true);
	data.minimumHeight = 120;
	Point p = comp.computeSize(SWT.DEFAULT, SWT.DEFAULT);
	data.heightHint = p.y < 120 ? 120 : p.y;

	if (types == null || types.length == 0)
		return;
	if (types.length == 1) {
		tree.setInput(Navigator.findElement(types[0]));
	} else {
		List<INavigationElement<?>> elems = Arrays.stream(types)
				.map(type -> Navigator.findElement(type))
				.filter(elem -> !elem.getChildren().isEmpty())
				.collect(Collectors.toList());
		tree.setInput(elems);
	}
	tree.expandToLevel(2);
}
 
Example 6
Source File: ModelSelectionPage.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void createViewer(Composite composite) {
	viewer = new CheckboxTreeViewer(composite, SWT.VIRTUAL | SWT.MULTI
			| SWT.BORDER);
	viewer.setUseHashlookup(true);
	viewer.getTree().setLayoutData(
			new GridData(SWT.FILL, SWT.FILL, true, true));
	viewer.setContentProvider(new NavigationContentProvider());
	viewer.setLabelProvider(new NavigationLabelProvider(false));
	viewer.setComparator(new NavigationComparator());
	viewer.addFilter(new ModelTypeFilter(types));
	viewer.addCheckStateListener(new ModelSelectionState(this, viewer));
	registerInputHandler(composite);
	ColumnViewerToolTipSupport.enableFor(viewer);
}
 
Example 7
Source File: RepositoryImportWizard.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
@Override
public void createControl(Composite parent) {
	Composite container = UI.formComposite(parent);
	setControl(container);
	viewer = new CheckboxTreeViewer(container, SWT.BORDER);
	viewer.setLabelProvider(new Label());
	viewer.setContentProvider(new ContentProvider());
	viewer.setUseHashlookup(true);
	viewer.addCheckStateListener(new SelectionState(this));
	UI.gridData(viewer.getTree(), true, true);
}
 
Example 8
Source File: ExportWizardPage.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void createProcessTree(Composite container) {
	Composite composite = new Composite(container, SWT.NONE);
	composite.setLayout(new FillLayout());
	UI.gridData(composite, true, true);
	viewer = new CheckboxTreeViewer(composite, SWT.MULTI | SWT.BORDER);
	viewer.setUseHashlookup(true);
	viewer.setContentProvider(new NavigationContentProvider());
	viewer.setLabelProvider(new NavigationLabelProvider(false));
	viewer.setInput(Navigator.getNavigationRoot());
	viewer.addCheckStateListener(new NavigationTreeCheck(viewer));
	viewer.addCheckStateListener(this);
	viewer.addFilter(new NavigationTreeFilter());
	viewer.setComparator(new NavigationComparator());
}
 
Example 9
Source File: FieldToContractInputMappingViewerCheckStateManagerTest.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private CheckboxTreeViewer aCheckBoxTreeViewer(List<FieldToContractInputMapping> input) {
    CheckboxTreeViewer viewer = new CheckboxTreeViewer(realmWithDisplay.createComposite());
    viewer.setFilters(hidePersistenceIdMapping());
    ObservableListTreeContentProvider provider = new ObservableListTreeContentProvider(
            new FieldToContractInputMappingObservableFactory(),
            new FieldToContractInputMappingTreeStructureAdvisor());
    viewer.setContentProvider(provider);
    viewer.setInput(input);
    return viewer;
}
 
Example 10
Source File: ContactSelectionComposite.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void configureViewer(CheckboxTreeViewer viewer) {
  viewer.setContentProvider(new RosterContentProvider());
  viewer.setLabelProvider(new TreeLabelProvider());
  viewer.setComparator(new RosterComparator());
  viewer.setUseHashlookup(true);

  checkStateProvider = new RosterCheckStateProvider();
  viewer.setCheckStateProvider(checkStateProvider);
}
 
Example 11
Source File: BaseResourceSelectionComposite.java    From saros with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void configureViewer(CheckboxTreeViewer viewer) {
  viewer.setContentProvider(new WorkbenchContentProvider());
  viewer.setLabelProvider(new WorkbenchLabelProvider());
  viewer.setUseHashlookup(true);
  viewer.setSorter(new WorkbenchItemsSorter());
}
 
Example 12
Source File: PackageFilterEditor.java    From eclipse-cs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Creates the tree viewer.
 *
 * @param parent
 *          the parent composite
 * @return the tree viewer
 */
protected CheckboxTreeViewer createTreeViewer(Composite parent) {

  mViewer = new CheckboxTreeViewer(parent, SWT.BORDER);
  mViewer.setContentProvider(mContentProvider);
  mViewer.setLabelProvider(mLabelProvider);

  mViewer.addCheckStateListener(new ICheckStateListener() {
    @Override
    public void checkStateChanged(CheckStateChangedEvent event) {

      IContainer element = (IContainer) event.getElement();

      if (isRecursivelyExcludeSubTree() && !isGrayed(element)) {
        setSubElementsGrayedChecked(element, event.getChecked());
      } else if (isRecursivelyExcludeSubTree() && isGrayed(element)) {
        mViewer.setGrayChecked(element, true);
      }
    }
  });

  mViewer.setInput(mInput);
  mViewer.setCheckedElements(getInitialElementSelections().toArray());
  adaptRecurseBehaviour();
  if (mExpandedElements != null) {
    mViewer.setExpandedElements(mExpandedElements);
  }

  return mViewer;
}
 
Example 13
Source File: SGenWizardPage2.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
private void createObjectTree(Composite container) {
	lblNewLabel = new Label(container, SWT.NONE);
	lblNewLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 1, 1));
	lblNewLabel.setText("Choose: " + getSelectedGenerator().getContentType());

	resourceTree = new CheckboxTreeViewer(container, SWT.BORDER);
	resourceTree.getTree().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

	resourceTree.setContentProvider(new WorkspaceTreeContentProvider());
	resourceTree.setLabelProvider(new SGenWorkspaceLabelProvider());

	TreePropagatingCheckStateListener checkStateListener = new TreePropagatingCheckStateListener(resourceTree) {
		@Override
		public void checkStateChanged(CheckStateChangedEvent event) {
			super.checkStateChanged(event);
		}
	};
	resourceTree.addCheckStateListener(checkStateListener);
	resourceTree.addDoubleClickListener(new TreeExpandingDoubleClickListener(resourceTree, checkStateListener));
	resourceTree.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
	resourceTree.setFilters(new ViewerFilter[] { new ViewerFilter() {
		@Override
		public boolean select(Viewer viewer, Object parentElement, Object element) {
			// TODO: Filter by common navigator filter instead of supressing
			// '.' prefixed folder
			if (element instanceof IFolder) {
				return !((IFolder) element).getName().startsWith(".");
			}
			return true;
		}
	} });
}
 
Example 14
Source File: AddContextDialog.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
@Override
protected Control createDialogArea(Composite parent) {

    // Main dialog panel
    Composite dialogComposite = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout(1, true);
    dialogComposite.setLayout(layout);
    dialogComposite.setLayoutData(new GridData(GridData.FILL_BOTH));

    // Contexts list
    Group contextGroup = new Group(dialogComposite, SWT.SHADOW_NONE);
    contextGroup.setText(Messages.TraceControl_AddContextAvailableContextsLabel);
    layout = new GridLayout(1, true);
    contextGroup.setLayout(layout);
    contextGroup.setLayoutData(new GridData(GridData.FILL_BOTH));

    fContextsViewer = new CheckboxTreeViewer(contextGroup, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
    fContextsViewer.getTree().setToolTipText(Messages.TraceControl_AddContextAvailableContextsTooltip);

    fContextsViewer.setContentProvider(new ContextsContentProvider());
    fContextsViewer.setLabelProvider(new ContextsLabelProvider());
    fContextsViewer.addCheckStateListener(new ContextCheckListener());
    fContextsViewer.setInput(fContextModel);
    fContextsViewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));

    getShell().setMinimumSize(new Point(500, 450));

    return dialogComposite;
}
 
Example 15
Source File: CreateContractInputFromBusinessObjectWizardPage.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private void createProcessDataMappingTreeViewer(Composite composite, EMFDataBindingContext dbc) {
    final Composite viewerComposite = new Composite(composite, SWT.NONE);
    viewerComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    viewerComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(15, 15).create());
    createButtonComposite(viewerComposite);
    treeViewer = new CheckboxTreeViewer(viewerComposite,
            SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.MULTI);
    treeViewer.getTree()
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(SWT.DEFAULT, 200).create());
    treeViewer.getTree().setHeaderVisible(true);
    treeViewer.addFilter(hidePersistenceIdMapping());
    final FieldToContractInputMappingViewerCheckStateManager manager = new FieldToContractInputMappingViewerCheckStateManager();
    treeViewer.addCheckStateListener(manager);
    treeViewer.setCheckStateProvider(manager);
    final ObservableListTreeContentProvider provider = new ObservableListTreeContentProvider(
            new FieldToContractInputMappingObservableFactory(),
            new FieldToContractInputMappingTreeStructureAdvisor());
    treeViewer.setContentProvider(provider);

    final TreeViewerColumn nameTreeViewerColumn = new TreeViewerColumn(treeViewer, SWT.FILL);
    nameTreeViewerColumn.getColumn().setText(Messages.attributeName);
    nameTreeViewerColumn.getColumn().setWidth(250);
    lazyFieldStatusProvider = new UnselectLazyReferencesInMultipleContainer();
    nameTreeViewerColumn.setLabelProvider(new FieldNameColumnLabelProvider(lazyFieldStatusProvider));

    final TreeViewerColumn typeTreeViewerColumn = new TreeViewerColumn(treeViewer, SWT.FILL);
    typeTreeViewerColumn.getColumn().setText(Messages.attributetype);
    typeTreeViewerColumn.getColumn().setWidth(150);
    typeTreeViewerColumn.setLabelProvider(new FieldTypeColumnLabelProvider());

    final TreeViewerColumn inputTypeTreeViewerColumn = new TreeViewerColumn(treeViewer, SWT.FILL);
    inputTypeTreeViewerColumn.getColumn().setText(Messages.inputType);
    inputTypeTreeViewerColumn.getColumn().setWidth(150);
    inputTypeTreeViewerColumn.setLabelProvider(new InputTypeColumnLabelProvider(contract));
    inputTypeTreeViewerColumn.setEditingSupport(new ContractInputTypeEditingSupport(treeViewer, contract));

    final TreeViewerColumn mandatoryTreeViewerColumn = new TreeViewerColumn(treeViewer, SWT.FILL);
    mandatoryTreeViewerColumn.getColumn().setText(Messages.mandatory);
    mandatoryTreeViewerColumn.getColumn().setWidth(80);
    mandatoryTreeViewerColumn.setLabelProvider(new MandatoryColumnLabelProvider());

    IViewerObservableSet checkedElements = ViewersObservables.observeCheckedElements(treeViewer,
            FieldToContractInputMapping.class);

    final IObservableValue<FieldToContractInputMapping> observeInput = ViewersObservables.observeInput(treeViewer);
    dbc.bindValue(observeInput,
            selectedDataObservable,
            null,
            UpdateStrategyFactory.updateValueStrategy().withConverter(selectedDataToFieldMappings()).create());

    generationOptions.getEditModeObservable().addValueChangeListener(event -> {
        if (selectedDataObservable.getValue() instanceof BusinessObjectData) {
            createMapping(selectedDataObservable.getValue());
            treeViewer.setInput(mappings);
        }
    });

    createButtonListeners(checkedElements);

    multiValidator = new EmptySelectionMultivalidator(selectedDataObservable, checkedElements, mappings,
            contract.eContainer(), generationOptions.getEditModeObservable());
    dbc.addValidationStatusProvider(multiValidator);

    new Label(viewerComposite, SWT.NONE); //FILLER

    Link formGenerationDocLink = new Link(viewerComposite, SWT.NONE);
    formGenerationDocLink.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create());
    formGenerationDocLink.setText(Messages.moreInfoFormGenerationLink);
    formGenerationDocLink.addListener(SWT.Selection, event -> openBrowser(FORM_GENERATION_REDIRECT_ID));

    ColumnViewerToolTipSupport.enableFor(treeViewer);
}
 
Example 16
Source File: XSPGenPage.java    From XPagesExtensionLibrary with Apache License 2.0 4 votes vote down vote up
private void createXPageLibraries(Composite parent){
    Section advancedSection = XSPEditorUtil.createSection(toolkit, parent, "XPage Libraries", 1, 1);  // $NLX-XSPGenPage.XPageLibraries-1$
    treeComposite = new Composite(advancedSection, SWT.NONE);
    treeComposite.setLayoutData(SWTLayoutUtils.createGDFillNoGrab());
    treeComposite.setBackground(getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
    treeComposite.setLayout(SWTLayoutUtils.createLayoutNoMarginDefaultSpacing(1));
    
    new Label(treeComposite, SWT.NONE).setText("Select the libraries of extended XPage controls to use\nin this application.");  // $NLX-XSPGenPage.SelectthelibrariesofextendedXPage-1$
    
    CustomTree tree = new CustomTree(treeComposite, SWT.CHECK | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, "xsp.libraries"); // $NON-NLS-1$
    tree.setLayoutData(SWTLayoutUtils.createGDFillHorizontal());
    tree.setLinesVisible(true);
    tree.setHeaderVisible(true);
    tree.setRows(4);
    CustomTreeColumn col = new CustomTreeColumn(tree, SWT.NONE, "lib.id.col"); // $NON-NLS-1$
    col.setText("Library ID"); // $NLX-XSPGenPage.LibraryID-1$
    col.setWidthUnit(CustomTreeColumn.UNIT_REMAINDER);
    /*
     * Create a checkbox viewer that allows the user to select which xsp
     * libraries this application will depend upon
     */
    _xpageLibraries = new CheckboxTreeViewer(tree);
    _xpageLibraries.setLabelProvider(new XPageLibraryLabelProvider());
    _xpageLibraries.setContentProvider(new XPageLibraryContentProvider());
    _xpageLibraries.setColumnProperties(new String[]{"ID"}); //For future reference - when editing - we need to check against the ids set here! $NON-NLS-1$
        
    XSPEditorUtil.createLabel(treeComposite, "When running on the Web, the libraries must be available on the\nserver. When running on the Notes client, the library plug-ins must\nbe installed on the client.", 1); // $NLX-XSPGenPage.WhenrunningontheWebthelibrariesmu-1$
    
    Composite twoCols = new Composite(treeComposite, SWT.NONE);
    twoCols.setLayout(SWTLayoutUtils.createLayoutNoMarginNoSpacing(2));
    twoCols.setLayoutData(SWTLayoutUtils.createGDFillHorizontalNoGrab());
    
    missingLibrariesImg = new Label(twoCols, SWT.NONE);
    GridData data = new GridData();
    data.verticalAlignment = SWT.BEGINNING;
    data.verticalIndent = 3;
    missingLibrariesImg.setLayoutData(data);
    
    missingLibrariesTxt = new Label(twoCols, SWT.NONE);
    data = GridDataFactory.copyData(data);
    data.horizontalIndent = 5;
    data.verticalIndent = 0;
    missingLibrariesTxt.setLayoutData(data);
    
    advancedSection.setClient(treeComposite);
    
    SWTUtils.setBackgroundColor(treeComposite);
}
 
Example 17
Source File: LTTngProfileViewer.java    From tracecompass with Eclipse Public License 2.0 3 votes vote down vote up
/**
 * Creates a CheckboxTreeViewer for selection available LTTng profiles.
 * @param parent
 *                A parent composite
 * @param style
 *                The style bits
 * @return LTTng Profiles CheckboxTreeViewer
 */
public static CheckboxTreeViewer createLTTngProfileViewer(Composite parent, int style) {
    CheckboxTreeViewer fFolderViewer = new CheckboxTreeViewer(parent, style);
    fFolderViewer.setContentProvider(new ProfileContentProvider());
    fFolderViewer.setLabelProvider(new ProfileLabelProvider());
    fFolderViewer.setInput(getViewerInput());
    return fFolderViewer;
}