01: /*
02: * All content copyright (c) 2003-2006 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package org.terracotta.dso.actions;
05:
06: import org.eclipse.jdt.core.IField;
07: import org.terracotta.dso.ConfigurationHelper;
08:
09: /**
10: * Marks the currently selected field as being a shared root.
11: * Creates a default root name based on the simple name of the
12: * field.
13: *
14: * @see org.eclipse.jdt.core.IField
15: * @see BaseAction
16: * @see org.terracotta.dso.ConfigurationHelper.isRoot
17: * @see org.terracotta.dso.ConfigurationHelper.ensureRoot
18: * @see org.terracotta.dso.ConfigurationHelper.ensureNotRoot
19: */
20:
21: public class RootFieldAction extends BaseAction {
22: private IField m_field;
23:
24: public RootFieldAction() {
25: super ("Shared root", AS_CHECK_BOX);
26: }
27:
28: public void setField(IField field) {
29: setJavaElement(m_field = field);
30: setChecked(getConfigHelper().isRoot(m_field));
31: }
32:
33: public void performAction() {
34: ConfigurationHelper helper = getConfigHelper();
35:
36: if (isChecked()) {
37: helper.ensureRoot(m_field);
38: } else {
39: helper.ensureNotRoot(m_field);
40: }
41:
42: inspectCompilationUnit();
43: }
44: }
|