KickJava   Java API By Example, From Geeks To Geeks.

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


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.IField;
7 import org.eclipse.jdt.core.IJavaElement;
8 import org.eclipse.jface.viewers.ISelection;
9 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 JavaDoc 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 }
44
Popular Tags