Search in sources :

Example 71 with ISelectionChangedListener

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

the class PropertyEntitiesPage method createHeader.

/**
 * @see EntitiesPage#createHeader(Composite)
 */
@Override
protected Control createHeader(Composite parent) {
    Group typeSelectionGroup = new Group(parent, SWT.NONE);
    typeSelectionGroup.setText("Type");
    typeSelectionGroup.setLayout(new GridLayout());
    sourceTargetSelector = new SourceTargetTypeSelector(typeSelectionGroup);
    sourceTargetSelector.getControl().setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false));
    // set initial selection
    sourceTargetSelector.setSelection(getInitialTypeSelection(SchemaSpaceID.SOURCE), SchemaSpaceID.SOURCE);
    sourceTargetSelector.setSelection(getInitialTypeSelection(SchemaSpaceID.TARGET), SchemaSpaceID.TARGET);
    // add selection listener
    sourceTargetSelector.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            TypeEntityDefinition selectedType = sourceTargetSelector.getSelection(SchemaSpaceID.SOURCE);
            for (PropertyField field : getFunctionFields()) {
                if (field.getSchemaSpace() == SchemaSpaceID.SOURCE) {
                    field.setParentType(selectedType);
                }
            }
        }
    }, SchemaSpaceID.SOURCE);
    sourceTargetSelector.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            TypeEntityDefinition selectedType = sourceTargetSelector.getSelection(SchemaSpaceID.TARGET);
            for (PropertyField field : getFunctionFields()) if (field.getSchemaSpace() == SchemaSpaceID.TARGET)
                field.setParentType(selectedType);
        }
    }, SchemaSpaceID.TARGET);
    return typeSelectionGroup;
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) TypeEntityDefinition(eu.esdihumboldt.hale.common.align.model.impl.TypeEntityDefinition) PropertyField(eu.esdihumboldt.hale.ui.function.generic.pages.internal.PropertyField) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) GridData(org.eclipse.swt.layout.GridData) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) SourceTargetTypeSelector(eu.esdihumboldt.hale.ui.function.common.SourceTargetTypeSelector)

Example 72 with ISelectionChangedListener

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

the class NewRelationPage method createViewer.

/**
 * @see ViewerWizardSelectionPage#createViewer(Composite)
 */
@Override
protected Pair<StructuredViewer, Control> createViewer(Composite parent) {
    PatternFilter filter = new PatternFilter();
    filter.setIncludeLeadingWildcard(true);
    FilteredTree tree = new FilteredTree(parent, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL, filter, true);
    viewer = tree.getViewer();
    viewer.setContentProvider(new FunctionWizardNodeContentProvider(getContainer(), initialSelection, selectionMatcher));
    viewer.setLabelProvider(new FunctionWizardNodeLabelProvider());
    // no input needed, but we have to set something
    viewer.setInput(Boolean.TRUE);
    // set focus on viewer control to prevent odd behavior
    viewer.getControl().setFocus();
    // expand selection
    viewer.expandAll();
    // selection context
    contextProvider = new HALEContextProvider(viewer, null);
    // help update on page shown
    if (getContainer() instanceof IPageChangeProvider) {
        ((IPageChangeProvider) getContainer()).addPageChangedListener(changeListener = new IPageChangedListener() {

            @Override
            public void pageChanged(PageChangedEvent event) {
                if (event.getSelectedPage() == NewRelationPage.this) {
                    // update the help button
                    if (getContainer() instanceof HaleWizardDialog) {
                        ((HaleWizardDialog) getContainer()).setHelpButtonEnabled(getHelpContext() != null);
                    }
                }
            }
        });
    }
    // help update on selection change
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            IContext context = getHelpContext();
            // update the help button
            if (getContainer() instanceof HaleWizardDialog) {
                ((HaleWizardDialog) getContainer()).setHelpButtonEnabled(context != null);
            }
            // update the help
            if (context != null) {
                TrayDialog trayDialog = (TrayDialog) getContainer();
                if (trayDialog.getTray() != null) {
                    // if the tray is already open, update the help
                    performHelp();
                }
            }
        }
    });
    // load page configuration
    // XXX would be better if called from outside
    ProjectService ps = PlatformUI.getWorkbench().getService(ProjectService.class);
    restore(ps.getConfigurationService());
    return new Pair<StructuredViewer, Control>(viewer, tree);
}
Also used : PatternFilter(org.eclipse.ui.dialogs.PatternFilter) IContext(org.eclipse.help.IContext) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) IPageChangeProvider(org.eclipse.jface.dialogs.IPageChangeProvider) ProjectService(eu.esdihumboldt.hale.ui.service.project.ProjectService) PageChangedEvent(org.eclipse.jface.dialogs.PageChangedEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) FilteredTree(org.eclipse.ui.dialogs.FilteredTree) TrayDialog(org.eclipse.jface.dialogs.TrayDialog) HALEContextProvider(eu.esdihumboldt.hale.ui.HALEContextProvider) IPageChangedListener(org.eclipse.jface.dialogs.IPageChangedListener) HaleWizardDialog(eu.esdihumboldt.hale.ui.util.wizard.HaleWizardDialog) Pair(eu.esdihumboldt.util.Pair)

