1 20 21 package org.apache.directory.ldapstudio.browser.common.actions; 22 23 24 import org.apache.directory.ldapstudio.browser.common.widgets.browser.BrowserCategory; 25 import org.apache.directory.ldapstudio.browser.common.widgets.browser.BrowserEntryPage; 26 import org.apache.directory.ldapstudio.browser.common.widgets.browser.BrowserSearchResultPage; 27 import org.apache.directory.ldapstudio.browser.core.events.BookmarkUpdateEvent; 28 import org.apache.directory.ldapstudio.browser.core.events.ConnectionUpdateEvent; 29 import org.apache.directory.ldapstudio.browser.core.events.EntryModificationEvent; 30 import org.apache.directory.ldapstudio.browser.core.events.SearchUpdateEvent; 31 import org.apache.directory.ldapstudio.browser.core.model.AttributeHierarchy; 32 import org.apache.directory.ldapstudio.browser.core.model.IAttribute; 33 import org.apache.directory.ldapstudio.browser.core.model.IBookmark; 34 import org.apache.directory.ldapstudio.browser.core.model.IConnection; 35 import org.apache.directory.ldapstudio.browser.core.model.IEntry; 36 import org.apache.directory.ldapstudio.browser.core.model.ISearch; 37 import org.apache.directory.ldapstudio.browser.core.model.ISearchResult; 38 import org.apache.directory.ldapstudio.browser.core.model.IValue; 39 import org.apache.directory.ldapstudio.browser.core.model.ldif.LdifFile; 40 import org.apache.directory.ldapstudio.browser.core.model.ldif.LdifPart; 41 import org.apache.directory.ldapstudio.browser.core.model.ldif.container.LdifContainer; 42 43 import org.eclipse.jface.action.IAction; 44 import org.eclipse.jface.resource.ImageDescriptor; 45 import org.eclipse.jface.viewers.ISelection; 46 import org.eclipse.swt.widgets.Shell; 47 import org.eclipse.ui.IWorkbenchWindow; 48 import org.eclipse.ui.IWorkbenchWindowActionDelegate; 49 import org.eclipse.ui.PlatformUI; 50 51 52 58 public abstract class BrowserAction implements IWorkbenchWindowActionDelegate 59 { 60 61 private IConnection[] selectedConnections; 62 63 64 private BrowserCategory[] selectedBrowserViewCategories; 65 66 67 private IEntry[] selectedEntries; 68 69 70 private BrowserEntryPage[] selectedBrowserEntryPages; 71 72 73 private ISearch[] selectedSearches; 74 75 76 private ISearchResult[] selectedSearchResults; 77 78 79 private BrowserSearchResultPage[] selectedBrowserSearchResultPages; 80 81 82 private IBookmark[] selectedBookmarks; 83 84 85 private IAttribute[] selectedAttributes; 86 87 88 private AttributeHierarchy[] selectedAttributeHierarchies; 89 90 91 private IValue[] selectedValues; 92 93 94 private LdifFile selectedLdifModel; 95 96 97 private LdifContainer[] selectedLdifContainers; 98 99 100 private LdifPart[] selectedLdifParts; 101 102 103 private Object input; 104 105 106 109 protected BrowserAction() 110 { 111 this.init(); 112 } 113 114 115 118 public void init( IWorkbenchWindow window ) 119 { 120 this.init(); 121 } 122 123 124 127 public void run( IAction action ) 128 { 129 this.run(); 130 } 131 132 133 136 public void selectionChanged( IAction action, ISelection selection ) 137 { 138 setSelectedConnections( SelectionUtils.getConnections( selection ) ); 139 140 setSelectedBrowserViewCategories( SelectionUtils.getBrowserViewCategories( selection ) ); 141 setSelectedEntries( SelectionUtils.getEntries( selection ) ); 142 setSelectedBrowserEntryPages( SelectionUtils.getBrowserEntryPages( selection ) ); 143 setSelectedSearchResults( SelectionUtils.getSearchResults( selection ) ); 144 setSelectedBrowserSearchResultPages( SelectionUtils.getBrowserSearchResultPages( selection ) ); 145 setSelectedBookmarks( SelectionUtils.getBookmarks( selection ) ); 146 147 setSelectedSearches( SelectionUtils.getSearches( selection ) ); 148 149 setSelectedAttributes( SelectionUtils.getAttributes( selection ) ); 150 setSelectedAttributeHierarchies( SelectionUtils.getAttributeHierarchie( selection ) ); 151 setSelectedValues( SelectionUtils.getValues( selection ) ); 152 153 action.setEnabled( this.isEnabled() ); 154 action.setText( this.getText() ); 155 action.setToolTipText( this.getText() ); 156 } 157 158 159 169 public abstract String getText(); 170 171 172 182 public abstract ImageDescriptor getImageDescriptor(); 183 184 185 191 public abstract String getCommandId(); 192 193 194 205 public abstract boolean isEnabled(); 206 207 208 214 public abstract void run(); 215 216 217 220 private void init() 221 { 222 this.selectedConnections = new IConnection[0]; 223 this.selectedBrowserViewCategories = new BrowserCategory[0]; 224 this.selectedEntries = new IEntry[0]; 225 this.selectedBrowserEntryPages = new BrowserEntryPage[0]; 226 this.selectedSearches = new ISearch[0]; 227 this.selectedSearchResults = new ISearchResult[0]; 228 this.selectedBrowserSearchResultPages = new BrowserSearchResultPage[0]; 229 this.selectedBookmarks = new IBookmark[0]; 230 this.selectedAttributes = new IAttribute[0]; 231 this.selectedAttributeHierarchies = new AttributeHierarchy[0]; 232 this.selectedValues = new IValue[0]; 233 234 this.selectedLdifModel = null; 235 this.selectedLdifContainers = new LdifContainer[0]; 236 this.selectedLdifParts = new LdifPart[0]; 237 238 this.input = null; 239 } 240 241 242 245 public void dispose() 246 { 247 this.selectedConnections = new IConnection[0]; 248 this.selectedBrowserViewCategories = new BrowserCategory[0]; 249 this.selectedEntries = new IEntry[0]; 250 this.selectedBrowserEntryPages = new BrowserEntryPage[0]; 251 this.selectedSearches = new ISearch[0]; 252 this.selectedSearchResults = new ISearchResult[0]; 253 this.selectedBrowserSearchResultPages = new BrowserSearchResultPage[0]; 254 this.selectedBookmarks = new IBookmark[0]; 255 this.selectedAttributes = new IAttribute[0]; 256 this.selectedAttributeHierarchies = new AttributeHierarchy[0]; 257 this.selectedValues = new IValue[0]; 258 259 this.selectedLdifModel = null; 260 this.selectedLdifContainers = new LdifContainer[0]; 261 this.selectedLdifParts = new LdifPart[0]; 262 263 this.input = null; 264 } 265 266 267 273 protected Shell getShell() 274 { 275 return PlatformUI.getWorkbench().getDisplay().getActiveShell(); 276 } 277 278 279 285 public final void entryUpdated( EntryModificationEvent event ) 286 { 287 } 288 289 290 296 public void searchUpdated( SearchUpdateEvent searchUpdateEvent ) 297 { 298 } 299 300 301 307 public void bookmarkUpdated( BookmarkUpdateEvent bookmarkUpdateEvent ) 308 { 309 } 310 311 312 318 public final void connectionUpdated( ConnectionUpdateEvent connectionUpdateEvent ) 319 { 320 } 321 322 323 329 public IAttribute[] getSelectedAttributes() 330 { 331 return selectedAttributes; 332 } 333 334 335 341 public void setSelectedAttributes( IAttribute[] selectedAttributes ) 342 { 343 this.selectedAttributes = selectedAttributes; 344 } 345 346 347 353 public IBookmark[] getSelectedBookmarks() 354 { 355 return selectedBookmarks; 356 } 357 358 359 365 public void setSelectedBookmarks( IBookmark[] selectedBookmarks ) 366 { 367 this.selectedBookmarks = selectedBookmarks; 368 } 369 370 371 377 public BrowserCategory[] getSelectedBrowserViewCategories() 378 { 379 return selectedBrowserViewCategories; 380 } 381 382 383 389 public void setSelectedBrowserViewCategories( BrowserCategory[] selectedBrowserViewCategories ) 390 { 391 this.selectedBrowserViewCategories = selectedBrowserViewCategories; 392 } 393 394 395 401 public IConnection[] getSelectedConnections() 402 { 403 return selectedConnections; 404 } 405 406 407 413 public void setSelectedConnections( IConnection[] selectedConnections ) 414 { 415 this.selectedConnections = selectedConnections; 416 } 417 418 419 424 public IEntry[] getSelectedEntries() 425 { 426 return selectedEntries; 427 } 428 429 430 436 public void setSelectedEntries( IEntry[] selectedEntries ) 437 { 438 this.selectedEntries = selectedEntries; 439 } 440 441 442 448 public ISearch[] getSelectedSearches() 449 { 450 return selectedSearches; 451 } 452 453 454 460 public void setSelectedSearches( ISearch[] selectedSearches ) 461 { 462 this.selectedSearches = selectedSearches; 463 } 464 465 466 472 public ISearchResult[] getSelectedSearchResults() 473 { 474 return selectedSearchResults; 475 } 476 477 478 484 public void setSelectedSearchResults( ISearchResult[] selectedSearchResults ) 485 { 486 this.selectedSearchResults = selectedSearchResults; 487 } 488 489 490 496 public IValue[] getSelectedValues() 497 { 498 return selectedValues; 499 } 500 501 502 508 public void setSelectedValues( IValue[] selectedValues ) 509 { 510 this.selectedValues = selectedValues; 511 } 512 513 514 520 public Object getInput() 521 { 522 return input; 523 } 524 525 526 532 public void setInput( Object input ) 533 { 534 this.input = input; 535 } 536 537 538 544 public LdifContainer[] getSelectedLdifContainers() 545 { 546 return selectedLdifContainers; 547 } 548 549 550 556 public void setSelectedLdifContainers( LdifContainer[] selectedLdifContainers ) 557 { 558 this.selectedLdifContainers = selectedLdifContainers; 559 } 560 561 562 568 public LdifFile getSelectedLdifModel() 569 { 570 return selectedLdifModel; 571 } 572 573 574 580 public void setSelectedLdifModel( LdifFile selectedLdifModel ) 581 { 582 this.selectedLdifModel = selectedLdifModel; 583 } 584 585 586 592 public LdifPart[] getSelectedLdifParts() 593 { 594 return selectedLdifParts; 595 } 596 597 598 604 public void setSelectedLdifParts( LdifPart[] selectedLdifParts ) 605 { 606 this.selectedLdifParts = selectedLdifParts; 607 } 608 609 610 616 public BrowserEntryPage[] getSelectedBrowserEntryPages() 617 { 618 return selectedBrowserEntryPages; 619 } 620 621 622 628 public void setSelectedBrowserEntryPages( BrowserEntryPage[] selectedBrowserEntryPages ) 629 { 630 this.selectedBrowserEntryPages = selectedBrowserEntryPages; 631 } 632 633 634 640 public BrowserSearchResultPage[] getSelectedBrowserSearchResultPages() 641 { 642 return selectedBrowserSearchResultPages; 643 } 644 645 646 652 public void setSelectedBrowserSearchResultPages( BrowserSearchResultPage[] selectedBrowserSearchResultPages ) 653 { 654 this.selectedBrowserSearchResultPages = selectedBrowserSearchResultPages; 655 } 656 657 658 664 public AttributeHierarchy[] getSelectedAttributeHierarchies() 665 { 666 return selectedAttributeHierarchies; 667 } 668 669 670 676 public void setSelectedAttributeHierarchies( AttributeHierarchy[] ahs ) 677 { 678 this.selectedAttributeHierarchies = ahs; 679 } 680 } 681 | Popular Tags |