package com.redhat.ceylon.eclipse.imp.editor;

import org.eclipse.imp.editor.UniversalEditor;
import org.eclipse.imp.services.ILanguageActionsContributor;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;

import com.redhat.ceylon.eclipse.imp.open.OpenDeclarationAction;
import com.redhat.ceylon.eclipse.imp.refactoring.ConvertToNamedArgumentsRefactoringAction;
import com.redhat.ceylon.eclipse.imp.refactoring.ExtractFunctionRefactoringAction;
import com.redhat.ceylon.eclipse.imp.refactoring.ExtractValueRefactoringAction;
import com.redhat.ceylon.eclipse.imp.refactoring.InlineRefactoringAction;
import com.redhat.ceylon.eclipse.imp.refactoring.RenameRefactoringAction;
import com.redhat.ceylon.eclipse.imp.search.FindReferencesAction;
import com.redhat.ceylon.eclipse.imp.search.FindRefinementsAction;
import com.redhat.ceylon.eclipse.imp.search.FindSubtypesAction;

public class CeylonEditorActionContributions implements
		ILanguageActionsContributor {

	public void contributeToEditorMenu(final UniversalEditor editor,
			IMenuManager menuManager) {
		//IMenuManager languageMenu = new MenuManager("Search");
        menuManager.add(new OpenDeclarationAction(editor));
        menuManager.add(new Separator());
		menuManager.add(new FindReferencesAction(editor));
		menuManager.add(new FindRefinementsAction(editor));
        menuManager.add(new FindSubtypesAction(editor));
        menuManager.add(new Separator());
        menuManager.add(new RenameRefactoringAction(editor));
        menuManager.add(new InlineRefactoringAction(editor));
        menuManager.add(new ExtractValueRefactoringAction(editor));
        menuManager.add(new ExtractFunctionRefactoringAction(editor));
        //menuManager.add(new Separator());
        menuManager.add(new ConvertToNamedArgumentsRefactoringAction(editor));
	}

	public void contributeToMenuBar(final UniversalEditor editor, IMenuManager menu) {
		//languageMenu = new MenuManager("ceylon");
		/*IMenuManager refactor = menu.findMenuUsingPath("refactorMenuId");
		if (refactor.getItems().length==0) {
			for (IAction action: RefactoringContributor.getActions(editor)) {
				refactor.add(action);
			}
		}
		IMenuManager search = menu.findMenuUsingPath("navigate");
		search.add(new Separator());
		search.add(new FindReferencesAction(editor));
        search.add(new FindRefinementsAction(editor));
        search.add(new FindSubtypesAction(editor));
        search.add(new Separator());
        search.add(new OpenDeclarationAction("Open Declaration...", editor));*/
	}

	public void contributeToStatusLine(final UniversalEditor editor,
			IStatusLineManager statusLineManager) {
		// TODO add ControlContribution objects to the statusLineManager
	}

	public void contributeToToolBar(UniversalEditor editor,
			IToolBarManager toolbarManager) {
		// add ControlContribution objects to the toolbarManager
	}
}

@@ -2153,102 +2153,246 @@
 ;%0A%09%09
-if (refactor.getItems().length==0) %7B%0A%09%09%09for (IAction action: RefactoringContributor.get
+refactor.removeAll();%0A%09%09refactor.add(new RenameRefactoringAction(editor));%0A%09%09refactor.add(new InlineRefactoringAction(editor));%0A%09%09refactor.add(new ExtractValueRefactoringAction(editor));%0A%09%09refactor.add(new ExtractFunctionRefactoring
 Action
-s
 (edi
@@ -2400,45 +2400,118 @@
 or))
- %7B%0A%09%09%09%09refactor.add(action);%0A%09%09%09%7D%0A%09%09%7D
+;%0A        refactor.add(new Separator());%0A%09%09refactor.add(new ConvertToNamedArgumentsRefactoringAction(editor));
 %0A%09%09I
@@ -2565,24 +2565,54 @@
 vigate%22);%0A%09%09
+search.removeAll();%0A        //
 search.add(n
@@ -2628,18 +2628,26 @@
 tor());%0A
-%09%09
+        //
 search.a
@@ -2649,38 +2649,39 @@
 rch.add(new 
-FindReferences
+OpenDeclaration
 Action(edito
@@ -2681,32 +2681,26 @@
 n(editor));%0A
-        
+%09%09
 search.add(n
@@ -2706,48 +2706,24 @@
 new 
-FindRefinementsAction(editor));%0A        
+Separator());%0A%09%09
 sear
@@ -2729,38 +2729,40 @@
 rch.add(new Find
-Subtyp
+Referenc
 esAction(editor)
@@ -2783,34 +2783,52 @@
 rch.add(new 
-Separa
+FindRefinementsAction(edi
 tor
-(
 ));%0A        
@@ -2846,53 +2846,27 @@
 new 
-OpenDeclarationAction(%22Open Declaration...%22, 
+FindSubtypesAction(
 edit

update disabled code ;)