use of eu.esdihumboldt.hale.ui.views.schemas.explorer.EntitySchemaExplorer 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.views.schemas.explorer.EntitySchemaExplorer in project hale by halestudio.
the class AbstractSchemaView method createViewControl.
@Override
public void createViewControl(Composite _parent) {
Composite modelComposite = new Composite(_parent, SWT.NONE);
modelComposite.setLayout(new FillLayout());
explorer = new EntitySchemaExplorer(modelComposite, getTitle(), schemaSpace);
explorerManager = new ServiceSchemaExplorer(explorer, schemaSpace);
// context menu
new ViewerMenu(getSite(), explorer.getTreeViewer());
// register selection provider
getSite().setSelectionProvider(explorer.getTreeViewer());
}
Aggregations