View Javadoc

1   /**
2    * Copyright (C) 2007 Joern Krueger surething@users.sourceforge.net
3    * 
4    * This program is free software; you can redistribute
5    * it and/or modify it under the terms of the GNU General
6    * Public License version 2 as published by the Free Software
7    * Foundation.
8    *
9    * This program is distributed in the hope that it will be
10   * useful, but WITHOUT ANY WARRANTY; without even the implied
11   * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12   * PURPOSE.  See the GNU General Public License for more
13   * details.
14   *
15   * You should have received a copy of the GNU General Public
16   * License along with this program; if not, write to the
17   * Free Software Foundation, Inc., 59 Temple Place,
18   * Suite 330, Boston, MA  02111-1307  USA
19   */
20  package de.surething.lda.actions;
21  
22  import java.util.Set;
23  import java.util.SortedSet;
24  import java.util.TreeSet;
25  
26  import de.surething.lda.resources.Messages;
27  import de.surethingies.properties.Parameter;
28  import de.surethingies.properties.ParameterImpl;
29  import de.surethingies.properties.TypedParameter;
30  import de.surethingies.properties.ValueType;
31  
32  public enum MailActionSettings {
33      
34      DISPLAY_NAME(Messages.getString("MailAction.DisplayName"), "", false, ValueType.STRING),
35      SERVER(Messages.getString("MailAction.Server"), "", true, ValueType.STRING), 
36      USERNAME(Messages.getString("MailAction.Username"), "", true, ValueType.STRING), 
37      SENDER_ADDRESS(Messages.getString("MailAction.SenderAddress"), "", true, ValueType.STRING), 
38      RECIPIENT(Messages.getString("MailAction.Recipient"), "", true, ValueType.STRING), 
39      CC_ADDRESSES(Messages.getString("MailAction.CcAddresses"), "", true, ValueType.STRINGLIST), // TODO:  MultiValueList
40      BCC_ADDRESSES(Messages.getString("MailAction.BccAddresses"), "", true, ValueType.STRINGLIST), // TODO: MultiValueList
41      SUBJECT(Messages.getString("MailAction.Subject"), "", true, ValueType.STRING), 
42      BODY(Messages.getString("MailAction.Body"), "", true, ValueType.TEXT);
43  
44      public static final String GROUP = "mailaction";
45      
46      private final Parameter param;
47  
48      private int order = 0;
49      
50      /**
51       * Initialize
52       */
53      private MailActionSettings( 
54              String displayName, 
55              String defaultValue,
56              boolean isEditable, 
57              ValueType valueType) {
58          
59          param = new ParameterImpl(
60                  GROUP,
61                  this.name(),
62                  displayName,
63                  defaultValue,
64                  isEditable, 
65                  valueType,
66                  order++);    }
67  
68      public Parameter param() {
69          return param;
70      }
71      
72      public static synchronized Set<TypedParameter> getDefaultParameters(String identifier) {
73          Set<TypedParameter> result = new TreeSet<TypedParameter>();
74          
75          for (Parameter parameter: params()) {
76              result.add (new TypedParameter(parameter, identifier, parameter.getDefaultValue()));                
77          }
78          
79          return result;
80      }
81  
82      /**
83       * @return a List of all Parameters of this Type
84       */
85      public static synchronized SortedSet<Parameter> params() {
86          SortedSet<Parameter> result = new TreeSet<Parameter>();
87          
88          for (MailActionSettings settings: values()) {
89              result.add(settings.param);
90          }
91          
92          return result;        
93      }    
94  }