Syntax highlighting is changeable.
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / text / template / contentassist / TemplateInformationControlCreator.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.internal.ui.text.template.contentassist;
12
13 import org.eclipse.swt.events.DisposeEvent;
14 import org.eclipse.swt.events.DisposeListener;
15 import org.eclipse.swt.widgets.Shell;
16
17 import org.eclipse.jface.text.IInformationControl;
18 import org.eclipse.jface.text.IInformationControlCreator;
19 import org.eclipse.jface.text.IInformationControlCreatorExtension;
20
21 import net.sourceforge.phpdt.internal.ui.text.java.hover.SourceViewerInformationControl;
22
23
24 final public class TemplateInformationControlCreator implements IInformationControlCreator, IInformationControlCreatorExtension {
25         
26         private SourceViewerInformationControl fControl;
27         
28         public TemplateInformationControlCreator()  {
29         }
30         
31         /*
32          * @see org.eclipse.jface.text.IInformationControlCreator#createInformationControl(org.eclipse.swt.widgets.Shell)
33          */
34         public IInformationControl createInformationControl(Shell parent) {
35                 fControl= new SourceViewerInformationControl(parent);
36                 fControl.addDisposeListener(new DisposeListener() {
37                         public void widgetDisposed(DisposeEvent e) {
38                                 fControl= null;
39                         }
40                 });
41                 return fControl;
42         }
43
44         /*
45          * @see org.eclipse.jface.text.IInformationControlCreatorExtension#canReuse(org.eclipse.jface.text.IInformationControl)
46          */
47         public boolean canReuse(IInformationControl control) {
48                 return fControl == control && fControl != null;
49         }
50
51         /*
52          * @see org.eclipse.jface.text.IInformationControlCreatorExtension#canReplace(org.eclipse.jface.text.IInformationControlCreator)
53          */
54         public boolean canReplace(IInformationControlCreator creator) {
55                 return (creator != null && getClass() == creator.getClass());
56         }
57 }