01: package net.sourceforge.squirrel_sql.client.session.action;
02:
03: /*
04: * Copyright (C) 2003 Colin Bell
05: * colbell@users.sourceforge.net
06: *
07: * This library is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU Lesser General Public
09: * License as published by the Free Software Foundation; either
10: * version 2.1 of the License, or (at your option) any later version.
11: *
12: * This library is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15: * Lesser General Public License for more details.
16: *
17: * You should have received a copy of the GNU Lesser General Public
18: * License along with this library; if not, write to the Free Software
19: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20: */
21: import java.awt.event.ActionEvent;
22:
23: import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
24: import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
25:
26: import net.sourceforge.squirrel_sql.client.IApplication;
27: import net.sourceforge.squirrel_sql.client.action.SquirrelAction;
28: import net.sourceforge.squirrel_sql.client.session.IObjectTreeAPI;
29:
30: /**
31: * This <CODE>Action</CODE> will copy the simple object names of all objects
32: * currently in the object tree and place on the system clipboard.
33: *
34: * @author <A HREF="mailto:colbell@users.sourceforge.net">Colin Bell</A>
35: */
36: public class CopySimpleObjectNameAction extends SquirrelAction
37: implements IObjectTreeAction, CopyObjectNameCommand.ICopyTypes {
38: /** Logger for this class. */
39: private final static ILogger s_log = LoggerController
40: .createLogger(CopySimpleObjectNameAction.class);
41:
42: /** API for the current tree. */
43: private IObjectTreeAPI _tree;
44:
45: /**
46: * Ctor.
47: *
48: * @param app Application API.
49: */
50: public CopySimpleObjectNameAction(IApplication app) {
51: super (app);
52: }
53:
54: /**
55: * Set the current object tree API.
56: *
57: * @param tree Current ObjectTree
58: */
59: public void setObjectTree(IObjectTreeAPI tree) {
60: _tree = tree;
61: setEnabled(null != _tree);
62: }
63:
64: /**
65: * Perform this action. Use the <TT>CopyObjectNameCommand</TT>.
66: *
67: * @param evt The current event.
68: */
69: public void actionPerformed(ActionEvent evt) {
70: if (_tree != null) {
71: try {
72: new CopyObjectNameCommand(_tree, SIMPLE_NAME).execute();
73: } catch (Throwable ex) {
74: final String msg = "Error occured copying object names";
75: _tree.getSession().showErrorMessage(msg + ": " + ex);
76: s_log.error(msg, ex);
77: }
78: }
79: }
80: }
|