Example usage for org.eclipse.jface.viewers TreeViewer setContentProvider

List of usage examples for org.eclipse.jface.viewers TreeViewer setContentProvider

Introduction

In this page you can find the example usage for org.eclipse.jface.viewers TreeViewer setContentProvider.

Prototype

@Override
public void setContentProvider(IContentProvider provider) 

Source Link

Document

Sets the content provider used by this TreeViewer.

Usage

From source file:edu.utexas.cs.orc.orceclipse.edit.OrcContentOutlinePage.java

License:Open Source License

/**
 * Creates the SWT control for this page under the given parent control.
 * Here, we configure the superclass-provided tree viewer with a content
 * provider, label provider, and input element.
 *
 * @param parent the parent control//from   w ww. j  a  va2s  . c o m
 */
@Override
public void createControl(final Composite parent) {

    super.createControl(parent);

    final TreeViewer viewer = getTreeViewer();
    viewer.setContentProvider(new OrcContentProvider());
    viewer.setLabelProvider(new OrcLabelProvider());

    viewer.setAutoExpandLevel(2);
}

From source file:es.cv.gvcase.emf.ui.common.composites.SelectModelComposite.java

License:Open Source License

protected TreeViewer createTree(Composite parent) {
    historyTableProvider = new LocalFileHistoryTableProvider();
    TreeViewer viewer = historyTableProvider.createTree(parent);
    Rectangle bounds = viewer.getTree().getBounds();
    // hack to not show horizontal scroll bar
    viewer.getTree().setBounds(bounds.x, bounds.y, 100, bounds.height);
    viewer.setContentProvider(new LocalHistoryContentProvider());
    return viewer;
}

