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-2007 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.api.visual.action;
042:
043: import org.netbeans.api.visual.widget.ConnectionWidget;
044: import org.netbeans.api.visual.widget.Widget;
045: import org.netbeans.api.visual.widget.Scene;
046:
047: import java.awt.*;
048:
049: /**
050: * This interface controls a reconnect action.
051: *
052: * @author David Kaspar
053: */
054: public interface ReconnectProvider {
055:
056: /**
057: * Called for checking whether it is possible to reconnection a source of a specified connection widget.
058: * @param connectionWidget the connection widget
059: * @return if true, then it is possible to reconnection the source; if false, then is not allowed
060: */
061: boolean isSourceReconnectable(ConnectionWidget connectionWidget);
062:
063: /**
064: * Called for checking whether it is possible to reconnection a target of a specified connection widget.
065: * @param connectionWidget the connection widget
066: * @return if true, then it is possible to reconnection the target; if false, then is not allowed
067: */
068: boolean isTargetReconnectable(ConnectionWidget connectionWidget);
069:
070: /**
071: * Called to notify about the start of reconnecting.
072: * @param connectionWidget the connection widget
073: * @param reconnectingSource if true, then source is being reconnected; if false, then target is being reconnected
074: */
075: void reconnectingStarted(ConnectionWidget connectionWidget,
076: boolean reconnectingSource);
077:
078: /**
079: * Called to notify about the finish of reconnecting.
080: * @param connectionWidget the connection widget
081: * @param reconnectingSource if true, then source is being reconnected; if false, then target is being reconnected
082: */
083: void reconnectingFinished(ConnectionWidget connectionWidget,
084: boolean reconnectingSource);
085:
086: /**
087: * Called to check for possible replacement of a connection source/target.
088: * Called only when the hasCustomReplacementWidgetResolver method return false.
089: * @param connectionWidget the connection widget
090: * @param replacementWidget the replacement widget
091: * @param reconnectingSource if true, then source is being reconnected; if false, then target is being reconnected
092: */
093: ConnectorState isReplacementWidget(
094: ConnectionWidget connectionWidget,
095: Widget replacementWidget, boolean reconnectingSource);
096:
097: /**
098: * Called to check whether the provider has a custom replacement widget resolver.
099: * @param scene the scene where the resolver will be called
100: * @return if true, then the resolveReplacementWidget method is called for resolving the replacement widget;
101: * if false, then the isReplacementWidget method is called for resolving the replacement widget
102: */
103: boolean hasCustomReplacementWidgetResolver(Scene scene);
104:
105: /**
106: * Called to find the replacement widget of a possible connection.
107: * Called only when a hasCustomReplacementWidgetResolver returns true.
108: * @param scene the scene
109: * @param sceneLocation the scene location
110: * @return the replacement widget; null if no replacement widget found
111: */
112: Widget resolveReplacementWidget(Scene scene, Point sceneLocation);
113:
114: /**
115: * Called for replacing a source/target with a new one.
116: * This method is called only when the possible replacement is found and an user approves it.
117: * @param connectionWidget the connection widget
118: * @param replacementWidget the replacement widget
119: * @param reconnectingSource if true, then source is being reconnected; if false, then target is being reconnected
120: */
121: void reconnect(ConnectionWidget connectionWidget,
122: Widget replacementWidget, boolean reconnectingSource);
123:
124: }
|