Java Code Examples for org.eclipse.ui.dialogs.FilteredTree#setLayoutData()

The following examples show how to use org.eclipse.ui.dialogs.FilteredTree#setLayoutData() . 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: WorkspaceResourceSelectionDialog.java    From typescript.java with MIT License 5 votes vote down vote up
protected TreeViewer doCreateTreeViewer(Composite parent, int style) {
	FilteredTree tree = new FilteredTree(parent, style, new PatternFilter(), true);
	tree.setLayoutData(new GridData(GridData.FILL_BOTH));

	applyDialogFont(tree);

	TreeViewer viewer = tree.getViewer();
	return viewer;
}
 
Example 2
Source File: FilteredElementTreeSelectionDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected TreeViewer doCreateTreeViewer(Composite parent, int style) {
	FilteredTree tree= new FilteredTreeWithFilter(parent, style, fInitialFilter, fIsDeepFiltering);
	tree.setLayoutData(new GridData(GridData.FILL_BOTH));

	applyDialogFont(tree);

	TreeViewer viewer= tree.getViewer();
	SWTUtil.setAccessibilityText(viewer.getControl(), Strings.removeMnemonicIndicator(getMessage()));
	return viewer;
}
 
Example 3
Source File: BonitaTreeViewer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private TreeViewer createFilteredTree(final Composite mainComposite) {
    final PatternFilter filter = new SearchPatternFilter();
    filter.setIncludeLeadingWildcard(true);
    filteredTree = new FilteredTree(mainComposite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL, filter, true);
    final TreeViewer treeViewer = filteredTree.getViewer();
    treeViewer.getTree().setData(SWTBOT_WIDGET_ID_KEY, BONITA_OVERVIEW_TREE_ID);
    filteredTree.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    filteredTree.getFilterControl().setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
    filteredTree.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
    return treeViewer;
}
 
Example 4
Source File: SelectConnectorConfigurationWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void createControl(Composite parent) {
	Composite composite = new Composite(parent, SWT.NONE);
       composite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).extendedMargins(10, 10, 10, 0).create());
	filterTree = new FilteredTree(composite, SWT.SINGLE | SWT.BORDER, new PatternFilter(), true);
       filterTree.setLayoutData(GridDataFactory.fillDefaults().grab(true,true).create()) ;
       filterTree.getViewer().setLabelProvider(new ConnectorConfigurationLabelProvider());
       filterTree.getViewer().setContentProvider(new ConnectorConfigurationContentProvider());
       filterTree.getViewer().addSelectionChangedListener(this) ;
       filterTree.getViewer().addDoubleClickListener(this) ;
       filterTree.getViewer().setInput(new Object());
       filterTree.getViewer().addFilter(new ViewerFilter() {

           @Override
           public boolean select(Viewer arg0, Object arg1, Object element) {
           	ITreeContentProvider contentProvider = (ITreeContentProvider)filterTree.getViewer().getContentProvider();
			if (element instanceof Category){
				
           		if(!contentProvider.hasChildren(element)){
           			return false;
           		}
           		boolean hasElements=false;
           		for(Object c : contentProvider.getChildren(element)){
           					hasElements=hasElements || select(arg0,element,c);
           				}
           		return hasElements;
           	}else if(element instanceof ConnectorDefinition){
           		return contentProvider.getChildren(element).length > 0;
   
   			}
               return element instanceof ConnectorConfiguration;
           }
       }) ;
       filterTree.getViewer().expandAll();
       filterTree.setFocus();
       setControl(composite);
}
 
Example 5
Source File: AbstractManageDiagramWizardPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected Composite doCreateControl(final Composite parent, final DataBindingContext context) {
    final Composite mainComposite = new Composite(parent, SWT.NONE);
    mainComposite.setLayout(fillDefaults().numColumns(2).equalWidth(true).create());

    diagramTree = new FilteredTree(mainComposite, SWT.MULTI | SWT.BORDER, new PatternFilter(), false);
    final TreeViewer treeViewer = diagramTree.getViewer();
    treeViewer.getTree().setData(SWTBOT_WIDGET_ID_KEY, SWTBOT_ID_OPEN_DIAGRAM_TREE_ID);
    diagramTree
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(2, 1).hint(SWT.DEFAULT, 250).create());

    treeViewer.setContentProvider(
            new ObservableListTreeContentProvider(diagramListObservableFactory(), diagramTreeStructure()));
    treeViewer.setLabelProvider(new DiagramLabelProvider(new FileStoreLabelProvider()));

    final IObservableList selectionObservable = PojoObservables.observeList(this, "selectedDiagrams");
    context.bindList(ViewersObservables.observeMultiSelection(diagramTree.getViewer()),
            selectionObservable);
    context.addValidationStatusProvider(new MultiValidator() {

        @Override
        protected IStatus validate() {
            return selectionObservable.isEmpty() ? ValidationStatus.error(Messages.noDiagramSelected)
                    : ValidationStatus.ok();
        }
    });
    treeViewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(final DoubleClickEvent arg0) {
            final IWizard wizard = getWizard();
            if (wizard.canFinish() && wizard.performFinish() && wizard.getContainer() instanceof WizardDialog) {
                ((WizardDialog) wizard.getContainer()).close();
            }
        }
    });
    treeViewer.setInput(diagramRepositoryStore);
    treeViewer.getTree().setFocus();
    defaultSelection(selectionObservable);
    return mainComposite;
}
 
