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

The following examples show how to use org.eclipse.ui.dialogs.FilteredTree#getViewer() . 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: M2DocTypeSelectionDialog.java    From M2Doc with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Control createCustomArea(Composite parent) {
    final Composite container = new Composite(parent, parent.getStyle());
    container.setLayout(new GridLayout(1, false));
    container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));

    final FilteredTree filteredTree = new FilteredTree(container, SWT.BORDER, new PatternFilter(), true);
    final TreeViewer treeViewer = filteredTree.getViewer();
    final Tree tree = treeViewer.getTree();
    final GridData gdTable = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
    gdTable.minimumWidth = TABLE_MINIMUM_WIDTH;
    gdTable.minimumHeight = TABLE_MINIMUM_HEIGHT;
    tree.setLayoutData(gdTable);
    treeViewer.setContentProvider(new CollectionContentProvider());
    treeViewer.setLabelProvider(new LabelProvider());
    treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            final Object selected = ((IStructuredSelection) event.getSelection()).getFirstElement();
            selectedType = (String) selected;
        }
    });
    treeViewer.setInput(getAvailableTypes(nsURIs));
    if (defaultType != null) {
        treeViewer.setSelection(new StructuredSelection(defaultType));
    }

    return container;
}
 
Example 2
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 3
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 4
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 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: ControlView.java    From tracecompass with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void createPartControl(Composite parent) {
    // Filter that shows all children of a match node
    PatternFilter filter = new PatternFilter() {
        @Override
        protected boolean isLeafMatch(Viewer viewer, Object element) {
            ITraceControlComponent parentElement = (ITraceControlComponent) element;
            while (parentElement != null) {
                if (super.isLeafMatch(viewer, parentElement)) {
                    return true;
                }
                parentElement = parentElement.getParent();
            }
            return false;
        }
    };

    // Create filtered tree
    FilteredTree filteredTree = new FilteredTree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL, filter, true) {
        @Override
        protected void updateToolbar(boolean visible) {
            super.updateToolbar(visible);
            treeViewer.expandToLevel(DEFAULT_EXPAND_LEVEL);
        }
    };

    fTreeViewer = filteredTree.getViewer();
    ColumnViewerToolTipSupport.enableFor(fTreeViewer);

    fTreeViewer.setContentProvider(new TraceControlContentProvider());
    fTreeViewer.setLabelProvider(new TraceControlLabelProvider());

    // Create model root
    fRoot = new TraceControlRoot();
    fRoot.addComponentListener(this);
    if (fInitialConnections != null) {
        for (IRemoteConnection rc : fInitialConnections) {
            TargetNodeComponent node = new TargetNodeComponent(rc.getName(), fRoot, rc);
            fRoot.addChild(node);
        }
        fInitialConnections = null;
    }
    fTreeViewer.setInput(fRoot);

    // Create context menu for the tree viewer
    createContextMenu();

    getSite().setSelectionProvider(fTreeViewer);
}
 
Example 7
Source File: EIPModelAndRouteSelectionDialog.java    From eip-designer with Apache License 2.0 4 votes vote down vote up
@Override
protected Control createDialogArea(Composite base) {
   Composite parent = (Composite) super.createDialogArea(base);
   Composite composite = new Composite(parent, SWT.NONE);
   
   GridLayout layout = new GridLayout();
   layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
   layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
   layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
   layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
   composite.setLayout(layout);
   composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
   
   // Manage dialog tree content.
   FilteredTree tree = new FilteredTree(composite, SWT.SINGLE | SWT.BORDER,
         new PatternFilter(), true);

   projectTree = tree.getViewer();
   projectTree.setLabelProvider(new EIPModelTreeLabelProvider());
   projectTree.setContentProvider(new EIPModelTreeContentProvider());
   projectTree.setInput(ResourcesPlugin.getWorkspace().getRoot());
   
   GridDataFactory.fillDefaults().grab(true, true).hint(500, 300).applyTo(tree);
   
   // Manage dialog tree events.
   projectTree.addSelectionChangedListener(new ISelectionChangedListener() {
      @Override
      public void selectionChanged(SelectionChangedEvent event) {
         if (event.getSelection() instanceof TreeSelection) {
            TreeSelection tSelection = (TreeSelection)event.getSelection();
            if (tSelection.getFirstElement() instanceof IResource) {
               eipModel = (IResource) tSelection.getFirstElement();
            }
         }
      }
   });
   
   setTitle("Choose a target EIP model");
   setMessage("Select the EIP model for designing a new Route from Service");
   applyDialogFont(composite);
   
   return composite;
}
 