Example 73 with ISelectionChangedListener

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

the class URLSource method createControls.

/**
 * @see ImportSource#createControls(Composite)
 */
@Override
public void createControls(Composite parent) {
    parent.setLayout(new GridLayout(3, false));
    detectImage = HALEUIPlugin.getImageDescriptor("icons/find_obj.gif").createImage();
    // source file
    sourceURL = new URLSourceURIFieldEditor("sourceURL", "Source URL:", parent) {

        @Override
        protected void onHistorySelected(URI location, IContentType contentType) {
            // select the content type associated with the recent URL
            types.setSelection(new StructuredSelection(contentType));
            updateState(false);
        }
    };
    sourceURL.setPage(getPage());
    // set content types for file field
    Collection<IOProviderDescriptor> factories = getConfiguration().getFactories();
    supportedTypes = new HashSet<IContentType>();
    for (IOProviderDescriptor factory : factories) {
        supportedTypes.addAll(factory.getSupportedTypes());
    }
    sourceURL.setContentTypes(supportedTypes);
    sourceURL.setPropertyChangeListener(new IPropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent event) {
            if (event.getProperty().equals(FieldEditor.IS_VALID)) {
                getPage().setMessage(null);
                updateState(false);
            } else if (event.getProperty().equals(FieldEditor.VALUE)) {
                getPage().setMessage(null);
                updateState(false);
            }
        }
    });
    // content type selection
    // label
    Label typesLabel = new Label(parent, SWT.NONE);
    typesLabel.setText("Content type");
    // types combo
    Composite group = new Composite(parent, SWT.NONE);
    group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 2, 1));
    group.setLayout(GridLayoutFactory.fillDefaults().numColumns(2).create());
    types = new ComboViewer(group, SWT.DROP_DOWN | SWT.READ_ONLY);
    types.getControl().setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
    types.setContentProvider(ArrayContentProvider.getInstance());
    types.setLabelProvider(new LabelProvider() {

        @Override
        public String getText(Object element) {
            if (element instanceof IContentType) {
                return ((IContentType) element).getName();
            }
            return super.getText(element);
        }
    });
    types.setInput(supportedTypes);
    // process selection changes
    types.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            updateState(true);
        }
    });
    // detect button
    detect = new Button(group, SWT.PUSH);
    detect.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
    detect.setText("Detect");
    detect.setImage(detectImage);
    detect.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            runDetectContentType();
        }
    });
    // provider selection
    // label
    Label providerLabel = new Label(parent, SWT.NONE);
    providerLabel.setText("Import as");
    // create provider combo
    ComboViewer providers = createProviders(parent);
    providers.getControl().setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1));
    // initial state update
    updateState(true);
}
Also used : IPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener) PropertyChangeEvent(org.eclipse.jface.util.PropertyChangeEvent) IOProviderDescriptor(eu.esdihumboldt.hale.common.core.io.extension.IOProviderDescriptor) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Label(org.eclipse.swt.widgets.Label) IContentType(org.eclipse.core.runtime.content.IContentType) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) URI(java.net.URI) GridLayout(org.eclipse.swt.layout.GridLayout) ComboViewer(org.eclipse.jface.viewers.ComboViewer) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) LabelProvider(org.eclipse.jface.viewers.LabelProvider)

