~ubuntu-branches/debian/sid/geogebra/sid

« back to all changes in this revision

Viewing changes to geogebra/cas/view/CASInputPanel.java

  • Committer: Package Import Robot
  • Author(s): Giovanni Mascellani
  • Date: 2012-01-10 11:37:41 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120110113741-satwohsd4de4ite1
Tags: 4.0.19.0+dfsg1-1
* New upstream version (closes: #649893).
* Update dependency: icedtea-plugin -> icedtea-netx-common (LP: #893007).
* New thumbnailer configuration compatible with Gnome 3.
* Package building is now managed by javahelper instead of upstream
  build.xml.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * This panel is for the input.
 
3
 */
 
4
 
 
5
package geogebra.cas.view;
 
6
 
 
7
import geogebra.gui.inputfield.AutoCompleteTextField;
 
8
import geogebra.main.Application;
 
9
 
 
10
import java.awt.BorderLayout;
 
11
import java.awt.Color;
 
12
import java.awt.Component;
 
13
import java.awt.Font;
 
14
import java.awt.KeyboardFocusManager;
 
15
import java.awt.event.FocusEvent;
 
16
import java.awt.event.FocusListener;
 
17
import java.beans.PropertyChangeEvent;
 
18
import java.beans.PropertyChangeListener;
 
19
 
 
20
import javax.swing.BorderFactory;
 
21
import javax.swing.JButton;
 
22
import javax.swing.JPanel;
 
23
import javax.swing.JTextField;
 
24
import javax.swing.text.JTextComponent;
 
25
 
 
26
public class CASInputPanel extends JPanel {
 
27
 
 
28
        private AutoCompleteTextField inputArea;
 
29
        
 
30
        private Application app;
 
31
        
 
32
        public CASInputPanel(Application app) {
 
33
                this.app = app;
 
34
                
 
35
                setBackground(Color.white);
 
36
                setLayout(new BorderLayout(0,0));
 
37
                
 
38
                // use autocomplete text field from input bar 
 
39
                // but ignore Escape, Up, Down keys
 
40
                inputArea = new AutoCompleteTextField(1, app, false, app.getCommandDictionaryCAS());
 
41
                inputArea.setCASInput(true);
 
42
                inputArea.setAutoComplete(true);
 
43
                inputArea.showPopupSymbolButton(true);
 
44
                inputArea.setBorder(BorderFactory.createEmptyBorder());                                         
 
45
                add(inputArea, BorderLayout.CENTER);
 
46
                
 
47
        
 
48
//              inputArea.addFocusListener(new FocusListener() {
 
49
//
 
50
//                      public void focusGained(FocusEvent e) {
 
51
////                            String text = inputArea.getText();
 
52
////                            int pos = text != null ? text.length() : 0;
 
53
////                            inputArea.setCaretPosition(pos);
 
54
////                            inputArea.setSelectionStart(pos);
 
55
////                            inputArea.setSelectionEnd(pos);
 
56
//                              
 
57
//                              System.out.println("inputArea focus GAINED: " + e);
 
58
//                      }
 
59
//
 
60
//                      public void focusLost(FocusEvent e) {
 
61
//                              //System.out.println("inputArea focus LOST: " + e);     
 
62
//                              Application.printStacktrace("inputArea focus LOST: " + e);
 
63
//                      }
 
64
//                      
 
65
//              });
 
66
                
 
67
//              KeyboardFocusManager focusManager =
 
68
//                  KeyboardFocusManager.getCurrentKeyboardFocusManager();
 
69
//              focusManager.addPropertyChangeListener(
 
70
//                  new PropertyChangeListener() {
 
71
//                      public void propertyChange(PropertyChangeEvent e) {
 
72
//                                System.out.println(e.getPropertyName() + ": old: " + e.getOldValue() + ", new: "+ e.getNewValue() + ", source: " + e.getSource());
 
73
//                                
 
74
//                                if (e.getNewValue() instanceof JButton) {
 
75
//                                        JButton bt = (JButton) e.getNewValue();
 
76
//                                        System.out.println("BUTTON: " + bt.getText() + ", " + bt.getToolTipText());
 
77
//                                }
 
78
//                                
 
79
////                        String prop = e.getPropertyName();
 
80
////                        if (("focusOwner".equals(prop))) {
 
81
////                            e.get
 
82
////                            Component comp = (Component)e.getNewValue();
 
83
////                            String name = comp.getName();
 
84
////                            System.out.println("focus owner: " + name + ", " + comp);
 
85
////                        }
 
86
//                      }
 
87
//                  }
 
88
//              );
 
89
        }
 
90
 
 
91
        public void setInput(String inValue) {
 
92
                inputArea.setText(inValue);
 
93
        }
 
94
 
 
95
        public String getInput() {
 
96
                return inputArea.getText();
 
97
        }
 
98
 
 
99
        public JTextComponent getInputArea() {
 
100
                return inputArea;
 
101
        }
 
102
 
 
103
        public void setInputAreaFocused() {
 
104
                boolean success = inputArea.requestFocusInWindow();
 
105
        }
 
106
 
 
107
        final public void setFont(Font ft) {
 
108
                super.setFont(ft);
 
109
 
 
110
                if (inputArea != null)
 
111
                        inputArea.setFont(ft);
 
112
        }
 
113
 
 
114
        public void setLabels() {
 
115
                inputArea.setDictionary(app.getCommandDictionaryCAS());
 
116
        }
 
117
        
 
118
}