Search in sources :

Example 11 with IContentProvider

use of org.eclipse.jface.viewers.IContentProvider in project webtools.sourceediting by eclipse.

the class InternalXSDMultiPageEditor method editorModeChanged.

public void editorModeChanged(EditorMode newEditorMode) {
    // if (isInitializing)
    // return;
    EditPartFactory editPartFactory = newEditorMode.getEditPartFactory();
    if (editPartFactory != null) {
        graphicalViewer.setEditPartFactory(editPartFactory);
        if (graphicalViewer instanceof DesignViewGraphicalViewer) {
            DesignViewGraphicalViewer viewer = (DesignViewGraphicalViewer) graphicalViewer;
            IADTObject input = viewer.getInput();
            viewer.setInput(null);
            // viewer.getRootEditPart().refresh();
            // viewer.getRootEditPart().getContents().refresh();
            viewer.setInput(input);
            floatingToolbar.setEditPartFactory(editPartFactory);
            floatingToolbar.setModel(getModel());
            floatingToolbar.refresh(!(input instanceof IModel));
            Control control = graphicalViewer.getControl();
            if (control instanceof Composite) {
                Composite parent = ((Composite) control).getParent();
                parent.layout();
            }
        }
    }
    IContentProvider provider = newEditorMode.getOutlineProvider();
    if (provider != null) {
        ADTContentOutlinePage outline = (ADTContentOutlinePage) getContentOutlinePage();
        if (outline != null) {
            TreeViewer treeViewer = outline.getTreeViewer();
            if (treeViewer != null) {
                outline.getTreeViewer().setContentProvider(provider);
                outline.getTreeViewer().refresh();
            }
        }
    }
}
Also used : DesignViewGraphicalViewer(org.eclipse.wst.xsd.ui.internal.adt.design.DesignViewGraphicalViewer) IModel(org.eclipse.wst.xsd.ui.internal.adt.facade.IModel) Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) IContentProvider(org.eclipse.jface.viewers.IContentProvider) IADTObject(org.eclipse.wst.xsd.ui.internal.adt.facade.IADTObject) TreeViewer(org.eclipse.jface.viewers.TreeViewer) EditPartFactory(org.eclipse.gef.EditPartFactory) ADTContentOutlinePage(org.eclipse.wst.xsd.ui.internal.adt.outline.ADTContentOutlinePage)

Example 12 with IContentProvider

use of org.eclipse.jface.viewers.IContentProvider in project tdi-studio-se by Talend.

the class ExportItemWizardPage method collectNodes.

private void collectNodes(Map<String, Item> items, Object[] objects) {
    for (Object object : objects) {
        if (object instanceof RepositoryNode) {
            RepositoryNode repositoryNode = (RepositoryNode) object;
            IRepositoryViewObject repositoryObject = repositoryNode.getObject();
            if (repositoryObject != null) {
                if (repositoryObject.getRepositoryObjectType().isResourceItem()) {
                    Item item = repositoryObject.getProperty().getItem();
                    items.put(item.getProperty().getId(), item);
                }
            } else {
                if (repositoryNode.getParent() != null && repositoryNode.getParent().getObject() != null) {
                    Item item = repositoryNode.getParent().getObject().getProperty().getItem();
                    items.put(item.getProperty().getId(), item);
                }
            }
            if (filteredCheckboxTree != null && !isHadoopClusterNode(repositoryNode)) {
                IContentProvider contentProvider = filteredCheckboxTree.getViewer().getContentProvider();
                if (contentProvider instanceof ITreeContentProvider) {
                    // only check childrens of allowed items in this viewer
                    if (selectRepositoryNode(getItemsTreeViewer(), repositoryNode)) {
                        Object[] children = ((ITreeContentProvider) contentProvider).getChildren(repositoryNode);
                        List<Object> childrenNodes = getUnTestCaseChildren(children);
                        collectNodes(items, childrenNodes.toArray());
                    }
                }
            }
        } else {
            for (IExtendedRepositoryNodeHandler nodeHandler : RepositoryContentManager.getExtendedNodeHandler()) {
                Property property = nodeHandler.getProperty(object);
                if (property != null) {
                    items.put(property.getId(), property.getItem());
                }
            }
        }
    }
}
Also used : Item(org.talend.core.model.properties.Item) TreeItem(org.eclipse.swt.widgets.TreeItem) ITreeContentProvider(org.eclipse.jface.viewers.ITreeContentProvider) IExtendedRepositoryNodeHandler(org.talend.core.model.repository.IExtendedRepositoryNodeHandler) IContentProvider(org.eclipse.jface.viewers.IContentProvider) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) MetadataColumnRepositoryObject(org.talend.core.repository.model.repositoryObject.MetadataColumnRepositoryObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) RepositoryObject(org.talend.core.model.repository.RepositoryObject) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Property(org.talend.core.model.properties.Property)

