001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: /*
043: * ModelingPalette.java
044: *
045: * Created on March 2, 2005, 3:13 PM
046: */
047:
048: package org.netbeans.modules.uml.palette.ui;
049:
050: import org.openide.nodes.Node;
051: import org.openide.nodes.FilterNode;
052: import org.openide.cookies.InstanceCookie;
053:
054: /**
055: *
056: * @author Praveen Savur
057: */
058: public class ModelingPalette extends FilterNode {
059: private static final int DELEGATE = DELEGATE_SET_NAME
060: | DELEGATE_GET_NAME | DELEGATE_SET_DISPLAY_NAME
061: | DELEGATE_GET_DISPLAY_NAME
062: | DELEGATE_SET_SHORT_DESCRIPTION
063: | DELEGATE_GET_SHORT_DESCRIPTION | DELEGATE_DESTROY
064: | DELEGATE_GET_ACTIONS | DELEGATE_GET_CONTEXT_ACTIONS
065: | DELEGATE_SET_VALUE | DELEGATE_GET_VALUE;
066:
067: /** Creates a new instance of ModelingPalette */
068: public ModelingPalette(Node root) {
069: super (root, new PaletteCategoryFilterNode(root));
070: enableDelegation(DELEGATE);
071: }
072:
073: // public SystemAction[] getActions() {
074: // if (staticActions == null)
075: // staticActions = new SystemAction [] {
076: // SystemAction.get(ReorderAction.class)
077: // };
078: // return staticActions;
079: // }
080: }
081:
082: class PaletteCategoryFilterNode extends FilterNode.Children {
083:
084: public PaletteCategoryFilterNode(Node node) {
085: super (node);
086: }
087:
088: protected Node copyNode(Node node) {
089: return new PaletteCategoryNode(node);
090: }
091: }
092:
093: class PaletteCategoryNode extends FilterNode {
094:
095: private static final int DELEGATE = DELEGATE_SET_NAME
096: | DELEGATE_GET_NAME | DELEGATE_SET_DISPLAY_NAME
097: | DELEGATE_GET_DISPLAY_NAME
098: | DELEGATE_SET_SHORT_DESCRIPTION
099: | DELEGATE_GET_SHORT_DESCRIPTION | DELEGATE_DESTROY
100: | DELEGATE_GET_ACTIONS | DELEGATE_GET_CONTEXT_ACTIONS
101: | DELEGATE_SET_VALUE | DELEGATE_GET_VALUE;
102:
103: public PaletteCategoryNode(Node node) {
104: super (node, new PaletteElementFilterNode(node));
105: enableDelegation(DELEGATE);
106: }
107: }
108:
109: class PaletteElementFilterNode extends FilterNode.Children {
110: public PaletteElementFilterNode(Node node) {
111: super (node);
112: }
113:
114: public Node copyNode(Node node) {
115: InstanceCookie ic = (InstanceCookie) node
116: .getCookie(InstanceCookie.class);
117: if (ic != null)
118: return new PaletteElementNode(ic, node);
119:
120: return node;
121: }
122: }
|