Search in sources :

Example 76 with ISelectionChangedListener

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

the class BasicConfigurationWithWMSListPage method createComponent.

@Override
public void createComponent() {
    super.createComponent();
    Button storeWMS = new Button(getComposite(), SWT.PUSH);
    storeWMS.setText(Messages.WMSListConfigurationPage_2);
    // add new WMS to list and refresh
    storeWMS.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            // store WMS i UI list
            map.put(getServiceName(), getServiceURL());
            getListForUI(listUI);
            comboViewer.refresh();
        }
    });
    // free line
    new Text(getComposite(), SWT.NONE).setEditable(false);
    new Text(getComposite(), SWT.NONE).setEditable(false);
    new Text(getComposite(), SWT.NONE).setEditable(false);
    new Text(getComposite(), SWT.NONE).setEditable(false);
    new Text(getComposite(), SWT.NONE).setEditable(false);
    // add text and combo viewer
    Text text = new Text(getComposite(), SWT.NONE);
    text.setEditable(false);
    text.setText(Messages.WMSListConfigurationPage_0);
    // get a list of all WMS
    // get all WMS, storing as WMS Map Server
    Preferences PREF_SERVERS = new WMSMapServer().getPreferences();
    String[] prefs = null;
    try {
        prefs = PREF_SERVERS.childrenNames();
        // put all in map
        for (String current : prefs) {
            Preferences child = PREF_SERVERS.node(current);
            map.put(current, child.get("baseUrl", "baseUrl"));
        }
    } catch (BackingStoreException e) {
        // $NON-NLS-1$
        log.warn(Messages.WMSListConfigurationPage_1, e);
    }
    // get all WMS, storing as extension points
    IConfigurationElement[] allER = Platform.getExtensionRegistry().getConfigurationElementsFor("de.fhg.igd.mapviewer.server.MapServer");
    for (IConfigurationElement current : allER) {
        String name = "";
        String url = "";
        // name is stored directly as attribute
        name = current.getAttribute("name");
        // url is stored as child
        for (IConfigurationElement child : current.getChildren()) {
            if (child.getAttribute("name").equals("baseUrl")) {
                url = child.getAttribute("value");
            }
        }
        // store everything into map
        if (name != null && !name.isEmpty() && url != null && !url.isEmpty()) {
            map.put(name, url);
        }
    }
    // show stored WMS as DropDown
    comboViewer = new ComboViewer(getComposite(), SWT.DROP_DOWN | SWT.BORDER | SWT.READ_ONLY);
    comboViewer.setContentProvider(new ArrayContentProvider());
    getListForUI(listUI);
    comboViewer.setInput(listUI);
    comboViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IStructuredSelection selection = (IStructuredSelection) event.getSelection();
            if (selection.size() > 0) {
                String currentSelection = (String) selection.getFirstElement();
                name.setStringValue(currentSelection);
                location.setStringValue(map.get(currentSelection));
            }
        }
    });
}
Also used : WMSMapServer(de.fhg.igd.mapviewer.server.wms.WMSMapServer) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) BackingStoreException(java.util.prefs.BackingStoreException) Text(org.eclipse.swt.widgets.Text) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) Button(org.eclipse.swt.widgets.Button) ComboViewer(org.eclipse.jface.viewers.ComboViewer) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) Preferences(java.util.prefs.Preferences)

Example 77 with ISelectionChangedListener

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

the class SRSConfigurationPage method createContent.

/**
 * @see WMSWizardPage#createContent(Composite)
 */
@Override
public void createContent(Composite parent) {
    Composite page = new Composite(parent, SWT.NONE);
    page.setLayout(new GridLayout(1, false));
    // SRS
    Combo combo = new Combo(page, SWT.DROP_DOWN | SWT.READ_ONLY);
    combo.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
    viewer = new ComboViewer(combo);
    viewer.setContentProvider(new ArrayContentProvider());
    viewer.setLabelProvider(new SRSLabelProvider());
    viewer.addPostSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            update();
        }
    });
    setControl(page);
    update();
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) ComboViewer(org.eclipse.jface.viewers.ComboViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) ArrayContentProvider(org.eclipse.jface.viewers.ArrayContentProvider) Combo(org.eclipse.swt.widgets.Combo) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent)

Example 78 with ISelectionChangedListener

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

the class InstanceExportConfigurationPage method onShowPage.

