]> git.uio.no Git - ifi-stolz-refaktor.git/blob - case-study/jdt-after/ui/org/eclipse/jdt/internal/ui/text/correction/CorrectionCommandInstaller.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-after / ui / org / eclipse / jdt / internal / ui / text / correction / CorrectionCommandInstaller.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2012 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11
12 package org.eclipse.jdt.internal.ui.text.correction;
13
14 import java.util.ArrayList;
15 import java.util.Collection;
16 import java.util.List;
17
18 import org.eclipse.ui.IWorkbench;
19 import org.eclipse.ui.PlatformUI;
20 import org.eclipse.ui.commands.ICommandService;
21 import org.eclipse.ui.handlers.IHandlerActivation;
22 import org.eclipse.ui.handlers.IHandlerService;
23
24 import org.eclipse.jdt.internal.ui.JavaPlugin;
25 import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor;
26
27 public class CorrectionCommandInstaller {
28
29         public List<IHandlerActivation> fCorrectionHandlerActivations;
30
31         public CorrectionCommandInstaller() {
32                 fCorrectionHandlerActivations= null;
33         }
34
35         public void registerCommands(CompilationUnitEditor editor) {
36                 IWorkbench workbench= PlatformUI.getWorkbench();
37                 ICommandService commandService= (ICommandService) workbench.getAdapter(ICommandService.class);
38                 IHandlerService handlerService= (IHandlerService) workbench.getAdapter(IHandlerService.class);
39                 if (commandService == null || handlerService == null) {
40                         return;
41                 }
42
43                 if (fCorrectionHandlerActivations != null) {
44                         JavaPlugin.logErrorMessage("correction handler activations not released"); //$NON-NLS-1$
45                 }
46                 fCorrectionHandlerActivations= new ArrayList<IHandlerActivation>();
47
48                 Collection<String> definedCommandIds= commandService.getDefinedCommandIds();
49                 editor.generated_7415811112593806754(this, handlerService, definedCommandIds);
50         }
51
52         public void deregisterCommands() {
53                 IHandlerService handlerService= (IHandlerService) PlatformUI.getWorkbench().getAdapter(IHandlerService.class);
54                 if (handlerService != null && fCorrectionHandlerActivations != null) {
55                         handlerService.deactivateHandlers(fCorrectionHandlerActivations);
56                         fCorrectionHandlerActivations= null;
57                 }
58         }
59
60 }