org.eclipse.jface.viewers.ColumnViewerToolTipSupport Java Examples

The following examples show how to use org.eclipse.jface.viewers.ColumnViewerToolTipSupport. 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: ContractConstraintsTableViewer.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public void initialize(final IViewerController constraintController, final IMessageManager messageManager,
        final EMFDataBindingContext emfDataBindingContext) {
    this.messageManager = messageManager;
    this.constraintController = constraintController;
    this.emfDataBindingContext = emfDataBindingContext;
    final ProcessItemProviderAdapterFactory adapterFactory = new ProcessItemProviderAdapterFactory();
    propertySourceProvider = new AdapterFactoryContentProvider(adapterFactory);
    adapterFactoryLabelProvider = new AdapterFactoryLabelProvider(adapterFactory);
    getTable().setHeaderVisible(true);
    getTable().setLinesVisible(true);
    setContentProvider(new ObservableListContentProvider());

    final CellNavigationStrategy cellNavigationStrategy = new AddRowOnEnterCellNavigationStrategy(this, constraintController);
    final TableViewerFocusCellManager focusCellManager = new TableViewerFocusCellManager(this, new FocusCellOwnerDrawHighlighter(
            this), cellNavigationStrategy);

    TableViewerEditor.create(this, focusCellManager, new CharriageColumnViewerEditorActivationStrategy(this), ColumnViewerEditor.TABBING_HORIZONTAL |
            ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR |
            ColumnViewerEditor.TABBING_VERTICAL |
            ColumnViewerEditor.KEYBOARD_ACTIVATION);

    ColumnViewerToolTipSupport.enableFor(this);
    createColumns();
    configureTableLayout();
}
 
Example #2
Source File: AdditionalResourcesConfigurationWizardPage.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createViewer(Composite parent) {
    viewer = new TableViewer(parent, SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE);
    viewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    ColumnViewerToolTipSupport.enableFor(viewer);
    viewer.setUseHashlookup(true);
    viewer.getTable().setHeaderVisible(true);
    viewer.getTable().setLinesVisible(true);

    TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(1, true));
    layout.addColumnData(new ColumnWeightData(1, true));
    viewer.getTable().setLayout(layout);

    createNameColumn();
    createFileColumn();

    viewer.setContentProvider(new ArrayContentProvider());
}
 
Example #3
Source File: BusinessObjectList.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected void createViewer(Composite parent, AbstractBdmFormPage formPage) {
    viewer = new TreeViewer(parent, SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.FULL_SELECTION);
    viewer.getTree().setLayoutData(GridDataFactory.fillDefaults().span(2, 1).grab(true, true).create());
    formPage.getToolkit().adapt(viewer.getTree());
    viewer.getTree().setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, BUSINESS_OBJECT_LIST_VIEWER_ID);
    viewer.addFilter(createSearchFilter());
    viewer.addDoubleClickListener(e -> {
        viewer.setExpandedState(selectionObservable.getValue(),
                !viewer.getExpandedState(selectionObservable.getValue()));
    });

    ColumnViewerToolTipSupport.enableFor(viewer);
    TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(1, true));
    viewer.getTree().setLayout(layout);
    viewer.setUseHashlookup(true);
    createBusinessObjectColumn(viewer, formPage);
    viewer.setContentProvider(new BusinessObjectTreeContentProvider());
    viewer.setComparator(new BusinessObjectViewerComparator());
    viewer.setInput(input);
    addDNDSupport(formPage);
    selectionObservable = ViewerProperties.singleSelection(Object.class).observe(viewer);
}
 
Example #4
Source File: IndexControl.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createIndexViewer(Composite parent) {
    indexViewer = new TableViewer(parent, SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE);
    indexViewer.getTable()
            .setLayoutData(GridDataFactory.fillDefaults().grab(false, true).span(2, 1).hint(350, SWT.DEFAULT).create());
    indexViewer.getTable().setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, INDEX_LIST_VIEWER_ID);
    formPage.getToolkit().adapt(indexViewer.getTable());
    ColumnViewerToolTipSupport.enableFor(indexViewer);
    indexViewer.setUseHashlookup(true);
    indexViewer.getTable().setHeaderVisible(true);
    indexViewer.getTable().setLinesVisible(true);
    indexViewer.addFilter(createSearchFilter());

    TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(1, true));
    layout.addColumnData(new ColumnWeightData(1, true));
    indexViewer.getTable().setLayout(layout);

    createIndexNameColumn(indexViewer);
    createAttributesColumn(indexViewer);

    indexViewer.setContentProvider(new ObservableListContentProvider());
    indexViewer.setInput(indexObservable);
    selectedIndexObservable = ViewerProperties.singleSelection(Index.class).observe(indexViewer);
}
 
