View Javadoc

1   package org.wcb.autohome.util;
2   /***
3    * Copyright (C) 1999  Walter Bogaardt
4    *
5    * This library is free software; you can redistribute it and/or
6    * modify it under the terms of the GNU Lesser General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
10   * This library is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13   * Lesser General Public License for more details.
14   *
15   * You should have received a copy of the GNU Lesser General Public
16   * License along with this library; if not, write to the Free Software
17   * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
18   *
19   *  Project:   Home Automation Interface 
20   *  Filename:  $Id: OpenFileDialog.java,v 1.0 1999/09/14 23:42:04 wbogaardt
21   *
22   */
23  
24  import java.awt.event.ActionListener;
25  import java.awt.event.ActionEvent;
26  import javax.swing.JPopupMenu;
27  import javax.swing.JMenuItem;
28  
29  import org.wcb.autohome.EventsPanel;
30  import org.wcb.autohome.AutoHomeAdminSession;
31  import org.wcb.autohome.interfaces.I18nConstants;
32  
33  public class TablePopup extends JPopupMenu implements ActionListener {
34  
35      private JMenuItem jmiSave, jmiDelete;
36      private EventsPanel stepDad;
37  
38      public TablePopup(EventsPanel daddy){
39          stepDad = daddy;
40          setMenus();
41      }
42  
43      private void setMenus() {
44          jmiSave = new JMenuItem(AutoHomeAdminSession.getInstance().getI18n().getString(I18nConstants.SAVE_MENU));
45          jmiDelete = new JMenuItem(AutoHomeAdminSession.getInstance().getI18n().getString(I18nConstants.DELETE_MENU), AutoHomeAdminSession.DELETE_ROW_ICON);
46          add(jmiSave);
47          add(jmiDelete);
48          jmiSave.addActionListener(this);
49          jmiDelete.addActionListener(this);
50          setVisible(true);
51      }
52  
53      public void actionPerformed(ActionEvent e){
54          Object src = e.getSource();
55          if (src == jmiSave)
56          {
57              saveModule();
58          }
59          if (src == jmiDelete)
60          {
61              deleteModule();
62          }
63      }
64  
65      private void saveModule(){
66          stepDad.saveAllData();
67      }
68  
69      private void deleteModule() {
70          stepDad.deleteRow();
71      }
72  }
73  
74  
75