JBoss Tools SVN: r9024 - trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-06-30 12:07:30 -0400 (Mon, 30 Jun 2008)
New Revision: 9024
Modified:
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/AddExceptionHandler.java
trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/AddViewSupport.java
Log:
JBIDE-2307
Modified: trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/AddExceptionHandler.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/AddExceptionHandler.java 2008-06-30 15:16:08 UTC (rev 9023)
+++ trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/AddExceptionHandler.java 2008-06-30 16:07:30 UTC (rev 9024)
@@ -6,6 +6,7 @@
import org.jboss.tools.common.model.XModelException;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
+import org.jboss.tools.seam.pages.xml.model.SeamPagesConstants;
import org.jboss.tools.seam.pages.xml.model.helpers.SeamPagesDiagramStructureHelper;
public class AddExceptionHandler extends DefaultCreateHandler {
@@ -28,6 +29,9 @@
protected XModelObject modifyCreatedObject(XModelObject o) {
Properties p = extractProperties(data[0]);
+ String viewId = p.getProperty(SeamPagesConstants.ATTR_VIEW_ID);
+ viewId = AddViewSupport.revalidatePath(viewId);
+ p.setProperty(SeamPagesConstants.ATTR_VIEW_ID, viewId);
String childEntity = action.getProperty("childEntity");
XModelObject c = XModelObjectLoaderUtil.createValidObject(o.getModel(), childEntity, p);
o.addChild(c);
Modified: trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/AddViewSupport.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/AddViewSupport.java 2008-06-30 15:16:08 UTC (rev 9023)
+++ trunk/seam/plugins/org.jboss.tools.seam.pages.xml/src/org/jboss/tools/seam/pages/xml/model/handlers/AddViewSupport.java 2008-06-30 16:07:30 UTC (rev 9024)
@@ -211,7 +211,7 @@
if(!path.startsWith("/") && !path.startsWith("*")) path = "/" + path;
if(hasWildCard(path)) return path;
if(path.indexOf('.') < 0 && !path.endsWith("/")) {
- path += getExtension();
+// path += getExtension();
}
return path;
}
16 years, 6 months
JBoss Tools SVN: r9023 - trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/action.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-06-30 11:16:08 -0400 (Mon, 30 Jun 2008)
New Revision: 9023
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/action/RemoveJSFNatureActionDelegate.java
Log:
JBIDE-1970
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/action/RemoveJSFNatureActionDelegate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/action/RemoveJSFNatureActionDelegate.java 2008-06-30 15:15:38 UTC (rev 9022)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/action/RemoveJSFNatureActionDelegate.java 2008-06-30 15:16:08 UTC (rev 9023)
@@ -10,11 +10,22 @@
******************************************************************************/
package org.jboss.tools.jsf.ui.action;
+import java.util.Properties;
+
+import org.jboss.tools.jsf.model.handlers.RemoveJSFNatureContribution;
import org.jboss.tools.jsf.project.JSFNature;
+import org.jboss.tools.common.meta.action.SpecialWizard;
import org.jboss.tools.common.model.ui.action.file.RemoveModelNatureActionDelegate;
public class RemoveJSFNatureActionDelegate extends RemoveModelNatureActionDelegate {
protected String getModelNatureName() {
return JSFNature.NATURE_ID;
}
+
+ protected void initProperties(Properties p) {
+ super.initProperties(p);
+ SpecialWizard w = new RemoveJSFNatureContribution();
+ p.put("contribution", w);
+ }
+
}
16 years, 6 months
JBoss Tools SVN: r9022 - in trunk/jsf/plugins/org.jboss.tools.jsf: src/org/jboss/tools/jsf/model/handlers and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-06-30 11:15:38 -0400 (Mon, 30 Jun 2008)
New Revision: 9022
Added:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/RemoveJSFNatureContribution.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/plugin.xml
Log:
JBIDE-1970
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/plugin.xml
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/plugin.xml 2008-06-30 15:14:54 UTC (rev 9021)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/plugin.xml 2008-06-30 15:15:38 UTC (rev 9022)
@@ -1758,6 +1758,8 @@
class="org.jboss.tools.jsf.model.handlers.JSFProcessRegirectHandler"/>
<xclass id="org.jboss.tools.jsf.model.handlers.JSPAdopt"
class="org.jboss.tools.jsf.model.handlers.JSPAdopt"/>
+ <xclass id="org.jboss.tools.jsf.model.handlers.RemoveJSFNatureContribution"
+ class="org.jboss.tools.jsf.model.handlers.RemoveJSFNatureContribution"/>
<xclass id="org.jboss.tools.jsf.model.handlers.ModifyLinkHandler"
class="org.jboss.tools.jsf.model.handlers.ModifyLinkHandler"/>
<xclass id="org.jboss.tools.jsf.model.handlers.OpenPageHandler"
Added: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/RemoveJSFNatureContribution.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/RemoveJSFNatureContribution.java (rev 0)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/handlers/RemoveJSFNatureContribution.java 2008-06-30 15:15:38 UTC (rev 9022)
@@ -0,0 +1,45 @@
+package org.jboss.tools.jsf.model.handlers;
+
+import org.jboss.tools.common.meta.action.SpecialWizard;
+import org.jboss.tools.common.meta.action.impl.handlers.DefaultRemoveHandler;
+import org.jboss.tools.common.model.XModel;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.jsf.model.JSFConstants;
+import org.jboss.tools.jst.web.model.helpers.WebAppHelper;
+
+public class RemoveJSFNatureContribution implements SpecialWizard {
+ XModel model = null;
+
+ public void setObject(Object object) {
+ if(object instanceof XModel) {
+ model = (XModel)object;
+ }
+ }
+
+ public int execute() {
+ if(model == null) return 1;
+ XModelObject webxml = WebAppHelper.getWebApp(model);
+ XModelObject servlet = WebAppHelper.findServlet(webxml,
+ JSFConstants.FACES_SERVLET_CLASS, "Faces Config");
+ String servletName = servlet == null ? null : servlet.getAttributeValue("servlet-name");
+ XModelObject mapping = WebAppHelper.findServletMapping(webxml, servletName);
+
+ if(servlet != null) {
+ DefaultRemoveHandler.removeFromParent(servlet);
+ }
+ if(mapping != null) {
+ DefaultRemoveHandler.removeFromParent(mapping);
+ }
+ XModelObject folder = webxml.getChildByPath("Context Params");
+ XModelObject[] params = folder.getChildren();
+ for (int i = 0; i < params.length; i++) {
+ String name = params[i].getAttributeValue("param-name");
+ if(name != null && name.startsWith("javax.faces.")) {
+ DefaultRemoveHandler.removeFromParent(params[i]);
+ }
+ }
+
+ return 0;
+ }
+
+}
16 years, 6 months
JBoss Tools SVN: r9021 - trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/handlers.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-06-30 11:14:54 -0400 (Mon, 30 Jun 2008)
New Revision: 9021
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/handlers/RemoveModelNatureHandler.java
Log:
JBIDE-1970
Modified: trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/handlers/RemoveModelNatureHandler.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/handlers/RemoveModelNatureHandler.java 2008-06-30 15:08:09 UTC (rev 9020)
+++ trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/handlers/RemoveModelNatureHandler.java 2008-06-30 15:14:54 UTC (rev 9021)
@@ -18,6 +18,7 @@
import org.jboss.tools.common.model.markers.ResourceMarkers;
import org.eclipse.jdt.core.*;
import org.jboss.tools.common.meta.action.SignificanceMessageFactory;
+import org.jboss.tools.common.meta.action.SpecialWizard;
import org.jboss.tools.common.meta.action.XAction;
import org.jboss.tools.common.meta.action.XActionInvoker;
import org.jboss.tools.common.meta.action.impl.AbstractHandler;
@@ -53,7 +54,7 @@
public void executeHandler(XModelObject object, Properties p) throws XModelException {
IProject project = getProject(object);
- String nature = (p == null) ? null : p.getProperty("nature");
+ String nature = (p == null) ? null : p.getProperty("nature");
if(nature == null) nature = getNature(object);
if (project == null || nature == null) return;
@@ -67,6 +68,12 @@
pd.setProperty(ServiceDialog.CHECKBOX_MESSAGE, checkBoxMessage);
pd.put(ServiceDialog.CHECKED, Boolean.FALSE);
if(!dialog.openConfirm(pd)) return;
+
+ SpecialWizard contribution = p == null ? null : (SpecialWizard)p.get("contribution");
+ if(contribution != null) {
+ contribution.setObject(object.getModel());
+ contribution.execute();
+ }
Boolean b = (Boolean)pd.get(ServiceDialog.CHECKED);
unregisterWTP = b.booleanValue();
16 years, 6 months
JBoss Tools SVN: r9020 - trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2008-06-30 11:08:09 -0400 (Mon, 30 Jun 2008)
New Revision: 9020
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-2451 Fixed
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java 2008-06-30 14:58:58 UTC (rev 9019)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamCoreValidator.java 2008-06-30 15:08:09 UTC (rev 9020)
@@ -135,6 +135,7 @@
if(linkedResources!=null) {
resources.addAll(linkedResources);
}
+ resources.addAll(getAllResourceOfComponent(currentFile.getFullPath()));
}
}
resources.add(currentFile.getFullPath());
@@ -162,7 +163,7 @@
// Remove markers from collected source file
IFile sourceFile = root.getFile(linkedResource);
reporter.removeMessageSubset(validationManager, sourceFile, ISeamValidator.MARKED_SEAM_RESOURCE_MESSAGE_GROUP);
- validateComponent(linkedResource, checkedComponents);
+ validateComponent(linkedResource, checkedComponents, newResources);
validateFactory(linkedResource, markedDuplicateFactoryNames);
}
@@ -313,8 +314,12 @@
}
}
- private void validateComponent(IPath sourceFilePath, Set<ISeamComponent> checkedComponents) {
+ private void validateComponent(IPath sourceFilePath, Set<ISeamComponent> checkedComponents, Set<IPath> unnamedResources) {
Set<ISeamComponent> components = project.getComponentsByPath(sourceFilePath);
+ if(components.size()==0) {
+ unnamedResources.add(sourceFilePath);
+ return;
+ }
for (ISeamComponent component : components) {
// Don't validate one component twice.
if(!checkedComponents.contains(component)) {
@@ -340,6 +345,21 @@
}
/*
+ * Collect all resources of all declarations of all components which is declared in the source.
+ */
+ private Set<IPath> getAllResourceOfComponent(IPath sourceComponentFilePath) {
+ Set<IPath> result = new HashSet<IPath>();
+ Set<ISeamComponent> components = project.getComponentsByPath(sourceComponentFilePath);
+ for (ISeamComponent component : components) {
+ Set<ISeamComponentDeclaration> declarations = component.getAllDeclarations();
+ for (ISeamComponentDeclaration seamComponentDeclaration : declarations) {
+ result.add(seamComponentDeclaration.getResource().getFullPath());
+ }
+ }
+ return result;
+ }
+
+ /*
* Validates the component
*/
private void validateComponent(ISeamComponent component) {
16 years, 6 months
JBoss Tools SVN: r9019 - trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-06-30 10:58:58 -0400 (Mon, 30 Jun 2008)
New Revision: 9019
Added:
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/Parameter.java
Modified:
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/AbstractOdaFactory.java
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateOdaQuery.java
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateParameterMetaData.java
Log:
JBIDE-2220 JBoss BIRT Integration - Adding parameters to the BIRT Hibernate ODA data set
Modified: trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/AbstractOdaFactory.java
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/AbstractOdaFactory.java 2008-06-30 14:58:52 UTC (rev 9018)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/AbstractOdaFactory.java 2008-06-30 14:58:58 UTC (rev 9019)
@@ -1,10 +1,12 @@
package org.jboss.tools.birt.oda.impl;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.StringTokenizer;
+import org.eclipse.datatools.connectivity.oda.IParameterMetaData;
import org.eclipse.datatools.connectivity.oda.IResultSetMetaData;
import org.eclipse.datatools.connectivity.oda.OdaException;
import org.hibernate.EntityMode;
@@ -12,6 +14,8 @@
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
+import org.hibernate.engine.query.HQLQueryPlan;
+import org.hibernate.impl.SessionFactoryImpl;
import org.hibernate.metadata.ClassMetadata;
import org.hibernate.type.Type;
import org.jboss.tools.birt.oda.IOdaFactory;
@@ -42,6 +46,11 @@
public HibernateResultSetMetaData prepare(String queryText) throws OdaException {
this.queryText = queryText;
+ return parseQuery();
+ }
+
+ private HibernateResultSetMetaData parseQuery()
+ throws OdaException {
List arColsType = new ArrayList();
List arCols = new ArrayList();
List arColClass = new ArrayList();
@@ -152,6 +161,19 @@
try {
session = getSessionFactory().openSession();
Query q = session.createQuery(queryText);
+ HibernateParameterMetaData parameterMetaData = (HibernateParameterMetaData) query.getParameterMetaData();
+ List<Parameter> parameters = parameterMetaData.getParameters();
+ int position=0;
+ SessionFactoryImpl sfimpl = (SessionFactoryImpl) sessionFactory; // hack - to get to the actual queries..
+ HQLQueryPlan plan = new HQLQueryPlan(queryText, false, Collections.EMPTY_MAP, sfimpl);
+ int pCount = plan.getParameterMetadata().getOrdinalParameterCount();
+ if (pCount > 0) {
+ for(Parameter parameter:parameters) {
+ q.setParameter(position++, parameter.getValue(), parameter.getHibernateType());
+ if (position >= pCount)
+ break;
+ }
+ }
result = q.list();
iterator = result.iterator();
this.queryReturnTypes = q.getReturnTypes();
Modified: trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateOdaQuery.java
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateOdaQuery.java 2008-06-30 14:58:52 UTC (rev 9018)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateOdaQuery.java 2008-06-30 14:58:58 UTC (rev 9019)
@@ -12,6 +12,7 @@
import java.sql.Date;
import java.sql.Time;
import java.sql.Timestamp;
+import java.util.List;
import org.eclipse.datatools.connectivity.oda.IParameterMetaData;
import org.eclipse.datatools.connectivity.oda.IQuery;
@@ -23,295 +24,336 @@
/**
* Implementation class of IQuery for an ODA runtime driver.
*
- * @author snjeza
+ * @author snjeza
*/
-public class HibernateOdaQuery implements IQuery
-{
+public class HibernateOdaQuery implements IQuery {
private HibernateConnection connection;
private HibernateResultSetMetaData resultSetMetaData;
-
+ private HibernateParameterMetaData parameterMetaData = new HibernateParameterMetaData();
+
public HibernateOdaQuery(HibernateConnection connection) {
this.connection = connection;
}
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#prepare(java.lang.String)
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IQuery#prepare(java.lang.String)
*/
public void prepare(String queryText) throws OdaException {
- this.resultSetMetaData = getConnection().getOdaSessionFactory().prepare(queryText);
+ this.resultSetMetaData = getConnection().getOdaSessionFactory()
+ .prepare(queryText);
}
-
+
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setAppContext(java.lang.Object)
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IQuery#setAppContext(java.lang
+ * .Object)
*/
- public void setAppContext( Object context ) throws OdaException
- {
- // do nothing; assumes no support for pass-through context
+ public void setAppContext(Object context) throws OdaException {
+ // do nothing; assumes no support for pass-through context
}
/*
* @see org.eclipse.datatools.connectivity.oda.IQuery#close()
*/
- public void close() throws OdaException
- {
- // TODO Auto-generated method stub
+ public void close() throws OdaException {
+ // TODO Auto-generated method stub
}
/*
* @see org.eclipse.datatools.connectivity.oda.IQuery#getMetaData()
*/
- public IResultSetMetaData getMetaData() throws OdaException
- {
+ public IResultSetMetaData getMetaData() throws OdaException {
return this.resultSetMetaData;
}
/*
* @see org.eclipse.datatools.connectivity.oda.IQuery#executeQuery()
*/
- public IResultSet executeQuery() throws OdaException
- {
- try {
- return new HibernateResultSet(this);
- } catch (Exception e) {
- throw new OdaException(e.getLocalizedMessage());
- }
+ public IResultSet executeQuery() throws OdaException {
+ try {
+ return new HibernateResultSet(this);
+ } catch (Exception e) {
+ throw new OdaException(e.getLocalizedMessage());
+ }
}
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setProperty(java.lang.String, java.lang.String)
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IQuery#setProperty(java.lang.String
+ * , java.lang.String)
*/
- public void setProperty( String name, String value ) throws OdaException
- {
+ public void setProperty(String name, String value) throws OdaException {
// do nothing; assumes no data set query property
}
/*
* @see org.eclipse.datatools.connectivity.oda.IQuery#setMaxRows(int)
*/
- public void setMaxRows( int max ) throws OdaException
- {
- getConnection().getOdaSessionFactory().setMaxRows(max);
+ public void setMaxRows(int max) throws OdaException {
+ getConnection().getOdaSessionFactory().setMaxRows(max);
}
/*
* @see org.eclipse.datatools.connectivity.oda.IQuery#getMaxRows()
*/
- public int getMaxRows() throws OdaException
- {
+ public int getMaxRows() throws OdaException {
return getConnection().getOdaSessionFactory().getMaxRows();
}
/*
* @see org.eclipse.datatools.connectivity.oda.IQuery#clearInParameters()
*/
- public void clearInParameters() throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to input parameter
+ public void clearInParameters() throws OdaException {
+ parameterMetaData.getParameters().clear();
}
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setInt(java.lang.String, int)
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IQuery#setInt(java.lang.String,
+ * int)
*/
- public void setInt( String parameterName, int value ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to named input parameter
+ public void setInt(String parameterName, int value) throws OdaException {
+ setParameter(parameterName, Parameter.IntegerType, value);
}
+
+ private void setParameter(String parameterName,int type,Object value) {
+ Parameter parameter = getParameter(parameterName);
+ if (parameter == null) {
+ parameter = new Parameter(type, parameterName,
+ value);
+ parameterMetaData.getParameters().add(parameter);
+ } else {
+ parameter.setValue(value);
+ parameter.setType(type);
+ }
+ }
+ private Parameter getParameter(String parameterName) {
+ if (parameterName == null)
+ return null;
+ List<Parameter> parameters = parameterMetaData.getParameters();
+ for (Parameter parameter : parameters) {
+ if (parameterName.equals(parameter.getName())) {
+ return parameter;
+ }
+ }
+ return null;
+ }
+
/*
* @see org.eclipse.datatools.connectivity.oda.IQuery#setInt(int, int)
*/
- public void setInt( int parameterId, int value ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to input parameter
+ public void setInt(int parameterId, int value) throws OdaException {
+ setParameter(parameterId, Parameter.IntegerType, value);
}
+
+ private void setParameter(int parameterId,int type,Object value) {
+ List<Parameter> parameters = parameterMetaData.getParameters();
+ String parameterName = "parameter" + parameterId;
+ if (parameters.size() < parameterId) {
+ Parameter parameter = new Parameter(type, parameterName,
+ value);
+ parameterMetaData.getParameters().add(parameter);
+ } else {
+ Parameter parameter = parameterMetaData.getParameters().get(parameterId-1);
+ parameter.setValue(value);
+ parameter.setType(type);
+ }
+ }
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setDouble(java.lang.String, double)
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IQuery#setDouble(java.lang.String,
+ * double)
*/
- public void setDouble( String parameterName, double value ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to named input parameter
+ public void setDouble(String parameterName, double value)
+ throws OdaException {
+ setParameter(parameterName, Parameter.DoubleType, new Double(value));
}
/*
* @see org.eclipse.datatools.connectivity.oda.IQuery#setDouble(int, double)
*/
- public void setDouble( int parameterId, double value ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to input parameter
+ public void setDouble(int parameterId, double value) throws OdaException {
+ setParameter(parameterId, Parameter.DoubleType, new Double(value));
}
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setBigDecimal(java.lang.String, java.math.BigDecimal)
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IQuery#setBigDecimal(java.lang
+ * .String, java.math.BigDecimal)
*/
- public void setBigDecimal( String parameterName, BigDecimal value ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to named input parameter
+ public void setBigDecimal(String parameterName, BigDecimal value)
+ throws OdaException {
+ setParameter(parameterName, Parameter.BigDecimalType, value);
}
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setBigDecimal(int, java.math.BigDecimal)
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setBigDecimal(int,
+ * java.math.BigDecimal)
*/
- public void setBigDecimal( int parameterId, BigDecimal value ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to input parameter
+ public void setBigDecimal(int parameterId, BigDecimal value)
+ throws OdaException {
+ setParameter(parameterId, Parameter.BigDecimalType, value);
}
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setString(java.lang.String, java.lang.String)
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IQuery#setString(java.lang.String,
+ * java.lang.String)
*/
- public void setString( String parameterName, String value ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to named input parameter
+ public void setString(String parameterName, String value)
+ throws OdaException {
+ setParameter(parameterName, Parameter.StringType, value);
}
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setString(int, java.lang.String)
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setString(int,
+ * java.lang.String)
*/
- public void setString( int parameterId, String value ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to input parameter
+ public void setString(int parameterId, String value) throws OdaException {
+ setParameter(parameterId, Parameter.StringType, value);
}
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setDate(java.lang.String, java.sql.Date)
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IQuery#setDate(java.lang.String,
+ * java.sql.Date)
*/
- public void setDate( String parameterName, Date value ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to named input parameter
+ public void setDate(String parameterName, Date value) throws OdaException {
+ setParameter(parameterName, Parameter.DateType, value);
}
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setDate(int, java.sql.Date)
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setDate(int,
+ * java.sql.Date)
*/
- public void setDate( int parameterId, Date value ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to input parameter
+ public void setDate(int parameterId, Date value) throws OdaException {
+ setParameter(parameterId, Parameter.DateType, value);
}
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setTime(java.lang.String, java.sql.Time)
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IQuery#setTime(java.lang.String,
+ * java.sql.Time)
*/
- public void setTime( String parameterName, Time value ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to named input parameter
+ public void setTime(String parameterName, Time value) throws OdaException {
+ setParameter(parameterName, Parameter.TimeType, value);
}
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setTime(int, java.sql.Time)
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setTime(int,
+ * java.sql.Time)
*/
- public void setTime( int parameterId, Time value ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to input parameter
+ public void setTime(int parameterId, Time value) throws OdaException {
+ setParameter(parameterId, Parameter.TimeType, value);
}
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setTimestamp(java.lang.String, java.sql.Timestamp)
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IQuery#setTimestamp(java.lang.
+ * String, java.sql.Timestamp)
*/
- public void setTimestamp( String parameterName, Timestamp value ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to named input parameter
+ public void setTimestamp(String parameterName, Timestamp value)
+ throws OdaException {
+ setParameter(parameterName, Parameter.TimestampType, value);
}
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setTimestamp(int, java.sql.Timestamp)
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setTimestamp(int,
+ * java.sql.Timestamp)
*/
- public void setTimestamp( int parameterId, Timestamp value ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to input parameter
+ public void setTimestamp(int parameterId, Timestamp value)
+ throws OdaException {
+ setParameter(parameterId, Parameter.TimestampType, value);
}
- /* (non-Javadoc)
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setBoolean(java.lang.String, boolean)
- */
- public void setBoolean( String parameterName, boolean value )
- throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to named input parameter
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IQuery#setBoolean(java.lang.String
+ * , boolean)
+ */
+ public void setBoolean(String parameterName, boolean value)
+ throws OdaException {
+ setParameter(parameterName, Parameter.BooleanType, new Boolean(value));
+ }
- /* (non-Javadoc)
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setBoolean(int, boolean)
- */
- public void setBoolean( int parameterId, boolean value )
- throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to input parameter
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setNull(java.lang.String)
- */
- public void setNull( String parameterName ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to named input parameter
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setBoolean(int,
+ * boolean)
+ */
+ public void setBoolean(int parameterId, boolean value) throws OdaException {
+ setParameter(parameterId, Parameter.BooleanType, new Boolean(value));
+ }
- /* (non-Javadoc)
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setNull(int)
- */
- public void setNull( int parameterId ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to input parameter
- }
+ /*
+ * (non-Javadoc)
+ *
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IQuery#setNull(java.lang.String)
+ */
+ public void setNull(String parameterName) throws OdaException {
+ Parameter parameter = getParameter(parameterName);
+ if (parameter != null) {
+ parameter.setValue(null);
+ }
+ }
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#findInParameter(java.lang.String)
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setNull(int)
*/
- public int findInParameter( String parameterName ) throws OdaException
- {
- // TODO Auto-generated method stub
- // only applies to named input parameter
+ public void setNull(int parameterId) throws OdaException {
+ Parameter parameter = parameterMetaData.getParameters().get(parameterId);
+ if (parameter != null) {
+ parameter.setValue(null);
+ }
+ }
+
+ /*
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IQuery#findInParameter(java.lang
+ * .String)
+ */
+ public int findInParameter(String parameterName) throws OdaException {
+ if (parameterName == null)
+ return 0;
+ for(Parameter parameter:parameterMetaData.getParameters()) {
+ if (parameterName.equals(parameter.getName()))
+ return parameterMetaData.getParameters().indexOf(parameter);
+ }
return 0;
}
/*
* @see org.eclipse.datatools.connectivity.oda.IQuery#getParameterMetaData()
*/
- public IParameterMetaData getParameterMetaData() throws OdaException
- {
- /* TODO Auto-generated method stub
- * Replace with implementation to return an instance
- * based on this prepared query.
- */
- return new HibernateParameterMetaData();
+ public IParameterMetaData getParameterMetaData() throws OdaException {
+ return parameterMetaData;
}
/*
- * @see org.eclipse.datatools.connectivity.oda.IQuery#setSortSpec(org.eclipse.datatools.connectivity.oda.SortSpec)
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IQuery#setSortSpec(org.eclipse
+ * .datatools.connectivity.oda.SortSpec)
*/
- public void setSortSpec( SortSpec sortBy ) throws OdaException
- {
- // TODO Auto-generated method stub
+ public void setSortSpec(SortSpec sortBy) throws OdaException {
+ // TODO Auto-generated method stub
// only applies to sorting, assumes not supported
- throw new UnsupportedOperationException();
+ throw new UnsupportedOperationException();
}
/*
* @see org.eclipse.datatools.connectivity.oda.IQuery#getSortSpec()
*/
- public SortSpec getSortSpec() throws OdaException
- {
- // TODO Auto-generated method stub
+ public SortSpec getSortSpec() throws OdaException {
+ // TODO Auto-generated method stub
// only applies to sorting
return null;
}
@@ -319,5 +361,5 @@
public HibernateConnection getConnection() {
return connection;
}
-
+
}
Modified: trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateParameterMetaData.java
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateParameterMetaData.java 2008-06-30 14:58:52 UTC (rev 9018)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateParameterMetaData.java 2008-06-30 14:58:58 UTC (rev 9019)
@@ -9,6 +9,9 @@
package org.jboss.tools.birt.oda.impl;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.datatools.connectivity.oda.IParameterMetaData;
import org.eclipse.datatools.connectivity.oda.OdaException;
@@ -20,12 +23,14 @@
public class HibernateParameterMetaData implements IParameterMetaData
{
+ private List<Parameter> parameters = new ArrayList<Parameter>();
+
/*
* @see org.eclipse.datatools.connectivity.oda.IParameterMetaData#getParameterCount()
*/
public int getParameterCount() throws OdaException
{
- return 0;
+ return parameters.size();
}
/*
@@ -41,7 +46,11 @@
*/
public String getParameterName( int param ) throws OdaException
{
- return null; // name is not available
+ if (getParameterCount() > param) {
+ return null;
+ }
+ Parameter parameter = parameters.get(param);
+ return parameter.getName();
}
/*
@@ -49,7 +58,11 @@
*/
public int getParameterType( int param ) throws OdaException
{
- return java.sql.Types.CHAR; // as defined in data set extension manifest
+ if (getParameterCount() > param) {
+ return -1;
+ }
+ Parameter parameter = parameters.get(param);
+ return parameter.getType();
}
/*
@@ -85,4 +98,8 @@
return IParameterMetaData.parameterNullableUnknown;
}
+ public List<Parameter> getParameters() {
+ return parameters;
+ }
+
}
Added: trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/Parameter.java
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/Parameter.java (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/Parameter.java 2008-06-30 14:58:58 UTC (rev 9019)
@@ -0,0 +1,93 @@
+package org.jboss.tools.birt.oda.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.hibernate.Hibernate;
+import org.hibernate.type.Type;
+
+public class Parameter {
+ public static int StringType = 1;
+ public static int IntegerType = 4;
+ public static int DoubleType = 8;
+ public static int BigDecimalType = 3;
+ public static int DateType = 91;
+ public static int TimeType = 92;
+ public static int TimestampType = 93;
+ public static int BooleanType = 16;
+
+ private String name;
+ private int type;
+ private String typeName;
+ private Object value;
+ private static Map<Integer,Type>hibernateTypes = new HashMap<Integer,Type>();
+
+ static {
+ hibernateTypes.put(StringType, Hibernate.STRING);
+ hibernateTypes.put(IntegerType, Hibernate.INTEGER);
+ hibernateTypes.put(DoubleType, Hibernate.DOUBLE);
+ hibernateTypes.put(BigDecimalType, Hibernate.BIG_DECIMAL);
+ hibernateTypes.put(DateType, Hibernate.DATE);
+ hibernateTypes.put(TimeType, Hibernate.TIME);
+ hibernateTypes.put(TimestampType, Hibernate.TIMESTAMP);
+ hibernateTypes.put(BooleanType, Hibernate.BOOLEAN);
+ }
+
+ public Parameter(int type, String name, Object value) {
+ this.type = type;
+ this.name = name;
+ this.value = value;
+ }
+
+ public String getName() {
+ return name;
+ }
+ public void setName(String name) {
+ this.name = name;
+ }
+ public int getType() {
+ return type;
+ }
+ public void setType(int type) {
+ this.type = type;
+ }
+ public String getTypeName() {
+ return typeName;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+ public void setValue(Object value) {
+ this.value = value;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((name == null) ? 0 : name.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ Parameter other = (Parameter) obj;
+ if (name == null) {
+ if (other.name != null)
+ return false;
+ } else if (!name.equals(other.name))
+ return false;
+ return true;
+ }
+
+ public Type getHibernateType() {
+ return hibernateTypes.get(type);
+ }
+}
16 years, 6 months
JBoss Tools SVN: r9018 - trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/impl.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-06-30 10:58:52 -0400 (Mon, 30 Jun 2008)
New Revision: 9018
Modified:
trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/impl/CustomDataSetWizardPage.java
Log:
JBIDE-2220 JBoss BIRT Integration - Adding parameters to the BIRT Hibernate ODA data set
Modified: trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/impl/CustomDataSetWizardPage.java
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/impl/CustomDataSetWizardPage.java 2008-06-30 14:57:37 UTC (rev 9017)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/impl/CustomDataSetWizardPage.java 2008-06-30 14:58:52 UTC (rev 9018)
@@ -9,6 +9,9 @@
package org.jboss.tools.birt.oda.ui.impl;
+import java.util.Collections;
+import java.util.Iterator;
+
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.IHandler;
@@ -75,13 +78,19 @@
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.console.KnownConfigurations;
import org.hibernate.console.QueryInputModel;
+import org.hibernate.eclipse.console.HibernateConsoleMessages;
import org.hibernate.eclipse.console.QueryEditor;
+import org.hibernate.eclipse.console.utils.QLFormatHelper;
import org.hibernate.eclipse.console.viewers.xpl.MTreeViewer;
import org.hibernate.eclipse.console.views.KnownConfigurationsProvider;
import org.hibernate.eclipse.console.workbench.LazySessionFactory;
import org.hibernate.eclipse.console.workbench.xpl.AnyAdaptableLabelProvider;
import org.hibernate.eclipse.hqleditor.HQLEditorDocumentSetupParticipant;
import org.hibernate.eclipse.hqleditor.HQLSourceViewerConfiguration;
+import org.hibernate.engine.query.HQLQueryPlan;
+import org.hibernate.hql.QueryTranslator;
+import org.hibernate.impl.SessionFactoryImpl;
+import org.hibernate.type.Type;
import org.jboss.tools.birt.oda.IOdaFactory;
import org.jboss.tools.birt.oda.impl.HibernateDriver;
import org.jboss.tools.birt.oda.ui.Activator;
@@ -332,13 +341,14 @@
MessageDialog.openConfirm(getShell(), title,
"Invalid configuration '" + getConfigurationName() + "'.");
}
- Session session = null;
try {
- session = configuration.getSessionFactory().openSession();
- Query q = session.createQuery(getQueryText());
- q.setFirstResult(0);
- q.setMaxResults(1);
- q.list();
+ //session = configuration.getSessionFactory().openSession();
+ //Query q = session.createQuery(getQueryText());
+ String sql = generateSQL(configuration.getSessionFactory(),getQueryText());
+ //System.out.println(sql);
+ //q.setFirstResult(0);
+ //q.setMaxResults(1);
+ //q.list();
MessageDialog.openInformation(getShell(), title,
"The query is valid.");
} catch (Exception e) {
@@ -347,11 +357,47 @@
.getLocalizedMessage(), e);
Activator.getDefault().getLog().log(status);
ErrorDialog.openError(getShell(), title, message, status);
- } finally {
- if (session != null) {
- session.close();
+ }
+ }
+
+ /*
+ * copied from the DynamicSQLPreviewView.generateSQL method
+ */
+ private String generateSQL(SessionFactory sessionFactory, String queryText) {
+ SessionFactoryImpl sfimpl = (SessionFactoryImpl) sessionFactory; // hack - to get to the actual queries..
+ StringBuffer str = new StringBuffer(256);
+ HQLQueryPlan plan = new HQLQueryPlan(queryText, false, Collections.EMPTY_MAP, sfimpl);
+
+ QueryTranslator[] translators = plan.getTranslators();
+ for (int i = 0; i < translators.length; i++) {
+ QueryTranslator translator = translators[i];
+ if(translator.isManipulationStatement()) {
+ str.append(HibernateConsoleMessages.DynamicSQLPreviewView_manipulation_of + i + ":"); //$NON-NLS-1$
+ Iterator iterator = translator.getQuerySpaces().iterator();
+ while ( iterator.hasNext() ) {
+ Object qspace = iterator.next();
+ str.append(qspace);
+ if(iterator.hasNext()) { str.append(", "); } //$NON-NLS-1$
+ }
+
+ } else {
+ Type[] returnTypes = translator.getReturnTypes();
+ str.append(i +": "); //$NON-NLS-1$
+ for (int j = 0; j < returnTypes.length; j++) {
+ Type returnType = returnTypes[j];
+ str.append(returnType.getName());
+ if(j<returnTypes.length-1) { str.append(", "); } //$NON-NLS-1$
+ }
}
- }
+ str.append("\n-----------------\n"); //$NON-NLS-1$
+ Iterator sqls = translator.collectSqlStrings().iterator();
+ while ( sqls.hasNext() ) {
+ String sql = (String) sqls.next();
+ str.append(QLFormatHelper.formatForScreen(sql));
+ str.append("\n\n"); //$NON-NLS-1$
+ }
+ };
+ return str.toString();
}
private final void attachMenus(SourceViewer viewer) {
16 years, 6 months
JBoss Tools SVN: r9017 - trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit.
by jbosstools-commits@lists.jboss.org
Author: dazarov
Date: 2008-06-30 10:57:37 -0400 (Mon, 30 Jun 2008)
New Revision: 9017
Modified:
trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ParamListEditPart.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1189
Modified: trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ParamListEditPart.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ParamListEditPart.java 2008-06-30 14:07:18 UTC (rev 9016)
+++ trunk/seam/plugins/org.jboss.tools.seam.ui.pages/src/org/jboss/tools/seam/ui/pages/editor/edit/ParamListEditPart.java 2008-06-30 14:57:37 UTC (rev 9017)
@@ -98,11 +98,13 @@
Rectangle r = new Rectangle(loc, size);
- ((GraphicalEditPart) getParent()).setLayoutConstraint(this,
+ if(getParent() != null){
+ ((GraphicalEditPart) getParent()).setLayoutConstraint(this,
getFigure(), r);
- ((PagesDiagramEditPart) ParamListEditPart.this.getParent())
- .setToFront(this);
+ ((PagesDiagramEditPart) ParamListEditPart.this.getParent())
+ .setToFront(this);
+ }
}
16 years, 6 months
JBoss Tools SVN: r9016 - in trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf: web/helpers/context and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-06-30 10:07:18 -0400 (Mon, 30 Jun 2008)
New Revision: 9016
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFConstants.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/helpers/context/AdoptJSFProjectFinisher.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/helpers/context/ImportJSFWarContext.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/pattern/PatternLoader.java
Log:
JBIDE-1970
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFConstants.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFConstants.java 2008-06-30 14:00:15 UTC (rev 9015)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFConstants.java 2008-06-30 14:07:18 UTC (rev 9016)
@@ -56,5 +56,6 @@
public static final String ENT_FILEXHTML = "FileXHTML";
public static final String EMPTY_NAVIGATION_RULE_NAME = "[any]";
-
+
+ public static final String FACES_SERVLET_CLASS = "javax.faces.webapp.FacesServlet";
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/helpers/context/AdoptJSFProjectFinisher.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/helpers/context/AdoptJSFProjectFinisher.java 2008-06-30 14:00:15 UTC (rev 9015)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/helpers/context/AdoptJSFProjectFinisher.java 2008-06-30 14:07:18 UTC (rev 9016)
@@ -17,22 +17,27 @@
import java.util.List;
import java.util.Map;
+import org.jboss.tools.common.meta.action.impl.handlers.DefaultCreateHandler;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.model.XModelConstants;
import org.jboss.tools.common.model.XModelException;
import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
+import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
import org.jboss.tools.common.util.FileUtil;
+import org.jboss.tools.jsf.model.JSFConstants;
import org.jboss.tools.jst.web.context.IImportWebProjectContext;
+import org.jboss.tools.jst.web.model.helpers.WebAppHelper;
import org.jboss.tools.jst.web.project.WebModuleConstants;
public class AdoptJSFProjectFinisher {
protected IImportWebProjectContext context = null;
- protected XModel model = null;
- protected XModelObject web;
- protected XModelObject fss;
- protected String workspace = null;
- protected String srclocation = "";
- protected Map<String,XModelObject> filesystems = new HashMap<String,XModelObject>();
+ protected XModel model = null;
+ protected XModelObject web;
+ protected XModelObject fss;
+ protected String workspace = null;
+ protected String srclocation = "";
+ protected Map<String,XModelObject> filesystems = new HashMap<String,XModelObject>();
public void setContext(XModel model, IImportWebProjectContext context) {
this.context = context;
@@ -40,137 +45,160 @@
}
public void execute() throws XModelException {
- filesystems.clear();
- workspace = context.getWebInfLocation();
- fss = model.getByPath("FileSystems");
- web = model.getByPath("Web");
+ filesystems.clear();
+ workspace = context.getWebInfLocation();
+ fss = model.getByPath("FileSystems");
+ web = model.getByPath("Web");
- createBuildFileSystem();
- createWebInfFileSystem();
- createWebXMLFileSystem();
- createWebRootFileSystem();
- createSrcFileSystems();
- createClassesFileSystem();
- createLibFileSystems();
-
- String an = context.getApplicationName();
- if(an == null) an = context.getProjectName();
- fss.setAttributeValue("application name", an);
-
- fss.setModified(true);
- appendModules();
- model.save();
- }
+ createBuildFileSystem();
+ createWebInfFileSystem();
+ createWebXMLFileSystem();
+ createWebRootFileSystem();
+ createSrcFileSystems();
+ createClassesFileSystem();
+ createLibFileSystems();
+ String an = context.getApplicationName();
+ if (an == null)
+ an = context.getProjectName();
+ fss.setAttributeValue("application name", an);
+
+ fss.setModified(true);
+ appendModules();
+
+ modifyWebXML();
+
+ model.save();
+ }
+
private XModelObject getOrCreateFileSystem(String name, String location, boolean req) {
- return getOrCreateFileSystem(name, location, null, req, false);
- }
+ return getOrCreateFileSystem(name, location, null, req, false);
+ }
- private XModelObject getOrCreateFileSystem(String name, String location, String info) {
- return getOrCreateFileSystem(name, location, info, true, false);
- }
+ private XModelObject getOrCreateFileSystem(String name, String location, String info) {
+ return getOrCreateFileSystem(name, location, info, true, false);
+ }
- private XModelObject getOrCreateFileSystem(String name, String location, String info, boolean req, boolean jar) {
- XModelObject fs = (req) ? null : (XModelObject)filesystems.get(location);
- if(fs != null) return fs;
- String entity = (!jar) ? "FileSystemFolder" : "FileSystemJar";
- fs = model.createModelObject(entity, null);
- fs.setAttributeValue("name", name);
- fs.setAttributeValue("location", location);
- if(info != null) fs.setAttributeValue("info", info);
- fss.addChild(fs);
- filesystems.put(location, fs);
- return fs;
- }
+ private XModelObject getOrCreateFileSystem(String name, String location,
+ String info, boolean req, boolean jar) {
+ XModelObject fs = (req) ? null : (XModelObject) filesystems.get(location);
+ if (fs != null)
+ return fs;
+ String entity = (!jar) ? "FileSystemFolder" : "FileSystemJar";
+ fs = model.createModelObject(entity, null);
+ fs.setAttributeValue("name", name);
+ fs.setAttributeValue("location", location);
+ if (info != null)
+ fs.setAttributeValue("info", info);
+ fss.addChild(fs);
+ filesystems.put(location, fs);
+ return fs;
+ }
private void createWebInfFileSystem() {
- getOrCreateFileSystem("WEB-INF", XModelConstants.WORKSPACE_REF, true);
- }
+ getOrCreateFileSystem("WEB-INF", XModelConstants.WORKSPACE_REF, true);
+ }
private void createWebXMLFileSystem() {
File webxml = new File(context.getWebXmlLocation());
- String webxmlfolder = webxml.getParent();
- String relative = getRelativePath(workspace, webxmlfolder);
- if(relative == null || relative.startsWith("/..")) {
- String loc = (relative == null) ? webxmlfolder : XModelConstants.WORKSPACE_REF + relative;
- getOrCreateFileSystem("web-xml", loc, true);
- web.setAttributeValue("model path", "/" + webxml.getName());
- } else {
- web.setAttributeValue("model path", relative + "/" + webxml.getName());
- }
- }
+ String webxmlfolder = webxml.getParent();
+ String relative = getRelativePath(workspace, webxmlfolder);
+ if (relative == null || relative.startsWith("/..")) {
+ String loc = (relative == null) ? webxmlfolder
+ : XModelConstants.WORKSPACE_REF + relative;
+ getOrCreateFileSystem("web-xml", loc, true);
+ web.setAttributeValue("model path", "/" + webxml.getName());
+ } else {
+ web.setAttributeValue("model path", relative + "/"
+ + webxml.getName());
+ }
+ }
private XModelObject getDefaultModule() {
- XModelObject[] ms = context.getModules();
- for (int i = 0; i < ms.length; i++)
- if(ms[i].getAttributeValue("name").length() == 0) return ms[i];
- return null;
- }
+ XModelObject[] ms = context.getModules();
+ for (int i = 0; i < ms.length; i++) {
+ if (ms[i].getAttributeValue("name").length() == 0)
+ return ms[i];
+ }
+ return null;
+ }
private void createWebRootFileSystem() {
- XModelObject m = getDefaultModule();
- if(m == null) return;
- String loc = getFileSystemLocation(workspace, m.getAttributeValue("root"));
- m.setAttributeValue(WebModuleConstants.ATTR_ROOT_FS, "WEB-ROOT");
- getOrCreateFileSystem("WEB-ROOT", loc, "Content-Type=Web");
- }
+ XModelObject m = getDefaultModule();
+ if (m == null)
+ return;
+ String loc = getFileSystemLocation(workspace, m
+ .getAttributeValue("root"));
+ m.setAttributeValue(WebModuleConstants.ATTR_ROOT_FS, "WEB-ROOT");
+ getOrCreateFileSystem("WEB-ROOT", loc, "Content-Type=Web");
+ }
- private void createSrcFileSystems() {
- createWebRootSrcFileSystem();
- }
+ private void createSrcFileSystems() {
+ createWebRootSrcFileSystem();
+ }
private void createWebRootSrcFileSystem() {
- XModelObject m = getDefaultModule();
- String[] srcs = context.getExistingSources();
- List<String> l = new ArrayList<String>();
- if(srcs != null) for (int i = 0; i < srcs.length; i++) l.add(srcs[i]);
+ XModelObject m = getDefaultModule();
+ String[] srcs = context.getExistingSources();
+ List<String> l = new ArrayList<String>();
+ if (srcs != null)
+ for (int i = 0; i < srcs.length; i++)
+ l.add(srcs[i]);
String s = m.getAttributeValue("java src");
- if(!l.contains(s)) l.add(s);
- srcs = l.toArray(new String[0]);
- String srcAttr = "";
- int j = 0;
- for (int i = 0; i < srcs.length; i++) {
+ if (!l.contains(s))
+ l.add(s);
+ srcs = l.toArray(new String[0]);
+ String srcAttr = "";
+ int j = 0;
+ for (int i = 0; i < srcs.length; i++) {
srclocation = srcs[i];
- if(srclocation.length() == 0) continue;
+ if (srclocation.length() == 0)
+ continue;
String loc = getFileSystemLocation(workspace, srclocation);
++j;
- String fsn = (j == 1) ? "src" : "src" + j;
+ String fsn = (j == 1) ? "src" : "src" + j;
getOrCreateFileSystem(fsn, loc, false);
- if(j > 1) srcAttr += ",";
+ if (j > 1)
+ srcAttr += ",";
srcAttr += fsn;
- }
- m.setAttributeValue("src file system", srcAttr);
- }
+ }
+ m.setAttributeValue("src file system", srcAttr);
+ }
private void createLibFileSystems() {
String lib = context.getLibLocation();
- if(lib == null || lib.length() == 0) return;
- File f = new File(lib);
- if(!f.isDirectory()) return;
- String loc = getFileSystemLocation(workspace, lib);
+ if (lib == null || lib.length() == 0)
+ return;
+ File f = new File(lib);
+ if (!f.isDirectory())
+ return;
+ String loc = getFileSystemLocation(workspace, lib);
getOrCreateFileSystem("lib", loc, true);
- File[] jars = f.listFiles(new FileFilter() {
- public boolean accept(File file) {
- if (!file.isFile()) return false;
- String name = file.getName().toLowerCase();
- return name.endsWith(".jar") || name.endsWith(".zip");
- }
- });
- if(jars != null) for (int i = 0; i < jars.length; i++) {
- String n = jars[i].getName();
- getOrCreateFileSystem("lib-" + n, loc + "/" + n, "hidden=yes", true, true);
- }
- }
+ File[] jars = f.listFiles(new FileFilter() {
+ public boolean accept(File file) {
+ if (!file.isFile())
+ return false;
+ String name = file.getName().toLowerCase();
+ return name.endsWith(".jar") || name.endsWith(".zip");
+ }
+ });
+ if (jars != null)
+ for (int i = 0; i < jars.length; i++) {
+ String n = jars[i].getName();
+ getOrCreateFileSystem("lib-" + n, loc + "/" + n, "hidden=yes",
+ true, true);
+ }
+ }
- private void createClassesFileSystem() {
+ private void createClassesFileSystem() {
String classes = context.getClassesLocation();
- if(classes == null || classes.length() == 0) return;
- if(!new File(classes).isDirectory()) return;
- String loc = getFileSystemLocation(workspace, classes);
- getOrCreateFileSystem("classes", loc, false);
- }
+ if(classes == null || classes.length() == 0) return;
+ if(!new File(classes).isDirectory()) return;
+ String loc = getFileSystemLocation(workspace, classes);
+ getOrCreateFileSystem("classes", loc, false);
+ }
- private void createBuildFileSystem() {
+ private void createBuildFileSystem() {
String build = context.getBuildXmlLocation();
if(build == null || build.length() == 0) return;
File f = new File(build);
@@ -178,28 +206,54 @@
f = f.getParentFile();
build = f.getAbsolutePath();
}
- if(!new File(build).isDirectory()) return;
- String loc = getFileSystemLocation(workspace, build);
- getOrCreateFileSystem("build", loc, false);
- }
+ if(!new File(build).isDirectory()) return;
+ String loc = getFileSystemLocation(workspace, build);
+ getOrCreateFileSystem("build", loc, false);
+ }
protected void appendModules() {
- XModelObject[] ms = web.getChildren("WebJSFModule");
- for (int i = 0; i < ms.length; i++) ms[i].removeFromParent();
- ms = context.getModules();
- for (int i = 0; i < ms.length; i++) web.addChild(ms[i]);
- web.setModified(true);
- }
+ XModelObject[] ms = web.getChildren("WebJSFModule");
+ for (int i = 0; i < ms.length; i++) ms[i].removeFromParent();
+ ms = context.getModules();
+ for (int i = 0; i < ms.length; i++) web.addChild(ms[i]);
+ web.setModified(true);
+ }
public static String getRelativePath(String rootpath, String path) {
- return FileUtil.getRelativePath(rootpath, path);
- }
+ return FileUtil.getRelativePath(rootpath, path);
+ }
- public static String getFileSystemLocation(String rootpath, String path) {
- path = path.replace('\\', '/');
- String relative = getRelativePath(rootpath, path);
- return (relative == null) ? path : XModelConstants.WORKSPACE_REF + relative;
- }
+ public static String getFileSystemLocation(String rootpath, String path) {
+ path = path.replace('\\', '/');
+ String relative = getRelativePath(rootpath, path);
+ return (relative == null) ? path : XModelConstants.WORKSPACE_REF + relative;
+ }
+ void modifyWebXML() throws XModelException {
+ XModelObject webxml = WebAppHelper.getWebApp(model);
+ XModelObject servlet = WebAppHelper.findServlet(webxml,
+ JSFConstants.FACES_SERVLET_CLASS, "Faces Config");
+ if (servlet == null) {
+ servlet = WebAppHelper.findOrCreateServlet(webxml,
+ JSFConstants.FACES_SERVLET_CLASS, "Faces Config", -1);
+ }
+ String servletName = servlet.getAttributeValue("servlet-name");
+ XModelObject mapping = WebAppHelper.findServletMapping(webxml,
+ servletName);
+ if (mapping == null) {
+ mapping = WebAppHelper.findOrCreateServletMapping(webxml, servletName);
+ }
+
+ XModelObject facesConfig = model.getByPath("/faces-config.xml");
+ if (facesConfig == null) {
+ XModelObject webinf = FileSystemsHelper.getWebInf(model);
+ if (webinf != null) {
+ facesConfig = XModelObjectLoaderUtil.createValidObject(model, JSFConstants.ENT_FACESCONFIG_12);
+ DefaultCreateHandler.addCreatedObject(webinf, facesConfig, -1);
+ }
+ }
+
+ }
+
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/helpers/context/ImportJSFWarContext.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/helpers/context/ImportJSFWarContext.java 2008-06-30 14:00:15 UTC (rev 9015)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/helpers/context/ImportJSFWarContext.java 2008-06-30 14:07:18 UTC (rev 9016)
@@ -12,6 +12,7 @@
import org.jboss.tools.common.model.XModelException;
import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.jsf.model.JSFConstants;
import org.jboss.tools.jsf.project.JSFNature;
import org.jboss.tools.jsf.web.JSFWebHelper;
import org.jboss.tools.jst.web.context.AdoptWebProjectContext;
@@ -30,7 +31,7 @@
protected void loadWebXML(String body, String location) throws XModelException {
super.loadWebXML(body, location);
- if(WebAppHelper.findServlet(webxml, "javax.faces.webapp.FacesServlet", null) == null) {
+ if(WebAppHelper.findServlet(webxml, JSFConstants.FACES_SERVLET_CLASS, null) == null) {
String webXMLErrorMessage = "No JSF support found in the project.";
throw new XModelException(webXMLErrorMessage);
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/pattern/PatternLoader.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/pattern/PatternLoader.java 2008-06-30 14:00:15 UTC (rev 9015)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/web/pattern/PatternLoader.java 2008-06-30 14:07:18 UTC (rev 9016)
@@ -13,6 +13,7 @@
import java.util.ArrayList;
import org.jboss.tools.common.model.*;
+import org.jboss.tools.jsf.model.JSFConstants;
import org.jboss.tools.jst.web.browser.wtp.RunOnServerContext;
import org.jboss.tools.jst.web.model.helpers.WebAppHelper;
@@ -65,7 +66,7 @@
}
String getFacesServletName(XModelObject webxml) {
- XModelObject s = WebAppHelper.findServlet(webxml, "javax.faces.webapp.FacesServlet", null);
+ XModelObject s = WebAppHelper.findServlet(webxml, JSFConstants.FACES_SERVLET_CLASS, null);
return (s != null) ? s.getAttributeValue("servlet-name") : "FacesServlet";
}
16 years, 6 months
JBoss Tools SVN: r9015 - trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/model/helpers.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-06-30 10:00:15 -0400 (Mon, 30 Jun 2008)
New Revision: 9015
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/model/helpers/WebAppHelper.java
Log:
JBIDE-1970
Modified: trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/model/helpers/WebAppHelper.java
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/model/helpers/WebAppHelper.java 2008-06-30 12:45:57 UTC (rev 9014)
+++ trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/model/helpers/WebAppHelper.java 2008-06-30 14:00:15 UTC (rev 9015)
@@ -118,6 +118,43 @@
}
/**
+ * Returns model object representing <servlet-mapping> with
+ * <servlet-name> = servletName
+ * @param webxml
+ * @param name - <servlet-name> value or null
+ * @return
+ */
+ public static XModelObject findServletMapping(XModelObject webxml, String servletName) {
+ if(webxml == null) return null;
+ XModelObject[] s = getServletMappings(webxml);
+ for (int i = 0; i < s.length; i++) {
+ if(servletName != null && servletName.equals(s[i].getAttributeValue("servlet-name"))) return s[i];
+ }
+ return null;
+ }
+
+ /**
+ * Returns model object of entity WebAppServlet, either found
+ * by findServletMapping method or new object.
+ * @param webxml
+ * @param servletName
+ * @return
+ */
+ public static XModelObject findOrCreateServletMapping(XModelObject webxml, String servletName) throws XModelException {
+ if(webxml == null) return null;
+ XModelObject s = findServletMapping(webxml, servletName);
+ if(s == null) {
+ XModelObject folder = webxml.getChildByPath(SERVLET_FOLDER);
+ if(folder == null) folder = webxml;
+ s = webxml.getModel().createModelObject(SERVLET_MAPPING_ENTITY, null);
+ s.setAttributeValue("servlet-name", servletName);
+ s.setAttributeValue("url-pattern", "*.jsf");
+ DefaultCreateHandler.addCreatedObject(folder, s, -1);
+ }
+ return s;
+ }
+
+ /**
* Returns model object representing <init-param> in <servlet> with
* param-name = name.
* @param servlet
16 years, 6 months