Example #5
Source File: ConstraintEditionControl.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private void createConstraintsDefinitionViewer(AbstractBdmFormPage formPage, Composite parent) {
    constraintViewer = new TableViewer(parent,
            SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE);
    constraintViewer.getTable()
            .setLayoutData(GridDataFactory.fillDefaults().span(2, 1).grab(true, true).create());
    constraintViewer.getTable().setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, CONSTRAINTS_LIST_VIEWER_ID);
    formPage.getToolkit().adapt(constraintViewer.getTable());
    ColumnViewerToolTipSupport.enableFor(constraintViewer);
    constraintViewer.setUseHashlookup(true);
    constraintViewer.getTable().setHeaderVisible(true);
    constraintViewer.getTable().setLinesVisible(true);
    constraintViewer.addFilter(createSearchFilter());

    TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(1, true));
    layout.addColumnData(new ColumnWeightData(1, true));
    constraintViewer.getTable().setLayout(layout);

    createConstraintnameColumn(constraintViewer);
    createAttributesColumn(constraintViewer);

    constraintViewer.setContentProvider(new ObservableListContentProvider());
    constraintViewer.setInput(constraintsObservable);
    selectedConstraintObservable = ViewerProperties.singleSelection(UniqueConstraint.class).observe(constraintViewer);
}
 
Example #6
Source File: ServersViewer.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
public ServersViewer ( final Composite parent )
{
    parent.setLayout ( new FillLayout () );
    this.viewer = new TreeViewer ( parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL );

    this.contentProvider = new ObservableSetTreeContentProvider ( new ObservableFactoryImpl (), null );
    this.viewer.setContentProvider ( this.contentProvider );
    this.labelProvider = new ServerLabelProvider ( this.contentProvider.getKnownElements () );
    this.viewer.setLabelProvider ( this.labelProvider );

    this.viewer.setInput ( HivesPlugin.getDefault ().getServerManager () );
    this.viewer.getControl ().addDisposeListener ( new DisposeListener () {

        @Override
        public void widgetDisposed ( final DisposeEvent e )
        {
            handleDispose ();
        }
    } );

    ColumnViewerToolTipSupport.enableFor ( this.viewer );
}
 
Example #7
Source File: QueryEditionControl.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private TreeViewer createQueryViewer(Composite parent) {
    TreeViewer queryViewer = new TreeViewer(parent,
            SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE);
    queryViewer.getTree()
            .setLayoutData(GridDataFactory.fillDefaults().grab(false, true).hint(300, SWT.DEFAULT).create());
    queryViewer.getTree().setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, QUERY_LIST_VIEWER_ID);
    formPage.getToolkit().adapt(queryViewer.getTree());
    ColumnViewerToolTipSupport.enableFor(queryViewer);
    queryViewer.setUseHashlookup(true);
    queryViewer.addFilter(createSearchFilter());
    queryViewer.addDoubleClickListener(e -> {
        queryViewer.setExpandedState(querySelectedObservable.getValue(),
                !viewer.getExpandedState(querySelectedObservable.getValue()));
    });

    TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(1, true));
    queryViewer.getTree().setLayout(layout);

    createQueryNameColumn(queryViewer);

    provider = new QueryContentProvider();
    queryViewer.setContentProvider(provider);
    return queryViewer;
}
 
Example #8
Source File: QueryDetailsControl.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void createParametersTable(Composite parent) {
    parametersTableViewer = new TableViewer(parent,
            SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI);
    parametersTableViewer.getControl()
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).span(2, 1).create());
    parametersTableViewer.getTable().setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, QUERY_PARAMETERS_VIEWER_ID);
    ColumnViewerToolTipSupport.enableFor(parametersTableViewer);
    parametersTableViewer.getTable().setHeaderVisible(true);
    parametersTableViewer.setContentProvider(new ObservableListContentProvider());
    parametersTableViewer.addFilter(createSearchFilter());

    TableLayout tableLayout = new TableLayout();
    tableLayout.addColumnData(new ColumnWeightData(1));
    tableLayout.addColumnData(new ColumnWeightData(1));
    tableLayout.addColumnData(new ColumnWeightData(2));
    parametersTableViewer.getTable().setLayout(tableLayout);

    createNameColumn(parametersTableViewer);
    createTypeColumn(parametersTableViewer);
    createDescriptionColumn(parametersTableViewer);

    selectedQueryParameterObservableList = EMFObservables.observeDetailList(Realm.getDefault(),
            querySelectedObservable,
            BusinessDataModelPackage.Literals.QUERY__QUERY_PARAMETERS);
    parametersMultipleSelectionObservable = ViewerProperties.multipleSelection(QueryParameter.class)
            .observe(parametersTableViewer);
    parametersTableViewer.setInput(selectedQueryParameterObservableList);
}
 
