You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BrowserViewPanel.java 6.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. /* *******************************************************************
  2. * Copyright (c) 1999-2001 Xerox Corporation,
  3. * 2002 Palo Alto Research Center, Incorporated (PARC).
  4. * All rights reserved.
  5. * This program and the accompanying materials are made available
  6. * under the terms of the Eclipse Public License v1.0
  7. * which accompanies this distribution and is available at
  8. * http://www.eclipse.org/legal/epl-v10.html
  9. *
  10. * Contributors:
  11. * Xerox/PARC initial implementation
  12. * Helen Hawkins Converted to new interface (bug 148190)
  13. * ******************************************************************/
  14. package org.aspectj.ajde.ui.swing;
  15. import java.awt.BorderLayout;
  16. import java.awt.Dimension;
  17. import java.awt.event.ActionEvent;
  18. import java.util.Iterator;
  19. import javax.swing.JComboBox;
  20. import javax.swing.JPanel;
  21. import javax.swing.JScrollPane;
  22. import javax.swing.JSlider;
  23. import javax.swing.JToolBar;
  24. import org.aspectj.ajde.Ajde;
  25. import org.aspectj.ajde.IconRegistry;
  26. import org.aspectj.ajde.ui.GlobalStructureView;
  27. import org.aspectj.ajde.ui.IStructureViewNode;
  28. import org.aspectj.ajde.ui.StructureView;
  29. import org.aspectj.ajde.ui.StructureViewProperties;
  30. import org.aspectj.ajde.ui.StructureViewRenderer;
  31. import org.aspectj.bridge.IMessage;
  32. import org.aspectj.bridge.Message;
  33. /**
  34. * Represents the configuration of a structure view of the system, rendered
  35. * by the <CODE>StructureTreeManager</CODE>.
  36. *
  37. * @author Mik Kersten
  38. */
  39. public class BrowserViewPanel extends JPanel implements StructureViewRenderer {
  40. private static final long serialVersionUID = 2201330630036486567L;
  41. private StructureTreeManager treeManager;
  42. //private StructureView structureView = null;
  43. //private int depthSliderVal = 0;
  44. private JComboBox view_comboBox = null;
  45. private BorderLayout borderLayout1 = new BorderLayout();
  46. private JToolBar view_toolBar = new JToolBar();
  47. private JSlider depth_slider = new JSlider();
  48. JScrollPane tree_ScrollPane = new JScrollPane();
  49. JPanel tree_panel = new JPanel();
  50. BorderLayout borderLayout2 = new BorderLayout();
  51. // private final StructureViewRenderer VIEW_LISTENER = new StructureViewRenderer() {
  52. // public void viewUpdated() {
  53. // updateTree();
  54. // }
  55. // };
  56. public BrowserViewPanel(IconRegistry icons, java.util.List views, StructureViewProperties.Hierarchy visibleViewHierarchy) {
  57. try {
  58. view_comboBox = new JComboBox(views.toArray());
  59. for (Object view : views) {
  60. StructureViewProperties.Hierarchy hierarchy = (StructureViewProperties.Hierarchy) view;
  61. if (hierarchy == visibleViewHierarchy) {
  62. view_comboBox.setSelectedItem(hierarchy);
  63. }
  64. }
  65. //GlobalViewProperties visibleView = (GlobalViewProperties)viewProperties.get(visibleViewHierarchy.toString());
  66. treeManager = new StructureTreeManager();//, visibleView);
  67. jbInit();
  68. initDepthSlider();
  69. tree_ScrollPane.getViewport().add(treeManager.getStructureTree(), null);
  70. //Ajde.getDefault().getViewManager().getFileStructureView().addListener(VIEW_LISTENER);
  71. }
  72. catch(Exception e) {
  73. Message msg = new Message("Could not initialize GUI.",IMessage.ERROR,e,null);
  74. Ajde.getDefault().getMessageHandler().handleMessage(msg);
  75. }
  76. }
  77. public void setActiveNode(IStructureViewNode node) {
  78. throw new RuntimeException("not implemented");
  79. }
  80. public void setActiveNode(IStructureViewNode activeNode, int lineOffset) {
  81. throw new RuntimeException("not implemented");
  82. }
  83. // public void highlightNode(ProgramElementNode node) {
  84. // treeManager.navigationAction(node, true, true);
  85. // }
  86. // void updateTree() {
  87. // StructureViewProperties.Hierarchy hierarchy = ((StructureViewProperties.Hierarchy)view_comboBox.getSelectedItem());
  88. // GlobalStructureView structureView = Ajde.getDefault().getStructureViewManager().getGlobalStructureView(hierarchy);
  89. // treeManager.updateTree(structureView, depthSliderVal);
  90. // }
  91. public void updateView(StructureView structureView) {
  92. if (structureView instanceof GlobalStructureView) {
  93. treeManager.updateTree(structureView);
  94. }
  95. }
  96. void updateTree(String filePath) {
  97. //treeManager.updateTree(Ajde.getDefault().getViewManager().getFileStructureView(filePath));
  98. }
  99. private void initDepthSlider() {
  100. depth_slider.setMinimum(0);
  101. depth_slider.setMaximum(9);
  102. depth_slider.setMinorTickSpacing(1);
  103. depth_slider.setValue(9);
  104. depth_slider.setSnapToTicks(true);
  105. depth_slider.setPaintTrack(true);
  106. depth_slider.setPaintTicks(true);
  107. // this.depth_slider.addChangeListener(
  108. // new ChangeListener() {
  109. // public void stateChanged(ChangeEvent e) {
  110. // depthSliderVal = depth_slider.getValue();
  111. // //AjdeUIManager.getDefault().getViewManager().updateView();
  112. // }
  113. // });
  114. // depthSliderVal = depth_slider.getValue();
  115. }
  116. private void view_comboBox_actionPerformed(ActionEvent e) {
  117. //updateTree(DECLARATION_VIEW);
  118. throw new RuntimeException("not implemented");
  119. }
  120. private void jbInit() throws Exception {
  121. tree_panel.setLayout(borderLayout2);
  122. this.setLayout(borderLayout1);
  123. view_comboBox.setPreferredSize(new Dimension(200, 20));
  124. view_comboBox.addActionListener(new java.awt.event.ActionListener() {
  125. public void actionPerformed(ActionEvent e) {
  126. view_comboBox_actionPerformed(e);
  127. }
  128. });
  129. view_comboBox.setMinimumSize(new Dimension(40, 20));
  130. view_comboBox.setFont(new java.awt.Font("SansSerif", 0, 11));
  131. depth_slider.setMaximumSize(new Dimension(32767, 25));
  132. depth_slider.setToolTipText("");
  133. depth_slider.setMinimumSize(new Dimension(30, 20));
  134. depth_slider.setBorder(null);
  135. depth_slider.setPreferredSize(new Dimension(30, 25));
  136. depth_slider.setMaximum(3);
  137. depth_slider.setPaintTicks(true);
  138. depth_slider.setValue(1);
  139. depth_slider.setPaintLabels(true);
  140. view_toolBar.setFloatable(false);
  141. this.add(view_toolBar, BorderLayout.NORTH);
  142. view_toolBar.add(view_comboBox, null);
  143. view_toolBar.add(depth_slider, null);
  144. this.add(tree_panel, BorderLayout.CENTER);
  145. tree_panel.add(tree_ScrollPane, BorderLayout.CENTER);
  146. }
  147. }