From: Jakub Adam <jakub.adam@ktknet.cz>
Date: Sat, 28 Jan 2012 18:28:16 +0100
Subject: remove-pre-eclipse-3.7.0-compatibility

These classes are both useless and uncompilable with current Eclipse
---
 .../de/loskutov/anyedit/AnyEditToolsPlugin.java    |    7 +-
 .../actions/internal/SpecialSaveAction.java        |  152 ---------
 .../actions/internal/SpecialSaveAllAction.java     |  191 -----------
 .../anyedit/actions/internal/StartupHelper.java    |  337 --------------------
 4 files changed, 1 insertions(+), 686 deletions(-)
 delete mode 100644 AnyEditTools/src/de/loskutov/anyedit/actions/internal/SpecialSaveAction.java
 delete mode 100644 AnyEditTools/src/de/loskutov/anyedit/actions/internal/SpecialSaveAllAction.java
 delete mode 100644 AnyEditTools/src/de/loskutov/anyedit/actions/internal/StartupHelper.java

diff --git a/AnyEditTools/src/de/loskutov/anyedit/AnyEditToolsPlugin.java b/AnyEditTools/src/de/loskutov/anyedit/AnyEditToolsPlugin.java
index b7906ab..52473f1 100644
--- a/AnyEditTools/src/de/loskutov/anyedit/AnyEditToolsPlugin.java
+++ b/AnyEditTools/src/de/loskutov/anyedit/AnyEditToolsPlugin.java
@@ -17,7 +17,6 @@ import org.eclipse.ui.IStartup;
 import org.eclipse.ui.plugin.AbstractUIPlugin;
 import org.osgi.framework.Version;
 
-import de.loskutov.anyedit.actions.internal.StartupHelper;
 import de.loskutov.anyedit.actions.internal.StartupHelper2;
 import de.loskutov.anyedit.util.EclipseUtils;
 
@@ -115,11 +114,7 @@ public class AnyEditToolsPlugin extends AbstractUIPlugin implements IStartup {
 
     public void earlyStartup() {
         // hooks into the global toolbar/menu
-        if(EclipseUtils.getWorkbenchVersion().compareTo(new Version(3,7,0)) >= 0) {
-            new StartupHelper2().init();
-        } else {
-            new StartupHelper().init();
-        }
+        new StartupHelper2().init();
         setSaveHookInitialized(true);
     }
 }
