下面列出了怎么用org.eclipse.ui.SubActionBars的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Creates the viewer. Registers the full outline at the document model.
*/
public void createPartControl(Composite parent) {
PageSite site = new PageSite(getViewSite());
outline.init(site);
outline.createControl(parent);
((SubActionBars) site.getActionBars()).activate(true);
outline.switchTreeViewerSelectionChangeListener(this);
// add a part listener if the editor isn't available when the view is created.
getSite().getPage().addPartListener(this);
// register it directly if the view is already created.
IEditorPart part = getSite().getPage().getActiveEditor();
if (part != null && part instanceof TexEditor) {
TexEditor e = (TexEditor) part;
e.registerFullOutline(this);
}
}
public void propertyChange( PropertyChangeEvent event )
{
RegisterAction[] actions = getInsertElementActions( );
if ( actions != null )
{
for ( int i = 0; i < actions.length; i++ )
{
if ( event.getProperty( )
.equals( SubActionBars.P_ACTION_HANDLERS ) )
{
if ( getAction( actions[i].id ) instanceof ReportRetargetAction )
{
( (ReportRetargetAction) getAction( actions[i].id ) ).propagateChange( event );
}
}
}
}
}
public void init( IActionBars bars )
{
super.init( bars );
if ( bars instanceof SubActionBars )
{
( (SubActionBars) bars ).addPropertyChangeListener( propertyChangeListener );
}
}
@Override
public void dispose( )
{
if ( toggleBreadcrumbAction != null )
{
toggleBreadcrumbAction.dispose( );
}
if ( getActionBars( ) instanceof SubActionBars )
{
( (SubActionBars) getActionBars( ) ).removePropertyChangeListener( propertyChangeListener );
}
super.dispose( );
}
/**
* Creates and shows the page, if page is null
* the not available message will be shown.
*
* @param page the page
*/
protected void initializeAndShowPage(IPageBookViewPage page) {
if (book != null) {
if (page != null) {
page.createControl(book);
casViewPage = page;
// Note: If page is in background event listening must be disabled!
ISelectionProvider selectionProvider = page.getSite().getSelectionProvider();
selectionProvider.addSelectionChangedListener(CasEditorViewPage.this::selectionChanged);
subActionBar = (SubActionBars) casViewPage.getSite().getActionBars();
casViewPage.setActionBars(subActionBar);
subActionBar.activate();
subActionBar.updateActionBars();
refreshActionHandlers();
book.showPage(page.getControl());
}
else {
book.showPage(messageText);
getSite().getActionBars().updateActionBars();
}
}
}
@Override
public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage){
super.createControls(parent, aTabbedPropertySheetPage);
fc = new FaelleComposite(parent, SWT.None, aTabbedPropertySheetPage);
aTabbedPropertySheetPage.getWidgetFactory().adapt(fc);
aTabbedPropertySheetPage.getWidgetFactory().paintBordersFor(fc);
subActionBars = new SubActionBars(aTabbedPropertySheetPage.getSite().getActionBars());
// COMPAT
subActionBars.getToolBarManager().add(GlobalActions.neuerFallAction);
}
public SubActionBarDef( IActionBars rootBar,
IEditorActionBarContributor actionBarContrubutor )
{
this.subActionBar = new SubActionBars( rootBar );
this.actionBarContrubutor = actionBarContrubutor;
}
public SubActionBars getSubActionBar( )
{
return subActionBar;
}