Example 74 with ISelectionChangedListener

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

the class RuleStylePage method createControl.

/**
 * @see IDialogPage#createControl(Composite)
 */
@Override
public void createControl(Composite parent) {
    changed = false;
    Composite page = new Composite(parent, SWT.NONE);
    page.setLayout(new GridLayout(2, false));
    // DISABLED - this method seems to change the rule order - Rule[]
    // ruleArray = SLD.rules(getParent().getStyle());
    // use list instead:
    List<Rule> ruleList;
    try {
        ruleList = getParent().getStyle().featureTypeStyles().get(0).rules();
    } catch (Exception e) {
        ruleList = new ArrayList<Rule>();
    }
    // init index
    if (ruleList.size() > 0) {
        currentIndex = 0;
    } else {
        currentIndex = -1;
    }
    currentEditor = null;
    // populate rule map
    rules = new ArrayList<RuleItem>(ruleList.size() + 5);
    for (int i = 0; i < ruleList.size(); i++) {
        Rule rule = ruleList.get(i);
        if (rule != null) {
            rules.add(new RuleItem(rule));
        }
    }
    // rule list
    Composite ruleArea = new Composite(page, SWT.NONE);
    ruleArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true));
    GridLayout leftLayout = new GridLayout(5, true);
    leftLayout.horizontalSpacing = 1;
    leftLayout.verticalSpacing = 1;
    ruleArea.setLayout(leftLayout);
    // label
    Label rulesLabel = new Label(ruleArea, SWT.NONE);
    rulesLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 5, 1));
    rulesLabel.setFont(JFaceResources.getFontRegistry().getBold(JFaceResources.DEFAULT_FONT));
    rulesLabel.setText(Messages.RuleStylePage_RuleLabelText);
    // viewer
    listViewer = new ListViewer(ruleArea);
    listViewer.getList().setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, true, 5, 1));
    listViewer.setContentProvider(new IStructuredContentProvider() {

        @Override
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        // ignore
        }

        @Override
        public void dispose() {
        // ignore
        }

        @SuppressWarnings("unchecked")
        @Override
        public Object[] getElements(Object inputElement) {
            try {
                List<RuleItem> rules = (List<RuleItem>) inputElement;
                return rules.toArray();
            } catch (Exception e) {
                return null;
            }
        }
    });
    listViewer.setInput(rules);
    if (currentIndex >= 0 && currentIndex < rules.size()) {
        listViewer.setSelection(new StructuredSelection(rules.get(currentIndex)));
    }
    listViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            RuleItem item = (RuleItem) ((IStructuredSelection) event.getSelection()).getFirstElement();
            int newIndex = rules.indexOf(item);
            if (currentIndex != newIndex) {
                try {
                    updateCurrentRule();
                } catch (Exception e) {
                    log.userError("Invalid editor state, could not update rule.", e);
                    return;
                }
                currentIndex = newIndex;
                updateEditor();
            }
        }
    });
    // buttons
    addButton = new Button(ruleArea, SWT.PUSH);
    addButton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
    addButton.setImage(addImage);
    addButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            addRule();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // ignore
        }
    });
    addButton.setToolTipText(Messages.RuleStylePage_AddRuleButtonToolTippText);
    removeButton = new Button(ruleArea, SWT.PUSH);
    removeButton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
    removeButton.setImage(removeImage);
    removeButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            removeCurrentRule();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // ignore
        }
    });
    removeButton.setToolTipText(Messages.RuleStylePage_RemoveRuleButtonToolTippText);
    upButton = new Button(ruleArea, SWT.PUSH);
    upButton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
    upButton.setImage(upImage);
    upButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            moveCurrentRuleUp();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // ignore
        }
    });
    upButton.setToolTipText(Messages.RuleStylePage_UpRuleButtonToolTippText);
    downButton = new Button(ruleArea, SWT.PUSH);
    downButton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
    downButton.setImage(downImage);
    downButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            moveCurrentRuleDown();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // ignore
        }
    });
    downButton.setToolTipText(Messages.RuleStylePage_DownRuleButtonToolTippText);
    renameButton = new Button(ruleArea, SWT.PUSH);
    renameButton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
    renameButton.setImage(renameImage);
    renameButton.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            renameCurrentRule();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
        // ignore
        }
    });
    renameButton.setToolTipText(Messages.RuleStylePage_RenameRuleButtonToolTippText);
    // editor area
    editorArea = new Composite(page, SWT.NONE);
    editorArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
    editorArea.setLayout(new FillLayout());
    setControl(page);
    updateEditor();
}
Also used : ArrayList(java.util.ArrayList) Label(org.eclipse.swt.widgets.Label) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ListViewer(org.eclipse.jface.viewers.ListViewer) Viewer(org.eclipse.jface.viewers.Viewer) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ArrayList(java.util.ArrayList) List(java.util.List) ListViewer(org.eclipse.jface.viewers.ListViewer) Composite(org.eclipse.swt.widgets.Composite) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) FillLayout(org.eclipse.swt.layout.FillLayout) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) Rule(org.geotools.styling.Rule) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 75 with ISelectionChangedListener

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

