KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > cheatsheets > composite > explorer > TreeTaskExplorer


1 /*******************************************************************************
2  * Copyright (c) 2005, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.ui.internal.cheatsheets.composite.explorer;
13
14
15 import org.eclipse.jface.viewers.ISelection;
16 import org.eclipse.jface.viewers.ISelectionProvider;
17 import org.eclipse.jface.viewers.TreeViewer;
18 import org.eclipse.swt.widgets.Composite;
19 import org.eclipse.swt.widgets.Control;
20 import org.eclipse.swt.widgets.Tree;
21 import org.eclipse.ui.forms.widgets.FormToolkit;
22 import org.eclipse.ui.internal.cheatsheets.composite.parser.ICompositeCheatsheetTags;
23 import org.eclipse.ui.internal.provisional.cheatsheets.ICompositeCheatSheet;
24 import org.eclipse.ui.internal.provisional.cheatsheets.ICompositeCheatSheetTask;
25 import org.eclipse.ui.internal.provisional.cheatsheets.TaskExplorer;
26
27 public class TreeTaskExplorer extends TaskExplorer {
28     private TreeViewer viewer;
29
30     
31     public String JavaDoc getId() {
32         return ICompositeCheatsheetTags.TREE;
33     }
34
35     public void createControl(Composite parent, FormToolkit toolkit) {
36         Tree tree = new Tree(parent, toolkit.getOrientation());
37         toolkit.adapt(tree, false, false);
38         viewer = new TreeViewer(tree);
39         viewer.setContentProvider(new TreeContentProvider());
40         viewer.setLabelProvider(new TreeLabelProvider());
41     }
42     
43     public void taskUpdated(ICompositeCheatSheetTask task) {
44         viewer.update(task, null);
45     }
46
47     public Control getControl() {
48         return viewer.getControl();
49     }
50
51     public void setFocus() {
52         viewer.getControl().setFocus();
53     }
54
55     public ISelectionProvider getSelectionProvider() {
56         return viewer;
57     }
58
59     public void setCompositeCheatSheet(ICompositeCheatSheet compositeCheatSheet) {
60         viewer.setInput(compositeCheatSheet);
61     }
62
63     public void dispose() {
64         viewer.getLabelProvider().dispose();
65     }
66
67     public void setSelection(ISelection selection, boolean reveal) {
68         viewer.setSelection(selection, reveal);
69     }
70
71 }
Popular Tags