use of eu.esdihumboldt.hale.ui.common.service.compatibility.CompatibilityModeFactory in project hale by halestudio.
the class AlignmentView method createViewControl.
/**
* @see eu.esdihumboldt.hale.ui.views.mapping.AbstractMappingView#createViewControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createViewControl(Composite parent) {
Composite page = new Composite(parent, SWT.NONE);
page.setLayout(GridLayoutFactory.fillDefaults().create());
// create type relation selection control
sourceTargetSelector = new SourceTargetTypeSelector(page);
sourceTargetSelector.getControl().setLayoutData(GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false).create());
sourceTargetSelector.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
getViewer().setInput(sourceTargetSelector.getSelectedCell());
if (deactivatedCellFilterAction != null) {
deactivatedCellFilterAction.setEnabled(sourceTargetSelector.isCellSelected());
if (!sourceTargetSelector.isCellSelected())
deactivatedCellFilterAction.setChecked(true);
}
refreshGraph();
}
});
// typeRelations = new ComboViewer(page, SWT.DROP_DOWN | SWT.READ_ONLY);
// typeRelations.setContentProvider(ArrayContentProvider.getInstance());
// typeRelations.setLabelProvider(new LabelProvider() {
//
// @Override
// public Image getImage(Object element) {
// if (element instanceof Cell) {
// // use function image if possible
// Cell cell = (Cell) element;
// String functionId = cell.getTransformationIdentifier();
// AbstractFunction<?> function = FunctionUtil.getFunction(functionId);
// if (function != null) {
// return functionLabels.getImage(function);
// }
// return null;
// }
//
// return super.getImage(element);
// }
//
// @Override
// public String getText(Object element) {
// if (element instanceof Cell) {
// Cell cell = (Cell) element;
//
// return CellUtil.getCellDescription(cell);
// }
//
// return super.getText(element);
// }
//
// });
// typeRelations.addSelectionChangedListener(new ISelectionChangedListener() {
//
// @Override
// public void selectionChanged(SelectionChangedEvent event) {
// updateGraph();
// }
// });
// typeRelations.getControl().setLayoutData(
// GridDataFactory.swtDefaults().align(SWT.FILL, SWT.CENTER).grab(true, false)
// .create());
// create viewer
Composite viewerContainer = new Composite(page, SWT.NONE);
viewerContainer.setLayout(new FillLayout());
viewerContainer.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create());
super.createViewControl(viewerContainer);
updateLayout(false);
AlignmentService as = PlatformUI.getWorkbench().getService(AlignmentService.class);
// update();
as.addListener(alignmentListener = new AlignmentServiceAdapter() {
@Override
public void alignmentCleared() {
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
sourceTargetSelector.setSelection(StructuredSelection.EMPTY);
}
});
}
@Override
public void cellsRemoved(Iterable<Cell> cells) {
if (sourceTargetSelector.isCellSelected() && Iterables.contains(cells, sourceTargetSelector.getSelectedCell()))
sourceTargetSelector.setSelection(StructuredSelection.EMPTY);
refreshGraph();
}
@Override
public void cellsReplaced(Map<? extends Cell, ? extends Cell> cells) {
if (sourceTargetSelector.isCellSelected() && cells.keySet().contains(sourceTargetSelector.getSelectedCell()))
sourceTargetSelector.setSelection(StructuredSelection.EMPTY);
refreshGraph();
}
@Override
public void cellsAdded(Iterable<Cell> cells) {
refreshGraph();
}
@Override
public void alignmentChanged() {
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
sourceTargetSelector.setSelection(StructuredSelection.EMPTY);
}
});
}
@Override
public void cellsPropertyChanged(Iterable<Cell> cells, String propertyName) {
refreshGraph();
}
@Override
public void customFunctionsChanged() {
refreshGraph();
}
});
TaskService taskService = PlatformUI.getWorkbench().getService(TaskService.class);
taskService.addListener(tasksListener = new TaskServiceListener() {
@Override
public void tasksRemoved(Iterable<Task<?>> tasks) {
refreshGraph();
}
@Override
public void tasksAdded(Iterable<Task<?>> tasks) {
refreshGraph();
}
@Override
public void taskUserDataChanged(ResolvedTask<?> task) {
refreshGraph();
}
});
// initialize compatibility checkup and display
CompatibilityService cs = PlatformUI.getWorkbench().getService(CompatibilityService.class);
cs.addListener(compListener = new ExclusiveExtensionListener<CompatibilityMode, CompatibilityModeFactory>() {
@Override
public void currentObjectChanged(final CompatibilityMode arg0, final CompatibilityModeFactory arg1) {
refreshGraph();
}
});
// listen on SchemaSelections
getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(selectionListener = new ISelectionListener() {
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
if (!(selection instanceof SchemaSelection)) {
// only react on schema selections
return;
}
if (part != AlignmentView.this) {
updateRelation((SchemaSelection) selection);
}
}
});
// select type cell, if it is double clicked
getViewer().addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
IStructuredSelection selection = (IStructuredSelection) event.getSelection();
if (selection.size() == 1) {
Object selected = selection.getFirstElement();
if (selected instanceof Cell && AlignmentUtil.isTypeCell((Cell) selected))
sourceTargetSelector.setSelection(selection);
}
}
});
// listen on size changes
getViewer().getControl().addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
updateLayout(true);
}
});
getViewer().setInput(new DefaultCell());
}
use of eu.esdihumboldt.hale.ui.common.service.compatibility.CompatibilityModeFactory 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);
}
use of eu.esdihumboldt.hale.ui.common.service.compatibility.CompatibilityModeFactory in project hale by halestudio.
the class CompatibilityModeComposite method createControl.
/**
* @see org.eclipse.jface.action.ControlContribution#createControl(org.eclipse.swt.widgets.Composite)
*/
@Override
protected Control createControl(Composite parent) {
// initiate the composite for the compatibility elements
Composite comp = new Composite(parent, SWT.NONE);
comp.setLayout(new RowLayout(SWT.HORIZONTAL));
// label for displaying the status of the mode
final Label statusLabel = new Label(comp, SWT.NONE);
statusLabel.setImage(CommonSharedImages.getImageRegistry().get(CommonSharedImages.IMG_SIGNED_YES));
// label for displaying the mode itself
final Label modeLabel = new Label(comp, SWT.NONE);
// Menu for mode selection on left click
IContributionItem popupMenu = new CompatibilityMenu();
final MenuManager mmanager = new MenuManager();
mmanager.add(popupMenu);
modeLabel.setMenu(mmanager.createContextMenu(modeLabel));
modeLabel.addMouseListener(new MouseListener() {
@Override
public void mouseDoubleClick(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseDown(MouseEvent e) {
// TODO Auto-generated method stub
}
@Override
public void mouseUp(MouseEvent e) {
modeLabel.getMenu().setVisible(true);
}
});
// listener to update the mode label
modeListener = new ExclusiveExtensionListener<CompatibilityMode, CompatibilityModeFactory>() {
@Override
public void currentObjectChanged(final CompatibilityMode arg0, final CompatibilityModeFactory arg1) {
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
modeLabel.setText(cs.getCurrentDefinition().getDisplayName());
}
});
}
};
cs.addListener(modeListener);
// listener for updating the mode status label
compListener = new CompatibilityServiceListener() {
@Override
public void compatibilityChanged(final boolean isCompatible, List<Cell> incompatibleCells) {
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
if (isCompatible) {
statusLabel.setImage(CommonSharedImages.getImageRegistry().get(CommonSharedImages.IMG_SIGNED_YES));
statusLabel.setToolTipText("No incompatibility detected!");
}
if (!isCompatible) {
statusLabel.setImage(CommonSharedImages.getImageRegistry().get(CommonSharedImages.IMG_SIGNED_NO));
statusLabel.setToolTipText("Incompatibility detected!");
}
}
});
}
};
cs.addCompatibilityListener(compListener);
modeLabel.setText(cs.getCurrentDefinition().getDisplayName());
statusLabel.setToolTipText("No incompatibility detected!");
return comp;
}
Aggregations