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: * Created on May 20, 2003
044: *
045: */
046: package org.netbeans.modules.uml.ui.products.ad.viewfactory;
047:
048: import org.netbeans.modules.uml.common.ETException;
049: import org.netbeans.modules.uml.common.ETStrings;
050: import org.netbeans.modules.uml.common.ETSystem;
051: import org.netbeans.modules.uml.ui.swing.drawingarea.IDrawingAreaControl;
052:
053: /**
054: * @author Embarcadero Technologies Inc.
055: *
056: *
057: */
058: public class ETUIFactory {
059:
060: public ETUIFactory() {
061: }
062:
063: public static ETGenericGraphUI createGraphUI(String command) {
064:
065: return null;
066:
067: }
068:
069: public static IETGraphObjectUI createGraphObjectUI(String UIClass,
070: String initString, String drawEngineName,
071: IDrawingAreaControl drawingArea) throws ETException {
072: IETGraphObjectUI ui = null;
073:
074: try {
075: //ui = (IETGraphObjectUI) Class.forName(UIFACTORY_PACKAGE + UIClass).newInstance();
076: ui = (IETGraphObjectUI) Class.forName(UIClass)
077: .newInstance();
078: ui.setInitStringValue(initString);
079: ui.setDrawEngineClass(drawEngineName);
080: ui.setDrawingArea(drawingArea);
081: return ui;
082: } catch (InstantiationException e) {
083: throw new ETException(ETStrings.E_CMN_CREATE_INSTANCE,
084: UIClass, e.getMessage());
085: } catch (IllegalAccessException e) {
086: throw new ETException(ETStrings.E_CMN_ILLEGAL_ACCESS,
087: UIClass, e.getMessage());
088: } catch (ClassNotFoundException e) {
089: throw new ETException(ETStrings.E_CMN_CLASS_NOT_FOUND,
090: UIClass, e.getMessage());
091: } catch (Exception e) {
092: throw new ETException(ETStrings.E_CMN_UNEXPECTED_EXC,
093: "ETUIFactory.createGraphObjUI()", e.getMessage());
094: }
095: }
096:
097: public static ETGenericNodeUI createNodeUI(String nodeUIClass,
098: String initString, String drawEngineName,
099: IDrawingAreaControl drawingArea) throws ETException {
100:
101: IETGraphObjectUI retVal = createGraphObjectUI(nodeUIClass,
102: initString, drawEngineName, drawingArea);
103:
104: return (ETGenericNodeUI) retVal;
105: }
106:
107: public static ETGenericNodeLabelUI createNodeLabelUI(
108: String nodeLabelUIClass, String initString,
109: String drawEngineName, IDrawingAreaControl drawingArea)
110: throws ETException {
111:
112: ETSystem.out.println("Inside ETUIFactory.createNodeLabelUI() ");
113: IETGraphObjectUI retVal = createGraphObjectUI(nodeLabelUIClass,
114: initString, drawEngineName, drawingArea);
115:
116: return (ETGenericNodeLabelUI) retVal;
117: }
118:
119: public static ETGenericEdgeUI createEdgeUI(String edgeUIClass,
120: String initString, String drawEngineClass,
121: IDrawingAreaControl drawingArea) throws ETException {
122: return (ETGenericEdgeUI) createGraphObjectUI(edgeUIClass,
123: initString, drawEngineClass, drawingArea);
124: }
125:
126: public static ETGenericEdgeLabelUI createEdgeLabelUI(
127: String edgeLabelUIClass, String initString,
128: String drawEngineName, IDrawingAreaControl drawingArea)
129: throws ETException {
130:
131: ETSystem.out.println("Inside ETUIFactory.createEdgeLabelUI() ");
132: IETGraphObjectUI retVal = createGraphObjectUI(edgeLabelUIClass,
133: initString, drawEngineName, drawingArea);
134:
135: return (ETGenericEdgeLabelUI) retVal;
136: }
137:
138: public static ETGenericConnectorUI createConnectorUI(String command) {
139: return null;
140: }
141:
142: // Package where the classes for the supported UI' can be found
143: private static final String UIFACTORY_PACKAGE = "org.netbeans.modules.uml.ui.products.ad.viewfactory.";
144:
145: // The class names of the supported UI's
146: public static final String GENERIC_GRAPH_UI = "ETGenericGraphUI";
147: public static final String GENERIC_EDGE_UI = "ETGenericEdgeUI";
148: public static final String GENERIC_EDGE_LABEL_UI = "ETGenericEdgeLabelUI";
149: public static final String GENERIC_NODE_UI = "ETGenericNodeUI";
150: public static final String GENERIC_NODE_LABEL_UI = "ETGenericNodeLabelUI";
151: public static final String GENERIC_CONNECTOR_UI = "ETGenericConnectorUI";
152:
153: }
|