Example 13 with IContentProvider

use of org.eclipse.jface.viewers.IContentProvider in project tdi-studio-se by Talend.

the class StatusManagerSettingPage method processItems.

private void processItems(List<RepositoryObject> objects, IRepositoryNode node) {
    if (node == null) {
        return;
    }
    // if the root node of type is not init, force init.
    IProjectRepositoryNode root = node.getRoot();
    if (root instanceof ProjectRepositoryNode) {
        ((ProjectRepositoryNode) root).initNode(node);
    }
    if (node.getType() == ENodeType.REPOSITORY_ELEMENT) {
        if (node.getObject() != null) {
            Property property = node.getObject().getProperty();
            Item item = property.getItem();
            if (item != null && filterRepositoryNode((RepositoryNode) node)) {
                // must be item
                RepositoryObject object = new RepositoryObject(node.getObject().getProperty());
                object.setRepositoryNode(node);
                // ItemVersionObject object = new ItemVersionObject(node, property.getVersion());
                objects.add(object);
            }
        }
    } else {
        IContentProvider contentProvider = treeViewer.getContentProvider();
        if (contentProvider instanceof NavigatorContentServiceContentProvider) {
            NavigatorContentServiceContentProvider navigatorProvider = (NavigatorContentServiceContentProvider) contentProvider;
            Object[] children = navigatorProvider.getChildren(node);
            for (Object child : children) {
                if (child instanceof RepositoryNode) {
                    processItems(objects, (RepositoryNode) child);
                }
            }
        } else {
            for (IRepositoryNode child : node.getChildren()) {
                processItems(objects, child);
            }
        }
    }
}
Also used : Item(org.talend.core.model.properties.Item) TableItem(org.eclipse.swt.widgets.TableItem) RepositoryObject(org.talend.core.model.repository.RepositoryObject) IContentProvider(org.eclipse.jface.viewers.IContentProvider) IRepositoryNode(org.talend.repository.model.IRepositoryNode) NavigatorContentServiceContentProvider(org.eclipse.ui.internal.navigator.NavigatorContentServiceContentProvider) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) RepositoryObject(org.talend.core.model.repository.RepositoryObject) ProjectRepositoryNode(org.talend.core.repository.model.ProjectRepositoryNode) RepositoryNode(org.talend.repository.model.RepositoryNode) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode) IRepositoryNode(org.talend.repository.model.IRepositoryNode) Property(org.talend.core.model.properties.Property) IProjectRepositoryNode(org.talend.repository.model.nodes.IProjectRepositoryNode)

Example 14 with IContentProvider

use of org.eclipse.jface.viewers.IContentProvider in project hale by halestudio.

the class PageFunctions method createContents.

/**
 * @see org.eclipse.jface.dialogs.DialogTray#createContents(org.eclipse.swt.widgets.Composite)
 */
