1 /* 2 * $HeadURL: https://mindtreeinsight.svn.sourceforge.net/svnroot/mindtreeinsight/insight/insight-ui/trunk/src/main/java/com/mindtree/techworks/insight/gui/action/ScrollLockAction.java $ 3 * $Date: 2007-12-16 05:20:57 -0700 (Sun, 16 Dec 2007) $ 4 * $Revision: 30 $ 5 * $Author: bindul $ 6 * 7 * Copyright (c) 2005 MindTree Consulting Ltd. 8 * 9 * This file is part of Insight. 10 * 11 * Insight is free software: you can redistribute it and/or modify it under the 12 * terms of the GNU General Public License as published by the Free Software 13 * Foundation, either version 3 of the License, or (at your option) any later 14 * version. 15 * 16 * Insight is distributed in the hope that it will be useful, but 17 * WITHOUT ANY WARRANTY; without even the implied warranty of 18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 19 * Public License for more details. 20 * 21 * You should have received a copy of the GNU General Public License along with 22 * Insight. If not, see <http://www.gnu.org/licenses/>. 23 */ 24 package com.mindtree.techworks.insight.gui.action; 25 26 import java.awt.event.ActionEvent; 27 28 import javax.swing.AbstractAction; 29 30 import com.mindtree.techworks.insight.Controller; 31 import com.mindtree.techworks.insight.InsightConstants; 32 import com.mindtree.techworks.insight.ResourceManager; 33 import com.mindtree.techworks.insight.gui.widgets.InsightToolbarButton; 34 35 /** 36 * 37 * The <code>ScrollLockAction</code> class is an AbstractAction derivative that 38 * controls the scrolling behavior of the EventListPresentation 39 * 40 * @author Regunath B 41 * @version 1.0, 05/08/02 42 * 43 */ 44 45 public class ScrollLockAction extends AbstractAction { 46 47 /** 48 * SVUID 49 */ 50 private static final long serialVersionUID = -1576214815624797300L; 51 52 /** 53 * The Controller instance 54 */ 55 private Controller controller; 56 57 /** 58 * The InsightToolbarButton whose image and tooltip needs to be toggled 59 * when the scroll display is locked/unlocked 60 */ 61 private InsightToolbarButton scrollButton; 62 63 /** 64 * Constructor for this class 65 * @param controller the Insight that created an instance of this class 66 */ 67 public ScrollLockAction(Controller controller) { 68 this.controller = controller; 69 } 70 71 /** 72 * Overriden super class method. Resets the display widgets. 73 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) 74 */ 75 public void actionPerformed(ActionEvent e) { 76 boolean isScrollLock = this.controller.isScrollLock(); 77 ResourceManager rm = ResourceManager.getInstance(); 78 this.scrollButton.setIconAndToolTip ( 79 isScrollLock ? rm.loadImageIcon("UNLOCK_ICON") 80 : rm.loadImageIcon("LOCK_ICON"), 81 isScrollLock ? InsightConstants 82 .getLiteral ("SCROLL_LOCK_TOOL_TIP") 83 : InsightConstants 84 .getLiteral ("SCROLL_UNLOCK_TOOL_TIP")); 85 boolean newScrollLockStatus = !isScrollLock; 86 this.controller.setScrollLock(newScrollLockStatus); 87 } 88 /** 89 * @param scrollButton The scrollButton to set. 90 */ 91 public void setScrollButton(InsightToolbarButton scrollButton) { 92 this.scrollButton = scrollButton; 93 } 94 }