001: /*
002: * The contents of this file are subject to the terms of the Common Development
003: * and Distribution License (the License). You may not use this file except in
004: * compliance with the License.
005: *
006: * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007: * or http://www.netbeans.org/cddl.txt.
008: *
009: * When distributing Covered Code, include this CDDL Header Notice in each file
010: * and include the License file at http://www.netbeans.org/cddl.txt.
011: * If applicable, add the following below the CDDL Header, with the fields
012: * enclosed by brackets [] replaced by your own identifying information:
013: * "Portions Copyrighted [year] [name of copyright owner]"
014: *
015: * The Original Software is NetBeans. The Initial Developer of the Original
016: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017: * Microsystems, Inc. All Rights Reserved.
018: */
019: package org.netbeans.modules.xslt.tmap.multiview.tree;
020:
021: import java.awt.Component;
022: import java.beans.PropertyChangeEvent;
023: import org.netbeans.modules.xslt.tmap.model.api.TMapModel;
024: import org.netbeans.modules.xslt.tmap.nodes.LogicalTreeHandler;
025: import org.openide.explorer.ExplorerManager;
026: import org.openide.explorer.view.BeanTreeView;
027: import org.openide.nodes.Node;
028: import org.openide.util.Lookup;
029: import org.openide.windows.TopComponent;
030:
031: /**
032: *
033: * @author Vitaly Bychkov
034: * @version 1.0
035: *
036: */
037: public class MultiviewTreeHandler extends LogicalTreeHandler {
038:
039: public MultiviewTreeHandler(ExplorerManager explorerManager,
040: TMapModel tModel, Lookup contextLookup) {
041: super (explorerManager, tModel, contextLookup);
042: }
043:
044: @Override
045: public void propertyChange(PropertyChangeEvent evt) {
046: // System.out.println("propertyChange: "+evt);
047:
048: String propertyName = evt.getPropertyName();
049: TopComponent curTc = getCurrentTopComponent();
050: if (curTc == null) {
051: return;
052: }
053: // System.out.println("propertyChange name: "+propertyName);
054:
055: if (propertyName.equals(TopComponent.Registry.PROP_ACTIVATED)) {
056: if (TopComponent.getRegistry().getActivated() == curTc) {
057: // addUndoManager();
058: // triggerValidation();
059: }
060: } else if (propertyName
061: .equals(TopComponent.Registry.PROP_ACTIVATED_NODES)) {
062: if (TopComponent.getRegistry().getActivated() != curTc) {
063: doTreeNodeSelectionByActiveNode();
064: }
065: return;
066:
067: } else if (propertyName
068: .equals(ExplorerManager.PROP_SELECTED_NODES)) {
069: // NAVIGATOR SELECTED NODES SETTED AS ACTIVE NODES
070: //navigatorTopComponent.setActivatedNodes(new Node[] {});
071: curTc.setActivatedNodes((Node[]) evt.getNewValue());
072: } else if (propertyName
073: .equals(ExplorerManager.PROP_ROOT_CONTEXT)) {
074: //EVENT FOR PROPERTY PROP_ROOT_CONTEXT
075: doTreeNodeSelectionByActiveNode();
076: }
077: // } else if (propertyName.equals(TopComponent.Registry.PROP_OPENED)) {
078: //// System.out.println("the set of the opened topComponent were changed");
079: // TMapNavigatorController.activateLogicalPanel();
080: // } /***/else if (propertyName.equals(TopComponent.Registry.PROP_CURRENT_NODES)) {
081: //// System.out.println("the set of currently selected nodes were changed");
082: // TMapNavigatorController.activateLogicalPanel();
083: // }
084:
085: }
086:
087: private TopComponent getCurrentTopComponent() {
088: BeanTreeView beanTreeView = getBeanTreeView();
089: if (beanTreeView == null) {
090: return null;
091: }
092:
093: TopComponent tc = null;
094: Component parent = beanTreeView;
095: while ((parent = parent.getParent()) != null) {
096: if (parent instanceof TopComponent) {
097: tc = (TopComponent) parent;
098: break;
099: }
100: }
101:
102: return tc;
103: }
104:
105: }
|