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-2006 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: */package org.netbeans.modules.vmd.midp.converter.wizard;
041:
042: import org.netbeans.modules.vmd.api.model.ComponentProducer;
043: import org.netbeans.modules.vmd.api.model.DesignComponent;
044: import org.netbeans.modules.vmd.api.model.DesignDocument;
045: import org.netbeans.modules.vmd.api.model.common.DocumentSupport;
046: import org.netbeans.modules.vmd.midp.components.MidpDocumentSupport;
047: import org.netbeans.modules.vmd.midp.components.MidpTypes;
048: import org.netbeans.modules.vmd.midp.components.categories.ResourcesCategoryCD;
049: import org.netbeans.modules.vmd.midpnb.components.displayables.AbstractInfoScreenCD;
050: import org.netbeans.modules.vmd.midpnb.components.displayables.SplashScreenCD;
051: import org.netbeans.modules.vmd.midpnb.components.displayables.WaitScreenCD;
052: import org.netbeans.modules.vmd.midpnb.components.items.TableItemCD;
053: import org.netbeans.modules.vmd.midpnb.components.resources.SimpleCancellableTaskCD;
054: import org.netbeans.modules.vmd.midpnb.components.resources.SimpleTableModelCD;
055: import org.netbeans.modules.vmd.midpnb.components.resources.TableModelCD;
056: import org.netbeans.modules.vmd.midpnb.components.sources.SplashScreenDismissCommandEventSourceCD;
057: import org.netbeans.modules.vmd.midpnb.components.sources.WaitScreenFailureCommandEventSourceCD;
058: import org.netbeans.modules.vmd.midpnb.components.sources.WaitScreenSuccessCommandEventSourceCD;
059: import org.netbeans.modules.vmd.midpnb.producers.WaitScreenProducer;
060:
061: import java.util.HashMap;
062: import java.util.List;
063:
064: /**
065: * @author David Kaspar
066: */
067: public class ConverterBuilt {
068:
069: // Created: NO, Adds: NE
070: static void convertAbstractInfoScreen(
071: HashMap<String, ConverterItem> id2item, ConverterItem item,
072: DesignComponent screen) {
073: ConverterDisplayables.convertCanvas(id2item, item, screen);
074:
075: ConverterUtil.convertStringWithUserCode(screen,
076: AbstractInfoScreenCD.PROP_TEXT, item
077: .getPropertyValue("text")); // NOI18N
078: ConverterUtil.convertConverterItemComponent(screen,
079: AbstractInfoScreenCD.PROP_TEXT_FONT, id2item, item
080: .getPropertyValue("textFont")); // NOI18N
081: ConverterUtil.convertConverterItemComponent(screen,
082: AbstractInfoScreenCD.PROP_IMAGE, id2item, item
083: .getPropertyValue("image")); // NOI18N
084: // HINT - display property is not used in mvd file
085: }
086:
087: // Created: YES, Adds: YES
088: static void convertSimpleCancellableTask(
089: HashMap<String, ConverterItem> id2item, ConverterItem item,
090: DesignDocument document) {
091: DesignComponent task = document
092: .createComponent(SimpleCancellableTaskCD.TYPEID);
093: Converter.convertClass(item, task);
094: MidpDocumentSupport.getCategoryComponent(document,
095: ResourcesCategoryCD.TYPEID).addComponent(task);
096:
097: String code = ConverterUtil.decryptStringFromJavaCode(item
098: .getPropertyValue("runnableMethodBody")); // NOI18N
099: if (code != null)
100: task.writeProperty(SimpleCancellableTaskCD.PROP_CODE,
101: MidpTypes.createJavaCodeValue(code));
102: }
103:
104: // Created: YES, Adds: YES
105: static void convertSimpleTableModel(
106: HashMap<String, ConverterItem> id2item, ConverterItem item,
107: DesignDocument document) {
108: DesignComponent table = document
109: .createComponent(SimpleTableModelCD.TYPEID);
110: Converter.convertClass(item, table);
111: MidpDocumentSupport.getCategoryComponent(document,
112: ResourcesCategoryCD.TYPEID).addComponent(table);
113:
114: String columns = item.getPropertyValue("columnNames"); // NOI18N
115: if (columns != null)
116: table.writeProperty(SimpleTableModelCD.PROP_COLUMN_NAMES,
117: ConverterUtil.decryptStringArrayArray(columns,
118: TableModelCD.TYPEID_COLUMN_NAMES, 1));
119:
120: String values = item.getPropertyValue("values"); // NOI18N
121: if (values != null)
122: table.writeProperty(SimpleTableModelCD.PROP_VALUES,
123: ConverterUtil.decryptStringArrayArray(values,
124: TableModelCD.TYPEID_VALUES, 2));
125: }
126:
127: // Created: YES, Adds: NO
128: static void convertSplashScreen(
129: HashMap<String, ConverterItem> id2item, ConverterItem item,
130: DesignDocument document) {
131: ComponentProducer producer = DocumentSupport
132: .getComponentProducer(document, SplashScreenCD.TYPEID
133: .toString());
134: DesignComponent screen = producer.createComponent(document)
135: .getMainComponent();
136: convertAbstractInfoScreen(id2item, item, screen);
137:
138: ConverterUtil.convertInteger(screen,
139: SplashScreenCD.PROP_TIMEOUT, item
140: .getPropertyValue("timeout")); // NOI18N
141: Boolean allow = ConverterUtil.getBoolean(item
142: .getPropertyValue("allowTimeoutInterrupt")); // NOI18N
143: screen.writeProperty(
144: SplashScreenCD.PROP_ALLOW_TIMEOUT_INTERRUPT, MidpTypes
145: .createBooleanValue(allow == null || allow));
146:
147: ConverterItem dismissActionItem = id2item.get(item
148: .getPropertyValue("dismissCommandAction")); // NOI18N
149: List<DesignComponent> dismissCommandEventSourceComponents = DocumentSupport
150: .gatherSubComponentsOfType(screen,
151: SplashScreenDismissCommandEventSourceCD.TYPEID);
152: DesignComponent dismissEventSource = dismissCommandEventSourceComponents
153: .get(0);
154: Converter.convertObject(dismissActionItem, dismissEventSource);
155: ConverterActions.convertCommandActionHandler(id2item,
156: dismissActionItem, dismissEventSource);
157: }
158:
159: // Created: YES, Adds: NO
160: static void convertWaitScreen(
161: HashMap<String, ConverterItem> id2item, ConverterItem item,
162: DesignDocument document) {
163: DesignComponent screen = WaitScreenProducer.produceWaitScreen(
164: document,
165: document.createComponent(WaitScreenCD.TYPEID), false)
166: .getMainComponent();
167: convertAbstractInfoScreen(id2item, item, screen);
168:
169: ConverterUtil.convertConverterItemComponent(screen,
170: WaitScreenCD.PROP_TASK, id2item, item
171: .getPropertyValue("task")); // NOI18N
172:
173: ConverterItem successActionItem = id2item.get(item
174: .getPropertyValue("successCommandAction")); // NOI18N
175: List<DesignComponent> successCommandEventSourceComponents = DocumentSupport
176: .gatherSubComponentsOfType(screen,
177: WaitScreenSuccessCommandEventSourceCD.TYPEID);
178: DesignComponent successEventSource = successCommandEventSourceComponents
179: .get(0);
180: Converter.convertObject(successActionItem, successEventSource);
181: ConverterActions.convertCommandActionHandler(id2item,
182: successActionItem, successEventSource);
183:
184: ConverterItem failureActionItem = id2item.get(item
185: .getPropertyValue("failureCommandAction")); // NOI18N
186: List<DesignComponent> failureCommandEventSourceComponents = DocumentSupport
187: .gatherSubComponentsOfType(screen,
188: WaitScreenFailureCommandEventSourceCD.TYPEID);
189: DesignComponent failureEventSource = failureCommandEventSourceComponents
190: .get(0);
191: Converter.convertObject(failureActionItem, failureEventSource);
192: ConverterActions.convertCommandActionHandler(id2item,
193: failureActionItem, failureEventSource);
194: }
195:
196: static void convertTableItem(
197: HashMap<String, ConverterItem> id2item, ConverterItem item,
198: DesignDocument document) {
199: DesignComponent table = document
200: .createComponent(TableItemCD.TYPEID);
201: ConverterItems.convertCustomItem(id2item, item, table);
202:
203: ConverterUtil.convertString(table, TableItemCD.PROP_TITLE, item
204: .getPropertyValue("title")); // NOI18N
205: ConverterUtil.convertBoolean(table, TableItemCD.PROP_BORDERS,
206: item.getPropertyValue("borders")); // NOI18N
207: ConverterUtil.convertConverterItemComponent(table,
208: TableItemCD.PROP_MODEL, id2item, item
209: .getPropertyValue("model")); // NOI18N
210: ConverterUtil.convertConverterItemComponent(table,
211: TableItemCD.PROP_TITLE_FONT, id2item, item
212: .getPropertyValue("titleFont")); // NOI18N
213: ConverterUtil.convertConverterItemComponent(table,
214: TableItemCD.PROP_HEADERS_FONT, id2item, item
215: .getPropertyValue("headersFont")); // NOI18N
216: ConverterUtil.convertConverterItemComponent(table,
217: TableItemCD.PROP_VALUES_FONT, id2item, item
218: .getPropertyValue("valuesFont")); // NOI18N
219: }
220:
221: }
|