Search in sources :

Example 1 with IFacetedProjectEvent

use of org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent in project webtools.sourceediting by eclipse.

the class NewProjectDataModelFacetWizard method addPages.

@Override
public void addPages() {
    beginingPages = createBeginingPages();
    for (int i = 0; i < beginingPages.length; i++) {
        addPage(beginingPages[i]);
    }
    super.addPages();
    getFacetedProjectWorkingCopy().addListener(new IFacetedProjectListener() {

        @Override
        public void handleEvent(final IFacetedProjectEvent event) {
            facetSelectionChangedEvent();
        }
    }, IFacetedProjectEvent.Type.PROJECT_FACETS_CHANGED);
}
Also used : IFacetedProjectListener(org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener) IFacetedProjectEvent(org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent)

Example 2 with IFacetedProjectEvent

use of org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent in project webtools.sourceediting by eclipse.

the class NewProjectDataModelFacetWizard method synchRuntimes.

protected void synchRuntimes() {
    final Boolean[] suppressBackEvents = { Boolean.FALSE };
    model.addListener(new IDataModelListener() {

        @Override
        public void propertyChanged(DataModelEvent event) {
            if (IDataModel.VALUE_CHG == event.getFlag() || IDataModel.DEFAULT_CHG == event.getFlag()) {
                if (FACET_RUNTIME.equals(event.getPropertyName())) {
                    if (!suppressBackEvents[0].booleanValue()) {
                        IRuntime runtime = (IRuntime) event.getProperty();
                        setRuntimeAndDefaultFacets(runtime);
                    }
                }
            }
        }
    });
    getFacetedProjectWorkingCopy().addListener(new IFacetedProjectListener() {

        @Override
        public void handleEvent(final IFacetedProjectEvent event) {
            suppressBackEvents[0] = Boolean.TRUE;
            model.setProperty(FACET_RUNTIME, getFacetedProjectWorkingCopy().getPrimaryRuntime());
            suppressBackEvents[0] = Boolean.FALSE;
        }
    }, IFacetedProjectEvent.Type.PRIMARY_RUNTIME_CHANGED);
}
Also used : IFacetedProjectListener(org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener) IDataModelListener(org.eclipse.wst.common.frameworks.datamodel.IDataModelListener) IFacetedProjectEvent(org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent) DataModelEvent(org.eclipse.wst.common.frameworks.datamodel.DataModelEvent) IRuntime(org.eclipse.wst.common.project.facet.core.runtime.IRuntime)

Example 3 with IFacetedProjectEvent

use of org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent 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)

Example 4 with IFacetedProjectEvent

use of org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent in project webtools.sourceediting by eclipse.

the class DataModelFacetCreationWizardPage method createPrimaryFacetComposite.

protected void createPrimaryFacetComposite(Composite top) {
    primaryProjectFacet = ProjectFacetsManager.getProjectFacet(getModuleTypeID());
    if (primaryProjectFacet.getVersions().size() <= 1) {
        // facet version to choose from (e.g. utility and static web)
        return;
    }
    final Group group = new Group(top, SWT.NONE);
    group.setLayoutData(gdhfill());
    group.setLayout(new GridLayout(1, false));
    group.setText(getPrimaryFacetCompositeLabel());
    primaryVersionCombo = new Combo(group, SWT.BORDER | SWT.READ_ONLY);
    primaryVersionCombo.setLayoutData(gdhfill());
    updatePrimaryVersions();
    primaryVersionCombo.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(final SelectionEvent e) {
            handlePrimaryFacetVersionSelectedEvent();
        }
    });
    IFacetedProjectListener fpjwcListenerForPrimaryFacetCombo = new IFacetedProjectListener() {

        @Override
        public void handleEvent(IFacetedProjectEvent event) {
            if (event.getType() == IFacetedProjectEvent.Type.PROJECT_FACETS_CHANGED) {
                // this block is to update the combo when the underlying facet version changes
                IProjectFacetsChangedEvent actionEvent = (IProjectFacetsChangedEvent) event;
                Set<IProjectFacetVersion> changedVersions = actionEvent.getFacetsWithChangedVersions();
                boolean foundComboVersion = false;
                for (Iterator<IProjectFacetVersion> iterator = changedVersions.iterator(); iterator.hasNext() && !foundComboVersion; ) {
                    IProjectFacetVersion next = iterator.next();
                    if (next.getProjectFacet().equals(primaryProjectFacet)) {
                        foundComboVersion = true;
                        final IProjectFacetVersion selectedVersion = next;
                        Display.getDefault().asyncExec(new Runnable() {

                            @Override
                            public void run() {
                                String selectedText = primaryVersionCombo.getItem(primaryVersionCombo.getSelectionIndex());
                                if (!selectedText.equals(selectedVersion.getVersionString())) {
                                    String[] items = primaryVersionCombo.getItems();
                                    int selectedVersionIndex = -1;
                                    for (int i = 0; i < items.length && selectedVersionIndex == -1; i++) {
                                        if (items[i].equals(selectedVersion.getVersionString())) {
                                            selectedVersionIndex = i;
                                            primaryVersionCombo.select(selectedVersionIndex);
                                        }
                                    }
                                }
                            }
                        });
                    }
                }
            } else if (event.getType() == IFacetedProjectEvent.Type.PRIMARY_RUNTIME_CHANGED) {
                // this block updates the items in the combo when the runtime changes
                Display.getDefault().asyncExec(new Runnable() {

                    @Override
                    public void run() {
                        updatePrimaryVersions();
                    }
                });
            }
        }
    };
    this.facetedProjectListeners.add(fpjwcListenerForPrimaryFacetCombo);
    fpjwc.addListener(fpjwcListenerForPrimaryFacetCombo, IFacetedProjectEvent.Type.PROJECT_FACETS_CHANGED, IFacetedProjectEvent.Type.PRIMARY_RUNTIME_CHANGED);
}
Also used : IFacetedProjectListener(org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener) NewProjectGroup(org.eclipse.wst.common.frameworks.internal.ui.NewProjectGroup) WorkingSetGroup(org.eclipse.ui.dialogs.WorkingSetGroup) Group(org.eclipse.swt.widgets.Group) IProjectFacetVersion(org.eclipse.wst.common.project.facet.core.IProjectFacetVersion) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) IProjectFacetsChangedEvent(org.eclipse.wst.common.project.facet.core.events.IProjectFacetsChangedEvent) Combo(org.eclipse.swt.widgets.Combo) GridLayout(org.eclipse.swt.layout.GridLayout) IFacetedProjectEvent(org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Aggregations

IFacetedProjectEvent (org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent)4 IFacetedProjectListener (org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener)4 IProjectFacetVersion (org.eclipse.wst.common.project.facet.core.IProjectFacetVersion)2 IProjectFacetsChangedEvent (org.eclipse.wst.common.project.facet.core.events.IProjectFacetsChangedEvent)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Combo (org.eclipse.swt.widgets.Combo)1 Group (org.eclipse.swt.widgets.Group)1 WorkingSetGroup (org.eclipse.ui.dialogs.WorkingSetGroup)1 DataModelEvent (org.eclipse.wst.common.frameworks.datamodel.DataModelEvent)1 IDataModelListener (org.eclipse.wst.common.frameworks.datamodel.IDataModelListener)1 NewProjectGroup (org.eclipse.wst.common.frameworks.internal.ui.NewProjectGroup)1 IFacetedProjectWorkingCopy (org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy)1 IPreset (org.eclipse.wst.common.project.facet.core.IPreset)1 IRuntime (org.eclipse.wst.common.project.facet.core.runtime.IRuntime)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