1 19 package org.netbeans.test.subversion.operators; 20 21 import java.awt.Component ; 22 import javax.swing.JComponent ; 23 import org.netbeans.jellytools.Bundle; 24 import org.netbeans.jellytools.TopComponentOperator; 25 import org.netbeans.jellytools.actions.Action; 26 import org.netbeans.jemmy.ComponentChooser; 27 import org.netbeans.jemmy.operators.JButtonOperator; 28 import org.netbeans.jemmy.operators.JPopupMenuOperator; 29 import org.netbeans.jemmy.operators.JTableOperator; 30 import org.netbeans.jemmy.operators.JToggleButtonOperator; 31 32 52 public class VersioningOperator extends TopComponentOperator { 53 54 55 static final String VERSIONING_TITLE = "Versioning"; 56 static final String SUBVERSION_TITLE = "Subversion"; 57 58 59 public VersioningOperator() { 60 super(waitTopComponent(null, SUBVERSION_TITLE, 0, new VersioningSubchooser())); 61 } 62 63 66 public static VersioningOperator invoke() { 67 String windowItem = Bundle.getStringTrimmed("org.netbeans.core.Bundle", "Menu/Window"); 68 String versioningItem = "Subversion"; 69 new Action(windowItem + "|" + VERSIONING_TITLE + "|" + versioningItem, null).perform(); 70 return new VersioningOperator(); 71 } 72 73 private JToggleButtonOperator _tbAll; 74 private JToggleButtonOperator _tbLocal; 75 private JToggleButtonOperator _tbRemote; 76 private JButtonOperator _btRefresh; 77 private JButtonOperator _btDiff; 78 private JButtonOperator _btUpdate; 79 private JButtonOperator _btCommit; 80 private JTableOperator _tabFiles; 81 82 83 87 90 public JToggleButtonOperator tbAll() { 91 if (_tbAll==null) { 92 _tbAll = new JToggleButtonOperator(this, "All"); 93 } 94 return _tbAll; 95 } 96 97 100 public JToggleButtonOperator tbLocal() { 101 if (_tbLocal==null) { 102 _tbLocal = new JToggleButtonOperator(this, "Local"); 103 } 104 return _tbLocal; 105 } 106 107 110 public JToggleButtonOperator tbRemote() { 111 if (_tbRemote==null) { 112 _tbRemote = new JToggleButtonOperator(this, "Remote"); 113 } 114 return _tbRemote; 115 } 116 117 120 public JButtonOperator btRefresh() { 121 if (_btRefresh==null) { 122 _btRefresh = new JButtonOperator(this, new TooltipChooser( 123 "Refresh Status", 124 this.getComparator())); 125 } 126 return _btRefresh; 127 } 128 129 132 public JButtonOperator btDiff() { 133 if (_btDiff==null) { 134 _btDiff = new JButtonOperator(this, new TooltipChooser( 135 "Diff All", 136 this.getComparator())); 137 } 138 return _btDiff; 139 } 140 141 144 public JButtonOperator btUpdate() { 145 if (_btUpdate==null) { 146 _btUpdate = new JButtonOperator(this, new TooltipChooser( 147 "Update All", 148 this.getComparator())); 149 } 150 return _btUpdate; 151 } 152 153 156 public JButtonOperator btCommit() { 157 if (_btCommit==null) { 158 _btCommit = new JButtonOperator(this, new TooltipChooser( 159 "Commit All", 160 this.getComparator())); 161 } 162 return _btCommit; 163 } 164 165 168 public JTableOperator tabFiles() { 169 if (_tabFiles==null) { 170 _tabFiles = new JTableOperator(this); 171 } 172 return _tabFiles; 173 } 174 175 176 180 183 public void checkAll(boolean state) { 184 if (tbAll().isSelected()!=state) { 185 tbAll().push(); 186 } 187 } 188 189 192 public void checkLocal(boolean state) { 193 if (tbLocal().isSelected()!=state) { 194 tbLocal().push(); 195 } 196 } 197 198 201 public void checkRemote(boolean state) { 202 if (tbRemote().isSelected()!=state) { 203 tbRemote().push(); 204 } 205 } 206 207 209 public void refresh() { 210 btRefresh().push(); 211 } 212 213 215 public void diff() { 216 btDiff().push(); 217 } 218 219 221 public void update() { 222 btUpdate().push(); 223 } 224 225 228 public CommitOperator commit() { 229 btCommit().pushNoBlock(); 230 return new CommitOperator(); 231 } 232 233 237 public void performPopup(int row, String popupPath) { 238 tabFiles().selectCell(row, 0); 239 JPopupMenuOperator popup = new JPopupMenuOperator(tabFiles().callPopupOnCell(row, 0)); 240 popup.pushMenu(popupPath); 241 } 242 243 247 public void performPopup(String filename, String popupPath) { 248 performPopup(tabFiles().findCellRow(filename), popupPath); 249 } 250 251 255 public void performPopupNoBlock(int row, String popupPath) { 256 tabFiles().selectCell(row, 0); 257 JPopupMenuOperator popup = new JPopupMenuOperator(tabFiles().callPopupOnCell(row, 0)); 258 popup.pushMenuNoBlock(popupPath); 259 } 260 261 265 public void performPopupNoBlock(String filename, String popupPath) { 266 performPopupNoBlock(tabFiles().findCellRow(filename), popupPath); 267 } 268 269 273 275 public void verify() { 276 tbAll(); 277 tbLocal(); 278 tbRemote(); 279 btRefresh(); 280 btDiff(); 281 btUpdate(); 282 btCommit(); 283 tabFiles(); 284 } 285 286 290 private static final class VersioningSubchooser implements ComponentChooser { 291 public boolean checkComponent(Component comp) { 292 return comp.getClass().getName().endsWith("SvnVersioningTopComponent"); 293 } 294 295 public String getDescription() { 296 return "org.netbeans.modules.subversion.ui.status.SvnVersioningTopComponent"; 297 } 298 } 299 300 303 private static class TooltipChooser implements ComponentChooser { 304 private String buttonTooltip; 305 private StringComparator comparator; 306 307 public TooltipChooser(String buttonTooltip, StringComparator comparator) { 308 this.buttonTooltip = buttonTooltip; 309 this.comparator = comparator; 310 } 311 312 public boolean checkComponent(Component comp) { 313 return comparator.equals(((JComponent )comp).getToolTipText(), buttonTooltip); 314 } 315 316 public String getDescription() { 317 return "Button with tooltip \""+buttonTooltip+"\"."; 318 } 319 } 320 } 321 322 | Popular Tags |