@Override
protected void onShowPage(boolean firstShow) {
    if (firstShow) {
        ViewerFilter[] filters = { validTypesToSelect };
        typeSelector = new TypeDefinitionSelector(page, "Select the corresponding schema type", getWizard().getProvider().getTargetSchema(), filters);
        typeSelector.getControl().setLayoutData(GridDataFactory.fillDefaults().grab(true, false).span(1, 1).create());
        typeSelector.addSelectionChangedListener(new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                setPageComplete(!(event.getSelection().isEmpty()));
                if (typeSelector.getSelectedObject() != null) {
                    // TypeDefinition type =
                    // typeSelector.getSelectedObject();
                    // label.getParent().layout();
                    page.layout();
                    page.pack();
                }
            }
        });
    }
    page.layout();
    page.pack();
}
Also used : ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) TypeDefinitionSelector(eu.esdihumboldt.hale.ui.common.definition.selector.TypeDefinitionSelector) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent)

Example 79 with ISelectionChangedListener

use of org.eclipse.jface.viewers.ISelectionChangedListener in project archi by archimatetool.

the class NewNestedRelationDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    // Help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
    setTitle(Messages.NewNestedRelationDialog_1);
    String message = NLS.bind(Messages.NewNestedRelationDialog_2, fParentElement.getName(), fChildElement.getName());
    setMessage(message);
    Composite composite = (Composite) super.createDialogArea(parent);
    Composite client = new Composite(composite, SWT.NULL);
    GridLayout layout = new GridLayout(1, false);
    client.setLayout(layout);
    client.setLayoutData(new GridData(GridData.FILL_BOTH));
    Composite tableComp = new Composite(client, SWT.BORDER);
    tableComp.setLayout(new TableColumnLayout());
    tableComp.setLayoutData(new GridData(GridData.FILL_BOTH));
    fTableViewer = new RelationsTableViewer(tableComp, SWT.NONE);
    fTableViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
    // anything will do //$NON-NLS-1$
    fTableViewer.setInput("");
    fTableViewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            okPressed();
        }
    });
    fTableViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            fSelected = (EClass) ((IStructuredSelection) fTableViewer.getSelection()).getFirstElement();
        }
    });
    if (fValidRelations != null && fValidRelations.length > 0) {
        fTableViewer.setSelection(new StructuredSelection(fValidRelations[0]));
    }
    return composite;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) GridLayout(org.eclipse.swt.layout.GridLayout) EClass(org.eclipse.emf.ecore.EClass) TableColumnLayout(org.eclipse.jface.layout.TableColumnLayout) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) GridData(org.eclipse.swt.layout.GridData)

Example 80 with ISelectionChangedListener

use of org.eclipse.jface.viewers.ISelectionChangedListener in project archi by archimatetool.

the class ValidatorView method createPartControl.

@Override
public void createPartControl(Composite parent) {
    Composite treeComp = new Composite(parent, SWT.NULL);
    treeComp.setLayout(new TreeColumnLayout());
    treeComp.setLayoutData(new GridData(GridData.FILL_BOTH));
    fViewer = new ValidatorViewer(treeComp, SWT.NULL);
    fViewer.addDoubleClickListener(new IDoubleClickListener() {

        public void doubleClick(DoubleClickEvent event) {
            selectObjects((IStructuredSelection) event.getSelection());
        }
    });
    fViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        public void selectionChanged(SelectionChangedEvent event) {
            updateMenuItems((IStructuredSelection) event.getSelection());
        }
    });
    makeActions();
    registerGlobalActions();
    makeLocalToolBar();
    hookContextMenu();
    // Listen to global selections to update the viewer
    getSite().getWorkbenchWindow().getSelectionService().addSelectionListener(this);
    // Selection Provider
    getSite().setSelectionProvider(fViewer);
    // Help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
    // Register us as a Model Listener
    IEditorModelManager.INSTANCE.addPropertyChangeListener(this);
    // Initialise with whatever is selected in the workbench
    selectionChanged(getSite().getWorkbenchWindow().getPartService().getActivePart(), getSite().getWorkbenchWindow().getSelectionService().getSelection());
    // Table row bug on Yosemite https://bugs.eclipse.org/bugs/show_bug.cgi?id=446534
    if (PlatformUtils.isMac() && System.getProperty("os.version").startsWith("10.10")) {
        // $NON-NLS-1$//$NON-NLS-2$
        Display.getCurrent().asyncExec(new Runnable() {

            public void run() {
                validateModel();
            }
        });
    } else {
        validateModel();
    }
}
Also used : Composite(org.eclipse.swt.widgets.Composite) TreeColumnLayout(org.eclipse.jface.layout.TreeColumnLayout) IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

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