1) Moved net.sourceforge.phpeclipse.ui\src\net\sourceforge\phpdt back to net.sourcefo...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / text / template / contentassist / TemplateInformationControlCreator.java
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/TemplateInformationControlCreator.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/contentassist/TemplateInformationControlCreator.java
new file mode 100644 (file)
index 0000000..522ac13
--- /dev/null
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package net.sourceforge.phpdt.internal.ui.text.template.contentassist;
+
+import net.sourceforge.phpdt.internal.ui.text.java.hover.SourceViewerInformationControl;
+
+import org.eclipse.jface.text.IInformationControl;
+import org.eclipse.jface.text.IInformationControlCreator;
+import org.eclipse.jface.text.IInformationControlCreatorExtension;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.widgets.Shell;
+
+final public class TemplateInformationControlCreator implements
+               IInformationControlCreator, IInformationControlCreatorExtension {
+
+       private SourceViewerInformationControl fControl;
+
+       public TemplateInformationControlCreator() {
+       }
+
+       /*
+        * @see org.eclipse.jface.text.IInformationControlCreator#createInformationControl(org.eclipse.swt.widgets.Shell)
+        */
+       public IInformationControl createInformationControl(Shell parent) {
+               fControl = new SourceViewerInformationControl(parent);
+               fControl.addDisposeListener(new DisposeListener() {
+                       public void widgetDisposed(DisposeEvent e) {
+                               fControl = null;
+                       }
+               });
+               return fControl;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.IInformationControlCreatorExtension#canReuse(org.eclipse.jface.text.IInformationControl)
+        */
+       public boolean canReuse(IInformationControl control) {
+               return fControl == control && fControl != null;
+       }
+
+       /*
+        * @see org.eclipse.jface.text.IInformationControlCreatorExtension#canReplace(org.eclipse.jface.text.IInformationControlCreator)
+        */
+       public boolean canReplace(IInformationControlCreator creator) {
+               return (creator != null && getClass() == creator.getClass());
+       }
+}