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.bpel.mapper.palette;
042:
043: import java.util.Date;
044: import javax.swing.Icon;
045:
046: import org.netbeans.modules.xml.xpath.ext.CoreFunctionType;
047: import org.netbeans.modules.xml.xpath.ext.CoreOperationType;
048:
049: import org.netbeans.modules.soa.mappercore.Mapper;
050: import org.netbeans.modules.soa.mappercore.model.GraphSubset;
051: import org.netbeans.modules.soa.mappercore.model.Vertex;
052: import org.netbeans.modules.xml.xpath.ext.metadata.ExtFunctionMetadata;
053: import org.netbeans.modules.bpel.editors.api.utils.DurationDialog;
054: import org.netbeans.modules.bpel.mapper.model.BpelMapperModel;
055: import org.netbeans.modules.bpel.mapper.model.ItemHandler;
056: import org.netbeans.modules.bpel.mapper.model.VertexFactory;
057: import static org.netbeans.modules.soa.ui.util.UI.*;
058:
059: /**
060: * @author Vladimir Yaroslavskiy
061: * @version 2007.11.27
062: */
063: class Handler implements ItemHandler {
064:
065: Handler(CoreFunctionType type) {
066: this (type.getMetadata().getDisplayName(), type.getMetadata()
067: .getIcon(), type);
068: }
069:
070: Handler(CoreOperationType type) {
071: this (type.getMetadata().getDisplayName(), type.getMetadata()
072: .getIcon(), type);
073: }
074:
075: Handler(String string) {
076: this (i18n(Handler.class, "LBL_String_Literal"), // NOI18N
077: icon(Handler.class, "string"), // NOI18N
078: string);
079: }
080:
081: Handler(Number number) {
082: this (i18n(Handler.class, "LBL_Numeric_Literal"), // NOI18N
083: icon(Handler.class, "numeric"), // NOI18N
084: number);
085: }
086:
087: Handler(ExtFunctionMetadata data) {
088: this (data.getDisplayName(), data.getIcon(), data);
089: }
090:
091: protected Handler(String name, Icon icon, Object object) {
092: myName = name;
093: myIcon = icon;
094: myObject = object;
095: }
096:
097: public Icon getIcon() {
098: return myIcon;
099: }
100:
101: public String getDisplayName() {
102: return myName;
103: }
104:
105: public boolean canAddGraphSubset() {
106: return true;
107: }
108:
109: public GraphSubset createGraphSubset() {
110: return VertexFactory.getInstance().createGraphSubset(myObject);
111: }
112:
113: protected void setObject(Object object) {
114: myObject = object;
115: }
116:
117: // ------------------------------------
118: static class Duration extends Handler {
119: Duration() {
120: super (i18n(Handler.class, "LBL_Duration_Literal"), // NOI18N
121: icon(Handler.class, "duration"), ""); // NOI18N
122: }
123:
124: @Override
125: public boolean canAddGraphSubset() {
126: DurationDialog dialog = new DurationDialog();
127: dialog.setVisible(true);
128: Object duration = dialog.getDuration();
129:
130: if (duration != null) {
131: setObject(duration);
132: }
133: //out("DURATION: " + duration);
134: return duration != null;
135: }
136: }
137:
138: private Icon myIcon;
139: private String myName;
140: private Object myObject;
141: }
|