}
try {
- String valid = validateDrop(synchronizer.getSession(), r,
+ Object errorOrSymbolResource = validateDrop(synchronizer.getSession(), r,
diagram.<Resource> getHint(DiagramModelHints.KEY_DIAGRAM_RESOURCE));
- if (valid == null) {
- ElementClassDragItem item = new ElementClassDragItem(synchronizer.getNodeClass(r));
+ if (errorOrSymbolResource instanceof Resource) {
+ ElementClassDragItem item = new ElementClassDragItem(synchronizer.getNodeClass((Resource)errorOrSymbolResource));
item.getHintContext().setHint(ElementHints.KEY_TRANSFORM, AffineTransform.getScaleInstance(1, 1));
dp.add(item);
}
}
}
- private String validateDrop(RequestProcessor processor, final Resource draggedResource, final Resource dropTarget) throws DatabaseException {
- return processor.syncRequest(new UniqueRead<String>() {
+ private Object validateDrop(RequestProcessor processor, final Resource draggedResource, final Resource dropTarget) throws DatabaseException {
+ return processor.syncRequest(new UniqueRead<Object>() {
@Override
- public String perform(ReadGraph graph) throws DatabaseException {
+ public Object perform(ReadGraph graph) throws DatabaseException {
// System.out.println("dragged resource: " + draggedResource);
// System.out.println("drop target resource: " + dropTarget);
Resource sourceModel = graph.syncRequest(new PossibleIndexRoot(draggedResource));
}
}
+ // Check if dragged object is symbol or component type and determine other
+ Resource componentType;
+ Resource symbol = graph.getPossibleObject(draggedResource, MOD.ComponentTypeToSymbol);
+
+ if(symbol != null)
+ componentType = draggedResource;
+ else {
+ componentType = graph.getPossibleObject(draggedResource, MOD.SymbolToComponentType);
+ symbol = draggedResource;
+ }
+
// Prevent dragging a symbol of component type into its own configuration.
- Resource componentTypeFromSymbol = graph.getPossibleObject(draggedResource, MOD.SymbolToComponentType);
- if (componentTypeFromSymbol != null) {
+ if (componentType != null) {
if (configuration != null) {
Resource componentTypeFromDiagram = graph.getPossibleObject(configuration, STR.Defines);
- if (componentTypeFromDiagram != null && componentTypeFromSymbol.equals(componentTypeFromDiagram)) {
+ if (componentTypeFromDiagram != null && componentType.equals(componentTypeFromDiagram)) {
return "Cannot instantiate user component within its own configuration.";
}
}
}
- return null;
+ return symbol;
}
});
}