Example #9
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 #10
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 #11
Source File: NavigationTree.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private static TreeViewer createViewer(Composite parent, boolean multi) {
	int selectionFlag = multi ? SWT.MULTI : SWT.SINGLE;
	TreeViewer viewer = new TreeViewer(parent, SWT.BORDER | selectionFlag);
	viewer.setContentProvider(new NavigationContentProvider());
	viewer.setLabelProvider(new NavigationLabelProvider(false));
	viewer.setComparator(new NavigationComparator());
	ColumnViewerToolTipSupport.enableFor(viewer);
	return viewer;
}
 
Example #12
Source File: Navigator.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
@Override
protected void initListeners(TreeViewer viewer) {
	super.initListeners(viewer);
	viewer.setUseHashlookup(true);
	ColumnViewerToolTipSupport.enableFor(viewer);
	viewer.addDoubleClickListener(evt -> {
		var elem = Viewers.getFirst(evt.getSelection());
		if (elem instanceof ModelElement) {
			var model = ((ModelElement) elem).getContent();
			App.openEditor(model);
		} else if (elem instanceof DatabaseElement) {
			var config = ((DatabaseElement) elem).getContent();
			if (config != null && !Database.isActive(config)) {
				new DbActivateAction(config).run();
			}
		} else if (elem instanceof ScriptElement) {
			var file = ((ScriptElement) elem).getContent();
			if (file.isDirectory())
				return;
			if (file.getName().endsWith(".py")) {
				PythonEditor.open(file);
			}
		} else if (elem instanceof LibraryElement) {
			var library = ((LibraryElement) elem).getContent();
			LibraryInfoPage.show(library);
		}
	});
}
 
Example #13
Source File: ContractInputTreeViewer.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public void initialize(final ContractInputController inputController, final IMessageManager messageManager,
        final EMFDataBindingContext emfDataBindingContext) {
    this.messageManager = messageManager;
    this.inputController = inputController;
    this.emfDataBindingContext = emfDataBindingContext;
    final ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(
            ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
    propertySourceProvider = new ContractInputTypePropertyDescriptor(adapterFactory);
    adapterFactoryLabelProvider = new AdapterFactoryLabelProvider(adapterFactory);
    getTree().setHeaderVisible(true);
    getTree().setLinesVisible(true);
    addFilter(new ComplexTypeChildrenViewerFilter());
    final ObservableListTreeContentProvider contentProvider = new ObservableListTreeContentProvider(
            new ContractInputObservableFactory(),
            new ContractInputTreeStructureAdvisor());
    setContentProvider(contentProvider);
    final CellNavigationStrategy cellNavigationStrategy = new AddRowOnEnterCellNavigationStrategy(this, inputController);
    final TreeViewerFocusCellManager focusCellManager = new TreeViewerFocusCellManager(this,
            new FocusCellOwnerDrawHighlighter(
                    this),
            cellNavigationStrategy);

    TreeViewerEditor.create(this, focusCellManager, new CharriageColumnViewerEditorActivationStrategy(this),
            ColumnViewerEditor.TABBING_HORIZONTAL |
                    ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR |
                    ColumnViewerEditor.TABBING_VERTICAL |
                    ColumnViewerEditor.KEYBOARD_ACTIVATION);

    ColumnViewerToolTipSupport.enableFor(this);

    createColumns();
    configureTableLayout();
}
 
Example #14
Source File: ParameterPropertySection.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void createParameterComposite(final Composite parent) {
    final Composite parameterComposite = getWidgetFactory().createComposite(parent);
    parameterComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    parameterComposite.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create());

    final Composite buttonsComposite = getWidgetFactory().createComposite(parameterComposite, SWT.NONE);
    buttonsComposite.setLayout(GridLayoutFactory.fillDefaults().spacing(0, 3).create());
    buttonsComposite.setLayoutData(GridDataFactory.fillDefaults().align(SWT.FILL, SWT.TOP).create());

    createAddParameterButton(buttonsComposite);
    updateButton = createUpdateParameterButton(buttonsComposite);
    createRemoveParameterButton(buttonsComposite);

    parameterTableViewer = new TableViewer(widgetFactory.createTable(parameterComposite,
            GTKStyleHandler.removeBorderFlag(SWT.BORDER | SWT.MULTI | SWT.NO_FOCUS | SWT.H_SCROLL | SWT.V_SCROLL)));
    parameterTableViewer.getTable().setLayout(GridLayoutFactory.fillDefaults().create());
    getWidgetFactory().adapt(parameterTableViewer.getTable(), false, false);
    parameterTableViewer.getTable()
            .setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(200, 100).create());
    parameterTableViewer.setSorter(new ViewerSorter());
    parameterTableViewer.addDoubleClickListener(this);
    parameterTableViewer.addSelectionChangedListener(this);
    parameterTableViewer.getTable().addKeyListener(new KeyAdapter() {

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

    parameterTableViewer.setContentProvider(new ArrayContentProvider());
    parameterTableViewer.setLabelProvider(new ParameterStyledLabelProvider());
    ColumnViewerToolTipSupport.enableFor(parameterTableViewer, ToolTip.RECREATE);
}
 
Example #15
Source File: ValidationViewPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void addSeverityDescriptionColumn() {
    severityColumn = new TableViewerColumn(tableViewer, SWT.NONE);
    severityColumn.getColumn().setText(
            Messages.validationViewSeverityColumnName);
    severityColumn.setLabelProvider(new SeverityColumnLabelProvider());
    ColumnViewerToolTipSupport.enableFor(severityColumn.getViewer());
}
 
Example #16
Source File: AttributeEditionControl.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private void createAttributeTableViewer(Composite parent) {
    viewer = new TableViewer(parent,
            SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE);
    viewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    viewer.getTable().setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, ATTRIBUTE_LIST_VIEWER_ID);
    formPage.getToolkit().adapt(viewer.getTable());
    ColumnViewerToolTipSupport.enableFor(viewer);
    viewer.setUseHashlookup(true);
    viewer.getTable().setHeaderVisible(true);
    viewer.getTable().setLinesVisible(true);
    viewer.addFilter(new SearchFilter<>(fieldToFilter));

    TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(5, true));
    layout.addColumnData(new ColumnWeightData(4, true));
    layout.addColumnData(new ColumnWeightData(3, true));
    layout.addColumnData(new ColumnWeightData(3, true));
    viewer.getTable().setLayout(layout);

    createNameColumn(viewer);
    createTypeColumn(viewer);
    createMultipleColumn(viewer);
    createMandatoryColumn(viewer);

    viewer.setContentProvider(new ObservableListContentProvider());
    viewer.setInput(fieldsObservable);
    selectedFieldObservable = ViewerProperties.singleSelection(Field.class).observe(viewer);

    addDragAndDropSupport();
}
 
