/** * Creates a site for the given editor nested within the given multi-page editor. * * @param multiPageEditor * the multi-page editor * @param editor * the nested editor */ public MultiPageToolbarEditorSite(MultiPageToolbarEditorPart multiPageEditor, IEditorPart editor) { Assert.isNotNull(multiPageEditor); Assert.isNotNull(editor); this.multiPageEditor = multiPageEditor; this.editor = editor; final IServiceLocator parentServiceLocator = multiPageEditor.getSite(); IServiceLocatorCreator slc = (IServiceLocatorCreator) parentServiceLocator.getService(IServiceLocatorCreator.class); this.serviceLocator = (ServiceLocator) slc.createServiceLocator(multiPageEditor.getSite(), null, new IDisposable() { public void dispose() { // Fix for ensuring compilation in E4 getMultiPageEditor().close(); } }); initializeDefaultServices(); }
public void dispose() { pageChangeListeners.clear(); for (IEditorPart editor : nestedEditors) { disposePart(editor); } nestedEditors.clear(); if (pageContainerSite instanceof IDisposable) { ((IDisposable) pageContainerSite).dispose(); pageContainerSite = null; } for (IServiceLocator sl : pageSites) { if (sl instanceof IDisposable) { ((IDisposable) sl).dispose(); } } pageSites.clear(); super.dispose(); }
private void deactivate() throws Exception { if (controller==null) return; Object ui = controller.getUI(); if (ui instanceof Composite) { Composite composite = (Composite)ui; GridUtils.setVisible(composite, false); composite.dispose(); } if (ui instanceof IDisposable) { ((IDisposable)ui).dispose(); } controller.dispose(); }
protected void doResetProvider() { boolean tracking = true; Object input = viewer.getInput(); if (input instanceof FolderPreferenceProvider) { ((IDisposable) input).dispose(); tracking = ((FolderPreferenceProvider) input).isTracking(); } setupPreferenceProvider(tracking); }
@Override public void dispose() { Object input = viewer.getInput(); if (input instanceof IDisposable) { ((IDisposable) input).dispose(); } super.dispose(); }
/** * Returns the service locator for the given page index. This method can be used to create service locators for pages * that are just controls. The page index must be valid. * <p> * This will return the editor site service locator for an editor, and create one for a page that is just a control. * </p> * * @param pageIndex * the index of the page * @return the editor for the specified page, or <code>null</code> if the specified page was not created with * <code>addPage(IEditorPart,IEditorInput)</code> * @since 3.4 */ protected final IServiceLocator getPageSite(int pageIndex) { if (pageIndex == PAGE_CONTAINER_SITE) { return getPageContainerSite(); } Item item = getItem(pageIndex); if (item != null) { Object data = item.getData(); if (data instanceof IEditorPart) { return ((IEditorPart) data).getSite(); } else if (data instanceof IServiceLocator) { return (IServiceLocator) data; } else if (data == null) { IServiceLocatorCreator slc = (IServiceLocatorCreator) getSite().getService(IServiceLocatorCreator.class); IServiceLocator sl = slc.createServiceLocator(getSite(), null, new IDisposable() { public void dispose() { close(); } }); item.setData(sl); pageSites.add(sl); return sl; } } return null; }
/** * @return A site that can be used with a header. * @since 3.4 * @see #createPageContainer(Composite) * @see #PAGE_CONTAINER_SITE * @see #getPageSite(int) */ private IServiceLocator getPageContainerSite() { if (pageContainerSite == null) { IServiceLocatorCreator slc = (IServiceLocatorCreator) getSite().getService(IServiceLocatorCreator.class); pageContainerSite = slc.createServiceLocator(getSite(), null, new IDisposable() { public void dispose() { close(); } }); } return pageContainerSite; }
@Override public void dispose() { for (IContributionItem item : menuManager.getItems()) if (item instanceof ActionContributionItem && ((ActionContributionItem) item).getAction() instanceof IDisposable) ((IDisposable) ((ActionContributionItem) item).getAction()).dispose(); menuManager.dispose(); }
public void removeAll() { for (IContributionItem it : tbManager.getItems()) { if (it instanceof ActionContributionItem && ((ActionContributionItem) it).getAction() instanceof IDisposable) ((IDisposable) ((ActionContributionItem) it).getAction()).dispose(); else if (it instanceof ContributionItem) it.dispose(); } tbManager.removeAll(); }
@Override public IDisposable createPlotDisposable(String plotName) throws Exception { // We plot to an offscreen plotting system, then take a screen shot of this. final PlotDisposable ret = new PlotDisposable(); IPlottingSystem<?> system = plotName!=null ? PlottingFactory.getPlottingSystem(plotName) : PlottingFactory.getLightWeightPlottingSystem(); if (system==null) system = PlottingFactory.getLightWeightPlottingSystem(); ret.setSystem(system); if (system.getPlotComposite()==null) { Display.getDefault().syncExec(new Runnable() { public void run() { final Shell shell = new Shell(Display.getDefault(), SWT.RESIZE|SWT.NO_TRIM); ret.setShell(shell); shell.setSize(600, 600); shell.setLayout(new FillLayout()); final Composite main = new Composite(shell, SWT.NONE); main.setLayout(new GridLayout(1, false)); final Composite plotter = new Composite(main, SWT.NONE); plotter.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); ret.getSystem().createPlotPart(plotter, "Thumbnail", null, PlotType.XY, null); } }); } return ret; }
public static void disposeParameter( String parameterId, Command command ) throws NotDefinedException { ParameterType parameterType = command.getParameterType( parameterId ); Object valueConverter = parameterType.getValueConverter( ); if ( valueConverter instanceof IDisposable ) ( (IDisposable) valueConverter ).dispose( ); }
public IDisposable getDisposable() { return disposable; }
public void setDisposible(IDisposable disposable) { this.disposable = disposable; }
/** * Creates an object which may be used to cache the plotting system * when looping over a stack and getting many images. For instance when * exporting surface or 1D plots. This IDisposable is then set in the * call to PlotImageData to make it more efficient. * * THREAD SAFE * * @param plotName to use to look up plotting system (can be null) * @return * @throws Exception */ public IDisposable createPlotDisposable(String plotName) throws Exception;