[Schmitzm-commits] r2111 - in trunk: . schmitzm-mail schmitzm-mail/src schmitzm-mail/src/main schmitzm-mail/src/main/java schmitzm-mail/src/main/java/de schmitzm-mail/src/main/java/de/schmitzm schmitzm-mail/src/main/java/de/schmitzm/net schmitzm-mail/src/main/java/de/schmitzm/net/mail schmitzm-mail/src/main/java/de/schmitzm/net/mail/gui schmitzm-mail/src/main/resources schmitzm-mail/src/main/resources/de schmitzm-mail/src/main/resources/de/schmitzm schmitzm-mail/src/main/resources/de/schmitzm/net schmitzm-mail/src/main/resources/de/schmitzm/net/mail schmitzm-mail/src/main/resources/de/schmitzm/net/mail/gui schmitzm-mail/src/main/resources/de/schmitzm/net/mail/gui/resource schmitzm-mail/src/main/resources/de/schmitzm/net/mail/gui/resource/locales schmitzm-mail/src/test schmitzm-mail/src/test/java schmitzm-mail/src/test/java/de schmitzm-mail/src/test/java/de/schmitzm schmitzm-mail/src/test/java/de/schmitzm/net schmitzm-mail/src/test/java/de/schmitzm/net/mail schmitzm-mail/src/test/java/de/schmitzm/net/mail/gui

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Mon Oct 15 14:37:39 CEST 2012


Author: mojays
Date: 2012-10-15 14:37:39 +0200 (Mon, 15 Oct 2012)
New Revision: 2111

Added:
   trunk/schmitzm-mail/
   trunk/schmitzm-mail/pom.xml
   trunk/schmitzm-mail/src/
   trunk/schmitzm-mail/src/main/
   trunk/schmitzm-mail/src/main/java/
   trunk/schmitzm-mail/src/main/java/de/
   trunk/schmitzm-mail/src/main/java/de/schmitzm/
   trunk/schmitzm-mail/src/main/java/de/schmitzm/net/
   trunk/schmitzm-mail/src/main/java/de/schmitzm/net/mail/
   trunk/schmitzm-mail/src/main/java/de/schmitzm/net/mail/gui/
   trunk/schmitzm-mail/src/main/java/de/schmitzm/net/mail/gui/MailAddressesPanel.java
   trunk/schmitzm-mail/src/main/java/de/schmitzm/net/mail/gui/MailEditorPanel.java
   trunk/schmitzm-mail/src/main/java/de/schmitzm/net/mail/gui/MailGUIUtil.java
   trunk/schmitzm-mail/src/main/resources/
   trunk/schmitzm-mail/src/main/resources/de/
   trunk/schmitzm-mail/src/main/resources/de/schmitzm/
   trunk/schmitzm-mail/src/main/resources/de/schmitzm/net/
   trunk/schmitzm-mail/src/main/resources/de/schmitzm/net/mail/
   trunk/schmitzm-mail/src/main/resources/de/schmitzm/net/mail/gui/
   trunk/schmitzm-mail/src/main/resources/de/schmitzm/net/mail/gui/resource/
   trunk/schmitzm-mail/src/main/resources/de/schmitzm/net/mail/gui/resource/locales/
   trunk/schmitzm-mail/src/main/resources/de/schmitzm/net/mail/gui/resource/locales/MailGUIResourceBundle.properties
   trunk/schmitzm-mail/src/main/resources/de/schmitzm/net/mail/gui/resource/locales/MailGUIResourceBundle_de.properties
   trunk/schmitzm-mail/src/test/
   trunk/schmitzm-mail/src/test/java/
   trunk/schmitzm-mail/src/test/java/de/
   trunk/schmitzm-mail/src/test/java/de/schmitzm/
   trunk/schmitzm-mail/src/test/java/de/schmitzm/net/
   trunk/schmitzm-mail/src/test/java/de/schmitzm/net/mail/
   trunk/schmitzm-mail/src/test/java/de/schmitzm/net/mail/gui/
   trunk/schmitzm-mail/src/test/java/de/schmitzm/net/mail/gui/MailEditorTest.java
   trunk/schmitzm-mail/src/test/resources/
Modified:
   trunk/pom.xml
Log:
New subproject schmitzm-mail


Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml	2012-10-15 12:36:04 UTC (rev 2110)
+++ trunk/pom.xml	2012-10-15 12:37:39 UTC (rev 2111)
@@ -19,6 +19,7 @@
 		<module>schmitzm-jfree-gt</module>
 		<module>schmitzm-adresses</module>
 		<module>schmitzm-excelcsv</module>
