Thread: [Bprocessor-commit] gui/src/net/sourceforge/bprocessor/gui/attrview MyFocusListener.java,NONE,1.1 At
Status: Pre-Alpha
Brought to you by:
henryml
From: Nikolaj B. <nbr...@us...> - 2006-01-13 09:29:38
|
Update of /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6919/src/net/sourceforge/bprocessor/gui/attrview Modified Files: AttributeView.java MyKeyListener.java Added Files: MyFocusListener.java Log Message: Added textarea to the attribute view of spaces, so its no possible to make a description. --- NEW FILE: MyFocusListener.java --- //--------------------------------------------------------------------------------- // $Id: MyFocusListener.java,v 1.1 2006/01/13 09:29:29 nbramsen Exp $ // // Copyright (c) 2005 The BProcessor Team (http://bprocessor.sourceforge.net) // Released under the Lesser GNU Public License v2.1 //--------------------------------------------------------------------------------- package net.sourceforge.bprocessor.gui.attrview; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import javax.swing.text.JTextComponent; import net.sourceforge.bprocessor.model.Space; /** * The focus handler */ public class MyFocusListener implements FocusListener { /** The current space */ private Space current; /** * The constructor * @param o the event */ public MyFocusListener (Space o) { current = o; } /** * Handles the focus gained event * @param arg0 the event */ public void focusGained(FocusEvent arg0) { // TODO Auto-generated method stub } /** * Handles the focus lost event * @param arg0 the event */ public void focusLost(FocusEvent arg0) { JTextComponent tf = (JTextComponent)arg0.getSource(); String newDes = tf.getText(); current.setDescription(newDes); current.changed(); } } Index: MyKeyListener.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview/MyKeyListener.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** MyKeyListener.java 4 Jan 2006 14:29:55 -0000 1.3 --- MyKeyListener.java 13 Jan 2006 09:29:29 -0000 1.4 *************** *** 17,21 **** */ public class MyKeyListener implements KeyListener { ! /** The current ConstructionSpace */ private Space cons; --- 17,27 ---- */ public class MyKeyListener implements KeyListener { ! ! /** If its a textfield */ ! public static final String TFIELD = "Textfield"; ! ! /** If its a textfield */ ! public static final String TAREA = "Textarea"; ! /** The current ConstructionSpace */ private Space cons; *************** *** 26,36 **** /** The current Object */ private Object current; /** * The constructor * @param o the event */ ! public MyKeyListener (Object o) { current = o; } --- 32,47 ---- /** The current Object */ private Object current; + + /** The type of component */ + private String type; /** * The constructor * @param o the event + * @param type shows the type of the component the listeners listens too. */ ! public MyKeyListener (Object o, String type) { current = o; + this.type = type; } *************** *** 40,43 **** --- 51,55 ---- */ public void keyTyped(KeyEvent e) { + } *************** *** 50,54 **** /** ! * Handles focus event * @param e the event */ --- 62,66 ---- /** ! * Handles the keypressed event * @param e the event */ *************** *** 56,75 **** int keyPressed = e.getKeyCode(); if (keyPressed == KeyEvent.VK_ENTER) { ! JTextComponent tf = (JTextComponent)e.getSource(); ! String newName = tf.getText(); ! if (current instanceof Space) { ! Space space = (Space) current; ! if (space.isFunctionalSpace()) { ! funs = space; ! funs.setName(newName); ! funs.changed(); ! } ! if (space.isConstructionSpace()) { ! cons = space; ! cons.setName(newName); ! cons.changed(); ! } } - } } --- 68,88 ---- int keyPressed = e.getKeyCode(); if (keyPressed == KeyEvent.VK_ENTER) { ! if (type == TFIELD) { ! JTextComponent tf = (JTextComponent)e.getSource(); ! String newName = tf.getText(); ! if (current instanceof Space) { ! Space space = (Space) current; ! if (space.isFunctionalSpace()) { ! funs = space; ! funs.setName(newName); ! funs.changed(); ! } ! if (space.isConstructionSpace()) { ! cons = space; ! cons.setName(newName); ! cons.changed(); ! } ! } } } } Index: AttributeView.java =================================================================== RCS file: /cvsroot/bprocessor/gui/src/net/sourceforge/bprocessor/gui/attrview/AttributeView.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** AttributeView.java 10 Jan 2006 14:02:21 -0000 1.17 --- AttributeView.java 13 Jan 2006 09:29:29 -0000 1.18 *************** *** 25,28 **** --- 25,29 ---- import javax.swing.JPanel; import javax.swing.JTabbedPane; + import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.JComboBox; *************** *** 91,94 **** --- 92,101 ---- private Object current; + /** If its a textfield */ + public static final String TFIELD = "Textfield"; + + /** If its a textfield */ + public static final String TAREA = "Textarea"; + /** * Constructor *************** *** 120,124 **** layout.setConstraints(nameEdit, con); add(nameEdit); ! nameEdit.addKeyListener(new MyKeyListener(o)); Object[] options = {"Arbejdsværelse", "Badeværelse", "Gang", "Køkken", "Stue", "Værelse"}; --- 127,131 ---- layout.setConstraints(nameEdit, con); add(nameEdit); ! nameEdit.addKeyListener(new MyKeyListener(o, TFIELD)); Object[] options = {"Arbejdsværelse", "Badeværelse", "Gang", "Køkken", "Stue", "Værelse"}; *************** *** 127,138 **** add(klassifikation); ! JPanel filler = new JPanel(); ! filler.setOpaque(true); ! Color background = new Color(0.1f, 0.2f, 0.5f); ! filler.setBackground(background); con.weighty = 1.0; con.fill = GridBagConstraints.BOTH; ! layout.setConstraints(filler, con); ! add(filler); revalidate(); } --- 134,145 ---- add(klassifikation); ! JTextArea funcSpaceDescripton = new JTextArea(o.getDescription()); ! funcSpaceDescripton.setWrapStyleWord(true); ! funcSpaceDescripton.setLineWrap(true); con.weighty = 1.0; con.fill = GridBagConstraints.BOTH; ! layout.setConstraints(funcSpaceDescripton, con); ! funcSpaceDescripton.addFocusListener(new MyFocusListener(o)); ! add(funcSpaceDescripton); revalidate(); } *************** *** 150,162 **** JLabel name = new JLabel("Name:"); ! con.anchor = GridBagConstraints.NORTH; ! con.weightx = 1.0; layout.setConstraints(name, con); ! add(name); ! JTextField nameEdit = new JTextField(o.getName(), 10); ! nameEdit.addKeyListener(new MyKeyListener(o)); con.gridwidth = GridBagConstraints.REMAINDER; layout.setConstraints(nameEdit, con); ! add(nameEdit); revalidate(); } --- 157,190 ---- JLabel name = new JLabel("Name:"); ! con.anchor = GridBagConstraints.NORTHEAST; ! con.weightx = 0; layout.setConstraints(name, con); ! add(name); ! ! ! ! JTextField nameEdit = new JTextField(o.getName()); con.gridwidth = GridBagConstraints.REMAINDER; + con.weightx = 1.0; + con.fill = GridBagConstraints.HORIZONTAL; layout.setConstraints(nameEdit, con); ! add(nameEdit); ! nameEdit.addKeyListener(new MyKeyListener(o, TFIELD)); ! ! Object[] options = {"Arbejdsværelse", "Badeværelse", "Gang", "Køkken", "Stue", "Værelse"}; ! JComboBox klassifikation = new JComboBox(options); ! layout.setConstraints(klassifikation, con); ! add(klassifikation); ! ! JTextArea consSpaceDescripton = new JTextArea(o.getDescription()); ! consSpaceDescripton.setLineWrap(true); ! consSpaceDescripton.setWrapStyleWord(true); ! con.weighty = 1.0; ! con.fill = GridBagConstraints.BOTH; ! layout.setConstraints(consSpaceDescripton, con); ! consSpaceDescripton.addFocusListener(new MyFocusListener(o)); ! add(consSpaceDescripton); ! revalidate(); ! revalidate(); } |