tn5250j/src/org/tn5250j/mailtools SendEMailDialog.java,1.18,1.19

Patrick Bielen <[email protected]> Wed, 31 Mar 2004 12:25:11 +0000
Newsgroups gmane.comp.java.tn5250j.cvs
Message-ID <[email protected]>
Update of /cvsroot/tn5250j/tn5250j/src/org/tn5250j/mailtools
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23849/src/org/tn5250j/mailtools

Modified Files:
	SendEMailDialog.java 
Log Message:
Submitted by: Kenneth
Various updates to update CVS with actual code

Index: SendEMailDialog.java
===================================================================
RCS file: /cvsroot/tn5250j/tn5250j/src/org/tn5250j/mailtools/SendEMailDialog.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** SendEMailDialog.java	12 Dec 2003 13:53:46 -0000	1.18
--- SendEMailDialog.java	31 Mar 2004 12:25:08 -0000	1.19
***************
*** 27,53 ****
  package org.tn5250j.mailtools;
  
! import java.awt.Dimension;
! import java.awt.Frame;
! import java.awt.GridBagLayout;
! import java.awt.GridBagConstraints;
! import java.awt.Insets;
! import java.awt.event.ActionEvent;
  import java.io.File;
  import java.io.IOException;
  import java.util.StringTokenizer;
  
! import javax.swing.BorderFactory;
! import javax.swing.ButtonGroup;
! import javax.swing.JComboBox;
! import javax.swing.JButton;
! import javax.swing.JFileChooser;
! import javax.swing.JFrame;
! import javax.swing.JLabel;
! import javax.swing.JOptionPane;
! import javax.swing.JPanel;
! import javax.swing.JRadioButton;
! import javax.swing.JScrollPane;
! import javax.swing.JTextArea;
! import javax.swing.JTextField;
  
  import org.tn5250j.Screen5250;
--- 27,38 ----
  package org.tn5250j.mailtools;
  
! import java.awt.*;
! import java.awt.event.*;
! import java.beans.*;
  import java.io.File;
  import java.io.IOException;
  import java.util.StringTokenizer;
  
! import javax.swing.*;
  
  import org.tn5250j.Screen5250;
***************
*** 61,65 ****
   * Send E-Mail dialog
   */
