Save This Page
Home » openjdk-7 » net.sourceforge » mflow » ui » [javadoc | source]
    1   /*
    2    *   (C) 2002 David Carr  david@carr.name
    3    *
    4    *   This program is free software; you can redistribute it and/or modify
    5    *   it under the terms of the GNU General Public License as published by
    6    *   the Free Software Foundation; either version 2 of the License, or
    7    *   (at your option) any later version.
    8    *
    9    *   This program is distributed in the hope that it will be useful,
   10    *   but WITHOUT ANY WARRANTY; without even the implied warranty of
   11    *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   12    *   GNU General Public License for more details.
   13    *
   14    *   You should have received a copy of the GNU General Public License
   15    *   along with this program; if not, write to the Free Software
   16    *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   17    *
   18    */
   19   
   20   package net.sourceforge.mflow.ui;
   21   
   22   import javax.swing.tree;
   23   import javax.swing;
   24   import java.awt;
   25   import java.awt.event;
   26   import net.sourceforge.mflow;
   27   
   28   /**
   29    * Dialog to allow the addition of ContactGroups, Contacts, and ContactMethods to a ContactGroup
   30    *
   31    * @author <a href="mailto:david@carr.name">David Carr</a>
   32    */
   33   public class ContactAddDialog extends JDialog {
   34   	/**
   35   	 * Private reference to the ContactList
   36   	 */
   37   	private ContactList mContactList;
   38   
   39   	/**
   40   	 * Constructor taking a parent window, and a ContactList
   41   	 *
   42   	 * @param owner the parent window
   43   	 * @param cl the ContactList
   44   	 */
   45   	public ContactAddDialog(Frame owner, ContactList cl) {
   46   /*		super(owner, "Add...", true);
   47   		JTabbedPane tabbedPane = new JTabbedPane();
   48   		mContactList = cl;
   49   		final TreePath tp = cl.getSelectionPath();
   50   
   51   		if(tp == null || tp.getLastPathComponent() instanceof ContactGroup) {
   52   			JPanel pnlGroup = new JPanel(false); pnlGroup.setLayout(new BoxLayout(pnlGroup, BoxLayout.Y_AXIS));
   53   			JLabel lblGroupName = new JLabel("Group Name:");
   54   			final JTextField txtGroupName = new JTextField();
   55   			txtGroupName.setColumns(8);
   56   			JButton btnGroup = new JButton("Add Contact Group");
   57   			btnGroup.addActionListener(new ActionListener() {
   58   				public void actionPerformed(ActionEvent ae) {
   59   					ContactGroup cg = new ContactGroup(txtGroupName.getText());
   60   					ContactListTreeModel cltm = (ContactListTreeModel) mContactList.getModel();
   61   					if(tp == null) {
   62   						cltm.addChild(cltm.getRoot(), cg);
   63   						System.out.println("Added " + cg.toString() + " to root");
   64   					} else {
   65   						cltm.addChild(tp.getLastPathComponent(), cg);
   66   						System.out.println("Added " + cg.toString() + " to " + tp.getLastPathComponent().toString());
   67   					}
   68   					hide();
   69   					SwingUtilities.invokeLater(new Runnable() {
   70   						public void run() {
   71   							mContactList.invalidate();
   72   							mContactList.validate();
   73   							mContactList.update(getGraphics());
   74   						}
   75   					});
   76   //					dispose();
   77   				}
   78   			});
   79   			JPanel pnlGroupTemp = new JPanel(); pnlGroupTemp.add(lblGroupName); pnlGroupTemp.add(txtGroupName);
   80   			pnlGroup.add(pnlGroupTemp);
   81   			pnlGroup.add(btnGroup);
   82   			tabbedPane.addTab("Group", null, pnlGroup, "Add Contact Group");
   83   		}
   84   
   85   		JPanel pnlContact = new JPanel(false);
   86   		JLabel filler2 = new JLabel("Moo2");
   87   		filler2.setHorizontalAlignment(JLabel.CENTER);
   88   		pnlContact.setLayout(new GridLayout(1, 1));
   89   		pnlContact.add(filler2);
   90   		tabbedPane.addTab("Contact", null, pnlContact, "Add Contact");
   91   
   92   		JPanel pnlContactMethod = new JPanel(false);
   93   		JLabel filler3 = new JLabel("Moo3");
   94   		filler3.setHorizontalAlignment(JLabel.CENTER);
   95   		pnlContactMethod.setLayout(new GridLayout(1, 1));
   96   		pnlContactMethod.add(filler3);
   97   		tabbedPane.addTab("Contact Method", null, pnlContactMethod, "Add Contact Method");
   98   
   99   		tabbedPane.setSelectedIndex(0);
  100   
  101   //		int maxWidth = Math.max(Math.max(pnlGroup.getPreferredSize().width, pnlContact.getPreferredSize().width), pnlContactMethod.getPreferredSize().width);
  102   //		int maxHeight = Math.max(Math.max(pnlGroup.getPreferredSize().height, pnlContact.getPreferredSize().height), pnlContactMethod.getPreferredSize().height);
  103   //		tabbedPane.setPreferredSize(new Dimension(maxWidth, maxHeight));
  104   
  105   		getContentPane().setLayout(new GridLayout(1, 1));
  106   		getContentPane().add(tabbedPane);
  107   		pack();
  108   */
  109   	}
  110   }

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