1) Reintroduced PHPPerspectiveFactory (was lost with refactoring).
[phpeclipse.git] / net.sourceforge.phpeclipse.ui / 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 net.sourceforge.phpdt.internal.ui.text.java.hover.SourceViewerInformationControl;
14
15 import org.eclipse.jface.text.IInformationControl;
16 import org.eclipse.jface.text.IInformationControlCreator;
17 import org.eclipse.jface.text.IInformationControlCreatorExtension;
18 import org.eclipse.swt.events.DisposeEvent;
19 import org.eclipse.swt.events.DisposeListener;
20 import org.eclipse.swt.widgets.Shell;
21
22 final public class TemplateInformationControlCreator implements
23                 IInformationControlCreator, IInformationControlCreatorExtension {
24
25         private SourceViewerInformationControl fControl;
26
27         public TemplateInformationControlCreator() {
28         }
29
30         /*
31          * @see org.eclipse.jface.text.IInformationControlCreator#createInformationControl(org.eclipse.swt.widgets.Shell)
32          */
33         public IInformationControl createInformationControl(Shell parent) {
34                 fControl = new SourceViewerInformationControl(parent);
35                 fControl.addDisposeListener(new DisposeListener() {
36                         public void widgetDisposed(DisposeEvent e) {
37                                 fControl = null;
38                         }
39                 });
40                 return fControl;
41         }
42
43         /*
44          * @see org.eclipse.jface.text.IInformationControlCreatorExtension#canReuse(org.eclipse.jface.text.IInformationControl)
45          */
46         public boolean canReuse(IInformationControl control) {
47                 return fControl == control && fControl != null;
48         }
49
50         /*
51          * @see org.eclipse.jface.text.IInformationControlCreatorExtension#canReplace(org.eclipse.jface.text.IInformationControlCreator)
52          */
53         public boolean canReplace(IInformationControlCreator creator) {
54                 return (creator != null && getClass() == creator.getClass());
55         }
56 }