123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- /* *******************************************************************
- * Copyright (c) 1999-2001 Xerox Corporation,
- * 2002 Palo Alto Research Center, Incorporated (PARC).
- * All rights reserved.
- * This program and the accompanying materials are made available
- * under the terms of the Eclipse Public License v 2.0
- * which accompanies this distribution and is available at
- * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
- *
- * Contributors:
- * Xerox/PARC initial implementation
- * ******************************************************************/
-
-
- package org.aspectj.ajde.ui;
-
- import org.aspectj.asm.IProgramElement;
-
- /**
- * @author Mik Kersten
- */
- public abstract class StructureView {
-
- private IStructureViewNode rootNode = null;
- private IStructureViewNode activeNode = null;
- protected StructureViewProperties viewProperties = null;
- protected StructureViewRenderer renderer = null;
-
- public StructureViewProperties getViewProperties() {
- return viewProperties;
- }
-
- public IStructureViewNode getRootNode() {
- return rootNode;
- }
-
- public void setRootNode(IStructureViewNode rootNode) {
- this.rootNode = rootNode;
- }
-
- public void setViewProperties(StructureViewProperties viewProperties) {
- this.viewProperties = viewProperties;
- }
-
- public void setRenderer(StructureViewRenderer renderer) {
- this.renderer = renderer;
- }
-
- protected void notifyViewUpdated() {
- if (renderer != null) renderer.updateView(this);
- }
-
- /**
- * @return the view node corresponding to the active ProgramElementNode or null
- */
- public IStructureViewNode getActiveNode() {
- if (activeNode != null
- && activeNode.getStructureNode()!=null) {
- return activeNode;
- } else {
- return null;
- }
- }
-
- /**
- * Searches from the root node of the view down in order to find matches.
- *
- * @return the first match
- */
- public IStructureViewNode findCorrespondingViewNode(IProgramElement node) {
- return findCorrespondingViewNodeHelper(rootNode, node);
- }
-
- private IStructureViewNode findCorrespondingViewNodeHelper(IStructureViewNode node, IProgramElement pNode) {
- if (node != null
- && node.getStructureNode() != null
- && node.getStructureNode().equals(pNode)
- && node.getKind() == IStructureViewNode.Kind.DECLARATION) {
-
- return node;
- }
-
- if (node != null && node.getChildren() != null) {
- for (Object o : node.getChildren()) {
- IStructureViewNode foundNode = findCorrespondingViewNodeHelper((IStructureViewNode) o, pNode);
- if (foundNode != null) return foundNode;
- }
- }
-
- return null;
- }
-
- public void setActiveNode(IStructureViewNode activeNode) {
- this.activeNode = activeNode;
- if (renderer != null) renderer.setActiveNode(activeNode);
- }
-
- public void setActiveNode(IStructureViewNode activeNode, int sourceLine) {
- this.activeNode = activeNode;
- if (renderer != null) renderer.setActiveNode(activeNode, sourceLine);
- }
- }
|