use of eu.esdihumboldt.hale.common.align.model.Priority in project hale by halestudio.
the class SetPriorityContribution method fill.
/**
* @see AbstractFunctionWizardContribution#fill(Menu, int)
*/
@Override
public void fill(Menu menu, int index) {
if (getOriginalCell() == null)
return;
AlignmentService alignmentService = PlatformUI.getWorkbench().getService(AlignmentService.class);
Cell cell = getOriginalCell();
Priority oldPriority = cell.getPriority();
for (Priority priority : Priority.values()) {
if (priority != oldPriority) {
SetPriorityAction setPriorityAction = new SetPriorityAction(priority, cell.getId(), alignmentService);
IContributionItem item = new ActionContributionItem(setPriorityAction);
item.fill(menu, index++);
}
}
}
use of eu.esdihumboldt.hale.common.align.model.Priority in project hale by halestudio.
the class AlignmentServiceImpl method setCellProperty.
/**
* @see eu.esdihumboldt.hale.ui.service.align.AlignmentService#setCellProperty(java.lang.String,
* java.lang.String, java.lang.Object)
*/
@Override
public void setCellProperty(String cellId, String propertyName, Object property) {
if (propertyName == null || property == null) {
throw new IllegalArgumentException("Mandatory parameter is null");
}
Cell cell = getAlignment().getCell(cellId);
if (cell instanceof ModifiableCell && (Cell.PROPERTY_DISABLE_FOR.equals(propertyName) || Cell.PROPERTY_ENABLE_FOR.equals(propertyName))) {
boolean disable = Cell.PROPERTY_DISABLE_FOR.equals(propertyName);
if (property instanceof Cell) {
Cell other = (Cell) property;
if (!AlignmentUtil.isTypeCell(other))
throw new IllegalArgumentException();
// This call may fail, if the cell was disabled in a base
// alignment and someone tries to enable it again.
((ModifiableCell) cell).setDisabledFor(other, disable);
} else
throw new IllegalArgumentException();
notifyCellsPropertyChanged(Arrays.asList(cell), propertyName);
} else if (Cell.PROPERTY_TRANSFORMATION_MODE.equals(propertyName)) {
// set the transformation mode
if (cell instanceof ModifiableCell && property instanceof TransformationMode) {
ModifiableCell modCell = (ModifiableCell) cell;
modCell.setTransformationMode((TransformationMode) property);
notifyCellsPropertyChanged(Arrays.asList(cell), propertyName);
}
} else if (cell instanceof MutableCell) {
MutableCell mutableCell = (MutableCell) cell;
if (Cell.PROPERTY_PRIORITY.equals(propertyName)) {
if (property instanceof Priority) {
Priority priority = (Priority) property;
mutableCell.setPriority(priority);
}
if (property instanceof String) {
String priorityStr = (String) property;
Priority priority = Priority.valueOf(priorityStr);
if (priority != null) {
mutableCell.setPriority(priority);
} else {
throw new IllegalArgumentException();
}
}
notifyCellsPropertyChanged(Arrays.asList(cell), propertyName);
}
} else {
throw new IllegalArgumentException("No mutable cell by the given id found: " + cellId);
}
}
use of eu.esdihumboldt.hale.common.align.model.Priority in project hale by halestudio.
the class AlignmentServiceUndoSupport method setCellProperty.
/**
* @see eu.esdihumboldt.hale.ui.service.align.AlignmentService#setCellProperty(java.lang.String,
* java.lang.String, java.lang.Object)
*/
@Override
public void setCellProperty(String cellId, String propertyName, Object property) {
if (Cell.PROPERTY_DISABLE_FOR.equals(propertyName) || Cell.PROPERTY_ENABLE_FOR.equals(propertyName)) {
IUndoableOperation operation = new DisableCellOperation(Cell.PROPERTY_DISABLE_FOR.equals(propertyName), cellId, (Cell) property);
executeOperation(operation);
} else if (Cell.PROPERTY_PRIORITY.equals(propertyName)) {
if (property instanceof Priority) {
Priority newPriority = (Priority) property;
Cell cell = getAlignment().getCell(cellId);
Priority oldPriority = cell.getPriority();
IUndoableOperation operation = new SetCellPropertyOperation(cellId, propertyName, oldPriority, newPriority);
executeOperation(operation);
}
} else if (Cell.PROPERTY_TRANSFORMATION_MODE.equals(propertyName)) {
Cell cell = getAlignment().getCell(cellId);
Object oldValue = cell.getTransformationMode();
IUndoableOperation operation = new SetCellPropertyOperation(cellId, propertyName, oldValue, property);
executeOperation(operation);
} else {
log.warn("An unknown cell property is set. No undo support.");
alignmentService.setCellProperty(cellId, propertyName, property);
}
}
use of eu.esdihumboldt.hale.common.align.model.Priority in project hale by halestudio.
the class CellPrioritySection method setFromCell.
private void setFromCell() {
Cell cell = getCell();
Priority currentPriority = cell.getPriority();
comboViewer.setSelection(new StructuredSelection(currentPriority));
}
use of eu.esdihumboldt.hale.common.align.model.Priority in project hale by halestudio.
the class CellPrioritySection method selectionChanged.
/**
* @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
*/
@Override
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
Object firstElement = structuredSelection.getFirstElement();
if (firstElement instanceof Priority) {
Priority priority = (Priority) firstElement;
Cell cell = getCell();
if (cell.getPriority() != priority) {
AlignmentService alignmentService = PlatformUI.getWorkbench().getService(AlignmentService.class);
alignmentService.setCellProperty(cell.getId(), Cell.PROPERTY_PRIORITY, priority);
}
}
}
}
Aggregations