2
* FreeMind - A Program for creating and viewing Mindmaps Copyright (C)
3
* 2000-2004 Joerg Mueller, Daniel Polansky, Christian Foltin and others.
5
* See COPYING for Details
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
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
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.
21
* Created on 25.08.2004
23
/* $Id: UnderlinedAction.java,v 1.1.2.2.2.4 2008/01/13 20:55:35 christianfoltin Exp $ */
24
package freemind.modes.mindmapmode.actions;
26
import javax.swing.Action;
27
import javax.swing.JMenuItem;
29
import freemind.controller.MenuItemSelectedListener;
30
import freemind.controller.actions.generated.instance.UnderlinedNodeAction;
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;
39
public class UnderlinedAction extends NodeGeneralAction implements NodeActorXml, MenuItemSelectedListener{
40
private final MindMapController modeController;
43
public UnderlinedAction(MindMapController modeController) {
44
super(modeController, "underlined", "images/Underline24.gif");
45
this.modeController = modeController;
49
public void act(XmlAction action) {
50
UnderlinedNodeAction underlinedact = (UnderlinedNodeAction) action;
51
NodeAdapter node = getNodeFromID(underlinedact.getNode());
52
if(node.isUnderlined() != underlinedact.getUnderlined()) {
53
node.setUnderlined(underlinedact.getUnderlined());
54
this.modeController.nodeChanged(node);
59
public Class getDoActionClass() {
60
return UnderlinedNodeAction.class;
63
public ActionPair apply(MindMap model, MindMapNode selected) {
64
// every node is set to the inverse of the focussed node.
65
boolean underlined = modeController.getSelected().isUnderlined();
66
return getActionPair(selected, underlined);
69
private ActionPair getActionPair(MindMapNode selected, boolean underlined)
71
UnderlinedNodeAction underlinedAction = toggleUnderlined(selected, !underlined);
72
UnderlinedNodeAction undoUnderlinedAction = toggleUnderlined(selected, underlined);
73
return new ActionPair(underlinedAction, undoUnderlinedAction);
76
private UnderlinedNodeAction toggleUnderlined(MindMapNode selected, boolean underlined)
78
UnderlinedNodeAction underlinedAction = new UnderlinedNodeAction();
79
underlinedAction.setNode(getNodeID(selected));
80
underlinedAction.setUnderlined(underlined);
81
return underlinedAction;
84
public void setUnderlined(MindMapNode node, boolean underlined) {
85
execute(getActionPair(node, underlined));
88
public boolean isSelected(JMenuItem item, Action action) {
89
return modeController.getSelected().isUnderlined();