From source file:es.cv.gvcase.emf.ui.common.dialogs.FeatureEditorDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite contents = (Composite) super.createDialogArea(parent);

    GridLayout contentsGridLayout = (GridLayout) contents.getLayout();
    contentsGridLayout.numColumns = 3;/*  www  . j a va2s.  c  o m*/

    GridData contentsGridData = (GridData) contents.getLayoutData();
    contentsGridData.horizontalAlignment = SWT.FILL;
    contentsGridData.verticalAlignment = SWT.FILL;

    Text patternText = null;

    if (choiceOfValues != null) {
        Group filterGroupComposite = new Group(contents, SWT.NONE);
        filterGroupComposite.setText(EMFEditUIPlugin.INSTANCE.getString("_UI_Choices_pattern_group"));
        filterGroupComposite.setLayout(new GridLayout(2, false));
        filterGroupComposite.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false, 3, 1));

        Label label = new Label(filterGroupComposite, SWT.NONE);
        label.setText(EMFEditUIPlugin.INSTANCE.getString("_UI_Choices_pattern_label"));

        patternText = new Text(filterGroupComposite, SWT.BORDER);
        patternText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    }

    Composite choiceComposite = new Composite(contents, SWT.NONE);
    {
        GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
        data.horizontalAlignment = SWT.END;
        choiceComposite.setLayoutData(data);

        GridLayout layout = new GridLayout();
        data.horizontalAlignment = SWT.FILL;
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        layout.numColumns = 1;
        choiceComposite.setLayout(layout);
    }

    Label choiceLabel = new Label(choiceComposite, SWT.NONE);
    choiceLabel.setText(choiceOfValues == null ? EMFEditUIPlugin.INSTANCE.getString("_UI_Value_label")
            : EMFEditUIPlugin.INSTANCE.getString("_UI_Choices_label"));
    GridData choiceLabelGridData = new GridData();
    choiceLabelGridData.verticalAlignment = SWT.FILL;
    choiceLabelGridData.horizontalAlignment = SWT.FILL;
    choiceLabel.setLayoutData(choiceLabelGridData);

    final Tree choiceTree = choiceOfValues == null ? null : new Tree(choiceComposite, SWT.MULTI | SWT.BORDER);
    if (choiceTree != null) {
        GridData choiceTtreeGridData = new GridData();
        choiceTtreeGridData.widthHint = Display.getCurrent().getBounds().width / 5;
        choiceTtreeGridData.heightHint = Display.getCurrent().getBounds().height / 3;
        choiceTtreeGridData.verticalAlignment = SWT.FILL;
        choiceTtreeGridData.horizontalAlignment = SWT.FILL;
        choiceTtreeGridData.grabExcessHorizontalSpace = true;
        choiceTtreeGridData.grabExcessVerticalSpace = true;
        choiceTree.setLayoutData(choiceTtreeGridData);
    }

    final TreeViewer choiceTreeViewer = choiceOfValues == null ? null : new TreeViewer(choiceTree);
    if (choiceTreeViewer != null) {
        choiceTreeViewer.setContentProvider(contentProvider);
        choiceTreeViewer.setLabelProvider(labelProvider);
        final PatternFilter filter = new PatternFilter() {
            @Override
            protected boolean isParentMatch(Viewer viewer, Object element) {
                return viewer instanceof AbstractTreeViewer && super.isParentMatch(viewer, element);
            }
        };
        choiceTreeViewer.addFilter(filter);
        assert patternText != null;
        patternText.addModifyListener(new ModifyListener() {
            public void modifyText(ModifyEvent e) {
                filter.setPattern(((Text) e.widget).getText());
                choiceTreeViewer.refresh();
            }
        });
        choiceTreeViewer.setInput(choiceOfValues);

        choiceTreeViewer.expandToLevel(2);
    }

    // We use multi even for a single line because we want to respond to the
    // enter key.
    //
    int style = multiLine ? SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER : SWT.MULTI | SWT.BORDER;
    final Text choiceText = choiceOfValues == null ? new Text(choiceComposite, style) : null;
    if (choiceText != null) {
        GridData choiceTextGridData = new GridData();
        choiceTextGridData.widthHint = Display.getCurrent().getBounds().width / 5;
        choiceTextGridData.verticalAlignment = SWT.BEGINNING;
        choiceTextGridData.horizontalAlignment = SWT.FILL;
        choiceTextGridData.grabExcessHorizontalSpace = true;
        if (multiLine) {
            choiceTextGridData.verticalAlignment = SWT.FILL;
            choiceTextGridData.grabExcessVerticalSpace = true;
        }
        choiceText.setLayoutData(choiceTextGridData);
    }

    Composite controlButtons = new Composite(contents, SWT.NONE);
    GridData controlButtonsGridData = new GridData();
    controlButtonsGridData.verticalAlignment = SWT.FILL;
    controlButtonsGridData.horizontalAlignment = SWT.FILL;
    controlButtons.setLayoutData(controlButtonsGridData);

    GridLayout controlsButtonGridLayout = new GridLayout();
    controlButtons.setLayout(controlsButtonGridLayout);

    new Label(controlButtons, SWT.NONE);

    final Button addButton = new Button(controlButtons, SWT.PUSH);
    addButton.setText(EMFEditUIPlugin.INSTANCE.getString("_UI_Add_label"));
    GridData addButtonGridData = new GridData();
    addButtonGridData.verticalAlignment = SWT.FILL;
    addButtonGridData.horizontalAlignment = SWT.FILL;
    addButton.setLayoutData(addButtonGridData);

    final Button removeButton = new Button(controlButtons, SWT.PUSH);
    removeButton.setText(EMFEditUIPlugin.INSTANCE.getString("_UI_Remove_label"));
    GridData removeButtonGridData = new GridData();
    removeButtonGridData.verticalAlignment = SWT.FILL;
    removeButtonGridData.horizontalAlignment = SWT.FILL;
    removeButton.setLayoutData(removeButtonGridData);

    Label spaceLabel = new Label(controlButtons, SWT.NONE);
    GridData spaceLabelGridData = new GridData();
    spaceLabelGridData.verticalSpan = 2;
    spaceLabel.setLayoutData(spaceLabelGridData);

    final Button upButton = new Button(controlButtons, SWT.PUSH);
    upButton.setText(EMFEditUIPlugin.INSTANCE.getString("_UI_Up_label"));
    GridData upButtonGridData = new GridData();
    upButtonGridData.verticalAlignment = SWT.FILL;
    upButtonGridData.horizontalAlignment = SWT.FILL;
    upButton.setLayoutData(upButtonGridData);

    final Button downButton = new Button(controlButtons, SWT.PUSH);
    downButton.setText(EMFEditUIPlugin.INSTANCE.getString("_UI_Down_label"));
    GridData downButtonGridData = new GridData();
    downButtonGridData.verticalAlignment = SWT.FILL;
    downButtonGridData.horizontalAlignment = SWT.FILL;
    downButton.setLayoutData(downButtonGridData);

    Composite featureComposite = new Composite(contents, SWT.NONE);
    {
        GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
        data.horizontalAlignment = SWT.END;
        featureComposite.setLayoutData(data);

        GridLayout layout = new GridLayout();
        data.horizontalAlignment = SWT.FILL;
        layout.marginHeight = 0;
        layout.marginWidth = 0;
        layout.numColumns = 1;
        featureComposite.setLayout(layout);
    }

    Label featureLabel = new Label(featureComposite, SWT.NONE);
    featureLabel.setText(EMFEditUIPlugin.INSTANCE.getString("_UI_Feature_label"));
    GridData featureLabelGridData = new GridData();
    featureLabelGridData.horizontalSpan = 2;
    featureLabelGridData.horizontalAlignment = SWT.FILL;
    featureLabelGridData.verticalAlignment = SWT.FILL;
    featureLabel.setLayoutData(featureLabelGridData);

    final Tree featureTree = new Tree(featureComposite, SWT.MULTI | SWT.BORDER);
    GridData featureTreeGridData = new GridData();
    featureTreeGridData.widthHint = Display.getCurrent().getBounds().width / 5;
    featureTreeGridData.heightHint = Display.getCurrent().getBounds().height / 3;
    featureTreeGridData.verticalAlignment = SWT.FILL;
    featureTreeGridData.horizontalAlignment = SWT.FILL;
    featureTreeGridData.grabExcessHorizontalSpace = true;
    featureTreeGridData.grabExcessVerticalSpace = true;
    featureTree.setLayoutData(featureTreeGridData);

    final TreeViewer featureTreeViewer = new TreeViewer(featureTree);
    featureTreeViewer.setContentProvider(contentProvider);
    featureTreeViewer.setLabelProvider(labelProvider);
    if (values != null) {
        featureTreeViewer.setInput(values);
        if (!values.getChildren().isEmpty()) {
            featureTreeViewer.setSelection(new StructuredSelection(values.getChildren().get(0)));
        }
    } else {
        featureTreeViewer.setInput(currentValues);
        if (!currentValues.isEmpty()) {
            featureTreeViewer.setSelection(new StructuredSelection(currentValues.get(0)));
        }
    }
    featureTreeViewer.expandToLevel(2);

    if (choiceTreeViewer != null) {
        choiceTreeViewer.addDoubleClickListener(new IDoubleClickListener() {
            public void doubleClick(DoubleClickEvent event) {
                if (addButton.isEnabled()) {
                    addButton.notifyListeners(SWT.Selection, null);
                }
            }
        });

        featureTreeViewer.addDoubleClickListener(new IDoubleClickListener() {
            public void doubleClick(DoubleClickEvent event) {
                if (removeButton.isEnabled()) {
                    removeButton.notifyListeners(SWT.Selection, null);
                }
            }
        });
    }

    if (choiceText != null) {
        choiceText.addKeyListener(new KeyAdapter() {
            @Override
            public void keyPressed(KeyEvent event) {
                if (!multiLine && (event.character == '\r' || event.character == '\n')) {
                    try {
                        Object value = EcoreUtil.createFromString((EDataType) eClassifier,
                                choiceText.getText());
                        if (values != null) {
                            values.getChildren().add(value);
                        } else {
                            currentValues.add(value);
                        }
                        choiceText.setText("");
                        featureTreeViewer.setSelection(new StructuredSelection(value));
                        event.doit = false;
                    } catch (RuntimeException exception) {
                        // Ignore
                    }
                } else if (event.character == '\33') {
                    choiceText.setText("");
                    event.doit = false;
                }
            }
        });
    }

    upButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            IStructuredSelection selection = (IStructuredSelection) featureTreeViewer.getSelection();
            int minIndex = 0;
            for (Iterator<?> i = selection.iterator(); i.hasNext();) {
                Object value = i.next();
                if (values != null) {
                    int index = values.getChildren().indexOf(value);
                    values.getChildren().move(Math.max(index - 1, minIndex++), value);
                } else {
                    int index = currentValues.indexOf(value);
                    currentValues.remove(value);
                    currentValues.add(Math.max(index - 1, minIndex++), value);
                }
            }
            featureTreeViewer.refresh();
            featureTreeViewer.expandToLevel(2);
            featureTreeViewer.setSelection(selection);
        }
    });

    downButton.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent event) {
            IStructuredSelection selection = (IStructuredSelection) featureTreeViewer.getSelection();
            int maxIndex = 0;
            if (values != null) {
                maxIndex = values.getChildren().size();
            } else {
                maxIndex = currentValues.size();
            }
            maxIndex = maxIndex - selection.size();
            for (Iterator<?> i = selection.iterator(); i.hasNext();) {
                Object value = i.next();
                if (values != null) {
                    int index = values.getChildren().indexOf(value);
                    values.getChildren().move(Math.min(index + 1, maxIndex++), value);
                } else {
                    int index = currentValues.indexOf(value);
                    currentValues.remove(value);
                    currentValues.add(Math.min(index + 1, maxIndex++), value);
                }
            }
            featureTreeViewer.refresh();
            featureTreeViewer.expandToLevel(2);
            featureTreeViewer.setSelection(selection);
        }
    });

    addButton.addSelectionListener(new SelectionAdapter() {
        // event is null when choiceTableViewer is double clicked
        @Override
        public void widgetSelected(SelectionEvent event) {
            if (choiceTreeViewer != null) {
                IStructuredSelection selection = (IStructuredSelection) choiceTreeViewer.getSelection();
                for (Iterator<?> i = selection.iterator(); i.hasNext();) {
                    Object value = i.next();
                    if (!eClassifier.isInstance(value)) {
                        continue;
                    }
                    if (values != null) {
                        if (!values.getChildren().contains(value)) {
                            values.getChildren().add(value);
                        }
                    } else {
                        if (!currentValues.contains(value)) {
                            currentValues.add(value);
                        }
                    }
                }
                featureTreeViewer.refresh();
                featureTreeViewer.expandToLevel(2);
                featureTreeViewer.setSelection(selection);
            } else if (choiceText != null) {
                try {
                    Object value = EcoreUtil.createFromString((EDataType) eClassifier, choiceText.getText());
                    if (values != null) {
                        values.getChildren().add(value);
                    } else {
                        currentValues.add(value);
                    }
                    choiceText.setText("");
                    featureTreeViewer.refresh(value);
                    featureTreeViewer.setSelection(new StructuredSelection(value));
                } catch (RuntimeException exception) {
                    // Ignore
                }
            }
        }
    });

    removeButton.addSelectionListener(new SelectionAdapter() {
        // event is null when featureTableViewer is double clicked
        @Override
        public void widgetSelected(SelectionEvent event) {
            IStructuredSelection selection = (IStructuredSelection) featureTreeViewer.getSelection();
            Object firstValue = null;
            for (Iterator<?> i = selection.iterator(); i.hasNext();) {
                Object value = i.next();
                if (!eClassifier.isInstance(value)) {
                    continue;
                }
                if (firstValue == null) {
                    firstValue = value;
                }
                if (values != null) {
                    values.getChildren().remove(value);
                } else {
                    currentValues.remove(value);
                }
            }

            if (values != null) {
                if (!values.getChildren().isEmpty()) {
                    featureTreeViewer.setSelection(new StructuredSelection(values.getChildren().get(0)));
                }
            } else {
                if (!currentValues.isEmpty()) {
                    featureTreeViewer.setSelection(new StructuredSelection(currentValues.get(0)));
                }
            }

            if (choiceTreeViewer != null) {
                choiceTreeViewer.refresh();
                choiceTreeViewer.expandToLevel(2);
                featureTreeViewer.refresh();
                featureTreeViewer.expandToLevel(2);
                choiceTreeViewer.setSelection(selection);
            } else if (choiceText != null) {
                if (firstValue != null) {
                    String value = EcoreUtil.convertToString((EDataType) eClassifier, firstValue);
                    choiceText.setText(value);
                }
            }
        }
    });

    return contents;
}

