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.midp.components.sources;
042:
043: import org.netbeans.modules.vmd.api.codegen.CodeClassLevelPresenter;
044: import org.netbeans.modules.vmd.api.codegen.CodeMultiGuardedLevelPresenter;
045: import org.netbeans.modules.vmd.api.codegen.CodeNamePresenter;
046: import org.netbeans.modules.vmd.api.codegen.MultiGuardedSection;
047: import org.netbeans.modules.vmd.api.model.*;
048: import org.netbeans.modules.vmd.api.model.presenters.InfoPresenter;
049: import org.netbeans.modules.vmd.api.model.presenters.actions.DeletePresenter;
050: import org.netbeans.modules.vmd.api.model.presenters.actions.DeleteDependencyPresenter;
051: import org.netbeans.modules.vmd.midp.components.MidpVersionDescriptor;
052: import org.netbeans.modules.vmd.midp.components.points.MobileDeviceCD;
053: import org.netbeans.modules.vmd.midp.flow.FlowEventSourcePinPresenter;
054: import org.netbeans.modules.vmd.midp.flow.FlowMobileDevicePinOrderPresenter;
055: import org.netbeans.modules.vmd.midp.actions.GoToSourcePresenter;
056: import org.netbeans.modules.vmd.midp.actions.MidpActionsSupport;
057: import org.netbeans.api.editor.guards.GuardedSection;
058: import org.openide.util.NbBundle;
059:
060: import javax.swing.text.StyledDocument;
061: import java.util.Arrays;
062: import java.util.List;
063: import java.util.ArrayList;
064:
065: /**
066: * @author David Kaspar
067: */
068:
069: public final class MobileDeviceResumeEventSourceCD extends
070: ComponentDescriptor {
071:
072: public static final TypeID TYPEID = new TypeID(
073: TypeID.Kind.COMPONENT, "#MobileDeviceResumeEventSource"); // NOI18N
074:
075: public static final String PROP_MOBILE_DEVICE = "mobileDevice"; // NOI18N
076:
077: public TypeDescriptor getTypeDescriptor() {
078: return new TypeDescriptor(EventSourceCD.TYPEID,
079: MobileDeviceResumeEventSourceCD.TYPEID, true, false);
080: }
081:
082: public VersionDescriptor getVersionDescriptor() {
083: return MidpVersionDescriptor.MIDP;
084: }
085:
086: public List<PropertyDescriptor> getDeclaredPropertyDescriptors() {
087: return Arrays.asList(new PropertyDescriptor(
088: MobileDeviceResumeEventSourceCD.PROP_MOBILE_DEVICE,
089: MobileDeviceCD.TYPEID, PropertyValue.createNull(),
090: true, false, Versionable.FOREVER));
091: }
092:
093: public static DesignComponent getMobileDeviceComponent(
094: DesignComponent mobileDeviceResumeEventSourceComponent) {
095: return mobileDeviceResumeEventSourceComponent
096: .getParentComponent();
097: }
098:
099: @Override
100: protected void gatherPresenters(ArrayList<Presenter> presenters) {
101: MidpActionsSupport.addCommonActionsPresenters(presenters,
102: false, true, false, false, false);
103: super .gatherPresenters(presenters);
104: }
105:
106: protected List<? extends Presenter> createPresenters() {
107: return Arrays.asList(
108: // info
109: InfoPresenter.createStatic(NbBundle.getMessage(
110: MobileDeviceResumeEventSourceCD.class,
111: "DISP_MIDletResumed"), NbBundle.getMessage(
112: MobileDeviceResumeEventSourceCD.class,
113: "DISP_Event"), MobileDeviceCD.ICON_PATH), // NOI18N
114: // general
115: new GoToSourcePresenter() {
116: protected boolean matches(GuardedSection section) {
117: return MultiGuardedSection.matches(section,
118: getComponent().getComponentID()
119: + "-resumeMIDlet", 0); // NOI18N
120: }
121: },
122: // flow
123: new FlowEventSourcePinPresenter() {
124: protected DesignComponent getComponentForAttachingPin() {
125: return getMobileDeviceComponent(getComponent());
126: }
127:
128: protected String getDisplayName() {
129: return NbBundle.getMessage(
130: MobileDeviceResumeEventSourceCD.class,
131: "DISP_FlowPin_MIDletResumed"); // NOI18N
132: }
133:
134: protected String getOrder() {
135: return FlowMobileDevicePinOrderPresenter.CATEGORY_ID;
136: }
137: },
138: // code
139: new CodeClassLevelPresenter.Adapter() {
140: @Override
141: protected void generateClassBodyCode(
142: StyledDocument document) {
143: MultiGuardedSection section = MultiGuardedSection
144: .create(document, getComponent()
145: .getComponentID()
146: + "-resumeMIDlet"); // NOI18N
147:
148: section
149: .getWriter()
150: .write(
151: "//<editor-fold defaultstate=\"collapsed\" desc=\" Generated Method: resumeMIDlet \">\n"); // NOI18N
152: section
153: .getWriter()
154: .write(
155: "/**\n * Performs an action assigned to the Mobile Device - MIDlet Resumed point.\n */\n"); // NOI18N
156: section.getWriter().write(
157: "public void resumeMIDlet () {\n"); // NOI18N
158:
159: CodeMultiGuardedLevelPresenter
160: .generateMultiGuardedSectionCode(
161: section, getComponent());
162:
163: assert section.isGuarded();
164: section.getWriter().write("}\n"); // NOI18N
165: section.getWriter().write("//</editor-fold>\n")
166: .commit(); // NOI18N
167:
168: section.close();
169: }
170: },
171: CodeNamePresenter.fixed("resumeMIDlet"), // NOI18N
172: // delete
173: DeletePresenter.createIndeliblePresenter(),
174: DeleteDependencyPresenter
175: .createDependentOnParentComponentPresenter()
176:
177: );
178: }
179:
180: }
|