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:
042: package org.netbeans.modules.uml.ui.swing.drawingarea;
043:
044: import org.netbeans.modules.uml.common.generics.ETPairT;
045: import org.netbeans.modules.uml.core.metamodel.core.foundation.IElement;
046: import org.netbeans.modules.uml.core.metamodel.core.foundation.INamedElement;
047: import org.netbeans.modules.uml.core.metamodel.core.foundation.INamespace;
048: import org.netbeans.modules.uml.core.metamodel.core.foundation.IPresentationElement;
049: import org.netbeans.modules.uml.core.metamodel.diagrams.ICoreRelationshipDiscovery;
050: import org.netbeans.modules.uml.core.metamodel.diagrams.IDelayedAction;
051: import org.netbeans.modules.uml.core.support.umlsupport.IStrings;
052: import org.netbeans.modules.uml.core.support.umlutils.ETList;
053: import org.netbeans.modules.uml.ui.products.ad.application.IMenuManager;
054: import org.netbeans.modules.uml.ui.support.archivesupport.IProductArchive;
055: import org.netbeans.modules.uml.ui.support.archivesupport.IProductArchiveElement;
056: import org.netbeans.modules.uml.ui.support.contextmenusupport.IProductContextMenu;
057: import org.netbeans.modules.uml.ui.support.contextmenusupport.IProductContextMenuItem;
058: import org.netbeans.modules.uml.ui.support.contextmenusupport.IProductContextMenuSorter;
059: import org.netbeans.modules.uml.ui.support.viewfactorysupport.ICompartment;
060: import org.netbeans.modules.uml.ui.support.viewfactorysupport.IETGraphObject;
061: import org.netbeans.modules.uml.ui.swing.trackbar.JTrackBar;
062: import com.tomsawyer.editor.TSEEdge;
063: import com.tomsawyer.editor.TSEEdgeLabel;
064: import com.tomsawyer.editor.TSEGraphWindow;
065: import com.tomsawyer.editor.TSENode;
066: import com.tomsawyer.editor.TSENodeLabel;
067: import com.tomsawyer.editor.export.TSEPrintSetup;
068: import com.tomsawyer.graph.TSGraphObject;
069:
070: //import com.tomsawyer.util.TSDList;
071:
072: public interface IDiagramEngine {
073: /**
074: * Tells the diagram engine that it should control the argument diagram
075: */
076: public void attach(IDrawingAreaControl pParentControl);
077:
078: /**
079: * Tells the diagram engine that it should release all references and prepare to be deleted
080: */
081: public void detach();
082:
083: /**
084: * This routine is called when the diagram needs to be saved to the IProductArchive
085: */
086: public void writeToArchive(IProductArchive pProductArchive,
087: IProductArchiveElement pParentElement);
088:
089: /**
090: * This routine is called when the diagram needs to be restored from the IProductArchive.
091: */
092: public void readFromArchive(IProductArchive pProductArchive,
093: IProductArchiveElement pParentElement);
094:
095: /**
096: * Returns the parent control for this diagram engine
097: */
098: public IDrawingAreaControl getDrawingArea();
099:
100: /**
101: * Returns the the namespace to use when elements are created on the diagram. Usually this is the same as the namespace of the diagram
102: */
103: public INamespace getNamespaceForCreatedElements();
104:
105: /**
106: * If the user wants to change the accelerator, here the routine where that
107: * should be done.
108: */
109: public void setQuickKeys(TSEGraphWindow pGraphEditor);
110:
111: /**
112: * Register for the accelerators that the drawing area may be interested in.
113: */
114: public void registerAccelerators();
115:
116: /**
117: * Called after a new diagram is initialized to setup our default layout settings.
118: */
119: public void setupLayoutSettings(boolean bNewDiagram);
120:
121: /**
122: * Revoke the accelerators.
123: */
124: public void revokeAccelerators();
125:
126: /**
127: * Handles the accelerator message coming from windows. bActive says that this drawing area is the active(or top) window, bWeHaveFocus means this drawing area has keyboard focus
128: */
129: public boolean onAccelerator(int nMsg, int wParam, int lParam,
130: boolean bActive, boolean bWeHaveFocus, int nKeyCode);
131:
132: /**
133: * This is the guy that should sort the drawing area context menus
134: */
135: public IProductContextMenuSorter getContextMenuSorter();
136:
137: /**
138: * Notifies the node that a context menu is about to be displayed
139: */
140: public void onContextMenu(IProductContextMenu pContextMenu,
141: int logicalX, int logicalY);
142:
143: public void onContextMenu(IMenuManager manager);
144:
145: /**
146: * Notifies the node that a context menu has been selected
147: */
148: public void onContextMenuHandleSelection(
149: IProductContextMenu pContextMenu,
150: IProductContextMenuItem pMenuItem);
151:
152: /**
153: * Set the menu button sensitivity and check state
154: */
155: public void setSensitivityAndCheck(
156: IProductContextMenu pContextMenu,
157: IProductContextMenuItem pMenuItem, int buttonKind);
158:
159: /**
160: * Returns the relationship discovery object that's appropriate for this diagram
161: */
162: public ICoreRelationshipDiscovery getRelationshipDiscovery();
163:
164: /**
165: * Puts the drawing area into a specific mode based on the sButtonID. sButtonID is a key in the PresentationTypes.etc file.
166: */
167: public boolean enterModeFromButton(String sButtonID);
168:
169: /**
170: * Allows the diagram engines the ability to change the element being dropped
171: */
172: public ETPairT<Boolean, IElement> processOnDropElement(
173: IElement pElementBeingDropped);
174:
175: /**
176: * Called after a new diagram is initialized
177: */
178: public void initializeNewDiagram();
179:
180: /**
181: * Called to determine if we need to initialize the trackbar
182: */
183: public JTrackBar initializeTrackBar();
184:
185: /**
186: * Layout is about to happen. Set bHandled to true to cancel normal handling
187: */
188: public boolean preDoLayout( /* LayoutKind */int nLayoutStyle);
189:
190: /**
191: * Layout has just happened
192: */
193: public void postDoLayout();
194:
195: /**
196: * Copy is about to happen. Set bHandled to true to cancel normal handling
197: */
198: public boolean preCopy();
199:
200: /**
201: * Copy has just happened
202: */
203: public void postCopy();
204:
205: /**
206: * Print is about to happen.
207: */
208: public void prePrint(TSEPrintSetup pPrintHelper);
209:
210: /**
211: * Print has happened
212: */
213: public void postPrint(TSEPrintSetup pPrintHelper);
214:
215: /**
216: * A deep sync broadcast was received and is about to happen. Set bHandled to true to cancel normal handling
217: */
218: public boolean preDeepSyncBroadcast(
219: ETList<IElement> pDeepSyncElements);
220:
221: /**
222: * A deep sync broadcast was received and responded to
223: */
224: public void postDeepSyncBroadcast(ETList<IElement> pDeepSyncElements);
225:
226: /**
227: * Called before pumping the messages
228: */
229: public void prePumpMessages();
230:
231: /**
232: * Called after pumping the messages
233: */
234: public void postPumpMessages();
235:
236: /**
237: * Called after an element has been added to the diagram
238: */
239: public void postAddObject(TSGraphObject pGraphObject);
240:
241: /**
242: * Called after an element has been added to the diagram, this routine specifically changes the dropped namespace or region as necessary
243: */
244: public void postAddObjectHandleContainment(IPresentationElement pPE);
245:
246: /**
247: * Allows the engine to handle a delayed action
248: */
249: public boolean handleDelayedAction(IDelayedAction pAction);
250:
251: /**
252: * Possibly convert any of the diagrams to model elements
253: */
254: public void convertDiagramsToElements(IElement[] pMEs,
255: IStrings pDiagramLocations);
256:
257: /**
258: * Called after elements have been droped onto the diagram
259: */
260: public void postOnDrop(ETList<IElement> pMEs,
261: boolean bAutoRouteEdges);
262:
263: /**
264: * Called before a COM interface for creating presentation elements is called.
265: */
266: public boolean preCreatePresentationElement(IElement pElement);
267:
268: /**
269: * Called to create a specific tool
270: */
271: //public void createTool( String sTool, TSTool pTool );
272: /**
273: * Puts the drawing area into a certain mouse mode
274: */
275: public void enterMode( /* DrawingToolKind */int nDrawingToolKind);
276:
277: /**
278: * Puts the drawing area into a certain mouse mode
279: */
280: public void enterMode2(String sMode, String sFullInitString,
281: String sTSViewString, String sGraphObjectObjectInitString);
282:
283: /**
284: * The user has entered VK_DELETE. Allows verification dialogs to be displayed
285: */
286: public boolean preHandleDeleteKey();
287:
288: /**
289: * Premove event from the drawing area
290: */
291: public void onPreMoveObjects(
292: ETList<IETGraphObject> affectedObjects, int dx, int dy);
293:
294: /**
295: * Delayed Postmove event from the drawing area
296: */
297: public void delayedPostMoveObjects(
298: ETList<IPresentationElement> pPEs, int nDeltaX, int nDeltaY);
299:
300: /**
301: * Preresize event from the drawing area
302: */
303: public boolean onPreResizeObjects(TSGraphObject graphObject);
304:
305: /**
306: * Postresize event from the drawing area
307: */
308: public boolean onPostResizeObjects(TSGraphObject graphObject);
309:
310: /**
311: * Fired before the control is scrolled and/or zoomed
312: */
313: public boolean onPreScrollZoom(double pageCenterX,
314: double pageCenterY, double zoomLevel);
315:
316: /**
317: * Fired after the control has been scrolled and/or zoomed
318: */
319: public boolean onPostScrollZoom();
320:
321: /**
322: * Fired before a cross diagram paste happens. This allows the diagram engine to enter into paste tool mode.
323: */
324: public boolean beginCrossDiagramPaste();
325:
326: /**
327: * Ask the user what to do about a name collision
328: */
329: public boolean questionUserAboutNameCollision(
330: ICompartment pCompartmentBeingEdited,
331: INamedElement pElement, String sProposedName,
332: ETList<INamedElement> pCollidingElements);
333:
334: /**
335: * Fired before the user is questioned about name collisions. bQuestionUser to FALSE to not ask the user.
336: */
337: public boolean preHandleNameCollision(
338: ICompartment pCompartmentBeingEdited,
339: INamedElement pElement, INamedElement pFirstCollidingElement);
340:
341: /**
342: * Reattaches the presentation element to the new model element
343: */
344: public void handlePresentationElementReattach(
345: ICompartment pCompartmentBeingEdited,
346: INamedElement pElement, INamedElement pFirstCollidingElement);
347:
348: /**
349: * Test if the user wants to delete the data behind the presenation.
350: *
351: * @return <code>true</code> if the user wants to delete the data associted
352: * with the presentation elements.
353: */
354: public DataVerificationResults verifyDataDeletion(
355: ETList<TSENode> selectedNodes,
356: ETList<TSEEdge> selectedEdges,
357: ETList<TSENodeLabel> selectedNodeLabels,
358: ETList<TSEEdgeLabel> selectedEdgeLabels);
359: }
|