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.support.viewfactorysupport;
043:
044: import java.awt.event.MouseEvent;
045: import java.util.List;
046:
047: import org.netbeans.modules.uml.core.metamodel.core.foundation.IElement;
048: import org.netbeans.modules.uml.core.metamodel.core.foundation.IPresentationElement;
049: import org.netbeans.modules.uml.core.support.umlsupport.IETPoint;
050: import org.netbeans.modules.uml.core.support.umlsupport.IETRect;
051: import org.netbeans.modules.uml.core.support.umlsupport.IETSize;
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.products.ad.application.action.ContextMenuActionClass;
055: import org.netbeans.modules.uml.ui.support.archivesupport.IProductArchive;
056: import org.netbeans.modules.uml.ui.support.archivesupport.IProductArchiveElement;
057: import org.netbeans.modules.uml.ui.support.contextmenusupport.IProductContextMenu;
058: import org.netbeans.modules.uml.ui.support.contextmenusupport.IProductContextMenuItem; //import com.tomsawyer.util.TSTransform;
059: import com.tomsawyer.editor.TSTransform;
060:
061: import java.awt.Color;
062: import java.awt.Font;
063:
064: public interface ICompartment {
065: public CompartmentResourceUser getCompartmentResourceUser();
066:
067: /** Used to specify that he compartment should expand to the end of the node. */
068: public final static int EXPAND_TO_NODE = -1;
069:
070: /**
071: * This is the name of the compartment used when storing and reading from the product archive
072: */
073: public String getCompartmentID();
074:
075: /**
076: * Notifies the compartment an event has been generated at the graph.
077: */
078: public long onGraphEvent( /* GraphEventKind */int nKind);
079:
080: /**
081: * Performs the actual drawing
082: */
083: public void draw(IDrawInfo pDrawInfo, IETRect BoundingRect);
084:
085: /**
086: * Fired when the context menu is about to be displayed
087: */
088: public long onContextMenu(IProductContextMenu pContextMenu,
089: int logicalX, int logicalY);
090:
091: public void onContextMenu(IMenuManager manager);
092:
093: /**
094: * Fired when a context menu has been selected
095: */
096: public long onContextMenuHandleSelection(
097: IProductContextMenu pContextMenu,
098: IProductContextMenuItem pMenuItem);
099:
100: /**
101: * Set the menu button sensitivity
102: */
103: public boolean setSensitivityAndCheck(
104: IProductContextMenu pContextMenu,
105: IProductContextMenuItem pMenuItem, int buttonKind);
106:
107: /**
108: * Should this compartment show its name
109: */
110: public boolean getShowName();
111:
112: /**
113: * Should this compartment show its name
114: */
115: public void setShowName(boolean value);
116:
117: /**
118: * The compartments name
119: */
120: public String getName();
121:
122: /**
123: * The compartments name
124: */
125: public void setName(String value);
126:
127: /**
128: * Determines if this compartment has anything to write to the presentation archive
129: */
130: public boolean hasOverride();
131:
132: /**
133: * Calculates the size of this compartment using the current font and name value. Set bAt100Pct to TRUE to return the 100% (unzoomed) size.
134: */
135: public IETSize calculateOptimumSize(IDrawInfo pDrawInfo,
136: boolean bAt100Pct);
137:
138: /**
139: * Gets the last calculated optimum size of this compartment.
140: */
141: public IETSize getOptimumSize(boolean bAt100Pct);
142:
143: /**
144: * Gets the current size of this compartment which is either the optimum size or a user defined size.
145: */
146: public IETSize getCurrentSize(boolean bAt100Pct);
147:
148: /**
149: * Gets the current size of this compartment which is either the optimum size or a user defined size on a specified Device.
150: */
151: public IETSize getCurrentSize(TSTransform transform,
152: boolean bAt100Pct);
153:
154: /**
155: * Sets the current size of this compartment.
156: */
157: public void setCurrentSize(IETSize pNewSize);
158:
159: /**
160: * Gets the last size used during drawing of this compartment.
161: */
162: public IETSize getVisibleSize(boolean bAt100Pct);
163:
164: /**
165: * Sets the absolute size used by the tranform operations.
166: */
167: public void setTransformSize(IETSize pNewSize);
168:
169: /**
170: * Sets the absolute size used by the tranform operations.
171: */
172: public void setTransformSize(int width, int height);
173:
174: /**
175: * Adds a model element to this compartment
176: */
177: public void addModelElement(IElement pElement, int nIndex);
178:
179: /**
180: * Sets the parent drawengine for this compartment
181: */
182: public void setEngine(IDrawEngine pEngine);
183:
184: /**
185: * Gets the parent drawengine for this compartment
186: */
187: public IDrawEngine getEngine();
188:
189: /**
190: * Creates a copy of this object.
191: */
192: public ICompartment clone(IDrawEngine pParentDrawEngine);
193:
194: /**
195: * Right mouse button down event
196: */
197: public boolean handleRightMouseButton(MouseEvent pEvent);
198:
199: /**
200: * Right mouse button down event
201: */
202: public boolean handleLeftMouseButton(MouseEvent pEvent);
203:
204: /**
205: * Right mouse button down event
206: */
207: public boolean handleLeftMouseButtonDoubleClick(MouseEvent pEvent);
208:
209: public boolean handleLeftMouseButtonPressed(MouseEvent pEvent);
210:
211: /**
212: * Gives each compartment an opportunity to set the mouse cursor
213: * In C++ we just passed the point (in win scaled owner coordinates) into the compartment.
214: * In Java we also need to pass in ISetCursorEvent in order to be able to set the cursor properly
215: */
216: public boolean handleSetCursor(IETPoint point, ISetCursorEvent event);
217:
218: /**
219: * Initializes the compartment resources
220: */
221: public void initResources();
222:
223: /**
224: * Determine the compartment's selected state
225: */
226: public boolean isSelected();
227:
228: /**
229: * Determine the compartment's selected state
230: */
231: public void setSelected(boolean value);
232:
233: /**
234: * Toggles the compartment's selected state
235: */
236: public void invertSelected();
237:
238: /**
239: * Sets the compartment's selected state
240: */
241: public boolean selectExtended(IETRect rect);
242:
243: /**
244: * This routine is called when the compartment needs to be saved to the IProductArchive
245: */
246: public IProductArchiveElement writeToArchive(
247: IProductArchive pProductArchive,
248: IProductArchiveElement pCompartmentElement);
249:
250: /**
251: * This routine is called when the compartment needs to be restored from the IProductArchive.
252: */
253: public void readFromArchive(IProductArchive pProductArchive,
254: IProductArchiveElement pCompartmentElement);
255:
256: /**
257: * Contained compartments and engines use their parent's resources.
258: */
259: public int getParentResource();
260:
261: /**
262: * Contained compartments and engines use their parent's resources.
263: */
264: public long setParentResource( /* long */int pParentResource);
265:
266: /**
267: * Does this compartment have a non-rectangular shape
268: */
269: public boolean getCompartmentHasNonRectangularShape();
270:
271: /**
272: * Returns the shape of this compartment
273: */
274: public ETList<IETPoint> getCompartmentShape();
275:
276: /**
277: * Returns the bounding rect for this compartment
278: */
279: public IETRect getBoundingRect();
280:
281: /**
282: * The TS logical bounding rectangle for this compartment
283: */
284: public IETRect getLogicalBoundingRect();
285:
286: /**
287: * Returns true when the input logical view point is within the bounds of the y upper and lower axis of the compartment
288: */
289: public boolean isPointInCompartmentYAxis(IETPoint pLogical);
290:
291: /**
292: * Returns true when the input logical view point is within the bounds of the compartment
293: */
294: public boolean isPointInCompartment(IETPoint pLogical);
295:
296: /**
297: * Returns true when the input logical view point is within the optimum size bounds of the compartment
298: */
299: public boolean isPointInOptimum(IETPoint pLogical);
300:
301: /**
302: * Returns the offset within the draw engine's rectangle for the compartment in logical coordinates
303: */
304: public IETPoint getLogicalOffsetInDrawEngineRect();
305:
306: /**
307: * Returns the offset within the draw engine's rectangle for the compartment in logical coordinates
308: */
309: public void setLogicalOffsetInDrawEngineRect(IETPoint value);
310:
311: /**
312: * true if this node is currently selected and resizeable.
313: */
314: public boolean isResizing();
315:
316: /**
317: * Called when a node is resized. nodeResizeOriginator is a TSENodeResizeOriginator
318: */
319: public long nodeResized(int nodeResizeOriginator);
320:
321: /**
322: * Moves the connector to the vertical location, in logical view coordinates
323: */
324: //public long moveConnector( TSDConnector pConnector, int nY, boolean bDoItNow, boolean bSetYOfAssociatedPiece );
325: /**
326: * Save the model element this compartment represents
327: */
328: public long saveModelElement();
329:
330: /**
331: * returns the model element associated with this compartment
332: */
333: public IElement getModelElement();
334:
335: /**
336: * returns the model element XMIID associated with this compartment
337: */
338: public String getModelElementXMIID();
339:
340: public void setModelElementXMIID(String newVal);
341:
342: /**
343: * Is this compartment visible.
344: */
345: public boolean getVisible();
346:
347: /**
348: * Is this compartment visible.
349: */
350: public void setVisible(boolean value);
351:
352: /**
353: * Enables or disables the compartments context menu.
354: */
355: public boolean getEnableContextMenu();
356:
357: /**
358: * Enables or disables the compartments context menu.
359: */
360: public void setEnableContextMenu(boolean value);
361:
362: /**
363: * Handle a keydown event
364: */
365: public boolean handleKeyDown(int KeyCode, int Shift);
366:
367: /**
368: * Handle a keydown event
369: */
370: public boolean handleCharTyped(char ch);
371:
372: /**
373: * Handle a keyup event
374: */
375: public boolean handleKeyUp(int KeyCode, int Shift);
376:
377: /**
378: * Handle dragging via the left mouse. Return FALSE if dragging is not to be continued.
379: */
380: public boolean handleLeftMouseBeginDrag(IETPoint pStartPos,
381: IETPoint pCurrentPos, boolean bCancel);
382:
383: /**
384: * Handle dragging via the left mouse. Return FALSE if dragging is not to be continued.
385: */
386: public boolean handleLeftMouseDrag(IETPoint pStartPos,
387: IETPoint pCurrentPos);
388:
389: /**
390: * Handle dropping via the left mouse.
391: */
392: public boolean handleLeftMouseDrop(IETPoint pCurrentPos,
393: List pElements, boolean bMoving);
394:
395: /**
396: * Is this compartment resizeable? (FALSE if height is fixed.)
397: */
398: public boolean isResizeable();
399:
400: /**
401: * Can this compartment be collapsed?
402: */
403: public boolean isCollapsible();
404:
405: /**
406: * Get/Set the collapsed state of the compartment
407: */
408: public boolean getCollapsed();
409:
410: /**
411: * Get/Set the collapsed state of the compartment
412: */
413: public void setCollapsed(boolean value);
414:
415: /**
416: * Place a specific type of decoration on the node at the specified location
417: */
418: public void addDecoration(String sDecorationType, IETPoint pLocation);
419:
420: /**
421: * Indicate to the draw engine that it is being stretched
422: */
423: public long stretch(IStretchContext pStretchContext);
424:
425: /**
426: * Restores the compartment size to its optimum size
427: */
428: public long clearStretch(IDrawInfo drawInfo);
429:
430: /**
431: * Allows this object to add tooltip data.
432: */
433: public long queryToolTipData(IToolTipData pToolTipData);
434:
435: /**
436: * Notifier that the model element has changed, if available the changed IFeature is passed along.
437: */
438: public long modelElementHasChanged(INotificationTargets pTargets);
439:
440: /**
441: * Notifier that the model element has been deleted, if available the changed IFeature is passed along.
442: */
443: public long modelElementDeleted(INotificationTargets pTargets);
444:
445: /**
446: * Re-reads the model element data
447: */
448: public void reattach(String sID);
449:
450: /**
451: * Is this compartment readonly?
452: */
453: public boolean getReadOnly();
454:
455: /**
456: * Is this compartment readonly?
457: */
458: public void setReadOnly(boolean value);
459:
460: /**
461: * Is this compartment valid (connected and in-synch with its model element)
462: */
463: public boolean validate(IElement pElement);
464:
465: /**
466: * Returns the compartment responsible for handling keyboard input when none other is selected.
467: */
468: public ICompartment getDefaultCompartment();
469:
470: /**
471: * Returns the desired size based on whether the scrollbar is visible.
472: */
473: public IETSize getDesiredSizeToFit();
474:
475: /**
476: * Lays out the compartment, and its elements
477: */
478: public long layout(IETRect pCompartmentInDE);
479:
480: /**
481: * Notification of a post load event.
482: */
483: public long postLoad();
484:
485: /**
486: * Invokes the in-place editor.
487: */
488: public long editCompartment(boolean bNew, int nKeyCode, int nShift,
489: int nPos);
490:
491: // /**
492: // * Allows you to directly change how this compartments text draws
493: // */
494: // public void setStyle( int value );
495:
496: /**
497: * Turns on and off text wrapping
498: */
499: public boolean getTextWrapping();
500:
501: /**
502: * Turns on and off text wrapping
503: */
504: public void setTextWrapping(boolean value);
505:
506: /**
507: * Turns on and off the horizontal centering of the text
508: */
509: public boolean getCenterText();
510:
511: /**
512: * Turns on and off the horizontal centering of the text
513: */
514: public void setCenterText(boolean value);
515:
516: /**
517: * Turns on and off the vertically centering of the text
518: */
519: public boolean getVerticallyCenterText();
520:
521: /**
522: * Turns on and off the vertically centering of the text
523: */
524: public void setVerticallyCenterText(boolean value);
525:
526: /**
527: * Retrieves the presentation elements graphically contained by this compartment.
528: */
529: public ETList<IPresentationElement> getContained();
530:
531: // public String getStaticText();
532:
533: // public void setName(String string);
534:
535: /**
536: * Returns the stereotype name for the model element
537: */
538: public String getStereotypeText(IElement pElement);
539:
540: /**
541: * Retreives the font definition to use when rendering the component.
542: */
543: public String getFontString();
544:
545: /**
546: * Set the font definition to use when rendering the component.
547: */
548: public void setFontString(String string);
549:
550: public ContextMenuActionClass createMenuAction(String text,
551: String menuID);
552:
553: /**
554: * Retrieves the actual font to use when compartment is rendered. The returned
555: * font will be based on the zoom level.
556: *
557: * @param zoomLevel The zoom that is used to determine the size of the font.
558: * @return The font.
559: */
560: public Font getCompartmentFont(double zoomLevel);
561:
562: /**
563: * Retrieves the color of the font to use when rendering the compartment.
564: */
565: public Color getCompartmentFontColor();
566:
567: }
|