Example #17
Source File: SmartImportBdmPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private Composite createMergeViewer(Composite parent) {
    Composite composite = new Composite(parent, SWT.None);
    composite.setLayout(GridLayoutFactory.fillDefaults().spacing(LayoutConstants.getSpacing().x, 1).create());
    composite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    viewer = new TreeViewer(composite,
            SWT.VIRTUAL | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
    viewer.getTree().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    viewer.setUseHashlookup(true);
    ColumnViewerToolTipSupport.enableFor(viewer);
    viewer.getTree().setHeaderVisible(true);
    viewer.getTree().setLinesVisible(true);
    viewer.setContentProvider(new SmartImportBdmTreeContentProvider());

    TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(6, true));
    layout.addColumnData(new ColumnWeightData(2, true));
    viewer.getTree().setLayout(layout);

    createModelColumn();
    createActionColumn();

    IViewerObservableValue singleSelectionObservable = ViewerProperties.singleSelection().observe(viewer);
    viewer.addDoubleClickListener(e -> viewer.setExpandedState(singleSelectionObservable.getValue(),
            !viewer.getExpandedState(singleSelectionObservable.getValue())));
    return composite;
}
 
Example #18
Source File: EditExpressionDialog.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected void createExpressionTypePanel(final Composite parentForm) {
    final Composite parentComposite = new Composite(parentForm, SWT.NONE);
    parentComposite
            .setLayoutData(GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.FILL).grab(false, true).create());
    parentComposite.setLayout(GridLayoutFactory.fillDefaults().spacing(LayoutConstants.getSpacing().x, 1).create());

    final Label expressionTypeLabel = new Label(parentComposite, SWT.NONE);
    expressionTypeLabel.setText(Messages.expressionTypeLabel);
    expressionTypeLabel.setLayoutData(GridDataFactory.swtDefaults().grab(true, false).create());

    expressionTypeViewer = new TableViewer(parentComposite, SWT.FULL_SELECTION | SWT.BORDER | SWT.SINGLE);
    expressionTypeViewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    expressionTypeViewer.setContentProvider(new ExpressionTypeContentProvider());
    expressionTypeViewer.setLabelProvider(new ExpressionTypeLabelProvider());
    expressionTypeViewer.setSorter(new ViewerSorter() {

        @Override
        public int compare(final Viewer viewer, final Object e1, final Object e2) {
            final IExpressionProvider p1 = (IExpressionProvider) e1;
            final IExpressionProvider p2 = (IExpressionProvider) e2;
            return p1.getTypeLabel().compareTo(p2.getTypeLabel());
        }
    });
    if (viewerTypeFilters != null) {
        expressionTypeViewer.setFilters(viewerTypeFilters);
    }
    if (!filteredEditor.isEmpty()) {
        expressionTypeViewer.addFilter(filterEditor());
    }
    ColumnViewerToolTipSupport.enableFor(expressionTypeViewer, ToolTip.NO_RECREATE);
    expressionTypeViewer.setInput(expressionViewer.getInput());
}
 
