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: * File : DiagramKind.java
044: * Version : 1.0
045: * Description : Enumerates the valid DiagramKind constants.
046: * Author : Darshan
047: */
048: package org.netbeans.modules.uml.integration.ide;
049:
050: import javax.swing.ImageIcon;
051:
052: import org.netbeans.modules.uml.integration.ide.actions.ImageFinder;
053: import org.netbeans.modules.uml.core.metamodel.diagrams.IDiagram;
054:
055: /**
056: * Enumerates the valid DiagramKind constants and maps between DiagramKind
057: * and NewWorkspaceItemKind.
058: *
059: * Revision History
060: * No. Date Who What
061: * --- ---- --- ----
062: * 1 2002-05-22 Darshan Created.
063: *
064: * @author Darshan
065: */
066: public class DiagramKind {
067: public static final int DK_UNKNOWN = 0x0000;
068: public static final int DK_DIAGRAM = 0x0001;
069: public static final int DK_ACTIVITY_DIAGRAM = 0x0002;
070: public static final int DK_CLASS_DIAGRAM = 0x0004;
071: public static final int DK_COLLABORATION_DIAGRAM = 0x0008;
072: public static final int DK_COMPONENT_DIAGRAM = 0x0010;
073: public static final int DK_DEPLOYMENT_DIAGRAM = 0x0020;
074: public static final int DK_SEQUENCE_DIAGRAM = 0x0040;
075: public static final int DK_STATE_DIAGRAM = 0x0080;
076: public static final int DK_USECASE_DIAGRAM = 0x0100;
077: public static final int DK_ALL = 0xFFFF;
078:
079: public static final int DK_CREATE_FROM_SELECTED = 0x10000;
080:
081: public static ImageIcon getDiagramIcon(IDiagram diag) {
082: switch (diag.getDiagramKind()) {
083: case DK_CLASS_DIAGRAM:
084: return ImageFinder.CLASS_DIAGRAM_ICON;
085: case DK_SEQUENCE_DIAGRAM:
086: return ImageFinder.SEQ_DIAGRAM_ICON;
087: case DK_ACTIVITY_DIAGRAM:
088: return ImageFinder.ACTIVITY_DIAGRAM_ICON;
089: case DK_COLLABORATION_DIAGRAM:
090: return ImageFinder.COLLABORATION_DIAGRAM_ICON;
091: case DK_COMPONENT_DIAGRAM:
092: return ImageFinder.COMPONENT_DIAGRAM_ICON;
093: case DK_DEPLOYMENT_DIAGRAM:
094: return ImageFinder.DEPLOYMENT_DIAGRAM_ICON;
095: case DK_STATE_DIAGRAM:
096: return ImageFinder.STATE_DIAGRAM_ICON;
097: case DK_USECASE_DIAGRAM:
098: return ImageFinder.USECASE_DIAGRAM_ICON;
099: }
100: return null;
101: }
102:
103: public static String getDiagramIconPath(IDiagram diag) {
104: return getDiagramIconPath(diag.getDiagramKind());
105: }
106:
107: public static String getDiagramIconPath(int kind) {
108: switch (kind) {
109: case DK_CLASS_DIAGRAM:
110: return ImageFinder.CLASS_DIAGRAM_PATH;
111: case DK_SEQUENCE_DIAGRAM:
112: return ImageFinder.SEQ_DIAGRAM_PATH;
113: case DK_ACTIVITY_DIAGRAM:
114: return ImageFinder.ACTIVITY_DIAGRAM_PATH;
115: case DK_COLLABORATION_DIAGRAM:
116: return ImageFinder.COLLABORATION_DIAGRAM_PATH;
117: case DK_COMPONENT_DIAGRAM:
118: return ImageFinder.COMPONENT_DIAGRAM_PATH;
119: case DK_DEPLOYMENT_DIAGRAM:
120: return ImageFinder.DEPLOYMENT_DIAGRAM_PATH;
121: case DK_STATE_DIAGRAM:
122: return ImageFinder.STATE_DIAGRAM_PATH;
123: case DK_USECASE_DIAGRAM:
124: return ImageFinder.USECASE_DIAGRAM_PATH;
125: }
126: return null;
127: }
128: }
|