+		<module>schmitzm-mail</module>
 	</modules>
 	
 	<distributionManagement>

Added: trunk/schmitzm-mail/pom.xml
===================================================================
--- trunk/schmitzm-mail/pom.xml	                        (rev 0)
+++ trunk/schmitzm-mail/pom.xml	2012-10-15 12:37:39 UTC (rev 2111)
@@ -0,0 +1,41 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+
+	<groupId>de.schmitzm</groupId>
+	<artifactId>schmitzm-mail</artifactId>
+	<version>2.8-SNAPSHOT</version>
+	<packaging>jar</packaging>
+
+	<parent>
+		<groupId>de.schmitzm</groupId>
+		<artifactId>schmitzm-parent</artifactId>
+		<version>2.8-SNAPSHOT</version>
+		<relativePath>../schmitzm-parent/pom.xml</relativePath>
+	</parent>
+
+	<name>schmitzm-mail</name>
+	<dependencies>
+                <dependency>
+                        <groupId>com.metaphaseeditor</groupId>
+                        <artifactId>metaphaseEditor</artifactId>
+                        <version>1.1.0</version>
+			<scope>compile</scope>
+                </dependency>
+		<dependency>
+			<groupId>de.schmitzm</groupId>
+			<artifactId>schmitzm-core</artifactId>
+			<version>${project.version}</version>
+			<type>test-jar</type>
+			<scope>test</scope>
+		</dependency>
+		<dependency>
+			<groupId>de.schmitzm</groupId>
+			<artifactId>schmitzm-core</artifactId>
+			<version>${project.version}</version>
+			<type>jar</type>
+			<scope>compile</scope>
+		</dependency>
+	</dependencies>
+
+</project>

