1 19 20 25 package org.netbeans.jellytools.modules.editor; 26 27 import java.io.File ; 28 import java.io.FileWriter ; 29 import java.io.PrintWriter ; 30 import org.netbeans.jellytools.properties.Property; 31 import org.netbeans.jemmy.operators.*; 32 import java.util.*; 33 34 import javax.swing.ListModel ; 35 import org.netbeans.jellytools.OptionsOperator; 36 import org.netbeans.jellytools.properties.PropertySheetOperator; 37 import org.netbeans.jemmy.EventTool; 38 39 44 public class KeyBindings extends JDialogOperator { 45 46 48 public KeyBindings() { 49 super(java.util.ResourceBundle.getBundle("org.netbeans.modules.editor.options.Bundle").getString("PROP_KeyBindings")); 50 } 51 52 private JRadioButtonOperator _rbSortByName; 53 private JRadioButtonOperator _rbSortByAction; 54 private JListOperator _lstActions; 55 private JButtonOperator _btMetalScrollButton; 56 private JButtonOperator _btMetalScrollButton2; 57 private JLabelOperator _lblKeybindings; 58 private JListOperator _lstKeybindings; 59 private JButtonOperator _btAdd; 60 private JButtonOperator _btRemove; 61 private JButtonOperator _btOK; 62 private JButtonOperator _btCancel; 63 private JButtonOperator _btHelp; 64 65 66 70 73 public JRadioButtonOperator rbSortByName() { 74 if (_rbSortByName==null) { 75 _rbSortByName = new JRadioButtonOperator(this, java.util.ResourceBundle.getBundle("org.netbeans.modules.editor.options.Bundle").getString("KBEP_name_sort_button")); 76 } 77 return _rbSortByName; 78 } 79 80 83 public JRadioButtonOperator rbSortByAction() { 84 if (_rbSortByAction==null) { 85 _rbSortByAction = new JRadioButtonOperator(this, java.util.ResourceBundle.getBundle("org.netbeans.modules.editor.options.Bundle").getString("KBEP_action_sort_button")); 86 } 87 return _rbSortByAction; 88 } 89 90 93 public JListOperator lstActions() { 94 if (_lstActions==null) { 95 _lstActions = new JListOperator(this); 96 } 97 return _lstActions; 98 } 99 100 103 public JButtonOperator btMetalScrollButton() { 104 if (_btMetalScrollButton==null) { 105 _btMetalScrollButton = new JButtonOperator(this, ""); 106 } 107 return _btMetalScrollButton; 108 } 109 110 113 public JButtonOperator btMetalScrollButton2() { 114 if (_btMetalScrollButton2==null) { 115 _btMetalScrollButton2 = new JButtonOperator(this, "", 1); 116 } 117 return _btMetalScrollButton2; 118 } 119 120 123 public JLabelOperator lblKeybindings() { 124 if (_lblKeybindings==null) { 125 _lblKeybindings = new JLabelOperator(this, java.util.ResourceBundle.getBundle("org.netbeans.modules.editor.options.Bundle").getString("KBEP_Sequences")); 126 } 127 return _lblKeybindings; 128 } 129 130 133 public JListOperator lstKeybindings() { 134 if (_lstKeybindings==null) { 135 _lstKeybindings = new JListOperator(this, 1); 136 } 137 return _lstKeybindings; 138 } 139 140 143 public JButtonOperator btAdd() { 144 if (_btAdd==null) { 145 _btAdd = new JButtonOperator(this, java.util.ResourceBundle.getBundle("org.netbeans.modules.editor.options.Bundle").getString("KBEP_Add")); 146 } 147 return _btAdd; 148 } 149 150 153 public JButtonOperator btRemove() { 154 if (_btRemove==null) { 155 _btRemove = new JButtonOperator(this, java.util.ResourceBundle.getBundle("org.netbeans.modules.editor.options.Bundle").getString("KBEP_Remove")); 156 } 157 return _btRemove; 158 } 159 160 163 public JButtonOperator btOK() { 164 if (_btOK==null) { 165 _btOK = new JButtonOperator(this, java.util.ResourceBundle.getBundle("org.netbeans.modules.editor.options.Bundle").getString("KBEP_OK_LABEL")); 166 } 167 return _btOK; 168 } 169 170 173 public JButtonOperator btCancel() { 174 if (_btCancel==null) { 175 _btCancel = new JButtonOperator(this, java.util.ResourceBundle.getBundle("org.netbeans.core.awt.Bundle").getString("CancelButton")); 176 } 177 return _btCancel; 178 } 179 180 183 public JButtonOperator btHelp() { 184 if (_btHelp==null) { 185 _btHelp = new JButtonOperator(this, java.util.ResourceBundle.getBundle("org.openide.explorer.propertysheet.Bundle").getString("CTL_Help")); 186 } 187 return _btHelp; 188 } 189 190 191 195 197 public void sortByName() { 198 rbSortByName().push(); 199 } 200 201 203 public void sortByAction() { 204 rbSortByAction().push(); 205 } 206 207 209 public void metalScrollButton() { 210 btMetalScrollButton().push(); 211 } 212 213 215 public void metalScrollButton2() { 216 btMetalScrollButton2().push(); 217 } 218 219 221 public void add() { 222 btAdd().push(); 223 } 224 225 227 public void remove() { 228 btRemove().push(); 229 } 230 231 233 public void oK() { 234 btOK().push(); 235 } 236 237 239 public void cancel() { 240 btCancel().push(); 241 } 242 243 245 public void help() { 246 btHelp().push(); 247 } 248 249 250 254 256 public void verify() { 257 rbSortByName(); 258 rbSortByAction(); 259 lstActions(); 260 btMetalScrollButton(); 261 btMetalScrollButton2(); 262 lblKeybindings(); 263 lstKeybindings(); 264 btAdd(); 265 btRemove(); 266 btOK(); 267 btCancel(); 268 btHelp(); 269 } 270 271 public List listActions() { 272 ListModel model = lstActions().getModel(); 273 List ret=new Vector(); 274 for (int i=0;i < model.getSize();i++) { 275 ret.add(model.getElementAt(i)); 276 } 277 return ret; 278 } 279 280 public List listKeyBindings(String actionName) { 281 JListOperator jlist=lstActions(); 282 jlist.selectItem(actionName); 283 ListModel model = lstKeybindings().getModel(); 284 List ret=new Vector(); 285 for (int i=0;i < model.getSize();i++) { 286 ret.add(model.getElementAt(i)); 287 } 288 return ret; 289 } 290 291 295 public static KeyBindings invoke(String editorName) { 296 OptionsOperator options = OptionsOperator.invoke(); 297 options.switchToClassicView(); 298 options.selectOption(ResourceBundle.getBundle("org/netbeans/core/Bundle").getString("UI/Services/Editing")+"|"+ResourceBundle.getBundle("org/netbeans/modules/editor/options/Bundle").getString("OPTIONS_all")+"|" + editorName); 299 try { 301 Thread.sleep(1000); 302 } catch (Exception ex) { 303 } 304 PropertySheetOperator pso = new PropertySheetOperator(options); 305 Property p=new Property(pso, ResourceBundle.getBundle("org/netbeans/modules/editor/options/Bundle").getString("PROP_KeyBindings")); 306 p.openEditor(); 307 KeyBindings ret=new KeyBindings(); 308 options.close(); 309 return ret; 310 } 311 312 public static List listActions(String editorName) { 313 KeyBindings instance = invoke(editorName); 314 List result = instance.listActions(); 315 instance.oK(); 316 return result; 317 } 318 319 public static Hashtable listAllKeyBindings(String editorName) { 320 KeyBindings instance = invoke(editorName); 321 List result = instance.listActions(); 322 Hashtable ret=new Hashtable(); 323 for (int i=0;i < result.size();i++) { 324 ret.put(result.get(i).toString(),instance.listKeyBindings(result.get(i).toString())); 325 } 326 instance.oK(); 327 return ret; 328 } 329 330 333 public static void main(String args[]) { 334 String [] names=new String [] {"Plain Editor","HTML Editor","Java Editor"}; 336 List list; 337 for (int j=0;j < 20;j++) { 338 339 for (int i=0;i < names.length;i++) { 340 list = KeyBindings.listActions(names[i]); 341 System.out.println("step "+j+" output size="+list.size()); 342 } 343 } 344 366 } 367 } 368 369 | Popular Tags |