JBoss Tools SVN: r8834 - trunk/birt/plugins/org.jboss.tools.birt.core/src/org/jboss/tools/birt/core/internal/project/facet.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-06-18 15:29:54 -0400 (Wed, 18 Jun 2008)
New Revision: 8834
Added:
trunk/birt/plugins/org.jboss.tools.birt.core/src/org/jboss/tools/birt/core/internal/project/facet/BirtPostInstallListener.java
Log:
JBIDE-2220 JBoss BIRT Integration
Added: trunk/birt/plugins/org.jboss.tools.birt.core/src/org/jboss/tools/birt/core/internal/project/facet/BirtPostInstallListener.java
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.core/src/org/jboss/tools/birt/core/internal/project/facet/BirtPostInstallListener.java (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.core/src/org/jboss/tools/birt/core/internal/project/facet/BirtPostInstallListener.java 2008-06-18 19:29:54 UTC (rev 8834)
@@ -0,0 +1,101 @@
+package org.jboss.tools.birt.core.internal.project.facet;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.Properties;
+import java.util.Set;
+
+import org.eclipse.birt.integration.wtp.ui.internal.resource.BirtWTPMessages;
+import org.eclipse.birt.integration.wtp.ui.internal.util.Logger;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.wst.common.frameworks.datamodel.IDataModel;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectEvent;
+import org.eclipse.wst.common.project.facet.core.events.IFacetedProjectListener;
+import org.eclipse.wst.common.project.facet.core.events.IProjectFacetActionEvent;
+import org.jboss.tools.birt.core.BirtCoreActivator;
+
+public class BirtPostInstallListener implements IFacetedProjectListener {
+
+ public void handleEvent(IFacetedProjectEvent event) {
+ IFacetedProject facetedProject = event.getProject();
+ Set<IProjectFacetVersion> projectFacets = facetedProject
+ .getProjectFacets();
+ boolean isBirtProject = false;
+ for (IProjectFacetVersion projectFacetVersion : projectFacets) {
+ IProjectFacet projectFacet = projectFacetVersion.getProjectFacet();
+ if (BirtCoreActivator.JBOSS_BIRT__FACET_ID.equals(projectFacet
+ .getId())) {
+ isBirtProject = true;
+ break;
+ }
+ }
+ if (isBirtProject) {
+ IProjectFacetActionEvent actionEvent = (IProjectFacetActionEvent) event;
+ IDataModel dataModel = (IDataModel) actionEvent.getActionConfig();
+ String configFolder = dataModel
+ .getStringProperty("IJ2EEFacetInstallDataModelProperties.CONFIG_FOLDER"); //$NON-NLS-1$
+ if (configFolder == null) {
+ String message = BirtWTPMessages.BIRTErrors_wrong_webcontent;
+ Logger.log(Logger.ERROR, message);
+ return;
+ }
+ String configIniString = configFolder + "/WEB-INF/platform/configuration/config.ini";
+ IProject project = facetedProject.getProject();
+ IResource configFile = project.findMember(new Path(configIniString));
+ if (!configFile.exists()) {
+ String message = "The config.ini file doesn't exist";
+ Logger.log(Logger.ERROR, message);
+ return;
+ }
+ Properties properties = new Properties();
+ InputStream inputStream = null;
+ ByteArrayOutputStream outputStream = null;
+ try {
+ URL url = configFile.getLocation().toFile().toURL();
+ inputStream = url.openStream();
+ properties.load(inputStream);
+ String bootDelegation = "org.osgi.framework.bootdelegation";
+ String loader = "osgi.parentClassloader";
+ properties.put(bootDelegation, "org.hibernate,org.hibernate.type,org.hibernate.metadata");
+ properties.put(loader,"fwk");
+ // FIXME
+ //String compatibility = "osgi.compatibility.bootdelegation";
+ //properties.put(compatibility,"false");
+ IFile file = (IFile) configFile;
+ outputStream = new ByteArrayOutputStream();
+ properties.store(outputStream, null);
+ file.setContents(new ByteArrayInputStream(outputStream
+ .toByteArray()), true, true, null);
+
+ } catch (Exception e) {
+ Logger.log(Logger.ERROR, e.getLocalizedMessage());
+ } finally {
+ if (inputStream != null) {
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ if (outputStream != null) {
+ try {
+ outputStream.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+
+ }
+ }
+
+}
17 years, 10 months
JBoss Tools SVN: r8833 - 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-18 15:29:19 -0400 (Wed, 18 Jun 2008)
New Revision: 8833
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/HibernateDataSourcePropertyPage.java
trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/impl/HibernateSelectionPageHelper.java
Log:
JBIDE-2220 JBoss BIRT Integration
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-18 19:29:12 UTC (rev 8832)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/impl/CustomDataSetWizardPage.java 2008-06-18 19:29:19 UTC (rev 8833)
@@ -82,7 +82,7 @@
import org.hibernate.eclipse.console.workbench.xpl.AnyAdaptableLabelProvider;
import org.hibernate.eclipse.hqleditor.HQLEditorDocumentSetupParticipant;
import org.hibernate.eclipse.hqleditor.HQLSourceViewerConfiguration;
-import org.jboss.tools.birt.oda.IOdaSessionFactory;
+import org.jboss.tools.birt.oda.IOdaFactory;
import org.jboss.tools.birt.oda.impl.HibernateDriver;
import org.jboss.tools.birt.oda.ui.Activator;
@@ -364,7 +364,7 @@
DataSetDesign design = getInitializationDesign();
DataSourceDesign dsDesign = design.getDataSourceDesign();
Property property = dsDesign.getPublicProperties().findProperty(
- IOdaSessionFactory.CONFIGURATION);
+ IOdaFactory.CONFIGURATION);
NameValuePair propertyValue = property.getNameValue();
String name = propertyValue.getValue();
return name;
Modified: trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/impl/HibernateDataSourcePropertyPage.java
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/impl/HibernateDataSourcePropertyPage.java 2008-06-18 19:29:12 UTC (rev 8832)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/impl/HibernateDataSourcePropertyPage.java 2008-06-18 19:29:19 UTC (rev 8833)
@@ -11,7 +11,7 @@
import org.eclipse.datatools.connectivity.oda.design.ui.wizards.DataSourceEditorPage;
import org.eclipse.swt.widgets.Composite;
-import org.jboss.tools.birt.oda.IOdaSessionFactory;
+import org.jboss.tools.birt.oda.IOdaFactory;
/**
* Hibernate property page
@@ -31,8 +31,8 @@
if (dataSourceProps == null) {
props = new Properties();
}
- props.setProperty(IOdaSessionFactory.CONFIGURATION, helper.getConfiguration());
- props.setProperty(IOdaSessionFactory.MAX_ROWS, helper.getMaxRows());
+ props.setProperty(IOdaFactory.CONFIGURATION, helper.getConfiguration());
+ props.setProperty(IOdaFactory.MAX_ROWS, helper.getMaxRows());
return props;
}
Modified: trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/impl/HibernateSelectionPageHelper.java
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/impl/HibernateSelectionPageHelper.java 2008-06-18 19:29:12 UTC (rev 8832)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/impl/HibernateSelectionPageHelper.java 2008-06-18 19:29:19 UTC (rev 8833)
@@ -34,7 +34,7 @@
import org.hibernate.SessionFactory;
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.console.KnownConfigurations;
-import org.jboss.tools.birt.oda.IOdaSessionFactory;
+import org.jboss.tools.birt.oda.IOdaFactory;
import org.jboss.tools.birt.oda.ui.Activator;
/**
@@ -150,12 +150,12 @@
public void initCustomControl(Properties profileProps) {
if (profileProps != null) {
String confName = profileProps
- .getProperty(IOdaSessionFactory.CONFIGURATION);
+ .getProperty(IOdaFactory.CONFIGURATION);
if (confName != null) {
configurationCombo.setText(confName);
}
String maxResult = profileProps
- .getProperty(IOdaSessionFactory.MAX_ROWS);
+ .getProperty(IOdaFactory.MAX_ROWS);
maxRows.setText(maxResult);
} else {
if (configurationCombo.getItemCount() > 0) {
@@ -224,9 +224,9 @@
props = new Properties();
props
- .setProperty(IOdaSessionFactory.CONFIGURATION,
+ .setProperty(IOdaFactory.CONFIGURATION,
getConfiguration());
- props.setProperty(IOdaSessionFactory.MAX_ROWS, getMaxRows());
+ props.setProperty(IOdaFactory.MAX_ROWS, getMaxRows());
return props;
}
17 years, 10 months
JBoss Tools SVN: r8832 - in trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda: impl and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-06-18 15:29:12 -0400 (Wed, 18 Jun 2008)
New Revision: 8832
Added:
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/IOdaFactory.java
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/ConsoleConfigurationOdaFactory.java
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/ReflectServerOdaFactory.java
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/ServerOdaFactory.java
Removed:
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/IOdaSessionFactory.java
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/ConsoleConfigurationOdaSessionFactory.java
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/ServerOdaSessionFactory.java
Modified:
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateConnection.java
Log:
JBIDE-2220 JBoss BIRT Integration
Copied: trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/IOdaFactory.java (from rev 8732, trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/IOdaSessionFactory.java)
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/IOdaFactory.java (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/IOdaFactory.java 2008-06-18 19:29:12 UTC (rev 8832)
@@ -0,0 +1,41 @@
+/*************************************************************************************
+ * Copyright (c) 2008 JBoss, a division of Red Hat 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss, a division of Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.birt.oda;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.datatools.connectivity.oda.OdaException;
+import org.jboss.tools.birt.oda.impl.HibernateOdaQuery;
+import org.jboss.tools.birt.oda.impl.HibernateResultSetMetaData;
+
+/**
+ *
+ * @author snjeza
+ *
+ */
+public interface IOdaFactory {
+
+ public static final String MAX_ROWS = "maxRows";
+ public static final String CONFIGURATION = "configuration";
+ public static final String ORG_HIBERNATE_ECLIPSE_BUNDLE_ID = "org.hibernate.eclipse";
+
+ void close();
+ boolean isOpen();
+ HibernateResultSetMetaData prepare(String queryText) throws OdaException;
+ void setMaxRows(int max);
+ int getMaxRows();
+ void executeQuery(HibernateOdaQuery query) throws OdaException;
+ Iterator getIterator();
+ List getResult();
+ Object getResult(int rstcol) throws OdaException;
+ void next();
+}
Deleted: trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/IOdaSessionFactory.java
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/IOdaSessionFactory.java 2008-06-18 19:28:59 UTC (rev 8831)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/IOdaSessionFactory.java 2008-06-18 19:29:12 UTC (rev 8832)
@@ -1,41 +0,0 @@
-/*************************************************************************************
- * Copyright (c) 2008 JBoss, a division of Red Hat 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * JBoss, a division of Red Hat - Initial implementation.
- ************************************************************************************/
-package org.jboss.tools.birt.oda;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.datatools.connectivity.oda.OdaException;
-import org.jboss.tools.birt.oda.impl.HibernateOdaQuery;
-import org.jboss.tools.birt.oda.impl.HibernateResultSetMetaData;
-
-/**
- *
- * @author snjeza
- *
- */
-public interface IOdaSessionFactory {
-
- public static final String MAX_ROWS = "maxRows";
- public static final String CONFIGURATION = "configuration";
- public static final String ORG_HIBERNATE_ECLIPSE_BUNDLE_ID = "org.hibernate.eclipse";
-
- void close();
- boolean isOpen();
- HibernateResultSetMetaData prepare(String queryText) throws OdaException;
- void setMaxRows(int max);
- int getMaxRows();
- void executeQuery(HibernateOdaQuery query) throws OdaException;
- Iterator getIterator();
- List getResult();
- Object getResult(int rstcol) throws OdaException;
- void next();
-}
Copied: trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/ConsoleConfigurationOdaFactory.java (from rev 8732, trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/ConsoleConfigurationOdaSessionFactory.java)
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/ConsoleConfigurationOdaFactory.java (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/ConsoleConfigurationOdaFactory.java 2008-06-18 19:29:12 UTC (rev 8832)
@@ -0,0 +1,76 @@
+/*************************************************************************************
+ * Copyright (c) 2008 JBoss, a division of Red Hat 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss, a division of Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.birt.oda.impl;
+
+import java.util.Properties;
+
+import org.eclipse.datatools.connectivity.oda.OdaException;
+import org.hibernate.HibernateException;
+import org.hibernate.SessionFactory;
+import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.console.KnownConfigurations;
+import org.jboss.tools.birt.oda.IOdaFactory;
+
+/**
+ *
+ * @author snjeza
+ *
+ */
+public class ConsoleConfigurationOdaFactory extends AbstractOdaFactory {
+
+ ConsoleConfiguration consoleConfiguration;
+
+ public ConsoleConfigurationOdaFactory(Properties properties) throws OdaException {
+ getSessionFactory(properties);
+ String maxRowString = properties.getProperty(IOdaFactory.MAX_ROWS);
+ try {
+ setMaxRows(new Integer(maxRowString).intValue());
+ } catch (NumberFormatException e) {
+ // ignore
+ }
+ }
+
+ public SessionFactory getSessionFactory(Properties properties) throws OdaException {
+ String configurationName = properties.getProperty(CONFIGURATION);
+ ConsoleConfiguration[] configurations = KnownConfigurations.getInstance().getConfigurations();
+ for (int i = 0; i < configurations.length; i++) {
+ if (configurations[i].getName().equals(configurationName)) {
+ consoleConfiguration=configurations[i];
+ break;
+ }
+ }
+ if (isOpen()) {
+ try {
+ sessionFactory = consoleConfiguration.getSessionFactory();
+ if (sessionFactory == null) {
+ consoleConfiguration.build();
+ consoleConfiguration.buildSessionFactory();
+ sessionFactory = consoleConfiguration.getSessionFactory();
+ }
+ } catch (HibernateException e) {
+ throw new OdaException(e.getLocalizedMessage());
+ }
+ } else {
+ throw new OdaException("Invalid configuration '" + configurationName + "'");
+ }
+ return sessionFactory;
+ }
+
+ @Override
+ public void close() {
+ consoleConfiguration = null;
+ super.close();
+ }
+
+ public boolean isOpen() {
+ return consoleConfiguration != null;
+ }
+}
Deleted: trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/ConsoleConfigurationOdaSessionFactory.java
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/ConsoleConfigurationOdaSessionFactory.java 2008-06-18 19:28:59 UTC (rev 8831)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/ConsoleConfigurationOdaSessionFactory.java 2008-06-18 19:29:12 UTC (rev 8832)
@@ -1,268 +0,0 @@
-/*************************************************************************************
- * Copyright (c) 2008 JBoss, a division of Red Hat 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * JBoss, a division of Red Hat - Initial implementation.
- ************************************************************************************/
-package org.jboss.tools.birt.oda.impl;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-import java.util.StringTokenizer;
-
-import org.eclipse.datatools.connectivity.oda.IResultSetMetaData;
-import org.eclipse.datatools.connectivity.oda.OdaException;
-import org.hibernate.EntityMode;
-import org.hibernate.HibernateException;
-import org.hibernate.Query;
-import org.hibernate.Session;
-import org.hibernate.SessionFactory;
-import org.hibernate.console.ConsoleConfiguration;
-import org.hibernate.console.KnownConfigurations;
-import org.hibernate.metadata.ClassMetadata;
-import org.hibernate.type.Type;
-import org.jboss.tools.birt.oda.IOdaSessionFactory;
-
-/**
- *
- * @author snjeza
- *
- */
-public class ConsoleConfigurationOdaSessionFactory implements
- IOdaSessionFactory {
-
- private ConsoleConfiguration consoleConfiguration;
- private SessionFactory sessionFactory;
- private int maxRows;
- private List result;
- private Iterator iterator;
- private Type[] queryReturnTypes;
- private Object currentRow;
- private HibernateOdaQuery query;
- private org.hibernate.classic.Session session;
- private String queryText;
-
- public ConsoleConfigurationOdaSessionFactory(Properties properties) throws OdaException {
- getSessionFactory(properties);
- String maxRowString = properties.getProperty(IOdaSessionFactory.MAX_ROWS);
- try {
- maxRows = new Integer(maxRowString);
- } catch (NumberFormatException e) {
- // ignore
- }
- }
-
- public SessionFactory getSessionFactory(Properties properties) throws OdaException {
- String configurationName = properties.getProperty(CONFIGURATION);
- ConsoleConfiguration[] configurations = KnownConfigurations.getInstance().getConfigurations();
- for (int i = 0; i < configurations.length; i++) {
- if (configurations[i].getName().equals(configurationName)) {
- consoleConfiguration=configurations[i];
- break;
- }
- }
- if (isOpen()) {
- try {
- sessionFactory = consoleConfiguration.getSessionFactory();
- if (sessionFactory == null) {
- consoleConfiguration.build();
- consoleConfiguration.buildSessionFactory();
- sessionFactory = consoleConfiguration.getSessionFactory();
- }
- } catch (HibernateException e) {
- throw new OdaException(e.getLocalizedMessage());
- }
- } else {
- throw new OdaException("Invalid configuration '" + configurationName + "'");
- }
- return sessionFactory;
- }
-
- public void close() {
- consoleConfiguration = null;
- sessionFactory = null;
- if (session != null) {
- session.close();
- session = null;
- }
- }
-
- public boolean isOpen() {
- return consoleConfiguration != null;
- }
-
- public SessionFactory getSessionFactory() {
- return sessionFactory;
- }
-
- public HibernateResultSetMetaData prepare(String queryText) throws OdaException {
- this.queryText = queryText;
- List arColsType = new ArrayList();
- List arCols = new ArrayList();
- List arColClass = new ArrayList();
- String[] props = null;
- Session session = null;
- try {
- session = getSessionFactory().openSession();
- Query query = session.createQuery(queryText);
- int maxRows = getMaxRows();
- if (maxRows > 0) {
- query.setFirstResult(0);
- query.setMaxResults(maxRows);
- }
- this.maxRows = maxRows;
- Type[] qryReturnTypes = query.getReturnTypes();
- if (qryReturnTypes.length > 0 && qryReturnTypes[0].isEntityType()) {
- for (int j = 0; j < qryReturnTypes.length; j++) {
- String clsName = qryReturnTypes[j].getName();
- props = getHibernateProp(clsName);
- for (int x = 0; x < props.length; x++) {
- String propType = getHibernatePropTypes(clsName,
- props[x]);
- if (DataTypes.isValidType(propType)) {
- arColsType.add(propType);
- arCols.add(props[x]);
- arColClass.add(clsName);
- } else {
- //throw new OdaException("Data Type is Not Valid");
- arColsType.add(DataTypes.UNKNOWN);
- arCols.add(props[x]);
- arColClass.add("java.lang.String");
- }
- }
- }
- } else {
- props = extractColumns(query.getQueryString());
- for (int t = 0; t < qryReturnTypes.length; t++) {
- if (DataTypes.isValidType(qryReturnTypes[t].getName())) {
- arColsType.add(qryReturnTypes[t].getName());
- arCols.add(props[t]);
- } else {
- throw new OdaException("'"
- + qryReturnTypes[t].getName()
- + "' is not a valid type.");
- }
- }
-
- }
- String[] arLabels = (String[]) arCols.toArray(new String[arCols
- .size()]);
- for (int j = 0; j < arLabels.length; j++) {
- arLabels[j] = arLabels[j].replace('.', ':');
- }
-
- return new HibernateResultSetMetaData(arLabels,
- (String[]) arColsType
- .toArray(new String[arColsType.size()]), arLabels,
- (String[]) arColClass
- .toArray(new String[arColClass.size()]));
- } catch (Exception e) {
- throw new OdaException(e.getLocalizedMessage());
- } finally {
- if (session != null) {
- session.close();
- }
- }
- }
-
- private static String[] extractColumns(final String query) {
- int fromPosition = query.toLowerCase().indexOf("from");
- int selectPosition = query.toLowerCase().indexOf("select");
- if (selectPosition >= 0) {
- String columns = query.substring(selectPosition + 6, fromPosition);
- StringTokenizer st = new StringTokenizer(columns, ",");
- List columnList = new ArrayList();
- while (st.hasMoreTokens()) {
- columnList.add(st.nextToken().trim());
- }
- return (String[]) columnList.toArray(new String[0]);
- } else {
- return null;
- }
- }
-
- private String[] getHibernateProp(String className){
- SessionFactory sf = getSessionFactory();
- String[] properties = sf.getClassMetadata(className).getPropertyNames();
- return( properties);
- }
-
- private String getHibernatePropTypes(String className, String property){
- SessionFactory sf = getSessionFactory();
- Type hibClassProps = sf.getClassMetadata(className).getPropertyType(property);
- return(hibClassProps.getName());
-
- }
-
- public int getMaxRows() {
- return maxRows;
- }
-
- public void setMaxRows(int maxRows) {
- this.maxRows = maxRows;
- }
-
- public void executeQuery(HibernateOdaQuery query) throws OdaException {
- this.query = query;
- try {
- session = getSessionFactory().openSession();
- Query q = session.createQuery(queryText);
- result = q.list();
- iterator = result.iterator();
- this.queryReturnTypes = q.getReturnTypes();
- } catch (HibernateException e) {
- throw new OdaException(e.getLocalizedMessage());
- }
- }
-
- public Iterator getIterator() {
- return iterator;
- }
-
- public List getResult() {
- return result;
- }
-
- public Object getResult(int rstcol) throws OdaException {
- Object obj = this.currentRow;
- Object value = null;
- try {
- if (queryReturnTypes.length > 0
- && queryReturnTypes[0].isEntityType()) {
- String checkClass = ((HibernateResultSetMetaData) getMetaData())
- .getColumnClass(rstcol);
- SessionFactory sf = getSessionFactory();
- ClassMetadata metadata = sf.getClassMetadata(checkClass);
- if (metadata == null) {
- metadata = sf.getClassMetadata(obj.getClass());
- }
- value = metadata.getPropertyValue(obj, getMetaData()
- .getColumnName(rstcol), EntityMode.POJO);
- } else {
- if (getMetaData().getColumnCount() == 1) {
- value = obj;
- } else {
- Object[] values = (Object[]) obj;
- value = values[rstcol - 1];
- }
- }
- } catch (Exception e) {
- throw new OdaException(e.getLocalizedMessage());
- }
- return (value);
- }
-
- private IResultSetMetaData getMetaData() throws OdaException {
- return query.getMetaData();
- }
-
- public void next() {
- currentRow = getIterator().next();
- }
-}
Modified: trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateConnection.java
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateConnection.java 2008-06-18 19:28:59 UTC (rev 8831)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateConnection.java 2008-06-18 19:29:12 UTC (rev 8832)
@@ -16,7 +16,7 @@
import org.eclipse.datatools.connectivity.oda.IDataSetMetaData;
import org.eclipse.datatools.connectivity.oda.IQuery;
import org.eclipse.datatools.connectivity.oda.OdaException;
-import org.jboss.tools.birt.oda.IOdaSessionFactory;
+import org.jboss.tools.birt.oda.IOdaFactory;
import org.osgi.framework.Bundle;
/**
@@ -24,103 +24,102 @@
*
* @author snjeza
*/
-public class HibernateConnection implements IConnection
-{
- private IOdaSessionFactory odaSessionFactory;
+public class HibernateConnection implements IConnection {
+ private IOdaFactory odaSessionFactory;
private Map appContext;
-
+
/*
- * @see org.eclipse.datatools.connectivity.oda.IConnection#open(java.util.Properties)
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IConnection#open(java.util.Properties
+ * )
*/
- public void open( Properties connProperties ) throws OdaException
- {
- Bundle bundle = Platform.getBundle(IOdaSessionFactory.ORG_HIBERNATE_ECLIPSE_BUNDLE_ID);
+ public void open(Properties connProperties) throws OdaException {
+ Bundle bundle = Platform
+ .getBundle(IOdaFactory.ORG_HIBERNATE_ECLIPSE_BUNDLE_ID);
if (bundle != null) {
- odaSessionFactory = new ConsoleConfigurationOdaSessionFactory(connProperties);
+ odaSessionFactory = new ConsoleConfigurationOdaFactory(
+ connProperties);
} else {
- //parentClassLoader = appContext.get(key);
- // FIXME
- odaSessionFactory = new ServerOdaSessionFactory(connProperties);
+ odaSessionFactory = new ServerOdaFactory(connProperties);
}
- }
+ }
/*
- * @see org.eclipse.datatools.connectivity.oda.IConnection#setAppContext(java.lang.Object)
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IConnection#setAppContext(java
+ * .lang.Object)
*/
- public void setAppContext( Object context ) throws OdaException
- {
- if (!(context instanceof Map)) {
- throw new OdaException("Invalid AppContext");
- }
- this.appContext = (Map) context;
+ public void setAppContext(Object context) throws OdaException {
+ if (!(context instanceof Map)) {
+ throw new OdaException("Invalid AppContext");
+ }
+ this.appContext = (Map) context;
}
/*
* @see org.eclipse.datatools.connectivity.oda.IConnection#close()
*/
- public void close() throws OdaException
- {
- odaSessionFactory.close();
+ public void close() throws OdaException {
+ odaSessionFactory.close();
}
/*
* @see org.eclipse.datatools.connectivity.oda.IConnection#isOpen()
*/
- public boolean isOpen() throws OdaException
- {
+ public boolean isOpen() throws OdaException {
return odaSessionFactory != null && odaSessionFactory.isOpen();
}
/*
- * @see org.eclipse.datatools.connectivity.oda.IConnection#getMetaData(java.lang.String)
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IConnection#getMetaData(java.lang
+ * .String)
*/
- public IDataSetMetaData getMetaData( String dataSetType ) throws OdaException
- {
- // assumes that this driver supports only one type of data set,
- // ignores the specified dataSetType
- return new HibernateDataSetMetaData( this );
+ public IDataSetMetaData getMetaData(String dataSetType) throws OdaException {
+ // assumes that this driver supports only one type of data set,
+ // ignores the specified dataSetType
+ return new HibernateDataSetMetaData(this);
}
/*
- * @see org.eclipse.datatools.connectivity.oda.IConnection#newQuery(java.lang.String)
+ * @see
+ * org.eclipse.datatools.connectivity.oda.IConnection#newQuery(java.lang
+ * .String)
*/
- public IQuery newQuery( String dataSetType ) throws OdaException
- {
- // assumes that this driver supports only one type of data set,
- // ignores the specified dataSetType
+ public IQuery newQuery(String dataSetType) throws OdaException {
+ // assumes that this driver supports only one type of data set,
+ // ignores the specified dataSetType
return new HibernateOdaQuery(this);
}
/*
* @see org.eclipse.datatools.connectivity.oda.IConnection#getMaxQueries()
*/
- public int getMaxQueries() throws OdaException
- {
- return 0; // no limit
+ public int getMaxQueries() throws OdaException {
+ return 0; // no limit
}
/*
* @see org.eclipse.datatools.connectivity.oda.IConnection#commit()
*/
- public void commit() throws OdaException
- {
- // do nothing; assumes no transaction support needed
+ public void commit() throws OdaException {
+ // do nothing; assumes no transaction support needed
}
/*
* @see org.eclipse.datatools.connectivity.oda.IConnection#rollback()
*/
- public void rollback() throws OdaException
- {
- // do nothing; assumes no transaction support needed
+ public void rollback() throws OdaException {
+ // do nothing; assumes no transaction support needed
}
- /*public SessionFactory getSessionFactory() {
- return odaSessionFactory.getSessionFactory();
- }*/
-
- public IOdaSessionFactory getOdaSessionFactory() {
+ /*
+ * public SessionFactory getSessionFactory() { return
+ * odaSessionFactory.getSessionFactory(); }
+ */
+
+ public IOdaFactory getOdaSessionFactory() {
return odaSessionFactory;
}
-
+
}
Added: trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/ReflectServerOdaFactory.java
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/ReflectServerOdaFactory.java (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/ReflectServerOdaFactory.java 2008-06-18 19:29:12 UTC (rev 8832)
@@ -0,0 +1,336 @@
+/*************************************************************************************
+ * Copyright (c) 2008 JBoss, a division of Red Hat 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * JBoss, a division of Red Hat - Initial implementation.
+ ************************************************************************************/
+package org.jboss.tools.birt.oda.impl;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.StringTokenizer;
+
+import javax.naming.InitialContext;
+
+import org.eclipse.datatools.connectivity.oda.IResultSetMetaData;
+import org.eclipse.datatools.connectivity.oda.OdaException;
+import org.hibernate.SessionFactory;
+import org.jboss.tools.birt.oda.Activator;
+import org.jboss.tools.birt.oda.IOdaFactory;
+
+/**
+ *
+ * @author snjeza
+ *
+ */
+public class ReflectServerOdaFactory implements IOdaFactory {
+
+ private static final Integer INTZERO = new Integer(0);
+ private static Class[] emptyClassArg = new Class[0];
+ private static Object[] emptyObjectArg = new Object[0];
+ private Object sessionFactory;
+ private Integer maxRows;
+ private String queryText;
+ private List result;
+ private Iterator iterator;
+ private Object currentRow;
+ private HibernateOdaQuery query;
+ private Object session;
+ private Object[] queryReturnTypes;
+
+ public ReflectServerOdaFactory(Properties properties) throws OdaException {
+ getSessionFactory(properties);
+ String maxRowString = properties.getProperty(IOdaFactory.MAX_ROWS);
+ try {
+ maxRows = new Integer(maxRowString);
+ } catch (NumberFormatException e) {
+ // ignore
+ }
+ }
+
+ public Object getSessionFactory(Properties properties)
+ throws OdaException {
+ String configurationName = properties.getProperty(CONFIGURATION);
+ if (sessionFactory == null) {
+ InitialContext ctx = null;
+ try {
+ ctx = new InitialContext();
+ Object obj = ctx.lookup("java:/" + configurationName);
+ sessionFactory = obj;
+ SessionFactory sf = (SessionFactory) obj;
+ System.out.println(sf);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new OdaException(
+ "Cannot create Hibernate session factory");
+ }
+
+ }
+ return sessionFactory;
+ }
+
+ public Object getSessionFactory() {
+ return sessionFactory;
+ }
+
+ public void close() {
+ closeSession(session);
+ }
+
+ public boolean isOpen() {
+ if (sessionFactory == null)
+ return false;
+ boolean isClosed = true;
+ try {
+ Method method = sessionFactory.getClass().getMethod("isClosed", new Class[0]);
+ if (method != null) {
+ Object closed = method.invoke(sessionFactory, new Object[0]);
+ isClosed = ((Boolean) closed).booleanValue();
+ }
+ } catch (Exception e) {
+ // ignore
+ }
+ return !isClosed;
+ }
+
+ public int getMaxRows() {
+ return maxRows;
+ }
+
+ public HibernateResultSetMetaData prepare(String queryText)
+ throws OdaException {
+ this.queryText = queryText;
+ List arColsType = new ArrayList();
+ List arCols = new ArrayList();
+ List arColClass = new ArrayList();
+ String[] props = null;
+ Object session = null;
+
+ try {
+ session = openSession();
+ Object query = createQuery(session, queryText);
+ if (maxRows > 0) {
+ Method setFirstResult = query.getClass().getMethod("setFirstResult", new Class[] {Integer.TYPE});
+ setFirstResult.invoke(query, new Object[] {INTZERO});
+ Method setMaxResults = query.getClass().getMethod("setMaxResults", new Class[] {Integer.TYPE});
+ setMaxResults.invoke(query, new Object[] {new Integer(maxRows)});
+ }
+ Method getReturnTypes = query.getClass().getMethod("getReturnTypes", emptyClassArg);
+ Object returnType = getReturnTypes.invoke(query, emptyObjectArg);
+ Object[] qryReturnTypes = (Object[]) returnType;
+ if (checkEntityType(qryReturnTypes)) {
+ for (int j = 0; j < qryReturnTypes.length; j++) {
+ String clsName = getReturnTypeName(qryReturnTypes[j]);
+ props = getHibernateProp(clsName);
+ for (int x = 0; x < props.length; x++) {
+ String propType = getHibernatePropTypes(clsName,
+ props[x]);
+ if (DataTypes.isValidType(propType)) {
+ arColsType.add(propType);
+ arCols.add(props[x]);
+ arColClass.add(clsName);
+ } else {
+ arColsType.add(DataTypes.UNKNOWN);
+ arCols.add(props[x]);
+ arColClass.add("java.lang.String");
+ }
+ }
+ }
+ } else {
+ props = extractColumns(queryText);
+ for (int t = 0; t < qryReturnTypes.length; t++) {
+ String typeName = getReturnTypeName(qryReturnTypes[t]);
+ if (DataTypes.isValidType(typeName)) {
+ arColsType.add(typeName);
+ arCols.add(props[t]);
+ } else {
+ throw new OdaException("'"
+ + typeName
+ + "' is not a valid type.");
+ }
+ }
+ }
+ String[] arLabels = (String[]) arCols.toArray(new String[arCols
+ .size()]);
+ for (int j = 0; j < arLabels.length; j++) {
+ arLabels[j] = arLabels[j].replace('.', ':');
+ }
+
+ return new HibernateResultSetMetaData(arLabels,
+ (String[]) arColsType
+ .toArray(new String[arColsType.size()]), arLabels,
+ (String[]) arColClass
+ .toArray(new String[arColClass.size()]));
+ } catch (Exception e) {
+ throw new OdaException(e.getLocalizedMessage());
+ } finally {
+ closeSession(session);
+ }
+ }
+
+ private void closeSession(Object session) {
+ if (session != null) {
+ try {
+ Method close = session.getClass().getMethod("close", emptyClassArg);
+ close.invoke(session, emptyObjectArg);
+ session = null;
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ }
+
+ private boolean checkEntityType(Object[] qryReturnTypes) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
+ Object first = qryReturnTypes[0];
+ Method isEntityType = first.getClass().getMethod("isEntityType", emptyClassArg);
+ Object ret = isEntityType.invoke(first, emptyObjectArg);
+ boolean isEntity = ((Boolean)ret).booleanValue();
+ return qryReturnTypes.length > 0 && isEntity;
+ }
+
+ private Object createQuery(Object session, String queryText)
+ throws NoSuchMethodException, IllegalAccessException,
+ InvocationTargetException {
+ Method createQuery = session.getClass().getMethod("createQuery", new Class[] {String.class});
+ Object query = createQuery.invoke(session, new Object[] {queryText});
+ return query;
+ }
+
+ private Object openSession() throws NoSuchMethodException,
+ IllegalAccessException, InvocationTargetException {
+ Object session;
+ Method openSession = sessionFactory.getClass().getMethod("openSession", emptyClassArg);
+ session = openSession.invoke(sessionFactory, emptyObjectArg);
+ return session;
+ }
+
+ private static String[] extractColumns(final String query) {
+ int fromPosition = query.toLowerCase().indexOf("from");
+ int selectPosition = query.toLowerCase().indexOf("select");
+ if (selectPosition >= 0) {
+ String columns = query.substring(selectPosition + 6, fromPosition);
+ StringTokenizer st = new StringTokenizer(columns, ",");
+ List columnList = new ArrayList();
+ while (st.hasMoreTokens()) {
+ columnList.add(st.nextToken().trim());
+ }
+ return (String[]) columnList.toArray(new String[0]);
+ } else {
+ return null;
+ }
+ }
+
+ private String getReturnTypeName(Object returnType) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
+ Method getName = returnType.getClass().getMethod("getName", emptyClassArg);
+ Object name = getName.invoke(returnType, emptyObjectArg);
+ return (String) name;
+ }
+
+ private String[] getHibernateProp(String className) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException{
+ Object classMetadata = getClassMetadata(className);
+ Method getPropertyNames = classMetadata.getClass().getMethod("getPropertyNames", emptyClassArg);
+ String[] properties = (String[]) getPropertyNames.invoke(classMetadata, emptyObjectArg);
+ return properties;
+ }
+
+ private Object getClassMetadata(String className)
+ throws NoSuchMethodException, IllegalAccessException,
+ InvocationTargetException {
+ Method getClassMetadata = sessionFactory.getClass().getMethod("getClassMetadata", new Class[] {String.class});
+ Object classMetadata = getClassMetadata.invoke(sessionFactory, new Object[] {className});
+ return classMetadata;
+ }
+
+ private Object getClassMetadata(Class clazz) throws NoSuchMethodException,
+ IllegalAccessException, InvocationTargetException {
+ Method getClassMetadata = sessionFactory.getClass().getMethod(
+ "getClassMetadata", new Class[] { Class.class });
+ Object classMetadata = getClassMetadata.invoke(sessionFactory,
+ new Object[] { clazz });
+ return classMetadata;
+ }
+
+ private String getHibernatePropTypes(String className, String property) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException{
+ Object classMetadata = getClassMetadata(className);
+ Method getPropertyType = classMetadata.getClass().getMethod("getPropertyType", new Class[] {String.class});
+ Object type = getPropertyType.invoke(classMetadata, new Object[] {property});
+ return getReturnTypeName(type);
+ }
+
+ public void setMaxRows(int max) {
+ maxRows = max;
+ }
+
+ public void executeQuery(HibernateOdaQuery query) throws OdaException {
+ this.query = query;
+ try {
+ session = openSession();
+ Object q = createQuery(session,queryText);
+ Method list = q.getClass().getMethod("list", emptyClassArg);
+ result = (List) list.invoke(q, emptyObjectArg);
+ iterator = result.iterator();
+ Method getReturnTypes = q.getClass().getMethod("getReturnTypes", emptyClassArg);
+ this.queryReturnTypes = (Object[]) getReturnTypes.invoke(q, emptyObjectArg);
+ } catch (Exception e) {
+ throw new OdaException(e.getLocalizedMessage());
+ }
+ }
+
+ public Iterator getIterator() {
+ return iterator;
+ }
+
+ public List getResult() {
+ return result;
+ }
+
+ public Object getResult(int rstcol) throws OdaException {
+ Object obj = this.currentRow;
+ Object value = null;
+ try {
+ if (checkEntityType(queryReturnTypes)) {
+ String checkClass = ((HibernateResultSetMetaData) getMetaData())
+ .getColumnClass(rstcol);
+ Object metadata = getClassMetadata(checkClass);
+ if (metadata == null) {
+ metadata = getClassMetadata(obj.getClass());
+ }
+ String className = "org.hibernate.EntityMode";
+ Class pojo = Activator.classForName(className, getClass());
+ Field pojoField = pojo.getField("POJO");
+ Object POJO = pojoField.get(null);
+ Class[] parameterTypes = new Class[] {Object.class,String.class, POJO.getClass()};
+ Method getPropertyValue = metadata.getClass().getMethod("getPropertyValue", parameterTypes);
+ Object[] args = new Object[] {obj,getMetaData().getColumnName(rstcol),POJO};
+ value = getPropertyValue.invoke(metadata, args);
+ } else {
+ if (getMetaData().getColumnCount() == 1) {
+ value = obj;
+ } else {
+ Object[] values = (Object[]) obj;
+ value = values[rstcol - 1];
+ }
+ }
+ } catch (Exception e) {
+ throw new OdaException(e.getLocalizedMessage());
+ }
+ return (value);
+ }
+
+ public void next() {
+ currentRow = getIterator().next();
+ }
+
+ private IResultSetMetaData getMetaData() throws OdaException {
+ return query.getMetaData();
+ }
+}
Copied: trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/ServerOdaFactory.java (from rev 8732, trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/ServerOdaSessionFactory.java)
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/ServerOdaFactory.java (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/ServerOdaFactory.java 2008-06-18 19:29:12 UTC (rev 8832)
@@ -0,0 +1,47 @@
+package org.jboss.tools.birt.oda.impl;
+
+import java.util.Properties;
+
+import javax.naming.InitialContext;
+
+import org.eclipse.datatools.connectivity.oda.OdaException;
+import org.hibernate.SessionFactory;
+import org.jboss.tools.birt.oda.IOdaFactory;
+
+public class ServerOdaFactory extends AbstractOdaFactory {
+
+ public ServerOdaFactory(Properties properties) throws OdaException {
+ getSessionFactory(properties);
+ String maxRowString = properties
+ .getProperty(IOdaFactory.MAX_ROWS);
+ try {
+ setMaxRows(new Integer(maxRowString).intValue());
+ } catch (NumberFormatException e) {
+ // ignore
+ }
+ }
+
+ public Object getSessionFactory(Properties properties) throws OdaException {
+ String configurationName = properties.getProperty(CONFIGURATION);
+ if (sessionFactory == null) {
+ InitialContext ctx = null;
+ try {
+ ctx = new InitialContext();
+ sessionFactory = (SessionFactory) ctx.lookup("java:/"
+ + configurationName);
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new OdaException(
+ "Cannot create Hibernate session factory");
+ }
+
+ }
+ return sessionFactory;
+ }
+
+ public boolean isOpen() {
+ return sessionFactory != null && !sessionFactory.isClosed();
+ }
+
+}
Deleted: trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/ServerOdaSessionFactory.java
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/ServerOdaSessionFactory.java 2008-06-18 19:28:59 UTC (rev 8831)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/ServerOdaSessionFactory.java 2008-06-18 19:29:12 UTC (rev 8832)
@@ -1,333 +0,0 @@
-/*************************************************************************************
- * Copyright (c) 2008 JBoss, a division of Red Hat 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * JBoss, a division of Red Hat - Initial implementation.
- ************************************************************************************/
-package org.jboss.tools.birt.oda.impl;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-import java.util.StringTokenizer;
-
-import javax.naming.InitialContext;
-
-import org.eclipse.datatools.connectivity.oda.IResultSetMetaData;
-import org.eclipse.datatools.connectivity.oda.OdaException;
-import org.jboss.tools.birt.oda.Activator;
-import org.jboss.tools.birt.oda.IOdaSessionFactory;
-
-/**
- *
- * @author snjeza
- *
- */
-public class ServerOdaSessionFactory implements IOdaSessionFactory {
-
- private static final Integer INTZERO = new Integer(0);
- private static Class[] emptyClassArg = new Class[0];
- private static Object[] emptyObjectArg = new Object[0];
- private Object sessionFactory;
- private Integer maxRows;
- private String queryText;
- private List result;
- private Iterator iterator;
- private Object currentRow;
- private HibernateOdaQuery query;
- private Object session;
- private Object[] queryReturnTypes;
-
- public ServerOdaSessionFactory(Properties properties) throws OdaException {
- getSessionFactory(properties);
- String maxRowString = properties.getProperty(IOdaSessionFactory.MAX_ROWS);
- try {
- maxRows = new Integer(maxRowString);
- } catch (NumberFormatException e) {
- // ignore
- }
- }
-
- public Object getSessionFactory(Properties properties)
- throws OdaException {
- String configurationName = properties.getProperty(CONFIGURATION);
- if (sessionFactory == null) {
- InitialContext ctx = null;
- try {
- ctx = new InitialContext();
- Object obj = ctx.lookup("java:/" + configurationName);
- sessionFactory = obj;
- } catch (Exception e) {
- e.printStackTrace();
- throw new OdaException(
- "Cannot create Hibernate session factory");
- }
-
- }
- return sessionFactory;
- }
-
- public Object getSessionFactory() {
- return sessionFactory;
- }
-
- public void close() {
- closeSession(session);
- }
-
- public boolean isOpen() {
- if (sessionFactory == null)
- return false;
- boolean isClosed = true;
- try {
- Method method = sessionFactory.getClass().getMethod("isClosed", new Class[0]);
- if (method != null) {
- Object closed = method.invoke(sessionFactory, new Object[0]);
- isClosed = ((Boolean) closed).booleanValue();
- }
- } catch (Exception e) {
- // ignore
- }
- return !isClosed;
- }
-
- public int getMaxRows() {
- return maxRows;
- }
-
- public HibernateResultSetMetaData prepare(String queryText)
- throws OdaException {
- this.queryText = queryText;
- List arColsType = new ArrayList();
- List arCols = new ArrayList();
- List arColClass = new ArrayList();
- String[] props = null;
- Object session = null;
-
- try {
- session = openSession();
- Object query = createQuery(session, queryText);
- if (maxRows > 0) {
- Method setFirstResult = query.getClass().getMethod("setFirstResult", new Class[] {Integer.TYPE});
- setFirstResult.invoke(query, new Object[] {INTZERO});
- Method setMaxResults = query.getClass().getMethod("setMaxResults", new Class[] {Integer.TYPE});
- setMaxResults.invoke(query, new Object[] {new Integer(maxRows)});
- }
- Method getReturnTypes = query.getClass().getMethod("getReturnTypes", emptyClassArg);
- Object returnType = getReturnTypes.invoke(query, emptyObjectArg);
- Object[] qryReturnTypes = (Object[]) returnType;
- if (checkEntityType(qryReturnTypes)) {
- for (int j = 0; j < qryReturnTypes.length; j++) {
- String clsName = getReturnTypeName(qryReturnTypes[j]);
- props = getHibernateProp(clsName);
- for (int x = 0; x < props.length; x++) {
- String propType = getHibernatePropTypes(clsName,
- props[x]);
- if (DataTypes.isValidType(propType)) {
- arColsType.add(propType);
- arCols.add(props[x]);
- arColClass.add(clsName);
- } else {
- arColsType.add(DataTypes.UNKNOWN);
- arCols.add(props[x]);
- arColClass.add("java.lang.String");
- }
- }
- }
- } else {
- props = extractColumns(queryText);
- for (int t = 0; t < qryReturnTypes.length; t++) {
- String typeName = getReturnTypeName(qryReturnTypes[t]);
- if (DataTypes.isValidType(typeName)) {
- arColsType.add(typeName);
- arCols.add(props[t]);
- } else {
- throw new OdaException("'"
- + typeName
- + "' is not a valid type.");
- }
- }
- }
- String[] arLabels = (String[]) arCols.toArray(new String[arCols
- .size()]);
- for (int j = 0; j < arLabels.length; j++) {
- arLabels[j] = arLabels[j].replace('.', ':');
- }
-
- return new HibernateResultSetMetaData(arLabels,
- (String[]) arColsType
- .toArray(new String[arColsType.size()]), arLabels,
- (String[]) arColClass
- .toArray(new String[arColClass.size()]));
- } catch (Exception e) {
- throw new OdaException(e.getLocalizedMessage());
- } finally {
- closeSession(session);
- }
- }
-
- private void closeSession(Object session) {
- if (session != null) {
- try {
- Method close = session.getClass().getMethod("close", emptyClassArg);
- close.invoke(session, emptyObjectArg);
- session = null;
- } catch (Exception e) {
- // ignore
- }
- }
- }
-
- private boolean checkEntityType(Object[] qryReturnTypes) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
- Object first = qryReturnTypes[0];
- Method isEntityType = first.getClass().getMethod("isEntityType", emptyClassArg);
- Object ret = isEntityType.invoke(first, emptyObjectArg);
- boolean isEntity = ((Boolean)ret).booleanValue();
- return qryReturnTypes.length > 0 && isEntity;
- }
-
- private Object createQuery(Object session, String queryText)
- throws NoSuchMethodException, IllegalAccessException,
- InvocationTargetException {
- Method createQuery = session.getClass().getMethod("createQuery", new Class[] {String.class});
- Object query = createQuery.invoke(session, new Object[] {queryText});
- return query;
- }
-
- private Object openSession() throws NoSuchMethodException,
- IllegalAccessException, InvocationTargetException {
- Object session;
- Method openSession = sessionFactory.getClass().getMethod("openSession", emptyClassArg);
- session = openSession.invoke(sessionFactory, emptyObjectArg);
- return session;
- }
-
- private static String[] extractColumns(final String query) {
- int fromPosition = query.toLowerCase().indexOf("from");
- int selectPosition = query.toLowerCase().indexOf("select");
- if (selectPosition >= 0) {
- String columns = query.substring(selectPosition + 6, fromPosition);
- StringTokenizer st = new StringTokenizer(columns, ",");
- List columnList = new ArrayList();
- while (st.hasMoreTokens()) {
- columnList.add(st.nextToken().trim());
- }
- return (String[]) columnList.toArray(new String[0]);
- } else {
- return null;
- }
- }
-
- private String getReturnTypeName(Object returnType) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException {
- Method getName = returnType.getClass().getMethod("getName", emptyClassArg);
- Object name = getName.invoke(returnType, emptyObjectArg);
- return (String) name;
- }
-
- private String[] getHibernateProp(String className) throws SecurityException, NoSuchMethodException, IllegalArgumentException, IllegalAccessException, InvocationTargetException{
- Object classMetadata = getClassMetadata(className);
- Method getPropertyNames = classMetadata.getClass().getMethod("getPropertyNames", emptyClassArg);
- String[] properties = (String[]) getPropertyNames.invoke(classMetadata, emptyObjectArg);
- return properties;
- }
-
- private Object getClassMetadata(String className)
- throws NoSuchMethodException, IllegalAccessException,
- InvocationTargetException {
- Method getClassMetadata = sessionFactory.getClass().getMethod("getClassMetadata", new Class[] {String.class});
- Object classMetadata = getClassMetadata.invoke(sessionFactory, new Object[] {className});
- return classMetadata;
- }
-
- private Object getClassMetadata(Class clazz) throws NoSuchMethodException,
- IllegalAccessException, InvocationTargetException {
- Method getClassMetadata = sessionFactory.getClass().getMethod(
- "getClassMetadata", new Class[] { Class.class });
- Object classMetadata = getClassMetadata.invoke(sessionFactory,
- new Object[] { clazz });
- return classMetadata;
- }
-
- private String getHibernatePropTypes(String className, String property) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException{
- Object classMetadata = getClassMetadata(className);
- Method getPropertyType = classMetadata.getClass().getMethod("getPropertyType", new Class[] {String.class});
- Object type = getPropertyType.invoke(classMetadata, new Object[] {property});
- return getReturnTypeName(type);
- }
-
- public void setMaxRows(int max) {
- maxRows = max;
- }
-
- public void executeQuery(HibernateOdaQuery query) throws OdaException {
- this.query = query;
- try {
- session = openSession();
- Object q = createQuery(session,queryText);
- Method list = q.getClass().getMethod("list", emptyClassArg);
- result = (List) list.invoke(q, emptyObjectArg);
- iterator = result.iterator();
- Method getReturnTypes = q.getClass().getMethod("getReturnTypes", emptyClassArg);
- this.queryReturnTypes = (Object[]) getReturnTypes.invoke(q, emptyObjectArg);
- } catch (Exception e) {
- throw new OdaException(e.getLocalizedMessage());
- }
- }
-
- public Iterator getIterator() {
- return iterator;
- }
-
- public List getResult() {
- return result;
- }
-
- public Object getResult(int rstcol) throws OdaException {
- Object obj = this.currentRow;
- Object value = null;
- try {
- if (checkEntityType(queryReturnTypes)) {
- String checkClass = ((HibernateResultSetMetaData) getMetaData())
- .getColumnClass(rstcol);
- Object metadata = getClassMetadata(checkClass);
- if (metadata == null) {
- metadata = getClassMetadata(obj.getClass());
- }
- String className = "org.hibernate.EntityMode";
- Class pojo = Activator.classForName(className, getClass());
- Field pojoField = pojo.getField("POJO");
- Object POJO = pojoField.get(null);
- Class[] parameterTypes = new Class[] {Object.class,String.class, POJO.getClass()};
- Method getPropertyValue = metadata.getClass().getMethod("getPropertyValue", parameterTypes);
- Object[] args = new Object[] {obj,getMetaData().getColumnName(rstcol),POJO};
- value = getPropertyValue.invoke(metadata, args);
- } else {
- if (getMetaData().getColumnCount() == 1) {
- value = obj;
- } else {
- Object[] values = (Object[]) obj;
- value = values[rstcol - 1];
- }
- }
- } catch (Exception e) {
- throw new OdaException(e.getLocalizedMessage());
- }
- return (value);
- }
-
- public void next() {
- currentRow = getIterator().next();
- }
-
- private IResultSetMetaData getMetaData() throws OdaException {
- return query.getMetaData();
- }
-}
17 years, 10 months
JBoss Tools SVN: r8831 - trunk/birt/plugins/org.jboss.tools.birt.core.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-06-18 15:28:59 -0400 (Wed, 18 Jun 2008)
New Revision: 8831
Modified:
trunk/birt/plugins/org.jboss.tools.birt.core/plugin.xml
Log:
JBIDE-2220 JBoss BIRT Integration
Modified: trunk/birt/plugins/org.jboss.tools.birt.core/plugin.xml
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.core/plugin.xml 2008-06-18 18:07:40 UTC (rev 8830)
+++ trunk/birt/plugins/org.jboss.tools.birt.core/plugin.xml 2008-06-18 19:28:59 UTC (rev 8831)
@@ -58,4 +58,10 @@
<page class="org.eclipse.birt.integration.wtp.ui.internal.wizards.BirtWebProjectWizardConfigurationPage"/>
</wizard-pages>
</extension>
+
+ <extension point="org.eclipse.wst.common.project.facet.core.listeners">
+ <listener class="org.jboss.tools.birt.core.internal.project.facet.BirtPostInstallListener"
+ eventTypes="POST_INSTALL"/>
+ </extension>
+
</plugin>
17 years, 10 months
JBoss Tools SVN: r8830 - in branches/jbosstools-2.1.x: vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor and 5 other directories.
by jbosstools-commits@lists.jboss.org
Author: sdzmitrovich
Date: 2008-06-18 14:07:40 -0400 (Wed, 18 Jun 2008)
New Revision: 8830
Added:
branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/DocTypeUtil.java
branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/FaceletUtil.java
Modified:
branches/jbosstools-2.1.x/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelTemplate.java
branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlBodyTemplate.java
branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/XulRunnerBrowser.java
branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java
branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java
branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java
branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/ve/init.html
Log:
http://jira.jboss.com/jira/browse/JBIDE-2170
Modified: branches/jbosstools-2.1.x/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelTemplate.java
===================================================================
--- branches/jbosstools-2.1.x/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelTemplate.java 2008-06-18 15:22:26 UTC (rev 8829)
+++ branches/jbosstools-2.1.x/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesPanelTemplate.java 2008-06-18 18:07:40 UTC (rev 8830)
@@ -87,7 +87,7 @@
// FIX for JBIDE-1213 (Max Areshkau)
if(data.getNode()!=null) {
String bodyClass = ((Element)sourceNode).getAttribute("bodyClass");
- applyStylesToTable(data.getNode(), bodyClass);
+ //applyStylesToTable(data.getNode(), bodyClass);
}
}
Modified: branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java
===================================================================
--- branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2008-06-18 15:22:26 UTC (rev 8829)
+++ branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeController.java 2008-06-18 18:07:40 UTC (rev 8830)
@@ -135,6 +135,7 @@
import org.jboss.tools.vpe.editor.template.VpeTemplateListener;
import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
import org.jboss.tools.vpe.editor.toolbar.format.FormatControllerManager;
+import org.jboss.tools.vpe.editor.util.DocTypeUtil;
import org.jboss.tools.vpe.editor.util.TemplateManagingUtil;
import org.jboss.tools.vpe.editor.util.TextUtil;
import org.jboss.tools.vpe.editor.util.VisualDomUtil;
@@ -1385,16 +1386,25 @@
}
void visualRefreshImpl() {
- visualEditor.hideResizer();
- visualBuilder.setSelectionRectangle(null);
- IDOMModel sourceModel = (IDOMModel) getModel();
- if (sourceModel != null) {
- IDOMDocument sourceDocument = sourceModel.getDocument();
- visualBuilder.rebuildDom(sourceDocument);
- } else {
- visualBuilder.rebuildDom(null);
+ visualEditor.hideResizer();
+ String currentDoctype = DocTypeUtil.getDoctype(visualEditor
+ .getEditorInput());
+
+ if (!visualEditor.getDoctype().equals(currentDoctype)) {
+
+ visualEditor.reload();
+
+ } else {
+ visualBuilder.setSelectionRectangle(null);
+ IDOMModel sourceModel = (IDOMModel) getModel();
+ if (sourceModel != null) {
+ IDOMDocument sourceDocument = sourceModel.getDocument();
+ visualBuilder.rebuildDom(sourceDocument);
+ } else {
+ visualBuilder.rebuildDom(null);
+ }
+ }
}
- }
public void preLongOperation() {
switcher.startActiveEditor(ActiveEditorSwitcher.ACTIVE_EDITOR_VISUAL);
@@ -2817,5 +2827,21 @@
}
synced = true;
}
+
+ public void reinit() {
+ visualBuilder.setSelectionRectangle(null);
+ visualEditor.setEditorDomEventListener(this);
+ IDOMModel sourceModel = (IDOMModel) getModel();
+ if (sourceModel != null) {
+ IDOMDocument sourceDocument = sourceModel.getDocument();
+ visualBuilder.rebuildDom(sourceDocument);
+ } else {
+ visualBuilder.rebuildDom(null);
+ }
+
+ visualSelectionController.setSelection(xulRunnerEditor.getSelection());
+
+ }
+
}
Modified: branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java
===================================================================
--- branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2008-06-18 15:22:26 UTC (rev 8829)
+++ branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeVisualDomBuilder.java 2008-06-18 18:07:40 UTC (rev 8830)
@@ -67,6 +67,7 @@
import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
import org.jboss.tools.vpe.editor.template.VpeToggableTemplate;
import org.jboss.tools.vpe.editor.template.dnd.VpeDnd;
+import org.jboss.tools.vpe.editor.util.FaceletUtil;
import org.jboss.tools.vpe.editor.util.HTML;
import org.jboss.tools.vpe.editor.util.TextUtil;
import org.jboss.tools.vpe.editor.util.VisualDomUtil;
@@ -115,10 +116,10 @@
private MozillaEditor visualEditor;
private XulRunnerEditor xulRunnerEditor;
private nsIDOMDocument visualDocument;
- private nsIDOMElement visualContentArea;
+// private nsIDOMElement visualContentArea;
private VpePageContext pageContext;
private VpeDnD dnd;
- private nsIDOMNode headNode;
+// private nsIDOMNode headNode;
private List includeStack;
// TODO Max Areshkau JBIDE-1457
// boolean rebuildFlag = false;
@@ -167,18 +168,6 @@
private Map<IFile, Document> includeDocuments = new HashMap<IFile, Document>();
-
- /**
- * facelet elements, if there are these elements on a page then other
- * elements are deleted
- */
- static private HashSet<String> faceletRootElements = new HashSet<String>();
-
- static {
- faceletRootElements.add("composition"); //$NON-NLS-1$
- faceletRootElements.add("component"); //$NON-NLS-1$
- }
-
public VpeVisualDomBuilder(VpeDomMapping domMapping,
INodeAdapter sorceAdapter, VpeTemplateManager templateManager,
MozillaEditor visualEditor, VpePageContext pageContext) {
@@ -186,10 +175,10 @@
this.visualEditor = visualEditor;
xulRunnerEditor = visualEditor.getXulRunnerEditor();
this.visualDocument = visualEditor.getDomDocument();
- this.visualContentArea = visualEditor.getContentArea();
+// this.visualContentArea = visualEditor.getContentArea();
this.dnd = new VpeDnD();
this.pageContext = pageContext;
- this.headNode = visualEditor.getHeadNode();
+// this.headNode = visualEditor.getHeadNode();
dropper = new VpeDnd();
dropper.setDndData(false, true);
@@ -219,77 +208,36 @@
pageContext.refreshConnector();
pageContext.installIncludeElements();
if (isFacelet()) {
- Element root = getRootElement(sourceDocument);
+ Element root = FaceletUtil.getRootFaceletElement(sourceDocument);
if(root != null)
{
- addNode(root, null, visualContentArea);
+ addNode(root, null, getContentArea());
}
} else {
- addChildren(null, sourceDocument, visualContentArea);
+ addChildren(null, sourceDocument, getContentArea());
}
/*
* Fixes http://jira.jboss.com/jira/browse/JBIDE-2126.
* To provide appropriate context menu functionality
* visual content area should be mapped in any case.
*/
- registerNodes(new VpeNodeMapping(sourceDocument, visualContentArea));
+ registerNodes(new VpeNodeMapping(sourceDocument, getContentArea()));
}
- private Element getRootElement(Document sourceDocument) {
-
- NodeList nodeList = sourceDocument.getChildNodes();
- Element root = null;
-
- for (int i = 0; i < nodeList.getLength(); i++) {
- Node child = nodeList.item(i);
- if (child.getNodeType() == Node.ELEMENT_NODE) {
- root = (Element) child;
- break;
- }
- }
-
- if (root != null) {
- Element trimmedElement = findFaceletRootElement(root);
- if (trimmedElement != null)
- root = trimmedElement;
- }
- return root;
- }
-
- private Element findFaceletRootElement(Element element) {
-
- NodeList children = element.getChildNodes();
-
- for (int i = 0; i < children.getLength(); i++) {
- Node child = children.item(i);
- if (child.getNodeType() == Node.ELEMENT_NODE) {
-
- Element trimmedElement = findFaceletRootElement((Element) child);
- if (trimmedElement != null)
- return trimmedElement;
-
- }
- }
-
- if (faceletRootElements.contains(element.getLocalName()))
- return element;
- return null;
- }
-
public void rebuildDom(Document sourceDocument) {
// clearIncludeDocuments();
cleanHead();
- domMapping.clear(visualContentArea);
+ domMapping.clear(getContentArea());
super.dispose();
pageContext.clearAll();
refreshExternalLinks();
pageContext.getBundle().refreshRegisteredBundles();
- nsIDOMNodeList children = visualContentArea.getChildNodes();
+ nsIDOMNodeList children = getContentArea().getChildNodes();
long len = children.getLength();
for (long i = len - 1; i >= 0; i--) {
- visualContentArea.removeChild(children.item(i));
+ getContentArea().removeChild(children.item(i));
}
if (sourceDocument != null) {
@@ -654,7 +602,7 @@
nsIDOMText newText = visualDocument.createTextNode(styleText);
newStyle.appendChild(newText);
}
- headNode.appendChild(newStyle);
+ getHeadNode().appendChild(newStyle);
return newStyle;
}
@@ -668,12 +616,12 @@
newStyle.appendChild(newText);
}
- headNode.replaceChild(newStyle, oldStyleNode);
+ getHeadNode().replaceChild(newStyle, oldStyleNode);
return newStyle;
}
public void removeStyleNodeFromHead(nsIDOMNode oldStyleNode) {
- headNode.removeChild(oldStyleNode);
+ getHeadNode().removeChild(oldStyleNode);
}
void addExternalLinks() {
@@ -695,7 +643,7 @@
}
void removeExternalLinks() {
- nsIDOMNodeList childs = headNode.getChildNodes();
+ nsIDOMNodeList childs = getHeadNode().getChildNodes();
long length = childs.getLength();
for (long i = length - 1; i >= 0; i--) {
nsIDOMNode node = childs.item(i);
@@ -712,7 +660,7 @@
.equalsIgnoreCase(element.getAttribute(ATTR_VPE))))
&& YES_STRING.equalsIgnoreCase(element
.getAttribute(VpeTemplateManager.ATTR_LINK_EXT))) {
- headNode.removeChild(node);
+ getHeadNode().removeChild(node);
}
}
}
@@ -841,7 +789,7 @@
}
public boolean isEmptyDocument() {
- nsIDOMNodeList visualNodes = visualContentArea.getChildNodes();
+ nsIDOMNodeList visualNodes = getContentArea().getChildNodes();
long len = visualNodes.getLength();
if ((len == 0)
|| (len == 1 && (isEmptyText(visualNodes.item(0)) || isPseudoElement(visualNodes
@@ -1282,12 +1230,12 @@
}
boolean isContentArea(nsIDOMNode visualNode) {
- return visualContentArea.equals(visualNode);
+ return getContentArea().equals(visualNode);
}
nsIDOMElement getContentArea() {
- return visualContentArea;
- }
+ return visualEditor.getContentArea();
+ }
public void setSelectionRectangle(nsIDOMElement visualElement) {
setSelectionRectangle(visualElement, true);
@@ -1305,8 +1253,8 @@
//TODO Dzmitry Sakovich
// Fix priority CSS classes JBIDE-1713
- nsIDOMNode firstNode = headNode.getFirstChild();
- headNode.insertBefore(newNode, firstNode);
+ nsIDOMNode firstNode = getHeadNode().getFirstChild();
+ getHeadNode().insertBefore(newNode, firstNode);
return newNode;
}
@@ -1314,7 +1262,7 @@
String href_val, String ext_val) {
nsIDOMNode newNode = createLinkNode(href_val,
ATTR_REL_STYLESHEET_VALUE, ext_val);
- headNode.replaceChild(newNode, oldNode);
+ getHeadNode().replaceChild(newNode, oldNode);
return newNode;
}
@@ -1328,7 +1276,7 @@
}
public void removeLinkNodeFromHead(nsIDOMNode node) {
- headNode.removeChild(node);
+ getHeadNode().removeChild(node);
}
private nsIDOMElement createLinkNode(String href_val, String rel_val,
@@ -1392,7 +1340,7 @@
}
private nsIDOMNode getLinkNode(String href_val, String ext_val) {
- nsIDOMNodeList children = headNode.getChildNodes();
+ nsIDOMNodeList children = getHeadNode().getChildNodes();
long len = children.getLength();
for (long i = len - 1; i >= 0; i--) {
nsIDOMNode node = children.item(i);
@@ -1415,7 +1363,7 @@
}
private void cleanHead() {
- nsIDOMNodeList children = headNode.getChildNodes();
+ nsIDOMNodeList children = getHeadNode().getChildNodes();
long len = children.getLength();
for (long i = len - 1; i >= 0; i--) {
nsIDOMNode node = children.item(i);
@@ -1435,14 +1383,14 @@
// nsIStyleSheetLinkingElement linkingElement = new
// nsIStyleSheetLinkingElement(linkAddress);
// linkingElement.removeStyleSheet();
- node = headNode.removeChild(node);
+ node = getHeadNode().removeChild(node);
}
} else if (HTML.TAG_STYLE.equalsIgnoreCase(node.getNodeName())
&& (!YES_STRING
.equalsIgnoreCase(((nsIDOMElement) node
.queryInterface(nsIDOMElement.NS_IDOMELEMENT_IID))
.getAttribute(ATTR_VPE)))) {
- node = headNode.removeChild(node);
+ node = getHeadNode().removeChild(node);
}
}
}
@@ -1571,7 +1519,7 @@
}
if (sourceDropContainer == null) {
sourceDropContainer = domMapping
- .getNearSourceNode(visualContentArea);
+ .getNearSourceNode(getContentArea());
sourceDropOffset = sourceDropContainer.getChildNodes()
.getLength();
}
@@ -2135,7 +2083,7 @@
clearIncludeDocuments();
includeDocuments = null;
cleanHead();
- domMapping.clear(visualContentArea);
+ domMapping.clear(getContentArea());
pageContext.dispose();
super.dispose();
}
@@ -2355,4 +2303,8 @@
public Map<IFile, Document> getIncludeDocuments() {
return includeDocuments;
}
+
+ public nsIDOMNode getHeadNode() {
+ return visualEditor.getHeadNode();
+ }
}
Modified: branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java
===================================================================
--- branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2008-06-18 15:22:26 UTC (rev 8829)
+++ branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaEditor.java 2008-06-18 18:07:40 UTC (rev 8830)
@@ -56,6 +56,7 @@
import org.jboss.tools.vpe.editor.toolbar.VpeToolBarManager;
import org.jboss.tools.vpe.editor.toolbar.format.FormatControllerManager;
import org.jboss.tools.vpe.editor.toolbar.format.TextFormattingToolBar;
+import org.jboss.tools.vpe.editor.util.DocTypeUtil;
import org.jboss.tools.vpe.editor.util.HTML;
import org.jboss.tools.vpe.messages.VpeUIMessages;
import org.jboss.tools.vpe.xulrunner.editor.XulRunnerEditor;
@@ -67,7 +68,7 @@
import org.mozilla.interfaces.nsIDOMNodeList;
public class MozillaEditor extends EditorPart implements IReusableEditor {
- protected static final String INIT_URL = "file://" + (new File(VpePlugin.getDefault().getResourcePath("ve"), "init.html")).getAbsolutePath(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ protected static final String INIT_URL = /*"file://" +*/ (new File(VpePlugin.getDefault().getResourcePath("ve"), "init.html")).getAbsolutePath(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
// private static final String INIT_URL = "chrome://vpe/content/init.html"; //$NON-NLS-1$
private static final String CONTENT_AREA_ID = "__content__area__"; //$NON-NLS-1$
@@ -86,7 +87,9 @@
private FormatControllerManager formatControllerManager = new FormatControllerManager();
private VpeController controller;
private Link link = null;
- private boolean loaded;
+ private boolean loaded;
+ private boolean loadPage;
+ private String doctype;
public void doSave(IProgressMonitor monitor) {
}
@@ -212,10 +215,20 @@
cmpEd.setBackground(buttonDarker);
try {
+ loadPage = true;
xulRunnerEditor = new XulRunnerEditor(cmpEd) {
public void onLoadWindow() {
- super.onLoadWindow();
- MozillaEditor.this.onLoadWindow();
+ // if the first load page
+ if (loadPage) {
+ super.onLoadWindow();
+ MozillaEditor.this.onLoadWindow();
+ loadPage = false;
+ }
+ // if only refresh page
+ else {
+ MozillaEditor.this.onReloadWindow();
+ }
+
}
public void onElementResize(nsIDOMElement element, int resizerConstrains, int top, int left, int width, int height) {
if (editorDomEventListener != null) {
@@ -249,7 +262,10 @@
}
});
- xulRunnerEditor.setURL(INIT_URL);
+
+ doctype = DocTypeUtil.getDoctype(getEditorInput());
+ xulRunnerEditor.setText(doctype
+ + DocTypeUtil.getContentInitFile(new File(INIT_URL)));
// Wait while visual part is loaded
while (!loaded) {
if (!Display.getCurrent().readAndDispatch())
@@ -539,7 +555,7 @@
public void setSelectionRectangle(nsIDOMElement element, int resizerConstrains, boolean scroll) {
if (getContentAreaEventListener() != null) {
- xulRunnerEditor.setSelectionRectangle((nsIDOMElement)element, resizerConstrains, scroll);
+ xulRunnerEditor.setSelectionRectangle(element, resizerConstrains, scroll);
}
}
@@ -629,6 +645,36 @@
this.contentAreaEventListener = contentAreaEventListener;
}
+
+
+ /**
+ *
+ */
+ private void onReloadWindow() {
+ removeDomEventListeners();
+ contentArea = findContentArea();
+ addDomEventListeners();
+ controller.reinit();
+
+ }
+ /**
+ *
+ */
+ public void reload() {
+
+ doctype = DocTypeUtil.getDoctype(getEditorInput());
+ xulRunnerEditor.setText(doctype
+ + DocTypeUtil.getContentInitFile(new File(INIT_URL)));
+
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getDoctype() {
+ return doctype;
+ }
}
\ No newline at end of file
Modified: branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java
===================================================================
--- branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java 2008-06-18 15:22:26 UTC (rev 8829)
+++ branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/mozilla/MozillaPreview.java 2008-06-18 18:07:40 UTC (rev 8830)
@@ -36,6 +36,7 @@
import org.jboss.tools.vpe.editor.context.VpePageContext;
import org.jboss.tools.vpe.editor.mapping.VpeDomMapping;
import org.jboss.tools.vpe.editor.template.VpeTemplateManager;
+import org.jboss.tools.vpe.editor.util.DocTypeUtil;
import org.jboss.tools.vpe.messages.VpeUIMessages;
import org.jboss.tools.vpe.xulrunner.editor.XulRunnerEditor;
@@ -89,7 +90,9 @@
super.onDispose();
}
});
- getXulRunnerEditor().setURL(INIT_URL);
+// getXulRunnerEditor().setURL(INIT_URL);
+ getXulRunnerEditor().setText(DocTypeUtil.prepareInitFile(INIT_URL,
+ getEditorInput()));
getXulRunnerEditor().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
} catch (Exception e) {
Label title = new Label(parent, SWT.WRAP);
Added: branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/DocTypeUtil.java
===================================================================
--- branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/DocTypeUtil.java (rev 0)
+++ branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/DocTypeUtil.java 2008-06-18 18:07:40 UTC (rev 8830)
@@ -0,0 +1,353 @@
+package org.jboss.tools.vpe.editor.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.core.filebuffers.ITextFileBuffer;
+import org.eclipse.core.filebuffers.ITextFileBufferManager;
+import org.eclipse.core.filebuffers.LocationKind;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.editors.text.ILocationProvider;
+import org.eclipse.wst.sse.core.StructuredModelManager;
+import org.eclipse.wst.sse.core.internal.FileBufferModelManager;
+import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocumentType;
+import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+public class DocTypeUtil {
+
+ static private List<String> urlTags;
+
+ static {
+ urlTags = new ArrayList<String>();
+ urlTags.add("link"); //$NON-NLS-1$
+ }
+
+ static private List<String> urlAttributes;
+
+ static {
+ urlAttributes = new ArrayList<String>();
+ urlAttributes.add("href"); //$NON-NLS-1$
+ }
+
+ /**
+ * get doctype by {@link IEditorInput}
+ *
+ * @param editorInput
+ * @return
+ */
+ static public String getDoctype(IEditorInput editorInput) {
+
+ // if opened file is located in eclipse workspace
+ if (editorInput instanceof IFileEditorInput) {
+ IFile f = ((IFileEditorInput) editorInput).getFile();
+ return (f == null || !f.exists()) ? null : getDoctype(f);
+ }
+ // if opened file is not located in eclipse workspace
+ else if (editorInput instanceof ILocationProvider) {
+ IPath path = ((ILocationProvider) editorInput).getPath(editorInput);
+ if (path == null || path.segmentCount() < 1)
+ return null;
+ return getDoctype(path.toFile());
+ }
+ return null;
+
+ }
+
+ /**
+ * get doctype by {@link IFile}
+ *
+ * @param file
+ * @return
+ */
+ static public String getDoctype(IFile file) {
+
+ String docTypeValue = null;
+
+ // get document
+ IDOMDocument document = getDocument(file);
+
+ if (document != null) {
+
+ /*
+ * if there is "component" element (ui:composition or ui:component )
+ * so we don't use doctype from current page (as all text outside
+ * this elements will be removed)
+ */
+
+ // find "component" element
+ Element componentElement = FaceletUtil
+ .findComponentElement(document.getDocumentElement());
+
+ // if "component" element was not found return doctype from current
+ // page
+ if (componentElement == null) {
+
+ IDOMDocumentType documentType = (IDOMDocumentType) document
+ .getDoctype();
+
+ if (documentType != null)
+ docTypeValue = documentType.getSource();
+
+ }
+
+ // if "component" element was not found return doctype from current
+ // page
+ else if ((componentElement != null)
+ && (FaceletUtil.TAG_COMPOSITION.equals(componentElement
+ .getLocalName()))
+ && (componentElement
+ .hasAttribute(FaceletUtil.ATTR_TEMPLATE))) {
+
+ // get attribute "template"
+ Attr attr = ((Element) componentElement)
+ .getAttributeNode(FaceletUtil.ATTR_TEMPLATE);
+
+ if (attr.getNodeValue().trim().length() > 0) {
+
+ // get name of template file
+ String fileName = attr.getNodeValue().trim();
+
+ // get file
+ IFile templateFile = FileUtil.getFile(fileName, file);
+
+ if (templateFile != null)
+ docTypeValue = getDoctype(templateFile);
+
+ }
+
+ }
+ }
+ return docTypeValue != null ? docTypeValue.trim() : ""; //$NON-NLS-1$
+ }
+
+ /**
+ * get doctype by {@link File}
+ *
+ * @param file
+ * @return
+ */
+ static public String getDoctype(File file) {
+
+ String docTypeValue = null;
+
+ // get document
+ IDOMDocument document = getDocument(file);
+
+ if (document != null) {
+
+ /*
+ * if there is "component" element (ui:composition or ui:component )
+ * so we don't use doctype from current page (as all text outside
+ * this elements will be removed)
+ */
+
+ // find "component" element
+ Element componentElement = FaceletUtil
+ .findComponentElement(document.getDocumentElement());
+
+ // if "component" element was not found return doctype from current
+ // page
+ if (componentElement == null) {
+
+ IDOMDocumentType documentType = (IDOMDocumentType) document
+ .getDoctype();
+
+ if (documentType != null)
+ docTypeValue = documentType.getSource();
+
+ }
+
+ // if "component" element was not found return doctype from current
+ // page
+ else if ((componentElement != null)
+ && (FaceletUtil.TAG_COMPOSITION.equals(componentElement
+ .getLocalName()))
+ && (componentElement
+ .hasAttribute(FaceletUtil.ATTR_TEMPLATE))) {
+
+ // get attribute "template"
+ Attr attr = ((Element) componentElement)
+ .getAttributeNode(FaceletUtil.ATTR_TEMPLATE);
+
+ if (attr.getNodeValue().trim().length() > 0) {
+
+ // get name of template file
+ String fileName = attr.getNodeValue().trim();
+
+ // get file
+ File templateFile = new File(file.getParent(), fileName);
+
+ if (templateFile.exists())
+ docTypeValue = getDoctype(templateFile);
+
+ }
+
+ }
+ }
+ return docTypeValue != null ? docTypeValue.trim() : ""; //$NON-NLS-1$
+
+ }
+
+ /**
+ * get document by {@link IFile}
+ *
+ * @param file
+ * @return
+ */
+ static private IDOMDocument getDocument(IFile file) {
+
+ IDOMDocument document = null;
+
+ if (file != null) {
+ try {
+
+ // get model
+ IDOMModel model = (IDOMModel) StructuredModelManager
+ .getModelManager().getModelForRead(file);
+
+ if (model != null)
+ document = model.getDocument();
+
+ } catch (IOException e) {
+ e.printStackTrace();
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+
+ return document;
+ }
+
+ /**
+ * get document by {@link File}
+ *
+ * @param file
+ * @return
+ */
+ static private IDOMDocument getDocument(File file) {
+
+ // if (file.exists()) {
+ //
+ // String content = org.jboss.tools.common.util.FileUtil
+ // .readFile(file);
+ //
+ // IStructuredDocument newStructuredDocument = StructuredDocumentFactory
+ // .getNewStructuredDocumentInstance(new JSPSourceParser());
+ //
+ // newStructuredDocument.set(content);
+ //
+ // IDOMModel modelForJSP = new DOMModelForJSP();
+ // modelForJSP.setStructuredDocument(newStructuredDocument);
+ //
+ // return modelForJSP.getDocument();
+ //
+ // }
+ // return null;
+
+ IDOMModel model = null;
+
+ ITextFileBufferManager bufferManager = FileBuffers
+ .getTextFileBufferManager();
+ IPath location = new Path(file.getAbsolutePath());
+
+ try {
+ bufferManager.connect(location, LocationKind.LOCATION,
+ new NullProgressMonitor());
+
+ ITextFileBuffer buffer = bufferManager.getTextFileBuffer(location,
+ LocationKind.LOCATION);
+ if (buffer != null) {
+
+ IDocument bufferDocument = buffer.getDocument();
+ if (bufferDocument instanceof IStructuredDocument) {
+ model = (IDOMModel) FileBufferModelManager.getInstance()
+ .getModel((IStructuredDocument) bufferDocument);
+ } else {
+
+ bufferManager.disconnect(location, LocationKind.IFILE,
+ new NullProgressMonitor());
+ }
+ }
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+
+ return model.getDocument();
+ }
+
+ /**
+ * get
+ *
+ * @param initFilePath
+ * @param editorInput
+ * @return
+ */
+ public static String prepareInitFile(String initFilePath,
+ IEditorInput editorInput) {
+
+ return getDoctype(editorInput)
+ + getContentInitFile(new File(initFilePath));
+
+ }
+
+ /**
+ * get content of initFile, corrected paths on a page
+ *
+ * @param initFile
+ * @return
+ */
+ public static String getContentInitFile(File initFile) {
+
+ IDOMDocument document = getDocument(initFile);
+
+ if (document != null) {
+ // for each tag's name
+ for (String tag : urlTags) {
+
+ NodeList list = document.getElementsByTagName(tag);
+
+ for (int i = 0; i < list.getLength(); i++) {
+
+ Element element = (Element) list.item(i);
+
+ // for each attribute's name
+ for (String attributeName : urlAttributes) {
+
+ if (element.hasAttribute(attributeName)) {
+
+ Attr attr = element.getAttributeNode(attributeName);
+
+ // corrected path
+ attr.setValue(initFile.getParent() + File.separator
+ + attr.getValue());
+
+ }
+
+ }
+
+ }
+
+ }
+
+ return (document).getSource();
+ }
+
+ return ""; //$NON-NLS-1$
+
+ }
+}
Added: branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/FaceletUtil.java
===================================================================
--- branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/FaceletUtil.java (rev 0)
+++ branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/FaceletUtil.java 2008-06-18 18:07:40 UTC (rev 8830)
@@ -0,0 +1,73 @@
+package org.jboss.tools.vpe.editor.util;
+
+import java.util.HashSet;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+public class FaceletUtil {
+
+ public static final String TAG_COMPOSITION = "composition"; //$NON-NLS-1$
+ public static final String TAG_COMPONENT = "component"; //$NON-NLS-1$
+
+ public static final String ATTR_TEMPLATE = "template"; //$NON-NLS-1$
+
+ /**
+ * facelet elements, if there are these elements on a page then other
+ * elements are deleted
+ */
+ static public HashSet<String> componentElements = new HashSet<String>();
+
+ static {
+ componentElements.add(TAG_COMPOSITION);
+ componentElements.add(TAG_COMPONENT);
+ }
+
+ /**
+ *
+ * @param root
+ * @return
+ */
+ public static Element findComponentElement(Element root) {
+
+ if(root==null) {
+
+ return null;
+ }
+ NodeList children = root.getChildNodes();
+
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE) {
+
+ Element trimmedElement = findComponentElement((Element) child);
+ if (trimmedElement != null)
+ return trimmedElement;
+
+ }
+ }
+
+ if (componentElements.contains(root.getLocalName()))
+ return root;
+
+ return null;
+ }
+
+ /**
+ *
+ * @param document
+ * @return
+ */
+ public static Element getRootFaceletElement(Document document) {
+
+ Element root = document.getDocumentElement();
+
+ Element component = findComponentElement(root);
+
+ return component != null ? component : root;
+
+ }
+
+}
Modified: branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java
===================================================================
--- branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java 2008-06-18 15:22:26 UTC (rev 8829)
+++ branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/util/HTML.java 2008-06-18 18:07:40 UTC (rev 8830)
@@ -84,10 +84,16 @@
public static final String ATTR_ROWS = "rows"; //$NON-NLS-1$
public static final String ATTR_COLS = "cols"; //$NON-NLS-1$
public static final String ATTR_VALIGN = "valign"; //$NON-NLS-1$
+ public static final String ATTR_SRC = "src"; //$NON-NLS-1$
+ public static final String ATTR_ALT = "alt"; //$NON-NLS-1$
public static final String VALUE_TOP_ALIGN = "top"; //$NON-NLS-1$
public static final String VALUE_MIDDLE_ALIGN = "middle"; //$NON-NLS-1$
public static final String VALUE_TEXT_TYPE = "text"; //$NON-NLS-1$
+ public static final String VALUE_PASSWORD_TYPE = "password"; //$NON-NLS-1$
public static final String VALUE_IMAGE_TYPE = "image"; //$NON-NLS-1$
-
+ public static final String VALUE_RADIOBUTTON_TYPE = "radiobutton"; //$NON-NLS-1$
+ public static final String VALUE_CHECKBOX_TYPE = "checkbox"; //$NON-NLS-1$
+ public static final String VALUE_HIDDEN_TYPE = "hidden"; //$NON-NLS-1$
+ public static final String VALUE_BUTTON_TYPE = "button"; //$NON-NLS-1$
}
\ No newline at end of file
Modified: branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/ve/init.html
===================================================================
--- branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/ve/init.html 2008-06-18 15:22:26 UTC (rev 8829)
+++ branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe/ve/init.html 2008-06-18 18:07:40 UTC (rev 8830)
@@ -2,11 +2,740 @@
<head>
<title>Test Page</title>
- <script src="mozileLoader.js" type="text/javascript"></script>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
+
+ <style type="text/css" vpe="yes">
+a:link {
+ cursor: text;
+}
+
+/* Use default arrow over objects with size that
+ are selected when clicked on.
+ Override the browser's pointer cursor over links
+*/
+img,img[usemap],area,object,object[usemap],applet,hr,button,input,isindex,textarea,select,a:link img,a:visited img,a:active img,a[name]:empty
+ {
+ cursor: default;
+}
+
+a:visited,a:active {
+ cursor: text; //
+ color: inherit;
+}
+
+a:link img,a:visited img {
+ -moz-user-input: none;
+}
+
+a /*:link*/ {
+ text-decoration: underline -moz-anchor-decoration;
+ color: -moz-hyperlinktext;
+}
+
+input,button,textarea {
+ -moz-user-select: all !important;
+ -moz-user-input: auto !important;
+ -moz-user-focus: none !important;
+}
+
+select,input[disabled],input[type="checkbox"],input[type="radio"],input[type="file"]
+ {
+ -moz-user-select: all !important;
+ -moz-user-input: auto !important;
+ -moz-user-focus: none !important;
+}
+
+isindex[prompt] {
+ -moz-user-select: none !important;
+ -moz-user-input: none !important;
+ -moz-user-focus: none !important;
+}
+
+input[type="hidden"] {
+ border: 1px solid black !important;
+ visibility: visible !important;
+}
+
+/*
+label {
+ -moz-user-select: all !important;
+}
+*/
+:
+:-moz-display-comboboxcontrol-frame {
+ -moz-user-select: text !important;
+}
+
+.def-link {
+ text-decoration: underline -moz-anchor-decoration;
+ color: -moz-hyperlinktext;
+}
+
+option {
+ -moz-user-select: text !important;
+}
+
+#mozToc.readonly {
+ -moz-user-select: all !important;
+ -moz-user-input: none !important;
+}
+
+span[\_moz_anonclass="mozResizer"] {
+ width: 5px;
+ height: 5px;
+ position: absolute;
+ border: 1px black solid;
+ background-color: white;
+ -moz-user-select: none;
+ z-index: 2147483646;
+}
+
+span[\_moz_anonclass="mozResizer"][\_moz_activated],span[\_moz_anonclass="mozResizer"]:hover
+ {
+ background-color: black;
+}
+
+span[\_moz_anonclass="mozResizer"].hidden,span[\_moz_anonclass="mozResizingShadow"].hidden,img[\_moz_anonclass="mozResizingShadow"].hidden,span[\_moz_anonclass="mozGrabber"].hidden,span[\_moz_anonclass="mozResizingInfo"].hidden,a[\_moz_anonclass="mozTableRemoveRow"].hidden,a[\_moz_anonclass="mozTableRemoveColumn"].hidden
+ {
+ display: none !important;
+}
+
+span[\_moz_anonclass="mozResizer"][anonlocation="nw"] {
+ cursor: nw-resize;
+}
+
+span[\_moz_anonclass="mozResizer"][anonlocation="n"] {
+ cursor: n-resize;
+}
+
+span[\_moz_anonclass="mozResizer"][anonlocation="ne"] {
+ cursor: ne-resize;
+}
+
+span[\_moz_anonclass="mozResizer"][anonlocation="w"] {
+ cursor: w-resize;
+}
+
+span[\_moz_anonclass="mozResizer"][anonlocation="e"] {
+ cursor: e-resize;
+}
+
+span[\_moz_anonclass="mozResizer"][anonlocation="sw"] {
+ cursor: sw-resize;
+}
+
+span[\_moz_anonclass="mozResizer"][anonlocation="s"] {
+ cursor: s-resize;
+}
+
+span[\_moz_anonclass="mozResizer"][anonlocation="se"] {
+ cursor: se-resize;
+}
+
+span[\_moz_anonclass="mozResizingShadow"],img[\_moz_anonclass="mozResizingShadow"]
+ {
+ -moz-outline: thin dashed black;
+ -moz-user-select: none;
+ -moz-opacity: 0.5;
+ position: absolute;
+ z-index: 2147483647;
+}
+
+span[\_moz_anonclass="mozResizingInfo"] {
+ font-family: sans-serif;
+ font-size: x-small;
+ color: black;
+ background-color: #d0d0d0;
+ border: ridge 2px #d0d0d0;
+ padding: 2px;
+ position: absolute;
+ z-index: 2147483647;
+}
+
+*[\_moz_abspos] {
+ -moz-outline: silver ridge 2px;
+ z-index: 2147483645 !important;
+}
+
+*[\_moz_abspos="white"] {
+ background-color: white !important;
+}
+
+*[\_moz_abspos="black"] {
+ background-color: black !important;
+}
+
+span[\_moz_anonclass="mozGrabber"] {
+ -moz-outline: ridge 2px silver;
+ padding: 2px;
+ position: absolute;
+ width: 12px;
+ height: 12px;
+ background-image: url("resource:/res/grabber.gif");
+ background-repeat: no-repeat;
+ background-position: center center;
+ -moz-user-select: none;
+ cursor: move;
+}
+
+a[\_moz_anonclass="mozTableAddColumnBefore"] {
+ position: absolute;
+ z-index: 2147483647;
+ text-decoration: none !important;
+ border: none 0px !important;
+ width: 4px;
+ height: 8px;
+ background-image: url("resource:/res/table-add-column-before.gif");
+ background-repeat: no-repeat;
+ background-position: center center;
+ -moz-user-select: none !important;
+ -moz-user-focus: none !important;
+}
+
+a[\_moz_anonclass="mozTableAddColumnBefore"]:hover {
+ background-image: url("resource:/res/table-add-column-before-hover.gif")
+ ;
+}
+
+a[\_moz_anonclass="mozTableAddColumnBefore"]:active {
+ background-image:
+ url("resource:/res/table-add-column-before-active.gif");
+}
+
+a[\_moz_anonclass="mozTableAddColumnAfter"] {
+ position: absolute;
+ z-index: 2147483647;
+ text-decoration: none !important;
+ border: none 0px !important;
+ width: 4px;
+ height: 8px;
+ background-image: url("resource:/res/table-add-column-after.gif");
+ background-repeat: no-repeat;
+ background-position: center center;
+ -moz-user-select: none !important;
+ -moz-user-focus: none !important;
+}
+
+a[\_moz_anonclass="mozTableAddColumnAfter"]:hover {
+ background-image: url("resource:/res/table-add-column-after-hover.gif");
+}
+
+a[\_moz_anonclass="mozTableAddColumnAfter"]:active {
+ background-image: url("resource:/res/table-add-column-after-active.gif")
+ ;
+}
+
+a[\_moz_anonclass="mozTableRemoveColumn"] {
+ position: absolute;
+ z-index: 2147483647;
+ text-decoration: none !important;
+ border: none 0px !important;
+ width: 8px;
+ height: 8px;
+ background-image: url("resource:/res/table-remove-column.gif");
+ background-repeat: no-repeat;
+ background-position: center center;
+ -moz-user-select: none !important;
+ -moz-user-focus: none !important;
+}
+
+a[\_moz_anonclass="mozTableRemoveColumn"]:hover {
+ background-image: url("resource:/res/table-remove-column-hover.gif");
+}
+
+a[\_moz_anonclass="mozTableRemoveColumn"]:active {
+ background-image: url("resource:/res/table-remove-column-active.gif");
+}
+
+a[\_moz_anonclass="mozTableAddRowBefore"] { /*
+ * The contents of this file are subject to the Netscape Public
+ * License Version 1.1 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.mozilla.org/NPL/
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * The Original Code is Mozilla Communicator client code, released
+ * March 31, 1998.
+ *
+ * The Initial Developer of the Original Code is Netscape
+ * Communications Corporation. Portions created by Netscape are
+ * Copyright (C) 1998-1999 Netscape Communications Corporation. All
+ * Rights Reserved.
+ *
+ * Contributor(s):
+ */ /* Styles to alter look of things in the Editor content window
+ * that should NOT be removed when we display in completely WYSIWYG
+ * "Browser Preview" mode.
+ * Anything that should change, like appearance of table borders
+ * and Named Anchors, should be placed in EditorContent.css instead of here.
+*/ /* Primary cursor is text I-beam */
+ a: link {
+ cursor : text;
+}
+
+/* Use default arrow over objects with size that
+ are selected when clicked on.
+ Override the browser's pointer cursor over links
+*/
+img,img[usemap],area,object,object[usemap],applet,hr,button,input,isindex,textarea,select,a:link img,a:visited img,a:active img,a[name]:empty
+ {
+ cursor: default;
+}
+
+a:visited,a:active {
+ cursor: text; //
+ color: inherit;
+}
+
+a:link img,a:visited img {
+ -moz-user-input: none;
+}
+
+a /*:link*/ {
+ text-decoration: underline -moz-anchor-decoration;
+ color: -moz-hyperlinktext;
+}
+
+input,button,textarea {
+ -moz-user-select: all !important;
+ -moz-user-input: auto !important;
+ -moz-user-focus: none !important;
+}
+
+select,input[disabled],input[type="checkbox"],input[type="radio"],input[type="file"]
+ {
+ -moz-user-select: all !important;
+ -moz-user-input: auto !important;
+ -moz-user-focus: none !important;
+}
+
+isindex[prompt] {
+ -moz-user-select: none !important;
+ -moz-user-input: none !important;
+ -moz-user-focus: none !important;
+}
+
+input[type="hidden"] {
+ border: 1px solid black !important;
+ visibility: visible !important;
+}
+
+/*
+label {
+ -moz-user-select: all !important;
+}
+*/
+:
+:-moz-display-comboboxcontrol-frame {
+ -moz-user-select: text !important;
+}
+
+.def-link {
+ text-decoration: underline -moz-anchor-decoration;
+ color: -moz-hyperlinktext;
+}
+
+option {
+ -moz-user-select: text !important;
+}
+
+#mozToc.readonly {
+ -moz-user-select: all !important;
+ -moz-user-input: none !important;
+}
+
+span[\_moz_anonclass="mozResizer"] {
+ width: 5px;
+ height: 5px;
+ position: absolute;
+ border: 1px black solid;
+ background-color: white;
+ -moz-user-select: none;
+ z-index: 2147483646;
+}
+
+span[\_moz_anonclass="mozResizer"][\_moz_activated],span[\_moz_anonclass="mozResizer"]:hover
+ {
+ background-color: black;
+}
+
+span[\_moz_anonclass="mozResizer"].hidden,span[\_moz_anonclass="mozResizingShadow"].hidden,img[\_moz_anonclass="mozResizingShadow"].hidden,span[\_moz_anonclass="mozGrabber"].hidden,span[\_moz_anonclass="mozResizingInfo"].hidden,a[\_moz_anonclass="mozTableRemoveRow"].hidden,a[\_moz_anonclass="mozTableRemoveColumn"].hidden
+ {
+ display: none !important;
+}
+
+span[\_moz_anonclass="mozResizer"][anonlocation="nw"] {
+ cursor: nw-resize;
+}
+
+span[\_moz_anonclass="mozResizer"][anonlocation="n"] {
+ cursor: n-resize;
+}
+
+span[\_moz_anonclass="mozResizer"][anonlocation="ne"] {
+ cursor: ne-resize;
+}
+
+span[\_moz_anonclass="mozResizer"][anonlocation="w"] {
+ cursor: w-resize;
+}
+
+span[\_moz_anonclass="mozResizer"][anonlocation="e"] {
+ cursor: e-resize;
+}
+
+span[\_moz_anonclass="mozResizer"][anonlocation="sw"] {
+ cursor: sw-resize;
+}
+
+span[\_moz_anonclass="mozResizer"][anonlocation="s"] {
+ cursor: s-resize;
+}
+
+span[\_moz_anonclass="mozResizer"][anonlocation="se"] {
+ cursor: se-resize;
+}
+
+span[\_moz_anonclass="mozResizingShadow"],img[\_moz_anonclass="mozResizingShadow"]
+ {
+ -moz-outline: thin dashed black;
+ -moz-user-select: none;
+ -moz-opacity: 0.5;
+ position: absolute;
+ z-index: 2147483647;
+}
+
+span[\_moz_anonclass="mozResizingInfo"] {
+ font-family: sans-serif;
+ font-size: x-small;
+ color: black;
+ background-color: #d0d0d0;
+ border: ridge 2px #d0d0d0;
+ padding: 2px;
+ position: absolute;
+ z-index: 2147483647;
+}
+
+*[\_moz_abspos] {
+ -moz-outline: silver ridge 2px;
+ z-index: 2147483645 !important;
+}
+
+*[\_moz_abspos="white"] {
+ background-color: white !important;
+}
+
+*[\_moz_abspos="black"] {
+ background-color: black !important;
+}
+
+span[\_moz_anonclass="mozGrabber"] {
+ -moz-outline: ridge 2px silver;
+ padding: 2px;
+ position: absolute;
+ width: 12px;
+ height: 12px;
+ background-image: url("resource:/res/grabber.gif");
+ background-repeat: no-repeat;
+ background-position: center center;
+ -moz-user-select: none;
+ cursor: move;
+}
+
+a[\_moz_anonclass="mozTableAddColumnBefore"] {
+ position: absolute;
+ z-index: 2147483647;
+ text-decoration: none !important;
+ border: none 0px !important;
+ width: 4px;
+ height: 8px;
+ background-image: url("resource:/res/table-add-column-before.gif");
+ background-repeat: no-repeat;
+ background-position: center center;
+ -moz-user-select: none !important;
+ -moz-user-focus: none !important;
+}
+
+a[\_moz_anonclass="mozTableAddColumnBefore"]:hover {
+ background-image: url("resource:/res/table-add-column-before-hover.gif")
+ ;
+}
+
+a[\_moz_anonclass="mozTableAddColumnBefore"]:active {
+ background-image:
+ url("resource:/res/table-add-column-before-active.gif");
+}
+
+a[\_moz_anonclass="mozTableAddColumnAfter"] {
+ position: absolute;
+ z-index: 2147483647;
+ text-decoration: none !important;
+ border: none 0px !important;
+ width: 4px;
+ height: 8px;
+ background-image: url("resource:/res/table-add-column-after.gif");
+ background-repeat: no-repeat;
+ background-position: center center;
+ -moz-user-select: none !important;
+ -moz-user-focus: none !important;
+}
+
+a[\_moz_anonclass="mozTableAddColumnAfter"]:hover {
+ background-image: url("resource:/res/table-add-column-after-hover.gif");
+}
+
+a[\_moz_anonclass="mozTableAddColumnAfter"]:active {
+ background-image: url("resource:/res/table-add-column-after-active.gif")
+ ;
+}
+
+a[\_moz_anonclass="mozTableRemoveColumn"] {
+ position: absolute;
+ z-index: 2147483647;
+ text-decoration: none !important;
+ border: none 0px !important;
+ width: 8px;
+ height: 8px;
+ background-image: url("resource:/res/table-remove-column.gif");
+ background-repeat: no-repeat;
+ background-position: center center;
+ -moz-user-select: none !important;
+ -moz-user-focus: none !important;
+}
+
+a[\_moz_anonclass="mozTableRemoveColumn"]:hover {
+ background-image: url("resource:/res/table-remove-column-hover.gif");
+}
+
+a[\_moz_anonclass="mozTableRemoveColumn"]:active {
+ background-image: url("resource:/res/table-remove-column-active.gif");
+}
+
+a[\_moz_anonclass="mozTableAddRowBefore"] {
+ position: absolute;
+ z-index: 2147483647;
+ text-decoration: none !important;
+ border: none 0px !important;
+ width: 8px;
+ height: 4px;
+ background-image: url("resource:/res/table-add-row-before.gif");
+ background-repeat: no-repeat;
+ background-position: center center;
+ -moz-user-select: none !important;
+ -moz-user-focus: none !important;
+}
+
+a[\_moz_anonclass="mozTableAddRowBefore"]:hover {
+ background-image: url("resource:/res/table-add-row-before-hover.gif");
+}
+
+a[\_moz_anonclass="mozTableAddRowBefore"]:active {
+ background-image: url("resource:/res/table-add-row-before-active.gif");
+}
+
+a[\_moz_anonclass="mozTableAddRowAfter"] {
+ position: absolute;
+ z-index: 2147483647;
+ text-decoration: none !important;
+ border: none 0px !important;
+ width: 8px;
+ height: 4px;
+ background-image: url("resource:/res/table-add-row-after.gif");
+ background-repeat: no-repeat;
+ background-position: center center;
+ -moz-user-select: none !important;
+ -moz-user-focus: none !important;
+}
+
+a[\_moz_anonclass="mozTableAddRowAfter"]:hover {
+ background-image: url("resource:/res/table-add-row-after-hover.gif");
+}
+
+a[\_moz_anonclass="mozTableAddRowAfter"]:active {
+ background-image: url("resource:/res/table-add-row-after-active.gif");
+}
+
+a[\_moz_anonclass="mozTableRemoveRow"] {
+ position: absolute;
+ z-index: 2147483647;
+ text-decoration: none !important;
+ border: none 0px !important;
+ width: 8px;
+ height: 8px;
+ background-image: url("resource:/res/table-remove-row.gif");
+ background-repeat: no-repeat;
+ background-position: center center;
+ -moz-user-select: none !important;
+ -moz-user-focus: none !important;
+}
+
+a[\_moz_anonclass="mozTableRemoveRow"]:hover {
+ background-image: url("resource:/res/table-remove-row-hover.gif");
+}
+
+a[\_moz_anonclass="mozTableRemoveRow"]:active {
+ background-image: url("resource:/res/table-remove-row-active.gif");
+}
+
+span {
+ color: red;
+}
+
+position
+:
+
+absolute
+;
+
+
+z-index
+:
+
+2147483647;
+text-decoration
+:
+
+none
+
+!
+important
+;
+
+
+border
+:
+
+none
+
+0
+px
+
+!
+important
+;
+
+
+width
+:
+
+8
+px
+;
+
+
+height
+:
+
+4
+px
+;
+
+
+background-image
+:
+
+url
+("resource:/res/table-add-row-before
+.gif
+");
+
+
+background-repeat
+:
+
+no-repeat
+;
+
+
+background-position
+:
+
+center
+
+center
+;
+
+
+-moz-user-select
+:
+
+none
+
+!
+important
+;
+
+
+-moz-user-focus
+:
+
+none
+
+!
+important
+;
+
+
+}
+a[\_moz_anonclass="mozTableAddRowBefore"]:hover {
+ background-image: url("resource:/res/table-add-row-before-hover.gif");
+}
+
+a[\_moz_anonclass="mozTableAddRowBefore"]:active {
+ background-image: url("resource:/res/table-add-row-before-active.gif");
+}
+
+a[\_moz_anonclass="mozTableAddRowAfter"] {
+ position: absolute;
+ z-index: 2147483647;
+ text-decoration: none !important;
+ border: none 0px !important;
+ width: 8px;
+ height: 4px;
+ background-image: url("resource:/res/table-add-row-after.gif");
+ background-repeat: no-repeat;
+ background-position: center center;
+ -moz-user-select: none !important;
+ -moz-user-focus: none !important;
+}
+
+a[\_moz_anonclass="mozTableAddRowAfter"]:hover {
+ background-image: url("resource:/res/table-add-row-after-hover.gif");
+}
+
+a[\_moz_anonclass="mozTableAddRowAfter"]:active {
+ background-image: url("resource:/res/table-add-row-after-active.gif");
+}
+
+a[\_moz_anonclass="mozTableRemoveRow"] {
+ position: absolute;
+ z-index: 2147483647;
+ text-decoration: none !important;
+ border: none 0px !important;
+ width: 8px;
+ height: 8px;
+ background-image: url("resource:/res/table-remove-row.gif");
+ background-repeat: no-repeat;
+ background-position: center center;
+ -moz-user-select: none !imporTetstant;
+ -moz-user-focus: none !important;
+}
+
+a[\_moz_anonclass="mozTableRemoveRow"]:hover {
+ background-image: url("resource:/res/table-remove-row-hover.gif");
+}
+
+a[\_moz_anonclass="mozTableRemoveRow"]:active {
+ background-image: url("resource:/res/table-remove-row-active.gif");
+}
+</style>
+
- <link href="EditorOverride.css" rel="stylesheet" type="text/css">
-
<style type="text/css" vpe="yes">
<!--
.__any__tag__block {
Modified: branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlBodyTemplate.java
===================================================================
--- branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlBodyTemplate.java 2008-06-18 15:22:26 UTC (rev 8829)
+++ branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe.html/src/org/jboss/tools/vpe/html/template/HtmlBodyTemplate.java 2008-06-18 18:07:40 UTC (rev 8830)
@@ -40,7 +40,7 @@
public VpeCreationData create(VpePageContext pageContext, Node sourceNode,
nsIDOMDocument visualDocument) {
- goToTree(visualDocument.getChildNodes().item(0));
+ goToTree(visualDocument.getDocumentElement());
nsIDOMNamedNodeMap attrsMap = bodyOld.getAttributes();
long len = attrsMap.getLength();
Modified: branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/XulRunnerBrowser.java
===================================================================
--- branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/XulRunnerBrowser.java 2008-06-18 15:22:26 UTC (rev 8829)
+++ branches/jbosstools-2.1.x/vpe/plugins/org.jboss.tools.vpe.xulrunner/src/org/jboss/tools/vpe/xulrunner/browser/XulRunnerBrowser.java 2008-06-18 18:07:40 UTC (rev 8830)
@@ -434,4 +434,8 @@
protected void onDispose() {
}
+
+ public void setText(String html) {
+ browser.setText(html);
+ }
}
17 years, 10 months
JBoss Tools SVN: r8829 - trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/xpl.
by jbosstools-commits@lists.jboss.org
Author: estherbin
Date: 2008-06-18 11:22:26 -0400 (Wed, 18 Jun 2008)
New Revision: 8829
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/xpl/CustomSashForm.java
Log:
Fix http://jira.jboss.com/jira/browse/JBIDE-2337
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/xpl/CustomSashForm.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/xpl/CustomSashForm.java 2008-06-18 15:22:03 UTC (rev 8828)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/xpl/CustomSashForm.java 2008-06-18 15:22:26 UTC (rev 8829)
@@ -43,7 +43,14 @@
public class CustomSashForm extends SashForm {
public static final String copyright = "(c) Copyright IBM Corporation 2002."; //$NON-NLS-1$
+
+ //added by estherbin
+ //fix http://jira.jboss.com/jira/browse/JBIDE-2337
/**
+ * Determine is hidden or not.
+ */
+ private boolean isHidden = false;
+ /**
* Custom style bits. They set whether max to one side of the other
* is not permitted. For example, if NO_MAX_UP, then there will be only
* one arrow. When not maxed, it will point down (and will do a max down),
@@ -286,6 +293,11 @@
* @see org.eclipse.swt.events.ControlAdapter#controlMoved(ControlEvent)
*/
public void controlMoved(ControlEvent e) {
+ if(e.widget instanceof Sash){
+ Sash s = (Sash) e.widget;
+ String text = s.getToolTipText();
+// if(text.equalsIgnoreCase(anotherString))
+ }
recomputeSashInfo();
}
@@ -496,6 +508,9 @@
drawArrows[1] = DOWN_ARROW;
currentSashInfo.sashBorderLeft = false;
currentSashInfo.sashBorderRight = sashBorders != null ? sashBorders[1] : false;
+ //added by estherbin
+ //fix http://jira.jboss.com/jira/browse/JBIDE-2337
+ this.isHidden = true;
} else if (weights[1] == 0 || (currentSashInfo.weight != NO_WEIGHT && sashBounds.y+sashBounds.height >= clientArea.height-DRAG_MINIMUM)) {
// Slammed to the bottom
addArrows[0] = UP_ARROW;
@@ -504,6 +519,9 @@
drawArrows[1] = UP_MAX_ARROW;
currentSashInfo.sashBorderLeft = sashBorders != null ? sashBorders[0] : false;
currentSashInfo.sashBorderRight = false;
+ //added by estherbin
+ //fix http://jira.jboss.com/jira/browse/JBIDE-2337
+ this.isHidden = true;
} else {
// Not slammed
addArrows[0] = UP_MAX_ARROW;
@@ -512,7 +530,10 @@
drawArrows[1] = DOWN_ARROW;
currentSashInfo.weight = NO_WEIGHT; // Since we are in the middle, there is no weight. We've could of been dragged here.
currentSashInfo.sashBorderLeft = sashBorders != null ? sashBorders[0] : false;
- currentSashInfo.sashBorderRight = sashBorders != null ? sashBorders[1] : false;
+ currentSashInfo.sashBorderRight = sashBorders != null ? sashBorders[1] : false;
+ //added by estherbin
+ //fix http://jira.jboss.com/jira/browse/JBIDE-2337
+ this.isHidden=false;
}
}
getNewSashArray(currentSashInfo, addArrows, drawArrows);
@@ -642,6 +663,16 @@
y+=tSize;
}
}
+ //added by estherbin
+ //fix http://jira.jboss.com/jira/browse/JBIDE-2337
+ /**
+ * Determine is hidden or not.
+ * @return <code>true</code> if hidden otherwise <code>false</code>
+ */
+
+ public boolean isHidden(){
+ return this.isHidden;
+ }
protected void drawSashBorder(GC gc, Sash sash, boolean leftBorder) {
gc.setForeground(borderColor);
17 years, 10 months
JBoss Tools SVN: r8828 - trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor.
by jbosstools-commits@lists.jboss.org
Author: estherbin
Date: 2008-06-18 11:22:03 -0400 (Wed, 18 Jun 2008)
New Revision: 8828
Modified:
trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java
Log:
Fix http://jira.jboss.com/jira/browse/JBIDE-2337
Modified: trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java
===================================================================
--- trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java 2008-06-18 13:20:05 UTC (rev 8827)
+++ trunk/vpe/plugins/org.jboss.tools.vpe/src/org/jboss/tools/vpe/editor/VpeEditorPart.java 2008-06-18 15:22:03 UTC (rev 8828)
@@ -897,7 +897,9 @@
try {
if (sourceEditor != null) {
if (visualEditor != null)
- if (visualEditor.getController() != null) {
+ //added by estherbin
+ //fix http://jira.jboss.com/jira/browse/JBIDE-2337
+ if ((visualEditor.getController() != null) && !container.isHidden()) {
visualEditor.getController().refreshTemplates();
}
sourceEditor.safelySanityCheckState(getEditorInput());
17 years, 10 months
JBoss Tools SVN: r8827 - trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/palette.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-06-18 09:20:05 -0400 (Wed, 18 Jun 2008)
New Revision: 8827
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/palette/DataTableWizard.java
Log:
JBIDE-2295
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/palette/DataTableWizard.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/palette/DataTableWizard.java 2008-06-18 13:19:11 UTC (rev 8826)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/palette/DataTableWizard.java 2008-06-18 13:20:05 UTC (rev 8827)
@@ -102,8 +102,13 @@
String value = null;
if (page2.getValue().trim().length() > 0) {
value = page2.getValue().trim();
- if(value.startsWith("#{")) value = value.substring(2);
- if(value.endsWith("}")) value = value.substring(0, value.length() - 1);
+ if(value.startsWith("#{")
+ || value.startsWith("${")) {
+ value = value.substring(2);
+ }
+ if(value.endsWith("}")) {
+ value = value.substring(0, value.length() - 1);
+ }
}
String var = null;
if (page2.getVar().length() > 0) {
17 years, 10 months
JBoss Tools SVN: r8826 - trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/palette.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2008-06-18 09:19:11 -0400 (Wed, 18 Jun 2008)
New Revision: 8826
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/palette/DataTableWizard.java
trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/palette/DataTableWizardPage.java
Log:
JBIDE-2295
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/palette/DataTableWizard.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/palette/DataTableWizard.java 2008-06-18 12:56:04 UTC (rev 8825)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/palette/DataTableWizard.java 2008-06-18 13:19:11 UTC (rev 8826)
@@ -95,13 +95,15 @@
public void fillColumn(){
Properties properties = fDropCommand.getProperties();
- String[] vs = page2.getSelectedProperties();
+ String[] vs = page2.getSelectedProperties();
StringBuffer text = new StringBuffer();
text.append(properties.getProperty("start text"));
String value = null;
- if (page2.getValue().length() > 0) {
- value = page2.getValue();
+ if (page2.getValue().trim().length() > 0) {
+ value = page2.getValue().trim();
+ if(value.startsWith("#{")) value = value.substring(2);
+ if(value.endsWith("}")) value = value.substring(0, value.length() - 1);
}
String var = null;
if (page2.getVar().length() > 0) {
@@ -131,4 +133,5 @@
getWizardModel().removePropertyChangeListener(this);
super.dispose();
}
+
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/palette/DataTableWizardPage.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/palette/DataTableWizardPage.java 2008-06-18 12:56:04 UTC (rev 8825)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.ui/src/org/jboss/tools/jsf/ui/wizard/palette/DataTableWizardPage.java 2008-06-18 13:19:11 UTC (rev 8826)
@@ -14,6 +14,7 @@
import java.beans.PropertyChangeListener;
import java.util.*;
import java.util.List;
+import java.util.regex.PatternSyntaxException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
@@ -39,6 +40,7 @@
import org.jboss.tools.common.model.util.AbstractTableHelper;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.jsf.model.pv.JSFPromptingProvider;
+import org.jboss.tools.jsf.ui.JsfUiPlugin;
import org.jboss.tools.common.model.ui.editors.dnd.*;
import org.jboss.tools.common.model.ui.editors.dnd.composite.*;
import org.jboss.tools.common.model.ui.editors.dnd.composite.TagAttributesComposite.AttributeDescriptorValue;
@@ -195,6 +197,27 @@
return generalTabContent;
}
+
+ public void validate() throws ValidationException {
+ super.validate();
+ String value = getValue();
+ if(value != null) value = value.trim();
+ if(value != null && value.length() > 0) {
+ try {
+ boolean b1 = value.matches("[#\\$]\\{[^#\\$\\}\\{]*\\}");
+ if(!b1) {
+ throw new ValidationException("Value must be set with Expression Language.");
+ }
+ boolean b2 = value.matches("[#\\$]\\{[^#\\$\\}\\{\\.]+(\\.[^#\\$\\}\\{\\.]+)*\\}");
+ if(!b2) {
+ throw new ValidationException("Expression Language in Value is not correct.");
+ }
+ } catch (PatternSyntaxException e) {
+ JsfUiPlugin.getPluginLog().logError(e);
+ }
+ }
+ }
+
boolean flag = false;
class PCL implements PropertyChangeListener {
17 years, 10 months
JBoss Tools SVN: r8825 - in trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui: src/org/jboss/tools/hibernate/jpt/ui/internal/platform and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: dgeraskov
Date: 2008-06-18 08:56:04 -0400 (Wed, 18 Jun 2008)
New Revision: 8825
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/META-INF/MANIFEST.MF
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernatePlatformUI.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-2344
http://jira.jboss.com/jira/browse/JBIDE-2345
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/META-INF/MANIFEST.MF 2008-06-18 12:06:37 UTC (rev 8824)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/META-INF/MANIFEST.MF 2008-06-18 12:56:04 UTC (rev 8825)
@@ -7,7 +7,16 @@
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.jpt.ui,
- org.eclipse.jpt.core;bundle-version="2.0.0"
+ org.eclipse.jpt.core;bundle-version="2.0.0",
+ org.eclipse.jpt;bundle-version="2.0.0",
+ org.eclipse.jpt.eclipselink.core;bundle-version="1.0.0",
+ org.eclipse.jpt.eclipselink.ui;bundle-version="1.0.0",
+ org.eclipse.jpt.gen;bundle-version="1.1.0",
+ org.eclipse.jpt.utility;bundle-version="1.2.0",
+ org.hibernate.eclipse.console;bundle-version="3.2.0",
+ org.hibernate.eclipse;bundle-version="3.2.0",
+ org.eclipse.core.resources;bundle-version="3.4.0",
+ org.eclipse.debug.core;bundle-version="3.4.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-Vendor: Hibernate Team
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernatePlatformUI.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernatePlatformUI.java 2008-06-18 12:06:37 UTC (rev 8824)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.jpt.ui/src/org/jboss/tools/hibernate/jpt/ui/internal/platform/HibernatePlatformUI.java 2008-06-18 12:56:04 UTC (rev 8825)
@@ -1,32 +1,113 @@
/*******************************************************************************
- * Copyright (c) 2007-2008 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributor:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ * Copyright (c) 2007-2008 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
package org.jboss.tools.hibernate.jpt.ui.internal.platform;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jpt.core.JpaProject;
-import org.eclipse.jpt.ui.internal.platform.base.EntitiesGenerator;
import org.eclipse.jpt.ui.internal.platform.generic.GenericPlatformUi;
+import org.hibernate.eclipse.launch.HibernateLaunchConstants;
/**
* @author Dmitry Geraskov
- *
+ *
*/
public class HibernatePlatformUI extends GenericPlatformUi {
-
- /**
- * Change method realization to provide other entities generation.
- */
+
+ public static final String LaunchConfigurationType_ID = "org.hibernate.eclipse.launch.CodeGenerationLaunchConfigurationType";
+
+ private static String exporter_id = "hbmexporter";
+ private static String full_exporter_id = HibernateLaunchConstants.ATTR_EXPORTERS + '.' + "hbmexporter";
+
@Override
public void generateEntities(JpaProject project, IStructuredSelection selection) {
- EntitiesGenerator.generate(project, selection);
+ ILaunchConfigurationWorkingCopy wc = createDefaultLaunchConfig(project.getName());
+ if (wc != null) {
+ // Main
+ // SHOULD PRESENT THE CONFIGURATION!!!
+ wc.setAttribute(HibernateLaunchConstants.ATTR_CONSOLE_CONFIGURATION_NAME, project.getName());
+
+ wc.setAttribute(HibernateLaunchConstants.ATTR_OUTPUT_DIR, project.getName() + "\\src"); //$NON-NLS-1$
+
+ wc.setAttribute(HibernateLaunchConstants.ATTR_PACKAGE_NAME, "package_name");
+ wc.setAttribute(HibernateLaunchConstants.ATTR_PREFER_BASIC_COMPOSITE_IDS, true);
+ wc.setAttribute(HibernateLaunchConstants.ATTR_AUTOMATIC_MANY_TO_MANY, true);
+ wc.setAttribute(HibernateLaunchConstants.ATTR_AUTOMATIC_VERSIONING, true);
+
+ wc.setAttribute(HibernateLaunchConstants.ATTR_ENABLE_JDK5, true);
+ wc.setAttribute(HibernateLaunchConstants.ATTR_ENABLE_EJB3_ANNOTATIONS, true);
+
+ wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS + '.' + exporter_id + ".extension_id",
+ HibernateLaunchConstants.ATTR_PREFIX + "hbm2java"); //$NON-NLS-1$ //$NON-NLS-2$
+ runLaunchConfiguration(wc);
+ }
}
+ @Override
+ public void generateDDL(JpaProject project, IStructuredSelection selection) {
+ ILaunchConfigurationWorkingCopy wc = createDefaultLaunchConfig(project.getName());
+ if (wc != null) {
+ // Main
+ // SHOULD PRESENT THE CONFIGURATION!!!
+ wc.setAttribute(HibernateLaunchConstants.ATTR_CONSOLE_CONFIGURATION_NAME, project.getName());
+ wc.setAttribute(HibernateLaunchConstants.ATTR_OUTPUT_DIR, project.getName() + "\\src"); //$NON-NLS-1$
+
+ Map<String, String> prop = new HashMap<String, String>();
+ prop.put("outputFileName", "schema.ddl");
+ prop.put("outputdir", project.getName() + "\\src");
+ prop.put("format", "true");
+ prop.put("scriptToConsole", "false");
+
+ wc.setAttribute(full_exporter_id + ".properties", prop);
+ wc.setAttribute(full_exporter_id + ".extension_id", HibernateLaunchConstants.ATTR_PREFIX + "hbm2ddl"); //$NON-NLS-1$ //$NON-NLS-2$
+ runLaunchConfiguration(wc);
+ }
+ }
+
+ private ILaunchConfigurationWorkingCopy createDefaultLaunchConfig(String projectName) {
+ ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
+ ILaunchConfigurationType launchConfigurationType = launchManager
+ .getLaunchConfigurationType(LaunchConfigurationType_ID); //$NON-NLS-1$
+
+ ILaunchConfigurationWorkingCopy wc = null;
+ try {
+ wc = launchConfigurationType.newInstance(null, projectName + "-hibernate-generate");
+ wc.setAttribute(HibernateLaunchConstants.ATTR_REVERSE_ENGINEER, true);
+ // Create exporters
+ List<String> exporters = new ArrayList<String>();
+ exporters.add(exporter_id); //$NON-NLS-1$
+ wc.setAttribute(HibernateLaunchConstants.ATTR_EXPORTERS, exporters);
+ wc.setAttribute(full_exporter_id, true);
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+
+ return wc;
+ }
+
+ private void runLaunchConfiguration(ILaunchConfiguration configuration) {
+ try {
+ DebugPlugin.getDefault().getLaunchManager().addLaunch(configuration.launch(ILaunchManager.RUN_MODE, null));
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
}
17 years, 10 months