KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > terracotta > dso > editors > chooser > JavaProjectNavigator


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.editors.chooser;
5
6 import org.eclipse.jdt.core.IJavaProject;
7
8 import org.terracotta.dso.editors.tree.JavaProjectModel;
9 import org.terracotta.dso.editors.tree.JavaProjectNode;
10 import org.terracotta.dso.editors.tree.ProjectNode;
11
12 import java.util.ArrayList JavaDoc;
13 import java.util.Arrays JavaDoc;
14
15 public abstract class JavaProjectNavigator extends BaseProjectNavigator {
16   protected String JavaDoc[] m_signatures;
17   
18   public JavaProjectNavigator(java.awt.Frame JavaDoc frame) {
19     super(frame);
20   }
21   
22   protected abstract JavaProjectModel createModel(IJavaProject javaProject);
23   
24   public void init(IJavaProject javaProject) {
25     m_packageTree.setModel(createModel(javaProject));
26     m_signatures = null;
27   }
28
29   public String JavaDoc[] getSelectedSignatures() {
30     ProjectNode[] nodes = getSelection();
31     
32     m_signatures = new String JavaDoc[nodes.length];
33     
34     for(int i = 0; i < nodes.length; i++) {
35       m_signatures[i] = ((JavaProjectNode)nodes[i]).getSignature();
36     }
37     
38     return m_signatures;
39   }
40
41   public String JavaDoc[] getSelectedFields() {
42     ProjectNode[] nodes = getSelection();
43     ArrayList JavaDoc<String JavaDoc> list = new ArrayList JavaDoc<String JavaDoc>();
44
45     for(int i = 0; i < nodes.length; i++) {
46       list.addAll(Arrays.asList(((JavaProjectNode)nodes[i]).getFields()));
47     }
48     
49     return list.toArray(new String JavaDoc[0]);
50   }
51 }
52
Popular Tags