the class MismatchPropertiesBlock method createMasterPart.

/* (non-Javadoc)
	 * @see org.eclipse.ui.forms.MasterDetailsBlock#createMasterPart(org.eclipse.ui.forms.IManagedForm, org.eclipse.swt.widgets.Composite)
	 */
@Override
protected void createMasterPart(final IManagedForm managedForm, Composite parent) {
    FormToolkit toolkit = managedForm.getToolkit();
    Section section = toolkit.createSection(parent, Section.DESCRIPTION | Section.TITLE_BAR);
    // $NON-NLS-1$
    section.setText("Mismatches");
    section.setDescription(// $NON-NLS-1$
    "Select the Mismatch or one of it's children to view and edit it.");
    section.marginWidth = 10;
    section.marginHeight = 5;
    Composite client = toolkit.createComposite(section, SWT.WRAP);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    layout.marginWidth = 2;
    layout.marginHeight = 2;
    client.setLayout(layout);
    Tree tree = toolkit.createTree(client, SWT.NULL);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.heightHint = 20;
    gd.widthHint = 250;
    tree.setLayoutData(gd);
    toolkit.paintBordersFor(client);
    section.setClient(client);
    final SectionPart spart = new SectionPart(section);
    managedForm.addPart(spart);
    TreeViewer mismatchTreeViewer = new TreeViewer(tree);
    mismatchTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {

        @Override
        public void selectionChanged(SelectionChangedEvent event) {
            managedForm.fireSelectionChanged(spart, event.getSelection());
        }
    });
    mismatchTreeViewer.setContentProvider(new MismatchTreeContentProvider());
    mismatchTreeViewer.setLabelProvider(new MismatchTreeLabelProvider());
    mismatchTreeViewer.setInput(getDummyCell());
}
Also used : FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) Composite(org.eclipse.swt.widgets.Composite) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) Section(org.eclipse.ui.forms.widgets.Section) GridLayout(org.eclipse.swt.layout.GridLayout) SectionPart(org.eclipse.ui.forms.SectionPart) GridData(org.eclipse.swt.layout.GridData) Tree(org.eclipse.swt.widgets.Tree)

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