KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ant > internal > ui > editor > templates > AntTemplateInformationControlCreator


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - Initial implementation
10  *******************************************************************************/

11 package org.eclipse.ant.internal.ui.editor.templates;
12
13 import org.eclipse.ant.internal.ui.editor.AntSourceViewerInformationControl;
14 import org.eclipse.jface.text.IInformationControl;
15 import org.eclipse.jface.text.IInformationControlCreator;
16 import org.eclipse.jface.text.IInformationControlCreatorExtension;
17 import org.eclipse.swt.events.DisposeEvent;
18 import org.eclipse.swt.events.DisposeListener;
19 import org.eclipse.swt.widgets.Shell;
20
21
22 public class AntTemplateInformationControlCreator implements IInformationControlCreator, IInformationControlCreatorExtension {
23     
24     private AntSourceViewerInformationControl fControl;
25     
26     public AntTemplateInformationControlCreator() {
27     }
28     
29     /*
30      * @see org.eclipse.jface.text.IInformationControlCreator#createInformationControl(org.eclipse.swt.widgets.Shell)
31      */

32     public IInformationControl createInformationControl(Shell parent) {
33         fControl= new AntSourceViewerInformationControl(parent);
34         fControl.addDisposeListener(new DisposeListener() {
35             public void widgetDisposed(DisposeEvent e) {
36                 fControl= null;
37             }
38         });
39         return fControl;
40     }
41
42     /*
43      * @see org.eclipse.jface.text.IInformationControlCreatorExtension#canReuse(org.eclipse.jface.text.IInformationControl)
44      */

45     public boolean canReuse(IInformationControl control) {
46         return fControl == control && fControl != null;
47     }
48
49     /*
50      * @see org.eclipse.jface.text.IInformationControlCreatorExtension#canReplace(org.eclipse.jface.text.IInformationControlCreator)
51      */

52     public boolean canReplace(IInformationControlCreator creator) {
53         return (creator != null && getClass() == creator.getClass());
54     }
55 }
56
Popular Tags