Added: trunk/schmitzm-mail/src/main/java/de/schmitzm/net/mail/gui/MailAddressesPanel.java
===================================================================
--- trunk/schmitzm-mail/src/main/java/de/schmitzm/net/mail/gui/MailAddressesPanel.java	                        (rev 0)
+++ trunk/schmitzm-mail/src/main/java/de/schmitzm/net/mail/gui/MailAddressesPanel.java	2012-10-15 12:37:39 UTC (rev 2111)
@@ -0,0 +1,232 @@
+/**
+ * Copyright (c) 2009 Martin O. J. Schmitz.
+ * 
+ * This file is part of the SCHMITZM library - a collection of utility 
+ * classes based on Java 1.6, focusing (not only) on Java Swing 
+ * and the Geotools library.
+ * 
+ * The SCHMITZM project is hosted at:
+ * http://wald.intevation.org/projects/schmitzm/
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License (license.txt)
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ * or try this link: http://www.gnu.org/licenses/lgpl.html
+ * 
+ * Contributors:
+ *     Martin O. J. Schmitz - initial API and implementation
+ *     Stefan A. Tzeggai - additional utility classes
+ */
+package de.schmitzm.net.mail.gui;
+
+import javax.swing.JLabel;
+import javax.swing.JTextField;
+
+import net.miginfocom.swing.MigLayout;
+import de.schmitzm.lang.LangUtil;
+import de.schmitzm.swing.JPanel;
+
+/**
+ * A panel which shows from-, to-, cc- and bcc-address. 
+ * @author Martin O.J. Schmitz
+ */
+public class MailAddressesPanel extends JPanel {
+  protected JLabel fromCaption = new JLabel(MailGUIUtil.R("MailAddressesPanel.from"));
+  protected JTextField from = new JTextField();
+  protected JLabel toCaption = new JLabel(MailGUIUtil.R("MailAddressesPanel.to"));
+  protected JTextField to = new JTextField();
+  protected JLabel ccCaption = new JLabel(MailGUIUtil.R("MailAddressesPanel.cc"));
+  protected JTextField cc = new JTextField();
+  protected JLabel bccCaption = new JLabel(MailGUIUtil.R("MailAddressesPanel.bcc"));
+  protected JTextField bcc = new JTextField();
+  
+  /**
+   * Creates a new panel.
+   */
+  public MailAddressesPanel() {
+    this(true, true, true, true);
+  }
+
+  /**
+   * Creates a new panel
+   * @param showFrom indicates whether field for FROM address is shown
+   * @param showTo   indicates whether field for TO address is shown
+   * @param showCC   indicates whether field for CC address is shown
+   * @param showBCC  indicates whether field for BCC address is shown
+   */
+  public MailAddressesPanel(boolean showFrom, boolean showTo, boolean showCC, boolean showBCC) {
+    super( new MigLayout("wrap 2","[]20[grow]","[top]") );
+    
+    if ( showFrom ) {
+      add(fromCaption,"");
+      add(from,"growx");
+    }
+    if ( showTo ) {
+      add(toCaption,"");
+      add(to,"growx");
+    }
+    if ( showCC ) { 
+      add(ccCaption,"");
+      add(cc,"growx");
+    }
+    if ( showBCC ) {
+      add(bccCaption,"");
+      add(bcc,"growx");
+    }
+  }
+  
+  /**
+   * Splits the content of the given text field by comma.
+   */
+  protected String[] splitAddresses(JTextField addrField) {
+    return splitAddresses(addrField.getText());
+  }
+
+  /**
+   * Splits the addresses string by comma.
+   */
+  protected String[] splitAddresses(String addrStr) {
+    if (addrStr == null)
+      return new String[0];
+    return addrStr.split(",");
+  }
+  
+  /**
+   * Creates a comma separated string which contains the given addresses.
+   */
+  protected String combineAddresses(String[] addr) {
+    if ( addr == null )
+      return "";
+    return LangUtil.stringConcatWithSep(", ", true, addr);
+  }
+
+  /**
+   * Creates a comma separated string which contains the given addresses
+   * and stores it in given text field.
+   */
+  protected void combineAddresses(String[] addr, JTextField field) {
+    field.setText( combineAddresses(addr) );
+  }
+
+  /**
+   * Returns the content of the FROM address field.
+   */
+  public String getFrom() {
+    return from.getText();
+  }
+  
+  /**
+   * Sets the content of the FROM address field.
+   */
+  public void setFrom(String addrStr) {
+    from.setText(addrStr);
+  }
+  
+  /**
+   * Returns all the content of the FROM address field.
+   */
+  public String[] getFromAdresses() {
+    return splitAddresses(from);
+  }
+  
+  /**
+   * Sets the content of the FROM address field.
+   */
+  public void getFromAdresses(String[] addr) {
+    combineAddresses(addr, from);
+  }
+
+  /**
+   * Returns the content of the TO address field.
+   */
+  public String getTo() {
+    return to.getText();
+  }
+  
+  /**
+   * Sets the content of the TO address field.
+   */
+  public void setTo(String addrStr) {
+    to.setText(addrStr);
+  }
+  
+  /**
+   * Returns all the content of the TO address field.
+   */
+  public String[] getToAdresses() {
+    return splitAddresses(to);
+  }
+  
+  /**
+   * Sets the content of the TO address field.
+   */
+  public void getToAdresses(String[] addr) {
+    combineAddresses(addr, to);
+  }
+
+  /**
+   * Returns the content of the CC address field.
+   */
+  public String getCc() {
+    return cc.getText();
+  }
+  
+  /**
+   * Sets the content of the CC address field.
+   */
+  public void setCc(String addrStr) {
+    cc.setText(addrStr);
+  }
+  
+  /**
+   * Returns all the content of the CC address field.
+   */
+  public String[] getCcAdresses() {
+    return splitAddresses(cc);
+  }
+  
+  /**
+   * Sets the content of the CC address field.
+   */
+  public void getCcAdresses(String[] addr) {
+    combineAddresses(addr, cc);
+  }
+
+  /**
+   * Returns the content of the BCC address field.
+   */
+  public String getBcc() {
+    return bcc.getText();
+  }
+  
+  /**
+   * Sets the content of the BCC address field.
+   */
+  public void setBcc(String addrStr) {
+    bcc.setText(addrStr);
+  }
+  
+  /**
+   * Returns all the content of the BCC address field.
+   */
+  public String[] getBccAdresses() {
+    return splitAddresses(bcc);
+  }
+  
+  /**
+   * Sets the content of the BCC address field.
+   */
+  public void getBccAdresses(String[] addr) {
+    combineAddresses(addr, bcc);
+  }
+}

