View Javadoc
1 /*** 2 * FilterManipulateDialog.java 3 * 4 * Project: Dependency Tool 5 * 6 * WHEN WHO WHAT 7 * 06.06.2003 pko initial public release 8 * 26.02.2002 ctr creation 9 * 10 * Copyright 2003 ELCA Informatique SA 11 * Av. de la Harpe 22-24, 1000 Lausanne 13, Switzerland 12 * www.elca.ch 13 * 14 * This library is free software; you can redistribute it and/or 15 * modify it under the terms of the GNU Lesser General Public License 16 * as published by the Free Software Foundation; either version 2.1 of 17 * the License, or (at your option) any later version. 18 * 19 * This library is distributed in the hope that it will be useful, but 20 * WITHOUT ANY WARRANTY; without even the implied warranty of 21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 22 * Lesser General Public License for more details. 23 * 24 * You should have received a copy of the GNU Lesser General Public 25 * License along with this library; if not, write to the Free Software 26 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 27 * USA 28 */ 29 30 package ch.elca.dependency.gui; 31 32 import java.awt.Dimension; 33 import java.awt.Insets; 34 import java.awt.event.ActionEvent; 35 import java.awt.event.ActionListener; 36 import javax.swing.*; 37 38 import info.clearthought.layout.TableLayout; 39 40 /*** 41 * Dialog for creating and modifying filters. 42 * 43 * @author Christoph Trutmann 44 * @version 1.0-beta 45 */ 46 public class FilterManipulationDialog 47 extends JDialog implements ActionListener { 48 49 /*** 50 * Textfield containing the name of this filter. 51 */ 52 private JTextField m_nameField; 53 54 /*** 55 * Textfield containing the value of this filter. 56 */ 57 private JTextField m_valueField; 58 59 /*** 60 * Constructor - Set the owner dialog and call the <code>init</code> method. 61 * 62 * @param owner Filter main dialog which is the owner of this dialog. 63 */ 64 public FilterManipulationDialog(JDialog owner){ 65 super(owner, true); // modal dialog with the owner 66 init(); 67 } 68 69 /*** 70 * Initializes the gui components. 71 */ 72 public void init() { 73 74 double border = 10; 75 double fill = TableLayout.FILL; 76 double pref = TableLayout.PREFERRED; 77 double size[][] = 78 {{border, pref, fill, pref, border}, // Columns 79 {border, pref, border, pref, border, pref, border}}; // Rows 80 81 this.getContentPane().setLayout(new TableLayout(size)); 82 83 // label and text field for the name 84 JLabel nameLabel = new JLabel("Name of the Filter:"); 85 this.getContentPane().add(nameLabel, "1, 1, L, T"); 86 87 m_nameField = new JTextField(20); 88 this.getContentPane().add(m_nameField, "3, 1, F, C"); 89 90 // label and text field for the value 91 JLabel valueLabel = new JLabel("Value of the Filter:"); 92 this.getContentPane().add(valueLabel, "1, 3, L, T"); 93 94 m_valueField = new JTextField(20); 95 this.getContentPane().add(m_valueField, "3, 3, F, C"); 96 97 // ok button for committing the change 98 JButton okButton = new JButton("OK"); 99 okButton.setPreferredSize(new Dimension(100,25)); 100 okButton.addActionListener(this); 101 this.getContentPane().add(okButton, "1, 5, C, C"); 102 103 // cancel button 104 JButton cancelButton = new JButton("Cancel"); 105 cancelButton.setPreferredSize(new Dimension(100,25)); 106 cancelButton.addActionListener(this); 107 this.getContentPane().add(cancelButton, "3, 5, C, C"); 108 109 this.setSize(new Dimension(400, 140)); 110 this.setLocation(450, 300); 111 this.setVisible(false); 112 this.setResizable(false); 113 } 114 115 116 /*** 117 * Overrides the <code>setVisible</code> method of the class 118 * <code>Component</code>. 119 * The textfields of this diaog are cleaned and then the method is delegated 120 * to its superclass. 121 */ 122 public void clearFields(){ 123 m_nameField.setText(""); 124 m_valueField.setText(""); 125 } 126 127 128 /*** 129 * Handles the action events generated by the buttons. 130 * 131 * @param event Action event generated by one of the buttons. 132 */ 133 public void actionPerformed(ActionEvent event) { 134 String comm = (String)event.getActionCommand(); 135 136 if ( comm.equals("OK") ) { 137 handleOK(); 138 } 139 else if ( comm.equals("Cancel") ) { 140 handleCancel(); 141 } 142 } 143 144 145 /*** 146 * Get the name of the filter which the user has specified. 147 * 148 * @return Filter name of the new or modified filter. 149 */ 150 public String getFilterName(){ 151 return m_nameField.getText(); 152 } 153 154 155 /*** 156 * Set the name of the filter which has to be modified. 157 * 158 * @param name Name of the filter. 159 */ 160 public void setFilterName(String name){ 161 m_nameField.setText(name); 162 } 163 164 165 /*** 166 * Get the value of the filter which the user has specified. 167 * 168 * @return Filter value of the new or modified filter. 169 */ 170 public String getFilterValue(){ 171 return m_valueField.getText(); 172 } 173 174 175 /*** 176 * Set the value of the filter which has to be modified. 177 * 178 * @param value Value of the filter. 179 */ 180 public void setFilterValue(String value){ 181 m_valueField.setText(value); 182 } 183 184 185 /*** 186 * Helper method for handling the action events of the ok button. 187 */ 188 private void handleOK(){ 189 setVisible(false); 190 } 191 192 193 /*** 194 * Helper method for handling the action events of the cancel button. 195 */ 196 private void handleCancel(){ 197 setVisible(false); 198 // rollback all the changes made in this session 199 m_nameField.setText(""); 200 m_valueField.setText(""); 201 } 202 }

This page was automatically generated by Maven