01: /*
02: * Copyright 2001-2006 C:1 Financial Services GmbH
03: *
04: * This software is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License Version 2.1, as published by the Free Software Foundation.
07: *
08: * This software is distributed in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11: * Lesser General Public License for more details.
12: *
13: * You should have received a copy of the GNU Lesser General Public
14: * License along with this library; if not, write to the Free Software
15: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
16: */
17:
18: package de.finix.contelligent.client.gui.explorer;
19:
20: import java.awt.event.ActionEvent;
21: import java.util.logging.Level;
22:
23: import javax.swing.AbstractAction;
24: import javax.swing.tree.DefaultMutableTreeNode;
25:
26: import de.finix.contelligent.client.base.ComponentNotFoundException;
27: import de.finix.contelligent.client.base.ComponentReference;
28: import de.finix.contelligent.client.base.ContelligentComponent;
29: import de.finix.contelligent.client.gui.ContelligentAction;
30: import de.finix.contelligent.client.gui.text.StringOptionPane;
31: import de.finix.contelligent.client.i18n.Resources;
32: import de.finix.contelligent.client.remote.ActionResult;
33: import de.finix.contelligent.client.remote.Actions;
34: import de.finix.contelligent.client.remote.RemoteActionException;
35: import de.finix.contelligent.client.util.ExceptionDialog;
36:
37: public class ExportSubtreeAction extends AbstractAction implements
38: ContelligentAction {
39: /**
40: *
41: */
42: private final ExplorerEditor editor;
43:
44: public ExportSubtreeAction(ExplorerEditor editor) {
45: super ("export_action", Resources.exportSubtreeIcon);
46: this .editor = editor;
47: putValue(ROLLOVER_ICON, Resources.exportSubtreeIconRollOver);
48: putValue(TYPE, PUSH_ACTION);
49: putValue(ACTION_TYPE, FILE_ACTION);
50: putValue(ACTION_GROUP, FILE_COMPONENT_GROUP);
51: putValue(ACTION_POS, FILE_COMPONENT_EXPORT);
52: putValue(MENU_TARGET, MENU);
53: putValue(BUTTON_TARGET, NO_BUTTON);
54: }
55:
56: public void actionPerformed(ActionEvent e) {
57: DefaultMutableTreeNode node = (DefaultMutableTreeNode) this .editor.tree
58: .getLastSelectedPathComponent();
59: if (node != null
60: && node.getUserObject() instanceof ComponentReference) {
61: try {
62: // delete profile from objects
63: ContelligentComponent exportComponent = ((ComponentReference) node
64: .getUserObject()).getComponent();
65:
66: // ask for the filename
67: String filename = exportComponent.getName() + ".xml";
68: StringOptionPane stringOptionPane = new StringOptionPane();
69: if (stringOptionPane.showStringDialog(Resources
70: .getLocalString("export_component"), Resources
71: .getLocalString("enter_name_export_file")
72: + ":", filename) == StringOptionPane.OK_OPTION) {
73: filename = stringOptionPane.getText();
74: if (filename.length() > 0) {
75: ActionResult result = Actions.export(editor
76: .getView().getEnvironment(),
77: exportComponent.getName(),
78: exportComponent.getDir(), filename);
79: result.showErrors();
80: }
81: }
82: } catch (RemoteActionException rae) {
83: ExceptionDialog.show(rae);
84: } catch (ComponentNotFoundException cnfe) {
85: ExplorerEditor.logger.log(Level.SEVERE,
86: "Error in export", cnfe);
87: }
88: }
89: }
90: }
|