Added: trunk/schmitzm-mail/src/main/java/de/schmitzm/net/mail/gui/MailEditorPanel.java
===================================================================
--- trunk/schmitzm-mail/src/main/java/de/schmitzm/net/mail/gui/MailEditorPanel.java	                        (rev 0)
+++ trunk/schmitzm-mail/src/main/java/de/schmitzm/net/mail/gui/MailEditorPanel.java	2012-10-15 12:37:39 UTC (rev 2111)
@@ -0,0 +1,216 @@
+/**
+ * Copyright (c) 2009 Martin O. J. Schmitz.
+ * 
+ * This file is part of the SCHMITZM library - a collection of utility 
+ * classes based on Java 1.6, focusing (not only) on Java Swing 
+ * and the Geotools library.
+ * 
+ * The SCHMITZM project is hosted at:
+ * http://wald.intevation.org/projects/schmitzm/
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License (license.txt)
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ * or try this link: http://www.gnu.org/licenses/lgpl.html
+ * 
+ * Contributors:
+ *     Martin O. J. Schmitz - initial API and implementation
+ *     Stefan A. Tzeggai - additional utility classes
+ */
+package de.schmitzm.net.mail.gui;
+
+import java.awt.Component;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.swing.Action;
+import javax.swing.JButton;
+import javax.swing.JFileChooser;
+import javax.swing.JLabel;
+import javax.swing.SwingConstants;
+
+import net.miginfocom.swing.MigLayout;
+
+import com.metaphaseeditor.MetaphaseEditorPanel;
+
+import de.schmitzm.lang.LangUtil;
+import de.schmitzm.swing.JPanel;
+import de.schmitzm.swing.SwingUtil;
+import de.schmitzm.swing.table.AbstractMutableTableModel;
+import de.schmitzm.swing.table.ComponentRenderer;
+import de.schmitzm.swing.table.MutableTable;
+
+/**
+ * A panel based on {@link BaseEditor} to edit an HTML mail. 
+ * 
+ * @author Martin O.J. Schmitz
+ */
+public class MailEditorPanel extends JPanel implements ActionListener {
+  public static final JFileChooser FILE_CHOOSER = new JFileChooser();
+  static {
+    FILE_CHOOSER.setMultiSelectionEnabled(true);
+    FILE_CHOOSER.setFileSelectionMode(JFileChooser.FILES_ONLY);
+  }
+  
+  protected MailAddressesPanel addresses;
+//  protected BaseEditor mailEditor;
+  protected MetaphaseEditorPanel mailEditor;
+  protected JLabel attachmentsCaption = new JLabel(MailGUIUtil.R("MailEditorPanel.attachments"));
+  protected FilesTableModel attachmentsTableModel;
+  protected MutableTable attachments;
+ 
+  
+  /**
+   * Creates a new panel.
+   * @param showFrom indicates whether field for FROM address is shown
+   * @param showTo   indicates whether field for TO address is shown
+   * @param showCC   indicates whether field for CC address is shown
+   * @param showBCC  indicates whether field for BCC address is shown
+   */
+  public MailEditorPanel(boolean showFrom, boolean showTo, boolean showCC, boolean showBCC) {
+    super( new MigLayout("wrap 2","[grow]10[]","[top]") );
+    URL dictURL = getClass().getResource("/dictionary/");
+//    SpellCheckerProxy.registerDictionaries(dictURL, "de,en", "de");
+    
+    addresses = new MailAddressesPanel(showFrom, showTo, showCC, showBCC);
+//    mailEditor = new BaseEditor(true,true,true,true) {
+//      protected void addButtons( List<Component> defaultComponents, List<Component> editComponents, List<Component> formatComponents ) {
+//        super.addButtons( defaultComponents, editComponents, formatComponents );
+//        MailEditorPanel.this.addButtons(defaultComponents, editComponents, formatComponents);
+//      }
+//    };
+    mailEditor = new MetaphaseEditorPanel();
+    attachmentsTableModel = new FilesTableModel();
+    attachments = new MutableTable(attachmentsTableModel, MutableTable.ITEM_ADD | MutableTable.ITEM_REMOVE);
+    attachments.setShowHorizontalLines(false);
+    attachments.setShowVerticalLines(false);
+    attachments.setTableHeader(null);
+    attachments.getColumnModel().getColumn(1).setCellRenderer(new ComponentRenderer(SwingConstants.RIGHT,SwingConstants.CENTER));
+//    SwingUtil.setPreferredWidth(attachments, 150);
+
+//    JPanel attachmentsPanel = new JPanel(new BorderLayout());
+//    attachmentsPanel.add(attachmentsCaption, BorderLayout.NORTH);
+//    attachmentsPanel.add(attachments.createScrollPane(), BorderLayout.CENTER);
+    
+//    JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
+//    split.setLeftComponent(mailEditor);
+//    split.setRightComponent(attachmentsPanel);
+//    split.setResizeWeight(1.0);
+
+//    MultiSplitPane split = new MultiSplitPane(2,JSplitPane.HORIZONTAL_SPLIT);
+//    split.setContainer(0, new JPanel(new BorderLayout()));
+//    split.setContainer(1, new JPanel(new BorderLayout()));
+//    split.getContainer(1).add(attachmentsCaption, BorderLayout.NORTH);
+//    split.getContainer(1).add(attachments.createScrollPane(), BorderLayout.CENTER);
+//    split.getContainer(0).add(mailEditor, BorderLayout.CENTER);
+//    split.setResizeWeigth( new double[] {0.8,0.2});
+    add(addresses,"span 2, growx");
+    add(mailEditor,"span 1 2, h :2000:, growx, growy");
+    add(attachmentsCaption,"");
+    add(attachments.createScrollPane(),"w :150:, growy");
+//    add(split,"span 2, growx, growy");
+  }
+
+  /**
+   * Does nothing. Can be overridden by sub classes to add or remove tools.
+   */
+  protected void addButtons( List<Component> defaultComponents, List<Component> editComponents, List<Component> formatComponents ) {
+    Action addAttachmentAction = SwingUtil.createAction(MailGUIUtil.R("MailEditorPanel.attachments.add"),
+                                         this,
+                                         "ADD_ATTACHMENT",
+                                         MailGUIUtil.R("MailEditorPanel.attachments.add.desc"),
+                                         SwingUtil.createImageIconFromResourcePath("resource/icons/small/attach.png", null));
+    final JButton sendButton = new JButton(addAttachmentAction);
+    editComponents.add(editComponents.size(),sendButton);
+  }
+
+  /**
+   * Called on editor actions.
+   */
+  @Override
+  public void actionPerformed(ActionEvent e) {
+    String actionID = e.getActionCommand();
+    if ( "ADD_ATTACHMENT".equals(actionID) )
+      performAddAttachment();
+   
+  }
+  
+  protected void performAddAttachment() {
+    if ( FILE_CHOOSER.showSaveDialog(this) != JFileChooser.APPROVE_OPTION )
+      return;
+    File[] files = FILE_CHOOSER.getSelectedFiles();
+    attachmentsTableModel.addFiles(files);
+  }
+  
+  protected class FilesTableModel extends AbstractMutableTableModel {
+
+    List<File> files = new ArrayList<File>();
+    public FilesTableModel() {
+      super();
+    }
+    
+    
+    @Override
+    public String[] createColumnNames() {
+      return new String[] {MailGUIUtil.R("MailEditorPanel.attachments"),
+                           MailGUIUtil.R("MailEditorPanel.attachments.size")};
+    }
+
+    @Override
+    public int getRowCount() {
+      return files.size();
+    }
+
+    public void addFiles(File[] file) {
+      for (File f : file)
+        files.add(f);
+      fireTableDataChanged();
+    }
+
+    public void addFile(File file) {
+      files.add(file);
+      fireTableDataChanged();
+    }
+    
+    @Override
+    public Object getValueAt(int row, int col) {
+      File f = files.get(row);
+      switch (col) {
+        case 0: return f.getName();
+        case 1: return LangUtil.formatFileSize(f.length());
+      }
+      return null;
+    }
+    
+    
+    @Override
+    public void performRemoveRow(int row) {
+      files.remove(row);
+    }
+    
+    @Override
+    public void performChangeData(int row, int col) {
+      // not used
+    }
+    
+    @Override
+    public void performAddRow() {
+      performAddAttachment();
+    }
+    
+  }
+}

