Thread: [Ejtools-cvs] libraries/graph/src/main/org/ejtools/graph/dialog SelectGraphDialog.java,1.4,1.5
Brought to you by:
letiemble
From: <let...@us...> - 2003-12-14 09:48:33
|
Update of /cvsroot/ejtools/libraries/graph/src/main/org/ejtools/graph/dialog In directory sc8-pr-cvs1:/tmp/cvs-serv18699/graph/src/main/org/ejtools/graph/dialog Modified Files: SelectGraphDialog.java Log Message: Add more javadocs. Adjust text export. Index: SelectGraphDialog.java =================================================================== RCS file: /cvsroot/ejtools/libraries/graph/src/main/org/ejtools/graph/dialog/SelectGraphDialog.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SelectGraphDialog.java 15 Sep 2003 22:11:22 -0000 1.4 --- SelectGraphDialog.java 13 Dec 2003 21:26:46 -0000 1.5 *************** *** 1,154 **** ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.graph.dialog; ! ! import java.awt.Component; ! import java.awt.GridBagConstraints; ! import java.awt.GridBagLayout; ! import java.awt.GridLayout; ! import java.awt.Insets; ! import java.awt.event.ActionEvent; ! import java.awt.event.ActionListener; ! import java.util.ResourceBundle; ! ! import javax.swing.JButton; ! import javax.swing.JComboBox; ! import javax.swing.JDialog; ! import javax.swing.JLabel; ! import javax.swing.JPanel; ! ! /** ! * @author Laurent Etiemble ! * @version $Revision$ ! */ ! public class SelectGraphDialog extends JDialog ! { ! /** Description of the Field */ ! protected JComboBox choices; ! /** Description of the Field */ ! protected Object initialSelectionValue; ! /** Description of the Field */ ! protected Object selectedValue = null; ! /** Description of the Field */ ! private static ResourceBundle resources = ResourceBundle.getBundle("org.ejtools.graph.GraphService"); ! ! ! /** ! *Constructor for the CustomJOptionPane object ! * ! * @param parentComponent Description of the Parameter ! * @param selectionValues Description of the Parameter ! * @param initialSelectionValue Description of the Parameter ! */ ! public SelectGraphDialog(Component parentComponent, Object[] selectionValues, Object initialSelectionValue) ! { ! super(); ! this.setModal(true); ! this.setTitle(resources.getString("graph.dialog.title")); ! ! JPanel main = new JPanel(new GridBagLayout()); ! GridBagConstraints constraints = new GridBagConstraints(); ! constraints.insets = new Insets(5, 5, 5, 5); ! ! constraints.gridwidth = GridBagConstraints.REMAINDER; ! constraints.weightx = 1.0; ! constraints.fill = GridBagConstraints.HORIZONTAL; ! constraints.anchor = GridBagConstraints.WEST; ! JLabel messageLabel = new JLabel(resources.getString("graph.dialog.text.description")); ! main.add(messageLabel, constraints); ! ! this.initialSelectionValue = initialSelectionValue; ! ! this.choices = new JComboBox(selectionValues); ! this.choices.setSelectedItem(this.initialSelectionValue); ! this.choices.setEditable(true); ! if (selectionValues.length == 0) ! { ! choices.getEditor().setItem(this.initialSelectionValue); ! } ! ! main.add(choices, constraints); ! ! JPanel buttons = new JPanel(new GridLayout(1, 2, 2, 2)); ! ! JButton buttonSelect = new JButton(resources.getString("graph.dialog.button.select")); ! buttons.add(buttonSelect); ! buttonSelect.addActionListener( ! new ActionListener() ! { ! /** ! * @param e Description of the Parameter ! */ ! public void actionPerformed(ActionEvent e) ! { ! select(); ! dispose(); ! } ! }); ! ! JButton buttonCancel = new JButton(resources.getString("graph.dialog.button.cancel")); ! buttons.add(buttonCancel); ! buttonCancel.addActionListener( ! new ActionListener() ! { ! /** ! * @param e Description of the Parameter ! */ ! public void actionPerformed(ActionEvent e) ! { ! selectedValue = null; ! dispose(); ! } ! }); ! ! constraints.fill = GridBagConstraints.NONE; ! constraints.anchor = GridBagConstraints.SOUTH; ! main.add(buttons, constraints); ! ! this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); ! this.getContentPane().add(main); ! this.pack(); ! this.setLocationRelativeTo(parentComponent); ! } ! ! ! /** ! * Returns the selectedValue. ! * ! * @return Object ! */ ! public Object getSelectedValue() ! { ! return selectedValue; ! } ! ! ! /** Description of the Method */ ! private void select() ! { ! boolean found = false; ! ! Object choice = this.choices.getSelectedItem(); ! Object text = this.choices.getEditor().getItem(); ! ! for (int i = 0; i < this.choices.getModel().getSize(); i++) ! { ! choice = this.choices.getModel().getElementAt(i); ! if (choice.toString().equals(text.toString())) ! { ! found = true; ! break; ! } ! } ! if (!found) ! { ! choice = text; ! } ! ! this.selectedValue = choice; ! } ! } --- 1,154 ---- ! /* ! * EJTools, the Enterprise Java Tools ! * ! * Distributable under LGPL license. ! * See terms of license at www.gnu.org. ! */ ! package org.ejtools.graph.dialog; ! ! import java.awt.Component; ! import java.awt.GridBagConstraints; ! import java.awt.GridBagLayout; ! import java.awt.GridLayout; ! import java.awt.Insets; ! import java.awt.event.ActionEvent; ! import java.awt.event.ActionListener; ! import java.util.ResourceBundle; ! ! import javax.swing.JButton; ! import javax.swing.JComboBox; ! import javax.swing.JDialog; ! import javax.swing.JLabel; ! import javax.swing.JPanel; ! ! /** ! * @author Laurent Etiemble ! * @version $Revision$ ! */ ! public class SelectGraphDialog extends JDialog ! { ! /** Description of the Field */ ! protected JComboBox choices; ! /** Description of the Field */ ! protected Object initialSelectionValue; ! /** Description of the Field */ ! protected Object selectedValue = null; ! /** Description of the Field */ ! private static ResourceBundle resources = ResourceBundle.getBundle("org.ejtools.graph.GraphService"); ! ! ! /** ! *Constructor for the CustomJOptionPane object ! * ! * @param parentComponent Description of the Parameter ! * @param selectionValues Description of the Parameter ! * @param initialSelectionValue Description of the Parameter ! */ ! public SelectGraphDialog(Component parentComponent, Object[] selectionValues, Object initialSelectionValue) ! { ! super(); ! this.setModal(true); ! this.setTitle(resources.getString("graph.dialog.title")); ! ! JPanel main = new JPanel(new GridBagLayout()); ! GridBagConstraints constraints = new GridBagConstraints(); ! constraints.insets = new Insets(5, 5, 5, 5); ! ! constraints.gridwidth = GridBagConstraints.REMAINDER; ! constraints.weightx = 1.0; ! constraints.fill = GridBagConstraints.HORIZONTAL; ! constraints.anchor = GridBagConstraints.WEST; ! JLabel messageLabel = new JLabel(resources.getString("graph.dialog.text.description")); ! main.add(messageLabel, constraints); ! ! this.initialSelectionValue = initialSelectionValue; ! ! this.choices = new JComboBox(selectionValues); ! this.choices.setSelectedItem(this.initialSelectionValue); ! this.choices.setEditable(true); ! if (selectionValues.length == 0) ! { ! choices.getEditor().setItem(this.initialSelectionValue); ! } ! ! main.add(choices, constraints); ! ! JPanel buttons = new JPanel(new GridLayout(1, 2, 2, 2)); ! ! JButton buttonSelect = new JButton(resources.getString("graph.dialog.button.select")); ! buttons.add(buttonSelect); ! buttonSelect.addActionListener( ! new ActionListener() ! { ! /** ! * @param e Description of the Parameter ! */ ! public void actionPerformed(ActionEvent e) ! { ! select(); ! dispose(); ! } ! }); ! ! JButton buttonCancel = new JButton(resources.getString("graph.dialog.button.cancel")); ! buttons.add(buttonCancel); ! buttonCancel.addActionListener( ! new ActionListener() ! { ! /** ! * @param e Description of the Parameter ! */ ! public void actionPerformed(ActionEvent e) ! { ! selectedValue = null; ! dispose(); ! } ! }); ! ! constraints.fill = GridBagConstraints.NONE; ! constraints.anchor = GridBagConstraints.SOUTH; ! main.add(buttons, constraints); ! ! this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); ! this.getContentPane().add(main); ! this.pack(); ! this.setLocationRelativeTo(parentComponent); ! } ! ! ! /** ! * Returns the selectedValue. ! * ! * @return Object ! */ ! public Object getSelectedValue() ! { ! return selectedValue; ! } ! ! ! /** Description of the Method */ ! private void select() ! { ! boolean found = false; ! ! Object choice = this.choices.getSelectedItem(); ! Object text = this.choices.getEditor().getItem(); ! ! for (int i = 0; i < this.choices.getModel().getSize(); i++) ! { ! choice = this.choices.getModel().getElementAt(i); ! if (choice.toString().equals(text.toString())) ! { ! found = true; ! break; ! } ! } ! if (!found) ! { ! choice = text; ! } ! ! this.selectedValue = choice; ! } ! } |