@@ -0,0 +1,3151 @@
+/*******************************************************************************%0A * Copyright (c) 2012 Oak Ridge National Laboratory.%0A * All rights reserved. This program and the accompanying materials%0A * are made available under the terms of the Eclipse Public License v1.0%0A * which accompanies this distribution, and is available at%0A * http://www.eclipse.org/legal/epl-v10.html%0A ******************************************************************************/%0Apackage org.csstudio.ui.util;%0A%0Aimport org.eclipse.jface.resource.ImageDescriptor;%0Aimport org.eclipse.rwt.resources.IResource;%0Aimport org.eclipse.ui.IEditorInput;%0Aimport org.eclipse.ui.IPersistableElement;%0A%0A/** Terrible Hack to avoid extra context menu entries%0A *%0A *  %3Cp%3EEclipse Editors are often associated with a file,%0A *  specifically %3Ccode%3EIFile%3C/code%3E which is an %7B@link IResource%7D.%0A *  Depending on what else is included in the overall%0A *  product, the context menu of such editors will then receive%0A *  certain menu entries that don't make sense to the end user:%0A *  %3Cul%3E%0A *  %3Cli%3ETeam support adds %22Team%22, %22Compare With%22, %22Replace With%22%0A *      even though your editor may not really participare%0A *      in team and local history.%0A *  %3Cli%3Eorg.eclipse.debug.ui adds %22Run As%22, %22Debug As%22%0A *      even though your editor may not represent anything%0A *      %22runnable%22%0A *  %3Cli%3EPyDev adds more python-refactoring code even%0A *      though your editor has nothing to do with python%0A *  %3C/ul%3E%0A *%0A *  %3Cp%3EWhen inspecting for example org.eclipse.debug.ui/plugin.xml%0A *  of Eclipse 3.7.2, it turned out to contribute the %22Run As%22%0A *  context menu for any editor input that adapts to IResource.%0A *%0A *  %3Cp%3ETo avoid such context menu entries, we wrap the actual%0A *  editor input into something that does %3Cu%3Enot%3C/u%3E adapt%0A *  to a plain %7B@link IResource%7D, but otherwise forwards%0A *  to the original %7B@link IEditorInput%7D.%0A *  When the editor wraps its input (received in %3Ccode%3Einit()%3C/code%3E%0A *  and maybe set in %3Ccode%3EsaveAs()%3C/code%3E%0A *  the nonapplicable context menu entries can be avoided%0A *  - at least with Eclipse 3.7.2 for team, debug.ui and PyDev;%0A *  it is a hack after all.%0A *%0A *  @author Kay Kasemir%0A */%0Apublic class NoResourceEditorInput implements IEditorInput%0A%7B%0A    final private IEditorInput orig;%0A%0A    /** Initialize%0A     *  @param orig Original editor input%0A     */%0A    public NoResourceEditorInput(final IEditorInput orig)%0A    %7B%0A        this.orig = orig;%0A    %7D%0A%0A    /** Do NOT adapt to IResource */%0A    @SuppressWarnings(%22rawtypes%22)%0A    public Object getAdapter(Class adapter)%0A    %7B%0A        return orig.getAdapter(adapter);%0A    %7D%0A%0A    // Rest just forwards to original implementation...%0A    public boolean exists()%0A    %7B%0A        return orig.exists();%0A    %7D%0A%0A    public ImageDescriptor getImageDescriptor()%0A    %7B%0A        return orig.getImageDescriptor();%0A    %7D%0A%0A    public String getName()%0A    %7B%0A        return orig.getName();%0A    %7D%0A%0A    public IPersistableElement getPersistable()%0A    %7B%0A        return orig.getPersistable();%0A    %7D%0A%0A    public String getToolTipText()%0A    %7B%0A        return orig.getToolTipText();%0A    %7D%0A%0A%09public IEditorInput getOriginEditorInput() %7B%0A%09%09return orig;%0A%09%7D%0A%7D%0A

add NoresourceEditorInput