Added: trunk/schmitzm-mail/src/main/java/de/schmitzm/net/mail/gui/MailGUIUtil.java
===================================================================
--- trunk/schmitzm-mail/src/main/java/de/schmitzm/net/mail/gui/MailGUIUtil.java	                        (rev 0)
+++ trunk/schmitzm-mail/src/main/java/de/schmitzm/net/mail/gui/MailGUIUtil.java	2012-10-15 12:37:39 UTC (rev 2111)
@@ -0,0 +1,62 @@
+/**
+ * Copyright (c) 2009 Martin O. J. Schmitz.
+ * 
+ * This file is part of the SCHMITZM library - a collection of utility 
+ * classes based on Java 1.6, focusing (not only) on Java Swing 
+ * and the Geotools library.
+ * 
+ * The SCHMITZM project is hosted at:
+ * http://wald.intevation.org/projects/schmitzm/
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License (license.txt)
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ * or try this link: http://www.gnu.org/licenses/lgpl.html
+ * 
+ * Contributors:
+ *     Martin O. J. Schmitz - initial API and implementation
+ *     Stefan A. Tzeggai - additional utility classes
+ */
+package de.schmitzm.net.mail.gui;
+
+import java.util.Locale;
+
+import org.apache.log4j.Logger;
+
+import de.schmitzm.lang.LangUtil;
+import de.schmitzm.lang.ResourceProvider;
+import de.schmitzm.swing.SwingUtil;
+
+/**
+ * Utility methods.
+ * @author Martin O.J. Schmitz
+ */
+public class MailGUIUtil {
+  private static final Logger LOGGER = Logger.getLogger(SwingUtil.class
+                                                        .getClass().getName());
+  /**
+   * {@link ResourceProvider} for the localization of the package
+   * {@code de.schmitzm.net.mail.gui}.
+   */
+  public static ResourceProvider RESOURCE = ResourceProvider.newInstance(
+          LangUtil.extendPackagePath(MailGUIUtil.class,
+                  "resource.locales.MailGUIResourceBundle"), Locale.ENGLISH);
+
+
+  /**
+   * Convenience method to access the translation resources.
+   */
+  public static String R(String key, Object... values) {
+      return RESOURCE.getString(key, values);
+  }
+}

