use of org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener 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);
}
use of org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener 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);
}
use of org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener 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());
}
use of org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener in project webtools.sourceediting by eclipse.
the class DataModelFacetCreationWizardPage method dispose.
@Override
public void dispose() {
super.dispose();
if (projectNameGroup != null)
projectNameGroup.dispose();
this.fpjwc.removeListener(this.fpjwcListener);
for (IFacetedProjectListener listener : this.facetedProjectListeners) {
fpjwc.removeListener(listener);
}
model = null;
}
use of org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener 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);
}
Aggregations