use of org.whole.lang.ui.editparts.IEntityPart in project whole by wholeplatform.
the class NotationStyling method getEmbeddingStyle.
public EmbeddingStyle getEmbeddingStyle(IStylingFactory stylingFactory, IEntityPart contextPart, IEntity entity) {
if (!(contextPart instanceof IStyledPart))
return EmbeddingStyle.NONE;
IEntity parentEntity = stylingFactory.getParentEntity(entity);
IEntityPart parentContextPart = stylingFactory.getParentPart(contextPart);
IEntityStyling parentEntityStyling = getEntityStyling(stylingFactory, parentContextPart, parentEntity);
boolean embedChild = parentEntityStyling.embedChild(entity.wGetParent().wIndexOf(entity));
if (embedChild) {
switch(parentEntityStyling.getLayoutStyle()) {
case SIMPLE_TABLE:
return EmbeddingStyle.TABLE_CELL;
case COMPOSITE_TABLE:
return EmbeddingStyle.TABLE_ROW;
default:
return EmbeddingStyle.NONE;
}
} else
return EmbeddingStyle.NONE;
}
use of org.whole.lang.ui.editparts.IEntityPart in project whole by wholeplatform.
the class NotationStyling method isEmbedded.
public boolean isEmbedded(IStylingFactory stylingFactory, IEntityPart contextPart, IEntity entity) {
if (!(contextPart instanceof IStyledPart))
return false;
IEntityStyling entityStyling = getEntityStyling(stylingFactory, contextPart, entity);
LayoutStyle layoutStyle = entityStyling.getLayoutStyle();
IEntity parentEntity = stylingFactory.getParentEntity(entity);
IEntityPart parentContextPart = stylingFactory.getParentPart(contextPart);
IEntityStyling parentEntityStyling = getEntityStyling(stylingFactory, parentContextPart, parentEntity);
boolean embedChild = parentEntityStyling.embedChild(entity.wGetParent().wIndexOf(entity));
if (embedChild)
return true;
else {
LayoutStyle parentLayoutStyle = parentEntityStyling.getLayoutStyle();
switch(parentLayoutStyle) {
case COLUMN:
case COMPOSITE_TABLE:
return embedChild;
case TABLE_CELL:
case TABLE_ROW:
return true;
case TREE:
return false;
case SIMPLE_TABLE:
default:
return isEmbedded(stylingFactory, parentContextPart, parentEntity);
}
}
}
use of org.whole.lang.ui.editparts.IEntityPart in project whole by wholeplatform.
the class TextTransferDropTargetListener method getCommand.
@Override
protected Command getCommand() {
String text = (String) getCurrentEvent().data;
Shell shell = getViewer().getControl().getShell();
IImportAsModelDialog dialog = factory.createImplicitElementImportAsModelDialog(shell, "Drop As", false);
if (!dialog.show())
return null;
IPersistenceKit persistenceKit = dialog.getPersistenceKit();
EntityDescriptor<?> stage = dialog.getStage();
try {
IBindingManager bm = BindingManagerFactory.instance.createBindingManager();
bm.wDefValue("parseFragments", true);
IEntity entity = persistenceKit.readModel(new StringPersistenceProvider(text, bm));
// FIXME workaround for selections with multiple entities
if (EntityUtils.isTuple(entity))
bm.wDef("syntheticRoot", entity);
boolean hasSyntheticRoot = bm.wIsSet("syntheticRoot");
IEntityIterator<IEntity> iterator;
boolean needsCompositeTarget = false;
if (hasSyntheticRoot) {
IEntity syntheticRoot = bm.wGet("syntheticRoot");
iterator = IteratorFactory.childIterator();
iterator.reset(syntheticRoot);
needsCompositeTarget = syntheticRoot.wSize() > 1;
} else {
iterator = IteratorFactory.selfIterator();
iterator.reset(entity);
}
List<IEntityPart> editParts = new ArrayList<IEntityPart>();
while (iterator.hasNext()) {
IEntity stageEntity = EntityUtils.clone(iterator.next());
stageEntity = ClipboardUtils.conditionalStageAdd(getTargetEditPart(), stage, stageEntity, needsCompositeTarget);
editParts.add(ClipboardUtils.createEditPart(getViewer().getEditPartFactory(), stageEntity));
}
ChangeBoundsRequest request = (ChangeBoundsRequest) getTargetRequest();
request.setEditParts(editParts);
return super.getCommand();
} catch (Exception e) {
return null;
}
}
use of org.whole.lang.ui.editparts.IEntityPart in project whole by wholeplatform.
the class TextTransferDragSourceListener method dragSetData.
public void dragSetData(DragSourceEvent event) {
EditPartViewer viewer = getViewer();
List<EditPart> selectedEditParts = getSelectedEditParts();
IStructuredSelection selection = new StructuredSelection(selectedEditParts);
if (ClipboardUtils.hasTextSeletion(viewer, selection))
event.data = ClipboardUtils.getTextSelection(viewer, selection);
else
try {
int length = selectedEditParts.size();
IEntity[] values = new IEntity[length];
for (int i = 0; i < length; i++) values[i] = EntityUtils.clone(((IEntityPart) selectedEditParts.get(i)).getModelEntity());
event.data = ClipboardUtils.unparseEntity(BindingManagerFactory.instance.createTuple(true, values));
} catch (Exception e) {
event.data = "";
}
}
Aggregations