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
.uiDesigner
.inspections
;
18 import com
.intellij
.openapi
.module
.Module
;
19 import com
.intellij
.openapi
.util
.NotNullLazyValue
;
20 import com
.intellij
.uiDesigner
.lw
.*;
21 import com
.intellij
.uiDesigner
.propertyInspector
.properties
.BorderProperty
;
22 import org
.jetbrains
.annotations
.NonNls
;
23 import org
.jetbrains
.annotations
.NotNull
;
28 public abstract class StringDescriptorInspection
extends BaseFormInspection
{
29 private static final NotNullLazyValue
<BorderProperty
> myBorderProperty
= new NotNullLazyValue
<BorderProperty
>() {
32 protected BorderProperty
compute() {
33 return new BorderProperty(null);
37 public StringDescriptorInspection(@NonNls String inspectionKey
) {
41 protected void checkComponentProperties(Module module
, IComponent component
, FormErrorCollector collector
) {
42 for(IProperty prop
: component
.getModifiedProperties()) {
43 Object propValue
= prop
.getPropertyValue(component
);
44 if (propValue
instanceof StringDescriptor
) {
45 StringDescriptor descriptor
= (StringDescriptor
) propValue
;
46 checkStringDescriptor(module
, component
, prop
, descriptor
, collector
);
50 if (component
instanceof IContainer
) {
51 IContainer container
= (IContainer
) component
;
52 StringDescriptor descriptor
= container
.getBorderTitle();
53 if (descriptor
!= null) {
54 checkStringDescriptor(module
, component
, myBorderProperty
.getValue(), descriptor
, collector
);
58 if (component
.getParentContainer() instanceof ITabbedPane
) {
59 ITabbedPane parentTabbedPane
= (ITabbedPane
) component
.getParentContainer();
60 StringDescriptor descriptor
= parentTabbedPane
.getTabProperty(component
, ITabbedPane
.TAB_TITLE_PROPERTY
);
61 if (descriptor
!= null) {
62 checkStringDescriptor(module
, component
, MockTabTitleProperty
.INSTANCE
, descriptor
, collector
);
64 descriptor
= parentTabbedPane
.getTabProperty(component
, ITabbedPane
.TAB_TOOLTIP_PROPERTY
);
65 if (descriptor
!= null) {
66 checkStringDescriptor(module
, component
, MockTabToolTipProperty
.INSTANCE
, descriptor
, collector
);
71 protected abstract void checkStringDescriptor(final Module module
,
72 final IComponent component
,
74 final StringDescriptor descriptor
,
75 final FormErrorCollector collector
);
77 private static class MockTabTitleProperty
implements IProperty
{
78 public static MockTabTitleProperty INSTANCE
= new MockTabTitleProperty();
80 public String
getName() {
81 return ITabbedPane
.TAB_TITLE_PROPERTY
;
84 public Object
getPropertyValue(final IComponent component
) {
89 private static class MockTabToolTipProperty
implements IProperty
{
90 public static MockTabToolTipProperty INSTANCE
= new MockTabToolTipProperty();
92 public String
getName() {
93 return ITabbedPane
.TAB_TOOLTIP_PROPERTY
;
96 public Object
getPropertyValue(final IComponent component
) {