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: */
041:
042: package org.netbeans.modules.vmd.midpnb.producers;
043:
044: import org.netbeans.modules.vmd.api.model.DesignComponent;
045: import org.netbeans.modules.vmd.api.model.DesignDocument;
046: import org.netbeans.modules.vmd.api.model.PaletteDescriptor;
047: import org.netbeans.modules.vmd.api.model.PropertyValue;
048: import org.netbeans.modules.vmd.midp.components.MidpDocumentSupport;
049: import org.netbeans.modules.vmd.midp.java.MidpJavaSupport;
050: import org.netbeans.modules.vmd.midp.components.MidpTypes;
051: import org.netbeans.modules.vmd.midp.components.displayables.DisplayableCD;
052: import org.netbeans.modules.vmd.midp.components.sources.CommandEventSourceCD;
053: import org.netbeans.modules.vmd.midp.palette.MidpPaletteProvider;
054: import org.netbeans.modules.vmd.midp.producers.MidpComponentProducer;
055: import org.netbeans.modules.vmd.midpnb.components.commands.SMSComposerSendCommandCD;
056: import org.netbeans.modules.vmd.midpnb.components.displayables.SMSComposerCD;
057: import org.netbeans.modules.vmd.midpnb.components.sources.SMSComposerSendCommandEventSourceCD;
058: import org.openide.util.NbBundle;
059:
060: /**
061: *
062: * @author Karol Harezlak
063: */
064: public class SMSComposerProducer extends MidpComponentProducer {
065:
066: public SMSComposerProducer() {
067: super (SMSComposerCD.TYPEID, new PaletteDescriptor(
068: MidpPaletteProvider.CATEGORY_DISPLAYABLES, NbBundle
069: .getMessage(SMSComposerProducer.class,
070: "DISP_SMS_Composer"), NbBundle
071: .getMessage(SMSComposerProducer.class,
072: "TTIP_SMS_Composer"),
073: SMSComposerCD.ICON_PATH, SMSComposerCD.ICON_LARGE_PATH)); // NOI18N
074: }
075:
076: @Override
077: public Result postInitialize(DesignDocument document,
078: DesignComponent smsComposer) {
079: DesignComponent sendCommand = MidpDocumentSupport
080: .getSingletonCommand(document,
081: SMSComposerSendCommandCD.TYPEID);
082: DesignComponent smsEventSource = document
083: .createComponent(SMSComposerSendCommandEventSourceCD.TYPEID);
084: smsEventSource.writeProperty(
085: CommandEventSourceCD.PROP_DISPLAYABLE, PropertyValue
086: .createComponentReference(smsComposer));
087: smsEventSource.writeProperty(CommandEventSourceCD.PROP_COMMAND,
088: PropertyValue.createComponentReference(sendCommand));
089: MidpDocumentSupport.addEventSource(smsComposer,
090: DisplayableCD.PROP_COMMANDS, smsEventSource);
091: smsComposer.writeProperty(SMSComposerCD.PROP_BGK_COLOR,
092: MidpTypes.createIntegerValue(-3355444));
093: smsComposer.writeProperty(SMSComposerCD.PROP_FRG_COLOR,
094: MidpTypes.createIntegerValue(-16777216));
095: smsComposer
096: .writeProperty(
097: SMSComposerCD.PROP_PHONE_NUMEBR_LABEL,
098: MidpTypes
099: .createStringValue(SMSComposerCD.PHONE_NUMBER_LABEL));
100: smsComposer
101: .writeProperty(
102: SMSComposerCD.PROP_MESSAGE_LABEL,
103: MidpTypes
104: .createStringValue(SMSComposerCD.MESSAGE_LABEL));
105: return new Result(smsComposer, sendCommand, smsEventSource);
106: }
107:
108: @Override
109: public Boolean checkValidity(DesignDocument document,
110: boolean useCachedValue) {
111: if (useCachedValue) {
112: return MidpJavaSupport.getCache(document)
113: .checkValidityCached(
114: "javax.wireless.messaging.TextMessage"); // NOI18N
115: }
116: return MidpJavaSupport.checkValidity(document,
117: "javax.wireless.messaging.TextMessage"); // NOI18N
118: }
119: }
|