update copyright
[fedora-idea.git] / plugins / properties / src / com / intellij / lang / properties / structureView / PropertiesStructureViewElement.java
blobe46287603f9a82a65635c196790bf1633747f7e1
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.lang.properties.structureView;
18 import com.intellij.ide.structureView.StructureViewTreeElement;
19 import com.intellij.lang.properties.psi.Property;
20 import com.intellij.navigation.ItemPresentation;
21 import com.intellij.navigation.NavigationItem;
22 import com.intellij.openapi.editor.colors.TextAttributesKey;
23 import com.intellij.openapi.util.Iconable;
25 import javax.swing.*;
27 /**
28 * Created by IntelliJ IDEA.
29 * User: max
30 * Date: Feb 10, 2005
31 * Time: 3:26:11 PM
32 * To change this template use File | Settings | File Templates.
34 public class PropertiesStructureViewElement implements StructureViewTreeElement {
35 private final Property myProperty;
36 private String myPresentableName;
38 public PropertiesStructureViewElement(final Property element) {
39 myProperty = element;
42 public Property getValue() {
43 return myProperty;
46 public void navigate(boolean requestFocus) {
47 ((NavigationItem)myProperty).navigate(requestFocus);
50 public boolean canNavigate() {
51 return ((NavigationItem)myProperty).canNavigate();
54 public boolean canNavigateToSource() {
55 return ((NavigationItem)myProperty).canNavigateToSource();
58 public StructureViewTreeElement[] getChildren() {
59 return EMPTY_ARRAY;
62 public ItemPresentation getPresentation() {
63 return new ItemPresentation() {
64 public String getPresentableText() {
65 if (myPresentableName == null) {
66 return myProperty.getUnescapedKey();
68 else {
69 return myPresentableName;
73 public TextAttributesKey getTextAttributesKey() {
74 return null;
77 public String getLocationString() {
78 return null;
81 public Icon getIcon(boolean open) {
82 return myProperty.getIcon(Iconable.ICON_FLAG_OPEN);
87 public void setPresentableName(final String presentableName) {
88 myPresentableName = presentableName;