| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
|
| 13 | |
|
| 14 | |
|
| 15 | |
|
| 16 | |
|
| 17 | |
|
| 18 | |
|
| 19 | |
|
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | |
|
| 28 | |
|
| 29 | |
|
| 30 | |
|
| 31 | |
|
| 32 | |
|
| 33 | |
|
| 34 | |
|
| 35 | |
|
| 36 | |
|
| 37 | |
|
| 38 | |
|
| 39 | |
|
| 40 | |
|
| 41 | |
package org.argouml.uml.diagram.ui; |
| 42 | |
|
| 43 | |
import java.awt.Dimension; |
| 44 | |
import java.awt.Font; |
| 45 | |
import java.awt.Graphics; |
| 46 | |
import java.awt.Image; |
| 47 | |
import java.awt.Rectangle; |
| 48 | |
import java.awt.event.InputEvent; |
| 49 | |
import java.awt.event.KeyEvent; |
| 50 | |
import java.awt.event.KeyListener; |
| 51 | |
import java.awt.event.MouseEvent; |
| 52 | |
import java.awt.event.MouseListener; |
| 53 | |
import java.beans.PropertyChangeEvent; |
| 54 | |
import java.beans.PropertyChangeListener; |
| 55 | |
import java.beans.PropertyVetoException; |
| 56 | |
import java.beans.VetoableChangeListener; |
| 57 | |
import java.util.ArrayList; |
| 58 | |
import java.util.Collection; |
| 59 | |
import java.util.HashSet; |
| 60 | |
import java.util.Iterator; |
| 61 | |
import java.util.List; |
| 62 | |
import java.util.Set; |
| 63 | |
import java.util.Vector; |
| 64 | |
|
| 65 | |
import javax.swing.Action; |
| 66 | |
import javax.swing.Icon; |
| 67 | |
import javax.swing.JMenu; |
| 68 | |
import javax.swing.JSeparator; |
| 69 | |
import javax.swing.SwingUtilities; |
| 70 | |
|
| 71 | |
import org.apache.log4j.Logger; |
| 72 | |
import org.argouml.application.events.ArgoDiagramAppearanceEvent; |
| 73 | |
import org.argouml.application.events.ArgoDiagramAppearanceEventListener; |
| 74 | |
import org.argouml.application.events.ArgoEventPump; |
| 75 | |
import org.argouml.application.events.ArgoEventTypes; |
| 76 | |
import org.argouml.application.events.ArgoHelpEvent; |
| 77 | |
import org.argouml.application.events.ArgoNotationEvent; |
| 78 | |
import org.argouml.application.events.ArgoNotationEventListener; |
| 79 | |
import org.argouml.cognitive.Designer; |
| 80 | |
import org.argouml.cognitive.Highlightable; |
| 81 | |
import org.argouml.cognitive.ToDoItem; |
| 82 | |
import org.argouml.cognitive.ToDoList; |
| 83 | |
import org.argouml.cognitive.ui.ActionGoToCritique; |
| 84 | |
import org.argouml.i18n.Translator; |
| 85 | |
import org.argouml.kernel.DelayedChangeNotify; |
| 86 | |
import org.argouml.kernel.DelayedVChangeListener; |
| 87 | |
import org.argouml.kernel.Owned; |
| 88 | |
import org.argouml.kernel.Project; |
| 89 | |
import org.argouml.model.AssociationChangeEvent; |
| 90 | |
import org.argouml.model.AttributeChangeEvent; |
| 91 | |
import org.argouml.model.DeleteInstanceEvent; |
| 92 | |
import org.argouml.model.DiElement; |
| 93 | |
import org.argouml.model.InvalidElementException; |
| 94 | |
import org.argouml.model.Model; |
| 95 | |
import org.argouml.model.UmlChangeEvent; |
| 96 | |
import org.argouml.notation.Notation; |
| 97 | |
import org.argouml.notation.NotationName; |
| 98 | |
import org.argouml.notation.NotationProvider; |
| 99 | |
import org.argouml.notation.NotationProviderFactory2; |
| 100 | |
import org.argouml.notation.NotationRenderer; |
| 101 | |
import org.argouml.notation.NotationSettings; |
| 102 | |
import org.argouml.profile.FigNodeStrategy; |
| 103 | |
import org.argouml.ui.ArgoJMenu; |
| 104 | |
import org.argouml.ui.Clarifier; |
| 105 | |
import org.argouml.ui.ContextActionFactoryManager; |
| 106 | |
import org.argouml.ui.ProjectActions; |
| 107 | |
import org.argouml.ui.UndoableAction; |
| 108 | |
import org.argouml.ui.targetmanager.TargetManager; |
| 109 | |
import org.argouml.uml.StereotypeUtility; |
| 110 | |
import org.argouml.uml.diagram.ArgoDiagram; |
| 111 | |
import org.argouml.uml.diagram.DiagramAppearance; |
| 112 | |
import org.argouml.uml.diagram.DiagramElement; |
| 113 | |
import org.argouml.uml.diagram.DiagramSettings; |
| 114 | |
import org.argouml.uml.diagram.DiagramSettings.StereotypeStyle; |
| 115 | |
import org.argouml.uml.diagram.PathContainer; |
| 116 | |
import org.argouml.uml.ui.ActionDeleteModelElements; |
| 117 | |
import org.argouml.util.IItemUID; |
| 118 | |
import org.argouml.util.ItemUID; |
| 119 | |
import org.tigris.gef.base.Diagram; |
| 120 | |
import org.tigris.gef.base.Globals; |
| 121 | |
import org.tigris.gef.base.Layer; |
| 122 | |
import org.tigris.gef.base.LayerPerspective; |
| 123 | |
import org.tigris.gef.base.Selection; |
| 124 | |
import org.tigris.gef.graph.MutableGraphSupport; |
| 125 | |
import org.tigris.gef.presentation.Fig; |
| 126 | |
import org.tigris.gef.presentation.FigGroup; |
| 127 | |
import org.tigris.gef.presentation.FigImage; |
| 128 | |
import org.tigris.gef.presentation.FigNode; |
| 129 | |
import org.tigris.gef.presentation.FigRect; |
| 130 | |
import org.tigris.gef.presentation.FigText; |
| 131 | |
|
| 132 | |
|
| 133 | |
|
| 134 | |
|
| 135 | |
|
| 136 | |
|
| 137 | |
|
| 138 | |
|
| 139 | |
|
| 140 | |
|
| 141 | |
|
| 142 | |
|
| 143 | 119 | public abstract class FigNodeModelElement |
| 144 | |
extends FigNode |
| 145 | |
implements |
| 146 | |
VetoableChangeListener, |
| 147 | |
DelayedVChangeListener, |
| 148 | |
MouseListener, |
| 149 | |
KeyListener, |
| 150 | |
PropertyChangeListener, |
| 151 | |
PathContainer, |
| 152 | |
ArgoDiagramAppearanceEventListener, |
| 153 | |
ArgoNotationEventListener, |
| 154 | |
NotationRenderer, |
| 155 | |
Highlightable, |
| 156 | |
IItemUID, |
| 157 | |
Clarifiable, |
| 158 | |
ArgoFig, |
| 159 | |
StereotypeStyled, |
| 160 | |
DiagramElement, |
| 161 | |
Owned { |
| 162 | |
|
| 163 | |
|
| 164 | 119 | private static final Logger LOG = |
| 165 | |
Logger.getLogger(FigNodeModelElement.class); |
| 166 | |
|
| 167 | |
|
| 168 | |
|
| 169 | |
|
| 170 | |
|
| 171 | |
|
| 172 | |
|
| 173 | |
|
| 174 | |
|
| 175 | |
|
| 176 | |
|
| 177 | |
|
| 178 | |
protected static final int WIDTH = 64; |
| 179 | |
|
| 180 | |
|
| 181 | |
|
| 182 | |
|
| 183 | |
|
| 184 | |
|
| 185 | |
|
| 186 | |
|
| 187 | |
protected static final int NAME_FIG_HEIGHT = 21; |
| 188 | |
|
| 189 | |
|
| 190 | |
|
| 191 | |
|
| 192 | |
protected static final int NAME_V_PADDING = 2; |
| 193 | |
|
| 194 | |
private DiElement diElement; |
| 195 | |
|
| 196 | |
private NotationProvider notationProviderName; |
| 197 | |
|
| 198 | |
|
| 199 | |
|
| 200 | |
|
| 201 | |
|
| 202 | |
|
| 203 | |
|
| 204 | 1071 | protected boolean invisibleAllowed = false; |
| 205 | |
|
| 206 | |
|
| 207 | |
|
| 208 | |
|
| 209 | |
|
| 210 | 1071 | private boolean checkSize = true; |
| 211 | |
|
| 212 | |
|
| 213 | |
|
| 214 | |
|
| 215 | |
|
| 216 | |
|
| 217 | |
private static int popupAddOffset; |
| 218 | |
|
| 219 | |
|
| 220 | |
|
| 221 | |
|
| 222 | |
protected static final int ROOT = 1; |
| 223 | |
|
| 224 | |
|
| 225 | |
|
| 226 | |
|
| 227 | |
protected static final int ABSTRACT = 2; |
| 228 | |
|
| 229 | |
|
| 230 | |
|
| 231 | |
|
| 232 | |
protected static final int LEAF = 4; |
| 233 | |
|
| 234 | |
|
| 235 | |
|
| 236 | |
|
| 237 | |
protected static final int ACTIVE = 8; |
| 238 | |
|
| 239 | |
private Fig bigPort; |
| 240 | |
|
| 241 | |
|
| 242 | |
|
| 243 | |
|
| 244 | |
|
| 245 | |
private FigText nameFig; |
| 246 | |
|
| 247 | |
|
| 248 | |
|
| 249 | |
|
| 250 | |
|
| 251 | |
|
| 252 | |
|
| 253 | |
private FigStereotypesGroup stereotypeFig; |
| 254 | |
|
| 255 | |
|
| 256 | |
|
| 257 | |
|
| 258 | |
private FigProfileIcon stereotypeFigProfileIcon; |
| 259 | |
|
| 260 | |
|
| 261 | |
|
| 262 | |
|
| 263 | |
|
| 264 | 1071 | private List<Fig> floatingStereotypes = new ArrayList<Fig>(); |
| 265 | |
|
| 266 | |
|
| 267 | |
|
| 268 | |
|
| 269 | |
|
| 270 | |
|
| 271 | |
|
| 272 | |
|
| 273 | 1071 | private DiagramSettings.StereotypeStyle stereotypeStyle = |
| 274 | |
DiagramSettings.StereotypeStyle.TEXTUAL; |
| 275 | |
|
| 276 | |
|
| 277 | |
|
| 278 | |
|
| 279 | |
|
| 280 | |
|
| 281 | |
|
| 282 | |
private static final int ICON_WIDTH = 16; |
| 283 | |
|
| 284 | |
|
| 285 | |
|
| 286 | |
|
| 287 | |
|
| 288 | |
|
| 289 | |
|
| 290 | |
|
| 291 | |
private FigText originalNameFig; |
| 292 | |
|
| 293 | |
|
| 294 | |
|
| 295 | |
|
| 296 | |
|
| 297 | |
|
| 298 | |
|
| 299 | |
|
| 300 | 1071 | private Vector<Fig> enclosedFigs = new Vector<Fig>(); |
| 301 | |
|
| 302 | |
|
| 303 | |
|
| 304 | |
|
| 305 | |
private Fig encloser; |
| 306 | |
|
| 307 | |
|
| 308 | 1071 | private boolean readyToEdit = true; |
| 309 | |
|
| 310 | |
private boolean suppressCalcBounds; |
| 311 | |
private static boolean showBoldName; |
| 312 | |
|
| 313 | |
private ItemUID itemUid; |
| 314 | |
|
| 315 | |
|
| 316 | |
|
| 317 | |
|
| 318 | |
|
| 319 | 1071 | private boolean removeFromDiagram = true; |
| 320 | |
|
| 321 | |
|
| 322 | |
|
| 323 | |
|
| 324 | |
|
| 325 | 1071 | private boolean editable = true; |
| 326 | |
|
| 327 | |
|
| 328 | 1071 | private Set<Object[]> listeners = new HashSet<Object[]>(); |
| 329 | |
|
| 330 | |
|
| 331 | |
|
| 332 | |
|
| 333 | |
private DiagramSettings settings; |
| 334 | |
|
| 335 | |
|
| 336 | |
|
| 337 | |
|
| 338 | |
|
| 339 | |
private NotationSettings notationSettings; |
| 340 | |
|
| 341 | |
|
| 342 | |
|
| 343 | |
|
| 344 | |
|
| 345 | |
private void constructFigs() { |
| 346 | |
|
| 347 | 1071 | nameFig.setFilled(true); |
| 348 | 1071 | nameFig.setText(placeString()); |
| 349 | 1071 | nameFig.setBotMargin(7); |
| 350 | 1071 | nameFig.setRightMargin(4); |
| 351 | 1071 | nameFig.setLeftMargin(4); |
| 352 | |
|
| 353 | 1071 | readyToEdit = false; |
| 354 | |
|
| 355 | 1071 | setShadowSize(getSettings().getDefaultShadowWidth()); |
| 356 | |
|
| 357 | |
|
| 358 | |
|
| 359 | 1071 | stereotypeStyle = getSettings().getDefaultStereotypeView(); |
| 360 | 1071 | } |
| 361 | |
|
| 362 | |
|
| 363 | |
|
| 364 | |
|
| 365 | |
|
| 366 | |
|
| 367 | |
|
| 368 | |
|
| 369 | |
|
| 370 | |
|
| 371 | |
|
| 372 | |
|
| 373 | |
|
| 374 | |
protected FigNodeModelElement(Object element, Rectangle bounds, |
| 375 | |
DiagramSettings renderSettings) { |
| 376 | 1071 | super(); |
| 377 | 1071 | super.setOwner(element); |
| 378 | |
|
| 379 | |
|
| 380 | |
|
| 381 | |
|
| 382 | 1071 | settings = renderSettings; |
| 383 | |
|
| 384 | |
|
| 385 | |
|
| 386 | |
|
| 387 | 1071 | super.setFillColor(FILL_COLOR); |
| 388 | 1071 | super.setLineColor(LINE_COLOR); |
| 389 | 1071 | super.setLineWidth(LINE_WIDTH); |
| 390 | 1071 | super.setTextColor(TEXT_COLOR); |
| 391 | |
|
| 392 | |
|
| 393 | |
|
| 394 | |
|
| 395 | |
|
| 396 | |
|
| 397 | |
|
| 398 | 1071 | notationSettings = new NotationSettings(settings.getNotationSettings()); |
| 399 | |
|
| 400 | |
|
| 401 | |
|
| 402 | 1071 | bigPort = createBigPortFig(); |
| 403 | 1071 | nameFig = new FigNameWithAbstractAndBold(element, |
| 404 | |
new Rectangle(X0, Y0, WIDTH, NAME_FIG_HEIGHT), getSettings(), true); |
| 405 | 1071 | stereotypeFig = createStereotypeFig(); |
| 406 | 1071 | constructFigs(); |
| 407 | |
|
| 408 | |
|
| 409 | |
|
| 410 | |
|
| 411 | |
|
| 412 | |
|
| 413 | 1071 | if (element != null && !Model.getFacade().isAUMLElement(element)) { |
| 414 | 0 | throw new IllegalArgumentException( |
| 415 | |
"The owner must be a model element - got a " |
| 416 | |
+ element.getClass().getName()); |
| 417 | |
} |
| 418 | |
|
| 419 | 1071 | nameFig.setText(placeString()); |
| 420 | |
|
| 421 | 1071 | if (element != null) { |
| 422 | 0 | NotationName nn = Notation.findNotation(notationSettings.getNotationLanguage()); |
| 423 | 0 | notationProviderName = |
| 424 | |
NotationProviderFactory2.getInstance().getNotationProvider( |
| 425 | |
getNotationProviderType(), element, this, nn); |
| 426 | |
|
| 427 | |
|
| 428 | |
|
| 429 | |
|
| 430 | 0 | bindPort(element, bigPort); |
| 431 | |
|
| 432 | |
|
| 433 | 0 | addElementListener(element); |
| 434 | |
} |
| 435 | |
|
| 436 | 1071 | if (bounds != null) { |
| 437 | 0 | setLocation(bounds.x, bounds.y); |
| 438 | |
} |
| 439 | |
|
| 440 | |
|
| 441 | |
|
| 442 | |
|
| 443 | |
|
| 444 | |
|
| 445 | |
|
| 446 | |
|
| 447 | |
|
| 448 | |
|
| 449 | |
|
| 450 | 1071 | readyToEdit = true; |
| 451 | 1071 | } |
| 452 | |
|
| 453 | |
|
| 454 | |
|
| 455 | |
|
| 456 | |
|
| 457 | |
|
| 458 | |
protected Fig createBigPortFig() { |
| 459 | 1071 | return new FigRect(X0, Y0, 0, 0, DEBUG_COLOR, DEBUG_COLOR); |
| 460 | |
} |
| 461 | |
|
| 462 | |
protected FigStereotypesGroup createStereotypeFig() { |
| 463 | 0 | return new FigStereotypesGroup(getOwner(), |
| 464 | |
new Rectangle(X0, Y0, WIDTH, STEREOHEIGHT), settings); |
| 465 | |
} |
| 466 | |
|
| 467 | |
|
| 468 | |
|
| 469 | |
|
| 470 | |
|
| 471 | |
|
| 472 | |
|
| 473 | |
|
| 474 | |
|
| 475 | |
|
| 476 | |
@Override |
| 477 | |
public void setLayer(Layer lay) { |
| 478 | 0 | super.setLayer(lay); |
| 479 | 0 | determineDefaultPathVisible(); |
| 480 | 0 | } |
| 481 | |
|
| 482 | |
|
| 483 | |
|
| 484 | |
|
| 485 | |
|
| 486 | |
|
| 487 | |
|
| 488 | |
|
| 489 | |
|
| 490 | |
|
| 491 | |
|
| 492 | |
@Override |
| 493 | |
public Object clone() { |
| 494 | 0 | final FigNodeModelElement clone = (FigNodeModelElement) super.clone(); |
| 495 | |
|
| 496 | 0 | final Iterator cloneIter = clone.getFigs().iterator(); |
| 497 | 0 | for (Object thisFig : getFigs()) { |
| 498 | 0 | final Fig cloneFig = (Fig) cloneIter.next(); |
| 499 | 0 | if (thisFig == getBigPort()) { |
| 500 | 0 | clone.setBigPort(cloneFig); |
| 501 | |
} |
| 502 | 0 | if (thisFig == nameFig) { |
| 503 | 0 | clone.nameFig = (FigSingleLineText) thisFig; |
| 504 | |
|
| 505 | |
|
| 506 | |
|
| 507 | |
|
| 508 | |
|
| 509 | |
|
| 510 | |
|
| 511 | |
} |
| 512 | 0 | if (thisFig == getStereotypeFig()) { |
| 513 | 0 | clone.stereotypeFig = (FigStereotypesGroup) thisFig; |
| 514 | |
|
| 515 | |
|
| 516 | |
} |
| 517 | 0 | } |
| 518 | 0 | return clone; |
| 519 | |
} |
| 520 | |
|
| 521 | |
|
| 522 | |
|
| 523 | |
|
| 524 | |
|
| 525 | |
|
| 526 | |
|
| 527 | |
public String placeString() { |
| 528 | 2142 | if (Model.getFacade().isAModelElement(getOwner())) { |
| 529 | 0 | String placeString = Model.getFacade().getName(getOwner()); |
| 530 | 0 | if (placeString == null) { |
| 531 | 0 | placeString = |
| 532 | |
|
| 533 | |
"new " + Model.getFacade().getUMLClassName(getOwner()); |
| 534 | |
} |
| 535 | 0 | return placeString; |
| 536 | |
} |
| 537 | 2142 | return ""; |
| 538 | |
} |
| 539 | |
|
| 540 | |
|
| 541 | |
|
| 542 | |
|
| 543 | |
public void setItemUID(ItemUID id) { |
| 544 | 0 | itemUid = id; |
| 545 | 0 | } |
| 546 | |
|
| 547 | |
|
| 548 | |
|
| 549 | |
|
| 550 | |
public ItemUID getItemUID() { |
| 551 | 0 | return itemUid; |
| 552 | |
} |
| 553 | |
|
| 554 | |
|
| 555 | |
|
| 556 | |
|
| 557 | |
|
| 558 | |
|
| 559 | |
protected FigText getNameFig() { |
| 560 | 2142 | return nameFig; |
| 561 | |
} |
| 562 | |
|
| 563 | |
|
| 564 | |
|
| 565 | |
|
| 566 | |
|
| 567 | |
public Rectangle getNameBounds() { |
| 568 | 0 | return nameFig.getBounds(); |
| 569 | |
} |
| 570 | |
|
| 571 | |
|
| 572 | |
|
| 573 | |
|
| 574 | |
|
| 575 | |
|
| 576 | |
protected void setNameFig(FigText fig) { |
| 577 | 0 | nameFig = fig; |
| 578 | 0 | if (nameFig != null) { |
| 579 | 0 | updateFont(); |
| 580 | |
} |
| 581 | 0 | } |
| 582 | |
|
| 583 | |
|
| 584 | |
|
| 585 | |
|
| 586 | |
|
| 587 | |
|
| 588 | |
public String getName() { |
| 589 | 0 | return nameFig.getText(); |
| 590 | |
} |
| 591 | |
|
| 592 | |
|
| 593 | |
|
| 594 | |
|
| 595 | |
|
| 596 | |
|
| 597 | |
public void setName(String n) { |
| 598 | 0 | nameFig.setText(n); |
| 599 | 0 | } |
| 600 | |
|
| 601 | |
|
| 602 | |
|
| 603 | |
|
| 604 | |
|
| 605 | |
|
| 606 | |
@Override |
| 607 | |
public Vector getPopUpActions(MouseEvent me) { |
| 608 | 0 | ActionList popUpActions = |
| 609 | |
new ActionList(super.getPopUpActions(me), isReadOnly()); |
| 610 | |
|
| 611 | 0 | final List<Action> modulesActions = |
| 612 | |
ContextActionFactoryManager.getContextPopupActions(); |
| 613 | |
|
| 614 | 0 | for (Action a : modulesActions) { |
| 615 | 0 | if (a instanceof List) { |
| 616 | 0 | JMenu m = new JMenu((Action) a); |
| 617 | 0 | popUpActions.add(m); |
| 618 | 0 | for (Action subAction : (List<Action>) a) { |
| 619 | 0 | m.add(subAction); |
| 620 | |
} |
| 621 | 0 | } else { |
| 622 | 0 | popUpActions.add(a); |
| 623 | |
} |
| 624 | |
} |
| 625 | |
|
| 626 | |
|
| 627 | 0 | ArgoJMenu show = buildShowPopUp(); |
| 628 | 0 | if (show.getMenuComponentCount() > 0) { |
| 629 | 0 | popUpActions.add(show); |
| 630 | |
} |
| 631 | |
|
| 632 | |
|
| 633 | 0 | popUpActions.add(new JSeparator()); |
| 634 | 0 | popupAddOffset = 1; |
| 635 | 0 | if (removeFromDiagram) { |
| 636 | 0 | popUpActions.add( |
| 637 | |
ProjectActions.getInstance().getRemoveFromDiagramAction()); |
| 638 | 0 | popupAddOffset++; |
| 639 | |
} |
| 640 | |
|
| 641 | 0 | if (!isReadOnly()) { |
| 642 | 0 | popUpActions.add(new ActionDeleteModelElements()); |
| 643 | 0 | popupAddOffset++; |
| 644 | |
} |
| 645 | |
|
| 646 | |
|
| 647 | 0 | if (TargetManager.getInstance().getTargets().size() == 1) { |
| 648 | |
|
| 649 | |
|
| 650 | |
|
| 651 | |
|
| 652 | 0 | ToDoList tdList = Designer.theDesigner().getToDoList(); |
| 653 | 0 | List<ToDoItem> items = tdList.elementListForOffender(getOwner()); |
| 654 | 0 | if (items != null && items.size() > 0) { |
| 655 | |
|
| 656 | |
|
| 657 | |
|
| 658 | |
|
| 659 | 0 | ArgoJMenu critiques = new ArgoJMenu("menu.popup.critiques"); |
| 660 | 0 | ToDoItem itemUnderMouse = hitClarifier(me.getX(), me.getY()); |
| 661 | 0 | if (itemUnderMouse != null) { |
| 662 | 0 | critiques.add(new ActionGoToCritique(itemUnderMouse)); |
| 663 | 0 | critiques.addSeparator(); |
| 664 | |
} |
| 665 | 0 | for (ToDoItem item : items) { |
| 666 | 0 | if (item != itemUnderMouse) { |
| 667 | 0 | critiques.add(new ActionGoToCritique(item)); |
| 668 | |
} |
| 669 | |
} |
| 670 | 0 | popUpActions.add(0, new JSeparator()); |
| 671 | 0 | popUpActions.add(0, critiques); |
| 672 | |
} |
| 673 | |
} |
| 674 | |
|
| 675 | |
|
| 676 | 0 | Collection<Object> elements = new ArrayList<Object>(); |
| 677 | 0 | Object owner = getOwner(); |
| 678 | 0 | if (owner != null) { |
| 679 | 0 | elements.add(owner); |
| 680 | |
} |
| 681 | 0 | for (Object o : TargetManager.getInstance().getTargets()) { |
| 682 | 0 | Object element = null; |
| 683 | 0 | if (Model.getFacade().isAUMLElement(o)) { |
| 684 | 0 | element = o; |
| 685 | 0 | } else if (o instanceof Fig) { |
| 686 | 0 | element = ((Fig) o).getOwner(); |
| 687 | |
} |
| 688 | 0 | if (element != null && element != owner) { |
| 689 | 0 | elements.add(element); |
| 690 | |
} |
| 691 | 0 | } |
| 692 | 0 | final Action[] stereoActions = |
| 693 | |
StereotypeUtility.getApplyStereotypeActions(elements); |
| 694 | 0 | if (stereoActions != null) { |
| 695 | 0 | popUpActions.add(0, new JSeparator()); |
| 696 | 0 | final ArgoJMenu stereotypes = |
| 697 | |
new ArgoJMenu("menu.popup.apply-stereotypes"); |
| 698 | 0 | for (Action action : stereoActions) { |
| 699 | 0 | stereotypes.addCheckItem(action); |
| 700 | |
} |
| 701 | 0 | popUpActions.add(0, stereotypes); |
| 702 | |
} |
| 703 | |
|
| 704 | 0 | if (TargetManager.getInstance().getTargets().size() == 1) { |
| 705 | |
|
| 706 | 0 | ArgoJMenu stereotypesView = |
| 707 | |
new ArgoJMenu("menu.popup.stereotype-view"); |
| 708 | |
|
| 709 | |
|
| 710 | |
|
| 711 | |
|
| 712 | 0 | stereotypesView.addRadioItem(new ActionStereotypeViewTextual(this)); |
| 713 | 0 | stereotypesView.addRadioItem(new ActionStereotypeViewBigIcon(this)); |
| 714 | 0 | stereotypesView.addRadioItem( |
| 715 | |
new ActionStereotypeViewSmallIcon(this)); |
| 716 | |
|
| 717 | 0 | popUpActions.add(0, stereotypesView); |
| 718 | |
} |
| 719 | |
|
| 720 | 0 | return popUpActions; |
| 721 | |
} |
| 722 | |
|
| 723 | |
protected ArgoJMenu buildShowPopUp() { |
| 724 | 0 | ArgoJMenu showMenu = new ArgoJMenu("menu.popup.show"); |
| 725 | |
|
| 726 | 0 | for (UndoableAction ua : ActionSetPath.getActions()) { |
| 727 | 0 | showMenu.add(ua); |
| 728 | |
} |
| 729 | 0 | return showMenu; |
| 730 | |
} |
| 731 | |
|
| 732 | |
|
| 733 | |
|
| 734 | |
|
| 735 | |
protected Object buildVisibilityPopUp() { |
| 736 | 0 | ArgoJMenu visibilityMenu = new ArgoJMenu("menu.popup.visibility"); |
| 737 | |
|
| 738 | 0 | visibilityMenu.addRadioItem(new ActionVisibilityPublic(getOwner())); |
| 739 | 0 | visibilityMenu.addRadioItem(new ActionVisibilityPrivate(getOwner())); |
| 740 | 0 | visibilityMenu.addRadioItem(new ActionVisibilityProtected(getOwner())); |
| 741 | 0 | visibilityMenu.addRadioItem(new ActionVisibilityPackage(getOwner())); |
| 742 | |
|
| 743 | 0 | return visibilityMenu; |
| 744 | |
} |
| 745 | |
|
| 746 | |
|
| 747 | |
|
| 748 | |
|
| 749 | |
|
| 750 | |
|
| 751 | |
|
| 752 | |
|
| 753 | |
|
| 754 | |
protected Object buildModifierPopUp(int items) { |
| 755 | 0 | ArgoJMenu modifierMenu = new ArgoJMenu("menu.popup.modifiers"); |
| 756 | |
|
| 757 | 0 | if ((items & ABSTRACT) > 0) { |
| 758 | 0 | modifierMenu.addCheckItem(new ActionModifierAbstract(getOwner())); |
| 759 | |
} |
| 760 | 0 | if ((items & LEAF) > 0) { |
| 761 | 0 | modifierMenu.addCheckItem(new ActionModifierLeaf(getOwner())); |
| 762 | |
} |
| 763 | 0 | if ((items & ROOT) > 0) { |
| 764 | 0 | modifierMenu.addCheckItem(new ActionModifierRoot(getOwner())); |
| 765 | |
} |
| 766 | 0 | if ((items & ACTIVE) > 0) { |
| 767 | 0 | modifierMenu.addCheckItem(new ActionModifierActive(getOwner())); |
| 768 | |
} |
| 769 | |
|
| 770 | 0 | return modifierMenu; |
| 771 | |
} |
| 772 | |
|
| 773 | |
|
| 774 | |
|
| 775 | |
|
| 776 | |
@Override |
| 777 | |
public Fig getEnclosingFig() { |
| 778 | 0 | return encloser; |
| 779 | |
} |
| 780 | |
|
| 781 | |
|
| 782 | |
|
| 783 | |
|
| 784 | |
|
| 785 | |
|
| 786 | |
|
| 787 | |
|
| 788 | |
|
| 789 | |
|
| 790 | |
|
| 791 | |
@Override |
| 792 | |
public void setEnclosingFig(Fig newEncloser) { |
| 793 | 0 | Fig oldEncloser = encloser; |
| 794 | |
|
| 795 | 0 | LayerPerspective layer = (LayerPerspective) getLayer(); |
| 796 | 0 | if (layer != null) { |
| 797 | 0 | ArgoDiagram diagram = (ArgoDiagram) layer.getDiagram(); |
| 798 | 0 | diagram.encloserChanged( |
| 799 | |
this, |
| 800 | |
(FigNode) oldEncloser, |
| 801 | |
(FigNode) newEncloser); |
| 802 | |
} |
| 803 | |
|
| 804 | 0 | super.setEnclosingFig(newEncloser); |
| 805 | |
|
| 806 | 0 | if (layer != null && newEncloser != oldEncloser) { |
| 807 | 0 | Diagram diagram = layer.getDiagram(); |
| 808 | 0 | if (diagram instanceof ArgoDiagram) { |
| 809 | 0 | ArgoDiagram umlDiagram = (ArgoDiagram) diagram; |
| 810 | |
|
| 811 | |
|
| 812 | 0 | Object namespace = null; |
| 813 | 0 | if (newEncloser == null) { |
| 814 | |
|
| 815 | 0 | umlDiagram.setModelElementNamespace(getOwner(), null); |
| 816 | |
} else { |
| 817 | |
|
| 818 | 0 | namespace = newEncloser.getOwner(); |
| 819 | 0 | if (Model.getFacade().isANamespace(namespace)) { |
| 820 | 0 | umlDiagram.setModelElementNamespace( |
| 821 | |
getOwner(), namespace); |
| 822 | |
} |
| 823 | |
} |
| 824 | |
} |
| 825 | |
|
| 826 | 0 | if (encloser instanceof FigNodeModelElement) { |
| 827 | 0 | ((FigNodeModelElement) encloser).removeEnclosedFig(this); |
| 828 | |
} |
| 829 | 0 | if (newEncloser instanceof FigNodeModelElement) { |
| 830 | 0 | ((FigNodeModelElement) newEncloser).addEnclosedFig(this); |
| 831 | |
} |
| 832 | |
} |
| 833 | 0 | encloser = newEncloser; |
| 834 | 0 | } |
| 835 | |
|
| 836 | |
|
| 837 | |
|
| 838 | |
|
| 839 | |
|
| 840 | |
|
| 841 | |
protected void moveIntoComponent(Fig newEncloser) { |
| 842 | 0 | final Object component = newEncloser.getOwner(); |
| 843 | 0 | final Object owner = getOwner(); |
| 844 | |
|
| 845 | 0 | assert Model.getFacade().isAComponent(component); |
| 846 | 0 | assert Model.getFacade().isAUMLElement(owner); |
| 847 | |
|
| 848 | 0 | final Collection er1 = Model.getFacade().getElementResidences(owner); |
| 849 | 0 | final Collection er2 = Model.getFacade().getResidentElements(component); |
| 850 | 0 | boolean found = false; |
| 851 | |
|
| 852 | 0 | final Collection<Object> common = new ArrayList<Object>(er1); |
| 853 | 0 | common.retainAll(er2); |
| 854 | 0 | for (Object elementResidence : common) { |
| 855 | 0 | if (!found) { |
| 856 | 0 | found = true; |
| 857 | |
|
| 858 | |
} else { |
| 859 | |
|
| 860 | 0 | Model.getUmlFactory().delete(elementResidence); |
| 861 | |
} |
| 862 | |
} |
| 863 | 0 | if (!found) { |
| 864 | |
|
| 865 | 0 | Model.getCoreFactory().buildElementResidence( |
| 866 | |
owner, component); |
| 867 | |
} |
| 868 | 0 | } |
| 869 | |
|
| 870 | |
|
| 871 | |
|
| 872 | |
|
| 873 | |
|
| 874 | |
|
| 875 | |
public void addEnclosedFig(Fig fig) { |
| 876 | 0 | enclosedFigs.add(fig); |
| 877 | 0 | } |
| 878 | |
|
| 879 | |
|
| 880 | |
|
| 881 | |
|
| 882 | |
|
| 883 | |
|
| 884 | |
public void removeEnclosedFig(Fig fig) { |
| 885 | 0 | enclosedFigs.remove(fig); |
| 886 | 0 | } |
| 887 | |
|
| 888 | |
|
| 889 | |
|
| 890 | |
|
| 891 | |
@Override |
| 892 | |
public Vector<Fig> getEnclosedFigs() { |
| 893 | 0 | return enclosedFigs; |
| 894 | |
} |
| 895 | |
|
| 896 | |
|
| 897 | |
|
| 898 | |
|
| 899 | |
|
| 900 | |
@Override |
| 901 | |
public Selection makeSelection() { |
| 902 | 0 | return new SelectionDefaultClarifiers(this); |
| 903 | |
} |
| 904 | |
|
| 905 | |
|
| 906 | |
|
| 907 | |
|
| 908 | |
|
| 909 | |
|
| 910 | |
|
| 911 | |
|
| 912 | |
|
| 913 | |
|
| 914 | |
public void paintClarifiers(Graphics g) { |
| 915 | |
|
| 916 | 0 | int iconX = getX(); |
| 917 | 0 | int iconY = getY() - 10; |
| 918 | 0 | ToDoList tdList = Designer.theDesigner().getToDoList(); |
| 919 | 0 | List<ToDoItem> items = tdList.elementListForOffender(getOwner()); |
| 920 | 0 | for (ToDoItem item : items) { |
| 921 | 0 | Icon icon = item.getClarifier(); |
| 922 | 0 | if (icon instanceof Clarifier) { |
| 923 | 0 | ((Clarifier) icon).setFig(this); |
| 924 | 0 | ((Clarifier) icon).setToDoItem(item); |
| 925 | |
} |
| 926 | 0 | if (icon != null) { |
| 927 | 0 | icon.paintIcon(null, g, iconX, iconY); |
| 928 | 0 | iconX += icon.getIconWidth(); |
| 929 | |
} |
| 930 | 0 | } |
| 931 | 0 | items = tdList.elementListForOffender(this); |
| 932 | 0 | for (ToDoItem item : items) { |
| 933 | 0 | Icon icon = item.getClarifier(); |
| 934 | 0 | if (icon instanceof Clarifier) { |
| 935 | 0 | ((Clarifier) icon).setFig(this); |
| 936 | 0 | ((Clarifier) icon).setToDoItem(item); |
| 937 | |
} |
| 938 | 0 | if (icon != null) { |
| 939 | 0 | icon.paintIcon(null, g, iconX, iconY); |
| 940 | 0 | iconX += icon.getIconWidth(); |
| 941 | |
} |
| 942 | 0 | } |
| 943 | 0 | } |
| 944 | |
|
| 945 | |
|
| 946 | |
|
| 947 | |
|
| 948 | |
|
| 949 | |
|
| 950 | |
protected ToDoItem hitClarifier(int x, int y) { |
| 951 | |
|
| 952 | 0 | int iconX = getX(); |
| 953 | 0 | ToDoList tdList = Designer.theDesigner().getToDoList(); |
| 954 | 0 | List<ToDoItem> items = tdList.elementListForOffender(getOwner()); |
| 955 | 0 | for (ToDoItem item : items) { |
| 956 | 0 | Icon icon = item.getClarifier(); |
| 957 | 0 | int width = icon.getIconWidth(); |
| 958 | 0 | if (y >= getY() - 15 |
| 959 | |
&& y <= getY() + 10 |
| 960 | |
&& x >= iconX |
| 961 | |
&& x <= iconX + width) { |
| 962 | 0 | return item; |
| 963 | |
} |
| 964 | 0 | iconX += width; |
| 965 | 0 | } |
| 966 | 0 | for (ToDoItem item : items) { |
| 967 | 0 | Icon icon = item.getClarifier(); |
| 968 | 0 | if (icon instanceof Clarifier) { |
| 969 | 0 | ((Clarifier) icon).setFig(this); |
| 970 | 0 | ((Clarifier) icon).setToDoItem(item); |
| 971 | 0 | if (((Clarifier) icon).hit(x, y)) { |
| 972 | 0 | return item; |
| 973 | |
} |
| 974 | |
} |
| 975 | 0 | } |
| 976 | 0 | items = tdList.elementListForOffender(this); |
| 977 | 0 | for (ToDoItem item : items) { |
| 978 | 0 | Icon icon = item.getClarifier(); |
| 979 | 0 | int width = icon.getIconWidth(); |
| 980 | 0 | if (y >= getY() - 15 |
| 981 | |
&& y <= getY() + 10 |
| 982 | |
&& x >= iconX |
| 983 | |
&& x <= iconX + width) { |
| 984 | 0 | return item; |
| 985 | |
} |
| 986 | 0 | iconX += width; |
| 987 | 0 | } |
| 988 | 0 | for (ToDoItem item : items) { |
| 989 | 0 | Icon icon = item.getClarifier(); |
| 990 | 0 | if (icon instanceof Clarifier) { |
| 991 | 0 | ((Clarifier) icon).setFig(this); |
| 992 | 0 | ((Clarifier) icon).setToDoItem(item); |
| 993 | 0 | if (((Clarifier) icon).hit(x, y)) { |
| 994 | 0 | return item; |
| 995 | |
} |
| 996 | |
} |
| 997 | 0 | } |
| 998 | 0 | return null; |
| 999 | |
} |
| 1000 | |
|
| 1001 | |
|
| 1002 | |
|
| 1003 | |
|
| 1004 | |
@Override |
| 1005 | |
public String getTipString(MouseEvent me) { |
| 1006 | |
|
| 1007 | 0 | ToDoItem item = hitClarifier(me.getX(), me.getY()); |
| 1008 | 0 | String tip = ""; |
| 1009 | 0 | if (item != null |
| 1010 | |
&& Globals.curEditor().getSelectionManager().containsFig(this)) { |
| 1011 | 0 | tip = item.getHeadline() + " "; |
| 1012 | 0 | } else if (getOwner() != null) { |
| 1013 | 0 | tip = Model.getFacade().getTipString(getOwner()); |
| 1014 | |
} else { |
| 1015 | 0 | tip = toString(); |
| 1016 | |
} |
| 1017 | 0 | if (tip != null && tip.length() > 0 && !tip.endsWith(" ")) { |
| 1018 | 0 | tip += " "; |
| 1019 | |
} |
| 1020 | 0 | return tip; |
| 1021 | |
} |
| 1022 | |
|
| 1023 | |
|
| 1024 | |
|
| 1025 | |
|
| 1026 | |
|
| 1027 | |
|
| 1028 | |
|
| 1029 | |
public void vetoableChange(PropertyChangeEvent pce) { |
| 1030 | 0 | LOG.debug("in vetoableChange"); |
| 1031 | 0 | Object src = pce.getSource(); |
| 1032 | 0 | if (src == getOwner()) { |
| 1033 | 0 | DelayedChangeNotify delayedNotify = |
| 1034 | |
new DelayedChangeNotify(this, pce); |
| 1035 | 0 | SwingUtilities.invokeLater(delayedNotify); |
| 1036 | 0 | } else { |
| 1037 | 0 | LOG.debug("FigNodeModelElement got vetoableChange" |
| 1038 | |
+ " from non-owner:" |
| 1039 | |
+ src); |
| 1040 | |
} |
| 1041 | 0 | } |
| 1042 | |
|
| 1043 | |
|
| 1044 | |
|
| 1045 | |
|
| 1046 | |
public void delayedVetoableChange(PropertyChangeEvent pce) { |
| 1047 | 0 | LOG.debug("in delayedVetoableChange"); |
| 1048 | |
|
| 1049 | 0 | renderingChanged(); |
| 1050 | 0 | endTrans(); |
| 1051 | 0 | } |
| 1052 | |
|
| 1053 | |
|
| 1054 | |
|
| 1055 | |
|
| 1056 | |
|
| 1057 | |
|
| 1058 | |
|
| 1059 | |
|
| 1060 | |
|
| 1061 | |
|
| 1062 | |
|
| 1063 | |
|
| 1064 | |
protected void updateBounds() { |
| 1065 | 0 | if (!checkSize) { |
| 1066 | 0 | return; |
| 1067 | |
} |
| 1068 | 0 | Rectangle bbox = getBounds(); |
| 1069 | 0 | Dimension minSize = getMinimumSize(); |
| 1070 | 0 | if (isResizable()) { |
| 1071 | 0 | bbox.width = Math.max(bbox.width, minSize.width); |
| 1072 | 0 | bbox.height = Math.max(bbox.height, minSize.height); |
| 1073 | |
} |
| 1074 | |
|
| 1075 | 0 | if (bbox.x != getX() |
| 1076 | |
|| bbox.y != getY() |
| 1077 | |
|| bbox.width != getWidth() |
| 1078 | |
|| bbox.height != getHeight()) { |
| 1079 | 0 | setBounds(bbox.x, bbox.y, bbox.width, bbox.height); |
| 1080 | |
} |
| 1081 | 0 | } |
| 1082 | |
|
| 1083 | |
|
| 1084 | |
|
| 1085 | |
|
| 1086 | |
public void propertyChange(final PropertyChangeEvent pve) { |
| 1087 | 32 | final Object src = pve.getSource(); |
| 1088 | 32 | final String pName = pve.getPropertyName(); |
| 1089 | 32 | if (pve instanceof DeleteInstanceEvent && src == getOwner()) { |
| 1090 | 0 | removeFromDiagram(); |
| 1091 | 0 | return; |
| 1092 | |
} |
| 1093 | |
|
| 1094 | |
|
| 1095 | 32 | if (pve.getPropertyName().equals("supplierDependency") |
| 1096 | |
&& Model.getFacade().isADependency(pve.getOldValue())) { |
| 1097 | |
|
| 1098 | |
|
| 1099 | 0 | return; |
| 1100 | |
} |
| 1101 | |
|
| 1102 | |
|
| 1103 | 32 | if (pName.equals("editing") |
| 1104 | |
&& Boolean.FALSE.equals(pve.getNewValue())) { |
| 1105 | |
try { |
| 1106 | |
|
| 1107 | 0 | textEdited((FigText) src); |
| 1108 | |
|
| 1109 | 0 | final Rectangle bbox = getBounds(); |
| 1110 | 0 | final Dimension minSize = getMinimumSize(); |
| 1111 | 0 | bbox.width = Math.max(bbox.width, minSize.width); |
| 1112 | 0 | bbox.height = Math.max(bbox.height, minSize.height); |
| 1113 | 0 | setBounds(bbox.x, bbox.y, bbox.width, bbox.height); |
| 1114 | 0 | endTrans(); |
| 1115 | 0 | } catch (PropertyVetoException ex) { |
| 1116 | 0 | LOG.error("could not parse the text entered. " |
| 1117 | |
+ "PropertyVetoException", |
| 1118 | |
ex); |
| 1119 | 0 | } |
| 1120 | 32 | } else if (pName.equals("editing") |
| 1121 | |
&& Boolean.TRUE.equals(pve.getNewValue())) { |
| 1122 | 0 | if (!isReadOnly()) { |
| 1123 | 0 | textEditStarted((FigText) src); |
| 1124 | |
} |
| 1125 | |
} else { |
| 1126 | 32 | super.propertyChange(pve); |
| 1127 | |
} |
| 1128 | 32 | if (Model.getFacade().isAUMLElement(src)) { |
| 1129 | 0 | final UmlChangeEvent event = (UmlChangeEvent) pve; |
| 1130 | |
|
| 1131 | |
|
| 1132 | |
|
| 1133 | |
|
| 1134 | |
|
| 1135 | 0 | final Object owner = getOwner(); |
| 1136 | 0 | if (owner == null) { |
| 1137 | |
|
| 1138 | 0 | return; |
| 1139 | |
} |
| 1140 | |
|
| 1141 | |
try { |
| 1142 | 0 | modelChanged(event); |
| 1143 | 0 | } catch (InvalidElementException e) { |
| 1144 | 0 | if (LOG.isDebugEnabled()) { |
| 1145 | 0 | LOG.debug("modelChanged method accessed deleted element" |
| 1146 | |
+ formatEvent(event), |
| 1147 | |
e); |
| 1148 | |
} |
| 1149 | 0 | } |
| 1150 | |
|
| 1151 | 0 | if (event.getSource() == owner |
| 1152 | |
&& "stereotype".equals(event.getPropertyName())) { |
| 1153 | 0 | stereotypeChanged(event); |
| 1154 | |
} |
| 1155 | |
|
| 1156 | 0 | Runnable doWorkRunnable = new Runnable() { |
| 1157 | |
public void run() { |
| 1158 | |
try { |
| 1159 | 0 | updateLayout(event); |
| 1160 | 0 | } catch (InvalidElementException e) { |
| 1161 | 0 | if (LOG.isDebugEnabled()) { |
| 1162 | 0 | LOG.debug("updateLayout method accessed " |
| 1163 | |
+ "deleted element " |
| 1164 | |
+ formatEvent(event), e); |
| 1165 | |
} |
| 1166 | 0 | } |
| 1167 | 0 | } |
| 1168 | |
}; |
| 1169 | 0 | SwingUtilities.invokeLater(doWorkRunnable); |
| 1170 | |
} |
| 1171 | 32 | } |
| 1172 | |
|
| 1173 | |
private String formatEvent(PropertyChangeEvent event) { |
| 1174 | 0 | return "\n\t event = " + event.getClass().getName() |
| 1175 | |
+ "\n\t source = " + event.getSource() |
| 1176 | |
+ "\n\t old = " + event.getOldValue() |
| 1177 | |
+ "\n\t name = " + event.getPropertyName(); |
| 1178 | |
} |
| 1179 | |
|
| 1180 | |
|
| 1181 | |
|
| 1182 | |
|
| 1183 | |
|
| 1184 | |
private boolean isReadOnly() { |
| 1185 | |
try { |
| 1186 | 0 | return Model.getModelManagementHelper().isReadOnly(getOwner()); |
| 1187 | 0 | } catch (InvalidElementException e) { |
| 1188 | 0 | return true; |
| 1189 | |
} |
| 1190 | |
} |
| 1191 | |
|
| 1192 | |
|
| 1193 | |
|
| 1194 | |
|
| 1195 | |
|
| 1196 | |
|
| 1197 | |
|
| 1198 | |
|
| 1199 | |
|
| 1200 | |
|
| 1201 | |
|
| 1202 | |
|
| 1203 | |
|
| 1204 | |
|
| 1205 | |
|
| 1206 | |
|
| 1207 | |
|
| 1208 | |
private void stereotypeChanged(final UmlChangeEvent event) { |
| 1209 | 0 | final Object owner = getOwner(); |
| 1210 | 0 | assert owner != null; |
| 1211 | |
try { |
| 1212 | 0 | if (event.getOldValue() != null) { |
| 1213 | 0 | removeElementListener(event.getOldValue()); |
| 1214 | |
} |
| 1215 | 0 | if (event.getNewValue() != null) { |
| 1216 | 0 | addElementListener(event.getNewValue(), "name"); |
| 1217 | |
} |
| 1218 | 0 | } catch (InvalidElementException e) { |
| 1219 | 0 | LOG.debug("stereotypeChanged method accessed deleted element ", e); |
| 1220 | 0 | } |
| 1221 | 0 | } |
| 1222 | |
|
| 1223 | |
|
| 1224 | |
|
| 1225 | |
|
| 1226 | |
|
| 1227 | |
|
| 1228 | |
|
| 1229 | |
|
| 1230 | |
|
| 1231 | |
|
| 1232 | |
|
| 1233 | |
|
| 1234 | |
|
| 1235 | |
|
| 1236 | |
protected void textEditStarted(FigText ft) { |
| 1237 | 0 | if (ft == getNameFig()) { |
| 1238 | 0 | showHelp(notationProviderName.getParsingHelp()); |
| 1239 | 0 | ft.setText(notationProviderName.toString(getOwner(), |
| 1240 | |
getNotationSettings())); |
| 1241 | |
} |
| 1242 | 0 | if (ft instanceof CompartmentFigText) { |
| 1243 | 0 | final CompartmentFigText figText = (CompartmentFigText) ft; |
| 1244 | 0 | showHelp(figText.getNotationProvider().getParsingHelp()); |
| 1245 | 0 | figText.setText(figText.getNotationProvider().toString( |
| 1246 | |
figText.getOwner(), getNotationSettings())); |
| 1247 | |
} |
| 1248 | 0 | } |
| 1249 | |
|
| 1250 | |
|
| 1251 | |
|
| 1252 | |
|
| 1253 | |
|
| 1254 | |
|
| 1255 | |
|
| 1256 | |
|
| 1257 | |
|
| 1258 | |
|
| 1259 | |
|
| 1260 | |
protected void showHelp(String s) { |
| 1261 | 0 | if (s == null) { |
| 1262 | |
|
| 1263 | 0 | ArgoEventPump.fireEvent(new ArgoHelpEvent( |
| 1264 | |
ArgoEventTypes.HELP_CHANGED, this, "")); |
| 1265 | |
} else { |
| 1266 | 0 | ArgoEventPump.fireEvent(new ArgoHelpEvent( |
| 1267 | |
ArgoEventTypes.HELP_CHANGED, this, Translator.localize(s))); |
| 1268 | |
} |
| 1269 | 0 | } |
| 1270 | |
|
| 1271 | |
|
| 1272 | |
|
| 1273 | |
|
| 1274 | |
|
| 1275 | |
|
| 1276 | |
|
| 1277 | |
|
| 1278 | |
|
| 1279 | |
|
| 1280 | |
|
| 1281 | |
|
| 1282 | |
protected void textEdited(FigText ft) throws PropertyVetoException { |
| 1283 | 0 | if (ft == nameFig) { |
| 1284 | |
|
| 1285 | 0 | if (getOwner() == null) { |
| 1286 | 0 | return; |
| 1287 | |
} |
| 1288 | 0 | notationProviderName.parse(getOwner(), ft.getText()); |
| 1289 | 0 | ft.setText(notationProviderName.toString(getOwner(), |
| 1290 | |
getNotationSettings())); |
| 1291 | |
} |
| 1292 | 0 | if (ft instanceof CompartmentFigText) { |
| 1293 | 0 | final CompartmentFigText figText = (CompartmentFigText) ft; |
| 1294 | 0 | figText.getNotationProvider().parse(ft.getOwner(), ft.getText()); |
| 1295 | 0 | ft.setText(figText.getNotationProvider().toString( |
| 1296 | |
ft.getOwner(), getNotationSettings())); |
| 1297 | |
} |
| 1298 | 0 | } |
| 1299 | |
|
| 1300 | |
|
| 1301 | |
|
| 1302 | |
|
| 1303 | |
|
| 1304 | |
|
| 1305 | |
|
| 1306 | |
|
| 1307 | |
|
| 1308 | |
|
| 1309 | |
|
| 1310 | |
@Override |
| 1311 | |
public void mouseClicked(MouseEvent me) { |
| 1312 | 0 | if (!readyToEdit) { |
| 1313 | 0 | if (Model.getFacade().isAModelElement(getOwner())) { |
| 1314 | |
|
| 1315 | 0 | Model.getCoreHelper().setName(getOwner(), ""); |
| 1316 | 0 | readyToEdit = true; |
| 1317 | |
} else { |
| 1318 | 0 | LOG.debug("not ready to edit name"); |
| 1319 | 0 | return; |
| 1320 | |
} |
| 1321 | |
} |
| 1322 | 0 | if (me.isConsumed()) { |
| 1323 | 0 | return; |
| 1324 | |
} |
| 1325 | 0 | if (me.getClickCount() >= 2 |
| 1326 | |
&& !(me.isPopupTrigger() |
| 1327 | |
|| me.getModifiers() == InputEvent.BUTTON3_MASK) |
| 1328 | |
&& getOwner() != null |
| 1329 | |
&& !isReadOnly()) { |
| 1330 | 0 | Rectangle r = new Rectangle(me.getX() - 2, me.getY() - 2, 4, 4); |
| 1331 | 0 | Fig f = hitFig(r); |
| 1332 | 0 | if (f instanceof MouseListener && f.isVisible()) { |
| 1333 | 0 | ((MouseListener) f).mouseClicked(me); |
| 1334 | 0 | } else if (f instanceof FigGroup && f.isVisible()) { |
| 1335 | |
|
| 1336 | |
|
| 1337 | 0 | Fig f2 = ((FigGroup) f).hitFig(r); |
| 1338 | 0 | if (f2 instanceof MouseListener) { |
| 1339 | 0 | ((MouseListener) f2).mouseClicked(me); |
| 1340 | |
} else { |
| 1341 | 0 | createContainedModelElement((FigGroup) f, me); |
| 1342 | |
} |
| 1343 | |
} |
| 1344 | |
} |
| 1345 | 0 | } |
| 1346 | |
|
| 1347 | |
|
| 1348 | |
|
| 1349 | |
|
| 1350 | |
public void keyPressed(KeyEvent ke) { |
| 1351 | 0 | if (ke.isConsumed() || getOwner() == null) { |
| 1352 | 0 | return; |
| 1353 | |
} |
| 1354 | 0 | nameFig.keyPressed(ke); |
| 1355 | 0 | } |
| 1356 | |
|
| 1357 | |
|
| 1358 | |
|
| 1359 | |
|
| 1360 | |
public void keyReleased(KeyEvent ke) { |
| 1361 | 0 | if (ke.isConsumed() || getOwner() == null) { |
| 1362 | 0 | return; |
| 1363 | |
} |
| 1364 | 0 | nameFig.keyReleased(ke); |
| 1365 | 0 | } |
| 1366 | |
|
| 1367 | |
|
| 1368 | |
|
| 1369 | |
|
| 1370 | |
public void keyTyped(KeyEvent ke) { |
| 1371 | 0 | if (!editable || isReadOnly()) { |
| 1372 | 0 | return; |
| 1373 | |
} |
| 1374 | 0 | if (!readyToEdit) { |
| 1375 | 0 | if (Model.getFacade().isAModelElement(getOwner())) { |
| 1376 | 0 | Model.getCoreHelper().setName(getOwner(), ""); |
| 1377 | 0 | readyToEdit = true; |
| 1378 | |
} else { |
| 1379 | 0 | LOG.debug("not ready to edit name"); |
| 1380 | 0 | return; |
| 1381 | |
} |
| 1382 | |
} |
| 1383 | 0 | if (ke.isConsumed() || getOwner() == null) { |
| 1384 | 0 | return; |
| 1385 | |
} |
| 1386 | 0 | nameFig.keyTyped(ke); |
| 1387 | 0 | } |
| 1388 | |
|
| 1389 | |
|
| 1390 | |
|
| 1391 | |
|
| 1392 | |
|
| 1393 | |
|
| 1394 | |
|
| 1395 | |
|
| 1396 | |
|
| 1397 | |
|
| 1398 | |
|
| 1399 | |
|
| 1400 | |
|
| 1401 | |
|
| 1402 | |
protected void modelChanged(PropertyChangeEvent event) { |
| 1403 | 0 | if (event instanceof AssociationChangeEvent |
| 1404 | |
|| event instanceof AttributeChangeEvent) { |
| 1405 | |
|
| 1406 | |
|
| 1407 | |
|
| 1408 | |
|
| 1409 | |
|
| 1410 | 0 | updateListeners(getOwner(), getOwner()); |
| 1411 | |
} |
| 1412 | 0 | } |
| 1413 | |
|
| 1414 | |
|
| 1415 | |
|
| 1416 | |
|
| 1417 | |
|
| 1418 | |
|
| 1419 | |
|
| 1420 | |
|
| 1421 | |
|
| 1422 | |
|
| 1423 | |
|
| 1424 | |
|
| 1425 | |
|
| 1426 | |
|
| 1427 | |
|
| 1428 | |
|
| 1429 | |
|
| 1430 | |
|
| 1431 | |
|
| 1432 | |
|
| 1433 | |
|
| 1434 | |
protected void updateLayout(UmlChangeEvent event) { |
| 1435 | 0 | assert event != null; |
| 1436 | 0 | final Object owner = getOwner(); |
| 1437 | 0 | assert owner != null; |
| 1438 | 0 | if (owner == null) { |
| 1439 | 0 | return; |
| 1440 | |
} |
| 1441 | 0 | boolean needDamage = false; |
| 1442 | 0 | if (event instanceof AssociationChangeEvent |
| 1443 | |
|| event instanceof AttributeChangeEvent) { |
| 1444 | 0 | if (notationProviderName != null) { |
| 1445 | 0 | updateNameText(); |
| 1446 | |
} |
| 1447 | 0 | needDamage = true; |
| 1448 | |
} |
| 1449 | 0 | if (event.getSource() == owner |
| 1450 | |
&& "stereotype".equals(event.getPropertyName())) { |
| 1451 | 0 | updateStereotypeText(); |
| 1452 | 0 | updateStereotypeIcon(); |
| 1453 | 0 | needDamage = true; |
| 1454 | |
} |
| 1455 | 0 | if (needDamage) { |
| 1456 | 0 | damage(); |
| 1457 | |
} |
| 1458 | 0 | } |
| 1459 | |
|
| 1460 | |
|
| 1461 | |
|
| 1462 | |
|
| 1463 | |
|
| 1464 | |
|
| 1465 | |
|
| 1466 | |
|
| 1467 | |
|
| 1468 | |
|
| 1469 | |
protected void createContainedModelElement(FigGroup fg, InputEvent me) { |
| 1470 | |
|
| 1471 | |
|
| 1472 | 0 | } |
| 1473 | |
|
| 1474 | |
|
| 1475 | |
|
| 1476 | |
|
| 1477 | |
|
| 1478 | |
protected boolean isPartlyOwner(Object o) { |
| 1479 | 0 | if (o == null || o == getOwner()) { |
| 1480 | 0 | return true; |
| 1481 | |
} |
| 1482 | 0 | for (Object fig : getFigs()) { |
| 1483 | 0 | if (isPartlyOwner((Fig) fig, o)) { |
| 1484 | 0 | return true; |
| 1485 | |
} |
| 1486 | |
} |
| 1487 | 0 | return false; |
| 1488 | |
} |
| 1489 | |
|
| 1490 | |
|
| 1491 | |
|
| 1492 | |
|
| 1493 | |
|
| 1494 | |
|
| 1495 | |
protected boolean isPartlyOwner(Fig fig, Object o) { |
| 1496 | 0 | if (o == null) { |
| 1497 | 0 | return false; |
| 1498 | |
} |
| 1499 | 0 | if (o == fig.getOwner()) { |
| 1500 | 0 | return true; |
| 1501 | |
} |
| 1502 | 0 | if (fig instanceof FigGroup) { |
| 1503 | 0 | for (Object fig2 : ((FigGroup) fig).getFigs()) { |
| 1504 | 0 | if (isPartlyOwner((Fig) fig2, o)) { |
| 1505 | 0 | return true; |
| 1506 | |
} |
| 1507 | |
} |
| 1508 | |
} |
| 1509 | 0 | return false; |
| 1510 | |
} |
| 1511 | |
|
| 1512 | |
|
| 1513 | |
|
| 1514 | |
|
| 1515 | |
@Override |
| 1516 | |
public void deleteFromModel() { |
| 1517 | 0 | Object own = getOwner(); |
| 1518 | 0 | if (own != null) { |
| 1519 | 0 | getProject().moveToTrash(own); |
| 1520 | |
} |
| 1521 | 0 | for (Object fig : getFigs()) { |
| 1522 | 0 | ((Fig) fig).deleteFromModel(); |
| 1523 | |
} |
| 1524 | 0 | super.deleteFromModel(); |
| 1525 | 0 | } |
| 1526 | |
|
| 1527 | |
|
| 1528 | |
|
| 1529 | |
|
| 1530 | |
|
| 1531 | |
|
| 1532 | |
|
| 1533 | |
|
| 1534 | |
|
| 1535 | |
|
| 1536 | |
|
| 1537 | |
|
| 1538 | |
|
| 1539 | |
|
| 1540 | |
|
| 1541 | |
|
| 1542 | |
|
| 1543 | |
|
| 1544 | |
|
| 1545 | |
|
| 1546 | |
|
| 1547 | |
|
| 1548 | |
|
| 1549 | |
protected void initNotationProviders(Object own) { |
| 1550 | 0 | if (notationProviderName != null) { |
| 1551 | 0 | notationProviderName.cleanListener(); |
| 1552 | |
} |
| 1553 | 0 | if (Model.getFacade().isAUMLElement(own)) { |
| 1554 | 0 | NotationName notation = Notation.findNotation( |
| 1555 | |
getNotationSettings().getNotationLanguage()); |
| 1556 | 0 | notationProviderName = |
| 1557 | |
NotationProviderFactory2.getInstance().getNotationProvider( |
| 1558 | |
getNotationProviderType(), own, this, |
| 1559 | |
notation); |
| 1560 | |
} |
| 1561 | 0 | } |
| 1562 | |
|
| 1563 | |
|
| 1564 | |
|
| 1565 | |
|
| 1566 | |
|
| 1567 | |
|
| 1568 | |
|
| 1569 | |
protected int getNotationProviderType() { |
| 1570 | 0 | return NotationProviderFactory2.TYPE_NAME; |
| 1571 | |
} |
| 1572 | |
|
| 1573 | |
|
| 1574 | |
|
| 1575 | |
|
| 1576 | |
|
| 1577 | |
protected void updateStereotypeText() { |
| 1578 | 0 | if (getOwner() == null) { |
| 1579 | 0 | LOG.warn("Null owner for [" + this.toString() + "/" |
| 1580 | |
+ this.getClass()); |
| 1581 | 0 | return; |
| 1582 | |
} |
| 1583 | 0 | if (getStereotypeFig() != null) { |
| 1584 | 0 | getStereotypeFig().populate(); |
| 1585 | |
} |
| 1586 | 0 | } |
| 1587 | |
|
| 1588 | |
|
| 1589 | |
|
| 1590 | |
|
| 1591 | |
|
| 1592 | |
|
| 1593 | |
protected void updateNameText() { |
| 1594 | 0 | if (readyToEdit) { |
| 1595 | 0 | if (getOwner() == null) { |
| 1596 | 0 | return; |
| 1597 | |
} |
| 1598 | 0 | if (notationProviderName != null) { |
| 1599 | 0 | nameFig.setText(notationProviderName.toString( |
| 1600 | |
getOwner(), getNotationSettings())); |
| 1601 | 0 | updateFont(); |
| 1602 | 0 | updateBounds(); |
| 1603 | |
} |
| 1604 | |
} |
| 1605 | 0 | } |
| 1606 | |
|
| 1607 | |
|
| 1608 | |
|
| 1609 | |
|
| 1610 | |
public boolean isPathVisible() { |
| 1611 | 0 | return getNotationSettings().isShowPaths(); |
| 1612 | |
} |
| 1613 | |
|
| 1614 | |
|
| 1615 | |
|
| 1616 | |
|
| 1617 | |
public void setPathVisible(boolean visible) { |
| 1618 | 0 | NotationSettings ns = getNotationSettings(); |
| 1619 | 0 | if (ns.isShowPaths() == visible) { |
| 1620 | 0 | return; |
| 1621 | |
} |
| 1622 | 0 | MutableGraphSupport.enableSaveAction(); |
| 1623 | |
|
| 1624 | |
|
| 1625 | 0 | firePropChange("pathVisible", !visible, visible); |
| 1626 | 0 | ns.setShowPaths(visible); |
| 1627 | 0 | if (readyToEdit) { |
| 1628 | 0 | renderingChanged(); |
| 1629 | 0 | damage(); |
| 1630 | |
} |
| 1631 | 0 | } |
| 1632 | |
|
| 1633 | |
|
| 1634 | |
|
| 1635 | |
|
| 1636 | |
|
| 1637 | |
|
| 1638 | |
|
| 1639 | |
|
| 1640 | |
|
| 1641 | |
|
| 1642 | |
|
| 1643 | |
|
| 1644 | |
|
| 1645 | |
|
| 1646 | |
|
| 1647 | |
|
| 1648 | |
|
| 1649 | |
protected void determineDefaultPathVisible() { |
| 1650 | 0 | Object modelElement = getOwner(); |
| 1651 | 0 | LayerPerspective layer = (LayerPerspective) getLayer(); |
| 1652 | 0 | if ((layer != null) |
| 1653 | |
&& Model.getFacade().isAModelElement(modelElement)) { |
| 1654 | 0 | ArgoDiagram diagram = (ArgoDiagram) layer.getDiagram(); |
| 1655 | 0 | Object elementNs = Model.getFacade().getNamespace(modelElement); |
| 1656 | 0 | Object diagramNs = diagram.getNamespace(); |
| 1657 | 0 | if (elementNs != null) { |
| 1658 | 0 | boolean visible = (elementNs != diagramNs); |
| 1659 | 0 | getNotationSettings().setShowPaths(visible); |
| 1660 | 0 | updateNameText(); |
| 1661 | 0 | damage(); |
| 1662 | |
} |
| 1663 | |
|
| 1664 | |
} |
| 1665 | |
|
| 1666 | 0 | } |
| 1667 | |
|
| 1668 | |
|
| 1669 | |
|
| 1670 | |
|
| 1671 | |
@Deprecated |
| 1672 | |
@Override |
| 1673 | |
public String classNameAndBounds() { |
| 1674 | 0 | return getClass().getName() |
| 1675 | |
+ "[" + getX() + ", " + getY() + ", " |
| 1676 | |
+ getWidth() + ", " + getHeight() + "]" |
| 1677 | |
+ "pathVisible=" + isPathVisible() + ";" |
| 1678 | |
+ "stereotypeView=" + getStereotypeView() + ";"; |
| 1679 | |
} |
| 1680 | |
|
| 1681 | |
|
| 1682 | |
|
| 1683 | |
|
| 1684 | |
|
| 1685 | |
|
| 1686 | |
|
| 1687 | |
|
| 1688 | |
|
| 1689 | |
|
| 1690 | |
|
| 1691 | |
|
| 1692 | |
|
| 1693 | |
|
| 1694 | |
|
| 1695 | |
|
| 1696 | |
|
| 1697 | |
|
| 1698 | |
|
| 1699 | |
|
| 1700 | |
|
| 1701 | |
|
| 1702 | |
|
| 1703 | |
|
| 1704 | |
|
| 1705 | |
|
| 1706 | |
|
| 1707 | |
|
| 1708 | |
|
| 1709 | |
|
| 1710 | |
|
| 1711 | |
protected void updateListeners(Object oldOwner, Object newOwner) { |
| 1712 | 0 | if (oldOwner == newOwner) { |
| 1713 | 0 | return; |
| 1714 | |
} |
| 1715 | 0 | if (oldOwner != null) { |
| 1716 | 0 | removeElementListener(oldOwner); |
| 1717 | |
} |
| 1718 | 0 | if (newOwner != null) { |
| 1719 | 0 | addElementListener(newOwner); |
| 1720 | |
} |
| 1721 | |
|
| 1722 | 0 | } |
| 1723 | |
|
| 1724 | |
|
| 1725 | |
|
| 1726 | |
|
| 1727 | |
|
| 1728 | |
|
| 1729 | |
@Deprecated |
| 1730 | |
public void notationChanged(ArgoNotationEvent event) { |
| 1731 | 0 | if (getOwner() == null) { |
| 1732 | 0 | return; |
| 1733 | |
} |
| 1734 | |
try { |
| 1735 | 0 | renderingChanged(); |
| 1736 | 0 | } catch (Exception e) { |
| 1737 | 0 | LOG.error("Exception", e); |
| 1738 | 0 | } |
| 1739 | 0 | } |
| 1740 | |
|
| 1741 | |
|
| 1742 | |
|
| 1743 | |
|
| 1744 | |
|
| 1745 | |
@Deprecated |
| 1746 | |
public void notationAdded(ArgoNotationEvent event) { |
| 1747 | |
|
| 1748 | 0 | } |
| 1749 | |
|
| 1750 | |
|
| 1751 | |
|
| 1752 | |
|
| 1753 | |
|
| 1754 | |
@Deprecated |
| 1755 | |
public void notationRemoved(ArgoNotationEvent event) { |
| 1756 | |
|
| 1757 | 0 | } |
| 1758 | |
|
| 1759 | |
|
| 1760 | |
|
| 1761 | |
|
| 1762 | |
|
| 1763 | |
@Deprecated |
| 1764 | |
public void notationProviderAdded(ArgoNotationEvent event) { |
| 1765 | |
|
| 1766 | 0 | } |
| 1767 | |
|
| 1768 | |
|
| 1769 | |
|
| 1770 | |
|
| 1771 | |
|
| 1772 | |
@Deprecated |
| 1773 | |
public void notationProviderRemoved(ArgoNotationEvent event) { |
| 1774 | |
|
| 1775 | 0 | } |
| 1776 | |
|
| 1777 | |
|
| 1778 | |
|
| 1779 | |
|
| 1780 | |
|
| 1781 | |
|
| 1782 | |
|
| 1783 | |
|
| 1784 | |
|
| 1785 | |
public void renderingChanged() { |
| 1786 | 0 | initNotationProviders(getOwner()); |
| 1787 | 0 | updateNameText(); |
| 1788 | 0 | updateStereotypeText(); |
| 1789 | 0 | updateStereotypeIcon(); |
| 1790 | 0 | updateBounds(); |
| 1791 | 0 | damage(); |
| 1792 | 0 | } |
| 1793 | |
|
| 1794 | |
protected void updateStereotypeIcon() { |
| 1795 | 0 | if (getOwner() == null) { |
| 1796 | 0 | LOG.warn("Owner of [" + this.toString() + "/" + this.getClass() |
| 1797 | |
+ "] is null."); |
| 1798 | 0 | LOG.warn("I return..."); |
| 1799 | 0 | return; |
| 1800 | |
} |
| 1801 | |
|
| 1802 | 0 | if (stereotypeFigProfileIcon != null) { |
| 1803 | 0 | for (Object fig : getFigs()) { |
| 1804 | 0 | ((Fig) fig).setVisible(fig != stereotypeFigProfileIcon); |
| 1805 | |
} |
| 1806 | |
|
| 1807 | 0 | this.removeFig(stereotypeFigProfileIcon); |
| 1808 | 0 | stereotypeFigProfileIcon = null; |
| 1809 | |
} |
| 1810 | |
|
| 1811 | 0 | if (originalNameFig != null) { |
| 1812 | 0 | this.setNameFig(originalNameFig); |
| 1813 | 0 | originalNameFig = null; |
| 1814 | |
} |
| 1815 | |
|
| 1816 | 0 | for (Fig icon : floatingStereotypes) { |
| 1817 | 0 | this.removeFig(icon); |
| 1818 | |
} |
| 1819 | 0 | floatingStereotypes.clear(); |
| 1820 | |
|
| 1821 | |
|
| 1822 | 0 | int practicalView = getPracticalView(); |
| 1823 | 0 | Object modelElement = getOwner(); |
| 1824 | 0 | Collection stereos = Model.getFacade().getStereotypes(modelElement); |
| 1825 | |
|
| 1826 | 0 | boolean hiding = |
| 1827 | |
practicalView == DiagramAppearance.STEREOTYPE_VIEW_SMALL_ICON; |
| 1828 | 0 | if (getStereotypeFig() != null) { |
| 1829 | 0 | getStereotypeFig().setHidingStereotypesWithIcon(hiding); |
| 1830 | |
} |
| 1831 | |
|
| 1832 | 0 | if (practicalView == DiagramAppearance.STEREOTYPE_VIEW_BIG_ICON) { |
| 1833 | |
|
| 1834 | 0 | Image replaceIcon = null; |
| 1835 | |
|
| 1836 | 0 | if (stereos.size() == 1) { |
| 1837 | 0 | Object stereo = stereos.iterator().next(); |
| 1838 | |
|
| 1839 | 0 | replaceIcon = getProject() |
| 1840 | |
.getProfileConfiguration().getFigNodeStrategy() |
| 1841 | |
.getIconForStereotype(stereo); |
| 1842 | |
} |
| 1843 | |
|
| 1844 | 0 | if (replaceIcon != null) { |
| 1845 | 0 | stereotypeFigProfileIcon = new FigProfileIcon(settings, |
| 1846 | |
replaceIcon, getName()); |
| 1847 | 0 | stereotypeFigProfileIcon.setOwner(getOwner()); |
| 1848 | |
|
| 1849 | 0 | stereotypeFigProfileIcon.setLocation(getBigPort() |
| 1850 | |
.getLocation()); |
| 1851 | 0 | addFig(stereotypeFigProfileIcon); |
| 1852 | |
|
| 1853 | 0 | originalNameFig = this.getNameFig(); |
| 1854 | 0 | final FigText labelFig = |
| 1855 | |
stereotypeFigProfileIcon.getLabelFig(); |
| 1856 | 0 | setNameFig(labelFig); |
| 1857 | |
|
| 1858 | 0 | labelFig.addPropertyChangeListener(this); |
| 1859 | |
|
| 1860 | 0 | getBigPort().setBounds(stereotypeFigProfileIcon.getBounds()); |
| 1861 | |
|
| 1862 | 0 | for (Object fig : getFigs()) { |
| 1863 | 0 | ((Fig) fig).setVisible(fig == stereotypeFigProfileIcon); |
| 1864 | |
} |
| 1865 | |
|
| 1866 | |
} |
| 1867 | 0 | } else if (practicalView |
| 1868 | |
== DiagramAppearance.STEREOTYPE_VIEW_SMALL_ICON) { |
| 1869 | 0 | int i = this.getX() + this.getWidth() - ICON_WIDTH - 2; |
| 1870 | |
|
| 1871 | 0 | for (Object stereo : stereos) { |
| 1872 | |
|
| 1873 | 0 | Image icon = getProject() |
| 1874 | |
.getProfileConfiguration().getFigNodeStrategy() |
| 1875 | |
.getIconForStereotype(stereo); |
| 1876 | 0 | if (icon != null) { |
| 1877 | 0 | FigImage fimg = new FigImage(i, |
| 1878 | |
this.getBigPort().getY() + 2, icon); |
| 1879 | 0 | fimg.setSize(ICON_WIDTH, |
| 1880 | |
(icon.getHeight(null) * ICON_WIDTH) |
| 1881 | |
/ icon.getWidth(null)); |
| 1882 | |
|
| 1883 | 0 | addFig(fimg); |
| 1884 | 0 | floatingStereotypes.add(fimg); |
| 1885 | |
|
| 1886 | 0 | i -= ICON_WIDTH - 2; |
| 1887 | |
} |
| 1888 | 0 | } |
| 1889 | |
|
| 1890 | 0 | updateSmallIcons(this.getWidth()); |
| 1891 | |
} |
| 1892 | |
|
| 1893 | |
|
| 1894 | 0 | updateStereotypeText(); |
| 1895 | |
|
| 1896 | 0 | damage(); |
| 1897 | 0 | calcBounds(); |
| 1898 | 0 | updateEdges(); |
| 1899 | 0 | updateBounds(); |
| 1900 | 0 | redraw(); |
| 1901 | 0 | } |
| 1902 | |
|
| 1903 | |
|
| 1904 | |
|
| 1905 | |
|
| 1906 | |
public void calcBounds() { |
| 1907 | 2142 | if (suppressCalcBounds) { |
| 1908 | 0 | return; |
| 1909 | |
} |
| 1910 | 2142 | super.calcBounds(); |
| 1911 | 2142 | } |
| 1912 | |
|
| 1913 | |
|
| 1914 | |
|
| 1915 | |
|
| 1916 | |
|
| 1917 | |
|
| 1918 | |
public void enableSizeChecking(boolean flag) { |
| 1919 | 0 | checkSize = flag; |
| 1920 | 0 | } |
| 1921 | |
|
| 1922 | |
|
| 1923 | |
|
| 1924 | |
|
| 1925 | |
|
| 1926 | |
|
| 1927 | |
@Override |
| 1928 | |
public boolean hit(Rectangle r) { |
| 1929 | 0 | int cornersHit = countCornersContained(r.x, r.y, r.width, r.height); |
| 1930 | 0 | if (_filled) { |
| 1931 | 0 | return cornersHit > 0 || intersects(r); |
| 1932 | |
} |
| 1933 | 0 | return (cornersHit > 0 && cornersHit < 4) || intersects(r); |
| 1934 | |
} |
| 1935 | |
|
| 1936 | |
|
| 1937 | |
|
| 1938 | |
|
| 1939 | |
@Override |
| 1940 | |
public final void removeFromDiagram() { |
| 1941 | 0 | Fig delegate = getRemoveDelegate(); |
| 1942 | 0 | if (delegate instanceof FigNodeModelElement) { |
| 1943 | 0 | ((FigNodeModelElement) delegate).removeFromDiagramImpl(); |
| 1944 | 0 | } else if (delegate instanceof FigEdgeModelElement) { |
| 1945 | 0 | ((FigEdgeModelElement) delegate).removeFromDiagramImpl(); |
| 1946 | 0 | } else if (delegate != null) { |
| 1947 | 0 | removeFromDiagramImpl(); |
| 1948 | |
} |
| 1949 | 0 | } |
| 1950 | |
|
| 1951 | |
|
| 1952 | |
|
| 1953 | |
|
| 1954 | |
|
| 1955 | |
|
| 1956 | |
|
| 1957 | |
|
| 1958 | |
protected Fig getRemoveDelegate() { |
| 1959 | 0 | return this; |
| 1960 | |
} |
| 1961 | |
|
| 1962 | |
|
| 1963 | |
|
| 1964 | |
|
| 1965 | |
|
| 1966 | |
|
| 1967 | |
|
| 1968 | |
protected void removeFromDiagramImpl() { |
| 1969 | 0 | if (notationProviderName != null) { |
| 1970 | 0 | notationProviderName.cleanListener(); |
| 1971 | |
} |
| 1972 | 0 | removeAllElementListeners(); |
| 1973 | 0 | setShadowSize(0); |
| 1974 | 0 | super.removeFromDiagram(); |
| 1975 | |
|
| 1976 | 0 | if (getStereotypeFig() != null) { |
| 1977 | 0 | getStereotypeFig().removeFromDiagram(); |
| 1978 | |
} |
| 1979 | 0 | } |
| 1980 | |
|
| 1981 | |
|
| 1982 | |
|
| 1983 | |
|
| 1984 | |
|
| 1985 | |
|
| 1986 | |
protected FigStereotypesGroup getStereotypeFig() { |
| 1987 | 0 | return stereotypeFig; |
| 1988 | |
} |
| 1989 | |
|
| 1990 | |
|
| 1991 | |
|
| 1992 | |
|
| 1993 | |
|
| 1994 | |
|
| 1995 | |
|
| 1996 | |
|
| 1997 | |
protected void setBigPort(Fig bp) { |
| 1998 | 0 | this.bigPort = bp; |
| 1999 | 0 | bindPort(getOwner(), bigPort); |
| 2000 | 0 | } |
| 2001 | |
|
| 2002 | |
|
| 2003 | |
|
| 2004 | |
|
| 2005 | |
public Fig getBigPort() { |
| 2006 | 1071 | return bigPort; |
| 2007 | |
} |
| 2008 | |
|
| 2009 | |
|
| 2010 | |
|
| 2011 | |
|
| 2012 | |
protected boolean isCheckSize() { |
| 2013 | 0 | return checkSize; |
| 2014 | |
} |
| 2015 | |
|
| 2016 | |
|
| 2017 | |
|
| 2018 | |
|
| 2019 | |
public boolean isDragConnectable() { |
| 2020 | 0 | return false; |
| 2021 | |
} |
| 2022 | |
|
| 2023 | |
|
| 2024 | |
|
| 2025 | |
|
| 2026 | |
protected void setEncloser(Fig e) { |
| 2027 | 0 | this.encloser = e; |
| 2028 | 0 | } |
| 2029 | |
|
| 2030 | |
|
| 2031 | |
|
| 2032 | |
|
| 2033 | |
protected Fig getEncloser() { |
| 2034 | 0 | return encloser; |
| 2035 | |
} |
| 2036 | |
|
| 2037 | |
|
| 2038 | |
|
| 2039 | |
protected boolean isReadyToEdit() { |
| 2040 | 0 | return readyToEdit; |
| 2041 | |
} |
| 2042 | |
|
| 2043 | |
|
| 2044 | |
|
| 2045 | |
|
| 2046 | |
protected void setReadyToEdit(boolean v) { |
| 2047 | 0 | readyToEdit = v; |
| 2048 | 0 | } |
| 2049 | |
|
| 2050 | |
|
| 2051 | |
|
| 2052 | |
|
| 2053 | |
|
| 2054 | |
|
| 2055 | |
protected void setSuppressCalcBounds(boolean scb) { |
| 2056 | 0 | this.suppressCalcBounds = scb; |
| 2057 | 0 | } |
| 2058 | |
|
| 2059 | |
|
| 2060 | |
|
| 2061 | |
|
| 2062 | |
|
| 2063 | |
|
| 2064 | |
|
| 2065 | |
|
| 2066 | |
|
| 2067 | |
|
| 2068 | |
|
| 2069 | |
public void setVisible(boolean visible) { |
| 2070 | 0 | if (!visible && !invisibleAllowed) { |
| 2071 | 0 | throw new IllegalArgumentException( |
| 2072 | |
"Visibility of a FigNode should never be false"); |
| 2073 | |
} |
| 2074 | 0 | } |
| 2075 | |
|
| 2076 | |
|
| 2077 | |
|
| 2078 | |
|
| 2079 | |
|
| 2080 | |
|
| 2081 | |
|
| 2082 | |
|
| 2083 | |
|
| 2084 | |
public void displace (int xInc, int yInc) { |
| 2085 | |
List<Fig> figsVector; |
| 2086 | 0 | Rectangle rFig = getBounds(); |
| 2087 | 0 | setLocation(rFig.x + xInc, rFig.y + yInc); |
| 2088 | 0 | figsVector = ((List<Fig>) getEnclosedFigs().clone()); |
| 2089 | 0 | if (!figsVector.isEmpty()) { |
| 2090 | 0 | for (int i = 0; i < figsVector.size(); i++) { |
| 2091 | 0 | ((FigNodeModelElement) figsVector.get(i)) |
| 2092 | |
.displace(xInc, yInc); |
| 2093 | |
} |
| 2094 | |
} |
| 2095 | 0 | } |
| 2096 | |
|
| 2097 | |
|
| 2098 | |
|
| 2099 | |
|
| 2100 | |
|
| 2101 | |
protected void allowRemoveFromDiagram(boolean allowed) { |
| 2102 | 0 | this.removeFromDiagram = allowed; |
| 2103 | 0 | } |
| 2104 | |
|
| 2105 | |
public void setDiElement(DiElement element) { |
| 2106 | 0 | this.diElement = element; |
| 2107 | 0 | } |
| 2108 | |
|
| 2109 | |
public DiElement getDiElement() { |
| 2110 | 0 | return diElement; |
| 2111 | |
} |
| 2112 | |
|
| 2113 | |
|
| 2114 | |
|
| 2115 | |
|
| 2116 | |
protected static int getPopupAddOffset() { |
| 2117 | 0 | return popupAddOffset; |
| 2118 | |
} |
| 2119 | |
|
| 2120 | |
|
| 2121 | |
|
| 2122 | |
|
| 2123 | |
|
| 2124 | |
public boolean isEditable() { |
| 2125 | 0 | return editable; |
| 2126 | |
} |
| 2127 | |
|
| 2128 | |
|
| 2129 | |
|
| 2130 | |
|
| 2131 | |
|
| 2132 | |
|
| 2133 | |
|
| 2134 | |
|
| 2135 | |
|
| 2136 | |
protected void setEditable(boolean canEdit) { |
| 2137 | 0 | this.editable = canEdit; |
| 2138 | 0 | } |
| 2139 | |
|
| 2140 | |
|
| 2141 | |
|
| 2142 | |
|
| 2143 | |
|
| 2144 | |
|
| 2145 | |
|
| 2146 | |
|
| 2147 | |
protected void addElementListener(Object element) { |
| 2148 | 0 | listeners.add(new Object[] {element, null}); |
| 2149 | 0 | Model.getPump().addModelEventListener(this, element); |
| 2150 | 0 | } |
| 2151 | |
|
| 2152 | |
|
| 2153 | |
|
| 2154 | |
|
| 2155 | |
|
| 2156 | |
|
| 2157 | |
|
| 2158 | |
|
| 2159 | |
|
| 2160 | |
|
| 2161 | |
|
| 2162 | |
protected void addElementListener(Object element, String property) { |
| 2163 | 0 | listeners.add(new Object[] {element, property}); |
| 2164 | 0 | Model.getPump().addModelEventListener(this, element, property); |
| 2165 | 0 | } |
| 2166 | |
|
| 2167 | |
|
| 2168 | |
|
| 2169 | |
|
| 2170 | |
|
| 2171 | |
|
| 2172 | |
|
| 2173 | |
|
| 2174 | |
|
| 2175 | |
|
| 2176 | |
|
| 2177 | |
|
| 2178 | |
protected void addElementListener(Object element, String[] property) { |
| 2179 | 0 | listeners.add(new Object[] {element, property}); |
| 2180 | 0 | Model.getPump().addModelEventListener(this, element, property); |
| 2181 | 0 | } |
| 2182 | |
|
| 2183 | |
|
| 2184 | |
|
| 2185 | |
|
| 2186 | |
|
| 2187 | |
|
| 2188 | |
|
| 2189 | |
|
| 2190 | |
protected void removeElementListener(Object element) { |
| 2191 | 0 | listeners.remove(new Object[] {element, null}); |
| 2192 | 0 | Model.getPump().removeModelEventListener(this, element); |
| 2193 | 0 | } |
| 2194 | |
|
| 2195 | |
|
| 2196 | |
|
| 2197 | |
|
| 2198 | |
|
| 2199 | |
protected void removeAllElementListeners() { |
| 2200 | 0 | removeElementListeners(listeners); |
| 2201 | 0 | } |
| 2202 | |
|
| 2203 | |
private void removeElementListeners(Set<Object[]> listenerSet) { |
| 2204 | 0 | for (Object[] listener : listenerSet) { |
| 2205 | 0 | Object property = listener[1]; |
| 2206 | 0 | if (property == null) { |
| 2207 | 0 | Model.getPump().removeModelEventListener(this, listener[0]); |
| 2208 | 0 | } else if (property instanceof String[]) { |
| 2209 | 0 | Model.getPump().removeModelEventListener(this, listener[0], |
| 2210 | |
(String[]) property); |
| 2211 | 0 | } else if (property instanceof String) { |
| 2212 | 0 | Model.getPump().removeModelEventListener(this, listener[0], |
| 2213 | |
(String) property); |
| 2214 | |
} else { |
| 2215 | 0 | throw new RuntimeException( |
| 2216 | |
"Internal error in removeAllElementListeners"); |
| 2217 | |
} |
| 2218 | 0 | } |
| 2219 | 0 | listeners.removeAll(listenerSet); |
| 2220 | 0 | } |
| 2221 | |
|
| 2222 | |
private void addElementListeners(Set<Object[]> listenerSet) { |
| 2223 | 0 | for (Object[] listener : listenerSet) { |
| 2224 | 0 | Object property = listener[1]; |
| 2225 | 0 | if (property == null) { |
| 2226 | 0 | addElementListener(listener[0]); |
| 2227 | 0 | } else if (property instanceof String[]) { |
| 2228 | 0 | addElementListener(listener[0], (String[]) property); |
| 2229 | 0 | } else if (property instanceof String) { |
| 2230 | 0 | addElementListener(listener[0], (String) property); |
| 2231 | |
} else { |
| 2232 | 0 | throw new RuntimeException( |
| 2233 | |
"Internal error in addElementListeners"); |
| 2234 | |
} |
| 2235 | 0 | } |
| 2236 | 0 | } |
| 2237 | |
|
| 2238 | |
|
| 2239 | |
|
| 2240 | |
|
| 2241 | |
|
| 2242 | |
|
| 2243 | |
|
| 2244 | |
|
| 2245 | |
|
| 2246 | |
protected void updateElementListeners(Set<Object[]> listenerSet) { |
| 2247 | 0 | Set<Object[]> removes = new HashSet<Object[]>(listeners); |
| 2248 | 0 | removes.removeAll(listenerSet); |
| 2249 | 0 | removeElementListeners(removes); |
| 2250 | |
|
| 2251 | 0 | Set<Object[]> adds = new HashSet<Object[]>(listenerSet); |
| 2252 | 0 | adds.removeAll(listeners); |
| 2253 | 0 | addElementListeners(adds); |
| 2254 | 0 | } |
| 2255 | |
|
| 2256 | |
|
| 2257 | |
|
| 2258 | |
|
| 2259 | |
|
| 2260 | |
|
| 2261 | |
|
| 2262 | |
|
| 2263 | |
|
| 2264 | |
@SuppressWarnings("deprecation") |
| 2265 | |
@Deprecated |
| 2266 | |
public void setProject(Project project) { |
| 2267 | 0 | throw new UnsupportedOperationException(); |
| 2268 | |
} |
| 2269 | |
|
| 2270 | |
|
| 2271 | |
|
| 2272 | |
|
| 2273 | |
|
| 2274 | |
|
| 2275 | |
|
| 2276 | |
|
| 2277 | |
@Deprecated |
| 2278 | |
public Project getProject() { |
| 2279 | 0 | return ArgoFigUtil.getProject(this); |
| 2280 | |
} |
| 2281 | |
|
| 2282 | |
|
| 2283 | |
|
| 2284 | |
|
| 2285 | |
|
| 2286 | |
|
| 2287 | |
protected boolean isSingleTarget() { |
| 2288 | 0 | return TargetManager.getInstance().getSingleModelTarget() |
| 2289 | |
== getOwner(); |
| 2290 | |
} |
| 2291 | |
|
| 2292 | |
|
| 2293 | |
|
| 2294 | |
|
| 2295 | |
|
| 2296 | |
|
| 2297 | |
public int getStereotypeView() { |
| 2298 | 0 | return stereotypeStyle.ordinal(); |
| 2299 | |
} |
| 2300 | |
|
| 2301 | |
|
| 2302 | |
|
| 2303 | |
|
| 2304 | |
|
| 2305 | |
public StereotypeStyle getStereotypeStyle() { |
| 2306 | 0 | return stereotypeStyle; |
| 2307 | |
} |
| 2308 | |
|
| 2309 | |
|
| 2310 | |
|
| 2311 | |
|
| 2312 | |
|
| 2313 | |
|
| 2314 | |
|
| 2315 | |
|
| 2316 | |
|
| 2317 | |
private int getPracticalView() { |
| 2318 | |
|
| 2319 | 0 | int practicalView = getStereotypeView(); |
| 2320 | 0 | Object modelElement = getOwner(); |
| 2321 | |
|
| 2322 | 0 | if (modelElement != null) { |
| 2323 | 0 | int stereotypeCount = getStereotypeCount(); |
| 2324 | |
|
| 2325 | 0 | if (getStereotypeView() |
| 2326 | |
== DiagramAppearance.STEREOTYPE_VIEW_BIG_ICON) { |
| 2327 | |
|
| 2328 | 0 | FigNodeStrategy figNodeStrategy = getProject() |
| 2329 | |
.getProfileConfiguration().getFigNodeStrategy(); |
| 2330 | 0 | Iterator<FigStereotype> figsIterator = getStereotypeFig() |
| 2331 | |
.getStereotypeFigs().iterator(); |
| 2332 | 0 | Object owner = figsIterator.hasNext() ? |
| 2333 | |
figsIterator.next().getOwner() : null; |
| 2334 | 0 | if (stereotypeCount != 1 |
| 2335 | |
|| figNodeStrategy == null |
| 2336 | |
|| owner == null |
| 2337 | |
|| (stereotypeCount == 1 |
| 2338 | |
&& figNodeStrategy.getIconForStereotype(owner) |
| 2339 | |
== null)) { |
| 2340 | 0 | practicalView = DiagramAppearance.STEREOTYPE_VIEW_TEXTUAL; |
| 2341 | |
} |
| 2342 | |
} |
| 2343 | |
} |
| 2344 | 0 | return practicalView; |
| 2345 | |
} |
| 2346 | |
|
| 2347 | |
|
| 2348 | |
|
| 2349 | |
|
| 2350 | |
|
| 2351 | |
public int getStereotypeCount() { |
| 2352 | 0 | if (getStereotypeFig() == null) { |
| 2353 | 0 | return 0; |
| 2354 | |
} |
| 2355 | 0 | return getStereotypeFig().getStereotypeCount(); |
| 2356 | |
} |
| 2357 | |
|
| 2358 | |
|
| 2359 | |
|
| 2360 | |
|
| 2361 | |
|
| 2362 | |
|
| 2363 | |
|
| 2364 | |
|
| 2365 | |
public void setStereotypeView(int s) { |
| 2366 | 0 | setStereotypeStyle(StereotypeStyle.getEnum(s)); |
| 2367 | 0 | } |
| 2368 | |
|
| 2369 | |
|
| 2370 | |
|
| 2371 | |
|
| 2372 | |
|
| 2373 | |
|
| 2374 | |
public void setStereotypeStyle(StereotypeStyle style) { |
| 2375 | 0 | stereotypeStyle = style; |
| 2376 | 0 | renderingChanged(); |
| 2377 | 0 | } |
| 2378 | |
|
| 2379 | |
|
| 2380 | |
|
| 2381 | |
|
| 2382 | |
|
| 2383 | |
|
| 2384 | |
|
| 2385 | |
|
| 2386 | |
|
| 2387 | |
|
| 2388 | |
@Override |
| 2389 | |
protected void setBoundsImpl(final int x, final int y, final int w, |
| 2390 | |
final int h) { |
| 2391 | |
|
| 2392 | 0 | if (getPracticalView() == DiagramAppearance.STEREOTYPE_VIEW_BIG_ICON) { |
| 2393 | 0 | if (stereotypeFigProfileIcon != null) { |
| 2394 | 0 | stereotypeFigProfileIcon.setBounds(stereotypeFigProfileIcon |
| 2395 | |
.getX(), stereotypeFigProfileIcon.getY(), w, h); |
| 2396 | |
|
| 2397 | |
|
| 2398 | |
} |
| 2399 | |
} else { |
| 2400 | 0 | setStandardBounds(x, y, w, h); |
| 2401 | 0 | if (getStereotypeView() |
| 2402 | |
== DiagramAppearance.STEREOTYPE_VIEW_SMALL_ICON) { |
| 2403 | 0 | updateSmallIcons(w); |
| 2404 | |
} |
| 2405 | |
} |
| 2406 | 0 | } |
| 2407 | |
|
| 2408 | |
private void updateSmallIcons(int wid) { |
| 2409 | 0 | int i = this.getX() + wid - ICON_WIDTH - 2; |
| 2410 | |
|
| 2411 | 0 | for (Fig ficon : floatingStereotypes) { |
| 2412 | 0 | ficon.setLocation(i, this.getBigPort().getY() + 2); |
| 2413 | 0 | i -= ICON_WIDTH - 2; |
| 2414 | |
} |
| 2415 | |
|
| 2416 | 0 | getNameFig().setRightMargin( |
| 2417 | |
floatingStereotypes.size() * (ICON_WIDTH + 5)); |
| 2418 | 0 | } |
| 2419 | |
|
| 2420 | |
|
| 2421 | |
|
| 2422 | |
|
| 2423 | |
|
| 2424 | |
|
| 2425 | |
|
| 2426 | |
|
| 2427 | |
|
| 2428 | |
|
| 2429 | |
@Override |
| 2430 | |
public Dimension getMinimumSize() { |
| 2431 | 0 | assert isResizable(); |
| 2432 | 0 | return super.getMinimumSize(); |
| 2433 | |
} |
| 2434 | |
|
| 2435 | |
|
| 2436 | |
|
| 2437 | |
|
| 2438 | |
|
| 2439 | |
|
| 2440 | |
|
| 2441 | |
|
| 2442 | |
|
| 2443 | |
|
| 2444 | |
protected void setStandardBounds(final int x, final int y, |
| 2445 | |
final int w, final int h) { |
| 2446 | |
|
| 2447 | 0 | } |
| 2448 | |
|
| 2449 | |
|
| 2450 | |
|
| 2451 | |
|
| 2452 | |
|
| 2453 | |
|
| 2454 | |
|
| 2455 | |
|
| 2456 | |
public void diagramFontChanged(ArgoDiagramAppearanceEvent e) { |
| 2457 | 0 | updateFont(); |
| 2458 | 0 | updateBounds(); |
| 2459 | 0 | damage(); |
| 2460 | 0 | } |
| 2461 | |
|
| 2462 | |
|
| 2463 | |
|
| 2464 | |
|
| 2465 | |
|
| 2466 | |
|
| 2467 | |
|
| 2468 | |
|
| 2469 | |
|
| 2470 | |
protected void updateFont() { |
| 2471 | 0 | int style = getNameFigFontStyle(); |
| 2472 | 0 | Font f = getSettings().getFont(style); |
| 2473 | 0 | nameFig.setFont(f); |
| 2474 | 0 | deepUpdateFont(this); |
| 2475 | 0 | } |
| 2476 | |
|
| 2477 | |
|
| 2478 | |
|
| 2479 | |
|
| 2480 | |
|
| 2481 | |
|
| 2482 | |
|
| 2483 | |
|
| 2484 | |
|
| 2485 | |
protected int getNameFigFontStyle() { |
| 2486 | |
|
| 2487 | |
|
| 2488 | 0 | showBoldName = getSettings().isShowBoldNames(); |
| 2489 | 0 | return showBoldName ? Font.BOLD : Font.PLAIN; |
| 2490 | |
} |
| 2491 | |
|
| 2492 | |
|
| 2493 | |
|
| 2494 | |
|
| 2495 | |
|
| 2496 | |
|
| 2497 | |
|
| 2498 | |
|
| 2499 | |
|
| 2500 | |
|
| 2501 | |
|
| 2502 | |
|
| 2503 | |
private void deepUpdateFont(FigGroup fg) { |
| 2504 | |
|
| 2505 | |
|
| 2506 | 0 | boolean changed = false; |
| 2507 | 0 | List<Fig> figs = fg.getFigs(); |
| 2508 | 0 | for (Fig f : figs) { |
| 2509 | 0 | if (f instanceof ArgoFigText) { |
| 2510 | 0 | ((ArgoFigText) f).renderingChanged(); |
| 2511 | 0 | changed = true; |
| 2512 | |
} |
| 2513 | 0 | if (f instanceof FigGroup) { |
| 2514 | 0 | deepUpdateFont((FigGroup) f); |
| 2515 | |
} |
| 2516 | |
} |
| 2517 | 0 | if (changed) { |
| 2518 | 0 | fg.calcBounds(); |
| 2519 | |
} |
| 2520 | 0 | } |
| 2521 | |
|
| 2522 | |
|
| 2523 | |
public DiagramSettings getSettings() { |
| 2524 | |
|
| 2525 | |
|
| 2526 | 3213 | if (settings == null) { |
| 2527 | 0 | LOG.debug("Falling back to project-wide settings"); |
| 2528 | 0 | Project p = getProject(); |
| 2529 | 0 | if (p != null) { |
| 2530 | 0 | return p.getProjectSettings().getDefaultDiagramSettings(); |
| 2531 | |
} |
| 2532 | |
} |
| 2533 | 3213 | return settings; |
| 2534 | |
} |
| 2535 | |
|
| 2536 | |
public void setSettings(DiagramSettings renderSettings) { |
| 2537 | 0 | settings = renderSettings; |
| 2538 | 0 | renderingChanged(); |
| 2539 | 0 | } |
| 2540 | |
|
| 2541 | |
protected NotationSettings getNotationSettings() { |
| 2542 | 0 | return notationSettings; |
| 2543 | |
} |
| 2544 | |
|
| 2545 | |
public void setLineWidth(int w) { |
| 2546 | 0 | super.setLineWidth(w); |
| 2547 | |
|
| 2548 | 0 | getNameFig().setLineWidth(0); |
| 2549 | 0 | if (getStereotypeFig() != null) { |
| 2550 | 0 | getStereotypeFig().setLineWidth(0); |
| 2551 | |
} |
| 2552 | 0 | } |
| 2553 | |
|
| 2554 | |
|
| 2555 | |
|
| 2556 | |
|
| 2557 | |
|
| 2558 | 0 | class SelectionDefaultClarifiers extends SelectionNodeClarifiers2 { |
| 2559 | |
|
| 2560 | |
|
| 2561 | |
|
| 2562 | |
|
| 2563 | |
|
| 2564 | 0 | private SelectionDefaultClarifiers(Fig f) { |
| 2565 | 0 | super(f); |
| 2566 | 0 | } |
| 2567 | |
|
| 2568 | |
@Override |
| 2569 | |
protected Icon[] getIcons() { |
| 2570 | 0 | return null; |
| 2571 | |
} |
| 2572 | |
|
| 2573 | |
@Override |
| 2574 | |
protected String getInstructions(int index) { |
| 2575 | 0 | return null; |
| 2576 | |
} |
| 2577 | |
|
| 2578 | |
@Override |
| 2579 | |
protected Object getNewNodeType(int index) { |
| 2580 | 0 | return null; |
| 2581 | |
} |
| 2582 | |
|
| 2583 | |
@Override |
| 2584 | |
protected Object getNewEdgeType(int index) { |
| 2585 | 0 | return null; |
| 2586 | |
} |
| 2587 | |
|
| 2588 | |
@Override |
| 2589 | |
protected boolean isReverseEdge(int index) { |
| 2590 | 0 | return false; |
| 2591 | |
} |
| 2592 | |
} |
| 2593 | |
|
| 2594 | |
|
| 2595 | |
|
| 2596 | |
|
| 2597 | |
|
| 2598 | |
|
| 2599 | |
|
| 2600 | |
|
| 2601 | |
|
| 2602 | |
|
| 2603 | |
|
| 2604 | |
|
| 2605 | |
|
| 2606 | |
@SuppressWarnings("deprecation") |
| 2607 | |
@Deprecated |
| 2608 | |
public void setOwner(Object owner) { |
| 2609 | 0 | if (owner != getOwner()) { |
| 2610 | 0 | throw new UnsupportedOperationException( |
| 2611 | |
"Owner must be set in constructor and left unchanged"); |
| 2612 | |
} |
| 2613 | 0 | } |
| 2614 | |
|
| 2615 | |
|
| 2616 | |
|
| 2617 | |
|
| 2618 | |
@Override |
| 2619 | |
public void bindPort(Object port, Fig f) { |
| 2620 | 0 | if (f.getOwner() != port) { |
| 2621 | 0 | f.setOwner(port); |
| 2622 | |
} |
| 2623 | 0 | } |
| 2624 | |
|
| 2625 | |
public void notationRenderingChanged(NotationProvider np, String rendering) { |
| 2626 | 0 | if (notationProviderName == np) { |
| 2627 | 0 | nameFig.setText(rendering); |
| 2628 | 0 | updateBounds(); |
| 2629 | 0 | damage(); |
| 2630 | |
} |
| 2631 | 0 | } |
| 2632 | |
|
| 2633 | |
public NotationSettings getNotationSettings(NotationProvider np) { |
| 2634 | 0 | if (notationProviderName == np) { |
| 2635 | 0 | return getNotationSettings(); |
| 2636 | |
} |
| 2637 | 0 | return null; |
| 2638 | |
} |
| 2639 | |
|
| 2640 | |
public Object getOwner(NotationProvider np) { |
| 2641 | 0 | if (notationProviderName == np) { |
| 2642 | 0 | return getOwner(); |
| 2643 | |
} |
| 2644 | 0 | return null; |
| 2645 | |
} |
| 2646 | |
} |