Search in sources :

Example 1 with ServiceSchemaExplorer

use of eu.esdihumboldt.hale.ui.views.schemas.explorer.ServiceSchemaExplorer 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));
}
Also used : Composite(org.eclipse.swt.widgets.Composite) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IMenuListener(org.eclipse.jface.action.IMenuListener) ViewerMenu(eu.esdihumboldt.hale.ui.util.viewer.ViewerMenu) GridLayout(org.eclipse.swt.layout.GridLayout) EntitySchemaExplorer(eu.esdihumboldt.hale.ui.views.schemas.explorer.EntitySchemaExplorer) Button(org.eclipse.swt.widgets.Button) ServiceSchemaExplorer(eu.esdihumboldt.hale.ui.views.schemas.explorer.ServiceSchemaExplorer) GridData(org.eclipse.swt.layout.GridData) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IMenuManager(org.eclipse.jface.action.IMenuManager) ViewerMenu(eu.esdihumboldt.hale.ui.util.viewer.ViewerMenu) Menu(org.eclipse.swt.widgets.Menu) SchemaSelection(eu.esdihumboldt.hale.ui.selection.SchemaSelection) DefaultSchemaSelection(eu.esdihumboldt.hale.ui.selection.impl.DefaultSchemaSelection)

Example 2 with ServiceSchemaExplorer

use of eu.esdihumboldt.hale.ui.views.schemas.explorer.ServiceSchemaExplorer 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());
}
Also used : Composite(org.eclipse.swt.widgets.Composite) EntitySchemaExplorer(eu.esdihumboldt.hale.ui.views.schemas.explorer.EntitySchemaExplorer) ServiceSchemaExplorer(eu.esdihumboldt.hale.ui.views.schemas.explorer.ServiceSchemaExplorer) FillLayout(org.eclipse.swt.layout.FillLayout) ViewerMenu(eu.esdihumboldt.hale.ui.util.viewer.ViewerMenu)

Aggregations

ViewerMenu (eu.esdihumboldt.hale.ui.util.viewer.ViewerMenu)2 EntitySchemaExplorer (eu.esdihumboldt.hale.ui.views.schemas.explorer.EntitySchemaExplorer)2 ServiceSchemaExplorer (eu.esdihumboldt.hale.ui.views.schemas.explorer.ServiceSchemaExplorer)2 Composite (org.eclipse.swt.widgets.Composite)2 SchemaSelection (eu.esdihumboldt.hale.ui.selection.SchemaSelection)1 DefaultSchemaSelection (eu.esdihumboldt.hale.ui.selection.impl.DefaultSchemaSelection)1 IMenuListener (org.eclipse.jface.action.IMenuListener)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 FillLayout (org.eclipse.swt.layout.FillLayout)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Menu (org.eclipse.swt.widgets.Menu)1