update copyright
[fedora-idea.git] / plugins / ui-designer / src / com / intellij / uiDesigner / propertyInspector / properties / IntroIntProperty.java
blob51d435901cabc2bda45de74b93c9b5e0880d67f5
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.uiDesigner.propertyInspector.properties;
18 import com.intellij.uiDesigner.propertyInspector.IntrospectedProperty;
19 import com.intellij.uiDesigner.propertyInspector.PropertyEditor;
20 import com.intellij.uiDesigner.propertyInspector.PropertyRenderer;
21 import com.intellij.uiDesigner.propertyInspector.editors.IntEditor;
22 import com.intellij.uiDesigner.propertyInspector.renderers.LabelPropertyRenderer;
23 import com.intellij.uiDesigner.snapShooter.SnapshotContext;
24 import com.intellij.uiDesigner.radComponents.RadComponent;
25 import com.intellij.uiDesigner.SwingProperties;
26 import org.jetbrains.annotations.NotNull;
28 import javax.swing.*;
29 import java.lang.reflect.Method;
31 /**
32 * @author Anton Katilin
33 * @author Vladimir Kondratyev
35 public final class IntroIntProperty extends IntrospectedProperty<Integer> {
36 private PropertyRenderer<Integer> myRenderer;
37 private PropertyEditor<Integer> myEditor;
39 public IntroIntProperty(final String name, final Method readMethod, final Method writeMethod, final boolean storeAsClient) {
40 this(name, readMethod, writeMethod, null, null, storeAsClient);
43 public IntroIntProperty(final String name,
44 final Method readMethod,
45 final Method writeMethod,
46 final PropertyRenderer<Integer> renderer,
47 final PropertyEditor<Integer> editor,
48 final boolean storeAsClient){
49 super(name, readMethod, writeMethod, storeAsClient);
50 myRenderer = renderer;
51 myEditor = editor;
54 @NotNull
55 public PropertyRenderer<Integer> getRenderer() {
56 if (myRenderer == null) {
57 myRenderer = new LabelPropertyRenderer<Integer>();
59 return myRenderer;
62 public PropertyEditor<Integer> getEditor() {
63 if (myEditor == null) {
64 myEditor = new IntEditor(Integer.MIN_VALUE);
66 return myEditor;
69 @Override
70 public void importSnapshotValue(final SnapshotContext context, final JComponent component, final RadComponent radComponent) {
71 // exclude property from snapshot import to avoid exceptions because of not imported model
72 if (!getName().equals(SwingProperties.SELECTED_INDEX)) {
73 super.importSnapshotValue(context, component, radComponent);