Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/fm/gui/action/createChannelAction.java


1   /****************************************************************************
2    * Copyright (c) 2003 Andrew Duka | aduka@users.sourceforge.net
3    * All right reserved.
4    *
5    * This program 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.1 of the License, or (at your option) any later version.
9    *
10   ****************************************************************************/
11  package com.fm.gui.action;
12  
13  import com.fm.gui.fmUITheme;
14  import com.fm.gui.fmCreateChannelDialog;
15  
16  
17  import javax.swing.AbstractAction;
18  import javax.swing.JFrame;
19  import javax.swing.ImageIcon;
20  import javax.swing.KeyStroke;
21  
22  import javax.swing.tree.TreeModel;
23  import java.awt.event.ActionEvent;
24  import java.awt.event.KeyEvent;
25  
26  /**
27   */
28  public class createChannelAction extends AbstractAction
29  {
30      private fmCreateChannelDialog createDialog;
31      private TreeModel modelToPass;
32      private JFrame    parentFrame;
33  
34      /**
35       * For iconized buttons (e.g. toolbar buttons) without text
36       *
37       * @param parent parent frame
38       * @param icon  Icon to use
39       * @param m TreeModel of parent category tree
40       */
41      public createChannelAction(JFrame parent, ImageIcon icon, TreeModel m)
42      {
43          super();
44  
45          putValue(ACCELERATOR_KEY,
46                        KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
47  
48          putValue(SHORT_DESCRIPTION,
49                        fmUITheme.getLocalizedStrings().getString("action.create_channel.tooltip"));
50  
51          putValue(SMALL_ICON, icon);
52  
53          modelToPass = m;
54          parentFrame = parent;
55      }
56  
57      public createChannelAction(JFrame parent, TreeModel m)
58      {
59          super();
60  
61          putValue(NAME,
62                        fmUITheme.getLocalizedStrings().getString("action.create_channel"));
63  
64          putValue(ACCELERATOR_KEY,
65                        KeyStroke.getKeyStroke(KeyEvent.VK_N, ActionEvent.CTRL_MASK));
66  
67          putValue(SHORT_DESCRIPTION,
68                        fmUITheme.getLocalizedStrings().getString("action.create_channel.tooltip"));
69  
70          modelToPass = m;
71          parentFrame = parent;
72      }
73  
74      /**
75       * Invoked when an action occurs.
76       */
77      public void actionPerformed(ActionEvent e)
78      {
79          createDialog = new fmCreateChannelDialog(parentFrame, modelToPass);
80          createDialog.pack();
81          createDialog.setVisible(true);
82      }
83  
84  }