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

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