@Override
protected Control createContents(Composite parent) {
    Composite comp = new Composite(parent, SWT.NONE);
    GridLayoutFactory.fillDefaults().numColumns(1).applyTo(comp);
    Label label = new Label(comp, SWT.NONE);
    label.setText("Functions Overview");
    label.setFont(JFaceResources.getHeaderFont());
    // tree viwever
    PatternFilter patternFilter = new TreePathPatternFilter();
    patternFilter.setIncludeLeadingWildcard(true);
    final FilteredTree filteredTree = new TreePathFilteredTree(comp, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER, patternFilter, true);
    TreeViewer tree = filteredTree.getViewer();
    tree.setUseHashlookup(true);
    HelperFunctionLabelProvider labelProvider = new HelperFunctionLabelProvider();
    tree.setLabelProvider(labelProvider);
    IContentProvider contentProvider;
    HelperFunctionsService functions = HaleUI.getServiceProvider().getService(HelperFunctionsService.class);
    contentProvider = new TreePathProviderAdapter(new HelperFunctionContentProvider(functions));
    tree.setContentProvider(contentProvider);
    GridDataFactory.fillDefaults().grab(true, true).hint(280, 400).applyTo(filteredTree);
    tree.setComparator(new HelperFunctionComparator());
    tree.setInput(Category.ROOT);
    // Examples
    Label example = new Label(comp, SWT.NONE);
    example.setText("Function documentation");
    try {
        browser = new Browser(comp, SWT.WRAP | SWT.BORDER);
        browser.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(300, 250).create());
    } catch (Throwable e) {
        if (BROWSER_ERROR_REPORTED.compareAndSet(false, true)) {
            log.error("Could not create embedded browser, using text field as fall-back", e);
        }
        textField = new Text(comp, SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
        textField.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).hint(300, 250).create());
    }
    tree.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            String eg = null;
            HelperFunctionSpecification hfs = null;
            if (!event.getSelection().isEmpty()) {
                TreeSelection treesel = (TreeSelection) event.getSelection();
                TreePath[] paths = treesel.getPaths();
                if (paths != null) {
                    TreePath path = paths[0];
                    for (int i = 0; i < path.getSegmentCount(); i++) {
                        if (path.getSegment(i) instanceof Category) {
                            eg = "Select a function to see its documentation.";
                            if (browser != null) {
                                browser.setText(eg);
                            } else if (textField != null) {
                                textField.setText(eg);
                            }
                        } else if (path.getSegment(i) instanceof HelperFunctionOrCategory) {
                            HelperFunctionOrCategory hfoc = ((HelperFunctionOrCategory) path.getSegment(i));
                            try {
                                hfs = (HelperFunctionSpecification) hfoc.asFunction().getSpec(hfoc.getName());
                            } catch (Exception e) {
                                log.error("There is a problem in retrieving the specification for a helper function.", e);
                            }
                            // displaying the specification
                            if (browser != null) {
                                eg = getFunctionSpecHTML(hfs);
                                browser.setText(eg);
                            } else if (textField != null) {
                                eg = getFunctionSpecText(hfs);
                                textField.setText(eg);
                            }
                        }
                    }
                }
            }
        }
    });
    return comp;
}
Also used : HelperFunctionOrCategory(eu.esdihumboldt.cst.functions.groovy.helper.HelperFunctionOrCategory) TreePathPatternFilter(eu.esdihumboldt.hale.ui.util.viewer.tree.TreePathPatternFilter) PatternFilter(org.eclipse.ui.dialogs.PatternFilter) HelperFunctionsService(eu.esdihumboldt.cst.functions.groovy.helper.HelperFunctionsService) Category(eu.esdihumboldt.cst.functions.groovy.helper.Category) HelperFunctionOrCategory(eu.esdihumboldt.cst.functions.groovy.helper.HelperFunctionOrCategory) IContentProvider(org.eclipse.jface.viewers.IContentProvider) TreePathFilteredTree(eu.esdihumboldt.hale.ui.util.viewer.tree.TreePathFilteredTree) TreeViewer(org.eclipse.jface.viewers.TreeViewer) Label(org.eclipse.swt.widgets.Label) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) FilteredTree(org.eclipse.ui.dialogs.FilteredTree) TreePathFilteredTree(eu.esdihumboldt.hale.ui.util.viewer.tree.TreePathFilteredTree) StyledString(org.eclipse.jface.viewers.StyledString) TreePathPatternFilter(eu.esdihumboldt.hale.ui.util.viewer.tree.TreePathPatternFilter) TreeSelection(org.eclipse.jface.viewers.TreeSelection) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Text(org.eclipse.swt.widgets.Text) TreePathProviderAdapter(eu.esdihumboldt.hale.ui.util.viewer.tree.TreePathProviderAdapter) TreePath(org.eclipse.jface.viewers.TreePath) HelperFunctionSpecification(eu.esdihumboldt.cst.functions.groovy.helper.spec.impl.HelperFunctionSpecification) Browser(org.eclipse.swt.browser.Browser)

Example 15 with IContentProvider

