KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > ajde > ui > swing > BrowserViewPanel


1
2 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3  *
4  * This file is part of the IDE support for the AspectJ(tm)
5  * programming language; see http://aspectj.org
6  *
7  * The contents of this file are subject to the Mozilla Public License
8  * Version 1.1 (the "License"); you may not use this file except in
9  * compliance with the License. You may obtain a copy of the License at
10  * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * The Original Code is AspectJ.
18  *
19  * The Initial Developer of the Original Code is Xerox Corporation. Portions
20  * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
21  * All Rights Reserved.
22  *
23  * Contributor(s):
24  */

25
26 package org.aspectj.ajde.ui.swing;
27
28 import java.awt.*;
29 import java.awt.event.*;
30 import javax.swing.*;
31 import javax.swing.event.*;
32 import java.util.*;
33 import org.aspectj.ajde.*;
34 import org.aspectj.asm.*;
35 import org.aspectj.asm.views.*;
36 import org.aspectj.ajde.ui.*;
37 import org.aspectj.ajde.ui.swing.*;
38
39 /**
40  * Represents the configuration of a structure view of the system, rendered
41  * by the <CODE>StructureTreeManager</CODE>.
42  *
43  * @author Mik Kersten
44  */

45 public class BrowserViewPanel extends JPanel implements StructureViewRenderer {
46
47     private StructureTreeManager treeManager;
48     //private StructureView structureView = null;
49
private int depthSliderVal = 0;
50     private JComboBox view_comboBox = null;
51
52     private BorderLayout borderLayout1 = new BorderLayout();
53     private JToolBar view_toolBar = new JToolBar();
54     private JSlider depth_slider = new JSlider();
55     JScrollPane tree_ScrollPane = new JScrollPane();
56     JPanel tree_panel = new JPanel();
57     BorderLayout borderLayout2 = new BorderLayout();
58
59 // private final StructureViewRenderer VIEW_LISTENER = new StructureViewRenderer() {
60
// public void viewUpdated() {
61
// updateTree();
62
// }
63
// };
64

65     public BrowserViewPanel(IconRegistry icons, java.util.List JavaDoc views, StructureViewProperties.Hierarchy visibleViewHierarchy) {
66         try {
67             view_comboBox = new JComboBox(views.toArray());
68             for (Iterator it = views.iterator(); it.hasNext(); ) {
69                 StructureViewProperties.Hierarchy hierarchy = (StructureViewProperties.Hierarchy)it.next();
70                 if (hierarchy == visibleViewHierarchy) {
71                     view_comboBox.setSelectedItem(hierarchy);
72                 }
73             }
74             //GlobalViewProperties visibleView = (GlobalViewProperties)viewProperties.get(visibleViewHierarchy.toString());
75
treeManager = new StructureTreeManager();//, visibleView);
76
jbInit();
77             initDepthSlider();
78             tree_ScrollPane.getViewport().add(treeManager.getStructureTree(), null);
79
80             //Ajde.getDefault().getViewManager().getFileStructureView().addListener(VIEW_LISTENER);
81
}
82         catch(Exception JavaDoc e) {
83             Ajde.getDefault().getErrorHandler().handleError("Could not initialize GUI.", e);
84         }
85     }
86
87     public void setActiveNode(StructureViewNode node) {
88         throw new RuntimeException JavaDoc("not implemented");
89     }
90
91     public void setActiveNode(StructureViewNode activeNode, int lineOffset) {
92         throw new RuntimeException JavaDoc("not implemented");
93     }
94
95 // public void highlightNode(ProgramElementNode node) {
96
// treeManager.navigationAction(node, true, true);
97
// }
98

99 // void updateTree() {
100
// StructureViewProperties.Hierarchy hierarchy = ((StructureViewProperties.Hierarchy)view_comboBox.getSelectedItem());
101
// GlobalStructureView structureView = Ajde.getDefault().getStructureViewManager().getGlobalStructureView(hierarchy);
102
// treeManager.updateTree(structureView, depthSliderVal);
103
// }
104

105     public void updateView(StructureView structureView) {
106         if (structureView instanceof GlobalStructureView) {
107             treeManager.updateTree((GlobalStructureView)structureView);
108         }
109     }
110
111     void updateTree(String JavaDoc filePath) {
112         //treeManager.updateTree(Ajde.getDefault().getViewManager().getFileStructureView(filePath));
113
}
114
115     private void initDepthSlider() {
116         depth_slider.setMinimum(0);
117         depth_slider.setMaximum(9);
118         depth_slider.setMinorTickSpacing(1);
119         depth_slider.setValue(9);
120         depth_slider.setSnapToTicks(true);
121         depth_slider.setPaintTrack(true);
122         depth_slider.setPaintTicks(true);
123         this.depth_slider.addChangeListener(
124             new ChangeListener() {
125                 public void stateChanged(ChangeEvent e) {
126                     depthSliderVal = depth_slider.getValue();
127                     //AjdeUIManager.getDefault().getViewManager().updateView();
128
}
129             });
130         depthSliderVal = depth_slider.getValue();
131     }
132
133     private void view_comboBox_actionPerformed(ActionEvent e) {
134         //updateTree(DECLARATION_VIEW);
135
throw new RuntimeException JavaDoc("not implemented");
136     }
137
138     private void jbInit() throws Exception JavaDoc {
139         tree_panel.setLayout(borderLayout2);
140         this.setLayout(borderLayout1);
141         view_comboBox.setPreferredSize(new Dimension(200, 20));
142         view_comboBox.addActionListener(new java.awt.event.ActionListener JavaDoc() {
143             public void actionPerformed(ActionEvent e) {
144                 view_comboBox_actionPerformed(e);
145             }
146         });
147         view_comboBox.setMinimumSize(new Dimension(40, 20));
148         view_comboBox.setFont(new java.awt.Font JavaDoc("SansSerif", 0, 11));
149         depth_slider.setMaximumSize(new Dimension(32767, 25));
150         depth_slider.setToolTipText("");
151         depth_slider.setMinimumSize(new Dimension(30, 20));
152         depth_slider.setBorder(null);
153         depth_slider.setPreferredSize(new Dimension(30, 25));
154         depth_slider.setMaximum(3);
155         depth_slider.setPaintTicks(true);
156         depth_slider.setValue(1);
157         depth_slider.setPaintLabels(true);
158         view_toolBar.setFloatable(false);
159         this.add(view_toolBar, BorderLayout.NORTH);
160         view_toolBar.add(view_comboBox, null);
161         view_toolBar.add(depth_slider, null);
162         this.add(tree_panel, BorderLayout.CENTER);
163         tree_panel.add(tree_ScrollPane, BorderLayout.CENTER);
164     }
165 }
Popular Tags