]> git.uio.no Git - ifi-stolz-refaktor.git/blobdiff - case-study/jdt-after/ui/org/eclipse/jdt/internal/ui/actions/SurroundWithActionGroup.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-after / ui / org / eclipse / jdt / internal / ui / actions / SurroundWithActionGroup.java
diff --git a/case-study/jdt-after/ui/org/eclipse/jdt/internal/ui/actions/SurroundWithActionGroup.java b/case-study/jdt-after/ui/org/eclipse/jdt/internal/ui/actions/SurroundWithActionGroup.java
new file mode 100644 (file)
index 0000000..cdef05b
--- /dev/null
@@ -0,0 +1,72 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * 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
+ *
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.jdt.internal.ui.actions;
+
+import org.eclipse.jface.action.IMenuManager;
+
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.actions.ActionGroup;
+
+import org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds;
+import org.eclipse.jdt.ui.actions.JdtActionConstants;
+import org.eclipse.jdt.ui.actions.SurroundWithTryCatchAction;
+import org.eclipse.jdt.ui.actions.SurroundWithTryMultiCatchAction;
+
+import org.eclipse.jdt.internal.ui.JavaPluginImages;
+import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor;
+
+public class SurroundWithActionGroup extends ActionGroup {
+
+       public CompilationUnitEditor fEditor;
+       public SurroundWithTryCatchAction fSurroundWithTryCatchAction;
+       public SurroundWithTryMultiCatchAction fSurroundWithTryMultiCatchAction;
+       public final String fGroup;
+
+       public SurroundWithActionGroup(CompilationUnitEditor editor, String group) {
+               fEditor= editor;
+               fGroup= group;
+               fSurroundWithTryCatchAction= createSurroundWithTryCatchAction(fEditor);
+               fSurroundWithTryMultiCatchAction= createSurroundWithTryMultiCatchAction(fEditor);
+       }
+
+       @Override
+       public void fillActionBars(IActionBars actionBar) {
+               actionBar.setGlobalActionHandler(JdtActionConstants.SURROUND_WITH_TRY_CATCH, fSurroundWithTryCatchAction);
+               actionBar.setGlobalActionHandler(JdtActionConstants.SURROUND_WITH_TRY_MULTI_CATCH, fSurroundWithTryMultiCatchAction);
+       }
+
+       /**
+        * The Menu to show when right click on the editor
+        * {@inheritDoc}
+        */
+       @Override
+       public void fillContextMenu(IMenuManager menu) {
+               fEditor.generated_8436872467051809828(this, menu);
+       }
+
+       static SurroundWithTryCatchAction createSurroundWithTryCatchAction(CompilationUnitEditor editor) {
+               SurroundWithTryCatchAction result= new SurroundWithTryCatchAction(editor);
+               result.setText(ActionMessages.SurroundWithTemplateMenuAction_SurroundWithTryCatchActionName);
+               result.setImageDescriptor(JavaPluginImages.getDescriptor(JavaPluginImages.IMG_CORRECTION_CHANGE));
+               result.setActionDefinitionId(IJavaEditorActionDefinitionIds.SURROUND_WITH_TRY_CATCH);
+               editor.setAction("SurroundWithTryCatch", result); //$NON-NLS-1$
+               return result;
+       }
+
+       static SurroundWithTryMultiCatchAction createSurroundWithTryMultiCatchAction(CompilationUnitEditor editor) {
+               SurroundWithTryMultiCatchAction result= new SurroundWithTryMultiCatchAction(editor);
+               result.setText(ActionMessages.SurroundWithTemplateMenuAction_SurroundWithTryMultiCatchActionName);
+               result.setImageDescriptor(JavaPluginImages.getDescriptor(JavaPluginImages.IMG_CORRECTION_CHANGE));
+               result.setActionDefinitionId(IJavaEditorActionDefinitionIds.SURROUND_WITH_TRY_MULTI_CATCH);
+               editor.setAction("SurroundWithTryMultiCatch", result); //$NON-NLS-1$
+               return result;
+       }
+}