|
Lines 74-79
Link Here
|
| 74 |
import org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper; |
74 |
import org.eclipse.papyrus.uml.diagram.common.helper.PreferenceInitializerForElementHelper; |
| 75 |
import org.eclipse.papyrus.uml.diagram.common.providers.UIAdapterImpl; |
75 |
import org.eclipse.papyrus.uml.diagram.common.providers.UIAdapterImpl; |
| 76 |
import org.eclipse.papyrus.uml.diagram.common.util.MessageDirection; |
76 |
import org.eclipse.papyrus.uml.diagram.common.util.MessageDirection; |
|
|
77 |
import org.eclipse.papyrus.uml.diagram.sequence.edit.helpers.AnchorHelper; |
| 77 |
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.InteractionItemSemanticEditPolicy; |
78 |
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.InteractionItemSemanticEditPolicy; |
| 78 |
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.SequenceGraphicalNodeEditPolicy; |
79 |
import org.eclipse.papyrus.uml.diagram.sequence.edit.policies.SequenceGraphicalNodeEditPolicy; |
| 79 |
import org.eclipse.papyrus.uml.diagram.sequence.part.UMLDiagramEditorPlugin; |
80 |
import org.eclipse.papyrus.uml.diagram.sequence.part.UMLDiagramEditorPlugin; |
|
Lines 273-336
Link Here
|
| 273 |
return getContentPane(); |
274 |
return getContentPane(); |
| 274 |
} |
275 |
} |
| 275 |
|
276 |
|
| 276 |
static class SlidableAnchorEx extends SlidableAnchor{ |
|
|
| 277 |
private PrecisionPoint percent; |
| 278 |
private IFigure figure; |
| 279 |
|
| 280 |
SlidableAnchorEx(IFigure fig, PrecisionPoint percent) { |
| 281 |
super(fig,percent); |
| 282 |
this.figure = fig; |
| 283 |
this.percent = percent; |
| 284 |
} |
| 285 |
|
| 286 |
static SlidableAnchorEx createAnchorAtLocation(IFigure fig, PrecisionPoint loc) { |
| 287 |
PrecisionPoint p = loc.getPreciseCopy(); |
| 288 |
Rectangle b = fig.getBounds().getCopy(); |
| 289 |
fig.translateToAbsolute(b); |
| 290 |
|
| 291 |
Dimension d = p.getDifference(b.getTopLeft()); |
| 292 |
PrecisionPoint per = new PrecisionPoint( d.preciseWidth()/ b.width , d.preciseHeight() / b.height); |
| 293 |
return new SlidableAnchorEx(fig, per); |
| 294 |
} |
| 295 |
|
| 296 |
protected Point getLocation(Point ownReference, Point foreignReference) { |
| 297 |
// PointList intersections = getIntersectionPoints(ownReference, foreignReference); |
| 298 |
// if (intersections!=null && intersections.size()!=0) { |
| 299 |
// int size = intersections.size(); |
| 300 |
// double dist = foreignReference.getDistance(ownReference); |
| 301 |
// for(int i = 0; i < size; i ++){ |
| 302 |
// Point loc = intersections.getPoint(i); |
| 303 |
// if(isInOrder(foreignReference,ownReference,dist, loc)){ |
| 304 |
// return loc; |
| 305 |
// } |
| 306 |
// } |
| 307 |
// return intersections.getFirstPoint(); |
| 308 |
// } |
| 309 |
// return null; |
| 310 |
PrecisionRectangle bounds = new PrecisionRectangle(figure.getBounds()); |
| 311 |
bounds.setPreciseWidth((bounds.width * percent.preciseX())); |
| 312 |
bounds.setPreciseHeight((bounds.height * percent.preciseY())); |
| 313 |
figure.translateToAbsolute(bounds); |
| 314 |
return bounds.getBottomRight(); |
| 315 |
} |
| 316 |
|
| 317 |
// public String getTerminal() { |
| 318 |
// return super.getTerminal() ; |
| 319 |
// } |
| 320 |
// |
| 321 |
// private boolean isInOrder(Point start, Point end, double dist, Point loc) { |
| 322 |
// double total = loc.getDistance(start); |
| 323 |
// double dist2 = loc.getDistance(end); |
| 324 |
// if(total < dist || total < dist2) |
| 325 |
// return false; |
| 326 |
// |
| 327 |
// if(Math.abs(total - dist - dist2) < 0.01) |
| 328 |
// return true; |
| 329 |
// |
| 330 |
// return false; |
| 331 |
// } |
| 332 |
} |
| 333 |
|
| 334 |
/** |
277 |
/** |
| 335 |
* @generated |
278 |
* @generated |
| 336 |
*/ |
279 |
*/ |
|
Lines 341-353
Link Here
|
| 341 |
String preferenceConstantHeight = PreferenceInitializerForElementHelper.getpreferenceKey(getNotationView(), prefElementId, PreferenceConstantHelper.HEIGHT); |
284 |
String preferenceConstantHeight = PreferenceInitializerForElementHelper.getpreferenceKey(getNotationView(), prefElementId, PreferenceConstantHelper.HEIGHT); |
| 342 |
DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(store.getInt(preferenceConstantWitdh), store.getInt(preferenceConstantHeight)){ |
285 |
DefaultSizeNodeFigure result = new DefaultSizeNodeFigure(store.getInt(preferenceConstantWitdh), store.getInt(preferenceConstantHeight)){ |
| 343 |
|
286 |
|
| 344 |
// protected ConnectionAnchor createAnchor(PrecisionPoint p) { |
287 |
protected ConnectionAnchor createAnchor(PrecisionPoint p) { |
| 345 |
// if (p==null) |
288 |
if (p==null) |
| 346 |
// // If the old terminal for the connection anchor cannot be resolved (by SlidableAnchor) a null |
289 |
// If the old terminal for the connection anchor cannot be resolved (by SlidableAnchor) a null |
| 347 |
// // PrecisionPoint will passed in - this is handled here |
290 |
// PrecisionPoint will passed in - this is handled here |
| 348 |
// return createDefaultAnchor(); |
291 |
return createDefaultAnchor(); |
| 349 |
// return new SlidableAnchorEx(this, p); |
292 |
return new AnchorHelper.IntersectionPointAnchor(this, p); |
| 350 |
// } |
293 |
} |
| 351 |
}; |
294 |
}; |
| 352 |
|
295 |
|
| 353 |
return result; |
296 |
return result; |
|
Lines 1312-1321
Link Here
|
| 1312 |
@Override |
1255 |
@Override |
| 1313 |
public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connEditPart) { |
1256 |
public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connEditPart) { |
| 1314 |
if(connEditPart instanceof Message7EditPart){ |
1257 |
if(connEditPart instanceof Message7EditPart){ |
| 1315 |
String terminal = getAnchorId(connEditPart,true); |
1258 |
String terminal = AnchorHelper.getAnchorId(getEditingDomain(), connEditPart,true); |
| 1316 |
if(terminal.length() > 0){ |
1259 |
if(terminal.length() > 0){ |
| 1317 |
PrecisionPoint pt = SlidableAnchor.parseTerminalString(terminal); |
1260 |
PrecisionPoint pt = SlidableAnchor.parseTerminalString(terminal); |
| 1318 |
return new SlidableAnchorEx(getFigure(),pt); |
1261 |
return new AnchorHelper.InnerPointAnchor(getFigure(),pt); |
| 1319 |
} |
1262 |
} |
| 1320 |
} |
1263 |
} |
| 1321 |
|
1264 |
|
|
Lines 1347-1356
Link Here
|
| 1347 |
public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connEditPart) { |
1290 |
public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connEditPart) { |
| 1348 |
|
1291 |
|
| 1349 |
if(connEditPart instanceof Message6EditPart){ |
1292 |
if(connEditPart instanceof Message6EditPart){ |
| 1350 |
String terminal = getAnchorId(connEditPart, false); |
1293 |
String terminal = AnchorHelper.getAnchorId(getEditingDomain(), connEditPart, false); |
| 1351 |
if(terminal.length() > 0){ |
1294 |
if(terminal.length() > 0){ |
| 1352 |
PrecisionPoint pt = SlidableAnchor.parseTerminalString(terminal); |
1295 |
PrecisionPoint pt = SlidableAnchor.parseTerminalString(terminal); |
| 1353 |
return new SlidableAnchorEx(getFigure(),pt); |
1296 |
return new AnchorHelper.InnerPointAnchor(getFigure(),pt); |
| 1354 |
} |
1297 |
} |
| 1355 |
} |
1298 |
} |
| 1356 |
|
1299 |
|
|
Lines 1361-1398
Link Here
|
| 1361 |
// } |
1304 |
// } |
| 1362 |
return targetConnectionAnchor; |
1305 |
return targetConnectionAnchor; |
| 1363 |
} |
1306 |
} |
| 1364 |
|
|
|
| 1365 |
private String getAnchorId(ConnectionEditPart connEditPart, final boolean isSource) { |
| 1366 |
final org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart connection = |
| 1367 |
(org.eclipse.gmf.runtime.diagram.ui.editparts.ConnectionEditPart)connEditPart; |
| 1368 |
|
| 1369 |
String t = ""; //$NON-NLS-1$ |
| 1370 |
try { |
| 1371 |
t = (String) getEditingDomain().runExclusive( |
| 1372 |
new RunnableWithResult.Impl() { |
| 1373 |
|
| 1374 |
public void run() { |
| 1375 |
Anchor a = null; |
| 1376 |
if(isSource) |
| 1377 |
a = ((Edge)connection.getModel()).getSourceAnchor(); |
| 1378 |
else |
| 1379 |
a = ((Edge)connection.getModel()).getTargetAnchor(); |
| 1380 |
if (a instanceof IdentityAnchor) |
| 1381 |
setResult(((IdentityAnchor) a).getId()); |
| 1382 |
else |
| 1383 |
setResult(""); //$NON-NLS-1$ |
| 1384 |
} |
| 1385 |
}); |
| 1386 |
} catch (InterruptedException e) { |
| 1387 |
Trace.catching(DiagramUIPlugin.getInstance(), |
| 1388 |
DiagramUIDebugOptions.EXCEPTIONS_CATCHING, getClass(), |
| 1389 |
"getTargetConnectionAnchor", e); //$NON-NLS-1$ |
| 1390 |
Log.error(DiagramUIPlugin.getInstance(), |
| 1391 |
DiagramUIStatusCodes.IGNORED_EXCEPTION_WARNING, |
| 1392 |
"getTargetConnectionAnchor", e); //$NON-NLS-1$ |
| 1393 |
} |
| 1394 |
return t; |
| 1395 |
} |
| 1396 |
|
1307 |
|
| 1397 |
/** |
1308 |
/** |
| 1398 |
* Create Anchor |
1309 |
* Create Anchor |
|
Lines 1444-1450
Link Here
|
| 1444 |
*/ |
1355 |
*/ |
| 1445 |
private ConnectionAnchor createAnchor(Point location) { |
1356 |
private ConnectionAnchor createAnchor(Point location) { |
| 1446 |
//return new SlidableAnchor(getFigure(), BaseSlidableAnchor.getAnchorRelativeLocation(location, getFigure().getBounds())); |
1357 |
//return new SlidableAnchor(getFigure(), BaseSlidableAnchor.getAnchorRelativeLocation(location, getFigure().getBounds())); |
| 1447 |
return SlidableAnchorEx.createAnchorAtLocation(getFigure(), new PrecisionPoint(location)); |
1358 |
return AnchorHelper.InnerPointAnchor.createAnchorAtLocation(getFigure(), new PrecisionPoint(location)); |
| 1448 |
} |
1359 |
} |
| 1449 |
|
1360 |
|
| 1450 |
} |
1361 |
} |