diff --git a/AnyEditTools/src/de/loskutov/anyedit/actions/internal/SpecialSaveAction.java b/AnyEditTools/src/de/loskutov/anyedit/actions/internal/SpecialSaveAction.java
deleted file mode 100644
index bd0be63..0000000
--- a/AnyEditTools/src/de/loskutov/anyedit/actions/internal/SpecialSaveAction.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Andrei Loskutov.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- * Contributor:  Andrei Loskutov - initial API and implementation
- *******************************************************************************/
-package de.loskutov.anyedit.actions.internal;
-
-import java.lang.reflect.Field;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.internal.PageEventAction;
-import org.eclipse.ui.internal.SaveAction;
-
-import de.loskutov.anyedit.AnyEditToolsPlugin;
-import de.loskutov.anyedit.IAnyEditConstants;
-import de.loskutov.anyedit.actions.Spaces;
-import de.loskutov.anyedit.ui.editor.AbstractEditor;
-import de.loskutov.anyedit.util.EclipseUtils;
-
-
-/**
- * @author Andrei
- */
-public class SpecialSaveAction extends SaveAction implements IDirtyWorkaround {
-
-    private final Spaces spacesAction;
-    private final IAction spacesToTabs = new DummyAction(IAnyEditConstants.ACTION_ID_CONVERT_SPACES);
-    private final IAction tabsToSpaces = new DummyAction(IAnyEditConstants.ACTION_ID_CONVERT_TABS);
-
-    /**
-     * @param window
-     */
-    public SpecialSaveAction(IWorkbenchWindow window) {
-        super(window);
-        spacesAction = new Spaces(){
-            protected AbstractEditor createActiveEditorDelegate() {
-                // this just returns the editor instance we already know, see runSpecial()
-                return getEditor();
-            }
-            public void setEditor(AbstractEditor editor) {
-                if(editor == null && getEditor() != null){
-                    getEditor().dispose();
-                }
-                this.editor = editor;
-            }
-        };
-        spacesAction.setUsedOnSave(true);
-    }
-
-    /**
-     * Performs the 'convert spaces' action before the editor buffer is saved
-     */
-    public void runBeforeSave() {
-        try {
-            runSpecial();
-        } catch (Throwable e) {
-            // to avoid any problems with any possible environements
-            // we trying to catch all errors to allow perform base save action
-            AnyEditToolsPlugin.logError("Cannot perform custom pre-save action", e); //$NON-NLS-1$
-        } finally {
-            spacesAction.setEditor(null);
-        }
-    }
-
-    public void run() {
-        runBeforeSave();
-        super.run();
-    }
-
-    private void runSpecial() {
-        if (getWindow() == null) {
-            // action has been disposed
-            return;
-        }
-        IEditorPart part = getActiveEditor();
-        if(part == null) {
-            return;
-        }
-        spacesAction.setActiveEditor(null, part);
-        boolean trim = spacesAction.isSaveAndTrimEnabled();
-        boolean convert = spacesAction.isSaveAndConvertEnabled();
-        if(trim || convert){
-            if(EclipseUtils.matchFilter(part, spacesAction.getCombinedPreferences())){
-                return;
-            }
-            final IAction action;
-            if(spacesAction.isDefaultTabToSpaces()){
-                action = tabsToSpaces;
-            } else {
-                action = spacesToTabs;
-            }
-            spacesAction.run(action);
-        }
-    }
-
-    public void copyStateAndDispose(IContributionItem oldItem){
-        if(oldItem == null || !(oldItem instanceof ActionContributionItem)){
-            return;
-        }
-        IAction action = ((ActionContributionItem) oldItem).getAction();
-        if(! (action instanceof SaveAction)){
-            return;
-        }
-        PageEventAction oldAction = (PageEventAction) action;
-        IWorkbenchPart activePart = oldAction.getActivePart();
-        if(activePart != null){
-            partActivated(activePart);
-        }
-        IWorkbenchPage activePage = oldAction.getActivePage();
-        if(activePage != null){
-            pageActivated(activePage);
-        }
-        // this will remove page/window listeners but will lead to crash on 3.3 shutdown
-        IWorkbenchWindow window = oldAction.getWorkbenchWindow();
-        if(window != null){
-            oldAction.dispose();
-            try {
-                Field field = PageEventAction.class.getDeclaredField("workbenchWindow");
-                field.setAccessible(true);
-                field.set(oldAction, window);
-            } catch (Exception e) {
-                AnyEditToolsPlugin.logError("Cannot properly dispose save action", e);
-            }
-        }
-
-    }
-
-    public IWorkbenchWindow getWindow() {
-        return getWorkbenchWindow();
-    }
-
-    private static final class DummyAction extends Action {
-
-        /**
-         * @param actionId
-         */
-        public DummyAction(String actionId) {
-            setId(actionId);
-        }
-
-    }
-}
diff --git a/AnyEditTools/src/de/loskutov/anyedit/actions/internal/SpecialSaveAllAction.java b/AnyEditTools/src/de/loskutov/anyedit/actions/internal/SpecialSaveAllAction.java
deleted file mode 100644
index 3f51c80..0000000
--- a/AnyEditTools/src/de/loskutov/anyedit/actions/internal/SpecialSaveAllAction.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Andrei Loskutov.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- * Contributor:  Andrei Loskutov - initial API and implementation
- *******************************************************************************/
-package de.loskutov.anyedit.actions.internal;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorReference;
-import org.eclipse.ui.IViewReference;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.internal.PageEventAction;
-import org.eclipse.ui.internal.SaveAllAction;
-
-import de.loskutov.anyedit.AnyEditToolsPlugin;
-import de.loskutov.anyedit.IAnyEditConstants;
-import de.loskutov.anyedit.actions.Spaces;
-import de.loskutov.anyedit.ui.editor.AbstractEditor;
-import de.loskutov.anyedit.util.EclipseUtils;
-
-/**
- * @author Andrei
- */
-public class SpecialSaveAllAction extends SaveAllAction implements IDirtyWorkaround {
-
-    private final Spaces spacesAction;
-
-    private final IAction spacesToTabs = new DummyAction(IAnyEditConstants.ACTION_ID_CONVERT_SPACES);
-
-    private final IAction tabsToSpaces = new DummyAction(IAnyEditConstants.ACTION_ID_CONVERT_TABS);
-
-    public SpecialSaveAllAction(IWorkbenchWindow window) {
-        super(window);
-        spacesAction = new Spaces() {
-            protected AbstractEditor createActiveEditorDelegate() {
-                // this just returns the editor instance we already know, see runSpecial()
-                return getEditor();
-            }
-
-            public void setEditor(AbstractEditor editor) {
-                if (editor == null && getEditor() != null) {
-                    getEditor().dispose();
-                }
-                this.editor = editor;
-            }
-        };
-        spacesAction.setUsedOnSave(true);
-
-        IWorkbenchPage page = getActivePage();
-        if (page != null) {
-            IEditorReference[] editorReferences = page.getEditorReferences();
-            for (int i = 0; i < editorReferences.length; i++) {
-                IWorkbenchPart part = editorReferences[i].getPart(false);
-                if (part != null) {
-                    partOpened(part);
-                }
-            }
-            IViewReference[] viewReferences = page.getViewReferences();
-            for (int i = 0; i < viewReferences.length; i++) {
-                IWorkbenchPart part = viewReferences[i].getPart(false);
-                if (part != null) {
-                    partOpened(part);
-                }
-            }
-        }
-    }
-
-    /**
-     * Performs the 'convert spaces' action before the editor buffer is saved
-     */
-    public void runBeforeSave() {
-        try {
-            runSpecial();
-        } catch (Throwable e) {
-            // to avoid any problems with any possible environements
-            // we trying to catch all errors to allow perform base save action
-            AnyEditToolsPlugin.logError("Cannot perform custom pre-save action", e); //$NON-NLS-1$
-        } finally {
-            spacesAction.setEditor(null);
-        }
-    }
-
-    public void run() {
-        runBeforeSave();
-        super.run();
-    }
-
-    private void runSpecial() {
-        if (getWindow() == null) {
-            // action has been disposed
-            return;
-        }
-        IWorkbenchPage page = getActivePage();
-        final IEditorPart[] dirtyEditors = page.getDirtyEditors();
-
-        final int editorsCount = dirtyEditors.length;
-        if(editorsCount == 0) {
-            return;
-        }
-        IRunnableWithProgress runnable = new IRunnableWithProgress() {
-
-            public void run(IProgressMonitor monitor) throws InvocationTargetException,
-            InterruptedException {
-                monitor.beginTask("Converting tabs <-> spaces before save", editorsCount);
-                try {
-                    for (int i = 0; i < editorsCount; i++) {
-                        if (monitor.isCanceled()) {
-                            break;
-                        }
-                        monitor.worked(1);
-                        IEditorPart part = dirtyEditors[i];
-                        spacesAction.setActiveEditor(null, part);
-                        boolean trim = spacesAction.isSaveAndTrimEnabled();
-                        boolean convert = spacesAction.isSaveAndConvertEnabled();
-                        if (trim || convert) {
-                            if (EclipseUtils.matchFilter(part,
-                                    spacesAction.getCombinedPreferences())) {
-                                continue;
-                            }
-                            monitor.subTask(part.getTitle());
-                            final IAction action;
-                            if (spacesAction.isDefaultTabToSpaces()) {
-                                action = tabsToSpaces;
-                            } else {
-                                action = spacesToTabs;
-                            }
-                            spacesAction.run(action);
-                        }
-                    }
-                } finally {
-                    monitor.done();
-                }
-            }
-        };
-
-        try {
-            PlatformUI.getWorkbench().getProgressService().run(false, true, runnable);
-        } catch (InvocationTargetException e) {
-            AnyEditToolsPlugin.logError("Error during custom pre-save action", e);
-        } catch (InterruptedException e) {
-            // user cancel
-        }
-    }
-
-    public void copyStateAndDispose(IContributionItem oldItem) {
-        if (oldItem == null || !(oldItem instanceof ActionContributionItem)) {
-            return;
-        }
-        IAction action = ((ActionContributionItem) oldItem).getAction();
-        if (!(action instanceof SaveAllAction)) {
-            return;
-        }
-        PageEventAction oldAction = (PageEventAction) action;
-        IWorkbenchPart activePart = oldAction.getActivePart();
-        if (activePart != null) {
-            partActivated(activePart);
-        }
-        IWorkbenchPage activePage = oldAction.getActivePage();
-        if (activePage != null) {
-            pageActivated(activePage);
-        }
-        // this should remove page/window listeners
-        oldAction.dispose();
-    }
-
-    public IWorkbenchWindow getWindow() {
-        return getWorkbenchWindow();
-    }
-
-    private static final class DummyAction extends Action {
-
-        public DummyAction(String actionId) {
-            setId(actionId);
-        }
-
-    }
-}
diff --git a/AnyEditTools/src/de/loskutov/anyedit/actions/internal/StartupHelper.java b/AnyEditTools/src/de/loskutov/anyedit/actions/internal/StartupHelper.java
deleted file mode 100644
index fc3756f..0000000
--- a/AnyEditTools/src/de/loskutov/anyedit/actions/internal/StartupHelper.java
+++ /dev/null
@@ -1,337 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Andrei Loskutov.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- * Contributor:  Andrei Loskutov - initial API and implementation
- *******************************************************************************/
-package de.loskutov.anyedit.actions.internal;
-
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.commands.Command;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IExecutionListener;
-import org.eclipse.core.commands.NotHandledException;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.IContributionManager;
-import org.eclipse.jface.action.ICoolBarManager;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.ToolBarContributionItem;
-import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.ui.IWindowListener;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.application.IActionBarConfigurer;
-import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
-import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.ui.internal.WorkbenchWindow;
-import org.eclipse.ui.menus.CommandContributionItem;
-
-import de.loskutov.anyedit.AnyEditToolsPlugin;
-import de.loskutov.anyedit.IAnyEditConstants;
-
-/**
- * @author Andrei
- */
-public class StartupHelper implements IWindowListener {
-
-    private List/*<PreExecutionHandler>*/ commandListeners;
-
-    /**
-     * Will be run after workbench is started and w.window is opened
-     */
-    public StartupHelper() {
-        super();
-        commandListeners = new ArrayList();
-    }
-
-    public void init() {
-        final IWorkbench workbench = PlatformUI.getWorkbench();
-        workbench.getDisplay().asyncExec(new DirtyHookRunnable());
-        workbench.addWindowListener(this);
-    }
-
-    /**
-     * Very dirty trick to get internal handle to WorkbenchWindowConfigurer.
-     * @param ww
-     */
-    static IWorkbenchWindowConfigurer getWorkbenchWindowConfigurer(IWorkbenchWindow ww) {
-        if (!(ww instanceof WorkbenchWindow)) {
-            return null;
-        }
-        try {
-            Method method = WorkbenchWindow.class.getDeclaredMethod(
-                    "getWindowConfigurer", null);
-            method.setAccessible(true);
-            Object object = method.invoke(ww, null);
-            if (object instanceof IWorkbenchWindowConfigurer) {
-                return (IWorkbenchWindowConfigurer) object;
-            }
-        } catch (Exception e) {
-            AnyEditToolsPlugin.logError(
-                    "Can't get handle for WorkbenchWindowConfigurer", e); //$NON-NLS-1$
-        }
-        return null;
-    }
-
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.IWindowListener#windowOpened(org.eclipse.ui.IWorkbenchWindow)
-     */
-    public void windowOpened(IWorkbenchWindow window) {
-        DirtyHookRunnable dh = new DirtyHookRunnable();
-        dh.run(window);
-    }
-
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.IWindowListener#windowActivated(org.eclipse.ui.IWorkbenchWindow)
-     */
-    public void windowActivated(IWorkbenchWindow window) {
-        // ignored
-    }
-
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.IWindowListener#windowDeactivated(org.eclipse.ui.IWorkbenchWindow)
-     */
-    public void windowDeactivated(IWorkbenchWindow window) {
-        // ignored
-    }
-
-    /* (non-Javadoc)
-     * @see org.eclipse.ui.IWindowListener#windowClosed(org.eclipse.ui.IWorkbenchWindow)
-     */
-    public void windowClosed(IWorkbenchWindow window) {
-        // ignored
-        List list = commandListeners;
-        for (int i = 0; i < list.size(); i++) {
-            PreExecutionHandler listener = (PreExecutionHandler) list.get(i);
-            if(listener.myAction.getWindow() == window) {
-                unHookFromCommand(listener);
-            }
-        }
-    }
-
-    /**
-     * @param listener
-     */
-    private void unHookFromCommand(PreExecutionHandler listener) {
-        ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(
-                ICommandService.class);
-        Command command = service.getCommand(listener.commandId);
-        command.removeExecutionListener(listener);
-    }
-
-    private void hookOnCommand(final IDirtyWorkaround myAction, String commandId) {
-        ICommandService service = (ICommandService) PlatformUI.getWorkbench().getService(
-                ICommandService.class);
-        Command command = service.getCommand(commandId);
-        PreExecutionHandler listener = new PreExecutionHandler(myAction, commandId);
-        command.addExecutionListener(listener);
-        commandListeners.add(listener);
-    }
-
-    private static final class PreExecutionHandler implements IExecutionListener {
-
-        private final IDirtyWorkaround myAction;
-        private final String commandId;
-
-        private PreExecutionHandler(IDirtyWorkaround myAction, String commandId) {
-            this.myAction = myAction;
-            this.commandId = commandId;
-        }
-
-        public void notHandled(String command, NotHandledException exception) {
-            //
-        }
-
-        public void postExecuteFailure(String command, ExecutionException exception) {
-            //
-        }
-
-        public void postExecuteSuccess(String command, Object returnValue) {
-            //
-        }
-
-        public void preExecute(String command, ExecutionEvent event) {
-            myAction.runBeforeSave();
-        }
-    }
-
-    private final class DirtyHookRunnable implements Runnable {
-
-        private static final String FILE_SAVE_ALL = "org.eclipse.ui.file.saveAll";
-
-        private static final String FILE_SAVE = "org.eclipse.ui.file.save";
-
-        private static final String FILE_MENU = "file";
-
-        private static final String PRINT_BUTTON_ID = "print";
-
-        private static final String FILE_TOOLBAR = "org.eclipse.ui.workbench.file";
-
-        private DirtyHookRunnable() {
-            super();
-        }
-
-        public void run() {
-            IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
-            if (window == null) {
-                return;
-            }
-            try{
-                run(window);
-            } catch (Throwable t){
-                AnyEditToolsPlugin.logError("Can't run dirty code to replace default actions", t);
-            }
-        }
-
-        private void run(IWorkbenchWindow window) {
-            IWorkbenchWindowConfigurer wwConf = getWorkbenchWindowConfigurer(window);
-            if (wwConf == null) {
-                return;
-            }
-            final SpecialSaveAction mySaveAction = new SpecialSaveAction(window);
-            final SpecialSaveAllAction mySaveAllAction = new SpecialSaveAllAction(window);
-
-            hookOnCommand(mySaveAction, FILE_SAVE);
-            hookOnCommand(mySaveAllAction, FILE_SAVE_ALL);
-
-            // override default save action with custom one, wich extend
-            // the default action
-            IActionBarConfigurer configurer = wwConf.getActionBarConfigurer();
-            configurer.registerGlobalAction(mySaveAction);
-            configurer.registerGlobalAction(mySaveAllAction);
-
-            IMenuManager menuBar = configurer.getMenuManager();
-
-            // get "file" menu group
-            IContributionItem item = menuBar.find(FILE_MENU);
-
-            if (item instanceof MenuManager) {
-                MenuManager menu = (MenuManager) item;
-                // replace menu actions with ours
-                insert(mySaveAction, menu);
-                insert(mySaveAllAction, menu);
-            }
-
-            ICoolBarManager coolBar = configurer.getCoolBarManager();
-            // get "file" toolbar group
-            item = coolBar.find(FILE_TOOLBAR);
-            if (item instanceof ToolBarContributionItem) {
-                ToolBarContributionItem item2 = (ToolBarContributionItem) item;
-                ToolBarManager manager = (ToolBarManager) item2.getToolBarManager();
-
-                int controlIdx = insert(mySaveAction, manager, -1);
-                int nextIndex = controlIdx;
-                boolean addSaveAll = getPref(IAnyEditConstants.ADD_SAVE_ALL_TO_TOOLBAR);
-                if (addSaveAll) {
-                    nextIndex++;
-                    insert(mySaveAllAction, manager, nextIndex);
-                }
-                boolean removePrint = getPref(IAnyEditConstants.REMOVE_PRINT_FROM_TOOLBAR);
-                if (removePrint) {
-                    nextIndex++;
-                    remove(manager, nextIndex, PRINT_BUTTON_ID);
-                }
-                // to resize toolbars after changes...
-                coolBar.update(true);
-            }
-        }
-    }
-
-    private static void remove(IContributionManager manager, int itemIndex, String id) {
-        IContributionItem[] items = manager.getItems();
-        int controlIdx = -1;
-        for (int i = 0; i < items.length; i++) {
-            if (items[i].isSeparator() || items[i] instanceof ActionContributionItem
-                    || items[i] instanceof CommandContributionItem) {
-                controlIdx++;
-                if (controlIdx == itemIndex && id.equals(items[i].getId())) {
-                    IContributionItem item = manager.remove(items[i]);
-                    // refresh menu gui
-                    manager.update(true);
-                    if (item != null) {
-                        item.dispose();
-                    }
-                    break;
-                }
-            }
-        }
-    }
-
-    private static boolean getPref(String prefkey) {
-        IPreferenceStore store = AnyEditToolsPlugin.getDefault().getPreferenceStore();
-        return store.getBoolean(prefkey);
-    }
-
-    /**
-     * @param myAction
-     * @param manager
-     */
-    private static int insert(IDirtyWorkaround myAction, ToolBarManager manager,
-            int controlIdx) {
-        IContributionItem item;
-        // get "file->save" action
-        item = manager.find(myAction.getId());
-        if (item != null) {
-            // copy references to opened editor/part
-            myAction.copyStateAndDispose(item);
-            if (controlIdx < 0) {
-                // get/remember position
-                IContributionItem[] items = manager.getItems();
-                for (int i = 0; i < items.length; i++) {
-                    if (items[i].isSeparator()
-                            || items[i] instanceof ActionContributionItem) {
-                        controlIdx++;
-                        if (items[i] == item) {
-                            break;
-                        }
-                    }
-                }
-            }
-            // clean old one
-            manager.remove(item);
-            item = new ActionContributionItem(myAction);
-            manager.insert(controlIdx, item);
-            // refresh menu gui
-            manager.update(true);
-        } else if (controlIdx >= 0) {
-            item = new ActionContributionItem(myAction);
-            manager.insert(controlIdx, item);
-            // refresh menu gui
-            manager.update(true);
-        }
-        return controlIdx;
-    }
-
-    /**
-     * @param myAction
-     * @param menu
-     */
-    private static void insert(IDirtyWorkaround myAction, MenuManager menu) {
-        IContributionItem item;
-        String id = myAction.getId();
-        // get "file->save" action
-        item = menu.find(id);
-        if (item != null) {
-            // copy references to opened editor/part
-            myAction.copyStateAndDispose(item);
-            // remember position
-            int controlIdx = menu.indexOf(id);
-            // clean old one
-            menu.remove(item);
-            item = new ActionContributionItem(myAction);
-            menu.insert(controlIdx, item);
-            // refresh menu gui
-            menu.update(true);
-        }
-    }
-}
\ No newline at end of file
-- 