From source file:es.cv.gvcase.ide.navigator.search.iu.pages.ElementInDiagramSearchResultPage.java

License:Open Source License

@Override
protected void configureTreeViewer(TreeViewer viewer) {
    viewer.setLabelProvider(searchResultLabelProvider);
    viewer.setContentProvider(searchResultItemProvider);
}

From source file:es.cv.gvcase.mdt.common.part.SelectModelElementsForDiagramDialog.java

License:Open Source License

/**
 * Creates the tree selector.//from  w  w  w. j av a  2 s . c o m
 * 
 * @param parent
 *            the parent
 */
private void createTreeSelector(Composite parent) {
    Tree tree = new Tree(parent, SWT.CHECK | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
    TreeViewer treeViewer = new TreeViewer(tree);
    GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
    data.heightHint = 300;
    data.widthHint = 300;
    tree.setLayoutData(data);
    selectionTree = treeViewer;

    treeViewer.setContentProvider(contentProvider);
    treeViewer.setLabelProvider(labelProvider);

    tree.addSelectionListener(new SelectionListener() {
        public void widgetDefaultSelected(SelectionEvent e) {
            return;
        }

        public void widgetSelected(SelectionEvent e) {
            treeSelectionChanged(e);
        }
    });
}

From source file:es.sidelab.pascaline.debug.ui.views.variables.FilteredVariablesView.java

License:Open Source License

/**
 * @param sashForm/*from   w w  w . java  2  s .c o m*/
 * @return
 */
private TreeViewer createTreeViewer(Composite parent) {
    Tree tree = new Tree(parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    TreeViewer treeViewer = new TreeViewer(tree);
    tree.setHeaderVisible(true);
    tree.setLinesVisible(true);

    // set the column headers implement this
    createTreeColumns(tree);

    // set the content and label providers
    treeViewer.setContentProvider(getContentProvider());
    treeViewer.setLabelProvider(getLabelProvider());

    // using internal hash table speeds the lookup
    treeViewer.setUseHashlookup(true);

    // layout the table tree viewer
    GridData layoutData = new GridData();
    layoutData.grabExcessHorizontalSpace = true;
    layoutData.grabExcessVerticalSpace = true;
    layoutData.horizontalAlignment = GridData.FILL;
    layoutData.verticalAlignment = GridData.FILL;
    layoutData.horizontalSpan = 1;
    treeViewer.getControl().setLayoutData(layoutData);

    // have a way to get the column names
    treeViewer.setColumnProperties(getColumnNames());

    treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            ISelection selection = event.getSelection();
            if (selection instanceof IStructuredSelection) {
                Object o = ((IStructuredSelection) selection).getFirstElement();
            }
        }
    });

    DebugUITools.getDebugContextManager().getContextService(getSite().getWorkbenchWindow())
            .addDebugContextListener(this);

    return treeViewer;
}

