Save This Page
Home » openjdk-7 » net.sourceforge » jbird » chklst » [javadoc | source]
    1   /*
    2   	J-Bird net/sourceforge/jbird/chklst/JChecklistInfo.java
    3   
    4   	Copyright 2001, 2002, 2003  Dick Repasky
    5   */
    6   package net.sourceforge.jbird.chklst;
    7   
    8   import java.util.Arrays;
    9   import java.util.ResourceBundle;
   10   
   11   import java.awt.Window;
   12   import java.awt.GridBagConstraints;
   13   
   14   import javax.swing.JLabel;
   15   
   16   import javax.swing.tree.TreePath;
   17   
   18   import net.sourceforge.jbird.JbirdDB;
   19   
   20   import net.sourceforge.jbird.swing.JTextFields;
   21   
   22   public class JChecklistInfo extends JTextFields {
   23   
   24   	protected ChecklistChooser clistchooser;
   25   
   26   	public JChecklistInfo(ChecklistDB clistdb, ResourceBundle rb, Window owner) {
   27   		this(clistdb, rb, new ChecklistTreeModel(clistdb), owner);
   28   	}
   29   
   30   	public JChecklistInfo(ChecklistDB clistdb, ResourceBundle rb,
   31   				ChecklistTreeModel model, Window owner) {
   32   		super(new String[] { rb.getString("Name:"),
   33   					rb.getString("Description:"),
   34   					rb.getString("Source:"),
   35   					rb.getString("Contributor:"),
   36   					rb.getString("Version:")
   37   					},
   38   			new int[] {	JbirdDB.LIST_NAME_LEN_MAX,
   39   					JbirdDB.LIST_DESCRIPTION_LEN_MAX,
   40   					JbirdDB.LIST_SOURCE_LEN_MAX,
   41   					JbirdDB.LIST_CONTRIBUTOR_LEN_MAX,
   42   					JbirdDB.LIST_VERSION_LEN_MAX
   43   					});
   44   			clistchooser = new ChecklistChooser(model, clistdb, 
   45   								owner);
   46   			clistchooser.setColumns(30);
   47   			GridBagConstraints c = new GridBagConstraints();
   48   			c.gridx = 1;
   49   			c.gridy = 11;
   50   			c.anchor = GridBagConstraints.EAST;
   51   			add(new JLabel(rb.getString("Parent_checklist:")), c);
   52   			c.gridx = 3;
   53   			c.anchor = GridBagConstraints.WEST;
   54   			add(clistchooser, c);
   55   	}
   56   
   57   		/**
   58   		  * Compare information in this object with that provided.
   59   		  *
   60   		*/
   61   
   62   	public final boolean equals(Object[] listinfo) {
   63   		return Arrays.equals(getChecklistInfo(), listinfo);
   64   	}
   65   
   66   	public final Object[] getChecklistInfo() {
   67   		Object[] answer = new Object[ChecklistDB.LIST_LENGTH];
   68   		String[] stringinfo = getText();
   69   		for (int idx = 0; idx < stringinfo.length; idx ++) {
   70   			answer[idx] = stringinfo[idx];
   71   		}
   72   		answer[ChecklistDB.LIST_PARENT] = 
   73   					new Integer(getParentChecklist());
   74   		return answer;
   75   	}
   76   
   77   	public final int getParentChecklist() {
   78   		return clistchooser.getSelectedChecklist();
   79   	}
   80   
   81   
   82   	public final TreePath getParentChecklistPath() {
   83   		return clistchooser.getSelectedPath();
   84   	}
   85   
   86   	public void nullify() {
   87   		clistchooser.nullify();
   88   		clistchooser = null;
   89   		super.nullify();
   90   	}
   91   
   92   		/**
   93   		  * Call this method with the Object[] that is returned
   94   		  * by ChecklistDB.getChecklistInfo.
   95   		  *
   96   		*/
   97   
   98   	public final void setChecklistInfo(Object[] info) {
   99   		for (int idx = 0; idx < ChecklistDB.LIST_PARENT; idx ++) {
  100   			setText(idx, (String)info[idx]);
  101   		}
  102   		setParentChecklist(((Integer)
  103   				info[ChecklistDB.LIST_PARENT]).intValue());
  104   	}
  105   
  106   	public final void setParentChecklist(int listno) {
  107   		clistchooser.setSelectedChecklist(listno);
  108   	}
  109   
  110   	public final void setParentChecklist(ChecklistNode node) {
  111   		clistchooser.setSelectedChecklist(node);
  112   	}
  113   
  114   	public final void setParentChecklist(TreePath path) {
  115   		clistchooser.setSelectedPath(path);
  116   	}
  117   
  118   }
  119   

Save This Page
Home » openjdk-7 » net.sourceforge » jbird » chklst » [javadoc | source]