Added: trunk/schmitzm-mail/src/main/resources/de/schmitzm/net/mail/gui/resource/locales/MailGUIResourceBundle.properties
===================================================================
--- trunk/schmitzm-mail/src/main/resources/de/schmitzm/net/mail/gui/resource/locales/MailGUIResourceBundle.properties	                        (rev 0)
+++ trunk/schmitzm-mail/src/main/resources/de/schmitzm/net/mail/gui/resource/locales/MailGUIResourceBundle.properties	2012-10-15 12:37:39 UTC (rev 2111)
@@ -0,0 +1,44 @@
+##########
+#Copyright (c) 2009 Martin O. J. Schmitz.
+#
+#This file is part of the SCHMITZM library - a collection of utility 
+#classes based on Java 1.6, focusing (not only) on Java Swing 
+#and the Geotools library.
+#
+#The SCHMITZM project is hosted at:
+#http://wald.intevation.org/projects/schmitzm/
+#
+#This program is free software; you can redistribute it and/or
+#modify it under the terms of the GNU Lesser General Public License
+#as published by the Free Software Foundation; either version 3
+#of the License, or (at your option) any later version.
+#
+#This program is distributed in the hope that it will be useful,
+#but WITHOUT ANY WARRANTY; without even the implied warranty of
+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#GNU General Public License for more details.
+#
+#You should have received a copy of the GNU Lesser General Public License (license.txt)
+#along with this program; if not, write to the Free Software
+#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+#or try this link: http://www.gnu.org/licenses/lgpl.html
+#
+#Contributors:
+#    Martin O. J. Schmitz - initial API and implementation
+#    Stefan A. Tzeggai - additional utility classes
+##########
+
+# -----------------------------------------------------------
+# ------ Default Translations (english) for components ------
+# ------ in Package de.schmitzm.net.mail               ------
+# -----------------------------------------------------------
+
+MailAddressesPanel.from=From
+MailAddressesPanel.to=To
+MailAddressesPanel.cc=CC
+MailAddressesPanel.bcc=BCC
+MailEditorPanel.attachments=Attachments
+MailEditorPanel.attachments.size=Size
+MailEditorPanel.attachments.add=Attachment
+MailEditorPanel.attachments.add.desc=Add file attachment(s) to mail
+