! public class SendEMailDialog {
  
  	JComboBox toAddress;
--- 46,50 ----
   * Send E-Mail dialog
   */
! public class SendEMailDialog implements Runnable {
  
  	JComboBox toAddress;
***************
*** 77,80 ****
--- 62,66 ----
  	JButton browse;
     boolean sendScreen;
+    SendEMail sendEMail;
  
  	/**
***************
*** 231,238 ****
  		if (!isEMailAvailable()) {
  
! 			JOptionPane.showMessageDialog(parent,
! 				"The Java E-Mail API can not be found or is not installed\n"
! 				+ "Please read e-mail.txt file for installation instructions.",
! 				"Error", JOptionPane.ERROR_MESSAGE, null);
  		}
  		else {
--- 217,226 ----
  		if (!isEMailAvailable()) {
  
! 			JOptionPane.showMessageDialog(
! 				parent,
! 				LangTool.getString("messages.noEmailAPI"),
! 				"Error",
! 				JOptionPane.ERROR_MESSAGE,
! 				null);
  		}
  		else {
***************
*** 305,338 ****
  	private void sendIt(Frame parent, SendEMail sem) {
  
! 		if (parent == null)
! 			parent = new JFrame();
  
! 		try {
! 			if (sem.send()) {
  
! 				JOptionPane.showMessageDialog(
! 					parent,
! 					LangTool.getString("em.confirmationMessage")
! 						+ " "
! 						+ (String) toAddress.getSelectedItem(),
! 					LangTool.getString("em.titleConfirmation"),
! 					JOptionPane.INFORMATION_MESSAGE);
  
! 				if (session != null) {
! 					config.setProperty(
! 						"emailTo",
! 						getToTokens(
! 							config.getStringProperty("emailTo"),
! 							toAddress));
! 					config.saveSessionProps();
! 					setToCombo(config.getStringProperty("emailTo"), toAddress);
! 				}
  			}
! 		} catch (IOException ioe) {
! 			System.out.println(ioe.getMessage());
  		} catch (Exception ex) {
  			System.out.println(ex.getMessage());
  		}
! 	}
  
  	/**
--- 293,364 ----
  	private void sendIt(Frame parent, SendEMail sem) {
  
!       setSendEMail(sem);
!       new Thread(this).start();
! //		if (parent == null)
! //			parent = new JFrame();
! //
! //		try {
! //			if (sem.send()) {
! //
! //				JOptionPane.showMessageDialog(
! //					parent,
! //					LangTool.getString("em.confirmationMessage")
! //						+ " "
! //						+ (String) toAddress.getSelectedItem(),
! //					LangTool.getString("em.titleConfirmation"),
! //					JOptionPane.INFORMATION_MESSAGE);
! //
! //				if (session != null) {
! //					config.setProperty(
! //						"emailTo",
! //						getToTokens(
! //							config.getStringProperty("emailTo"),
! //							toAddress));
! //					config.saveSessionProps();
! //					setToCombo(config.getStringProperty("emailTo"), toAddress);
! //				}
! //			}
! //		} catch (IOException ioe) {
! //			System.out.println(ioe.getMessage());
! //		} catch (Exception ex) {
! //			System.out.println(ex.getMessage());
! //		}
! 	}
  
!    public void setSendEMail(SendEMail sem) {
!       sendEMail = sem;
!    }
!    public void run() {
  
! //		if (parent == null)
! //			parent = new JFrame();
  
! 		try {
! 			if (sendEMail.send()) {
! 
! //				JOptionPane.showMessageDialog(
! //					parent,
! //					LangTool.getString("em.confirmationMessage")
! //						+ " "
! //						+ (String) toAddress.getSelectedItem(),
! //					LangTool.getString("em.titleConfirmation"),
! //					JOptionPane.INFORMATION_MESSAGE);
! //
! //				if (session != null) {
! //					config.setProperty(
! //						"emailTo",
! //						getToTokens(
! //							config.getStringProperty("emailTo"),
! //							toAddress));
! //					config.saveSessionProps();
! //					setToCombo(config.getStringProperty("emailTo"), toAddress);
! //				}
  			}
! //		} catch (IOException ioe) {
! //			System.out.println(ioe.getMessage());
  		} catch (Exception ex) {
  			System.out.println(ex.getMessage());
  		}
!    }
  
  	/**
***************
*** 386,390 ****
  		JLabel fnl = new JLabel(LangTool.getString("em.fileName"));
  		JLabel tom = new JLabel(LangTool.getString("em.typeofmail"));
! 		
  		browse = new JButton(LangTool.getString("em.choosefile"));
  		browse.addActionListener(new java.awt.event.ActionListener() {
--- 412,416 ----
  		JLabel fnl = new JLabel(LangTool.getString("em.fileName"));
  		JLabel tom = new JLabel(LangTool.getString("em.typeofmail"));
! 
  		browse = new JButton(LangTool.getString("em.choosefile"));
  		browse.addActionListener(new java.awt.event.ActionListener() {
***************
*** 522,526 ****
  		gbc.insets = new Insets(5, 5, 10, 10);
  		semp.add(browse, gbc);
! 		
  		return semp;
  
--- 548,552 ----
  		gbc.insets = new Insets(5, 5, 10, 10);
  		semp.add(browse, gbc);
! 
  		return semp;
  
***************
*** 534,538 ****
  
  		// check to see if something was actually chosen
! 		if (ret == JFileChooser.APPROVE_OPTION) {
  		   File file = pcFileChooser.getSelectedFile();
  		   fileName = file.getName();
--- 560,564 ----
  
  		// check to see if something was actually chosen
! 		if (ret == TN5250jFileChooser.APPROVE_OPTION) {
  		   File file = pcFileChooser.getSelectedFile();
  		   fileName = file.getName();
***************
*** 645,647 ****
--- 671,770 ----
  	}
  
+ 	/**
+ 	 * Create a option pane to show status of the transfer
+ 	 */
+ 	private class ProgressOptionPane extends JOptionPane {
+ 
+ 		ProgressOptionPane(Object messageList) {
+ 
+ 			super(
+ 				messageList,
+ 				JOptionPane.INFORMATION_MESSAGE,
+ 				JOptionPane.DEFAULT_OPTION,
+ 				null,
+ 				new Object[] {
+ 					 UIManager.getString("OptionPane.cancelButtonText")},
+ 				null);
+ 			setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
+ 
+ 		}
+ 
+ 		public void setDone() {
+ 			Object[] option = this.getOptions();
+ 			option[0] = LangTool.getString("xtfr.tableDone");
+ 			this.setOptions(option);
+ 			setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ 		}
+ 
+ 		public void reset() {
+ 
+ 			Object[] option = this.getOptions();
+ 			option[0] = UIManager.getString("OptionPane.cancelButtonText");
+ 			this.setOptions(option);
+ //			monitor.setValue(null);
+ 
+ 		}
+ 
+ 		public int getMaxCharactersPerLineCount() {
+ 			return 60;
+ 		}
+ 
+ 		/**
+ 		 * Returns true if the user hits the Cancel button in the progress dialog.
+ 		 *
+ 		 * @return whether or not dialog was cancelled
+ 		 */
+ 		public boolean isCanceled() {
+ 			if (this == null)
+ 				return false;
+ 			Object v = this.getValue();
+ 			return (v != null);
+ 		}
+ 
+ 		// Equivalent to JOptionPane.createDialog,
+ 		// but create a modeless dialog.
+ 		// This is necessary because the Solaris implementation doesn't
+ 		// support Dialog.setModal yet.
+ 		public JDialog createDialog(Component parentComponent, String title) {
+ 
+ 			Frame frame = JOptionPane.getFrameForComponent(parentComponent);
+ 			final JDialog dialog = new JDialog(frame, title, false);
+ 			Container contentPane = dialog.getContentPane();
+ 
+ 			contentPane.setLayout(new BorderLayout());
+ 			contentPane.add(this, BorderLayout.CENTER);
+ 			dialog.pack();
+ 			dialog.setLocationRelativeTo(parentComponent);
+ 			dialog.addWindowListener(new WindowAdapter() {
+ 				boolean gotFocus = false;
+ 
+ 				public void windowClosing(WindowEvent we) {
+ 					setValue(null);
+ 				}
+ 
+ 				public void windowActivated(WindowEvent we) {
+ 					// Once window gets focus, set initial focus
+ 					if (!gotFocus) {
+ 						selectInitialValue();
+ 						gotFocus = true;
+ 					}
+ 				}
+ 			});
+ 
+ 			addPropertyChangeListener(new PropertyChangeListener() {
+ 				public void propertyChange(PropertyChangeEvent event) {
+ 					if (dialog.isVisible()
+ 						&& event.getSource() == ProgressOptionPane.this
+ 						&& (event.getPropertyName().equals(VALUE_PROPERTY)
+ 							|| event.getPropertyName().equals(
+ 								INPUT_VALUE_PROPERTY))) {
+ 						dialog.setVisible(false);
+ 						dialog.dispose();
+ 					}
+ 				}
+ 			});
+ 			return dialog;
+ 		}
+ 	}
+ 
  }
\ No newline at end of file



-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click