public final class TemplatesView extends PageBookView
ITemplatesPage
s that shows the templates for the currently
active editor part.
When this view notices an editor being activated, it uses the Eclipse adapter mechanism to get
its ITemplatesPage
. Hence, editors that want to provide a templates page need to provide
such an adapter:
Object getAdapter() { ... if (ITemplatesPage.class.equals(required)) { if (fTemplatesPage == null) fTemplatesPage= new JavaTemplatesPage(this); return fTemplatesPage; } } ... }
Note: This plug-in does not contribute this view. Clients that want to
use this view must check whether it is available and if not, contribute this view via
extension point using the specified view Id ID
:
<extension point="org.eclipse.ui.views"> <view name="%templatesViewName" icon="$nl$/icons/full/eview16/templates.gif" category="org.eclipse.ui" class="org.eclipse.ui.texteditor.templates.TemplatesView" id="org.eclipse.ui.texteditor.TemplatesView"> </view> </extension>The
templates.gif
icon can be copied from this plug-in.
If the editor supports a templates page, the editor instantiates and configures the page, and
returns it. This page is then added to this Templates view and immediately made the current page
(the Templates view needs not to be visible). If the
editor does not support a templates page, the Templates view shows a special default page which
makes it clear to the user that no templates are available. When the Templates view notices
a different editor being activated, it flips to the editor's corresponding templates page. When
the templates view notices an editor being closed, it may destroy the editor's corresponding
templates page.
This class is not intended to be instantiated or subclassed by clients.
PageBookView.PageRec, PageBookView.SelectionProvider
Modifier and Type | Field and Description |
---|---|
static String |
ID
The id for this view.
|
PROP_TITLE
Constructor and Description |
---|
TemplatesView()
Creates a templates view.
|
Modifier and Type | Method and Description |
---|---|
protected IPage |
createDefaultPage(PageBook book)
Creates and returns the default page for this view.
|
void |
createPartControl(Composite parent)
The
PageBookView implementation of this
IWorkbenchPart method creates a PageBook
control with its default page showing. |
protected PageBookView.PageRec |
doCreatePage(IWorkbenchPart part)
Creates a new page in the pagebook for a particular part.
|
protected void |
doDestroyPage(IWorkbenchPart part,
PageBookView.PageRec rec)
Destroys a page in the pagebook for a particular part.
|
protected IWorkbenchPart |
getBootstrapPart()
Returns the active, important workbench part for this view.
|
TemplatePersistenceData[] |
getSelectedTemplates()
Returns the currently selected templates.
|
TemplateStore |
getTemplateStore()
Returns the template store of the current page.
|
protected boolean |
isImportant(IWorkbenchPart part)
Returns whether the given part should be added to this view.
|
void |
partBroughtToTop(IWorkbenchPart part)
The
PageBookView implementation of this
IPartListener method does nothing. |
dispose, doesPageExist, getAdapter, getCurrentContributingPart, getCurrentPage, getDefaultPage, getPageBook, getPageRec, getPageRec, getPageSite, getSelectionProvider, getViewAdapter, init, initPage, partActivated, partClosed, partDeactivated, partHidden, partOpened, partVisible, setFocus, showPageRec
checkSite, getViewSite, init, saveState, setContentDescription, setInitializationData, setPartName
addPartPropertyListener, addPropertyListener, firePartPropertyChanged, firePropertyChange, getConfigurationElement, getContentDescription, getDefaultImage, getOrientation, getPartName, getPartProperties, getPartProperty, getSite, getTitle, getTitleImage, getTitleToolTip, removePartPropertyListener, removePropertyListener, setPartProperty, setSite, setTitle, setTitleImage, setTitleToolTip, showBusy
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addPropertyListener, getSite, getTitle, getTitleImage, getTitleToolTip, removePropertyListener
public static final String ID
Note: Only this id is allowed when contributing this view via extension point.
protected IPage createDefaultPage(PageBook book)
PageBookView
Subclasses must implement this method.
Subclasses must call initPage with the new page (if it is an
IPageBookViewPage
) before calling createControl on the
page.
createDefaultPage
in class PageBookView
book
- the pagebook controlpublic void createPartControl(Composite parent)
PageBookView
PageBookView
implementation of this
IWorkbenchPart
method creates a PageBook
control with its default page showing. Subclasses may extend.createPartControl
in interface IWorkbenchPart
createPartControl
in class PageBookView
parent
- the parent controlprotected PageBookView.PageRec doCreatePage(IWorkbenchPart part)
PageBookView
doDestroyPage
.
Subclasses must implement this method.
Subclasses must call initPage with the new page (if it is an
IPageBookViewPage
) before calling createControl on the
page.
doCreatePage
in class PageBookView
part
- the input partPageBookView.doDestroyPage(org.eclipse.ui.IWorkbenchPart, org.eclipse.ui.part.PageBookView.PageRec)
protected void doDestroyPage(IWorkbenchPart part, PageBookView.PageRec rec)
PageBookView
doCreatePage
.
Subclasses must implement this method.
doDestroyPage
in class PageBookView
part
- the input partrec
- a page record for the partPageBookView.doCreatePage(org.eclipse.ui.IWorkbenchPart)
protected IWorkbenchPart getBootstrapPart()
PageBookView
When the page book view is created it has no idea which part within the
workbook should be used to generate the first page. Therefore, it
delegates the choice to subclasses of PageBookView
.
Implementors of this method should return an active, important part in
the workbench or null
if none found.
Subclasses must implement this method.
getBootstrapPart
in class PageBookView
null
if noneprotected boolean isImportant(IWorkbenchPart part)
PageBookView
Subclasses must implement this method.
isImportant
in class PageBookView
part
- the input parttrue
if the part is relevant, and
false
otherwisepublic void partBroughtToTop(IWorkbenchPart part)
PageBookView
PageBookView
implementation of this
IPartListener
method does nothing. Subclasses may extend.partBroughtToTop
in interface IPartListener
partBroughtToTop
in class PageBookView
part
- the part that was surfacedIWorkbenchPage.bringToTop(org.eclipse.ui.IWorkbenchPart)
public TemplateStore getTemplateStore()
null
if the current page does not provide that
informationpublic TemplatePersistenceData[] getSelectedTemplates()
null
if the current page does not
provide that information
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.