use of eu.esdihumboldt.hale.common.align.model.Cell in project hale by halestudio.
the class JoinParameterPage method onShowPage.
/**
* @see eu.esdihumboldt.hale.ui.HaleWizardPage#onShowPage(boolean)
*/
@Override
protected void onShowPage(boolean firstShow) {
super.onShowPage(firstShow);
Cell cell = getWizard().getUnfinishedCell();
List<? extends Entity> sourceEntities = cell.getSource().get(JOIN_TYPES);
List<TypeEntityDefinition> types = new ArrayList<TypeEntityDefinition>();
Iterator<? extends Entity> iter = sourceEntities.iterator();
while (iter.hasNext()) {
types.add(AlignmentUtil.getTypeEntity(iter.next().getDefinition()));
}
if (sameTypes(this.types, types)) {
return;
}
if (containsDuplicateType(types)) {
setPageComplete(false);
setErrorMessage("The selected source types contain duplicates.");
this.types.clear();
table.setInput(null);
return;
} else {
setErrorMessage(null);
}
JoinParameter initialValue = null;
if (firstShow && !getInitialValues().get(PARAMETER_JOIN).isEmpty()) {
initialValue = getInitialValues().get(PARAMETER_JOIN).get(0).as(JoinParameter.class);
if (initialValue != null) {
// use ordering of the initial value (needs to be modifiable)
List<TypeEntityDefinition> tmp = new ArrayList<>(initialValue.getTypes());
// append any type that were added, or remove types that were
// removed
tmp.retainAll(types);
List<TypeEntityDefinition> more = new ArrayList<>(types);
more.removeAll(tmp);
tmp.addAll(more);
types = tmp;
// apply potentially changed type list
initialValue = new JoinParameter(types, initialValue.getConditions());
if (initialValue.validate(true) != null) {
// try to fix config
// not recoverable
initialValue = null;
}
}
}
this.types = types;
for (ConditionPage page : pages) {
page.dispose();
}
pages.clear();
if (table != null) {
table.setInput(types);
}
for (int i = 1; i < types.size(); i++) {
ConditionPage conditionPage = new ConditionPage(i);
conditionPage.setWizard(getWizard());
pages.add(conditionPage);
}
if (initialValue != null) {
// add initial conditions
for (JoinCondition condition : initialValue.getConditions()) {
TypeEntityDefinition joinType = AlignmentUtil.getTypeEntity(condition.joinProperty);
int typeIndex = types.indexOf(joinType);
int pageIndex = typeIndex - 1;
pages.get(pageIndex).conditions.add(condition);
pages.get(pageIndex).updateCompletionStatus();
}
}
// order is always valid, will trigger updateButtons
setPageComplete(true);
}
use of eu.esdihumboldt.hale.common.align.model.Cell in project hale by halestudio.
the class RegexAnalysisParameterPage method onShowPage.
/**
* @see eu.esdihumboldt.hale.ui.HaleWizardPage#onShowPage(boolean)
*/
@Override
protected void onShowPage(boolean firstShow) {
super.onShowPage(firstShow);
// should never be null here, but better be safe than sorry
Cell unfinishedCell = getWizard().getUnfinishedCell();
if (unfinishedCell.getTarget() != null) {
PropertyDefinition propDef = (PropertyDefinition) unfinishedCell.getTarget().values().iterator().next().getDefinition().getDefinition();
if (!propDef.equals(target)) {
// target property definition changed, rebuild editor
target = propDef;
createContent(page);
page.layout();
setDefaultData(unfinishedCell);
}
}
}
use of eu.esdihumboldt.hale.common.align.model.Cell in project hale by halestudio.
the class SourceListParameterPage method onShowPage.
/**
* @see HaleWizardPage#onShowPage(boolean)
*/
@Override
protected void onShowPage(boolean firstShow) {
Cell cell = getWizard().getUnfinishedCell();
// update variables as they could have changed
variables.clear();
List<? extends Entity> sourceEntities = cell.getSource().get(getSourcePropertyName());
for (Entity entity : sourceEntities) {
variables.add(entity.getDefinition());
}
Map<EntityDefinition, String> varsAndNames = determineDefaultVariableNames(variables);
varTable.setInput(varsAndNames.entrySet());
// Update project variables content provider
projectVariablesProposalsProvider.reload();
// inform subclasses
sourcePropertiesChanged(varsAndNames.keySet());
((Composite) getControl()).layout();
}
use of eu.esdihumboldt.hale.common.align.model.Cell in project hale by halestudio.
the class HtmlMappingExporter method createImages.
private void createImages(File filesDir) {
Collection<? extends Cell> cells = alignment.getCells();
Iterator<? extends Cell> ite = cells.iterator();
while (ite.hasNext()) {
Cell cell = ite.next();
saveImageToFile(cell, filesDir);
}
}
use of eu.esdihumboldt.hale.common.align.model.Cell in project hale by halestudio.
the class GroovyCreatePage method validate.
@Override
protected boolean validate(String document) {
super.validate(document);
Type typeEntity = (Type) CellUtil.getFirstEntity(getWizard().getUnfinishedCell().getTarget());
if (typeEntity == null) {
// not yet selected (NewRelationWizard)
return false;
}
InstanceBuilder builder = new InstanceBuilder(false);
Cell cell = getWizard().getUnfinishedCell();
CellLog log = new CellLog(new DefaultTransformationReporter("dummy", false), cell);
ExecutionContext context = new DummyExecutionContext(HaleUI.getServiceProvider());
Binding binding = GroovyUtil.createBinding(builder, cell, cell, log, context, typeEntity.getDefinition().getDefinition());
binding.setProperty(BINDING_INDEX, 0);
GroovyService service = HaleUI.getServiceProvider().getService(GroovyService.class);
Script script = null;
try {
script = service.parseScript(document, binding);
GroovyUtil.evaluateAll(script, builder, typeEntity.getDefinition().getDefinition(), service, log);
} catch (final Exception e) {
return handleValidationResult(script, e);
}
return handleValidationResult(script, null);
}
Aggregations