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.api.flow.visual;
042:
043: import org.netbeans.api.visual.action.WidgetAction;
044: import org.netbeans.modules.vmd.api.model.DesignComponent;
045:
046: import java.awt.datatransfer.Transferable;
047: import java.util.List;
048:
049: /**
050: * @author David Kaspar
051: */
052: public abstract class FlowDescriptor {
053:
054: private DesignComponent representedComponent;
055: private String descriptorID;
056:
057: protected FlowDescriptor(DesignComponent representedComponent,
058: String descriptorID) {
059: assert representedComponent != null && descriptorID != null;
060: this .representedComponent = representedComponent;
061: this .descriptorID = descriptorID;
062: }
063:
064: public final DesignComponent getRepresentedComponent() {
065: return representedComponent;
066: }
067:
068: public final String getDescriptorID() {
069: return descriptorID;
070: }
071:
072: @Override
073: public final boolean equals(Object o) {
074: if (this == o)
075: return true;
076: if (o == null || getClass() != o.getClass())
077: return false;
078: FlowDescriptor desc = (FlowDescriptor) o;
079: return representedComponent == desc.representedComponent
080: && descriptorID.equals(desc.descriptorID);
081: }
082:
083: @Override
084: public final int hashCode() {
085: return 29 * representedComponent.hashCode()
086: + descriptorID.hashCode();
087: }
088:
089: @Override
090: public String toString() {
091: return getClass().getSimpleName() + ":"
092: + representedComponent.getComponentID() + ":"
093: + descriptorID; // NOI18N
094: }
095:
096: public interface Decorator {
097:
098: }
099:
100: public interface Behaviour {
101:
102: }
103:
104: public interface BadgeDecorator extends Decorator {
105:
106: void updateBadges(FlowDescriptor descriptor, FlowScene scene,
107: List<FlowBadgeDescriptor> badges);
108:
109: }
110:
111: public interface AcceptActionBehaviour extends Behaviour {
112:
113: boolean isAcceptable(FlowDescriptor descriptor,
114: Transferable transferable);
115:
116: void accept(FlowDescriptor descriptor, Transferable transferable);
117:
118: }
119:
120: public interface SelectActionBehaviour extends Behaviour {
121:
122: boolean select(FlowDescriptor descriptor, int modifiers);
123:
124: }
125:
126: public interface RenameActionBehaviour extends Behaviour {
127:
128: boolean isEditable(FlowDescriptor descriptor);
129:
130: String getText(FlowDescriptor descriptor);
131:
132: void setText(FlowDescriptor descriptor, String text);
133:
134: }
135:
136: public interface EditActionBehaviour extends Behaviour {
137:
138: void edit(FlowDescriptor descriptor);
139:
140: }
141:
142: // HINT - FlowDescriptor.KeyActionBehaviour is used for FlowScene/rootComponent only
143: public interface KeyActionBehaviour extends Behaviour {
144:
145: boolean keyPressed(WidgetAction.WidgetKeyEvent e);
146:
147: }
148:
149: }
|