1 11 package org.eclipse.jdt.internal.ui.text.template.contentassist; 12 13 import org.eclipse.core.runtime.Assert; 14 15 import org.eclipse.swt.SWT; 16 import org.eclipse.swt.events.DisposeEvent; 17 import org.eclipse.swt.events.DisposeListener; 18 import org.eclipse.swt.widgets.Shell; 19 20 import org.eclipse.jface.text.IInformationControl; 21 import org.eclipse.jface.text.IInformationControlCreator; 22 import org.eclipse.jface.text.IInformationControlCreatorExtension; 23 24 import org.eclipse.jdt.internal.ui.text.java.hover.SourceViewerInformationControl; 25 26 27 final public class TemplateInformationControlCreator implements IInformationControlCreator, IInformationControlCreatorExtension { 28 29 private SourceViewerInformationControl fControl; 30 31 36 private int fOrientation; 37 38 41 public TemplateInformationControlCreator(int orientation) { 42 Assert.isLegal(orientation == SWT.RIGHT_TO_LEFT || orientation == SWT.LEFT_TO_RIGHT); 43 fOrientation= orientation; 44 } 45 46 49 public IInformationControl createInformationControl(Shell parent) { 50 fControl= new SourceViewerInformationControl(parent, SWT.TOOL | fOrientation, SWT.NONE); 51 fControl.addDisposeListener(new DisposeListener() { 52 public void widgetDisposed(DisposeEvent e) { 53 fControl= null; 54 } 55 }); 56 return fControl; 57 } 58 59 62 public boolean canReuse(IInformationControl control) { 63 return fControl == control && fControl != null; 64 } 65 66 69 public boolean canReplace(IInformationControlCreator creator) { 70 return (creator != null && getClass() == creator.getClass()); 71 } 72 } 73 | Popular Tags |