Example #19
Source File: SelectionPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Control createControl(Composite parent, IWizardContainer wizardContainer, DataBindingContext ctx) {
    Composite mainComposite = new Composite(parent, SWT.NONE);
    mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    mainComposite.setLayout(GridLayoutFactory.fillDefaults().create());

    tableViewer = createTableViewer(mainComposite);
    tableViewer.getControl().setLayoutData(
            GridDataFactory.fillDefaults().grab(true, true).hint(TABLE_WIDTH_HINT, SWT.DEFAULT).create());
    tableViewer.setContentProvider(ArrayContentProvider.getInstance());
    tableViewer.setLabelProvider(labelProvider);
    tableViewer.setInput(getInput());
    tableViewer.addDoubleClickListener(new WizardDoubleClickListener((WizardDialog) wizardContainer));

    ColumnViewerToolTipSupport.enableFor(tableViewer);

    IObservableList<IRepositoryFileStore> multiSelection = ViewersObservables.observeMultiSelection(tableViewer);
    ctx.addValidationStatusProvider(new MultiValidator() {

        @Override
        protected IStatus validate() {
            return multiSelection.isEmpty()
                    ? ValidationStatus.error("No selection")
                    : unselectableElements.isPresent()
                            && multiSelection.stream().anyMatch(unselectableElements.get()::contains)
                                    ? ValidationStatus.error("Unselectable element selected")
                                    : ValidationStatus.ok();
        }
    });

    return mainComposite;
}
 
Example #20
Source File: OpenApplicationPage.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Control createControl(Composite parent, IWizardContainer wizardContainer, DataBindingContext ctx) {
    Composite mainComposite = new Composite(parent, SWT.NONE);
    mainComposite.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    mainComposite.setLayout(GridLayoutFactory.fillDefaults().create());

    TableViewer applicationsTableViewer = new TableViewer(mainComposite);
    applicationsTableViewer.getControl().setLayoutData(
            GridDataFactory.fillDefaults().grab(true, true).hint(TABLE_WIDTH_HINT, SWT.DEFAULT).create());
    applicationsTableViewer.setContentProvider(ArrayContentProvider.getInstance());
    applicationsTableViewer.setLabelProvider(new ApplicationFileStoreLabelProvider());
    applicationsTableViewer
            .setInput(repositoryAccessor.getRepositoryStore(ApplicationRepositoryStore.class).getChildren());

    ColumnViewerToolTipSupport.enableFor(applicationsTableViewer);

    ctx.bindList(ViewersObservables.observeMultiSelection(applicationsTableViewer), applicationFileStoreObservable);
    ctx.addValidationStatusProvider(new org.eclipse.core.databinding.validation.MultiValidator() {

        @Override
        protected IStatus validate() {
            return applicationFileStoreObservable.isEmpty() ? ValidationStatus.error("No selection")
                    : ValidationStatus.ok();
        }
    });

    return mainComposite;
}
 
Example #21
Source File: MOOSETreePropertySection.java    From ice with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates the table that displays properties for viewing and editing.
 * 
 * @param client
 *            The client <code>Composite</code> that should contain the
 *            table of properties.
 * @return The <code>TableViewer</code> for the table of properties.
 */
@Override
protected TableViewer createTableViewer(Composite client) {

	CheckboxTableViewer tableViewer = null;

	if (client != null) {
		Table table;

		// Create the TableViewer and the underlying Table Control.
		tableViewer = CheckboxTableViewer.newCheckList(client,
				SWT.BORDER | SWT.FULL_SELECTION | SWT.V_SCROLL);
		// Set some properties for the table.
		table = tableViewer.getTable();
		table.setHeaderVisible(true);
		table.setLinesVisible(true);

		// Set up the content provider for the table viewer. Now the table
		// viewer's input can be set.
		tableViewer.setContentProvider(new TreePropertyContentProvider());

		// Enable tool tips for the Table's cells.
		ColumnViewerToolTipSupport.enableFor(tableViewer,
				ToolTip.NO_RECREATE);

		// Populate the TableViewer with its columns.
		addTableViewerColumns(tableViewer);
	}

	return tableViewer;
}
 
