comparison dwtx/jface/text/source/CompositeRuler.d @ 162:1a5b8f8129df

...
author Frank Benoit <benoit@tionex.de>
date Mon, 08 Sep 2008 00:51:37 +0200
parents 25f1f92fa3df
children
comparison
equal deleted inserted replaced
161:f8d52b926852 162:1a5b8f8129df
185 ClassInfo fClass; 185 ClassInfo fClass;
186 EventListener fListener; 186 EventListener fListener;
187 } 187 }
188 188
189 /** The list of listeners added to this canvas. */ 189 /** The list of listeners added to this canvas. */
190 private List fCachedListeners= new ArrayList(); 190 private List fCachedListeners;
191 /** 191 /**
192 * Internal listener for opening the context menu. 192 * Internal listener for opening the context menu.
193 * @since 3.0 193 * @since 3.0
194 */ 194 */
195 private Listener fMenuDetectListener; 195 private Listener fMenuDetectListener;
199 * 199 *
200 * @param parent the parent composite 200 * @param parent the parent composite
201 * @param style the DWT styles 201 * @param style the DWT styles
202 */ 202 */
203 public this(Composite parent, int style) { 203 public this(Composite parent, int style) {
204 fCachedListeners= new ArrayList();
205
204 super(parent, style); 206 super(parent, style);
205 fMenuDetectListener= new class() Listener { 207 fMenuDetectListener= new class() Listener {
206 public void handleEvent(Event event) { 208 public void handleEvent(Event event) {
207 if (event.type is DWT.MenuDetect) { 209 if (event.type is DWT.MenuDetect) {
208 Menu menu= getMenu(); 210 Menu menu= getMenu();
354 */ 356 */
355 private void removeListener(ClassInfo clazz, EventListener listener) { 357 private void removeListener(ClassInfo clazz, EventListener listener) {
356 int length= fCachedListeners.size(); 358 int length= fCachedListeners.size();
357 for (int i= 0; i < length; i++) { 359 for (int i= 0; i < length; i++) {
358 ListenerInfo info= cast(ListenerInfo) fCachedListeners.get(i); 360 ListenerInfo info= cast(ListenerInfo) fCachedListeners.get(i);
359 if (listener is info.fListener && clazz.equals(info.fClass)) { 361 if (listener is info.fListener && clazz.opEquals(info.fClass)) {
360 fCachedListeners.remove(i); 362 fCachedListeners.remove(i);
361 break; 363 break;
362 } 364 }
363 } 365 }
364 366
567 /** The ruler's canvas to which to add the ruler columns */ 569 /** The ruler's canvas to which to add the ruler columns */
568 private CompositeRulerCanvas fComposite; 570 private CompositeRulerCanvas fComposite;
569 /** The ruler's annotation model */ 571 /** The ruler's annotation model */
570 private IAnnotationModel fModel; 572 private IAnnotationModel fModel;
571 /** The list of columns */ 573 /** The list of columns */
572 private List fDecorators= new ArrayList(2); 574 private List fDecorators;
573 /** The cached location of the last mouse button activity */ 575 /** The cached location of the last mouse button activity */
574 private Point fLocation= new Point(-1, -1); 576 private Point fLocation;
575 /** The cached line of the list mouse button activity */ 577 /** The cached line of the list mouse button activity */
576 private int fLastMouseButtonActivityLine= -1; 578 private int fLastMouseButtonActivityLine= -1;
577 /** The gap between the individual columns of this composite ruler */ 579 /** The gap between the individual columns of this composite ruler */
578 private int fGap; 580 private int fGap;
579 /** 581 /**
580 * The set of annotation listeners. 582 * The set of annotation listeners.
581 * @since 3.0 583 * @since 3.0
582 */ 584 */
583 private Set fAnnotationListeners= new HashSet(); 585 private Set fAnnotationListeners;
584 586
585 587
586 /** 588 /**
587 * Constructs a new composite vertical ruler. 589 * Constructs a new composite vertical ruler.
588 */ 590 */
594 * Constructs a new composite ruler with the given gap between its columns. 596 * Constructs a new composite ruler with the given gap between its columns.
595 * 597 *
596 * @param gap 598 * @param gap
597 */ 599 */
598 public this(int gap) { 600 public this(int gap) {
601 fDecorators= new ArrayList(2);
602 fLocation= new Point(-1, -1);
603 fAnnotationListeners= new HashSet();
604
599 fGap= gap; 605 fGap= gap;
600 } 606 }
601 607
602 /** 608 /**
603 * Inserts the given column at the specified slot to this composite ruler. 609 * Inserts the given column at the specified slot to this composite ruler.
608 */ 614 */
609 public void addDecorator(int index, IVerticalRulerColumn rulerColumn) { 615 public void addDecorator(int index, IVerticalRulerColumn rulerColumn) {
610 rulerColumn.setModel(getModel()); 616 rulerColumn.setModel(getModel());
611 617
612 if (index > fDecorators.size()) 618 if (index > fDecorators.size())
613 fDecorators.add(rulerColumn); 619 fDecorators.add(cast(Object)rulerColumn);
614 else 620 else
615 fDecorators.add(index, rulerColumn); 621 fDecorators.add(index, cast(Object)rulerColumn);
616 622
617 if (fComposite !is null && !fComposite.isDisposed()) { 623 if (fComposite !is null && !fComposite.isDisposed()) {
618 rulerColumn.createControl(this, fComposite); 624 rulerColumn.createControl(this, fComposite);
619 fComposite.childAdded(rulerColumn.getControl()); 625 fComposite.childAdded(rulerColumn.getControl());
620 layoutTextViewer(); 626 layoutTextViewer();
636 * 642 *
637 * @param rulerColumn the ruler column to be removed 643 * @param rulerColumn the ruler column to be removed
638 * @since 3.0 644 * @since 3.0
639 */ 645 */
640 public void removeDecorator(IVerticalRulerColumn rulerColumn) { 646 public void removeDecorator(IVerticalRulerColumn rulerColumn) {
641 fDecorators.remove(rulerColumn); 647 fDecorators.remove(cast(Object)rulerColumn);
642 if (rulerColumn !is null) { 648 if (rulerColumn !is null) {
643 Control cc= rulerColumn.getControl(); 649 Control cc= rulerColumn.getControl();
644 if (cc !is null && !cc.isDisposed()) { 650 if (cc !is null && !cc.isDisposed()) {
645 fComposite.childRemoved(cc); 651 fComposite.childRemoved(cc);
646 cc.dispose(); 652 cc.dispose();
846 * 852 *
847 * @return an iterator over the contained columns. 853 * @return an iterator over the contained columns.
848 * @since 3.0 854 * @since 3.0
849 */ 855 */
850 public Iterator getDecoratorIterator() { 856 public Iterator getDecoratorIterator() {
851 Assert.isNotNull(fDecorators, "fDecorators must be initialized"); //$NON-NLS-1$ 857 Assert.isNotNull(cast(Object)fDecorators, "fDecorators must be initialized"); //$NON-NLS-1$
852 return fDecorators.iterator(); 858 return fDecorators.iterator();
853 } 859 }
854 860
855 /* 861 /*
856 * @see dwtx.jface.text.source.IVerticalRulerInfoExtension#getHover() 862 * @see dwtx.jface.text.source.IVerticalRulerInfoExtension#getHover()
863 /* 869 /*
864 * @see dwtx.jface.text.source.IVerticalRulerInfoExtension#addVerticalRulerListener(dwtx.jface.text.source.IVerticalRulerListener) 870 * @see dwtx.jface.text.source.IVerticalRulerInfoExtension#addVerticalRulerListener(dwtx.jface.text.source.IVerticalRulerListener)
865 * @since 3.0 871 * @since 3.0
866 */ 872 */
867 public void addVerticalRulerListener(IVerticalRulerListener listener) { 873 public void addVerticalRulerListener(IVerticalRulerListener listener) {
868 fAnnotationListeners.add(listener); 874 fAnnotationListeners.add(cast(Object)listener);
869 } 875 }
870 876
871 /* 877 /*
872 * @see dwtx.jface.text.source.IVerticalRulerInfoExtension#removeVerticalRulerListener(dwtx.jface.text.source.IVerticalRulerListener) 878 * @see dwtx.jface.text.source.IVerticalRulerInfoExtension#removeVerticalRulerListener(dwtx.jface.text.source.IVerticalRulerListener)
873 * @since 3.0 879 * @since 3.0
874 */ 880 */
875 public void removeVerticalRulerListener(IVerticalRulerListener listener) { 881 public void removeVerticalRulerListener(IVerticalRulerListener listener) {
876 fAnnotationListeners.remove(listener); 882 fAnnotationListeners.remove(cast(Object)listener);
877 } 883 }
878 884
879 /** 885 /**
880 * Fires the annotation selected event to all registered vertical ruler 886 * Fires the annotation selected event to all registered vertical ruler
881 * listeners. 887 * listeners.