Added: trunk/schmitzm-mail/src/main/resources/de/schmitzm/net/mail/gui/resource/locales/MailGUIResourceBundle_de.properties
===================================================================
--- trunk/schmitzm-mail/src/main/resources/de/schmitzm/net/mail/gui/resource/locales/MailGUIResourceBundle_de.properties	                        (rev 0)
+++ trunk/schmitzm-mail/src/main/resources/de/schmitzm/net/mail/gui/resource/locales/MailGUIResourceBundle_de.properties	2012-10-15 12:37:39 UTC (rev 2111)
@@ -0,0 +1,42 @@
+##########
+#Copyright (c) 2009 Martin O. J. Schmitz.
+#
+#This file is part of the SCHMITZM library - a collection of utility 
+#classes based on Java 1.6, focusing (not only) on Java Swing 
+#and the Geotools library.
+#
+#The SCHMITZM project is hosted at:
+#http://wald.intevation.org/projects/schmitzm/
+#
+#This program is free software; you can redistribute it and/or
+#modify it under the terms of the GNU Lesser General Public License
+#as published by the Free Software Foundation; either version 3
+#of the License, or (at your option) any later version.
+#
+#This program is distributed in the hope that it will be useful,
+#but WITHOUT ANY WARRANTY; without even the implied warranty of
+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#GNU General Public License for more details.
+#
+#You should have received a copy of the GNU Lesser General Public License (license.txt)
+#along with this program; if not, write to the Free Software
+#Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+#or try this link: http://www.gnu.org/licenses/lgpl.html
+#
+#Contributors:
+#    Martin O. J. Schmitz - initial API and implementation
+#    Stefan A. Tzeggai - additional utility classes
+##########
+
+# ------------------------------------------------
+# ------ German Translations for components ------
+# ------ in Package de.schmitzm.net.mail    ------
+# ------------------------------------------------
+MailAddressesPanel.from=Von
+MailAddressesPanel.to=An
+MailAddressesPanel.cc=Kopie (CC)
+MailAddressesPanel.bcc=Blindkopie (BCC)
+MailEditorPanel.attachments=Anhänge
+MailEditorPanel.attachments.size=Größe
+MailEditorPanel.attachments.add=Anhang
+MailEditorPanel.attachments.add.desc=Datei-Anhang der Mail hinzufügen
\ No newline at end of file