Example #22
Source File: NameBluemixWizardPage.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
@Override
public void createControl(Composite parent) {
    super.createControl(parent);
    
    Composite container = new Composite(parent, SWT.NONE);
    GridLayout layout = WizardUtils.createGridLayout(1, 5);
    container.setLayout(layout);

    _newRadio = WizardUtils.createRadio(container, "Create a new application:", 1, this);  // $NLX-NameBluemixWizardPage.Createanewapplication-1$
    _newRadio.setSelection(true);
    
    _nameText = WizardUtils.createText(container, 1, 20);
    _nameText.addModifyListener(this);

    _existingRadio = WizardUtils.createRadio(container, "Overwrite an existing application:", 1, this);  // $NLX-NameBluemixWizardPage.Overwriteanexistingapplication-1$

    _appViewer = WizardUtils.createTableViewer(container, 1, 1, null, SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL, 20);
    ColumnViewerToolTipSupport.enableFor(_appViewer, ToolTip.NO_RECREATE);
    _appViewer.getTable().setToolTipText("Choose application"); // $NLX-NameBluemixWizardPage.ChooseApplication-1$
    _appViewer.getTable().setHeaderVisible(false);
    _appViewer.getTable().setLinesVisible(false);
    _appViewer.getTable().addControlListener(this);
    _appViewer.setContentProvider(new ArrayContentProvider());
    _appViewer.addSelectionChangedListener(this);
    _appViewer.getTable().addSelectionListener(this);
    
    // Create the only column
    TableViewerColumn col = new TableViewerColumn(_appViewer, SWT.LEFT);
    col.getColumn().setResizable(false);
    col.setLabelProvider(new ColumnLabelProvider());

    // Create Host Group
    _hostGroup = WizardUtils.createGroup(container, 3, 3);            
    WizardUtils.createLabel(_hostGroup, "Host:", 1); // $NLX-NameBluemixWizardPage.Host-1$
    _hostText = WizardUtils.createText(_hostGroup, 1, 0);
    _hostText.addModifyListener(this);
    _domainLabel = WizardUtils.createLabel(_hostGroup, "", 1);

    setControl(container);
}
 
Example #23
Source File: TaskSelectionDialog.java    From workspacemechanic with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected Control createDialogArea(Composite container) {
  Control area = super.createDialogArea(container);
  TableViewer tableViewer = getTableViewer();
  Table table = tableViewer.getTable();
  tableViewer.setLabelProvider(new DefaultCellLabelProvider());
  ColumnViewerToolTipSupport.enableFor(tableViewer, ToolTip.NO_RECREATE); 
  table.setHeaderVisible(true);
  newTableColumn(table, "Description", 200);
  newTableColumn(table, "ID", 200);
  newTableColumn(table, "Name", 200);
  tableViewer.refresh();
  return area;
}
 
Example #24
Source File: IndexEditionControl.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private void createAvailableAttributesTableViewer(Composite parent) {
    Section section = formPage.getToolkit().createSection(parent, Section.EXPANDED);
    section.setLayout(GridLayoutFactory.fillDefaults().create());
    section.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    section.setText(Messages.availableAttributes);

    Composite client = formPage.getToolkit().createComposite(section);
    client.setLayout(GridLayoutFactory.fillDefaults().create());
    client.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    availableAttributesTableViewer = new TableViewer(client,
            SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI);
    availableAttributesTableViewer.getTable().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
    availableAttributesTableViewer.getTable().setData(SWTBotConstants.SWTBOT_WIDGET_ID_KEY, AVAILABLE_FIELDS_VIEWER_ID);
    formPage.getToolkit().adapt(availableAttributesTableViewer.getTable());
    ColumnViewerToolTipSupport.enableFor(availableAttributesTableViewer);
    availableAttributesTableViewer.setUseHashlookup(true);
    availableAttributesTableViewer.getTable().setLinesVisible(true);
    availableAttributesTableViewer.setFilters(indexableFieldFilter, indexedFieldsFilter());

    TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(1, true));
    availableAttributesTableViewer.getTable().setLayout(layout);

    createAttributesColumn(availableAttributesTableViewer);

    availableAttributesTableViewer.setContentProvider(new ObservableListContentProvider());
    availableAttributesTableViewer.setInput(actualsFieldsObservable);
    selectedAvailableAttributeObservable = ViewersObservables.observeMultiSelection(availableAttributesTableViewer);

    availableAttributesTableViewer.getTable().addMouseMoveListener(e -> updateCursor(e, availableAttributesTableViewer));
    availableAttributesTableViewer.addDragSupport(DND.DROP_MOVE, new Transfer[] { FieldTransfer.getInstance() },
            dragSourceAdapter(selectedAvailableAttributeObservable));
    availableAttributesTableViewer.addDropSupport(DND.DROP_MOVE,
            new Transfer[] { FieldTransfer.getInstance() },
            new DropTargetAdapter() {

                @Override
                public void drop(DropTargetEvent event) {
                    dragLeave(event);
                    indexedFieldsObservable.removeAll((Collection<?>) event.data);
                }
            });

    section.setClient(client);
}
 
