package orm.editor;

import org.eclipse.gef.internal.GEFMessages;
import org.eclipse.gef.ui.actions.ActionBarContributor;
import org.eclipse.gef.ui.actions.DeleteRetargetAction;
import org.eclipse.gef.ui.actions.GEFActionConstants;
import org.eclipse.gef.ui.actions.RedoRetargetAction;
import org.eclipse.gef.ui.actions.UndoRetargetAction;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.actions.RetargetAction;
import org.eclipse.ui.part.MultiPageEditorPart;

/**
 * @author KAy Bierzynski
 * */
public class ORMGraphicalEditorActionBarContributor extends
		ActionBarContributor {

	 @Override
	  protected void buildActions() {
	    addRetargetAction(new UndoRetargetAction());
	    addRetargetAction(new RedoRetargetAction());
	    addRetargetAction(new DeleteRetargetAction());
	    addRetargetAction(new RetargetAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY, GEFMessages.ToggleGrid_Label, IAction.AS_CHECK_BOX));  
	    addRetargetAction(new RetargetAction(GEFActionConstants.TOGGLE_SNAP_TO_GEOMETRY, GEFMessages.ToggleSnapToGeometry_Label, IAction.AS_CHECK_BOX));
	    
	 }
	 
	 // is called from the ORMMultiPageEditor pageChange when user switch between editors
	 @Override
	public void setActiveEditor(IEditorPart editor) {
		super.setActiveEditor(editor);
	 // creats actionbar for active editor with actionregistry/graphicalViewer/CommandStack from the active editor
		getActionBars().updateActionBars();
	}
	  @Override
	  public void contributeToToolBar(IToolBarManager toolBarManager) {
	    super.contributeToToolBar(toolBarManager);
	    toolBarManager.add(getAction(ActionFactory.UNDO.getId()));
	    toolBarManager.add(getAction(ActionFactory.REDO.getId()));
	    toolBarManager.add(getAction(ActionFactory.DELETE.getId()));
	    toolBarManager.add(getAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY));
	    toolBarManager.add(getAction(GEFActionConstants.TOGGLE_SNAP_TO_GEOMETRY));
	  }

	@Override
	protected void declareGlobalActionKeys() {
		// TODO Auto-generated method stub

	}
	
	
}

@@ -18,53 +18,8 @@
 r;%0A%0A
-import org.eclipse.gef.internal.GEFMessages;%0A
 impo
@@ -507,56 +507,8 @@
 ion;
-%0Aimport org.eclipse.ui.part.MultiPageEditorPart;
 %0A%0A/*
@@ -535,16 +535,41 @@
 rzynski%0A
+ * @author Lars Schuetze%0A
  * */%0Apu
@@ -625,19 +625,17 @@
  extends
-%0A%09%09
+ 
 ActionBa
@@ -650,17 +650,148 @@
 utor %7B%0A%0A
-%09
+  private static String TOGGLE_GRID_LABEL = %22&Grid%22;%0A  private static String TOGGLE_SNAP_TO_GERMETRY_LABEL = %22Snap to Geo&metry%22;%0A%0A 
  @Overri
@@ -793,17 +793,16 @@
 verride%0A
-%09
   protec
@@ -823,25 +823,24 @@
 Actions() %7B%0A
-%09
     addRetar
@@ -868,33 +868,32 @@
 argetAction());%0A
-%09
     addRetargetA
@@ -917,33 +917,32 @@
 argetAction());%0A
-%09
     addRetargetA
@@ -972,25 +972,24 @@
 tAction());%0A
-%09
     addRetar
@@ -1063,37 +1063,34 @@
 ITY,
- GEFMessages.ToggleGrid_Label
+%0A        TOGGLE_GRID_LABEL
 , IA
@@ -1110,20 +1110,17 @@
 K_BOX));
-  %0A%09
+%0A
     addR
@@ -1199,47 +1199,46 @@
 TRY,
- GEFMessages.ToggleSnapToGeometry_Label
+%0A        TOGGLE_SNAP_TO_GERMETRY_LABEL
 , IA
@@ -1263,22 +1263,15 @@
 ));%0A
-%09    %0A%09 %7D%0A%09 %0A%09
+%0A  %7D%0A%0A 
  // 
@@ -1352,17 +1352,17 @@
 editors%0A
-%09
+ 
  @Overri
@@ -1364,17 +1364,18 @@
 verride%0A
-%09
+  
 public v
@@ -1416,18 +1416,20 @@
 itor) %7B%0A
-%09%09
+    
 super.se
@@ -1451,17 +1451,19 @@
 ditor);%0A
-%09
+   
  // crea
@@ -1550,16 +1550,23 @@
 from the
+%0A    //
  active 
@@ -1572,18 +1572,20 @@
  editor%0A
-%09%09
+    
 getActio
@@ -1612,20 +1612,21 @@
 Bars();%0A
-%09%7D%0A%09
+  %7D%0A%0A
   @Overr
@@ -1629,17 +1629,16 @@
 verride%0A
-%09
   public
@@ -1697,17 +1697,16 @@
 ager) %7B%0A
-%09
     supe
@@ -1744,17 +1744,16 @@
 nager);%0A
-%09
     tool
@@ -1799,33 +1799,32 @@
 UNDO.getId()));%0A
-%09
     toolBarManag
@@ -1862,33 +1862,32 @@
 REDO.getId()));%0A
-%09
     toolBarManag
@@ -1931,25 +1931,24 @@
 .getId()));%0A
-%09
     toolBarM
@@ -2013,17 +2013,16 @@
 LITY));%0A
-%09
     tool
@@ -2096,15 +2096,15 @@
 ));%0A
-%09
   %7D%0A%0A
-%09
+  
 @Ove
@@ -2109,17 +2109,18 @@
 verride%0A
-%09
+  
 protecte
@@ -2158,10 +2158,12 @@
 ) %7B%0A
-%09%09
+    
 // T
@@ -2197,14 +2197,12 @@
 tub%0A
-%0A%09%7D%0A%09%0A%09
+  %7D%0A%0A
 %0A%7D%0A

declare own strings to remove discouraged access to internal classes of GEF