Source code: com/fm/gui/action/createCategoryAction.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.fmCategoryTree;
15 import com.fm.gui.fmCategoryDialog;
16
17 import javax.swing.AbstractAction;
18 import javax.swing.KeyStroke;
19
20 import java.awt.event.ActionEvent;
21 import java.awt.event.KeyEvent;
22 import java.awt.Point;
23
24
25 /**
26 * Create category action.
27 *
28 * Displays create category dialog proceeds ac
29 */
30 public class createCategoryAction extends AbstractAction {
31
32 private fmCategoryTree categoryTree;
33
34 /**
35 * Default constructor
36 *
37 * @param catTree tree of categories to insert node into
38 */
39 public createCategoryAction (fmCategoryTree catTree)
40 {
41 super();
42
43 categoryTree = catTree;
44
45 putValue(NAME, fmUITheme.getLocalizedStrings().getString("action.create_folder"));
46 putValue(ACCELERATOR_KEY,
47 KeyStroke.getKeyStroke(
48 KeyEvent.VK_N, ActionEvent.CTRL_MASK | ActionEvent.ALT_MASK));
49 }
50
51 /**
52 * Invoked when an action occurs.
53 */
54 public void actionPerformed(ActionEvent e)
55 {
56 fmCategoryDialog createCatDialog = new fmCategoryDialog(null);
57
58 Point p = null;
59 p = new Point(categoryTree.getLocationOnScreen());
60 p.x += categoryTree.getSize().width / 2;
61 createCatDialog.setLocation(p);
62
63 createCatDialog.showCreateDialog(categoryTree);
64 }
65
66
67 }