PageRenderTime 284ms CodeModel.GetById 120ms app.highlight 4ms RepoModel.GetById 97ms app.codeStats 0ms

/src/mpv5/ui/menus/ClipboardMenuItem.java

http://mp-rechnungs-und-kundenverwaltung.googlecode.com/
Java | 63 lines | 31 code | 9 blank | 23 comment | 0 complexity | 0e9d3b2a67874fb3f0298c297e0399a0 MD5 | raw file
 1/*
 2 *  This file is part of YaBS.
 3 *
 4 *      YaBS is free software: you can redistribute it and/or modify
 5 *      it under the terms of the GNU General Public License as published by
 6 *      the Free Software Foundation, either version 3 of the License, or
 7 *      (at your option) any later version.
 8 *
 9 *      YaBS is distributed in the hope that it will be useful,
10 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
11 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 *      GNU General Public License for more details.
13 *
14 *      You should have received a copy of the GNU General Public License
15 *      along with YaBS.  If not, see <http://www.gnu.org/licenses/>.
16 */
17package mpv5.ui.menus;
18
19import javax.swing.JMenuItem;
20import mpv5.db.common.DatabaseObject;
21import mpv5.ui.frames.MPView;
22
23/**
24 *
25 *  
26 */
27public class ClipboardMenuItem extends JMenuItem {
28
29    private static final long serialVersionUID = 1L;
30    private DatabaseObject item;
31
32    public ClipboardMenuItem(final DatabaseObject dbo) {
33        this.item = dbo;
34        this.setText(dbo.toString());
35        this.setIcon(dbo.getIcon());
36
37        addActionListener(new java.awt.event.ActionListener() {
38
39            @Override
40            public void actionPerformed(java.awt.event.ActionEvent evt) {
41                try {
42                    mpv5.YabsViewProxy.instance().getIdentifierView().getCurrentTab().paste(dbo);
43                } catch (Exception e) {
44                    mpv5.YabsViewProxy.instance().getIdentifierView().addOrShowTab(dbo);
45                }
46            }
47        });
48
49    }
50
51    public ClipboardMenuItem(DatabaseObject dbo, String name) {
52        this.item = dbo;
53        this.setText(name);
54        this.setIcon(dbo.getIcon());
55    }
56
57    /**
58     * @return the item
59     */
60    public DatabaseObject getItem() {
61        return item;
62    }
63}