~adrian-wilkins/ubuntu/quantal/freemind/fix-file-association

« back to all changes in this revision

Viewing changes to freemind/freemind/modes/mindmapmode/actions/RemoveAllIconsAction.java

  • Committer: Bazaar Package Importer
  • Author(s): Benjamin Drung
  • Date: 2010-01-03 14:19:19 UTC
  • mfrom: (2.1.1 sid)
  • Revision ID: james.westby@ubuntu.com-20100103141919-m5az7dkicy21hqop
Tags: 0.9.0~rc6+dfsg-1ubuntu1
* Merge from Debian unstable (LP: #182927), remaining changes:
  - debian/copyright: add license/copyright for
    freemind/freemind/main/ExampleFileFilter.java

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*FreeMind - A Program for creating and viewing Mindmaps
 
2
 *Copyright (C) 2000-2004  Joerg Mueller, Daniel Polansky, Christian Foltin and others.
 
3
 *
 
4
 *See COPYING for Details
 
5
 *
 
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.
 
10
 *
 
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.
 
15
 *
 
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.
 
19
 *
 
20
 * Created on 29.09.2004
 
21
 */
 
22
/* $Id: RemoveAllIconsAction.java,v 1.1.2.2.2.7 2008/04/10 20:49:21 dpolivaev Exp $ */
 
23
 
 
24
package freemind.modes.mindmapmode.actions;
 
25
 
 
26
import java.awt.event.KeyEvent;
 
27
import java.io.ObjectInputStream.GetField;
 
28
import java.util.Iterator;
 
29
 
 
30
import javax.swing.Action;
 
31
import javax.swing.ImageIcon;
 
32
import javax.swing.KeyStroke;
 
33
 
 
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;
 
45
 
 
46
/**
 
47
 * @author foltin
 
48
 *
 
49
 */
 
50
public class RemoveAllIconsAction extends NodeGeneralAction implements NodeActorXml , IconInformation{
 
51
 
 
52
    private final IconAction addIconAction;
 
53
 
 
54
    /**
 
55
     */
 
56
    public RemoveAllIconsAction(MindMapController modeController, IconAction addIconAction) {
 
57
        super(modeController, "remove_all_icons", "images/edittrash.png");
 
58
        this.addIconAction = addIconAction;
 
59
        addActor(this);
 
60
    }
 
61
 
 
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));
 
67
        }
 
68
        return new ActionPair(createRemoveAllIconsXmlAction(selected), undoAction);
 
69
    }
 
70
 
 
71
    public RemoveAllIconsXmlAction createRemoveAllIconsXmlAction(MindMapNode node)  {
 
72
        RemoveAllIconsXmlAction action = new RemoveAllIconsXmlAction();
 
73
        action.setNode(node.getObjectId(modeController));
 
74
        return action;
 
75
    }
 
76
 
 
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);
 
83
            }
 
84
            modeController.nodeChanged(node);
 
85
        }
 
86
    }
 
87
 
 
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));
 
95
    }
 
96
 
 
97
    public Class getDoActionClass() {
 
98
        return RemoveAllIconsXmlAction.class;
 
99
    }
 
100
 
 
101
        public String getDescription() {
 
102
                return (String)getValue(Action.SHORT_DESCRIPTION);
 
103
        }
 
104
 
 
105
        public ImageIcon getIcon() {
 
106
                return (ImageIcon)getValue(Action.SMALL_ICON);
 
107
        }
 
108
 
 
109
        public KeyStroke getKeyStroke() {
 
110
                return Tools.getKeyStroke(getMindMapController().getFrame().getAdjustableProperty(getKeystrokeResourceName()));
 
111
        }
 
112
 
 
113
        public String getKeystrokeResourceName() {
 
114
                return "keystroke_remove_all_icons";
 
115
        }
 
116
}