From source file:eu.aniketos.wp1.ststool.analysis.ui.ResultViewDataProvider.java

License:Open Source License

public ResultViewDataProvider(final TreeViewer treeViewer, TreeViewerColumn treeViewerColumn,
        TreeViewerColumn treeViewerColumn2, Label statusLabel) {
    this.treeViewer = treeViewer;
    this.statusLabel = statusLabel;
    treeViewer.getTree().addDisposeListener(this);
    ColumnViewerToolTipSupport.enableFor(treeViewer);
    treeViewer.setContentProvider(new ListTreeNodeContentProvider());
    treeViewerColumn.setLabelProvider(new ResultLabelProviderWithToolTip());
    treeViewerColumn2.setLabelProvider(new ResultLabelProviderWithToolTip2());
    //treeViewer.addSelectionChangedListener(this);
    treeViewer.addOpenListener(this);

    rm.addAnalysisResultListener(this);
    DiagramObserver.addDiagramObserverListener(this);
    resultsChanged(rm);//from w  w  w .  ja  va  2s  .c  om

    final Tree tree = treeViewer.getTree();
    tree.addListener(SWT.EraseItem, new Listener() {

        public void handleEvent(Event event) {
            event.detail &= ~SWT.FOREGROUND;
        }
    });

    tree.addListener(SWT.PaintItem, new Listener() {

        Map<Image, Image> grayedimage = new HashMap<Image, Image>();

        public void handleEvent(Event event) {

            TreeItem item = (TreeItem) event.item;
            String text = item.getText(event.index);
            Image img = item.getImage();

            if (((TreeNode) item.getData()).isEnabled()) {
                event.gc.setForeground(item.getForeground(event.index));
            } else {
                if (!grayedimage.containsKey(img)) {
                    grayedimage.put(img, new Image(null, img, SWT.IMAGE_GRAY));
                }
                img = grayedimage.get(img);
                event.gc.setForeground(ColorConstants.gray);
            }

            int xOffset = 3;
            if (img != null && event.index == 0) {
                int yOffset = Math.max(0, (event.height - img.getImageData().height) / 2);
                event.gc.drawImage(img, event.x + xOffset, event.y + yOffset);
                xOffset += img.getImageData().width;
            }

            int yOffset = 0;
            Point size = event.gc.textExtent(text);
            yOffset = Math.max(0, (event.height - size.y) / 2);
            event.gc.drawText(text, event.x + xOffset + 3, event.y + yOffset, true);
        }
    });
}

