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.io.IOException;
22: import java.util.HashMap;
23: import java.util.logging.Level;
24:
25: import javax.swing.AbstractAction;
26: import javax.swing.Action;
27:
28: import de.finix.contelligent.client.base.ComponentFactory;
29: import de.finix.contelligent.client.base.ContelligentComponent;
30: import de.finix.contelligent.client.base.Context;
31: import de.finix.contelligent.client.gui.ContelligentAction;
32: import de.finix.contelligent.client.gui.CreateContextOptionPane;
33: import de.finix.contelligent.client.i18n.Resources;
34: import de.finix.contelligent.client.remote.Actions;
35: import de.finix.contelligent.client.remote.RemoteActionException;
36: import de.finix.contelligent.client.util.ExceptionDialog;
37:
38: final public class EditContextACLAction extends AbstractAction
39: implements ContelligentAction {
40: /**
41: *
42: */
43: private final ExplorerEditor editor;
44:
45: public EditContextACLAction(ExplorerEditor editor) {
46: super ("edit_context_acl_action", Resources.editContextIcon);
47: this .editor = editor;
48: putValue(Action.SHORT_DESCRIPTION, "edit_context_acl_action");
49: putValue(TYPE, PUSH_ACTION);
50: putValue(ACTION_TYPE, SERVER_ACTION);
51: putValue(ACTION_GROUP, SERVER_PERMISSION_GROUP);
52: putValue(MENU_TARGET, MENU);
53: }
54:
55: public void actionPerformed(ActionEvent e) {
56: // open editor of the referenced component
57: Context currentContext = ComponentFactory.getInstance()
58: .getCurrentContext();
59: ContelligentComponent aclComponent = currentContext
60: .getComponentForEdit();
61: CreateContextOptionPane createContextOptionPane = new CreateContextOptionPane(
62: aclComponent, false);
63: if (createContextOptionPane.showDialog("") == CreateContextOptionPane.OK_OPTION) {
64: try {
65: String xml = Actions.modifiedComponentToXml(
66: aclComponent, new HashMap());
67: ExplorerEditor.logger.log(Level.FINE,
68: "XML for edited context: " + xml);
69: currentContext.setACL(xml);
70: // XXX should be done by event
71: this .editor.updateActiveActionsCheckingWorkflowAndACL();
72: } catch (IOException ioe) {
73: ExceptionDialog.show(ioe);
74: } catch (RemoteActionException rae) {
75: ExceptionDialog.show(rae);
76: }
77: } else {
78: // On cancel, reload old ACL values, since the AccessEditor always
79: // overwrites these
80: try {
81: currentContext.loadACL();
82: } catch (RemoteActionException rae) {
83: ExceptionDialog.show(rae);
84: }
85: }
86: }
87: }
|