use of eu.esdihumboldt.hale.ui.functions.groovy.internal.TypeStructureTray.TypeProvider in project hale by halestudio.
the class PropertyFunctionScriptPage method addActions.
@Override
protected void addActions(ToolBar toolbar, CompilingSourceViewer<GroovyAST> viewer) {
super.addActions(toolbar, viewer);
PageHelp.createToolItem(toolbar, this);
TypeStructureTray.createToolItem(toolbar, this, SchemaSpaceID.SOURCE, new TypeProvider() {
@Override
public Collection<? extends TypeDefinition> getTypes() {
// create a dummy type with the variables as children
DefaultTypeDefinition dummy = new DefaultTypeDefinition(TypeStructureTray.VARIABLES_TYPE_NAME);
DefaultCustomPropertyFunction cf = getWizard().getUnfinishedFunction();
int index = 0;
for (EntityDefinition variable : getVariables()) {
DefaultCustomPropertyFunctionEntity source = cf.getSources().get(index);
if (variable.getDefinition() instanceof PropertyDefinition) {
PropertyDefinition prop = (PropertyDefinition) variable.getDefinition();
TypeDefinition propertyType;
boolean useInstanceValue = CustomGroovyTransformation.useInstanceVariableForSource(source);
if (useInstanceValue) {
// use instance type
propertyType = prop.getPropertyType();
} else {
// use dummy type with only the
// binding/HasValueFlag copied
DefaultTypeDefinition crippledType = new DefaultTypeDefinition(prop.getPropertyType().getName());
crippledType.setConstraint(prop.getPropertyType().getConstraint(Binding.class));
crippledType.setConstraint(prop.getPropertyType().getConstraint(HasValueFlag.class));
propertyType = crippledType;
}
DefaultPropertyDefinition dummyProp = new DefaultPropertyDefinition(new QName(source.getName()), dummy, propertyType);
// number of times
if (source.isEager())
dummyProp.setConstraint(Cardinality.CC_ANY_NUMBER);
}
index++;
}
return Collections.singleton(dummy);
}
});
TypeStructureTray.createToolItem(toolbar, this, SchemaSpaceID.TARGET, new TypeProvider() {
@Override
public Collection<? extends TypeDefinition> getTypes() {
DefaultCustomPropertyFunctionEntity target = getWizard().getUnfinishedFunction().getTarget();
if (target != null) {
return Collections.singleton(createDummyType(target));
}
return Collections.emptyList();
}
});
}
use of eu.esdihumboldt.hale.ui.functions.groovy.internal.TypeStructureTray.TypeProvider in project hale by halestudio.
the class GroovyCreatePage method addActions.
@Override
protected void addActions(ToolBar toolbar, CompilingSourceViewer<GroovyAST> viewer) {
super.addActions(toolbar, viewer);
PageHelp.createToolItem(toolbar, this);
TypeStructureTray.createToolItem(toolbar, this, SchemaSpaceID.TARGET, new TypeProvider() {
@Override
public Collection<? extends TypeDefinition> getTypes() {
Type typeEntity = (Type) CellUtil.getFirstEntity(getWizard().getUnfinishedCell().getTarget());
if (typeEntity != null) {
return Collections.singleton(typeEntity.getDefinition().getDefinition());
}
return Collections.emptyList();
}
});
PageFunctions.createToolItem(toolbar, this);
}
use of eu.esdihumboldt.hale.ui.functions.groovy.internal.TypeStructureTray.TypeProvider in project hale by halestudio.
the class GroovyJoinPage method addActions.
@Override
protected void addActions(ToolBar toolbar, CompilingSourceViewer<GroovyAST> viewer) {
PageHelp.createToolItem(toolbar, this);
// FIXME TypeStructureTray does not support FamilyInstances
// XXX for now only use Join base type
JoinTypeStructureTray.createToolItem(toolbar, this, SchemaSpaceID.SOURCE, new TypeProvider() {
@Override
public Collection<? extends TypeDefinition> getTypes() {
ParameterValue param = CellUtil.getFirstParameter(getWizard().getUnfinishedCell(), JoinFunction.PARAMETER_JOIN);
JoinParameter joinParameter = param.as(JoinParameter.class);
if (joinParameter != null && joinParameter.getTypes() != null && !joinParameter.getTypes().isEmpty()) {
return Collections.singleton(joinParameter.getTypes().get(0).getDefinition());
}
return Collections.emptyList();
}
});
TypeStructureTray.createToolItem(toolbar, this, SchemaSpaceID.TARGET, new TypeProvider() {
@Override
public Collection<? extends TypeDefinition> getTypes() {
Type targetType = (Type) CellUtil.getFirstEntity(getWizard().getUnfinishedCell().getTarget());
if (targetType != null) {
return Collections.singleton(targetType.getDefinition().getDefinition());
}
return Collections.emptyList();
}
});
PageFunctions.createToolItem(toolbar, this);
}
use of eu.esdihumboldt.hale.ui.functions.groovy.internal.TypeStructureTray.TypeProvider in project hale by halestudio.
the class GroovyTransformationPage method addActions.
@Override
protected void addActions(ToolBar toolbar, CompilingSourceViewer<GroovyAST> viewer) {
super.addActions(toolbar, viewer);
PageHelp.createToolItem(toolbar, this);
TypeStructureTray.createToolItem(toolbar, this, SchemaSpaceID.SOURCE, new TypeProvider() {
@Override
public Collection<? extends TypeDefinition> getTypes() {
// create a dummy type with the variables as children
DefaultTypeDefinition dummy = new DefaultTypeDefinition(TypeStructureTray.VARIABLES_TYPE_NAME);
Cell cell = getWizard().getUnfinishedCell();
boolean useInstanceValues = CellUtil.getOptionalParameter(cell, GroovyTransformation.PARAM_INSTANCE_VARIABLES, Value.of(false)).as(Boolean.class);
for (EntityDefinition variable : getVariables()) {
if (variable.getDefinition() instanceof PropertyDefinition) {
PropertyDefinition prop = (PropertyDefinition) variable.getDefinition();
TypeDefinition propertyType;
if (useInstanceValues) {
// use instance type
propertyType = prop.getPropertyType();
} else {
// use dummy type with only the
// binding/HasValueFlag copied
DefaultTypeDefinition crippledType = new DefaultTypeDefinition(prop.getPropertyType().getName());
crippledType.setConstraint(prop.getPropertyType().getConstraint(Binding.class));
crippledType.setConstraint(prop.getPropertyType().getConstraint(HasValueFlag.class));
propertyType = crippledType;
}
DefaultPropertyDefinition dummyProp = new DefaultPropertyDefinition(new QName(getVariableName(variable)), dummy, propertyType);
// number of times
if (cell.getTransformationIdentifier().equals(GroovyGreedyTransformation.ID))
dummyProp.setConstraint(Cardinality.CC_ANY_NUMBER);
}
}
return Collections.singleton(dummy);
}
});
TypeStructureTray.createToolItem(toolbar, this, SchemaSpaceID.TARGET, new TypeProvider() {
@Override
public Collection<? extends TypeDefinition> getTypes() {
Property targetProperty = (Property) CellUtil.getFirstEntity(getWizard().getUnfinishedCell().getTarget());
if (targetProperty != null) {
return Collections.singleton(targetProperty.getDefinition().getDefinition().getPropertyType());
}
return Collections.emptyList();
}
});
PageFunctions.createToolItem(toolbar, this);
}
use of eu.esdihumboldt.hale.ui.functions.groovy.internal.TypeStructureTray.TypeProvider in project hale by halestudio.
the class GroovyRetypePage method addActions.
@Override
protected void addActions(ToolBar toolbar, CompilingSourceViewer<GroovyAST> viewer) {
super.addActions(toolbar, viewer);
PageHelp.createToolItem(toolbar, this);
TypeStructureTray.createToolItem(toolbar, this, SchemaSpaceID.SOURCE, new TypeProvider() {
@Override
public Collection<? extends TypeDefinition> getTypes() {
Type sourceType = (Type) CellUtil.getFirstEntity(getWizard().getUnfinishedCell().getSource());
if (sourceType != null) {
return Collections.singleton(sourceType.getDefinition().getDefinition());
}
return Collections.emptyList();
}
});
TypeStructureTray.createToolItem(toolbar, this, SchemaSpaceID.TARGET, new TypeProvider() {
@Override
public Collection<? extends TypeDefinition> getTypes() {
Type targetType = (Type) CellUtil.getFirstEntity(getWizard().getUnfinishedCell().getTarget());
if (targetType != null) {
return Collections.singleton(targetType.getDefinition().getDefinition());
}
return Collections.emptyList();
}
});
PageFunctions.createToolItem(toolbar, this);
}
Aggregations