update copyright
[fedora-idea.git] / plugins / ui-designer / src / com / intellij / uiDesigner / propertyInspector / editors / string / NewKeyDialog.java
blob2838cf1ebdedd399142e3ba97010279948bcb20c
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.editors.string;
18 import com.intellij.openapi.ui.DialogWrapper;
19 import com.intellij.uiDesigner.UIDesignerBundle;
21 import javax.swing.*;
22 import javax.swing.event.DocumentListener;
23 import javax.swing.event.DocumentEvent;
24 import java.awt.*;
26 /**
27 * @author yole
29 public class NewKeyDialog extends DialogWrapper {
30 private JTextField myKeyNameEdit;
31 private JTextField myKeyValueEdit;
32 private JPanel myPanel;
34 public NewKeyDialog(Component parent) {
35 super(parent, true);
36 setTitle(UIDesignerBundle.message("key.chooser.new.property.title"));
37 init();
38 updateButton();
39 myKeyNameEdit.getDocument().addDocumentListener(new DocumentListener() {
40 public void insertUpdate(DocumentEvent e) {
41 updateButton();
44 public void removeUpdate(DocumentEvent e) {
45 updateButton();
48 public void changedUpdate(DocumentEvent e) {
49 updateButton();
51 });
54 private void updateButton() {
55 setOKActionEnabled(myKeyNameEdit.getText().length() > 0);
58 @Override public JComponent getPreferredFocusedComponent() {
59 return myKeyNameEdit;
62 protected JComponent createCenterPanel() {
63 return myPanel;
66 public String getName() {
67 return myKeyNameEdit.getText();
70 public String getValue() {
71 return myKeyValueEdit.getText();