use of org.eclipse.jface.viewers.IContentProvider in project linuxtools by eclipse.

the class AbstractSTViewer method init.

/*
     * Initializes this view with the given view site. A memento is passed to the view which contains a snapshot of the
     * views state from a previous session. Where possible, the view should try to recreate that state within the part
     * controls. <p> This implementation will ignore the memento and initialize the view in a fresh state. Subclasses
     * may override the implementation to perform any state restoration as needed.
     */
/**
 * Initializes the viewers. It sets: the columns of the viewers, a viewer setting (similar to memento) a column
 * manager a viewer comparator ColumnViewerToolTipSupport an OpenListener a KeyListener a PaintListener a
 * DisposeListener the input the content provider
 * @param parent The parent composite.
 * @param style  SWT style to be used.
 */
private void init(Composite parent, int style) {
    viewer = createViewer(parent, style);
    viewerSettings = createSTAbstractDataViewersSettings();
    fields = getAllFields();
    createColumns();
    restoreColumnOrder();
    // building columns manager
    // (needs the columns to be created first)
    STDataViewersHideShowManager manager = new STDataViewersHideShowManager(this);
    manager.restoreState(viewerSettings);
    setHideShowManager(manager);
    // building the column comparator
    // (needs the columns to be created first)
    STDataViewersComparator comparator = new STDataViewersComparator(getColumns());
    comparator.restoreState(viewerSettings);
    setComparator(comparator);
    setSortIndicators();
    IContentProvider cp = createContentProvider();
    viewer.setContentProvider(cp);
    viewer.setUseHashlookup(true);
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
    viewer.getControl().setLayoutData(data);
    viewer.setInput(null);
    ColumnViewerToolTipSupport.enableFor(viewer);
    Scrollable scrollable = (Scrollable) viewer.getControl();
    ScrollBar bar = scrollable.getVerticalBar();
    if (bar != null) {
        bar.setSelection(restoreVerticalScrollBarPosition());
    }
    bar = scrollable.getHorizontalBar();
    if (bar != null) {
        bar.setSelection(restoreHorizontalScrollBarPosition());
    }
    viewer.addOpenListener(event -> handleOpenEvent(event));
    viewer.getControl().addDisposeListener(new STDisposeListener(this));
}
Also used : STDisposeListener(org.eclipse.linuxtools.dataviewers.listeners.STDisposeListener) IContentProvider(org.eclipse.jface.viewers.IContentProvider) GridData(org.eclipse.swt.layout.GridData) Scrollable(org.eclipse.swt.widgets.Scrollable) ScrollBar(org.eclipse.swt.widgets.ScrollBar)

Aggregations

IContentProvider (org.eclipse.jface.viewers.IContentProvider)15 IRepositoryNode (org.talend.repository.model.IRepositoryNode)5 RepositoryNode (org.talend.repository.model.RepositoryNode)5 ITreeContentProvider (org.eclipse.jface.viewers.ITreeContentProvider)4 TreeViewer (org.eclipse.jface.viewers.TreeViewer)4 Item (org.talend.core.model.properties.Item)4 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)4 ProjectRepositoryNode (org.talend.core.repository.model.ProjectRepositoryNode)4 Composite (org.eclipse.swt.widgets.Composite)3 TableItem (org.eclipse.swt.widgets.TableItem)3 TreePathFilteredTree (eu.esdihumboldt.hale.ui.util.viewer.tree.TreePathFilteredTree)2 ArrayList (java.util.ArrayList)2 Property (org.talend.core.model.properties.Property)2 RepositoryObject (org.talend.core.model.repository.RepositoryObject)2 IProjectRepositoryNode (org.talend.repository.model.nodes.IProjectRepositoryNode)2 CubridDeferredTreeContentManager (com.cubrid.common.ui.common.navigator.CubridDeferredTreeContentManager)1 DeferredContentProvider (com.cubrid.common.ui.common.navigator.DeferredContentProvider)1 Category (eu.esdihumboldt.cst.functions.groovy.helper.Category)1 HelperFunctionOrCategory (eu.esdihumboldt.cst.functions.groovy.helper.HelperFunctionOrCategory)1 HelperFunctionsService (eu.esdihumboldt.cst.functions.groovy.helper.HelperFunctionsService)1