001 /** 002 * planningtool - A Planning Tool with Critiquing Support. 003 * 004 * Copyright (C) 2006 olale 005 006 * This program is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU General Public License 008 * as published by the Free Software Foundation; either version 2 009 * of the License, or (at your option) any later version. 010 011 * This program is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 014 * GNU General Public License for more details. 015 016 * You should have received a copy of the GNU General Public License 017 * along with this program; if not, write to the Free Software 018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 019 020 * Contact information: 021 * E-mail: olale@ida.liu.se 022 * olale@lysator.liu.se 023 */ 024 package se.liu.ida.critiquer.activities.parameters; 025 026 import java.awt.event.KeyEvent; 027 import java.awt.event.KeyListener; 028 029 import javax.swing.BorderFactory; 030 import javax.swing.JEditorPane; 031 032 import se.liu.ida.critiquer.activities.Activity; 033 034 035 public class DescriptionParameter extends AbstractTaskViewParameter<JEditorPane,String> { 036 037 038 039 /** 040 * 041 */ 042 private static final long serialVersionUID = -8241385230556176507L; 043 044 public DescriptionParameter(String name,Activity activity) { 045 super(name,activity); 046 } 047 048 public DescriptionParameter(Activity activity) { 049 super("description",activity); 050 } 051 052 /** 053 * 054 * Initialize the graphical component of this parameter. 055 * 056 * @see se.liu.ida.critiquer.activities.parameters.ActivityParameter#getComponent() 057 */ 058 059 public void initComponent() { 060 061 component = new JEditorPane(); 062 component.setBorder(BorderFactory.createTitledBorder(toString())); 063 component.setText(getValue()); 064 component.addKeyListener(new KeyListener(){ 065 066 public void keyTyped(KeyEvent arg0) { 067 setValue(component.getText()); 068 } 069 070 public void keyPressed(KeyEvent arg0) { 071 // Do nothing 072 073 } 074 075 public void keyReleased(KeyEvent arg0) { 076 // Do nothing 077 } 078 079 }); 080 081 } 082 083 public String toString() { 084 return "Description"; 085 } 086 087 088 }