Search in sources :

Example 1 with FilterEvent

use of org.eclipse.wst.common.project.facet.core.util.FilterEvent in project webtools.sourceediting by eclipse.

the class DataModelFacetCreationWizardPage method createPresetPanel.

protected void createPresetPanel(Composite top) {
    final IFacetedProjectWorkingCopy workingCopy = ((ModifyFacetedProjectWizard) getWizard()).getFacetedProjectWorkingCopy();
    final IFilter<IPreset> filter = new AbstractFilter<IPreset>() {

        {
            IFacetedProjectListener fpjwcListenerForPreset = new IFacetedProjectListener() {

                @Override
                public void handleEvent(final IFacetedProjectEvent event) {
                    handleProjectFacetsChangedEvent((IProjectFacetsChangedEvent) event);
                }
            };
            facetedProjectListeners.add(fpjwcListenerForPreset);
            workingCopy.addListener(fpjwcListenerForPreset, IFacetedProjectEvent.Type.PROJECT_FACETS_CHANGED);
        }

        @Override
        public boolean check(final IPreset preset) {
            final IProjectFacetVersion primaryFacetVersion = getPrimaryFacetVersion();
            return preset.getProjectFacets().contains(primaryFacetVersion);
        }

        private void handleProjectFacetsChangedEvent(final IProjectFacetsChangedEvent event) {
            for (IProjectFacetVersion fv : event.getFacetsWithChangedVersions()) {
                if (fv.getProjectFacet() == getPrimaryFacet()) {
                    final IFilterEvent<IPreset> filterEvent = new FilterEvent<IPreset>(this, IFilterEvent.Type.FILTER_CHANGED);
                    notifyListeners(filterEvent);
                }
            }
        }
    };
    final PresetSelectionPanel ppanel = new PresetSelectionPanel(top, workingCopy, filter);
    ppanel.setLayoutData(gdhfill());
}
Also used : IFacetedProjectListener(org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener) FilterEvent(org.eclipse.wst.common.project.facet.core.util.FilterEvent) AbstractFilter(org.eclipse.wst.common.project.facet.core.util.AbstractFilter) IFacetedProjectEvent(org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent) IProjectFacetVersion(org.eclipse.wst.common.project.facet.core.IProjectFacetVersion) ModifyFacetedProjectWizard(org.eclipse.wst.common.project.facet.ui.ModifyFacetedProjectWizard) IProjectFacetsChangedEvent(org.eclipse.wst.common.project.facet.core.events.IProjectFacetsChangedEvent) PresetSelectionPanel(org.eclipse.wst.common.project.facet.ui.PresetSelectionPanel) IPreset(org.eclipse.wst.common.project.facet.core.IPreset) IFacetedProjectWorkingCopy(org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy)

Aggregations

IFacetedProjectWorkingCopy (org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy)1 IPreset (org.eclipse.wst.common.project.facet.core.IPreset)1 IProjectFacetVersion (org.eclipse.wst.common.project.facet.core.IProjectFacetVersion)1 IFacetedProjectEvent (org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent)1 IFacetedProjectListener (org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener)1 IProjectFacetsChangedEvent (org.eclipse.wst.common.project.facet.core.events.IProjectFacetsChangedEvent)1 AbstractFilter (org.eclipse.wst.common.project.facet.core.util.AbstractFilter)1 FilterEvent (org.eclipse.wst.common.project.facet.core.util.FilterEvent)1 ModifyFacetedProjectWizard (org.eclipse.wst.common.project.facet.ui.ModifyFacetedProjectWizard)1 PresetSelectionPanel (org.eclipse.wst.common.project.facet.ui.PresetSelectionPanel)1