@Override public IEditorActionBarContributor getActionBarContributor() { return new IEditorActionBarContributor() { @Override public void setActiveEditor(IEditorPart targetEditor) { } @Override public void init(IActionBars bars, IWorkbenchPage page) { } @Override public void dispose() { } }; }
/** * Notifies action bar contributor about page change. * * @param pageIndex * the index of the new page */ protected void updateActionBarContributor( int pageIndex ) { super.updateActionBarContributor( pageIndex ); // Overwrite this method to implement multi-editor action bar // contributor IEditorActionBarContributor contributor = getEditorSite( ).getActionBarContributor( ); if ( contributor instanceof IMultiPageEditorActionBarContributor && pageIndex >= 0 && pageIndex < pages.size( ) ) { Object page = pages.get( pageIndex ); if ( page instanceof IFormPage ) { ( (IMultiPageEditorActionBarContributor) contributor ).setActivePage( (IFormPage) page ); } } }
@Override public void setActiveEditor(IEditorPart newEditor) { if (this.editor == newEditor) return; String currentLayer = null; if (this.editor != null) { TerrainLayer layer = this.editor.getActiveLayer(); if (layer != null) { currentLayer = layer.getName(); } this.editor.setActiveLayer(null); } if (!(newEditor instanceof TerrainEditor)) { this.editor = null; return; } this.editor = (TerrainEditor) newEditor; for(IEditorActionBarContributor c : contributors.values()) c.setActiveEditor(editor); editor.setActiveLayer(editor.getLayerByName(currentLayer)); }
@Override protected void postPageChange(int newPageIndex, int oldPageIndex) { AbstractVisualEditor activeEditor = editors.get(newPageIndex); //request the rapaint of the element on the main editor node when switching between the subeditors, supposing they were modified in the subeditor if (oldPageIndex > 0){ AbstractVisualEditor oldEditor = editors.get(oldPageIndex); INode subModel = getInnerModel(oldEditor.getModel()); ((JRChangeEventsSupport)subModel.getValue()).getEventSupport().firePropertyChange(MGraphicElement.FORCE_GRAPHICAL_REFRESH, null, null); } IEditorActionBarContributor contributor = parent.getEditorSite().getActionBarContributor(); if (contributor != null && contributor instanceof MultiPageEditorActionBarContributor) { ((MultiPageEditorActionBarContributor) contributor).setActivePage(activeEditor); } }
/** * {@inheritDoc} This method needs to be overriden so that when you switch between the editors the * actionbarcontributer takes the actionregistry/graphicalViewer/CommandStack from the active * editor. * */ @Override protected void pageChange(final int newPageIndex) { super.pageChange(newPageIndex); IEditorPart activeEditor = getEditor(newPageIndex); IEditorActionBarContributor contributor = getEditorSite().getActionBarContributor(); if (contributor != null && contributor instanceof ORMGraphicalEditorActionBarContributor) { ((ORMGraphicalEditorActionBarContributor) contributor).setActiveEditor(activeEditor); } }
public IEditorActionBarContributor createActionBarContributor( ) { Object def = loadClass( element, ATTRIBUTE_ACTION_BAR_CONTRIBUTOR ); if ( def instanceof IEditorActionBarContributor ) { return (IEditorActionBarContributor) def; } return null; }
public static IStatusLineManager getStatusLineManager(ITextEditor editor) { IEditorActionBarContributor contributor = editor.getEditorSite().getActionBarContributor(); if (!(contributor instanceof EditorActionBarContributor)) { return null; } IActionBars actionBars = ((EditorActionBarContributor) contributor).getActionBars(); if (actionBars == null) { return null; } return actionBars.getStatusLineManager(); }
@Override public void init(IActionBars bars, IWorkbenchPage page) { super.init(bars, page); for (LayerDefinition def : Activator.getLayerDefinitions().values()) { Class<? extends IEditorActionBarContributor> clazz = def.getActionBarContributorClass(); if (clazz != null) try { IEditorActionBarContributor c = clazz.newInstance(); c.init(bars, page); contributors.put(def.getName(), c); } catch (InstantiationException | IllegalAccessException e) { e.printStackTrace(); } } ToolBarManager toolBarManager = (ToolBarManager) bars.getToolBarManager(); IContributionItem[] items = toolBarManager.getItems(); for (int i = 0; i < items.length; i++) { if (items[i] instanceof ActionContributionItem) { ActionContributionItem item = (ActionContributionItem) items[i]; IAction action = item.getAction(); if (action instanceof EditorToolAction) { toolBarManager.remove(items[i]); SaveActionContributionItem ci = new SaveActionContributionItem(action); toolBarManager.insert(i, ci); actions.put(action.getId(), ci); action.addPropertyChangeListener(this); } } } setActiveTool(TerrainEditor.ACTION_CURSOR); }
public LayerDefinition(IConfigurationElement conf) throws Exception { this.name = conf.getAttribute("name"); Bundle plugin = Platform.getBundle(conf.getContributor().getName()); this.layerClass = (Class<? extends TerrainLayer>) plugin.loadClass(conf.getAttribute("class")); System.out.println("[Activator] Registriere Layer: " + layerClass.getName()); if (conf.getAttribute("contributorClass") != null) { this.contributorClass = (Class<? extends IEditorActionBarContributor>) plugin.loadClass(conf.getAttribute("contributorClass")); } }
protected void pageChange(final int newPageIndex, final int oldPageIndex) { getActiveEditor(); deactivateSite(false, false); IPartService partService = (IPartService) getSite().getService(IPartService.class); if (partService.getActivePart() == this) { setFocus(); } IEditorPart activeEditor = getEditor(newPageIndex); IEditorActionBarContributor contributor = getEditorSite().getActionBarContributor(); if (contributor != null && contributor instanceof MultiPageEditorActionBarContributor) { ((MultiPageEditorActionBarContributor) contributor).setActivePage(activeEditor); } if (activeEditor != null) { ISelectionProvider selectionProvider = activeEditor.getSite().getSelectionProvider(); if (selectionProvider != null) { ISelectionProvider outerProvider = getSite().getSelectionProvider(); if (outerProvider instanceof MultiPageToolbarSelectionProvider) { SelectionChangedEvent event = new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection()); MultiPageToolbarSelectionProvider provider = (MultiPageToolbarSelectionProvider) outerProvider; provider.fireSelectionChanged(event); provider.firePostSelectionChanged(event); } else { if (Policy.DEBUG_MPE) { Tracing.printTrace(TRACING_COMPONENT, "MultiPageEditorPart " + getTitle() //$NON-NLS-1$ + " did not propogate selection for " //$NON-NLS-1$ + activeEditor.getTitle()); } } } } activateSite(); postPageChange(newPageIndex, oldPageIndex); Object selectedPage = getSelectedPage(); if (selectedPage != null) { firePageChanged(new PageChangedEvent(this, selectedPage)); } }
@Override public IEditorActionBarContributor getActionBarContributor() { // PDEFormEditor editor = (PDEFormEditor) getMultiPageEditor(); // PDEFormEditorContributor contributor = editor.getContributor(); return null;// contributor.getSourceContributor(); }
public SubActionBarDef( IActionBars rootBar, IEditorActionBarContributor actionBarContrubutor ) { this.subActionBar = new SubActionBars( rootBar ); this.actionBarContrubutor = actionBarContrubutor; }
public void setActivePage( IFormPage page ) { if ( page == null ) { return; } if ( subBarMap == null ) { subBarMap = new HashMap( ); } if ( currentActionBarDef != null ) { currentActionBarDef.deactivate( ); currentActionBarDef.dispose( ); currentActionBarDef = null; } IActionBars rootBar = getActionBars( ); if ( page != null ) { // currentActionBarDef = (SubActionBarDef) subBarMap.get( // page.getId( ) ); if ( currentActionBarDef == null ) { FormEditor editor = page.getEditor( ); if ( editor != null ) { EditorContributor contributor = EditorContributorManager.getInstance( ) .getEditorContributor( editor.getSite( ).getId( ) ); if ( contributor != null ) { FormPageDef pageDef = contributor.getPage( page.getId( ) ); if ( pageDef != null ) { IEditorActionBarContributor actionBarContributor = pageDef.createActionBarContributor( ); if ( actionBarContributor != null ) { currentActionBarDef = new SubActionBarDef( rootBar, actionBarContributor ); currentActionBarDef.init( getPage( ) ); // subBarMap.put( page.getId( ), // currentActionBarDef // ); } } } } } } rootBar.clearGlobalActionHandlers( ); if ( currentActionBarDef != null ) { currentActionBarDef.setActiveEditor( page ); Map handlers = currentActionBarDef.getSubActionBar( ) .getGlobalActionHandlers( ); if ( handlers != null ) { for ( Iterator iter = handlers.entrySet( ).iterator( ); iter.hasNext( ); ) { Map.Entry entry = (Map.Entry) iter.next( ); rootBar.setGlobalActionHandler( entry.getKey( ).toString( ), (IAction) entry.getValue( ) ); } } currentActionBarDef.activate( ); currentActionBarDef.updateActionBars( ); } rootBar.getToolBarManager( ).update( true ); rootBar.updateActionBars( ); }
@Override public IEditorActionBarContributor getActionBarContributor() { // TODO Auto-generated method stub return null; }
public Class<? extends IEditorActionBarContributor> getActionBarContributorClass() { return contributorClass; }
/** * The <code>MultiPageEditorSite</code> implementation of this <code>IEditorSite</code> method returns * <code>null</code>, since nested editors do not have their own action bar contributor. * * @return <code>null</code> */ public IEditorActionBarContributor getActionBarContributor() { return null; }
/** * <!-- begin-user-doc --> <!-- end-user-doc --> * * @generated */ public IEditorActionBarContributor getActionBarContributor() { return getEditorSite().getActionBarContributor(); }