Example 6
Source File: GroupsWizardPage.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected StructuredViewer createViewer(final Composite parent) {
    final FilteredTree fileredTree = new FilteredTree(parent, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION, new PatternFilter(), true);
    ((Text) ((Composite) fileredTree.getChildren()[0]).getChildren()[0]).setMessage(Messages.search);
    fileredTree.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).minSize(200, 200).create());
    fileredTree.getViewer().setContentProvider(new GroupContentProvider());
    fileredTree.forceFocus();

    groupSingleSelectionObservable = ViewersObservables.observeSingleSelection(fileredTree.getViewer());
    groupSingleSelectionObservable.addValueChangeListener(new IValueChangeListener() {

        private final Adapter groupAdapter = new AdapterImpl() {

            /*
             * (non-Javadoc)
             * @see org.eclipse.emf.common.notify.impl.AdapterImpl#notifyChanged(org.eclipse.emf.common.notify.Notification)
             */
            @Override
            public void notifyChanged(Notification notification) {
                switch (notification.getFeatureID(org.bonitasoft.studio.actors.model.organization.Group.class)) {
                    case OrganizationPackage.GROUP__NAME:
                        handleGroupNameChange(notification);
                        break;
                    default:
                        break;
                }
                super.notifyChanged(notification);
            }
        };

        @Override
        public void handleValueChange(final ValueChangeEvent event) {
            final org.bonitasoft.studio.actors.model.organization.Group previousGroup = (org.bonitasoft.studio.actors.model.organization.Group) event.diff
                    .getOldValue();
            if (previousGroup != null) {
                previousGroup.eAdapters().remove(groupAdapter);
            }
            final org.bonitasoft.studio.actors.model.organization.Group selectedGroup = (org.bonitasoft.studio.actors.model.organization.Group) event.diff
                    .getNewValue();

            if (selectedGroup != null) {
                setControlEnabled(getInfoGroup(), true);
                selectedGroup.eAdapters().add(groupAdapter);
                addSubGroupButton.setEnabled(true);
            } else {
                addSubGroupButton.setEnabled(false);
                setControlEnabled(getInfoGroup(), false);
            }

        }
    });

    return fileredTree.getViewer();
}
 
Example 7
Source File: SelectProcessWizardPage.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void createControl(Composite parent) {
	Composite mainComposite = new Composite(parent, SWT.NONE) ;
	mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()) ;
	mainComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(1).create()) ;
	
	databindingContext = new DataBindingContext() ;
	
	final FilteredTree tree = new FilteredTree(mainComposite, SWT.FULL_SELECTION | SWT.BORDER | SWT.SINGLE,new PatternFilter(), false) ;
	tree.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()) ;
	TreeViewer viewer = tree.getViewer() ;
	viewer.setContentProvider(new ProcessContentProvider()) ;
	viewer.setLabelProvider(new ProcessTreeLabelProvider()) ;

	UpdateValueStrategy startegy = new UpdateValueStrategy() ;
	startegy.setBeforeSetValidator(new IValidator() {
		
		@Override
		public IStatus validate(Object value) {
			if(value  instanceof AbstractProcess && !(value instanceof MainProcess)){
				return Status.OK_STATUS ;
			}
			return ValidationStatus.error(Messages.mustSelectProcessError);
		}
	}) ;

	if(diagram == null){
		viewer.setInput(new Object[]{ProcessContentProvider.OTHER_PROCESSES}) ;
	}else{
		viewer.setInput(new Object[]{diagram,ProcessContentProvider.OTHER_PROCESSES}) ;
	}

	if(diagram != null){
		if(((ITreeContentProvider) viewer.getContentProvider()).hasChildren(diagram)){
			viewer.expandToLevel(diagram, 1) ;
		}
	}else{
		if(((ITreeContentProvider) viewer.getContentProvider()).hasChildren(ProcessContentProvider.OTHER_PROCESSES)){
			viewer.expandToLevel(ProcessContentProvider.OTHER_PROCESSES, 1) ;
		}
	}
	
	WizardPageSupport.create(this,databindingContext) ;
	databindingContext.bindValue(ViewersObservables.observeSingleSelection(viewer), PojoObservables.observeValue(this, "selection"),startegy,null) ;


	
	setControl(mainComposite) ;
}