Example 8
Source File: CompareTargetSelectionDialog.java    From eip-designer with Apache License 2.0 4 votes vote down vote up
@Override
protected Control createDialogArea(Composite base) {
   Composite parent = (Composite) super.createDialogArea(base);
   Composite composite = new Composite(parent, SWT.NONE);
   
   GridLayout layout = new GridLayout();
   layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
   layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
   layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
   layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
   composite.setLayout(layout);
   composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
   
   // Manage dialog tree content.
   FilteredTree tree = new FilteredTree(composite, SWT.SINGLE | SWT.BORDER,
         new PatternFilter(), true);

   projectTree = tree.getViewer();
   projectTree.setLabelProvider(new RouteTreeLabelProvider());
   projectTree.setContentProvider(new RouteTreeContentProvider());
   projectTree.setInput(ResourcesPlugin.getWorkspace().getRoot());
   
   GridDataFactory.fillDefaults().grab(true, true).hint(500, 300).applyTo(tree);
   
   // Manage dialog tree events.
   projectTree.addSelectionChangedListener(new ISelectionChangedListener() {
      @Override
      public void selectionChanged(SelectionChangedEvent event) {
         if (event.getSelection() instanceof TreeSelection) {
            TreeSelection tSelection = (TreeSelection)event.getSelection();
            if (tSelection.getFirstElement() instanceof Route) {
               selectedRoute = (Route) tSelection.getFirstElement();
            }
         }
      }
   });
   
   setTitle("Compare '" + fileName + "' with an EIP Route model");
   setMessage("Select an EIP Route to compare the resource with");
   applyDialogFont(composite);
   
   return composite;
}
 
Example 9
Source File: PersistTargetSelectionDialog.java    From eip-designer with Apache License 2.0 4 votes vote down vote up
@Override
protected Control createDialogArea(Composite base) {
   Composite parent = (Composite) super.createDialogArea(base);
   Composite composite = new Composite(parent, SWT.NONE);
   
   GridLayout layout = new GridLayout();
   layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
   layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
   layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
   layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
   composite.setLayout(layout);
   composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
   
   // Manage dialog tree content.
   FilteredTree tree = new FilteredTree(composite, SWT.SINGLE | SWT.BORDER,
         new PatternFilter(), true);

   projectTree = tree.getViewer();
   projectTree.setLabelProvider(new EIPModelTreeLabelProvider());
   projectTree.setContentProvider(new EIPModelTreeContentProvider());
   projectTree.setInput(ResourcesPlugin.getWorkspace().getRoot());
   
   GridDataFactory.fillDefaults().grab(true, true).hint(500, 300).applyTo(tree);
   
   // Manage dialog tree events.
   projectTree.addSelectionChangedListener(new ISelectionChangedListener() {
      @Override
      public void selectionChanged(SelectionChangedEvent event) {
         if (event.getSelection() instanceof TreeSelection) {
            TreeSelection tSelection = (TreeSelection)event.getSelection();
            if (tSelection.getFirstElement() instanceof IResource) {
               selectedEIPModel = (IResource) tSelection.getFirstElement();
            }
         }
      }
   });
   
   setTitle("Parse and merge '" + fileName + "' with an EIP Model");
   setMessage("Select an EIP Model to persist the parsed resource within");
   applyDialogFont(composite);
   
   return composite;
}
 
Example 10
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 11
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) ;
}