Example #25
Source File: ProblemsDialog.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected Control createCustomArea(Composite parent) {
    Collection<T> input = getInput();
    Assert.isNotNull(input);
    if (input.isEmpty()) {
        return super.createCustomArea(parent);
    }
    if(messageLabel != null) {
        GridData layoutData = (GridData) messageLabel.getLayoutData();
        layoutData.verticalAlignment = SWT.CENTER;
    }
    TableViewer problemsViewer = new TableViewer(parent,
            SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
    problemsViewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(600, 100).create());
    problemsViewer.setContentProvider(ArrayContentProvider.getInstance());
    problemsViewer.setComparator(getComparator());

    TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(1, false));
    problemsViewer.getTable().setLayout(layout);

    tableViewerColumn = new TableViewerColumn(problemsViewer, SWT.NONE);
    TypedLabelProvider<T> typedLabelProvider = getTypedLabelProvider();
    Assert.isNotNull(typedLabelProvider);
    tableViewerColumn.setLabelProvider(new LabelProviderBuilder<T>()
            .withTextProvider(typedLabelProvider::getText)
            .withImageProvider(typedLabelProvider::getImage)
            .withTooltipProvider(typedLabelProvider::getToolTipText)
            .createColumnLabelProvider());

    problemsViewer.getTable().getShell().addControlListener(new ControlAdapter() {
        
        @Override
        public void controlResized(ControlEvent e) {
            tableViewerColumn.getColumn().pack();
        }
        
    });
    
    problemsViewer.setInput(input);
    ColumnViewerToolTipSupport.enableFor(problemsViewer);

    return problemsViewer.getControl();
}
 
Example #26
Source File: ImportBosArchiveControlSupplier.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private Composite createTree(Composite parent) {
    final Composite fileTreeGroup = new Composite(parent, SWT.NONE);
    fileTreeGroup.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).margins(0, 5).create());
    fileTreeGroup.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());

    viewer = new TreeViewer(fileTreeGroup,
            SWT.VIRTUAL | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
    viewer.getTree().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(600, SWT.DEFAULT).create());
    provider = new ArchiveTreeContentProvider(viewer);
    viewer.setContentProvider(provider);
    viewer.setUseHashlookup(true); // important for lazy behavior!
    viewer.getTree().setHeaderVisible(true);
    viewer.getTree().setLinesVisible(true);
    final TableLayout layout = new TableLayout();
    layout.addColumnData(new ColumnWeightData(6, true));
    layout.addColumnData(new ColumnWeightData(2, true));
    viewer.getTree().setLayout(layout);
    ColumnViewerToolTipSupport.enableFor(viewer);

    final TreeViewerColumn archiveColumn = new TreeViewerColumn(viewer, SWT.NONE);
    archiveColumn.getColumn().setText(Messages.archiveColumn);
    archiveColumn.setLabelProvider(new DelegatingStyledCellLabelProvider(new ImportModelLabelProvider(
            new ImportModelStyler())));

    final TreeViewerColumn actionColumn = new TreeViewerColumn(viewer, SWT.NONE);
    actionColumn.getColumn().setText(Messages.actionColumn);
    actionColumn.setLabelProvider(new LabelProviderBuilder<>()
            .withTextProvider(this::getActionText)
            .createColumnLabelProvider());
    actionColumn.setEditingSupport(new ImportActionEditingSupport(viewer));

    final Composite buttonsComposite = new Composite(fileTreeGroup, SWT.NONE);
    buttonsComposite.setLayout(GridLayoutFactory.fillDefaults().spacing(5, 2).create());
    buttonsComposite.setLayoutData(
            GridDataFactory.swtDefaults().align(SWT.BEGINNING, SWT.TOP).create());

    importActionSelector = new ImportActionSelector(viewer);
    overwriteButton = new ButtonWidget.Builder()
            .withLabel(Messages.overwriteAll)
            .alignLeft()
            .fill()
            .grabHorizontalSpace()
            .minimumWidth(BUTTON_WIDTH)
            .onClick(importActionSelector::selectOverwriteAll)
            .createIn(buttonsComposite);
    overwriteButton.disable();

    keepAllButton = new ButtonWidget.Builder()
            .withLabel(Messages.keepAll)
            .alignLeft()
            .fill()
            .minimumWidth(BUTTON_WIDTH)
            .grabHorizontalSpace()
            .onClick(importActionSelector::selectKeepAll)
            .createIn(buttonsComposite);
    keepAllButton.disable();

    return fileTreeGroup;
}
 
