use of eu.esdihumboldt.hale.ui.util.viewer.ViewerMenu in project hale by halestudio.
the class AbstractMappingView method createViewControl.
@Override
public void createViewControl(Composite parent) {
viewer = new GraphViewer(parent, SWT.BORDER);
viewer.setContentProvider(createContentProvider());
// viewer.setContentProvider(new CellRelationshipContentProvider());
// viewer.setContentProvider(new NestedCellRelationshipContentProvider());
viewer.setLabelProvider(createLabelProvider(viewer));
viewer.setInput(null);
LayoutAlgorithm layout = createLayout();
viewer.setLayoutAlgorithm(layout, true);
viewer.applyLayout();
fillToolBar();
// set selection provider
selectionFacade = new SelectionProviderFacade();
selectionFacade.setSelectionProvider(getViewer());
getSite().setSelectionProvider(new PostSelectionSupport(selectionFacade));
viewer.getControl().addKeyListener(new KeyListener() {
@Override
public void keyReleased(KeyEvent e) {
if (e.keyCode == 'a' && (e.stateMask & SWT.MODIFIER_MASK) == SWT.CTRL) {
// XXX even though getSelection returns the current state, a
// selection update is not triggered by the control
// -> force selection change event after Ctrl+A
ISelection sel = viewer.getSelection();
selectionFacade.setSelection(sel);
}
}
@Override
public void keyPressed(KeyEvent e) {
// nothing to do
}
});
// create context menu
new ViewerMenu(getSite(), getViewer()) {
/**
* @see eu.esdihumboldt.hale.ui.util.ViewContextMenu#menuAboutToShow(org.eclipse.jface.action.IMenuManager)
*/
@Override
public void menuAboutToShow(IMenuManager manager) {
super.menuAboutToShow(manager);
AbstractMappingView.this.menuAboutToShow(manager);
}
};
}
use of eu.esdihumboldt.hale.ui.util.viewer.ViewerMenu 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.util.viewer.ViewerMenu in project hale by halestudio.
the class SchemasView method createViewControl.
/**
* @see eu.esdihumboldt.hale.ui.views.properties.PropertiesViewPart#createViewControl(org.eclipse.swt.widgets.Composite)
*/
@Override
public void createViewControl(Composite _parent) {
Composite modelComposite = new Composite(_parent, SWT.BEGINNING);
GridLayout layout = new GridLayout(3, false);
layout.verticalSpacing = 3;
layout.horizontalSpacing = 0;
modelComposite.setLayout(layout);
// source schema toolbar, filter and explorer
// sourceExplorer = new SchemaExplorer(modelComposite, "Source");
sourceExplorer = new EntitySchemaExplorer(modelComposite, "Source", SchemaSpaceID.SOURCE);
GridDataFactory.fillDefaults().grab(true, true).hint(400, 10).applyTo(sourceExplorer.getControl());
sourceExplorerManager = new ServiceSchemaExplorer(sourceExplorer, SchemaSpaceID.SOURCE);
// function button
final Button functionButton = new Button(modelComposite, SWT.PUSH | SWT.FLAT);
// $NON-NLS-1$
functionImage = SchemasViewPlugin.getImageDescriptor("icons/mapping.gif").createImage();
// $NON-NLS-1$
augmentImage = SchemasViewPlugin.getImageDescriptor("icons/augment.gif").createImage();
functionButton.setImage(functionImage);
functionButton.setToolTipText(Messages.ModelNavigationView_FunctionButtonToolTipText);
functionButton.setEnabled(false);
functionButton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
MenuManager manager = new MenuManager();
manager.setRemoveAllWhenShown(true);
final SchemaFunctionContribution functionContribution = new SchemaFunctionContribution();
manager.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(IMenuManager manager) {
// populate context menu
manager.add(functionContribution);
}
});
final Menu functionMenu = manager.createContextMenu(functionButton);
functionButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
// show menu on button press
functionMenu.setLocation(Display.getCurrent().getCursorLocation());
functionMenu.setVisible(true);
}
});
// target schema toolbar, filter and explorer
targetExplorer = new EntitySchemaExplorer(modelComposite, "Target", SchemaSpaceID.TARGET);
GridDataFactory.fillDefaults().grab(true, true).hint(400, 10).applyTo(targetExplorer.getControl());
targetExplorerManager = new ServiceSchemaExplorer(targetExplorer, SchemaSpaceID.TARGET);
// source context menu
new ViewerMenu(getSite(), sourceExplorer.getTreeViewer());
// target context menu
new ViewerMenu(getSite(), targetExplorer.getTreeViewer());
// register selection provider
getSite().setSelectionProvider(selectionProvider = new SchemasSelectionProvider());
// listen for selection changes and update function button
selectionProvider.addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
functionButton.setEnabled(functionContribution.hasActiveFunctions());
if (event.getSelection() instanceof SchemaSelection) {
SchemaSelection selection = (SchemaSelection) event.getSelection();
if (selection.getSourceItems().size() == 0 && selection.getTargetItems().size() > 0) {
// augmentation
functionButton.setImage(augmentImage);
} else {
// function
functionButton.setImage(functionImage);
}
}
}
});
// view toolbar
getViewSite().getActionBars().getToolBarManager().add(cellSyncAction = new CellSyncAction(getSite().getPage().getWorkbenchWindow().getSelectionService(), sourceExplorer, targetExplorer));
}
use of eu.esdihumboldt.hale.ui.util.viewer.ViewerMenu in project hale by halestudio.
the class TypeHierarchyView 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, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
viewer.setContentProvider(new TypeHierarchyContentProvider());
viewer.setLabelProvider(new TypeHierarchyLabelProvider(viewer));
viewer.setComparator(new DefinitionComparator());
contributeToActionBars();
viewer.addDoubleClickListener(new IDoubleClickListener() {
@Override
public void doubleClick(DoubleClickEvent event) {
update(event.getSelection());
}
});
getSite().getWorkbenchWindow().getSelectionService().addPostSelectionListener(selectionListener = new ISelectionListener() {
@Override
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
if (!(part instanceof PropertiesViewPart)) {
// selections
return;
}
if (part != TypeHierarchyView.this) {
update(selection);
}
}
});
getSite().setSelectionProvider(selectionProvider = new SelectionFilter(viewer) {
@Override
protected ISelection filter(ISelection selection) {
if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
List<Object> elements = new ArrayList<Object>();
for (Object element : ((IStructuredSelection) selection).toList()) {
if (element instanceof ParentPath) {
// add parent path head instead of parent path
elements.add(((ParentPath) element).getHead());
} else {
elements.add(element);
}
}
return new StructuredSelection(elements);
} else {
return selection;
}
}
});
new ViewerMenu(getSite(), viewer);
}
use of eu.esdihumboldt.hale.ui.util.viewer.ViewerMenu in project hale by halestudio.
the class ResourcesView method createViewControl.
@Override
protected void createViewControl(Composite parent) {
viewer = new TreeViewer(parent);
viewer.setContentProvider(new ResourcesContentProvider());
viewer.setLabelProvider(new ResourcesLabelProvider());
ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
ps.addListener(projectServiceListener = new ProjectServiceAdapter() {
@Override
public void resourceAdded(String actionId, Resource resource) {
updateInDisplayThread();
}
@Override
public void resourcesRemoved(String actionId, List<Resource> resources) {
updateInDisplayThread();
}
@Override
public void afterLoad(ProjectService projectService) {
updateInDisplayThread();
}
@Override
public void projectInfoChanged(ProjectInfo info) {
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
viewer.update(ProjectToken.TOKEN, null);
updateInDisplayThread();
}
});
}
});
viewer.setUseHashlookup(true);
viewer.setAutoExpandLevel(3);
update();
new ViewerMenu(getSite(), viewer);
getSite().setSelectionProvider(viewer);
// adding listener to refresh the resource view when any schema,
// instance is added or cleared.
SchemaService ss = PlatformUI.getWorkbench().getService(SchemaService.class);
ssListener = new SchemaServiceListener() {
@Override
public void schemaRemoved(SchemaSpaceID spaceID) {
final Display display = PlatformUI.getWorkbench().getDisplay();
display.syncExec(new Runnable() {
@Override
public void run() {
updateInDisplayThread();
}
});
}
@Override
public void schemasCleared(final SchemaSpaceID spaceID) {
final Display display = PlatformUI.getWorkbench().getDisplay();
display.syncExec(new Runnable() {
@Override
public void run() {
updateInDisplayThread();
}
});
}
@Override
public void schemaAdded(final SchemaSpaceID spaceID, Schema schema) {
final Display display = PlatformUI.getWorkbench().getDisplay();
display.syncExec(new Runnable() {
@Override
public void run() {
updateInDisplayThread();
}
});
}
@Override
public void mappableTypesChanged(final SchemaSpaceID spaceID, Collection<? extends TypeDefinition> types) {
final Display display = PlatformUI.getWorkbench().getDisplay();
display.syncExec(new Runnable() {
@Override
public void run() {
updateInDisplayThread();
}
});
}
};
ss.addSchemaServiceListener(ssListener);
InstanceService is = PlatformUI.getWorkbench().getService(InstanceService.class);
is.addListener(isa = new InstanceServiceAdapter() {
@Override
public void datasetChanged(DataSet type) {
final Display display = PlatformUI.getWorkbench().getDisplay();
display.syncExec(new Runnable() {
@Override
public void run() {
updateInDisplayThread();
}
});
}
});
}
Aggregations