1
/*FreeMind - A Program for creating and viewing Mindmaps
2
*Copyright (C) 2000-2004 Joerg Mueller, Daniel Polansky, Christian Foltin and others.
4
*See COPYING for Details
6
*This program is free software; you can redistribute it and/or
7
*modify it under the terms of the GNU General Public License
8
*as published by the Free Software Foundation; either version 2
9
*of the License, or (at your option) any later version.
11
*This program is distributed in the hope that it will be useful,
12
*but WITHOUT ANY WARRANTY; without even the implied warranty of
13
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
*GNU General Public License for more details.
16
*You should have received a copy of the GNU General Public License
17
*along with this program; if not, write to the Free Software
18
*Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
* Created on 29.09.2004
22
/* $Id: RemoveAllIconsAction.java,v 1.1.2.2.2.7 2008/04/10 20:49:21 dpolivaev Exp $ */
24
package freemind.modes.mindmapmode.actions;
26
import java.awt.event.KeyEvent;
27
import java.io.ObjectInputStream.GetField;
28
import java.util.Iterator;
30
import javax.swing.Action;
31
import javax.swing.ImageIcon;
32
import javax.swing.KeyStroke;
34
import freemind.controller.actions.generated.instance.CompoundAction;
35
import freemind.controller.actions.generated.instance.RemoveAllIconsXmlAction;
36
import freemind.controller.actions.generated.instance.XmlAction;
37
import freemind.main.Resources;
38
import freemind.main.Tools;
39
import freemind.modes.IconInformation;
40
import freemind.modes.MindIcon;
41
import freemind.modes.MindMap;
42
import freemind.modes.MindMapNode;
43
import freemind.modes.mindmapmode.MindMapController;
44
import freemind.modes.mindmapmode.actions.xml.ActionPair;
50
public class RemoveAllIconsAction extends NodeGeneralAction implements NodeActorXml , IconInformation{
52
private final IconAction addIconAction;
56
public RemoveAllIconsAction(MindMapController modeController, IconAction addIconAction) {
57
super(modeController, "remove_all_icons", "images/edittrash.png");
58
this.addIconAction = addIconAction;
62
public ActionPair apply(MindMap model, MindMapNode selected) {
63
CompoundAction undoAction = new CompoundAction();
64
for (Iterator i = selected.getIcons().iterator(); i.hasNext();) {
65
MindIcon icon = (MindIcon) i.next();
66
undoAction.addChoice(addIconAction.createAddIconAction(selected, icon, MindIcon.LAST));
68
return new ActionPair(createRemoveAllIconsXmlAction(selected), undoAction);
71
public RemoveAllIconsXmlAction createRemoveAllIconsXmlAction(MindMapNode node) {
72
RemoveAllIconsXmlAction action = new RemoveAllIconsXmlAction();
73
action.setNode(node.getObjectId(modeController));
77
public void act(XmlAction action) {
78
if (action instanceof RemoveAllIconsXmlAction) {
79
RemoveAllIconsXmlAction removeAction = (RemoveAllIconsXmlAction) action;
80
MindMapNode node = modeController.getNodeFromID(removeAction.getNode());
81
while(node.getIcons().size()>0) {
82
node.removeIcon(MindIcon.LAST);
84
modeController.nodeChanged(node);
88
public void removeAllIcons(MindMapNode node) {
89
modeController.getActionFactory().startTransaction(
90
(String) getValue(NAME));
91
modeController.getActionFactory().executeAction(
92
apply(modeController.getMap(), node));
93
modeController.getActionFactory().endTransaction(
94
(String) getValue(NAME));
97
public Class getDoActionClass() {
98
return RemoveAllIconsXmlAction.class;
101
public String getDescription() {
102
return (String)getValue(Action.SHORT_DESCRIPTION);
105
public ImageIcon getIcon() {
106
return (ImageIcon)getValue(Action.SMALL_ICON);
109
public KeyStroke getKeyStroke() {
110
return Tools.getKeyStroke(getMindMapController().getFrame().getAdjustableProperty(getKeystrokeResourceName()));
113
public String getKeystrokeResourceName() {
114
return "keystroke_remove_all_icons";