From source file:eu.artist.migration.cloudselection.ui.views.GenericView.java

License:Open Source License

public void createPartControl(Composite parent) {
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;/*from  w ww  .java 2 s.  c o m*/
    layout.verticalSpacing = 2;
    layout.marginWidth = 0;
    layout.marginHeight = 2;
    parent.setLayout(layout);

    // layout the text field above the treeview
    GridData layoutData = new GridData();
    layoutData.grabExcessHorizontalSpace = true;
    layoutData.horizontalAlignment = GridData.FILL;

    // Create the tree viewer as a child of the composite parent
    TreeViewer treeViewer = new TreeViewer(parent);
    contentProv = new ViewContentProvider();
    treeViewer.setContentProvider(contentProv);
    treeViewer.setLabelProvider(new ViewLabelProvider());
    treeViewer.setUseHashlookup(true);

    // layout the tree viewer below the text field
    layoutData = new GridData();
    layoutData.grabExcessHorizontalSpace = true;
    layoutData.grabExcessVerticalSpace = true;
    layoutData.horizontalAlignment = GridData.FILL;
    layoutData.verticalAlignment = GridData.FILL;
    treeViewer.getControl().setLayoutData(layoutData);
    final Tree t = treeViewer.getTree();
    contentProv.setViewer(treeViewer);
    t.addMouseListener(new MouseListener() {

        @Override
        public void mouseDown(MouseEvent e) {
            for (TreeItem item : t.getSelection()) {
                /*if((e.x > item.getImageBounds(0).x) && (e.x < (item.getImageBounds(0).x + item.getImage().getBounds().width))) {
                   if((e.y > item.getImageBounds(0).y) && (e.y < (item.getImageBounds(0).y + item.getImage().getBounds().height))) {
                */ ModelElement clickedElement = (ModelElement) item.getData();
                if (clickedElement instanceof LeafElement) {
                    boolean checked = ((LeafElement) clickedElement).isChecked();
                    setChecked(clickedElement, !checked);
                }
                //   }
                //   }
            }

            contentProv.viewer.refresh();
        }

        @Override
        public void mouseUp(MouseEvent e) {
        }

        public void mouseDoubleClick(MouseEvent arg0) {
            // TODO Auto-generated method stub

        }

    });
    if (!Resources.isCoreLoaded()) {
        Resources.loadCoreResource();
    }
    contentProv.viewer.setInput(getInitalInput());
    contentProv.viewer.expandAll();
    contentProv.viewer.refresh();
    makeActions();
    contributeToActionBars();
}

