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.eclipse.jdt.core.IJavaElement;
08: import org.eclipse.jface.viewers.ISelection;
09: import org.eclipse.swt.widgets.Menu;
10:
11: public class FieldHandler extends BaseMenuCreator {
12: private RootFieldAction m_rootAction;
13: private TransientFieldAction m_transientAction;
14:
15: public FieldHandler() {
16: super ();
17:
18: m_rootAction = new RootFieldAction();
19: m_transientAction = new TransientFieldAction();
20: }
21:
22: protected IJavaElement getJavaElement(ISelection selection) {
23: IField field = null;
24: String label = "Fields";
25:
26: if ((field = ActionUtil.findSelectedField(selection)) != null) {
27: label = "Field " + field.getElementName();
28: }
29: m_delegateAction.setText(label);
30:
31: return field;
32: }
33:
34: protected void fillMenu(Menu menu) {
35: if (m_element != null) {
36: m_rootAction.setField((IField) m_element);
37: addMenuAction(menu, m_rootAction);
38:
39: m_transientAction.setField((IField) m_element);
40: addMenuAction(menu, m_transientAction);
41: }
42: }
43: }
|