| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| UrumaTreeViewer |
|
| 1.0;1 |
| 1 | /* | |
| 2 | * Copyright 2004-2008 the Seasar Foundation and the Others. | |
| 3 | * | |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | * you may not use this file except in compliance with the License. | |
| 6 | * You may obtain a copy of the License at | |
| 7 | * | |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | * | |
| 10 | * Unless required by applicable law or agreed to in writing, software | |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | |
| 13 | * either express or implied. See the License for the specific language | |
| 14 | * governing permissions and limitations under the License. | |
| 15 | */ | |
| 16 | package org.seasar.uruma.viewer; | |
| 17 | ||
| 18 | import org.eclipse.jface.viewers.DoubleClickEvent; | |
| 19 | import org.eclipse.jface.viewers.IDoubleClickListener; | |
| 20 | import org.eclipse.jface.viewers.IStructuredSelection; | |
| 21 | import org.eclipse.jface.viewers.TreeViewer; | |
| 22 | import org.eclipse.swt.widgets.Composite; | |
| 23 | import org.eclipse.swt.widgets.Tree; | |
| 24 | ||
| 25 | /** | |
| 26 | * 機能拡張した {@link TreeViewer} です。<br /> | |
| 27 | * | |
| 28 | * @author y-komori | |
| 29 | */ | |
| 30 | public class UrumaTreeViewer extends TreeViewer implements IDoubleClickListener { | |
| 31 | ||
| 32 | /** | |
| 33 | * {@link UrumaTreeViewer} を構築します。<br /> | |
| 34 | * | |
| 35 | * @param parent | |
| 36 | * 親 {@link Composite} | |
| 37 | */ | |
| 38 | public UrumaTreeViewer(final Composite parent) { | |
| 39 | 0 | super(parent); |
| 40 | 0 | init(); |
| 41 | 0 | } |
| 42 | ||
| 43 | /** | |
| 44 | * {@link UrumaTreeViewer} を構築します。<br /> | |
| 45 | * | |
| 46 | * @param parent | |
| 47 | * 親 {@link Composite} | |
| 48 | * @param style | |
| 49 | * スタイル値 | |
| 50 | */ | |
| 51 | public UrumaTreeViewer(final Composite parent, final int style) { | |
| 52 | 4 | super(parent, style); |
| 53 | 4 | init(); |
| 54 | 4 | } |
| 55 | ||
| 56 | /** | |
| 57 | * {@link UrumaTreeViewer} を構築します。<br /> | |
| 58 | * | |
| 59 | * @param tree | |
| 60 | * {@link Tree} オブジェクト | |
| 61 | */ | |
| 62 | public UrumaTreeViewer(final Tree tree) { | |
| 63 | 0 | super(tree); |
| 64 | 0 | init(); |
| 65 | 0 | } |
| 66 | ||
| 67 | protected void init() { | |
| 68 | 4 | addDoubleClickListener(this); |
| 69 | 4 | } |
| 70 | ||
| 71 | /* | |
| 72 | * @see org.eclipse.jface.viewers.IDoubleClickListener#doubleClick(org.eclipse.jface.viewers.DoubleClickEvent) | |
| 73 | */ | |
| 74 | public void doubleClick(final DoubleClickEvent event) { | |
| 75 | 0 | IStructuredSelection selection = (IStructuredSelection) event |
| 76 | .getSelection(); | |
| 77 | 0 | Object selected = selection.getFirstElement(); |
| 78 | ||
| 79 | // ノードの展開状態を反転させる | |
| 80 | 0 | boolean expandedState = getExpandedState(selected); |
| 81 | 0 | setExpandedState(selected, !expandedState); |
| 82 | 0 | } |
| 83 | } |