use of eu.esdihumboldt.hale.common.align.model.Cell in project hale by halestudio.
the class MergeParameterPage method createContent.
@Override
protected void createContent(Composite page) {
// set layout of page
page.setLayout(new GridLayout());
Label name = new Label(page, SWT.NONE);
name.setText(parameter.getDisplayName());
// create checkbox tree viewer
viewer = new CheckboxTreeViewer(page, SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER);
viewer.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
// comparator
viewer.setComparator(new DefinitionComparator());
// label provider
viewer.setLabelProvider(labelProvider);
// content provider
viewer.setContentProvider(new PropertyPathContentProvider(SchemaSpaceID.SOURCE));
// check state listener
viewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
// add/remove it from/to set of selected properties
EntityDefinition eventSource = (EntityDefinition) event.getElement();
if (event.getChecked())
selection.add(eventSource);
else
selection.remove(eventSource);
}
});
// for now filter everything after first level
viewer.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
return parentElement == sourceType;
}
});
if (parameter.getName().equals(PARAMETER_ADDITIONAL_PROPERTY))
viewer.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
return !filtered.contains(element);
}
});
Cell unfinishedCell = getWizard().getUnfinishedCell();
if (unfinishedCell.getSource() != null) {
sourceType = (TypeDefinition) unfinishedCell.getSource().values().iterator().next().getDefinition().getDefinition();
}
viewer.setInput(sourceType);
// add initial selection
if (sourceType != null && initialSelection != null) {
for (String propertyPath : initialSelection) {
EntityDefinition entity = getEntityDefinition(propertyPath, sourceType);
if (entity != null) {
selection.add(entity);
} else {
log.warn("Could not find child for property path " + propertyPath);
}
}
viewer.setCheckedElements(selection.toArray());
}
}
use of eu.esdihumboldt.hale.common.align.model.Cell in project hale by halestudio.
the class MergeParameterPage method onShowPage.
/**
* @see eu.esdihumboldt.hale.ui.HaleWizardPage#onShowPage(boolean)
*/
@Override
protected void onShowPage(boolean firstShow) {
super.onShowPage(firstShow);
setPageComplete(true);
Cell unfinishedCell = getWizard().getUnfinishedCell();
// selected target could've changed!
TypeDefinition newSourceType = (TypeDefinition) unfinishedCell.getSource().values().iterator().next().getDefinition().getDefinition();
if (!newSourceType.equals(sourceType)) {
selection = new HashSet<EntityDefinition>();
sourceType = newSourceType;
viewer.setInput(sourceType);
}
// for additional_property: selected properties can change!
if (parameter.getName().equals(PARAMETER_ADDITIONAL_PROPERTY)) {
filtered = new HashSet<EntityDefinition>();
List<ParameterValue> properties = unfinishedCell.getTransformationParameters().get(PARAMETER_PROPERTY);
boolean oldSelectionChanged = false;
for (ParameterValue propertyPath : properties) {
EntityDefinition def = getEntityDefinition(propertyPath.as(String.class), sourceType);
filtered.add(def);
if (selection.remove(def))
oldSelectionChanged = true;
}
if (oldSelectionChanged) {
viewer.setCheckedElements(selection.toArray());
}
viewer.refresh();
}
}
use of eu.esdihumboldt.hale.common.align.model.Cell in project hale by halestudio.
the class AlignmentView method updateRelation.
/**
* Update the selected type relation to a cell that is related to the given
* schema selection.
*
* @param selection the schema selection
*/
private void updateRelation(SchemaSelection selection) {
Cell typeCell = sourceTargetSelector.getSelectedCell();
if (typeCell != null && (associatedWithType(typeCell.getSource(), selection.getSourceItems()) && associatedWithType(typeCell.getTarget(), selection.getTargetItems()))) {
// type cell is associated with source and target, don't change
return;
}
AlignmentService as = PlatformUI.getWorkbench().getService(AlignmentService.class);
Alignment alignment = as.getAlignment();
// find type cell associated with both source and target
for (Cell cell : alignment.getTypeCells()) {
if ((associatedWithType(cell.getSource(), selection.getSourceItems())) && associatedWithType(cell.getTarget(), selection.getTargetItems())) {
// typeRelations.setSelection(new StructuredSelection(cell));
sourceTargetSelector.setSelection(new StructuredSelection(cell));
return;
}
}
if (typeCell != null && (associatedWithType(typeCell.getSource(), selection.getSourceItems()) || associatedWithType(typeCell.getTarget(), selection.getTargetItems()))) {
// type cell is associated with source or target, don't change
return;
}
// find type cell associated with source or target
for (Cell cell : alignment.getTypeCells()) {
if ((associatedWithType(cell.getSource(), selection.getSourceItems())) || associatedWithType(cell.getTarget(), selection.getTargetItems())) {
sourceTargetSelector.setSelection(new StructuredSelection(cell));
// typeRelations.setSelection(new StructuredSelection(cell));
return;
}
}
}
use of eu.esdihumboldt.hale.common.align.model.Cell in project hale by halestudio.
the class PropertiesLabelProvider method getImage.
/**
* @see LabelProvider#getImage(Object)
*/
@Override
public Image getImage(Object element) {
if (element instanceof IStructuredSelection) {
element = ((IStructuredSelection) element).getFirstElement();
}
element = TransformationTreeUtil.extractObject(element);
if (element instanceof Entity) {
element = ((Entity) element).getDefinition();
}
if (element instanceof EntityDefinition || element instanceof Definition<?>) {
return definitionLabels.getImage(element);
}
if (element instanceof Cell) {
Cell cell = (Cell) element;
FunctionDefinition<?> function = FunctionUtil.getFunction(cell.getTransformationIdentifier(), HaleUI.getServiceProvider());
if (function != null) {
element = function;
}
}
if (element instanceof FunctionDefinition) {
return functionLabels.getImage(element);
}
return super.getImage(element);
}
use of eu.esdihumboldt.hale.common.align.model.Cell in project hale by halestudio.
the class HtmlExplanationCellSection method refresh.
@Override
public void refresh() {
super.refresh();
String text = null;
Cell cell = getCell();
if (cell != null) {
FunctionDefinition<?> function = FunctionUtil.getFunction(cell.getTransformationIdentifier(), HaleUI.getServiceProvider());
if (function != null) {
CellExplanation explanation = function.getExplanation();
if (explanation != null) {
if (browser != null) {
text = explanation.getExplanationAsHtml(cell, HaleUI.getServiceProvider());
if (text == null) {
text = explanation.getExplanation(cell, HaleUI.getServiceProvider());
}
} else if (textField != null) {
text = explanation.getExplanation(cell, HaleUI.getServiceProvider());
}
}
}
}
if (text == null) {
text = "Sorry, no explanation available.";
}
if (browser != null) {
browser.setText(text);
} else if (textField != null) {
textField.setText(text);
}
}
Aggregations