use of eu.esdihumboldt.hale.common.align.model.EntityDefinition in project hale by halestudio.
the class AssignParameterPage method createContent.
/**
* @see eu.esdihumboldt.hale.ui.HaleWizardPage#createContent(org.eclipse.swt.widgets.Composite)
*/
@Override
protected void createContent(Composite page) {
this.page = page;
page.setLayout(GridLayoutFactory.swtDefaults().numColumns(2).create());
// is created)
if (getWizard().getUnfinishedCell().getTarget() != null) {
EntityDefinition entityDef = getWizard().getUnfinishedCell().getTarget().values().iterator().next().getDefinition();
PropertyDefinition propDef = (PropertyDefinition) entityDef.getDefinition();
title = new Composite(page, SWT.NONE);
title.setLayout(GridLayoutFactory.swtDefaults().numColumns(2).margins(0, 0).create());
// title.setLayoutData(GridDataFactory.swtDefaults().align(SWT.END, SWT.END).create());
DefinitionLabelFactory dlf = PlatformUI.getWorkbench().getService(DefinitionLabelFactory.class);
dlf.createLabel(title, propDef, false);
Label label = new Label(title, SWT.NONE);
label.setText(" = ");
editor = PlatformUI.getWorkbench().getService(AttributeEditorFactory.class).createEditor(page, propDef, entityDef, false);
editor.setVariableReplacer(new TransformationVariableReplacer());
editor.getControl().setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
editor.setPropertyChangeListener(new IPropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent event) {
if (event.getProperty().equals(AttributeEditor.IS_VALID))
setPageComplete((Boolean) event.getNewValue());
}
});
}
if (editor != null && initialValue != null) {
editor.setAsText(initialValue.as(String.class));
if (editor instanceof EditorChooserEditor)
((EditorChooserEditor<?>) editor).selectEditor(initialValue.getType());
}
if (editor != null)
setPageComplete(editor.isValid());
}
use of eu.esdihumboldt.hale.common.align.model.EntityDefinition 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.EntityDefinition 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.EntityDefinition in project hale by halestudio.
the class MergeParameterPage method getConfiguration.
/**
* @see eu.esdihumboldt.hale.ui.function.generic.pages.ParameterPage#getConfiguration()
*/
@Override
public ListMultimap<String, ParameterValue> getConfiguration() {
ListMultimap<String, ParameterValue> configuration = ArrayListMultimap.create();
for (EntityDefinition selected : selection) {
// build property path (QNames separated by .)
/*
* FIXME this is problematic with property names that contain dots
* and only works out because only top level properties are allowed.
* If multiple levels are needed, properties should be stored as
* Lists of QNames (Complex values) or EntityDefinitions.
*/
// FIXME use MergeUtil helper function instead
String propertyPath = Joiner.on('.').join(Collections2.transform(selected.getPropertyPath(), new Function<ChildContext, String>() {
@Override
public String apply(ChildContext input) {
return input.getChild().getName().toString();
}
}));
// add it to configuration
configuration.put(parameter.getName(), new ParameterValue(propertyPath));
}
return configuration;
}
use of eu.esdihumboldt.hale.common.align.model.EntityDefinition in project hale by halestudio.
the class DefinitionInstanceLabelProvider method getToolTipText.
/**
* @see org.eclipse.jface.viewers.CellLabelProvider#getToolTipText(java.lang.Object)
*/
@Override
public String getToolTipText(Object element) {
if (element instanceof EntityDefinition) {
InstanceValidationReport report = validator.validate(instance);
Collection<InstanceValidationMessage> warnings = report.getWarnings();
if (warnings.isEmpty())
return null;
StringBuilder toolTip = new StringBuilder();
for (Message m : warnings) toolTip.append(m.getFormattedMessage()).append('\n');
return toolTip.substring(0, toolTip.length() - 1);
} else
return null;
}
Aggregations