1 19 20 25 package org.netbeans.jellytools.modules.editor; 26 27 import java.awt.Robot ; 28 import java.awt.event.InputEvent ; 29 import org.netbeans.jemmy.operators.*; 30 31 36 public class GoToLine extends JDialogOperator { 37 38 40 public GoToLine() { 41 super(java.util.ResourceBundle.getBundle("org.netbeans.editor.Bundle").getString("goto-title")); 42 } 43 44 private JLabelOperator _lblGoToLine; 45 private JComboBoxOperator _cboGoToLine; 46 private JButtonOperator _btGoto; 47 private JButtonOperator _btClose; 48 private JButtonOperator _btHelp; 49 50 51 55 58 public JLabelOperator lblGoToLine() { 59 if (_lblGoToLine==null) { 60 _lblGoToLine = new JLabelOperator(this, java.util.ResourceBundle.getBundle("org.netbeans.editor.Bundle").getString("goto-line")); 61 } 62 return _lblGoToLine; 63 } 64 65 68 public JComboBoxOperator cboGoToLine() { 69 if (_cboGoToLine==null) { 70 _cboGoToLine = new JComboBoxOperator(this); 71 } 72 return _cboGoToLine; 73 } 74 75 78 public JButtonOperator btGoto() { 79 if (_btGoto==null) { 80 _btGoto = new JButtonOperator(this, java.util.ResourceBundle.getBundle("org.netbeans.editor.Bundle").getString("goto-button-goto")); 81 } 82 return _btGoto; 83 } 84 85 88 public JButtonOperator btClose() { 89 if (_btClose==null) { 90 _btClose = new JButtonOperator(this, java.util.ResourceBundle.getBundle("org.netbeans.editor.Bundle").getString("goto-button-cancel")); 91 } 92 return _btClose; 93 } 94 95 98 public JButtonOperator btHelp() { 99 if (_btHelp==null) { 100 _btHelp = new JButtonOperator(this, java.util.ResourceBundle.getBundle("org.openide.explorer.propertysheet.Bundle").getString("CTL_Help")); 101 } 102 return _btHelp; 103 } 104 105 106 110 113 public String getSelectedGoToLine() { 114 return cboGoToLine().getSelectedItem().toString(); 115 } 116 117 120 public void selectGoToLine(String item) { 121 cboGoToLine().selectItem(item); 122 } 123 124 127 public void typeGoToLine(String text) { 128 cboGoToLine().typeText(text); 129 } 130 131 133 public void goTo() { 134 btGoto().push(); 135 } 136 137 139 public void close() { 140 btClose().push(); 141 } 142 143 145 public void help() { 146 btHelp().push(); 147 } 148 149 150 154 156 public void verify() { 157 lblGoToLine(); 158 cboGoToLine(); 159 btGoto(); 160 btClose(); 161 btHelp(); 162 } 163 164 public static void goToLine(int line) { 165 GoToLine op=new GoToLine(); 166 op.typeGoToLine(String.valueOf(line)); 167 op.goTo(); 168 while (op.isVisible()) { 169 op.goTo(); 170 } 171 } 172 173 public static void goToLine(int line,Robot robot) { 174 GoToLine op=new GoToLine(); 175 java.awt.Point p; 176 int x,y; 177 178 String s=String.valueOf(line); 179 int c; 180 robot.waitForIdle(); 181 robot.delay(200); 182 for (int i=0;i < s.length();i++) { 183 c=(int)s.charAt(i); 184 robot.keyPress(c); 185 robot.delay(50); 186 robot.keyRelease(c); 187 } 188 p=op.btGoto().getLocationOnScreen(); 189 x=p.x+op.btGoto().getWidth()/2; 190 y=p.y+op.btGoto().getHeight()/2; 191 robot.mouseMove(x,y); 192 robot.mousePress(InputEvent.BUTTON1_MASK); 193 robot.delay(50); 194 robot.mouseRelease(InputEvent.BUTTON1_MASK); 195 robot.delay(50); 196 robot.waitForIdle(); 197 while (op.isVisible()) { 198 robot.delay(50); 199 } 200 } 201 202 205 public static void main(String args[]) { 206 System.out.println("GoToLine verification finished."); 208 char c='0'; 209 System.out.println("Char c="+Integer.toHexString((int)c)); 210 } 211 } 212 213 | Popular Tags |