use of eu.esdihumboldt.hale.ui.service.align.AlignmentService in project hale by halestudio.
the class InstanceIndexUpdateServiceImpl method alignmentChanged.
@Override
public void alignmentChanged() {
getIndexService().clearAll();
AlignmentService alignmentService = serviceProvider.getService(AlignmentService.class);
getIndexService().addPropertyMappings(alignmentService.getAlignment().getActiveTypeCells(), serviceProvider);
reindex();
}
use of eu.esdihumboldt.hale.ui.service.align.AlignmentService in project hale by halestudio.
the class FeatureChainingConfigurationPage method onShowPage.
/**
* @see eu.esdihumboldt.hale.ui.HaleWizardPage#onShowPage(boolean)
*/
@Override
protected void onShowPage(boolean firstShow) {
super.onShowPage(firstShow);
if (firstShow) {
for (ChainPage page : pages) page.dispose();
pages.clear();
AlignmentService alignmentService = HaleUI.getServiceProvider().getService(AlignmentService.class);
Alignment alignment = alignmentService.getAlignment();
int pageIdx = 0;
Collection<? extends Cell> typeCells = alignment.getActiveTypeCells();
for (Cell typeCell : typeCells) {
if (AppSchemaMappingUtils.isJoin(typeCell)) {
JoinParameter joinParameter = getJoinParameter(typeCell);
List<JoinCondition> conditions = getSortedJoinConditions(joinParameter);
TypeEntityDefinition joinTarget = getTargetType(typeCell).getDefinition();
for (int i = 0; i < joinParameter.getTypes().size() - 1; i++) {
ChainPage chainPage = new ChainPage(pageIdx, typeCell.getId(), i, joinParameter.getTypes(), conditions, joinTarget);
chainPage.setWizard(getWizard());
pages.add(chainPage);
pageIdx++;
}
}
}
}
setPageComplete(true);
if (!goingBack) {
getContainer().showPage(getNextPage());
} else {
getContainer().showPage(getPreviousPage());
}
}
use of eu.esdihumboldt.hale.ui.service.align.AlignmentService in project hale by halestudio.
the class GroovyTransformationPage method validate.
@Override
protected boolean validate(String document) {
super.validate(document);
List<PropertyValue> values = new ArrayList<PropertyValue>();
for (EntityDefinition var : getVariables()) {
if (var instanceof PropertyEntityDefinition) {
PropertyEntityDefinition property = (PropertyEntityDefinition) var;
values.add(new PropertyValueImpl(testValues.get(property), property));
}
}
Property targetProperty = (Property) CellUtil.getFirstEntity(getWizard().getUnfinishedCell().getTarget());
if (targetProperty == null) {
// not yet selected (NewRelationWizard)
return false;
}
InstanceBuilder builder = GroovyTransformation.createBuilder(targetProperty.getDefinition());
Cell cell = getWizard().getUnfinishedCell();
boolean useInstanceValues = CellUtil.getOptionalParameter(cell, GroovyTransformation.PARAM_INSTANCE_VARIABLES, Value.of(false)).as(Boolean.class);
AlignmentService as = PlatformUI.getWorkbench().getService(AlignmentService.class);
GroovyService gs = HaleUI.getServiceProvider().getService(GroovyService.class);
Script script = null;
try {
Collection<? extends Cell> typeCells = as.getAlignment().getTypeCells(cell);
// select one matching type cell, the script has to run for all
// matching cells
// if there is no matching cell it may produce a npe, which is okay
Cell typeCell = null;
if (!typeCells.isEmpty()) {
typeCell = typeCells.iterator().next();
}
CellLog log = new CellLog(new DefaultTransformationReporter("dummy", false), cell);
ExecutionContext context = new DummyExecutionContext(HaleUI.getServiceProvider());
groovy.lang.Binding binding;
if (cell.getTransformationIdentifier().equals(GroovyGreedyTransformation.ID)) {
binding = GroovyGreedyTransformation.createGroovyBinding(values, null, cell, typeCell, builder, useInstanceValues, log, context, targetProperty.getDefinition().getDefinition().getPropertyType());
} else {
binding = GroovyTransformation.createGroovyBinding(values, null, cell, typeCell, builder, useInstanceValues, log, context, targetProperty.getDefinition().getDefinition().getPropertyType());
}
script = gs.parseScript(document, binding);
GroovyTransformation.evaluate(script, builder, targetProperty.getDefinition().getDefinition().getPropertyType(), gs, log);
} catch (NoResultException e) {
// continue
} catch (final Exception e) {
return handleValidationResult(script, e);
}
return handleValidationResult(script, null);
}
use of eu.esdihumboldt.hale.ui.service.align.AlignmentService in project hale by halestudio.
the class NewRelationWizard method performFinish.
/**
* @see MultiWizard#performFinish()
*/
@Override
public boolean performFinish() {
// performFinish of the function wizard was called first
FunctionWizard functionWizard = getSelectionPage().getFunctionWizard();
if (functionWizard == null) {
return false;
}
MutableCell cell = functionWizard.getResult();
if (cell != null) {
AlignmentService as = PlatformUI.getWorkbench().getService(AlignmentService.class);
as.addCell(cell);
}
createdCell = cell;
// save page configuration
ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
getSelectionPage().store(ps.getConfigurationService());
return true;
}
use of eu.esdihumboldt.hale.ui.service.align.AlignmentService in project hale by halestudio.
the class FunctionsView method createViewControl.
/**
* @see eu.esdihumboldt.hale.ui.views.properties.PropertiesViewPart#createViewControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createViewControl(Composite parent) {
viewer = new TreeViewer(parent);
viewer.setLabelProvider(new FunctionLabelProvider());
viewer.setContentProvider(new FunctionContentProvider(HaleUI.getServiceProvider()));
IToolBarManager manager = getViewSite().getActionBars().getToolBarManager();
IAction filterAction = new FilterAction("Filter incompatible functions", Action.AS_CHECK_BOX, CommonSharedImages.getImageRegistry().getDescriptor("IMG_FILTER_CLEAR"));
manager.add(filterAction);
filterAction.setChecked(true);
filterAction.run();
CompatibilityService cs = PlatformUI.getWorkbench().getService(CompatibilityService.class);
cs.addListener(compListener = new ExclusiveExtensionListener<CompatibilityMode, CompatibilityModeFactory>() {
@Override
public void currentObjectChanged(CompatibilityMode current, CompatibilityModeFactory definition) {
// refresh the viewer when the compatibility mode is
// changed
final Display display = PlatformUI.getWorkbench().getDisplay();
display.syncExec(new Runnable() {
@Override
public void run() {
viewer.refresh();
}
});
}
});
AlignmentService as = PlatformUI.getWorkbench().getService(AlignmentService.class);
as.addListener(alignListener = new AlignmentServiceAdapter() {
@Override
public void alignmentCleared() {
customFunctionsChanged();
}
@Override
public void customFunctionsChanged() {
// refresh the viewer when the compatibility mode is changed
final Display display = PlatformUI.getWorkbench().getDisplay();
display.syncExec(new Runnable() {
@Override
public void run() {
viewer.refresh();
}
});
}
});
// no input needed, but we have to set something
viewer.setInput(Boolean.TRUE);
new ViewerMenu(getSite(), viewer);
getSite().setSelectionProvider(viewer);
}
Aggregations