01: /*******************************************************************************
02: * Copyright (c) 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: ******************************************************************************/package org.eclipse.ui.internal.provisional.views.markers;
11:
12: import org.eclipse.jface.viewers.TreeViewer;
13: import org.eclipse.swt.widgets.Composite;
14: import org.eclipse.swt.widgets.Tree;
15: import org.eclipse.swt.widgets.TreeItem;
16: import org.eclipse.swt.widgets.Widget;
17:
18: /**
19: * The MarkersTreeViewer is a viewer that optimizes the expandToLevel
20: * method.
21: * @since 3.4
22: *
23: */
24:
25: //TODO Delete this class if Bug 201135 is fixed.
26: //https://bugs.eclipse.org/bugs/show_bug.cgi?id=201135
27: public class MarkersTreeViewer extends TreeViewer {
28:
29: /**
30: * Create a new instance of the receiver.
31: * @param parent
32: * @param style
33: */
34: public MarkersTreeViewer(Composite parent, int style) {
35: super (parent, style);
36:
37: }
38:
39: /**
40: * Create a new instance of the receiver.
41: * @param parent
42: */
43: public MarkersTreeViewer(Composite parent) {
44: super (parent);
45: }
46:
47: /**
48: * Create a new instance of the receiver.
49: * @param tree
50: */
51: public MarkersTreeViewer(Tree tree) {
52: super (tree);
53: }
54:
55: /* (non-Javadoc)
56: * @see org.eclipse.jface.viewers.AbstractTreeViewer#expandToLevel(java.lang.Object, int)
57: */
58: public void expandToLevel(Object elementOrTreePath, int level) {
59: if (level == 1) {
60: Widget widget = findItem(elementOrTreePath);
61: if (widget != null && widget instanceof TreeItem) {
62: ((TreeItem) widget).setExpanded(true);
63: return;
64: }
65: }
66: super.expandToLevel(elementOrTreePath, level);
67: }
68:
69: }
|