View Javadoc
1 /* 2 * Angkor Web Framework 3 * 4 * Distributable under LGPL license. 5 * See terms of license at gnu.org. 6 */ 7 8 package com.tirsen.angkor.table; 9 10 import com.tirsen.angkor.Debug; 11 import com.tirsen.angkor.RenderContext; 12 import com.tirsen.angkor.event.AbstractAction; 13 import com.tirsen.angkor.event.Action; 14 import com.tirsen.angkor.event.ActionEvent; 15 import com.tirsen.angkor.Component; 16 import com.tirsen.angkor.widget.Link; 17 import org.apache.log4j.Category; 18 19 import java.io.IOException; 20 21 /*** 22 * @author $Author: tirsen $ 23 * @version $Revision: 1.6 $ 24 * <BR> 25 * $Id: TableScroller.java,v 1.6 2002/10/13 19:59:22 tirsen Exp $ 26 */ 27 public class TableScroller extends Component 28 { 29 private static final Category logger = Category.getInstance(Debug.LOGGER_NAME); 30 31 private Table table; 32 33 public void setTable(Table table) 34 { 35 this.table = table; 36 } 37 38 private boolean isForwardEnabled() 39 { 40 boolean result; 41 42 if (table == null) 43 { 44 result = false; 45 } 46 else 47 { 48 if (getEnd() >= getRowCount() - 1) 49 result = false; 50 else 51 result = true; 52 } 53 54 return result; 55 } 56 57 private boolean isBackwardEnabled() 58 { 59 boolean result; 60 61 if (table == null) 62 { 63 result = false; 64 } 65 else 66 { 67 if (getStart() == 0) 68 result = false; 69 else 70 result = true; 71 } 72 73 return result; 74 } 75 76 private int getEnd() 77 { 78 return table.getTableModel().getEnd(); 79 } 80 81 private int getStart() 82 { 83 return table.getTableModel().getStart(); 84 } 85 86 private int getRowCount() 87 { 88 return table.getRowCount(); 89 } 90 91 public void render(RenderContext context) throws IOException 92 { 93 getPrevious().render(context); 94 context.println(" "); 95 getNext().render(context); 96 } 97 98 public Action getPreviousAction() 99 { 100 return new BackwardAction(); 101 } 102 103 public Action getNextAction() 104 { 105 return new ForwardAction(); 106 } 107 108 private Link getPrevious() 109 { 110 return Link.createActionLink(getPreviousAction()); 111 } 112 113 private Link getNext() 114 { 115 return Link.createActionLink(getNextAction()); 116 } 117 118 private class ForwardAction extends AbstractAction 119 { 120 public ForwardAction() 121 { 122 super("Next"); 123 } 124 125 public void actionPerformed(ActionEvent evt) 126 { 127 table.scrollForward(); 128 } 129 130 public boolean isEnabled() 131 { 132 return super.isEnabled() && isForwardEnabled(); 133 } 134 } 135 136 private class BackwardAction extends AbstractAction 137 { 138 public BackwardAction() 139 { 140 super("Previous"); 141 } 142 143 public void actionPerformed(ActionEvent evt) 144 { 145 table.scrollBackward(); 146 } 147 148 public boolean isEnabled() 149 { 150 return super.isEnabled() && isBackwardEnabled(); 151 } 152 } 153 }

This page was automatically generated by Maven