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