use of org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy in project webtools.sourceediting by eclipse.
the class NewProjectDataModelFacetWizard method setRuntimeAndDefaultFacets.
protected void setRuntimeAndDefaultFacets(final IRuntime runtime) {
final IFacetedProjectWorkingCopy dm = getFacetedProjectWorkingCopy();
dm.setTargetedRuntimes(Collections.<IRuntime>emptySet());
if (runtime != null) {
final Set<IProjectFacetVersion> minFacets = new HashSet<IProjectFacetVersion>();
try {
for (IProjectFacet f : dm.getFixedProjectFacets()) {
minFacets.add(f.getLatestSupportedVersion(runtime));
}
} catch (CoreException e) {
throw new RuntimeException(e);
}
dm.setProjectFacets(minFacets);
dm.setTargetedRuntimes(Collections.singleton(runtime));
}
dm.setSelectedPreset(FacetedProjectFramework.DEFAULT_CONFIGURATION_PRESET_ID);
}
use of org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy 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.IFacetedProjectWorkingCopy in project mdw-designer by CenturyLinkCloud.
the class ServerSettingsPage method initValues.
public void initValues() {
configurator = ServerConfigurator.Factory.create(getServerSettings());
ContainerType type = ServerSettings.getContainerTypeFromClass(this.getClass().getSimpleName());
if (type != null) {
String prevServerHome = MdwPlugin.getStringPref(type + "-" + ProjectPersist.MDW_SERVER_HOME);
if (prevServerHome.length() > 0)
getServerSettings().setHome(prevServerHome);
if (getServerSettings().getHome() != null)
serverHomeTextField.setText(getServerSettings().getHome());
if (getServerSettings().isServiceMix())
getServerSettings().setContainerVersion("4.4.1");
if (getServerSettings().isFuse())
getServerSettings().setContainerVersion("6.1.0");
String prevJdkHome = MdwPlugin.getStringPref(type + "-" + ProjectPersist.MDW_SERVER_JDK_HOME);
if (prevJdkHome.length() > 0)
getServerSettings().setJdkHome(prevJdkHome);
if (getServerSettings().getJdkHome() != null)
jdkHomeTextField.setText(getServerSettings().getJdkHome());
String prevServerHost = MdwPlugin.getStringPref(type + "-" + ProjectPersist.MDW_SERVER_HOST);
if (prevServerHost.length() > 0 && getProject().isRemote())
getServerSettings().setHost(prevServerHost);
else
getServerSettings().setHost(ServerSettings.DEFAULT_HOST);
serverHostTextField.setText(getServerSettings().getHost());
String prevServerPort = MdwPlugin.getStringPref(type + "-" + ProjectPersist.MDW_SERVER_PORT);
if (prevServerPort.length() > 0 && getProject().isRemote()) {
try {
getServerSettings().setPort(Integer.parseInt(prevServerPort));
} catch (NumberFormatException ex) {
MdwPlugin.setStringPref(type + "-" + ProjectPersist.MDW_SERVER_PORT, String.valueOf(getDefaultServerPort()));
}
} else {
getServerSettings().setPort(getDefaultServerPort());
}
serverPortTextField.setText(String.valueOf(getServerSettings().getPort()));
String prevServerUser = MdwPlugin.getStringPref(type + "-" + ProjectPersist.MDW_SERVER_USER);
if (prevServerUser.length() > 0)
getServerSettings().setUser(prevServerUser);
else
getServerSettings().setUser(getDefaultServerUser());
serverUserTextField.setText(getServerSettings().getUser());
}
if (!getProject().checkRequiredVersion(5, 0)) {
IProjectFacetVersion pfv = ProjectFacetsManager.getProjectFacet("mdw.workflow").getVersion("1.1");
IFacetedProjectWorkingCopy wc = ((ModifyFacetedProjectWizard) getWizard()).getFacetedProjectWorkingCopy();
wc.changeProjectFacetVersion(pfv);
}
}
use of org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy in project webtools.sourceediting by eclipse.
the class ConvertJob method runInWorkspace.
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
try {
IProjectFacet projectFacet = ProjectFacetsManager.getProjectFacet(JSDT_FACET);
IFacetedProject facetedProject = ProjectFacetsManager.create(fProject);
if (facetedProject != null && fProject.isAccessible()) {
if (fInstall) {
IProjectFacetVersion latestVersion = projectFacet.getLatestVersion();
facetedProject.installProjectFacet(latestVersion, null, monitor);
}
if (fUseExplicitWorkingCopy) {
IFacetedProjectWorkingCopy copy = facetedProject.createWorkingCopy();
Set fixed = new HashSet(facetedProject.getFixedProjectFacets());
fixed.add(projectFacet);
copy.setFixedProjectFacets(fixed);
copy.commitChanges(new NullProgressMonitor());
copy.dispose();
} else {
Set fixed = new HashSet(facetedProject.getFixedProjectFacets());
if (!fixed.contains(projectFacet)) {
fixed.add(projectFacet);
facetedProject.setFixedProjectFacets(fixed);
}
}
}
} catch (IllegalArgumentException e) {
// unknown facet ID, bad installation configuration?
} catch (Exception e) {
Logger.logException(e);
}
return Status.OK_STATUS;
}
use of org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy in project liferay-ide by liferay.
the class LiferayProjectImportDataModelProvider method init.
@Override
public void init() {
super.init();
// set the project facets to get the runtime target dropdown to only show liferay runtimes
IFacetedProjectWorkingCopy facetedProject = getFacetedProjectWorkingCopy();
facetedProject.setSelectedPreset(IPluginFacetConstants.LIFERAY_PORTLET_PRESET);
Set<IProjectFacet> fixedFacets = new HashSet<>();
fixedFacets.add(ProjectFacetsManager.getProjectFacet(IPluginFacetConstants.LIFERAY_EXT_FACET_ID));
facetedProject.setFixedProjectFacets(Collections.unmodifiableSet(fixedFacets));
ProjectUtil.setDefaultRuntime(getDataModel());
}
Aggregations