KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > terracotta > dso > actions > ExcludedTypeAction


1 /*
2  * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
3  */

4 package org.terracotta.dso.actions;
5
6 import org.eclipse.jdt.core.IJavaElement;
7 import org.eclipse.jdt.core.IType;
8 import org.terracotta.dso.ConfigurationHelper;
9 import org.terracotta.dso.TcPlugin;
10
11 /**
12  * Marks the currently selected IType as being excluded from instrumentation.
13  *
14  * @see org.eclipse.jdt.core.IType
15  * @see org.terracotta.dso.ConfigurationHelper.isExcluded
16  * @see org.terracotta.dso.ConfigurationHelper.ensureExcluded
17  * @see org.terracotta.dso.ConfigurationHelper.ensureNotExcluded
18  */

19
20 public class ExcludedTypeAction extends BaseAction {
21   public ExcludedTypeAction() {
22     super("Excluded", AS_CHECK_BOX);
23   }
24   
25   public void setJavaElement(IJavaElement element) {
26     super.setJavaElement(element);
27     
28     if(element instanceof IType) {
29       IType type = (IType)element;
30       boolean isBootClass = TcPlugin.getDefault().isBootClass(type);
31       
32       setEnabled(!isBootClass);
33       setChecked(!isBootClass && getConfigHelper().isExcluded(type));
34     }
35     else {
36       setChecked(getConfigHelper().isExcluded(element));
37     }
38   }
39   
40   public void performAction() {
41     ConfigurationHelper helper = getConfigHelper();
42     
43     if(isChecked()) {
44       helper.ensureExcluded(m_element);
45     }
46     else {
47       helper.ensureNotExcluded(m_element);
48     }
49
50     inspectCompilationUnit();
51   }
52 }
53
Popular Tags