Search in sources :

Example 51 with ISelectionChangedListener

use of org.eclipse.jface.viewers.ISelectionChangedListener in project Malai by arnobl.

the class WidgetEditor method setCurrentViewer.

/**
 * This makes sure that one content viewer, either for the current page or the outline view, if it has focus,
 * is the current one.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setCurrentViewer(Viewer viewer) {
    // 
    if (currentViewer != viewer) {
        if (selectionChangedListener == null) {
            // Create the listener on demand.
            // 
            selectionChangedListener = new ISelectionChangedListener() {

                // This just notifies those things that are affected by the section.
                // 
                public void selectionChanged(SelectionChangedEvent selectionChangedEvent) {
                    setSelection(selectionChangedEvent.getSelection());
                }
            };
        }
        // 
        if (currentViewer != null) {
            currentViewer.removeSelectionChangedListener(selectionChangedListener);
        }
        // 
        if (viewer != null) {
            viewer.addSelectionChangedListener(selectionChangedListener);
        }
        // Remember it.
        // 
        currentViewer = viewer;
        // Set the editors selection based on the current viewer's selection.
        // 
        setSelection(currentViewer == null ? StructuredSelection.EMPTY : currentViewer.getSelection());
    }
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent)

Example 52 with ISelectionChangedListener

use of org.eclipse.jface.viewers.ISelectionChangedListener in project Malai by arnobl.

the class WidgetEditor method getContentOutlinePage.

/**
 * This accesses a cached version of the content outliner.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public IContentOutlinePage getContentOutlinePage() {
    if (contentOutlinePage == null) {
        // 
        class MyContentOutlinePage extends ContentOutlinePage {

            @Override
            public void createControl(Composite parent) {
                super.createControl(parent);
                contentOutlineViewer = getTreeViewer();
                contentOutlineViewer.addSelectionChangedListener(this);
                // Set up the tree viewer.
                // 
                contentOutlineViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
                contentOutlineViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory));
                contentOutlineViewer.setInput(editingDomain.getResourceSet());
                // Make sure our popups work.
                // 
                createContextMenuFor(contentOutlineViewer);
                if (!editingDomain.getResourceSet().getResources().isEmpty()) {
                    // Select the root object in the view.
                    // 
                    contentOutlineViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true);
                }
            }

            @Override
            public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager, IStatusLineManager statusLineManager) {
                super.makeContributions(menuManager, toolBarManager, statusLineManager);
                contentOutlineStatusLineManager = statusLineManager;
            }

            @Override
            public void setActionBars(IActionBars actionBars) {
                super.setActionBars(actionBars);
                getActionBarContributor().shareGlobalActions(this, actionBars);
            }
        }
        contentOutlinePage = new MyContentOutlinePage();
        // Listen to selection so that we can handle it is a special way.
        // 
        contentOutlinePage.addSelectionChangedListener(new ISelectionChangedListener() {

            // This ensures that we handle selections correctly.
            // 
            public void selectionChanged(SelectionChangedEvent event) {
                handleContentOutlineSelection(event.getSelection());
            }
        });
    }
    return contentOutlinePage;
}
Also used : ContentOutlinePage(org.eclipse.ui.views.contentoutline.ContentOutlinePage) IContentOutlinePage(org.eclipse.ui.views.contentoutline.IContentOutlinePage) Composite(org.eclipse.swt.widgets.Composite) IToolBarManager(org.eclipse.jface.action.IToolBarManager) IStatusLineManager(org.eclipse.jface.action.IStatusLineManager) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) AdapterFactoryContentProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider) AdapterFactoryLabelProvider(org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IMenuManager(org.eclipse.jface.action.IMenuManager) IActionBars(org.eclipse.ui.IActionBars)

Example 53 with ISelectionChangedListener

use of org.eclipse.jface.viewers.ISelectionChangedListener in project Malai by arnobl.

the class WidgetEditor method setSelection.

/**
 * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to set this editor's overall selection.
 * Calling this result will notify the listeners.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void setSelection(ISelection selection) {
    editorSelection = selection;
    for (ISelectionChangedListener listener : selectionChangedListeners) {
        listener.selectionChanged(new SelectionChangedEvent(this, selection));
    }
    setStatusLineManager(selection);
}
Also used : ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent)

Example 54 with ISelectionChangedListener

use of org.eclipse.jface.viewers.ISelectionChangedListener in project hale by halestudio.

the class AbstractWFSCapabilitiesPage method createContent.

@Override
protected void createContent(Composite parent) {
    Composite page = new Composite(parent, SWT.NONE);
    page.setLayout(new GridLayout(2, false));
    // capabilities field
    location = new WFSCapabilitiesFieldEditor("location", "GetCapabilities URL", page) {

        @Override
        protected WFSVersion getWFSVersion() {
            if (versionSelect != null) {
                ISelection sel = versionSelect.getSelection();
                if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
                    Object selected = ((IStructuredSelection) sel).getFirstElement();
                    if (NoObject.NONE.equals(selected)) {
                        return null;
                    }
                    return (WFSVersion) selected;
                }
            }
            return super.getWFSVersion();
        }
    };
    location.setPage(this);
    location.setPropertyChangeListener(new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(FieldEditor.IS_VALID)) {
                update();
            }
        }
    });
    String currentValue = getCapabilitiesURL(getWizard().getConfiguration());
    if (currentValue != null) {
        location.setValue(currentValue);
    }
    // version field
    Label vLabel = new Label(page, SWT.NONE);
    vLabel.setText("WFS version");
    versionSelect = new ComboViewer(page, SWT.READ_ONLY);
    GridDataFactory.fillDefaults().grab(true, false).applyTo(versionSelect.getControl());
    versionSelect.setContentProvider(new EnumContentProvider() {

        @Override
        public Object[] getElements(Object inputElement) {
            Object[] values = super.getElements(inputElement);
            // add a NoObject
            values = Arrays.copyOf(values, values.length + 1, Object[].class);
            values[values.length - 1] = NoObject.NONE;
            return values;
        }
    });
    versionSelect.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof NoObject) {
                return "Based on URL / server default";
            }
            return super.getText(element);
        }
    });
    versionSelect.setInput(WFSVersion.class);
    versionSelect.setSelection(new StructuredSelection(NoObject.NONE));
    versionSelect.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            location.revalidate();
        }
    });
    setControl(page);
    update();
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) Label(org.eclipse.swt.widgets.Label) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) WFSVersion(eu.esdihumboldt.hale.io.wfs.WFSVersion) EnumContentProvider(eu.esdihumboldt.hale.ui.util.viewer.EnumContentProvider) GridLayout(org.eclipse.swt.layout.GridLayout) ComboViewer(org.eclipse.jface.viewers.ComboViewer) ISelection(org.eclipse.jface.viewers.ISelection) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 55 with ISelectionChangedListener

use of org.eclipse.jface.viewers.ISelectionChangedListener in project hale by halestudio.

the class ClassificationMappingParameterPage method createContent.

/**
 * @see eu.esdihumboldt.hale.ui.HaleWizardPage#createContent(org.eclipse.swt.widgets.Composite)
 */
