View Javadoc

1   /*
2    * @(#)$Id: CommandView.java 689 2009-07-22 00:10:27Z bsigner $
3    *
4    * Author       :   Michele Croci, mcroci@gmail.com
5    *
6    * Purpose      :   View for the defined command
7    *
8    * -----------------------------------------------------------------------
9    *
10   * Revision Information:
11   *
12   * Date             Who         Reason
13   *
14   * Dec 11, 2007     crocimi     Initial Release
15   *
16   * -----------------------------------------------------------------------
17   *
18   * Copyright 1999-2009 ETH Zurich. All Rights Reserved.
19   *
20   * This software is the proprietary information of ETH Zurich.
21   * Use is subject to license terms.
22   * 
23   */
24  
25  
26  package org.ximtec.igesture.geco.gui;
27  
28  import java.awt.Color;
29  import java.awt.Dimension;
30  import java.awt.GridBagConstraints;
31  import java.awt.GridBagLayout;
32  import java.awt.GridLayout;
33  import java.awt.Insets;
34  
35  import javax.swing.JPanel;
36  import javax.swing.JScrollPane;
37  import javax.swing.JTextPane;
38  import javax.swing.border.BevelBorder;
39  import javax.swing.border.TitledBorder;
40  
41  import org.ximtec.igesture.geco.util.Constant;
42  
43  
44  /**
45   * View for the defined command
46   * @version 0.9, Dec 11, 2007
47   * @author Michele Croci, mcroci@gmail.com
48   */
49  public class CommandView extends JPanel {
50  
51     private JTextPane textField;
52  
53  
54     public CommandView() {
55        populate();
56        init();
57     }
58  
59  
60     public String getCommand() {
61        return textField.getText();
62     }
63  
64  
65     /**
66      * Update the view
67      * 
68      * @command the current command
69      */
70     public void updateView(String command) {
71        textField.setText(command);
72     }
73  
74  
75     /**
76      * Reset the view.
77      */
78     public void init() {
79        textField.setText(Constant.EMPTY_STRING);
80     }
81  
82  
83     private void populate() {
84        this.setLayout(new GridBagLayout());
85        JPanel aPanel = new JPanel();
86        aPanel.setLayout(new GridLayout());
87        aPanel.setBorder(new TitledBorder(new BevelBorder(0, Color.gray,
88              Color.gray), Constant.COMMAND));
89        textField = new JTextPane();
90        JScrollPane scrollPane = new JScrollPane();
91        scrollPane.getViewport().add(textField);
92        textField.setMaximumSize(new Dimension(300, 200));
93        textField.setBorder(new BevelBorder(0, Color.gray, Color.gray));
94        aPanel.add(scrollPane);
95  
96        this.add(aPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0,
97              GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(40,
98                    20, 40, 20), 0, 0));
99     }
100 
101 }