KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > quickserver > net > qsadmin > gui > SaveActionListener


1 /*
2  * This file is part of the QuickServer library
3  * Copyright (C) 2003-2005 QuickServer.org
4  *
5  * Use, modification, copying and distribution of this software is subject to
6  * the terms and conditions of the GNU Lesser General Public License.
7  * You should have received a copy of the GNU LGP License along with this
8  * library; if not, you can download a copy from <http://www.quickserver.org/>.
9  *
10  * For questions, suggestions, bug-reports, enhancement-requests etc.
11  * visit http://www.quickserver.org
12  *
13  */

14
15 package org.quickserver.net.qsadmin.gui;
16
17 import java.awt.event.ActionListener JavaDoc;
18 import java.awt.event.ActionEvent JavaDoc;
19
20 public class SaveActionListener implements ActionListener JavaDoc {
21     private Propertie propertie;
22     private QSAdminMain qsadminMain;
23
24     public SaveActionListener(QSAdminMain qsadminMain, Propertie propertie) {
25         this.qsadminMain = qsadminMain;
26         this.propertie = propertie;
27     }
28
29     public void actionPerformed(ActionEvent JavaDoc e) {
30         Thread JavaDoc performer = new Thread JavaDoc(new Runnable JavaDoc() {
31             public void run() {
32                 String JavaDoc temp = null;
33                 if(propertie.getType().equals("edit")) {
34                     temp = propertie.getEditField().getText();
35                 } else if(propertie.getType().equals("select")) {
36                     temp = (String JavaDoc)propertie.getComboBox().getSelectedItem();
37                 }
38
39
40                 if(qsadminMain.getServerVersionNo() < propertie.getVersionNo()) {
41                     qsadminMain.getGUI().setResponse("-ERR "+"Host does not support this command");
42                     return;
43                 }
44
45                 try {
46                     temp = qsadminMain.sendCommunicationSilent(
47                         propertie.getSetCommand(temp), false, true);
48                     propertie.getSaveButton().setEnabled(false);
49                 } catch(Exception JavaDoc ex) {
50                     temp = "-ERR Could not set parameter : "+ex.getMessage();
51                 }
52                 if(temp==null) return;
53                 
54                 if(temp.indexOf(" ")==-1) {
55                     qsadminMain.getGUI().setResponse("-ERR "+temp);
56                     return;
57                 }
58                 qsadminMain.getGUI().setResponse(temp);
59             }
60         }, "QsAdminGUI-SaveThread");
61         performer.start();
62     }
63 }
64
Popular Tags