Example #27
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 #28
Source File: ImportWizardPagePreview.java    From arx with Apache License 2.0 4 votes vote down vote up
/**
 * Adds input to table once page gets visible to the user
 * 
 * This retrieves the preview data {@link ImportWizardModel#getPreviewData()} and applies it to the given {@link #tableViewer}. Only columns that have been enabled will be shown.
 * New names and reordering is also considered.
 *
 * @param visible
 */
@Override
public void setVisible(boolean visible) {

    super.setVisible(visible);

    if (visible) {

        /* Disable rendering until everything is finished */
        table.setRedraw(false);

        /* Remove old columns */
        while (table.getColumnCount() > 0) {
            table.getColumns()[0].dispose();
        }

        /* Add enabled columns with appropriate label providers */
        int columns = 0;
        for (ImportColumn column : wizardImport.getData().getEnabledColumns()) {

            columns++;
            if (columns > MAX_COLUMS) {
                setMessage(Resources.getMessage("ImportWizardPageCSV.21"), WARNING); //$NON-NLS-1$
                break;
            }
            
            TableViewerColumn tableViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
            tableViewerColumn.setLabelProvider(new PreviewColumnLabelProvider(((IImportColumnIndexed) column).getIndex()));

            TableColumn tblclmnColumn = tableViewerColumn.getColumn();
            tblclmnColumn.setToolTipText(Resources.getMessage("ImportWizardPagePreview.5") + //$NON-NLS-1$
                                         column.getDataType());
            tblclmnColumn.setWidth(100);
            tblclmnColumn.setText(column.getAliasName());
        }

        ColumnViewerToolTipSupport.enableFor(tableViewer, ToolTip.NO_RECREATE);

        /* Apply input to tableViewer */
        tableViewer.setInput(wizardImport.getData().getPreviewData());

        /* Make table visible again */
        table.layout();
        table.setRedraw(true);

        setPageComplete(true);

    } else {
        setPageComplete(false);
    }
}
 
Example #29
Source File: MedicationHistoryTableComposite.java    From elexis-3-core with Eclipse Public License 1.0 4 votes vote down vote up
public MedicationHistoryTableComposite(Composite parent, int style){
	super(parent, style);
	
	setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
	layout = new TableColumnLayout();
	setLayout(layout);
	
	viewer = new TableViewer(this, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
	viewer.getTable().setHeaderVisible(true);
	ColumnViewerToolTipSupport.enableFor(viewer, ToolTip.NO_RECREATE);
	
	viewer.addSelectionChangedListener(new ISelectionChangedListener() {
		@Override
		public void selectionChanged(SelectionChangedEvent e){
			IStructuredSelection is = (IStructuredSelection) viewer.getSelection();
			MedicationTableViewerItem presc = (MedicationTableViewerItem) is.getFirstElement();
			
			// set last disposition information
			Identifiable identifiable = (presc != null) ? presc.getLastDisposed() : null;
			medicationComposite.setLastDisposal(identifiable);
			
			// set writable databinding value
			medicationComposite.setSelectedMedication(presc);
			if (presc != null) {
				IPrescription selectedObj = presc.getPrescription();
				ContextServiceHolder.get().getRootContext().setTyped(selectedObj);
			} else {
				ContextServiceHolder.get().getRootContext().removeTyped(IPrescription.class);
			}
		}
	});
	
	MedicationViewerHelper.createTypeColumn(viewer, layout, 0);
	MedicationViewerHelper.createArticleColumn(viewer, layout, 1);
	MedicationViewerHelper.createDosageColumn(viewer, layout, 2);
	MedicationViewerHelper.createBeginColumn(viewer, layout, 3);
	MedicationViewerHelper.createIntakeCommentColumn(viewer, layout, 4);
	
	MedicationViewerHelper.createStopColumn(viewer, layout, 5);
	MedicationViewerHelper.createStopReasonColumn(viewer, layout, 6);
	MedicationViewerHelper.createMandantColumn(viewer, layout, 7);
	
	viewer.setContentProvider(new MedicationTableViewerContentProvider(viewer));
}
 
Example #30
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);
}