KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > cve > staticLayout > ViewEnvironment


1 package cve.staticLayout;
2
3 import javax.swing.JInternalFrame JavaDoc;
4 import javax.swing.tree.*;
5 import javax.swing.*;
6
7 import java.awt.event.*;
8 import java.awt.*;
9 import java.util.*;
10
11 import cve.core.elementLDL.*;
12 import cve.core.elementEEL.*;
13 import cve.util.ConfigurationRead;
14
15 import org.apache.log4j.Logger;
16
17 /**
18 * It manage the view of current environment
19 *
20 * @version 1.1.0
21 * @author Domenico Ventriglia
22 *
23 */

24 public class ViewEnvironment extends JInternalFrame JavaDoc {
25    static int openFrameCount = 0;
26    static final int xOffset = 0, yOffset = 50;
27    private IEnvironmentEEL envEEL;
28
29    /**
30    * @param envEEL ambiente cve
31    *
32    */

33    public ViewEnvironment(IEnvironmentEEL envEEL) {
34       super(" View cve environment",
35       true, //resizable
36
true, //closable
37
false, //maximizable
38
true);//iconifiable
39
Cve.errLog.debug("");
40       setFrameIcon(new ImageIcon(ConfigurationRead.getCveRoot()+"/resource/cve/bkmrk_nav.gif"));
41       this.envEEL=envEEL;
42       //Set the window's location.
43
setLocation(xOffset, yOffset);
44       if (envEEL==null) {
45          System.out.println(" Attenzione l'ambiente e' stato trovato nullo");
46       }
47       viewTreeEnv();
48    }
49
50    /**
51    * It shows environment cve as a tree
52    */

53    void viewTreeEnv() {
54       Cve.errLog.debug("");
55       DefaultMutableTreeNode root=new DefaultMutableTreeNode (envEEL.getDescription());
56       JTree jt=new JTree(root);
57       DefaultTreeCellRenderer envR=new DefaultTreeCellRenderer ();
58       envR.setOpenIcon(new ImageIcon(ConfigurationRead.getCveRoot()+"/resource/cve/metaphor/elements_obj.gif"));
59       envR.setClosedIcon(new ImageIcon(ConfigurationRead.getCveRoot()+"/resource/cve/metaphor/elements_obj.gif"));
60       envR.setLeafIcon(new ImageIcon(ConfigurationRead.getCveRoot()+"/resource/cve/metaphor/default_persp.gif"));
61       jt.setCellRenderer(envR);
62       Collection units=envEEL.getAllUnit();
63       Iterator itEle=units.iterator();
64       while (itEle.hasNext()){
65          IUnit eleUnit=(IUnit)itEle.next();
66          //DefaultMutableTreeNode unit= new DefaultMutableTreeNode(ele.getDescription());
67
DefaultTreeCellRenderer unitR=new DefaultTreeCellRenderer ();
68          //unitR.setOpenIcon(new ImageIcon("c:/cve1.0/resource/cve/metaphor/opensame_persp.gif"));
69
DefaultMutableTreeNode unit= new DefaultMutableTreeNode(eleUnit.getDescription());
70          //unit.setCellRenderer(unitR);
71
Collection presenters=eleUnit.getPresenters();
72          Iterator itPre=presenters.iterator();
73          while (itPre.hasNext()){
74             Presenter pre=(Presenter)itPre.next();
75             DefaultTreeCellRenderer preR=new DefaultTreeCellRenderer ();
76             //preR.setOpenIcon(new ImageIcon("c:/cve1.0/resource/cve/metaphor/default_persp.gif"));
77
DefaultMutableTreeNode presenter= new DefaultMutableTreeNode(pre.getDescription());
78             //presenter.setCellRenderer(preR);
79
//System.out.println(" id presenter "+descrPre.getDescription());
80
unit.add(presenter);
81          }
82          root.add(unit);
83       }
84       this.getContentPane().add(jt,BorderLayout.CENTER);
85       pack();
86       setSize(200,200);
87       setVisible(true);
88    }
89
90    /*public void setTree(Environment env) {
91    DefaultMutableTreeNode root=new DefaultMutableTreeNode (env.getDescription());
92    setTitle("Handle environment id="+env.getId());
93    JTree jt=new JTree(root);
94    IInsiemeElementiCve eleCve=env.getAllElement();
95    Collection elements=eleCve.getAll();
96    Iterator itEle=elements.iterator();
97    while (itEle.hasNext()){
98    IElementoCve ele=(IElementoCve)itEle.next();
99    System.out.println(" tipo trovato in env "+ele.getTipo());
100    if (ele.getTipo().equals("unit")){
101    DefaultMutableTreeNode unit= new DefaultMutableTreeNode(ele.getDescription());
102    Collection presenters=ele.getParameters();
103    Iterator itPre=presenters.iterator();
104    while (itPre.hasNext()){
105    IElementoCveVis descrPre=(IElementoCveVis)itPre.next();
106    DefaultMutableTreeNode presenter= new DefaultMutableTreeNode(descrPre.getDescription());
107    System.out.println(" id presenter "+descrPre.getDescription());
108    unit.add(presenter);
109    }
110    root.add(unit);
111    }
112    }
113    this.getContentPane().add(jt,BorderLayout.CENTER);
114    pack();
115    setSize(300,200);
116    setVisible(true);
117    }*/

118 }
119
Popular Tags