]> git.uio.no Git - ifi-stolz-refaktor.git/blob - case-study/jdt-before/ui/org/eclipse/jdt/internal/ui/callhierarchy/SelectFieldModeAction.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-before / ui / org / eclipse / jdt / internal / ui / callhierarchy / SelectFieldModeAction.java
1 /*******************************************************************************
2  * Copyright (c) 2008, 2011 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  *   Stephan Herrmann (stephan@cs.tu-berlin.de):
10  *          - bug 206949: [call hierarchy] filter field accesses (only write or only read)
11  *******************************************************************************/
12 package org.eclipse.jdt.internal.ui.callhierarchy;
13
14 import org.eclipse.core.runtime.Assert;
15
16 import org.eclipse.jface.action.Action;
17
18 import org.eclipse.jdt.core.search.IJavaSearchConstants;
19
20 /**
21  * Toggles how fields should be expanded: all references, read accesses, write accesses.
22  */
23 public class SelectFieldModeAction extends Action {
24
25     private CallHierarchyViewPart fView;
26     private int fMode;
27
28     public SelectFieldModeAction(CallHierarchyViewPart v, int mode) {
29         super(null, AS_RADIO_BUTTON);
30         if (mode == IJavaSearchConstants.REFERENCES) {
31             setText(CallHierarchyMessages.SelectFieldModeAction_all_references_label);
32             setDescription(CallHierarchyMessages.SelectFieldModeAction_all_references_description);
33         } else if (mode == IJavaSearchConstants.READ_ACCESSES) {
34             setText(CallHierarchyMessages.SelectFieldModeAction_read_accesses_label);
35             setDescription(CallHierarchyMessages.SelectFieldModeAction_read_accesses_description);
36         } else if (mode == IJavaSearchConstants.WRITE_ACCESSES) {
37             setText(CallHierarchyMessages.SelectFieldModeAction_write_accesses_label);
38             setDescription(CallHierarchyMessages.SelectFieldModeAction_write_accesses_description);
39         } else {
40             Assert.isTrue(false);
41         }
42         fView= v;
43         fMode= mode;
44         // FIXME(stephan) adjust/create new help context
45 //        PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_TOGGLE_CALL_MODE_ACTION);
46     }
47
48     public int getMode() {
49         return fMode;
50     }
51
52     /*
53      * @see Action#actionPerformed
54      */
55     @Override
56         public void run() {
57         fView.setFieldMode(fMode); // will toggle the checked state
58     }
59 }