Added: trunk/schmitzm-mail/src/test/java/de/schmitzm/net/mail/gui/MailEditorTest.java
===================================================================
--- trunk/schmitzm-mail/src/test/java/de/schmitzm/net/mail/gui/MailEditorTest.java	                        (rev 0)
+++ trunk/schmitzm-mail/src/test/java/de/schmitzm/net/mail/gui/MailEditorTest.java	2012-10-15 12:37:39 UTC (rev 2111)
@@ -0,0 +1,183 @@
+/**
+ * Copyright (c) 2009 Martin O. J. Schmitz.
+ * 
+ * This file is part of the SCHMITZM library - a collection of utility 
+ * classes based on Java 1.6, focusing (not only) on Java Swing 
+ * and the Geotools library.
+ * 
+ * The SCHMITZM project is hosted at:
+ * http://wald.intevation.org/projects/schmitzm/
+ * 
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation; either version 3
+ * of the License, or (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License (license.txt)
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ * or try this link: http://www.gnu.org/licenses/lgpl.html
+ * 
+ * Contributors:
+ *     Martin O. J. Schmitz - initial API and implementation
+ *     Stefan A. Tzeggai - additional utility classes
+ */
+package de.schmitzm.net.mail.gui;
+
+import java.awt.Dimension;
+import java.net.URL;
+
+import javax.swing.JComponent;
+
+import org.junit.Test;
+
+import com.metaphaseeditor.MetaphaseEditorPanel;
+import com.metaphaseeditor.SpellCheckDictionaryVersion;
+
+import de.schmitzm.testing.TestingClass;
+import de.schmitzm.testing.TestingUtil;
+
+/**
+ * Tests for mail GUI.
+ * @author Martin O.J. Schmitz
+ *
+ */
+public class MailEditorTest extends TestingClass {
+  
+  @Test
+  public void testlMailEditor() throws Throwable {
+    URL dictURL = getClass().getResource("/dictionary/");
+    JComponent gui = null;
+
+////    URL dictURL = IOUtil.fileToURL( new File("C:/Program Files (x86)/Java/jwebenginewithjortho_1.06/"))
+//    SpellCheckerProxy.registerDictionaries(dictURL, "de,en", "de");
+//    gui = new BaseEditor(true,true,true,true) {
+//        class WildCardAction extends AbstractAction {
+//          private String wildcard = "";
+//          public WildCardAction(String title, String wildcard) {
+//            super(title);
+//            this.wildcard = wildcard;
+//          }
+//          @Override
+//          public void actionPerformed(ActionEvent e) {
+//            insertHtml(" "+wildcard);
+//            requestFocus();
+//          }
+//        };
+//
+//        
+//        protected void addButtons( List<Component> defaultComponents, List<Component> editComponents, List<Component> formatComponents ) {
+//          super.addButtons( defaultComponents, editComponents, formatComponents );
+//          // This method is called by the toolbar controller after all buttons have been created
+//          // and before the buttons are added to the GUI.
+//          // Every change on these lists will be persistent and reflected by the GUI(even the order)
+//          // If you want to hide a component, remove it since the visibility is adjusted by the toolbar controller.
+//          
+//          // Example: remove the font family combo box
+//          Iterator<Component> i = formatComponents.iterator();
+////          while( i.hasNext() ){
+////              Component comp = i.next();
+////              System.out.println(comp);
+////              // NOTE: each component which is not a separator has a name which equals one
+////              // of the BaseEditorToolBar.DEFAULT_COMPONENTS enum constant names
+////              if( BaseEditorToolBar.DEFAULT_COMPONENTS.cmbFontFamily.name().equals( comp.getName() ) ){
+////                  i.remove();
+////                  break;
+////              }
+////          }
+//          final JPopupMenu  menu = new JPopupMenu();
+//          menu.add( new WildCardAction("Name", "{{Nachname}}"));
+//          menu.add( new WildCardAction("Vorname", "{{Vorname}}"));
+//          menu.add( new WildCardAction("Anrede", "{{Anrede}}"));
+//          
+//          final JButton wildcardButton = new JButton();
+//          Action insertWildcard = new AbstractAction("InsertWildcard") {
+//            @Override
+//            public void actionPerformed(ActionEvent e) {
+//              menu.show(wildcardButton, 0, wildcardButton.getHeight());
+//            }
+//          };
+//          wildcardButton.setAction(insertWildcard);
+//
+//          Action editImage = new AbstractAction("Edit Image") {
+//            @Override
+//            public void actionPerformed(ActionEvent e) {
+//            }
+//          };
+//          final JButton editImageButton = new JButton(editImage);
+//          
+//          Action send = new AbstractAction("Send") {
+//            @Override
+//            public void actionPerformed(ActionEvent e) {
+//              sendMail();
+//            }
+//          };
+//          final JButton sendButton = new JButton(send);
+//          
+//          formatComponents.add(0,wildcardButton);
+//          formatComponents.add(1,editImageButton);
+//          formatComponents.add(2,sendButton);
+//          
+//          // reorder the remaining format components
+////          Collections.reverse( formatComponents );
+//      }
+//        
+//        private void sendMail() {
+//          getEditor().setSelectionStart(0);
+//          getEditor().setSelectionEnd(0);
+//          BaseEditor tempEditor = new BaseEditor(false);
+//          tempEditor.insertFrom(this);
+//          
+//          System.out.println(getText()+"\n\n");
+//          System.out.println(tempEditor.getText());
+//          
+//          // determine embedded images and replace with "cid:..."
+//          List<File> attachments = new ArrayList<File>();
+//          for (EmbeddedImage i : tempEditor.getEmbeddedImages()) {
+//            try {
+//              URL url = new URL(i.getUrl());
+//              File f = IOUtil.urlToFile(url);
+//              attachments.add(f);
+//              i.setURL("cid:"+f.getName());
+//            } catch (MalformedURLException e1) {
+//              e1.printStackTrace();
+//            }
+//          }
+//          
+//          String recipientsAddress = "mojays at web.de";
+//          String subject = "junit MailUtilTest";
+//          String text    = tempEditor.getText();
+//          String smtpUser = "martin at mojays.de";
+//          String smtpCredential = "@drastE@";
+//          String smtpAuth = "true";
+//          String smtpHost = "smtp.1und1.de";
+//          String mailSenderAddress = "Martin at mojays.de";
+//          File attachment2 = new File("D:/Sonstiges/maibaumverkauf_2012.pdf");
+//          attachments.add(attachment2);
+//          
+//          try {
+//            MailUtil.sendSmtpHtmlMail(recipientsAddress, subject, text, smtpUser,
+//                                      smtpCredential, smtpAuth, smtpHost, mailSenderAddress,
+//                                      attachments.toArray(new File[0]));
+//          } catch (Exception e) {
+//            e.printStackTrace();
+//          }
+//        }
+//
+//      };
+//      
+//      gui = new MailEditorPanel(true, true, true, false);
+      
+      gui = new MetaphaseEditorPanel();
+      ((MetaphaseEditorPanel)gui).setCustomDictionaryFilename("D:/java/MetaphaseEditor/dict_de_de.zip");
+      ((MetaphaseEditorPanel)gui).setDictionaryVersion(SpellCheckDictionaryVersion.CUSTOM );
+      gui.setPreferredSize(new Dimension(800,500));
+      TestingUtil.testGui( gui,-1 );
+  }
+
+}



More information about the Schmitzm-commits mailing list