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.components.displayables;
043:
044: import org.netbeans.modules.vmd.api.codegen.CodeSetterPresenter;
045: import org.netbeans.modules.vmd.api.model.*;
046: import org.netbeans.modules.vmd.api.properties.DefaultPropertiesPresenter;
047: import org.netbeans.modules.vmd.api.properties.DesignEventFilterResolver;
048: import org.netbeans.modules.vmd.midp.codegen.MidpParameter;
049: import org.netbeans.modules.vmd.midp.codegen.MidpSetter;
050: import org.netbeans.modules.vmd.midp.components.MidpTypes;
051: import org.netbeans.modules.vmd.midp.components.MidpVersionDescriptor;
052: import org.netbeans.modules.vmd.midp.components.MidpVersionable;
053: import org.netbeans.modules.vmd.midp.propertyeditors.MidpPropertiesCategories;
054: import org.netbeans.modules.vmd.midp.propertyeditors.PropertyEditorBooleanUC;
055: import org.netbeans.modules.vmd.midp.propertyeditors.PropertyEditorNumber;
056: import org.netbeans.modules.vmd.midpnb.codegen.MidpCustomCodePresenterSupport;
057: import org.openide.util.NbBundle;
058:
059: import java.util.Arrays;
060: import java.util.List;
061: import org.netbeans.modules.vmd.midp.components.MidpProjectSupport;
062:
063: /**
064: *
065: * @author Anton Chechel
066: */
067: public class SplashScreenCD extends ComponentDescriptor {
068:
069: public static final TypeID TYPEID = new TypeID(
070: TypeID.Kind.COMPONENT,
071: "org.netbeans.microedition.lcdui.SplashScreen"); // NOI18N
072:
073: public static final String ICON_PATH = "org/netbeans/modules/vmd/midpnb/resources/splash_screen_16.png"; // NOI18N
074: public static final String ICON_LARGE_PATH = "org/netbeans/modules/vmd/midpnb/resources/splash_screen_32.png"; // NOI18N
075:
076: public static final String PROP_TIMEOUT = "timeout"; //NOI18N
077: public static final String PROP_ALLOW_TIMEOUT_INTERRUPT = "allowTimeoutInterrupt"; //NOI18N
078:
079: static {
080: MidpTypes.registerIconResource(TYPEID, ICON_PATH);
081: }
082:
083: public TypeDescriptor getTypeDescriptor() {
084: return new TypeDescriptor(AbstractInfoScreenCD.TYPEID, TYPEID,
085: true, true);
086: }
087:
088: public VersionDescriptor getVersionDescriptor() {
089: return MidpVersionDescriptor.MIDP_2;
090: }
091:
092: @Override
093: public void postInitialize(DesignComponent component) {
094: super .postInitialize(component);
095: MidpProjectSupport.addLibraryToProject(component.getDocument(),
096: AbstractInfoScreenCD.MIDP_NB_LIBRARY_BASIC); //NOI18N
097: }
098:
099: public List<PropertyDescriptor> getDeclaredPropertyDescriptors() {
100: return Arrays.asList(new PropertyDescriptor(PROP_TIMEOUT,
101: MidpTypes.TYPEID_INT, MidpTypes
102: .createIntegerValue(5000), false, true,
103: MidpVersionable.MIDP_2), new PropertyDescriptor(
104: PROP_ALLOW_TIMEOUT_INTERRUPT, MidpTypes.TYPEID_BOOLEAN,
105: MidpTypes.createBooleanValue(true), false, true,
106: MidpVersionable.MIDP_2));
107: }
108:
109: private static DefaultPropertiesPresenter createPropertiesPresenter() {
110: return new DefaultPropertiesPresenter(
111: DesignEventFilterResolver.THIS_COMPONENT)
112: .addPropertiesCategory(
113: MidpPropertiesCategories.CATEGORY_PROPERTIES)
114: .addProperty(
115: NbBundle.getMessage(SplashScreenCD.class,
116: "DISP_SplashScreen_Timeout"), // NOI18N
117: PropertyEditorNumber.createIntegerInstance(
118: false, NbBundle.getMessage(
119: SplashScreenCD.class,
120: "LBL_SplashScreen_Timeout")),
121: PROP_TIMEOUT) // NOI18N
122: .addProperty(
123: NbBundle
124: .getMessage(SplashScreenCD.class,
125: "DISP_SplashScreen_AllowTimeoutInterrupt"), // NOI18N
126: PropertyEditorBooleanUC
127: .createInstance(NbBundle
128: .getMessage(
129: SplashScreenCD.class,
130: "LBL_SplashScreen_AllowTimeoutInterrupt")),
131: PROP_ALLOW_TIMEOUT_INTERRUPT); // NOI18N
132: }
133:
134: private Presenter createSetterPresenter() {
135: return new CodeSetterPresenter()
136: .addParameters(
137: MidpCustomCodePresenterSupport
138: .createDisplayParameter())
139: .addParameters(
140: MidpCustomCodePresenterSupport
141: .createTimeoutParameter())
142: .addParameters(
143: MidpParameter
144: .create(PROP_ALLOW_TIMEOUT_INTERRUPT))
145: .addParameters(
146: MidpCustomCodePresenterSupport
147: .createSplashScreenCommandParameter())
148: .addSetters(
149: MidpSetter
150: .createConstructor(TYPEID,
151: MidpVersionable.MIDP_2)
152: .addParameters(
153: MidpCustomCodePresenterSupport.PARAM_DISPLAY))
154: .addSetters(
155: MidpSetter
156: .createSetter("setTimeout",
157: MidpVersionable.MIDP_2)
158: .addParameters(
159: MidpCustomCodePresenterSupport.PARAM_TIMEOUT))
160: .addSetters(
161: MidpSetter.createSetter(
162: "setAllowTimeoutInterrupt",
163: MidpVersionable.MIDP_2).addParameters(
164: PROP_ALLOW_TIMEOUT_INTERRUPT));
165: }
166:
167: protected List<? extends Presenter> createPresenters() {
168: return Arrays.asList(
169: // properties
170: createPropertiesPresenter(),
171: // code
172: createSetterPresenter());
173: }
174: }
|