From source file:eu.esdihumboldt.hale.ui.codelist.inspire.internal.CodeListSelectionDialog.java

License:Open Source License

/**
 * @see AbstractViewerSelectionDialog#setupViewer(StructuredViewer, Object)
 *///from  w w w.j  a v a  2s. co m
@Override
protected void setupViewer(final TreeViewer viewer, final CodeListRef initialSelection) {
    viewer.setLabelProvider(new CodeListLabelProvider());
    viewer.setContentProvider(new CodeListContentProvider());

    ProgressMonitorDialog dlg = new ProgressMonitorDialog(getShell());
    final Display display = Display.getCurrent();
    try {
        dlg.run(true, false, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.beginTask("Loading available code lists from INSPIRE registry",
                        IProgressMonitor.UNKNOWN);

                final Collection<CodeListRef> codeLists = RegistryCodeLists.loadCodeLists().values();

                display.asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        viewer.setInput(codeLists);

                        if (initialSelection != null) {
                            viewer.setSelection(new StructuredSelection(initialSelection));
                        }
                    }
                });

                monitor.done();
            }
        });
    } catch (InvocationTargetException | InterruptedException e) {
        throw new IllegalStateException("Failed to load code lists", e);
    }
}

From source file:eu.esdihumboldt.hale.ui.common.definition.selector.PropertyDefinitionDialog.java

License:Open Source License

@Override
protected void setupViewer(TreeViewer viewer, EntityDefinition initialSelection) {
    viewer.setLabelProvider(new DefinitionLabelProvider());
    viewer.setContentProvider(new TreePathProviderAdapter(new TypePropertyContentProvider(viewer)));

    viewer.setInput(parentType);/*from  ww  w  .ja  v a2s  .  c  om*/

    if (initialSelection != null) {
        viewer.setSelection(new StructuredSelection(initialSelection));
    }
}