@Override
protected void createContent(Composite page) {
    page.setLayout(GridLayoutFactory.swtDefaults().numColumns(4).create());
    // not classified action
    notClassifiedActionComposite = new Composite(page, SWT.NONE);
    notClassifiedActionComposite.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 4, 1));
    notClassifiedActionComposite.setLayout(GridLayoutFactory.swtDefaults().numColumns(4).margins(0, 0).create());
    Label notClassifiedActionLabel = new Label(notClassifiedActionComposite, SWT.NONE);
    notClassifiedActionLabel.setText("For unmapped source values");
    notClassifiedActionLabel.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false));
    notClassifiedActionViewer = new ComboViewer(notClassifiedActionComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
    notClassifiedActionViewer.getControl().setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));
    notClassifiedActionViewer.setContentProvider(ArrayContentProvider.getInstance());
    notClassifiedActionViewer.setInput(notClassifiedActionOptions);
    notClassifiedActionViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            if (notClassifiedActionOptions.indexOf(((IStructuredSelection) event.getSelection()).getFirstElement()) == 2)
                createFixedValueInputButton(null);
            else
                removeFixedValueInputButton();
        }
    });
    notClassifiedActionViewer.setSelection(new StructuredSelection(notClassifiedActionOptions.get(0)));
    if (notClassifiedAction != null) {
        if (notClassifiedAction.equals("source"))
            notClassifiedActionViewer.setSelection(new StructuredSelection(notClassifiedActionOptions.get(1)));
        else if (notClassifiedAction.startsWith("fixed:")) {
            notClassifiedActionViewer.setSelection(new StructuredSelection(notClassifiedActionOptions.get(2)));
            createFixedValueInputButton(notClassifiedAction.substring(6));
        }
    }
    // Tabs
    tabs = new TabFolder(page, SWT.NONE);
    tabs.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    // The manualTab for the manual way to specify something like a
    // lookupTable
    manualItem = new TabItem(tabs, SWT.NONE);
    manualItem.setText("Explicit");
    manualItem.setControl(createManualTabControl(tabs));
    // FromFileTab to load lookupTable from file
    fromFileItem = new TabItem(tabs, SWT.NONE);
    fromFileItem.setText("From file");
    fromFileItem.setControl(createFromFileTabControl(tabs));
    if (selectedLookupTableID != null) {
        tabs.setSelection(fromFileItem);
    }
}
Also used : TabItem(org.eclipse.swt.widgets.TabItem) Composite(org.eclipse.swt.widgets.Composite) ComboViewer(org.eclipse.jface.viewers.ComboViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) TabFolder(org.eclipse.swt.widgets.TabFolder) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent)

Aggregations

ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)774 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)755 GridData (org.eclipse.swt.layout.GridData)419 Composite (org.eclipse.swt.widgets.Composite)333 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)302 GridLayout (org.eclipse.swt.layout.GridLayout)247 SelectionEvent (org.eclipse.swt.events.SelectionEvent)187 Label (org.eclipse.swt.widgets.Label)157 TableViewer (org.eclipse.jface.viewers.TableViewer)151 AdapterFactoryLabelProvider (org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider)147 Button (org.eclipse.swt.widgets.Button)141 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)139 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)131 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)121 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)120 IPropertiesEditionEvent (org.eclipse.emf.eef.runtime.api.notify.IPropertiesEditionEvent)116 PropertiesEditionEvent (org.eclipse.emf.eef.runtime.impl.notify.PropertiesEditionEvent)116 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)116 Table (org.eclipse.swt.widgets.Table)93 ISelection (org.eclipse.jface.viewers.ISelection)87