~ubuntu-branches/ubuntu/utopic/freemind/utopic

« back to all changes in this revision

Viewing changes to freemind/freemind/modes/mindmapmode/actions/ItalicAction.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
/*
 
2
 * FreeMind - A Program for creating and viewing Mindmaps Copyright (C)
 
3
 * 2000-2004 Joerg Mueller, Daniel Polansky, Christian Foltin and others.
 
4
 * 
 
5
 * See COPYING for Details
 
6
 * 
 
7
 * This program is free software; you can redistribute it and/or modify it under
 
8
 * the terms of the GNU General Public License as published by the Free Software
 
9
 * Foundation; either version 2 of the License, or (at your option) any later
 
10
 * version.
 
11
 * 
 
12
 * This program is distributed in the hope that it will be useful, but WITHOUT
 
13
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 
14
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 
15
 * details.
 
16
 * 
 
17
 * You should have received a copy of the GNU General Public License along with
 
18
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 
19
 * Place - Suite 330, Boston, MA 02111-1307, USA.
 
20
 * 
 
21
 * Created on 25.08.2004
 
22
 */
 
23
/* $Id: ItalicAction.java,v 1.1.2.2.2.4 2008/01/13 20:55:35 christianfoltin Exp $ */
 
24
package freemind.modes.mindmapmode.actions;
 
25
 
 
26
import javax.swing.Action;
 
27
import javax.swing.JMenuItem;
 
28
 
 
29
import freemind.controller.MenuItemSelectedListener;
 
30
import freemind.controller.actions.generated.instance.ItalicNodeAction;
 
31
import freemind.controller.actions.generated.instance.XmlAction;
 
32
import freemind.modes.MindMap;
 
33
import freemind.modes.MindMapNode;
 
34
import freemind.modes.NodeAdapter;
 
35
import freemind.modes.mindmapmode.MindMapController;
 
36
import freemind.modes.mindmapmode.actions.xml.ActionPair;
 
37
 
 
38
 
 
39
public class ItalicAction extends NodeGeneralAction implements NodeActorXml, MenuItemSelectedListener{
 
40
        private final MindMapController modeController;
 
41
        /**
 
42
         */
 
43
        public ItalicAction(MindMapController modeController) {
 
44
                super(modeController, "italic", "images/Italic16.gif");
 
45
                this.modeController = modeController;
 
46
                addActor(this);                 
 
47
        }
 
48
 
 
49
        public void act(XmlAction action) {
 
50
                ItalicNodeAction italicact = (ItalicNodeAction) action;
 
51
                NodeAdapter node = getNodeFromID(italicact.getNode());
 
52
                if(node.isItalic() != italicact.getItalic()) {
 
53
                        node.setItalic(italicact.getItalic());
 
54
                        this.modeController.nodeChanged(node);
 
55
                }
 
56
        }
 
57
 
 
58
 
 
59
        public Class getDoActionClass() {
 
60
                return ItalicNodeAction.class;
 
61
        }
 
62
 
 
63
        public ActionPair apply(MindMap model, MindMapNode selected) {
 
64
                // every node is set to the inverse of the focussed node.
 
65
                boolean italic = modeController.getSelected().isItalic();
 
66
                return getActionPair(selected, !italic);
 
67
        }
 
68
 
 
69
        private ActionPair getActionPair(MindMapNode selected, boolean italic)
 
70
                 {
 
71
                ItalicNodeAction italicAction = toggleItalic(selected, italic);
 
72
                ItalicNodeAction undoItalicAction = toggleItalic(selected, selected.isItalic());
 
73
                return new ActionPair(italicAction, undoItalicAction);
 
74
        }
 
75
 
 
76
        private ItalicNodeAction toggleItalic(MindMapNode selected, boolean italic)
 
77
                 {
 
78
                ItalicNodeAction italicAction = new ItalicNodeAction();
 
79
                italicAction.setNode(getNodeID(selected));
 
80
                italicAction.setItalic(italic);
 
81
                return italicAction;
 
82
        }
 
83
 
 
84
        public void setItalic(MindMapNode node, boolean  italic) {
 
85
                execute(getActionPair(node, italic));
 
86
        }
 
87
 
 
88
    public boolean isSelected(JMenuItem item, Action action) {
 
89
                return modeController.getSelected().isItalic();
 
90
    }
 
91
 
 
92
}