Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: e490105e4e8f1750b87a679405d8158a357d8904 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*******************************************************************************
 * Copyright (c) 2000, 2006 IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.jface.tests.viewers.interactive;

import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.tests.viewers.TestElement;
import org.eclipse.jface.tests.viewers.TestModelContentProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Composite;

public class TestTree extends TestBrowser {
    TreeViewer<TestElement,TestElement> fViewer;

    Action fExpandAllAction;

    public TestTree() {
        super();
        fExpandAllAction = new ExpandAllAction("Expand All", this);
    }

    /**
     *
     */
    public Viewer<TestElement> createViewer(Composite parent) {
        TreeViewer<TestElement,TestElement> viewer = new TreeViewer<TestElement,TestElement>(parent);
        viewer.setContentProvider(new TestModelContentProvider());
        viewer.setUseHashlookup(true);

        if (fViewer == null)
            fViewer = viewer;
        return viewer;
    }

    public static void main(String[] args) {
        TestBrowser browser = new TestTree();
        if (args.length > 0 && args[0].equals("-twopanes"))
            browser.show2Panes();
        browser.setBlockOnOpen(true);
        browser.open(TestElement.createModel(3, 10));
    }

    public void testTreeFillMenuBar(MenuManager testMenu) {

    }

    /**
     * Adds the expand all action to the tests menu.
     */
    protected void viewerFillMenuBar(MenuManager mgr) {
        MenuManager testMenu = (MenuManager) (mgr.findMenuUsingPath("tests"));
        testMenu.add(new Separator());
        testMenu.add(fExpandAllAction);
    }
}

Back to the top