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.handlers;
043:
044: import org.netbeans.modules.vmd.api.codegen.CodeMultiGuardedLevelPresenter;
045: import org.netbeans.modules.vmd.api.codegen.MultiGuardedSection;
046: import org.netbeans.modules.vmd.api.model.*;
047: import org.netbeans.modules.vmd.api.model.presenters.InfoPresenter;
048: import org.netbeans.modules.vmd.midp.components.MidpVersionDescriptor;
049: import org.netbeans.modules.vmd.midp.components.handlers.EventHandlerCD;
050: import org.netbeans.modules.vmd.midp.flow.FlowEventHandlerPinBadgePresenter;
051: import org.netbeans.modules.vmd.midpnb.codegen.MidpCustomCodePresenterSupport;
052: import org.openide.util.Utilities;
053: import java.util.Arrays;
054: import java.util.List;
055: import org.openide.util.NbBundle;
056:
057: /**
058: *
059: * @author Anton Chechel
060: */
061: public class SVGMenuEventHandlerCD extends ComponentDescriptor {
062:
063: public static final TypeID TYPEID = new TypeID(
064: TypeID.Kind.COMPONENT, "#SVGMenuEventHandler"); // NOI18N
065:
066: public static final String ICON_PATH = "org/netbeans/modules/vmd/midpnb/resources/svg_menu_action_16.png"; // NOI18N
067: public static final String LARGE_ICON_PATH = "org/netbeans/modules/vmd/midpnb/resources/svg_menu_action_32.png"; // NOI18N
068:
069: public TypeDescriptor getTypeDescriptor() {
070: return new TypeDescriptor(EventHandlerCD.TYPEID, TYPEID, true,
071: false);
072: }
073:
074: public VersionDescriptor getVersionDescriptor() {
075: return MidpVersionDescriptor.MIDP_2;
076: }
077:
078: public List<PropertyDescriptor> getDeclaredPropertyDescriptors() {
079: return null;
080: }
081:
082: protected List<? extends Presenter> createPresenters() {
083: return Arrays.asList(
084: // info
085: InfoPresenter.createStatic(NbBundle.getMessage(
086: SVGMenuEventHandlerCD.class,
087: "DISP_Process_SVG_Menu"), NbBundle.getMessage(
088: SVGMenuEventHandlerCD.class, "TYPE_Action"),
089: ICON_PATH), // NOI18N
090: // flow
091: new FlowEventHandlerPinBadgePresenter(Utilities
092: .loadImage(ICON_PATH), 0) {
093: @Override
094: protected DesignEventFilter getEventFilter() {
095: return super .getEventFilter().addParentFilter(
096: getComponent(), 2, false);
097: }
098: },
099: // code
100: new CodeMultiGuardedLevelPresenter() {
101: protected void generateMultiGuardedSectionCode(
102: MultiGuardedSection section) {
103: DesignComponent eventHandler = getComponent();
104:
105: DesignComponent commandEventSource = eventHandler
106: .getParentComponent();
107: if (commandEventSource == null)
108: return;
109:
110: DesignComponent menu = commandEventSource
111: .getParentComponent();
112: String code = MidpCustomCodePresenterSupport
113: .getSVGMenuActionMethodAccessCode(menu);
114: if (code != null)
115: section.getWriter().write(code + " ();\n"); // NOI18N
116: }
117: }
118:
119: );
120: }
121:
122: }
|