1 19 20 package org.netbeans.jellytools.modules.editor; 21 22 import javax.swing.ComboBoxModel ; 23 import javax.swing.tree.TreePath ; 24 import org.netbeans.jellytools.HelpOperator; 25 import org.netbeans.jellytools.OptionsOperator; 26 import org.netbeans.jellytools.nodes.Node; 27 import org.netbeans.jemmy.EventTool; 28 import org.netbeans.jemmy.operators.JButtonOperator; 29 import org.netbeans.jemmy.operators.JComboBoxOperator; 30 import org.netbeans.jemmy.operators.JDialogOperator; 31 import org.netbeans.jemmy.operators.JListOperator; 32 import org.netbeans.jemmy.operators.JTreeOperator; 33 34 38 public class KeyMapOperator extends JDialogOperator{ 39 40 41 private static final String DUPLICATE_BUTTON = "Duplicate"; 42 private static final String RESTORE_BUTTON = "Restore"; 43 private static final String DELETE_BUTTON = "Delete"; 44 private static final String ADD_BUTTON = "Add ..."; 45 private static final String REMOVE_BUTTON = "Remove"; 46 47 private JComboBoxOperator profile; 48 private JButtonOperator duplicate; 49 private JButtonOperator restore; 50 private JButtonOperator delete; 51 private JTreeOperator actions; 52 private JListOperator shortcuts; 53 private JButtonOperator add; 54 private JButtonOperator remove; 55 56 private static OptionsOperator options; 57 58 59 public KeyMapOperator() { 60 super("Options"); 61 } 62 63 public static KeyMapOperator invoke() { 64 options = OptionsOperator.invoke(); 65 options.selectKeymap(); 66 new EventTool().waitNoEvent(500); 67 return new KeyMapOperator(); 68 } 69 70 public JComboBoxOperator profile() { 71 if(profile==null) { 72 profile = new JComboBoxOperator(this); 73 } 74 return profile; 75 } 76 77 public JButtonOperator duplicate() { 78 if(duplicate==null) { 79 duplicate = new JButtonOperator(this, DUPLICATE_BUTTON); 80 } 81 return duplicate; 82 } 83 84 public JButtonOperator delete() { 85 if(delete==null) { 86 delete = new JButtonOperator(this, DELETE_BUTTON); 87 } 88 return delete; 89 } 90 91 public JButtonOperator restore() { 92 if(restore==null) { 93 restore = new JButtonOperator(this, RESTORE_BUTTON); 94 } 95 return restore; 96 } 97 98 public JTreeOperator actions() { 99 if(actions==null) { 100 actions = new JTreeOperator(this); 101 } 102 return actions; 103 } 104 105 public JListOperator shortcuts() { 106 if(shortcuts==null) { 107 shortcuts = new JListOperator(this); 108 } 109 return shortcuts; 110 } 111 112 public JButtonOperator add() { 113 if(add==null) { 114 add = new JButtonOperator(this, ADD_BUTTON); 115 } 116 return add; 117 } 118 119 public JButtonOperator remove() { 120 if(remove==null) { 121 remove = new JButtonOperator(this, REMOVE_BUTTON); 122 } 123 return remove; 124 } 125 126 public JButtonOperator ok() { 127 return options.btOK(); 128 } 129 130 public JButtonOperator cancel() { 131 return options.btCancel(); 132 } 133 134 public JButtonOperator help() { 135 return options.btHelp(); 136 } 137 138 public void selectAction(String path) { 139 Node n = new Node(actions(), path); 140 n.select(); 141 } 142 143 public void selectProfile(String profile) { 144 JComboBoxOperator combo = profile(); 145 if(combo.getSelectedItem().toString().equals(profile)) return; ComboBoxModel model = combo.getModel(); 147 for (int i = 0; i < model.getSize(); i++) { 148 Object item = model.getElementAt(i); 149 if(item.toString().equals(profile)) { 150 combo.setSelectedIndex(i); 151 return; 152 } 153 } 154 throw new IllegalArgumentException ("Profile "+profile+" not found"); 155 } 156 157 158 public void verify() { 159 profile(); 160 duplicate(); 161 restore(); 162 actions(); 163 shortcuts(); 164 add(); 165 remove(); 166 ok(); 167 cancel(); 168 help(); 169 } 170 171 172 173 174 public static void main(String [] args) throws InterruptedException { 175 KeyMapOperator.invoke().selectAction("Other|select-line"); 177 178 179 } 180 181 182 } 183 | Popular Tags |