Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 186139 Details for
Bug 333617
ModuleFactory extension point should contain enablement expression
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
v1.0
333617.patch (text/plain), 8.54 KB, created by
Angel Vera
on 2011-01-05 21:31:13 EST
(
hide
)
Description:
v1.0
Filename:
MIME Type:
Creator:
Angel Vera
Created:
2011-01-05 21:31:13 EST
Size:
8.54 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.wst.server.core >Index: schema/moduleFactories.exsd >=================================================================== >RCS file: /cvsroot/webtools/servertools/plugins/org.eclipse.wst.server.core/schema/moduleFactories.exsd,v >retrieving revision 1.13 >diff -u -r1.13 moduleFactories.exsd >--- schema/moduleFactories.exsd 17 Oct 2007 21:59:52 -0000 1.13 >+++ schema/moduleFactories.exsd 6 Jan 2011 02:29:51 -0000 >@@ -1,6 +1,6 @@ > <?xml version='1.0' encoding='UTF-8'?> > <!-- Schema file written by PDE --> >-<schema targetNamespace="org.eclipse.wst.server.core"> >+<schema targetNamespace="org.eclipse.wst.server.core" xmlns="http://www.w3.org/2001/XMLSchema"> > <annotation> > <appInfo> > <meta.schema plugin="org.eclipse.wst.server.core" id="moduleFactories" name="Module Factories"/> >@@ -10,7 +10,14 @@ > </documentation> > </annotation> > >+ <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/> >+ > <element name="extension"> >+ <annotation> >+ <appInfo> >+ <meta.element /> >+ </appInfo> >+ </annotation> > <complexType> > <sequence> > <element ref="moduleFactory" minOccurs="1" maxOccurs="unbounded"/> >@@ -105,6 +112,15 @@ > > <annotation> > <appInfo> >+ <meta.section type="apiInfo"/> >+ </appInfo> >+ <documentation> >+ Value of the attribute <b>class</b> must be a fully qualified name of a Java class that extends <code>org.eclipse.wst.server.core.model.ModuleFactoryDelegate</code> and contains a public 0-arg constructor. >+ </documentation> >+ </annotation> >+ >+ <annotation> >+ <appInfo> > <meta.section type="since"/> > </appInfo> > <documentation> >@@ -135,30 +151,13 @@ > </documentation> > </annotation> > >- <annotation> >- <appInfo> >- <meta.section type="apiInfo"/> >- </appInfo> >- <documentation> >- Value of the attribute <b>class</b> must be a fully qualified name of a Java class that extends <code>org.eclipse.wst.server.core.model.ModuleFactoryDelegate</code> and contains a public 0-arg constructor. >- </documentation> >- </annotation> >- >- <annotation> >- <appInfo> >- <meta.section type="implementation"/> >- </appInfo> >- <documentation> >- >- </documentation> >- </annotation> > > <annotation> > <appInfo> > <meta.section type="copyright"/> > </appInfo> > <documentation> >- Copyright (c) 2000, 2005 IBM Corporation and others.<br> >+ Copyright (c) 2000, 2011 IBM Corporation and others.<br> > All rights reserved. This program and the accompanying materials are made > available under the terms of the Eclipse Public License v1.0 which accompanies > this distribution, and is available at >Index: servercore/org/eclipse/wst/server/core/ServerUtil.java >=================================================================== >RCS file: /cvsroot/webtools/servertools/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/ServerUtil.java,v >retrieving revision 1.56 >diff -u -r1.56 ServerUtil.java >--- servercore/org/eclipse/wst/server/core/ServerUtil.java 10 Mar 2010 19:27:34 -0000 1.56 >+++ servercore/org/eclipse/wst/server/core/ServerUtil.java 6 Jan 2011 02:29:51 -0000 >@@ -1,5 +1,5 @@ > /********************************************************************** >- * Copyright (c) 2003, 2010 IBM Corporation and others. >+ * Copyright (c) 2003, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -91,13 +91,16 @@ > List<IModule> list = new ArrayList<IModule>(); > > ModuleFactory[] factories = ServerPlugin.getModuleFactories(); >+ > if (factories != null) { > for (ModuleFactory factory : factories) { >- IModule[] modules = factory.getModules(project, null); >- if (modules != null) { >- for (IModule module : modules) { >- if (!list.contains(module)) >- list.add(module); >+ if (factory.isEnabled(project, null)){ >+ IModule[] modules = factory.getModules(project, null); >+ if (modules != null) { >+ for (IModule module : modules) { >+ if (!list.contains(module)) >+ list.add(module); >+ } > } > } > } >Index: servercore/org/eclipse/wst/server/core/internal/ModuleFactory.java >=================================================================== >RCS file: /cvsroot/webtools/servertools/plugins/org.eclipse.wst.server.core/servercore/org/eclipse/wst/server/core/internal/ModuleFactory.java,v >retrieving revision 1.28.10.2 >diff -u -r1.28.10.2 ModuleFactory.java >--- servercore/org/eclipse/wst/server/core/internal/ModuleFactory.java 8 Dec 2010 20:28:42 -0000 1.28.10.2 >+++ servercore/org/eclipse/wst/server/core/internal/ModuleFactory.java 6 Jan 2011 02:29:51 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2003, 2007 IBM Corporation and others. >+ * Copyright (c) 2003, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -13,10 +13,11 @@ > import java.util.ArrayList; > import java.util.List; > >+import org.eclipse.core.expressions.*; > import org.eclipse.core.resources.IProject; >+import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IConfigurationElement; > import org.eclipse.core.runtime.IProgressMonitor; >- > import org.eclipse.wst.server.core.IModule; > import org.eclipse.wst.server.core.IModuleType; > import org.eclipse.wst.server.core.model.InternalInitializer; >@@ -28,6 +29,7 @@ > private IConfigurationElement element; > public ModuleFactoryDelegate delegate; > private List<IModuleType> moduleTypes; >+ private Expression fContextualLaunchExpr = null; > > /** > * ModuleFactory constructor comment. >@@ -137,6 +139,55 @@ > return new IModule[0]; > } > } >+ >+ /** >+ * Returns an expression that represents the enablement logic for the >+ * contextual project of this module factory <code>null</code> if none. >+ * @return an evaluatable expression or <code>null</code> >+ * @throws CoreException if the configuration element can't be >+ * converted. Reasons include: (a) no handler is available to >+ * cope with a certain configuration element or (b) the XML >+ * expression tree is malformed. >+ */ >+ protected Expression getContextualLaunchEnablementExpression() throws CoreException { >+ if (fContextualLaunchExpr == null) { >+ IConfigurationElement[] elements = element.getChildren(ExpressionTagNames.ENABLEMENT); >+ IConfigurationElement enablement = (elements != null && elements.length > 0) ? elements[0] : null; >+ >+ if (enablement != null) >+ fContextualLaunchExpr = ExpressionConverter.getDefault().perform(enablement); >+ } >+ return fContextualLaunchExpr; >+ } >+ >+ /** >+ * Evaluate the given expression within the given context and return >+ * the result. Returns <code>true</code> if result is either TRUE or NOT_LOADED. >+ * This allows optimistic inclusion before plugins are loaded. >+ * Returns <code>true</code> if exp is <code>null</code>. >+ * >+ * @param exp the enablement expression to evaluate or <code>null</code> >+ * @param context the context of the evaluation. >+ * @return the result of evaluating the expression >+ * @throws CoreException >+ */ >+ protected boolean evalEnablementExpression(IEvaluationContext context, Expression exp) throws CoreException { >+ // for compatibility with the current behaviour, if the exp == null we return true. Meaning that the factory doesn't >+ // implement an expression and should be enabled for all cases. >+ return (exp != null) ? ((exp.evaluate(context)) != EvaluationResult.FALSE) : true; >+ } >+ >+ public boolean isEnabled(IProject project, IProgressMonitor monitor) { >+ try { >+ IEvaluationContext context = new EvaluationContext(null, project); >+ context.addVariable("project", project); >+ >+ return evalEnablementExpression(context, getContextualLaunchEnablementExpression()); >+ } catch (Throwable t) { >+ Trace.trace(Trace.SEVERE, "Error calling delegate " + toString(), t); >+ return false; >+ } >+ } > > /* > * @see ModuleFactoryDelegate#findModule(String)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 333617
: 186139