Providers can now specify fixed facets on per-runtime basis. Those facets will not be shown to users in the project creation wizard
--- a/plugins/org.symbian.tools.tmw.core/schema/runtimes.exsd Tue Aug 24 11:13:44 2010 -0700
+++ b/plugins/org.symbian.tools.tmw.core/schema/runtimes.exsd Tue Aug 24 15:17:50 2010 -0700
@@ -49,9 +49,10 @@
<element name="runtime">
<complexType>
- <sequence minOccurs="0" maxOccurs="unbounded">
- <element ref="runtime-component"/>
- </sequence>
+ <choice minOccurs="0" maxOccurs="unbounded">
+ <element ref="runtime-component" minOccurs="0" maxOccurs="unbounded"/>
+ <element ref="fixed-facet" minOccurs="0" maxOccurs="unbounded"/>
+ </choice>
<attribute name="component-id" type="string" use="required">
<annotation>
<documentation>
@@ -104,6 +105,28 @@
</complexType>
</element>
+ <element name="fixed-facet">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appinfo>
+ <meta.attribute kind="identifier" basedOn="org.eclipse.wst.common.project.facet.core.facets/project-facet/@id"/>
+ </appinfo>
+ </annotation>
+ </attribute>
+ <attribute name="version" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
<annotation>
<appinfo>
<meta.section type="since"/>
--- a/plugins/org.symbian.tools.tmw.core/src/org/symbian/tools/tmw/core/internal/facets/FProjSupportImpl.java Tue Aug 24 11:13:44 2010 -0700
+++ b/plugins/org.symbian.tools.tmw.core/src/org/symbian/tools/tmw/core/internal/facets/FProjSupportImpl.java Tue Aug 24 15:17:50 2010 -0700
@@ -19,6 +19,9 @@
package org.symbian.tools.tmw.core.internal.facets;
import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import org.eclipse.core.runtime.CoreException;
@@ -27,7 +30,10 @@
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
import org.eclipse.wst.common.project.facet.core.VersionFormatException;
import org.eclipse.wst.common.project.facet.core.runtime.IRuntime;
+import org.eclipse.wst.common.project.facet.core.runtime.IRuntimeComponent;
+import org.eclipse.wst.common.project.facet.core.runtime.IRuntimeComponentVersion;
import org.eclipse.wst.common.project.facet.core.runtime.RuntimeManager;
+import org.symbian.tools.tmw.core.TMWCore;
import org.symbian.tools.tmw.core.projects.IFProjSupport;
import org.symbian.tools.tmw.core.runtimes.IMobileWebRuntime;
@@ -46,6 +52,10 @@
private IProjectFacetVersion getFacet(String id, String version) {
final IProjectFacet projectFacet = ProjectFacetsManager.getProjectFacet(id);
+ if (projectFacet == null) {
+ TMWCore.log("Facet %s version %s was not found", id, version);
+ return null;
+ }
try {
return version != null ? projectFacet.getVersion(version) : projectFacet.getLatestVersion();
} catch (VersionFormatException e) {
@@ -63,11 +73,29 @@
final Set<IProjectFacetVersion> facets = new HashSet<IProjectFacetVersion>();
facets.add(getFacet("wst.jsdt.web", null));
facets.add(getFacet("tmw.core", null));
- // facets.add(getFacet("wst.jsdt.web", "1.0"));
+ final Map<String, String> fixedFacets = runtime.getFixedFacets();
+ for (Entry<String, String> entry : fixedFacets.entrySet()) {
+ final IProjectFacetVersion facet = getFacet(entry.getKey(), entry.getValue());
+ if (facet != null) {
+ facets.add(facet);
+ }
+ }
return facets;
}
public IProjectFacet getTMWFacet() {
return getFacet("tmw.core", null).getProjectFacet();
}
+
+ public IMobileWebRuntime getTMWRuntime(IRuntime runtime) {
+ if (runtime != null) {
+ final List<IRuntimeComponent> components = runtime.getRuntimeComponents();
+ if (!components.isEmpty()) {
+ final IRuntimeComponentVersion version = components.get(0).getRuntimeComponentVersion();
+ return TMWCore.getRuntimesManager().getRuntime(version.getRuntimeComponentType().getId(),
+ version.getVersionString());
+ }
+ }
+ return null;
+ }
}
--- a/plugins/org.symbian.tools.tmw.core/src/org/symbian/tools/tmw/core/internal/projects/TMWFacetedProject.java Tue Aug 24 11:13:44 2010 -0700
+++ b/plugins/org.symbian.tools.tmw.core/src/org/symbian/tools/tmw/core/internal/projects/TMWFacetedProject.java Tue Aug 24 15:17:50 2010 -0700
@@ -18,8 +18,6 @@
*/
package org.symbian.tools.tmw.core.internal.projects;
-import java.util.List;
-
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -28,9 +26,6 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.wst.common.project.facet.core.IFacetedProject;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
-import org.eclipse.wst.common.project.facet.core.runtime.IRuntime;
-import org.eclipse.wst.common.project.facet.core.runtime.IRuntimeComponent;
-import org.eclipse.wst.common.project.facet.core.runtime.IRuntimeComponentVersion;
import org.symbian.tools.tmw.core.TMWCore;
import org.symbian.tools.tmw.core.projects.ITMWProject;
import org.symbian.tools.tmw.core.runtimes.IMobileWebRuntime;
@@ -53,15 +48,7 @@
public IMobileWebRuntime getTargetRuntime() {
try {
final IFacetedProject fproj = ProjectFacetsManager.create(project);
- final IRuntime runtime = fproj.getPrimaryRuntime();
- if (runtime != null) {
- final List<IRuntimeComponent> components = runtime.getRuntimeComponents();
- if (!components.isEmpty()) {
- final IRuntimeComponentVersion version = components.get(0).getRuntimeComponentVersion();
- return TMWCore.getRuntimesManager()
- .getRuntime(version.getRuntimeComponentType().getId(), version.getVersionString());
- }
- }
+ return TMWCore.getFProjSupport().getTMWRuntime(fproj.getPrimaryRuntime());
} catch (CoreException e) {
TMWCore.log(null, e);
}
--- a/plugins/org.symbian.tools.tmw.core/src/org/symbian/tools/tmw/core/internal/runtimes/MobileWebRuntime.java Tue Aug 24 11:13:44 2010 -0700
+++ b/plugins/org.symbian.tools.tmw.core/src/org/symbian/tools/tmw/core/internal/runtimes/MobileWebRuntime.java Tue Aug 24 15:17:50 2010 -0700
@@ -18,8 +18,12 @@
*/
package org.symbian.tools.tmw.core.internal.runtimes;
+import java.util.Map;
+import java.util.TreeMap;
+
import org.eclipse.core.runtime.IConfigurationElement;
import org.symbian.tools.tmw.core.runtimes.IMobileWebRuntime;
+import org.symbian.tools.tmw.core.utilities.CoreUtil;
public final class MobileWebRuntime implements IMobileWebRuntime {
private final IConfigurationElement element;
@@ -49,4 +53,13 @@
return getId() + ":" + getVersion();
}
+ public Map<String, String> getFixedFacets() {
+ final Map<String, String> facets = new TreeMap<String, String>();
+ final IConfigurationElement[] children = element.getChildren("fixed-facet");
+ for (IConfigurationElement element : children) {
+ facets.put(CoreUtil.notNull(element.getAttribute("id")), element.getAttribute("version"));
+ }
+ return facets;
+ }
+
}
--- a/plugins/org.symbian.tools.tmw.core/src/org/symbian/tools/tmw/core/projects/IFProjSupport.java Tue Aug 24 11:13:44 2010 -0700
+++ b/plugins/org.symbian.tools.tmw.core/src/org/symbian/tools/tmw/core/projects/IFProjSupport.java Tue Aug 24 15:17:50 2010 -0700
@@ -57,4 +57,8 @@
*/
IProjectFacet getTMWFacet();
+ /**
+ * @return mobile web runtime that corresponds to FProj runtime
+ */
+ IMobileWebRuntime getTMWRuntime(IRuntime runtime);
}
--- a/plugins/org.symbian.tools.tmw.core/src/org/symbian/tools/tmw/core/runtimes/IMobileWebRuntime.java Tue Aug 24 11:13:44 2010 -0700
+++ b/plugins/org.symbian.tools.tmw.core/src/org/symbian/tools/tmw/core/runtimes/IMobileWebRuntime.java Tue Aug 24 15:17:50 2010 -0700
@@ -18,6 +18,8 @@
*/
package org.symbian.tools.tmw.core.runtimes;
+import java.util.Map;
+
/**
* Represents mobile web runtimes supported by the IDE
*
@@ -38,4 +40,9 @@
* @return user-readable runtime name
*/
String getName();
+
+ /**
+ * @return fixed facets (that are always enabled for the runtime) as id-version pairs
+ */
+ Map<String, String> getFixedFacets();
}
--- a/plugins/org.symbian.tools.tmw.core/src/org/symbian/tools/tmw/core/utilities/CoreUtil.java Tue Aug 24 11:13:44 2010 -0700
+++ b/plugins/org.symbian.tools.tmw.core/src/org/symbian/tools/tmw/core/utilities/CoreUtil.java Tue Aug 24 15:17:50 2010 -0700
@@ -39,4 +39,8 @@
public static boolean isLinux() {
return "linux".equals(Platform.getOS());
}
+
+ public static String notNull(final String string) {
+ return string == null ? "" : string.trim();
+ }
}
Binary file plugins/org.symbian.tools.tmw.ui/icons/full/obj16/earth.gif has changed
Binary file plugins/org.symbian.tools.tmw.ui/icons/full/obj16/javascript.gif has changed
Binary file plugins/org.symbian.tools.tmw.ui/icons/full/obj16/phone.gif has changed
--- a/plugins/org.symbian.tools.tmw.ui/plugin.xml Tue Aug 24 11:13:44 2010 -0700
+++ b/plugins/org.symbian.tools.tmw.ui/plugin.xml Tue Aug 24 15:17:50 2010 -0700
@@ -257,4 +257,22 @@
project="true">
</wizard>
</extension>
+ <extension
+ point="org.eclipse.wst.common.project.facet.ui.images">
+ <image
+ facet="tmw.core"
+ path="icons/full/obj16/phone.gif"
+ version="1.0">
+ </image>
+ <image
+ facet="wst.jsdt.web"
+ path="icons/full/obj16/javascript.gif"
+ version="1.0">
+ </image>
+ <image
+ facet="tmw.geolocation"
+ path="icons/full/obj16/earth.gif"
+ version="1.0">
+ </image>
+ </extension>
</plugin>
--- a/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/project/ProjectTemplateImpl.java Tue Aug 24 11:13:44 2010 -0700
+++ b/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/project/ProjectTemplateImpl.java Tue Aug 24 15:17:50 2010 -0700
@@ -164,4 +164,9 @@
public String getId() {
return element.getAttribute("id");
}
+
+ @Override
+ public String toString() {
+ return getName();
+ }
}
--- a/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/wizard/FacetsSelectionPanel.java Tue Aug 24 11:13:44 2010 -0700
+++ b/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/wizard/FacetsSelectionPanel.java Tue Aug 24 15:17:50 2010 -0700
@@ -40,6 +40,7 @@
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.jface.window.ToolTip;
import org.eclipse.swt.SWT;
@@ -138,7 +139,7 @@
this.fixedFacetToolTip = new FixedFacetToolTip(this.table);
this.tableViewer.setInput(new Object());
-
+ this.tableViewer.setFilters(new ViewerFilter[] { new RuntimeFacetsFilter(fpjwc) });
this.tableViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(final SelectionChangedEvent e) {
FacetsSelectionPanel.this.handleSelectionChangedEvent();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/internal/ui/wizard/RuntimeFacetsFilter.java Tue Aug 24 15:17:50 2010 -0700
@@ -0,0 +1,49 @@
+/**
+ * Copyright (c) 2010 Symbian Foundation and/or its subsidiary(-ies).
+ * All rights reserved.
+ * This component and the accompanying materials are made available
+ * under the terms of the License "Eclipse Public License v1.0"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Symbian Foundation - initial contribution.
+ * Contributors:
+ * Description:
+ * Overview:
+ * Details:
+ * Platforms/Drives/Compatibility:
+ * Assumptions/Requirement/Pre-requisites:
+ * Failures and causes:
+ */
+package org.symbian.tools.tmw.internal.ui.wizard;
+
+import java.util.Set;
+
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.symbian.tools.tmw.core.TMWCore;
+import org.symbian.tools.tmw.core.projects.IFProjSupport;
+import org.symbian.tools.tmw.core.runtimes.IMobileWebRuntime;
+
+public class RuntimeFacetsFilter extends ViewerFilter {
+ private final IFacetedProjectWorkingCopy fpjwc;
+
+ public RuntimeFacetsFilter(IFacetedProjectWorkingCopy fpjwc) {
+ this.fpjwc = fpjwc;
+ }
+
+ @Override
+ public boolean select(Viewer viewer, Object parentElement, Object element) {
+ final IFProjSupport support = TMWCore.getFProjSupport();
+ final IMobileWebRuntime webRuntime = support.getTMWRuntime(fpjwc.getPrimaryRuntime());
+ if (webRuntime != null) {
+ final Set<IProjectFacet> facets = support.getFixedFacets(webRuntime);
+ return !facets.contains(element);
+ }
+ return true;
+ }
+
+}
--- a/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/ui/project/NewApplicationWizard.java Tue Aug 24 11:13:44 2010 -0700
+++ b/plugins/org.symbian.tools.tmw.ui/src/org/symbian/tools/tmw/ui/project/NewApplicationWizard.java Tue Aug 24 15:17:50 2010 -0700
@@ -51,27 +51,27 @@
import org.symbian.tools.tmw.internal.ui.wizard.WizardContext;
/**
+ * This is the wizard that guides through new mobile application project creation.
+ *
* @author Eugene Ostroukhov (eugeneo@symbian.org)
*/
public final class NewApplicationWizard extends ModifyFacetedProjectWizard implements INewWizard {
public static final String ID = "org.symbian.tools.tmw.newproject";
+
private final PageContributions contributions = new PageContributions();
private final DataBindingContext databindingContext = new DataBindingContext();
- private NewApplicationFacetsWizardPage facetsPage;
+ private IWizardPage[] staticPages;
private NewApplicationDetailsWizardPage firstPage;
- private IStructuredSelection selection;
private IProjectTemplate template = null;
private INewApplicationWizardPage[] templatePages = new INewApplicationWizardPage[0];
- private NewApplicationTemplateWizardPage templatesPage;
private final WizardContext wizardContext = new WizardContext();
- private IWorkbench workbench;
public NewApplicationWizard() {
setShowFacetsSelectionPage(false);
}
public void addPages() {
- this.firstPage = createFirstPage();
+ firstPage = new NewApplicationDetailsWizardPage(wizardContext, databindingContext);
addPage(this.firstPage);
final IFacetedProject project = getFacetedProject();
final Set<IProjectFacetVersion> facets;
@@ -80,10 +80,14 @@
} else {
facets = project.getProjectFacets();
}
- facetsPage = new NewApplicationFacetsWizardPage(facets, getFacetedProjectWorkingCopy());
+ final IWizardPage facetsPage = new NewApplicationFacetsWizardPage(facets, getFacetedProjectWorkingCopy());
addPage(facetsPage);
- templatesPage = new NewApplicationTemplateWizardPage(wizardContext, databindingContext);
+ final IWizardPage templatesPage = new NewApplicationTemplateWizardPage(wizardContext, databindingContext);
addPage(templatesPage);
+ staticPages = new IWizardPage[3];
+ staticPages[0] = firstPage;
+ staticPages[1] = templatesPage;
+ staticPages[2] = facetsPage;
super.addPages();
}
@@ -92,11 +96,6 @@
&& super.canFinish();
}
- protected NewApplicationDetailsWizardPage createFirstPage() {
- firstPage = new NewApplicationDetailsWizardPage(wizardContext, databindingContext);
- return firstPage;
- }
-
@Override
public IWizardPage getNextPage(final IWizardPage page) {
final IFacetedProjectWorkingCopy fpjwc = getFacetedProjectWorkingCopy();
@@ -107,15 +106,6 @@
IRuntime runtime = fprojSupport.getRuntime(wizardContext.getRuntime());
fpjwc.setTargetedRuntimes(Collections.singleton(runtime));
fpjwc.setPrimaryRuntime(runtime);
- Set<IProjectFacetVersion> facets = getCurrentFixedFacetVersions();
- facets.addAll(fpjwc.getProjectFacets());
- fpjwc.setProjectFacets(facets);
- fpjwc.setFixedProjectFacets(getCurrentFixedFacets());
- } else if (page == this.templatesPage) {
- Set<IProjectFacetVersion> facets = getCurrentFixedFacetVersions();
- facets.addAll(fpjwc.getProjectFacets());
- fpjwc.setProjectFacets(facets);
- fpjwc.setFixedProjectFacets(getCurrentFixedFacets());
}
final Collection<Action> actions = fpjwc.getProjectFacetActions();
final Collection<Action> toReplace = new HashSet<IFacetedProject.Action>();
@@ -127,11 +117,35 @@
for (Action action : toReplace) {
fpjwc.setProjectFacetActionConfig(action.getProjectFacetVersion().getProjectFacet(), wizardContext);
}
-
- IWizardPage nextPage = super.getNextPage(page);
+ final IWizardPage nextPage = super.getNextPage(page);
+ synchronized (currentFacets) {
+ if (nextPage instanceof NewApplicationFacetsWizardPage && !reentry) {
+ try {
+ reentry = true;
+ final IFacetedProjectWorkingCopy projectWorkingCopy = getFacetedProjectWorkingCopy();
+ final Set<IProjectFacetVersion> facets = projectWorkingCopy.getProjectFacets();
+ final Set<IProjectFacet> fixed = projectWorkingCopy.getFixedProjectFacets();
+ currentFacets.retainAll(facets);
+ for (IProjectFacetVersion facetVersion : facets) {
+ if (!fixed.contains(facetVersion.getProjectFacet())) {
+ currentFacets.add(facetVersion);
+ }
+ }
+ final Set<IProjectFacetVersion> f = getCurrentFixedFacetVersions();
+ f.addAll(currentFacets);
+ fpjwc.setProjectFacets(f);
+ fpjwc.setFixedProjectFacets(getCurrentFixedFacets());
+ } finally {
+ reentry = false;
+ }
+ }
+ }
return nextPage;
}
+ private boolean reentry = false;
+ private final Collection<IProjectFacetVersion> currentFacets = new HashSet<IProjectFacetVersion>();
+
private Set<IProjectFacet> getCurrentFixedFacets() {
final Set<IProjectFacetVersion> fixedFacets = getCurrentFixedFacetVersions();
final Set<IProjectFacet> facets = new HashSet<IProjectFacet>();
@@ -171,11 +185,8 @@
}
}
final IWizardPage[] base = super.getPages();
- final IWizardPage[] pages = new IWizardPage[base.length + 3 + templatePages.length];
-
- pages[0] = this.firstPage;
- pages[1] = this.templatesPage;
- pages[2] = this.facetsPage;
+ final IWizardPage[] pages = new IWizardPage[staticPages.length + templatePages.length];
+ System.arraycopy(staticPages, 0, pages, 0, 3);
if (templatePages.length > 0) {
System.arraycopy(templatePages, 0, pages, 3, templatePages.length);
}
@@ -192,29 +203,8 @@
return wizardContext.getProjectName();
}
- /**
- * Returns the selection that this wizard was launched from.
- *
- * @return the selection that this wizard was launched from
- * @since 1.4
- */
- public IStructuredSelection getSelection() {
- return this.selection;
- }
-
- /**
- * Returns the workbench that this wizard belongs to.
- *
- * @return the workbench that this wizard belongs to
- * @since 1.4
- */
- public IWorkbench getWorkbench() {
- return this.workbench;
- }
-
public void init(final IWorkbench workbench, final IStructuredSelection selection) {
- this.workbench = workbench;
- this.selection = selection;
+ // Do nothing
}
@Override
--- a/plugins/org.symbian.tools.wrttools/plugin.xml Tue Aug 24 11:13:44 2010 -0700
+++ b/plugins/org.symbian.tools.wrttools/plugin.xml Tue Aug 24 15:17:50 2010 -0700
@@ -676,9 +676,14 @@
component-version="1.1"
name="Symbian WRT 1.1">
<runtime-component
+ alwayson="true"
id="tmw.geolocation"
version="1.0">
</runtime-component>
+ <fixed-facet
+ id="tmw.geolocation"
+ version="1.0">
+ </fixed-facet>
</runtime>
</extension>
<extension