001: /*
002: * Copyright 2001-2006 C:1 Financial Services GmbH
003: *
004: * This software is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License Version 2.1, as published by the Free Software Foundation.
007: *
008: * This software is distributed in the hope that it will be useful,
009: * but WITHOUT ANY WARRANTY; without even the implied warranty of
010: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
011: * Lesser General Public License for more details.
012: *
013: * You should have received a copy of the GNU Lesser General Public
014: * License along with this library; if not, write to the Free Software
015: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
016: */
017:
018: package de.finix.contelligent.client.gui.directory;
019:
020: import java.awt.event.ActionEvent;
021: import java.util.logging.Logger;
022:
023: import javax.swing.AbstractAction;
024: import javax.swing.Action;
025: import javax.swing.JOptionPane;
026:
027: import de.finix.contelligent.client.base.Errors;
028: import de.finix.contelligent.client.base.Type;
029: import de.finix.contelligent.client.gui.ContelligentAction;
030: import de.finix.contelligent.client.i18n.Resources;
031: import de.finix.contelligent.client.remote.ActionResult;
032: import de.finix.contelligent.client.remote.Actions;
033: import de.finix.contelligent.client.remote.RemoteActionException;
034: import de.finix.contelligent.client.util.ExceptionDialog;
035: import de.finix.contelligent.client.util.StringOptionPane;
036:
037: public class PagesFolderEditor extends FolderEditor {
038:
039: private static Logger logger = Logger
040: .getLogger(PagesFolderEditor.class.getName());
041:
042: private final static Object[] YES_CANCEL_OPTIONS = {
043: Resources.getLocalString("yes"),
044: Resources.getLocalString("cancel") };
045:
046: private CreatePageAction createPageAction = new CreatePageAction();
047:
048: private CreatePagesFolderAction createPagesFolderAction = new CreatePagesFolderAction();
049:
050: public class CreatePageAction extends AbstractAction implements
051: ContelligentAction {
052: public CreatePageAction() {
053: super ("create_page_action", Resources.createPageIcon);
054: putValue(ROLLOVER_ICON, Resources.createPageRollOver);
055: putValue(TYPE, PUSH_ACTION);
056: putValue(ACTION_TYPE, NAVIGATION_ACTION);
057: putValue(MENU_TARGET, MENU);
058: putValue(BUTTON_TARGET, TOOLBAR);
059: }
060:
061: public void actionPerformed(ActionEvent e) {
062:
063: }
064: }
065:
066: public class CreatePagesFolderAction extends AbstractAction
067: implements ContelligentAction {
068: public CreatePagesFolderAction() {
069: super ("create_page_folder_action",
070: Resources.createPagesFolderIcon);
071: putValue(ROLLOVER_ICON, Resources.createPagesFolderRollOver);
072: putValue(TYPE, PUSH_ACTION);
073: putValue(ACTION_TYPE, NAVIGATION_ACTION);
074: putValue(MENU_TARGET, MENU);
075: putValue(BUTTON_TARGET, TOOLBAR);
076: }
077:
078: public void actionPerformed(ActionEvent e) {
079: StringOptionPane folderOptionPane = new StringOptionPane();
080: if (folderOptionPane.showStringDialog(Resources
081: .getLocalString("create_folder"), Resources
082: .getLocalString("enter_folder_name"), "") == StringOptionPane.OK_OPTION) {
083: String name = folderOptionPane.getText();
084: try {
085: if (name != null && name.length() > 0) {
086: ActionResult response = Actions.createFromType(
087: getView().getEnvironment(),
088: Type.PAGES_FOLDER, name, getComponent()
089: .getPath()
090: + "/", false);
091:
092: if (response.hasError(Errors.COMPONENT_EXISTS)) {
093: if (JOptionPane
094: .showOptionDialog(
095: PagesFolderEditor.this
096: .getParent(),
097: Resources
098: .getLocalString("component_exists_override"),
099: Resources
100: .getLocalString("component_exists"),
101: JOptionPane.YES_NO_OPTION,
102: JOptionPane.WARNING_MESSAGE,
103: null, YES_CANCEL_OPTIONS,
104: YES_CANCEL_OPTIONS[0]) == JOptionPane.YES_OPTION) {
105: response = Actions.createFromType(
106: getView().getEnvironment(),
107: Type.PAGES_FOLDER, name,
108: getComponent().getPath() + "/",
109: true);
110: }
111: }
112:
113: response.showErrors();
114: }
115: } catch (RemoteActionException rae) {
116: ExceptionDialog.show(rae);
117: }
118: }
119: }
120: }
121:
122: public Action[] getActions() {
123: return new Action[] { createPageAction, createPagesFolderAction };
124: }
125: }
|