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: package org.netbeans.modules.vmd.midpnb.producers;
042:
043: import org.netbeans.modules.vmd.api.model.ComponentProducer;
044: import org.netbeans.modules.vmd.api.model.DesignDocument;
045: import org.netbeans.modules.vmd.api.model.PaletteDescriptor;
046: import org.netbeans.modules.vmd.api.model.TypeID;
047: import org.netbeans.modules.vmd.midp.java.MidpJavaSupport;
048: import org.netbeans.modules.vmd.midp.palette.MidpPaletteProvider;
049: import org.netbeans.modules.vmd.midpnb.components.handlers.SVGMenuEventHandlerCD;
050: import org.netbeans.modules.vmd.midpnb.components.items.TableItemCD;
051: import org.netbeans.modules.vmd.midpnb.components.resources.CancellableTaskCD;
052: import org.netbeans.modules.vmd.midpnb.components.resources.SimpleCancellableTaskCD;
053: import org.netbeans.modules.vmd.midpnb.components.resources.SimpleTableModelCD;
054: import org.netbeans.modules.vmd.midpnb.components.resources.TableModelCD;
055: import org.netbeans.modules.vmd.midpnb.components.svg.SVGImageCD;
056: import org.netbeans.modules.vmd.midpnb.components.svg.SVGPlayerCD;
057: import org.netbeans.modules.vmd.midpnb.palette.MidpNbPaletteProvider;
058: import org.openide.util.NbBundle;
059:
060: /**
061: *
062: * @author Karol Harezlak
063: * @author Anton Chechel
064: */
065: public abstract class CustomComponentProducer extends ComponentProducer {
066:
067: public CustomComponentProducer(TypeID typeID,
068: PaletteDescriptor paletteDescriptor) {
069: super (typeID.toString(), typeID, paletteDescriptor);
070: }
071:
072: public Boolean checkValidity(DesignDocument document,
073: boolean useCachedValue) {
074: Boolean isValid1;
075: Boolean isValid2;
076: if (useCachedValue) {
077: isValid1 = MidpJavaSupport.getCache(document)
078: .checkValidityCached(
079: "javax.microedition.m2g.SVGImage"); // NOI18N
080: isValid2 = MidpJavaSupport.getCache(document)
081: .checkValidityCached(
082: "javax.microedition.lcdui.Canvas"); // NOI18N
083: } else {
084: isValid1 = MidpJavaSupport.checkValidity(document,
085: "javax.microedition.m2g.SVGImage"); // NOI18N
086: isValid2 = MidpJavaSupport.checkValidity(document,
087: "javax.microedition.lcdui.Canvas"); // NOI18N
088: }
089:
090: return isValid1 != null && isValid2 != null ? isValid1
091: && isValid2 : null;
092: }
093:
094: public static final class SVGPlayerProducer extends
095: CustomComponentProducer {
096:
097: public SVGPlayerProducer() {
098: super (SVGPlayerCD.TYPEID, new PaletteDescriptor(
099: MidpNbPaletteProvider.CATEGORY_SVG, NbBundle
100: .getMessage(CustomComponentProducer.class,
101: "DISP_SVG_Player"), NbBundle
102: .getMessage(CustomComponentProducer.class,
103: "TTIP_SVG_Player"),
104: SVGPlayerCD.ICON_PATH, SVGPlayerCD.ICON_LARGE_PATH)); // NOI18N
105: }
106: }
107:
108: public static final class SVGImageProducer extends
109: CustomComponentProducer {
110:
111: public SVGImageProducer() {
112: super (SVGImageCD.TYPEID, new PaletteDescriptor(
113: MidpNbPaletteProvider.CATEGORY_SVG, NbBundle
114: .getMessage(CustomComponentProducer.class,
115: "DISP_SVG_Image"), NbBundle
116: .getMessage(CustomComponentProducer.class,
117: "TTIP_SVG_Image"),
118: SVGImageCD.ICON_PATH, SVGImageCD.ICON_LARGE_PATH)); // NOI18N
119: }
120: }
121:
122: public static final class SVGMenuEventHandlerProducer extends
123: CustomComponentProducer {
124:
125: public SVGMenuEventHandlerProducer() {
126: super (SVGMenuEventHandlerCD.TYPEID, new PaletteDescriptor(
127: MidpNbPaletteProvider.CATEGORY_SVG, NbBundle
128: .getMessage(CustomComponentProducer.class,
129: "DISP_SVG_Menu_Action"), NbBundle
130: .getMessage(CustomComponentProducer.class,
131: "TTIP_SVG_Menu_Action"),
132: SVGMenuEventHandlerCD.ICON_PATH,
133: SVGMenuEventHandlerCD.LARGE_ICON_PATH)); // NOI18N
134: }
135: }
136:
137: public static final class TableItemProducer extends
138: CustomComponentProducer {
139:
140: public TableItemProducer() {
141: super (TableItemCD.TYPEID, new PaletteDescriptor(
142: MidpPaletteProvider.CATEGORY_ITEMS, NbBundle
143: .getMessage(CustomComponentProducer.class,
144: "DISP_Table_Item"), NbBundle
145: .getMessage(CustomComponentProducer.class,
146: "TTIP_Table_Item"),
147: TableItemCD.ICON_PATH, TableItemCD.ICON_LARGE_PATH)); // NOI18N
148: }
149:
150: @Override
151: public Boolean checkValidity(DesignDocument document,
152: boolean useCachedValue) {
153: if (useCachedValue) {
154: return MidpJavaSupport.getCache(document)
155: .checkValidityCached(
156: "javax.microedition.lcdui.Item"); // NOI18N
157: }
158: return MidpJavaSupport.checkValidity(document,
159: "javax.microedition.lcdui.Item"); // NOI18N
160: }
161: }
162:
163: public static final class SimpleCancellableTaskProducer extends
164: CustomComponentProducer {
165:
166: public SimpleCancellableTaskProducer() {
167: super (SimpleCancellableTaskCD.TYPEID,
168: new PaletteDescriptor(
169: MidpPaletteProvider.CATEGORY_RESOURCES,
170: NbBundle.getMessage(
171: CustomComponentProducer.class,
172: "DISP_Simple_Cancellable_Task"),
173: NbBundle.getMessage(
174: CustomComponentProducer.class,
175: "TTIP_Simple_Cancellable_Task"),
176: CancellableTaskCD.ICON_PATH,
177: CancellableTaskCD.ICON_LARGE_PATH)); // NOI18N
178: }
179:
180: @Override
181: public Boolean checkValidity(DesignDocument document,
182: boolean useCachedValue) {
183: if (useCachedValue) {
184: return MidpJavaSupport.getCache(document)
185: .checkValidityCached("java.lang.Runnable"); // NOI18N
186: }
187: return MidpJavaSupport.checkValidity(document,
188: "java.lang.Runnable"); // NOI18N
189: }
190: }
191:
192: public static final class SimpleTableModelProducer extends
193: CustomComponentProducer {
194:
195: public SimpleTableModelProducer() {
196: super (SimpleTableModelCD.TYPEID, new PaletteDescriptor(
197: MidpPaletteProvider.CATEGORY_RESOURCES, NbBundle
198: .getMessage(CustomComponentProducer.class,
199: "DISP_Simple_Table_Model"),
200: NbBundle.getMessage(CustomComponentProducer.class,
201: "TTIP_Simple_Table_Model"),
202: TableModelCD.ICON_PATH,
203: TableModelCD.ICON_LARGE_PATH)); // NOI18N
204: }
205:
206: @Override
207: public Boolean checkValidity(DesignDocument document,
208: boolean useCachedValue) {
209: if (useCachedValue) {
210: return MidpJavaSupport.getCache(document)
211: .checkValidityCached(
212: "javax.microedition.lcdui.Form"); // NOI18N
213: }
214: return MidpJavaSupport.checkValidity(document,
215: "javax.microedition.lcdui.Form"); // NOI18N
216: }
217: }
218: }
|