/* A basic extension of the java.awt.Dialog class */ import java.awt.*; import twinfeats.util.*; import java.io.*; import twinfeats.io.*; import twinfeats.conf.core.*; public class BusinessCardWin extends Dialog { ClientWin cwin; public BusinessCardWin(Frame parent, boolean modal, String name, String title, String org, String location) { this(parent,modal); cwin = (ClientWin)parent; Name.setText(name); if (title != null) Title.setText(title); if (org != null) Organization.setText(org); if (location != null) Location.setText(location); } public BusinessCardWin(Frame parent, boolean modal) { super(parent, modal); // This code is automatically generated by Visual Cafe when you add // components to the visual environment. It instantiates and initializes // the components. To modify the code, only use code syntax that matches // what Visual Cafe can generate, or Visual Cafe may be unable to back // parse your Java file into its visual environment. //{{INIT_CONTROLS setLayout(null); setSize(insets().left + insets().right + 296,insets().top + insets().bottom + 203); setFont(new Font("SansSerif", Font.PLAIN, 12)); Title = new java.awt.TextField(); Title.setEditable(false); Title.setBounds(insets().left + 85,insets().top + 44,173,31); add(Title); Organization = new java.awt.TextField(); Organization.setEditable(false); Organization.setBounds(insets().left + 85,insets().top + 79,173,31); add(Organization); Location = new java.awt.TextField(); Location.setEditable(false); Location.setBounds(insets().left + 85,insets().top + 114,173,31); add(Location); Name = new java.awt.TextField(); Name.setEditable(false); Name.setBounds(insets().left + 85,insets().top + 9,173,31); add(Name); label1 = new java.awt.Label("Name",Label.RIGHT); label1.setBounds(insets().left + 13,insets().top + 10,69,28); add(label1); label2 = new java.awt.Label("Title",Label.RIGHT); label2.setBounds(insets().left + 13,insets().top + 45,69,28); add(label2); label3 = new java.awt.Label("Org.",Label.RIGHT); label3.setBounds(insets().left + 13,insets().top + 80,69,28); add(label3); label4 = new java.awt.Label("Location",Label.RIGHT); label4.setBounds(insets().left + 13,insets().top + 115,69,28); add(label4); Close = new java.awt.Button(); Close.setLabel("Close"); Close.setBounds(insets().left + 93,insets().top + 156,85,30); Close.setBackground(java.awt.Color.lightGray); add(Close); Update = new java.awt.Button(); Update.setLabel("Update"); Update.setVisible(false); Update.setBounds(insets().left + 183,insets().top + 156,85,30); Update.setBackground(java.awt.Color.lightGray); add(Update); setTitle("Business Card: "); //}} //{{REGISTER_LISTENERS SymWindow aSymWindow = new SymWindow(); this.addWindowListener(aSymWindow); SymAction lSymAction = new SymAction(); Close.addActionListener(lSymAction); Update.addActionListener(lSymAction); //}} } public void addNotify() { // Record the size of the window prior to calling parents addNotify. Dimension d = getSize(); super.addNotify(); if (fComponentsAdjusted) return; // Adjust components according to the insets setSize(insets().left + insets().right + d.width, insets().top + insets().bottom + d.height); Component components[] = getComponents(); for (int i = 0; i < components.length; i++) { Point p = components[i].getLocation(); p.translate(insets().left, insets().top); components[i].setLocation(p); } fComponentsAdjusted = true; } // Used for addNotify check. boolean fComponentsAdjusted = false; public BusinessCardWin(Frame parent, String title, boolean modal) { this(parent, modal); setTitle(title); } public synchronized void show() { Rectangle bounds = getParent().bounds(); Rectangle abounds = bounds(); move(bounds.x + (bounds.width - abounds.width)/ 2, bounds.y + (bounds.height - abounds.height)/2); super.show(); } //{{DECLARE_CONTROLS java.awt.TextField Title; java.awt.TextField Organization; java.awt.TextField Location; java.awt.TextField Name; java.awt.Label label1; java.awt.Label label2; java.awt.Label label3; java.awt.Label label4; java.awt.Button Close; java.awt.Button Update; //}} class SymWindow extends java.awt.event.WindowAdapter { public void windowClosing(java.awt.event.WindowEvent event) { Object object = event.getSource(); if (object == BusinessCardWin.this) Dialog1_WindowClosing(event); } } void Dialog1_WindowClosing(java.awt.event.WindowEvent event) { hide(); dispose(); } class SymAction implements java.awt.event.ActionListener { public void actionPerformed(java.awt.event.ActionEvent event) { Object object = event.getSource(); if (object == Close) Close_Action(event); else if (object == Update) Update_Action(event); } } void Close_Action(java.awt.event.ActionEvent event) { // to do: code goes here. hide(); dispose(); } void Update_Action(java.awt.event.ActionEvent event) { // to do: code goes here. Profile profile = cwin.getProfile(); Comm comm = cwin.getComm(); if (profile == null) return; ProfileSection ps = profile.getSection(comm.getName()+":Business Card"); if (ps == null) { ps = new ProfileSection(comm.getName()+":Business Card"); profile.addSection(ps); } ps.setValue("Title",Title.getText()); ps.setValue("Organization",Organization.getText()); ps.setValue("Location",Location.getText()); try { profile.write(); } catch (IOException e) { cwin.Status.setText("Error updating client.ini"); } CommMessage msg = new CommMessage(comm.getName(),ConfBean.CONFERENCESERVER, ConfBean.UPDATECARD,new MsgUpdateCard(Title.getText(),Organization.getText(), Location.getText())); comm.send(msg); hide(); dispose(); } public void setEditable(boolean b) { if (b) { Update.setVisible(true); Title.setEditable(true); Organization.setEditable(true); Location.setEditable(true); } else { Update.setVisible(false); Title.setEditable(false); Organization.setEditable(false); Location.setEditable(false); } } }