View Javadoc

1   /*
2   Copyright (C) 2000 - 2007 Grid Systems, S.A.
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, version 2, as
6   published by the Free Software Foundation.
7   
8   This program is distributed in the hope that it will be useful,
9   but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  GNU General Public License for more details.
12  
13  You should have received a copy of the GNU General Public License
14  along with this program; if not, write to the Free Software
15  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16  */
17  
18  /*
19   * Project: KernelConfigurator
20   * Created on 08-oct-2004
21   *
22   * Copyright (c)2004 Grid Systems
23   */
24  package com.gridsystems.config.modules.tomcat;
25  
26  import java.util.ArrayList;
27  import java.util.Iterator;
28  import java.util.List;
29  import java.util.ResourceBundle;
30  
31  import com.gridsystems.config.ConsoleConfiguratorView;
32  import com.gridsystems.config.tools.console.ConsoleViewAction;
33  import com.gridsystems.config.tools.console.GroupField;
34  
35  /**
36   * Type description.
37   *
38   * @author <a href="mailto:rruiz@gridsystems.com">Rodrigo Ruiz Aguayo</a>
39   * @version 1.0
40   */
41  public class ConnectorGroupField extends GroupField implements ConsoleViewAction {
42  
43    /**
44     * Key map for the group.
45     */
46    private String keyMapping = "";
47  
48    /**
49     * Creates a new instance.
50     *
51     * @param bundle  for i18n
52     */
53    public ConnectorGroupField(ResourceBundle bundle) {
54      super(bundle, "fldConnectorTitle");
55      this.keyMapping = bundle.getString("fldConnectorsList.keyMap");
56    }
57  
58    /**
59     * Adds itself to the list returned by the superclass.
60     *
61     * {@inheritDoc}
62     */
63    public List<ConsoleViewAction> getActionList() {
64      List<ConsoleViewAction> list = super.getActionList();
65      list.add(this);
66      return list;
67    }
68  
69    /**
70     * Gets the list of connectors in this group.
71     *
72     * @return  an array containing all connectors in this group
73     */
74    public Connector[] getConnectors() {
75      ArrayList<Connector> list = new ArrayList<Connector>();
76      for (Iterator it = fields.iterator(); it.hasNext();) {
77        ConnectorField cf = (ConnectorField)it.next();
78        Connector c = cf.getConnector();
79        list.add(c);
80      }
81      Connector[] cc = new Connector[list.size()];
82      list.toArray(cc);
83      return cc;
84    }
85  
86    /**
87     * {@inheritDoc}
88     */
89    public String getKeyMapping() {
90      return this.keyMapping;
91    }
92  
93    /**
94     * {@inheritDoc}
95     */
96    public boolean execute(ConsoleConfiguratorView view) {
97      TomcatConsoleView tcv = (TomcatConsoleView)view;
98      tcv.addConnector();
99      return true;
100   }
101 
102 }