JBoss Tools SVN: r8162 - trunk/birt/plugins/org.jboss.tools.birt.oda.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-05-16 16:38:12 -0400 (Fri, 16 May 2008)
New Revision: 8162
Modified:
trunk/birt/plugins/org.jboss.tools.birt.oda/
Log:
Initial import.
Property changes on: trunk/birt/plugins/org.jboss.tools.birt.oda
___________________________________________________________________
Name: svn:ignore
+ bin
17 years, 11 months
JBoss Tools SVN: r8161 - trunk/birt/plugins/org.jboss.tools.birt.oda.ui.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-05-16 16:38:08 -0400 (Fri, 16 May 2008)
New Revision: 8161
Modified:
trunk/birt/plugins/org.jboss.tools.birt.oda.ui/
Log:
Initial import.
Property changes on: trunk/birt/plugins/org.jboss.tools.birt.oda.ui
___________________________________________________________________
Name: svn:ignore
+ bin
17 years, 11 months
JBoss Tools SVN: r8160 - in trunk/birt/plugins/org.jboss.tools.birt.oda.ui: META-INF and 9 other directories.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-05-16 16:30:42 -0400 (Fri, 16 May 2008)
New Revision: 8160
Added:
trunk/birt/plugins/org.jboss.tools.birt.oda.ui/.classpath
trunk/birt/plugins/org.jboss.tools.birt.oda.ui/.project
trunk/birt/plugins/org.jboss.tools.birt.oda.ui/META-INF/
trunk/birt/plugins/org.jboss.tools.birt.oda.ui/META-INF/MANIFEST.MF
trunk/birt/plugins/org.jboss.tools.birt.oda.ui/about.html
trunk/birt/plugins/org.jboss.tools.birt.oda.ui/about.ini
trunk/birt/plugins/org.jboss.tools.birt.oda.ui/about.mappings
trunk/birt/plugins/org.jboss.tools.birt.oda.ui/about.properties
trunk/birt/plugins/org.jboss.tools.birt.oda.ui/build.properties
trunk/birt/plugins/org.jboss.tools.birt.oda.ui/icons/
trunk/birt/plugins/org.jboss.tools.birt.oda.ui/icons/datasetpage.ico
trunk/birt/plugins/org.jboss.tools.birt.oda.ui/icons/new_oda_dswiz.ico
trunk/birt/plugins/org.jboss.tools.birt.oda.ui/icons/profile.gif
trunk/birt/plugins/org.jboss.tools.birt.oda.ui/plugin.properties
trunk/birt/plugins/org.jboss.tools.birt.oda.ui/plugin.xml
trunk/birt/plugins/org.jboss.tools.birt.oda.ui/rhds_wiz.png
trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/
trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/
trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/
trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/
trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/
trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/
trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/
trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/Activator.java
trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/impl/
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/HibernateDSDragSource.java
trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/impl/HibernateDSDropSource.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/HibernateDataSourceWizardPage.java
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/TextMenuManager.java
Log:
Initial import.
Added: trunk/birt/plugins/org.jboss.tools.birt.oda.ui/.classpath
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda.ui/.classpath (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda.ui/.classpath 2008-05-16 20:30:42 UTC (rev 8160)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/birt/plugins/org.jboss.tools.birt.oda.ui/.project
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda.ui/.project (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda.ui/.project 2008-05-16 20:30:42 UTC (rev 8160)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.birt.oda.ui</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: trunk/birt/plugins/org.jboss.tools.birt.oda.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda.ui/META-INF/MANIFEST.MF (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda.ui/META-INF/MANIFEST.MF 2008-05-16 20:30:42 UTC (rev 8160)
@@ -0,0 +1,16 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %plugin.name
+Bundle-SymbolicName: org.jboss.tools.birt.oda.ui;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Activator: org.jboss.tools.birt.oda.ui.Activator
+Bundle-Vendor: RedHat, Inc.
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.datatools.connectivity.oda.design.ui;bundle-version="[3.0.4,4.0.0)",
+ org.jboss.tools.birt.oda,
+ org.eclipse.jface.text,
+ org.eclipse.jdt.core,
+ org.eclipse.ui.workbench.texteditor
+Eclipse-LazyStart: true
Added: trunk/birt/plugins/org.jboss.tools.birt.oda.ui/about.html
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda.ui/about.html (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda.ui/about.html 2008-05-16 20:30:42 UTC (rev 8160)
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
+<title>JBoss BIRT Integration</title>
+<style type="text/css" media="screen">
+<!--
+ body {
+ font-family: Sans-serif, Arial, Helvetica;
+ }
+
+-->
+</style>
+</head>
+<body>
+<h1>JBoss BIRT Integration</h1>
+
+<p>
+This plugin is part of the JBoss Tools developed by the <a href="http://www.jboss.com">JBoss Inc.</a>
+</p>
+
+<p>Information about this plugin is available at <a href="http://www.jboss.org/tools">JBoss Tools project page</a></p>
+
+<p>
+This software is distributed under the terms of the Eclipse Public License - v 1.0
+(see <a href="www.eclipse.org/legal/epl-v10.html">Eclipse Public License - Version 1.0</a>).
+</p>
+</body>
+</html>
\ No newline at end of file
Added: trunk/birt/plugins/org.jboss.tools.birt.oda.ui/about.ini
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda.ui/about.ini (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda.ui/about.ini 2008-05-16 20:30:42 UTC (rev 8160)
@@ -0,0 +1,27 @@
+# about.ini
+# contains information about a feature
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# "%key" are externalized strings defined in about.properties
+# This file does not need to be translated.
+# test
+# Property "aboutText" contains blurb for "About" dialog (translated)
+aboutText=%blurb
+
+# Property "windowImage" contains path to window icon (16x16)
+# needed for primary features only
+
+# Property "featureImage" contains path to feature image (32x32)
+featureImage=rhds_wiz.png
+
+# Property "aboutImage" contains path to product image (500x330 or 115x164)
+# needed for primary features only
+
+# Property "appName" contains name of the application (not translated)
+# needed for primary features only
+
+# Property "welcomePerspective" contains the id of the perspective in which the
+# welcome page is to be opened.
+# optional
+
+
+
Added: trunk/birt/plugins/org.jboss.tools.birt.oda.ui/about.mappings
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda.ui/about.mappings (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda.ui/about.mappings 2008-05-16 20:30:42 UTC (rev 8160)
@@ -0,0 +1,5 @@
+# about.mappings
+# contains fill-ins for about.properties
+# java.io.Properties file (ISO 8859-1 with "\" escapes)
+# This file does not need to be translated.
+
Added: trunk/birt/plugins/org.jboss.tools.birt.oda.ui/about.properties
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda.ui/about.properties (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda.ui/about.properties 2008-05-16 20:30:42 UTC (rev 8160)
@@ -0,0 +1,7 @@
+blurb=JBoss BIRT Integration\n\
+\n\
+Version: {featureVersion}\n\
+\n\
+(c) Copyright JBoss Inc. contributors and others 2004 - 2008. All rights reserved.\n\
+Visit http://jboss.org/tools
+
Added: trunk/birt/plugins/org.jboss.tools.birt.oda.ui/build.properties
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda.ui/build.properties (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda.ui/build.properties 2008-05-16 20:30:42 UTC (rev 8160)
@@ -0,0 +1,12 @@
+source.. = src/
+output.. = bin/
+bin.includes = plugin.xml,\
+ META-INF/,\
+ .,\
+ plugin.properties,\
+ icons/,\
+ about.properties,\
+ about.mappings,\
+ about.ini,\
+ about.html,\
+ rhds_wiz.png
Added: trunk/birt/plugins/org.jboss.tools.birt.oda.ui/icons/datasetpage.ico
===================================================================
(Binary files differ)
Property changes on: trunk/birt/plugins/org.jboss.tools.birt.oda.ui/icons/datasetpage.ico
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/birt/plugins/org.jboss.tools.birt.oda.ui/icons/new_oda_dswiz.ico
===================================================================
(Binary files differ)
Property changes on: trunk/birt/plugins/org.jboss.tools.birt.oda.ui/icons/new_oda_dswiz.ico
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/birt/plugins/org.jboss.tools.birt.oda.ui/icons/profile.gif
===================================================================
(Binary files differ)
Property changes on: trunk/birt/plugins/org.jboss.tools.birt.oda.ui/icons/profile.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/birt/plugins/org.jboss.tools.birt.oda.ui/plugin.properties
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda.ui/plugin.properties (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda.ui/plugin.properties 2008-05-16 20:30:42 UTC (rev 8160)
@@ -0,0 +1,16 @@
+###############################################################################
+# Plug-in Configuration
+#
+oda.data.source.id=org.jboss.tools.birt.oda
+#
+###############################################################################
+# NLS strings
+#
+plugin.name=JBoss BIRT Integration
+newwizard.name=Hibernate Data Source
+newwizard.description=Create a Hibernate Data Source connection profile
+wizard.window.title=New Hibernate Data Source Profile
+wizard.data.source.page.title=Hibernate Data Source
+profile.propertypage.name=Hibernate Data Source Connection Properties
+wizard.data.set.window.title=New Hibernate Data Set
+wizard.data.set.page.title=Query
Added: trunk/birt/plugins/org.jboss.tools.birt.oda.ui/plugin.xml
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda.ui/plugin.xml (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda.ui/plugin.xml 2008-05-16 20:30:42 UTC (rev 8160)
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+
+
+ <extension
+ point="org.eclipse.datatools.connectivity.connectionProfile">
+ <newWizard
+ name="%newwizard.name"
+ icon="icons/new_oda_dswiz.ico"
+ profile="%oda.data.source.id"
+ description="%newwizard.description"
+ class="org.eclipse.datatools.connectivity.oda.design.ui.wizards.NewDataSourceWizard"
+ id="%oda.data.source.id">
+ </newWizard>
+ </extension>
+ <extension
+ point="org.eclipse.ui.propertyPages">
+ <page
+ objectClass="org.eclipse.datatools.connectivity.IConnectionProfile"
+ name="%profile.propertypage.name"
+ class="org.jboss.tools.birt.oda.ui.impl.HibernateDataSourcePropertyPage"
+ id="%oda.data.source.id">
+ <filter
+ name="org.eclipse.datatools.profile.property.id"
+ value="%oda.data.source.id">
+ </filter>
+ </page>
+ </extension>
+
+ <extension
+ point="org.eclipse.datatools.connectivity.oda.design.ui.dataSource">
+ <dataSourceUI
+ id="%oda.data.source.id">
+ <newDataSourceWizard
+ pageClass="org.jboss.tools.birt.oda.ui.impl.HibernateDataSourceWizardPage"
+ includesProgressMonitor="false"
+ pageTitle="%wizard.data.source.page.title"
+ windowTitle="%wizard.window.title">
+ </newDataSourceWizard>
+ </dataSourceUI>
+ <dataSetUI
+ supportsOutParameters="false"
+ supportsInParameters="true"
+ initialPageId="org.jboss.tools.birt.oda.dataSet.page1"
+ id="org.jboss.tools.birt.oda.dataSet">
+ <dataSetWizard
+ class="org.eclipse.datatools.connectivity.oda.design.ui.wizards.DataSetWizard"
+ windowTitle="%wizard.data.set.window.title">
+ </dataSetWizard>
+ <dataSetPage
+ displayName="%wizard.data.set.page.title"
+ icon="icons/datasetpage.ico"
+ wizardPageClass="org.jboss.tools.birt.oda.ui.impl.CustomDataSetWizardPage"
+ path="/"
+ id="org.jboss.tools.birt.oda.dataSet.page1">
+ </dataSetPage>
+ </dataSetUI>
+ </extension>
+
+</plugin>
Added: trunk/birt/plugins/org.jboss.tools.birt.oda.ui/rhds_wiz.png
===================================================================
(Binary files differ)
Property changes on: trunk/birt/plugins/org.jboss.tools.birt.oda.ui/rhds_wiz.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/Activator.java
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/Activator.java (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/Activator.java 2008-05-16 20:30:42 UTC (rev 8160)
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ *
+ ******************************************************************************/
+package org.jboss.tools.birt.oda.ui;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ *
+ * @author snjeza
+ */
+public class Activator extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.birt.oda.ui";
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+}
Added: 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 (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/impl/CustomDataSetWizardPage.java 2008-05-16 20:30:42 UTC (rev 8160)
@@ -0,0 +1,722 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ *
+ ******************************************************************************/
+
+package org.jboss.tools.birt.oda.ui.impl;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.IHandler;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.datatools.connectivity.oda.IConnection;
+import org.eclipse.datatools.connectivity.oda.IDriver;
+import org.eclipse.datatools.connectivity.oda.IParameterMetaData;
+import org.eclipse.datatools.connectivity.oda.IQuery;
+import org.eclipse.datatools.connectivity.oda.IResultSetMetaData;
+import org.eclipse.datatools.connectivity.oda.OdaException;
+import org.eclipse.datatools.connectivity.oda.design.DataSetDesign;
+import org.eclipse.datatools.connectivity.oda.design.DataSetParameters;
+import org.eclipse.datatools.connectivity.oda.design.DataSourceDesign;
+import org.eclipse.datatools.connectivity.oda.design.DesignFactory;
+import org.eclipse.datatools.connectivity.oda.design.NameValuePair;
+import org.eclipse.datatools.connectivity.oda.design.ParameterDefinition;
+import org.eclipse.datatools.connectivity.oda.design.Property;
+import org.eclipse.datatools.connectivity.oda.design.ResultSetColumns;
+import org.eclipse.datatools.connectivity.oda.design.ResultSetDefinition;
+import org.eclipse.datatools.connectivity.oda.design.ui.designsession.DesignSessionUtil;
+import org.eclipse.datatools.connectivity.oda.design.ui.wizards.DataSetWizardPage;
+import org.eclipse.datatools.connectivity.oda.design.util.DesignUtil;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextOperationTarget;
+import org.eclipse.jface.text.IUndoManager;
+import org.eclipse.jface.text.TextViewerUndoManager;
+import org.eclipse.jface.text.source.CompositeRuler;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.LineNumberRulerColumn;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.text.source.SourceViewerConfiguration;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Sash;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.handlers.IHandlerActivation;
+import org.eclipse.ui.handlers.IHandlerService;
+import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
+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.console.QueryInputModel;
+import org.hibernate.eclipse.console.QueryEditor;
+import org.hibernate.eclipse.console.viewers.xpl.MTreeViewer;
+import org.hibernate.eclipse.console.views.KnownConfigurationsProvider;
+import org.hibernate.eclipse.console.workbench.LazySessionFactory;
+import org.hibernate.eclipse.console.workbench.LazySessionFactoryAdapter;
+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.impl.HibernateConnection;
+import org.jboss.tools.birt.oda.impl.HibernateDriver;
+import org.jboss.tools.birt.oda.ui.Activator;
+
+/**
+ * Hibernate data set designer page
+ *
+ * @author snjeza
+ */
+public class CustomDataSetWizardPage extends DataSetWizardPage {
+
+ private static String DEFAULT_MESSAGE = "Define the query text for the data set";
+
+ private StyledText styledText;
+
+ private SourceViewer sourceViewer;
+
+ private IHandlerService fService;
+
+ private IHandlerActivation fActivation;
+
+ private TreeViewer viewer;
+
+ private Button testButton;
+
+ /**
+ * Constructor
+ *
+ * @param pageName
+ */
+ public CustomDataSetWizardPage(String pageName) {
+ super(pageName);
+ setTitle(pageName);
+ setMessage(DEFAULT_MESSAGE);
+
+ setPageComplete(false);
+ }
+
+ /**
+ * Constructor
+ *
+ * @param pageName
+ * @param title
+ * @param titleImage
+ */
+ public CustomDataSetWizardPage(String pageName, String title,
+ ImageDescriptor titleImage) {
+ super(pageName, title, titleImage);
+ setMessage(DEFAULT_MESSAGE);
+ setPageComplete(false);
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.datatools.connectivity.oda.design.ui.wizards.DataSetWizardPage#createPageCustomControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createPageCustomControl(Composite parent) {
+ setControl(createPageControl(parent));
+ validateData();
+ setMessage(DEFAULT_MESSAGE);
+ }
+
+ /**
+ * Creates custom control for user-defined query text.
+ */
+ private Control createPageControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 3;
+ layout.marginWidth = 0;
+ layout.marginHeight = 0;
+ layout.horizontalSpacing = 2;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ Control left = createTableSelectionComposite(composite);
+ GridData gridData = (GridData) left.getLayoutData();
+ gridData.widthHint=160;
+ //left.setLayoutData(gridData);
+
+ Sash sash = createSash(composite);
+ Control right = createQueryComposite(composite);
+ //setWidthHints(composite, left, right, sash);
+ addDragListerner(sash, composite, left, right);
+ initDragAndDrop();
+ return composite;
+ }
+
+ private void initDragAndDrop() {
+ new HibernateDSDragSource(viewer);
+ new HibernateDSDropSource(sourceViewer);
+ }
+
+ private void addDragListerner( final Sash sash, final Composite parent,
+ final Control left, final Control right )
+ {
+ sash.addListener( SWT.Selection, new Listener( ) {
+
+ public void handleEvent( Event event )
+ {
+ if ( event.detail == SWT.DRAG )
+ {
+ return;
+ }
+ Sash sash = (Sash) event.widget;
+ int shift = event.x - sash.getBounds( ).x;
+
+ left.setSize( left.getSize( ).x+shift, left.getSize( ).y );
+ right.setSize( right.getSize( ).x-shift, right.getSize( ).y );
+ right.setLocation( right.getLocation( ).x+shift, right.getLocation( ).y );
+ sash.setLocation( sash.getLocation( ).x+shift, sash.getLocation( ).y );
+ }
+ } );
+ }
+
+
+ private Control createQueryComposite(Composite parent) {
+
+ Composite composite = new Composite(parent, SWT.FILL
+ | SWT.LEFT_TO_RIGHT );
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ composite.setLayout(layout);
+ composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ CompositeRuler ruler = new CompositeRuler();
+ LineNumberRulerColumn lineNumbers = new LineNumberRulerColumn();
+ ruler.addDecorator(0, lineNumbers);
+
+ sourceViewer = new SourceViewer(composite, ruler, SWT.V_SCROLL
+ | SWT.H_SCROLL | SWT.BORDER);
+ sourceViewer.setInput(parent);
+ styledText = sourceViewer.getTextWidget();
+ styledText.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ validateData();
+ }
+
+ });
+ styledText.setFont(JFaceResources.getTextFont());
+ Control control = sourceViewer.getControl();
+ GridData gd = new GridData(GridData.FILL_BOTH);
+ control.setLayoutData(gd);
+
+ IDocument document = new Document();
+ document.set(getInitialQueryString());
+ HQLEditorDocumentSetupParticipant docSetupParticipant = new HQLEditorDocumentSetupParticipant();
+ docSetupParticipant.setup(document);
+ sourceViewer.setEditable(true);
+ sourceViewer.setDocument(document);
+ IUndoManager undoManager = new TextViewerUndoManager(10);
+ sourceViewer.setUndoManager(undoManager);
+ undoManager.connect(sourceViewer);
+
+ attachMenus(sourceViewer);
+ // add support of additional accelerated key
+ sourceViewer.getTextWidget( ).addKeyListener( new KeyListener( ) {
+
+ public void keyPressed( KeyEvent e )
+ {
+ if ( isUndoKeyPress( e ) )
+ {
+ sourceViewer.doOperation( ITextOperationTarget.UNDO );
+ }
+ else if ( isRedoKeyPress( e ) )
+ {
+ sourceViewer.doOperation( ITextOperationTarget.REDO );
+ }
+ validateData();
+ }
+
+ private boolean isUndoKeyPress( KeyEvent e )
+ {
+ // CTRL + z
+ return ( ( e.stateMask & SWT.CONTROL ) > 0 )
+ && ( ( e.keyCode == 'z' ) || ( e.keyCode == 'Z' ) );
+ }
+
+ private boolean isRedoKeyPress( KeyEvent e )
+ {
+ // CTRL + y
+ return ( ( e.stateMask & SWT.CONTROL ) > 0 )
+ && ( ( e.keyCode == 'y' ) || ( e.keyCode == 'Y' ) );
+ }
+
+ public void keyReleased( KeyEvent e )
+ {
+ // do nothing
+ }
+ } );
+
+ IHandler handler = new AbstractHandler() {
+ public Object execute(ExecutionEvent event)
+ throws org.eclipse.core.commands.ExecutionException {
+ sourceViewer.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
+ return null;
+ }
+ };
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ fService = (IHandlerService) workbench
+ .getAdapter(IHandlerService.class);
+ fActivation = fService.activateHandler(
+ ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS,
+ handler);
+
+ QueryEditor editor = new QueryEditor() {
+
+ public boolean askUserForConfiguration(String name) {
+ return false;
+ }
+
+ public void executeQuery(ConsoleConfiguration cfg) {
+ }
+
+ public ConsoleConfiguration getConsoleConfiguration() {
+ return getInternalConsoleConfiguration();
+ }
+
+ public String getConsoleConfigurationName() {
+ return getConfigurationName();
+ }
+
+ public QueryInputModel getQueryInputModel() {
+ return null;
+ }
+
+ public String getQueryString() {
+ return null;
+ }
+
+ public void setConsoleConfigurationName(String text) {
+ }
+
+ };
+ SourceViewerConfiguration svc = new HQLSourceViewerConfiguration(
+ editor);
+ sourceViewer.configure(svc);
+ testButton = new Button(composite,SWT.NONE);
+ testButton.setText("Test query ...");
+ testButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent e) {
+ testQuery();
+ }
+
+ });
+ return composite;
+ }
+
+ private void testQuery() {
+ String title = "Test query";
+ ConsoleConfiguration configuration = getInternalConsoleConfiguration();
+ if (configuration == null || configuration.getSessionFactory() == null) {
+ MessageDialog.openConfirm(getShell(), title,
+ "Invalid configuration '" + getConfigurationName() + "'.");
+ }
+ Session session = null;
+ try {
+ session = configuration.getSessionFactory().openSession();
+ Query q = session.createQuery(getQueryText());
+ q.setFirstResult(0);
+ q.setMaxResults(1);
+ q.list();
+ MessageDialog.openInformation(getShell(), title,
+ "The query is valid.");
+ } catch (Exception e) {
+ String message = "The query is not valid.";
+ IStatus status = new Status(Status.ERROR, Activator.PLUGIN_ID,
+ e.getLocalizedMessage(), e);
+ Activator.getDefault().getLog().log(status);
+ ErrorDialog.openError(getShell(), title, message, status);
+ } finally {
+ if (session != null) {
+ session.close();
+ }
+ }
+ }
+
+ private final void attachMenus( SourceViewer viewer )
+ {
+ StyledText widget = viewer.getTextWidget( );
+ TextMenuManager menuManager = new TextMenuManager( viewer );
+ widget.setMenu( menuManager.getContextMenu( widget ) );
+ }
+
+ private String getConfigurationName() {
+ DataSetDesign design = getInitializationDesign();
+ DataSourceDesign dsDesign = design.getDataSourceDesign();
+ Property property = dsDesign.getPublicProperties().findProperty(
+ HibernateConnection.CONFIGURATION);
+ NameValuePair propertyValue = property.getNameValue();
+ String name = propertyValue.getValue();
+ return name;
+ }
+
+ private ConsoleConfiguration getInternalConsoleConfiguration() {
+ return getConsoleConfiguration(getConfigurationName());
+ }
+
+ private Sash createSash(final Composite composite) {
+ final Sash sash = new Sash(composite, SWT.VERTICAL);
+ sash.setLayoutData(new GridData(GridData.FILL_VERTICAL));
+ return sash;
+ }
+
+ private Control createTableSelectionComposite(Composite parent) {
+
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout layout = new GridLayout();
+
+ composite.setLayout(layout);
+
+ GridData data = new GridData(GridData.FILL_VERTICAL);
+ data.grabExcessVerticalSpace = true;
+ composite.setLayoutData(data);
+
+ Label dataSourceLabel = new Label(composite, SWT.LEFT);
+ dataSourceLabel.setText("Available Items");
+ data = new GridData();
+ dataSourceLabel.setLayoutData(data);
+
+ viewer = new MTreeViewer(composite, SWT.MULTI | SWT.H_SCROLL
+ | SWT.V_SCROLL);
+ data = new GridData(GridData.FILL_BOTH);
+ data.grabExcessHorizontalSpace = true;
+ data.grabExcessVerticalSpace = true;
+
+ viewer.getControl().setLayoutData(data);
+
+ viewer.setLabelProvider(new AnyAdaptableLabelProvider());
+ viewer.setContentProvider(new KnownConfigurationsProvider());
+ ConsoleConfiguration configuration = getInternalConsoleConfiguration();
+ if (configuration != null) {
+ SessionFactory sessionFactory = configuration.getSessionFactory();
+ if (sessionFactory == null) {
+ configuration.build();
+ configuration.buildSessionFactory();
+ configuration.getSessionFactory();
+ }
+ viewer.setInput(new LazySessionFactory(configuration));
+ }
+ else
+ viewer.setInput(KnownConfigurations.getInstance());
+
+ return composite;
+ }
+
+ private ConsoleConfiguration getConsoleConfiguration(String name) {
+ ConsoleConfiguration[] configurations = KnownConfigurations
+ .getInstance().getConfigurations();
+ for (int i = 0; i < configurations.length; i++) {
+ if (configurations[i].getName().equals(name)) {
+ return configurations[i];
+ }
+ }
+ return null;
+ }
+
+ private void setWidthHints(Composite pageContainer, Control left,
+ Control right, Sash sash) {
+ int leftWidth = left.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
+ int totalWidth = pageContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
+
+ if ((double) leftWidth / (double) totalWidth > 0.4) {
+ // if left side is too wide, set it to default value 40:60
+ leftWidth = totalWidth * 40 / 100;
+ leftWidth = leftWidth
+ - sash.computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
+ GridData data = (GridData) left.getLayoutData();
+ data.widthHint = leftWidth;
+ data = (GridData) right.getLayoutData();
+ data.widthHint = totalWidth - leftWidth;
+ } else {
+ GridData data = (GridData) left.getLayoutData();
+ data.widthHint = leftWidth;
+ data = (GridData) right.getLayoutData();
+ data.widthHint = totalWidth - leftWidth;
+ }
+ }
+
+ /**
+ * Initializes the page control with the last edited data set design.
+ */
+ private String getInitialQueryString() {
+ DataSetDesign dataSetDesign = getInitializationDesign();
+ if (dataSetDesign == null)
+ return ""; // nothing to initialize
+
+ String queryText = dataSetDesign.getQueryText();
+ if (queryText == null) {
+ return "";
+ }
+ return queryText;
+ }
+
+ /**
+ * Obtains the user-defined query text of this data set from page control.
+ *
+ * @return query text
+ */
+ private String getQueryText() {
+ return styledText.getText();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.datatools.connectivity.oda.design.ui.wizards.DataSetWizardPage#collectDataSetDesign(org.eclipse.datatools.connectivity.oda.design.DataSetDesign)
+ */
+ protected DataSetDesign collectDataSetDesign(DataSetDesign design) {
+ if (!hasValidData())
+ return design;
+ savePage(design);
+ return design;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.datatools.connectivity.oda.design.ui.wizards.DataSetWizardPage#collectResponseState()
+ */
+ protected void collectResponseState() {
+ super.collectResponseState();
+ /*
+ * To optionally assign a custom response state, for inclusion in the
+ * ODA design session response, use setResponseSessionStatus(
+ * SessionStatus status ); setResponseDesignerState( DesignerState
+ * customState );
+ */
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.datatools.connectivity.oda.design.ui.wizards.DataSetWizardPage#canLeave()
+ */
+ protected boolean canLeave() {
+ return isPageComplete();
+ }
+
+ /**
+ * Validates the user-defined value in the page control exists and not a
+ * blank text. Set page message accordingly.
+ */
+ private void validateData() {
+ boolean isValid = (styledText != null && getQueryText() != null && getQueryText()
+ .trim().length() > 0);
+
+ if (isValid)
+ setMessage(DEFAULT_MESSAGE);
+ else
+ setMessage("Requires input value.", ERROR);
+
+ if (testButton != null) {
+ testButton.setEnabled(isValid);
+ }
+ setPageComplete(isValid);
+ }
+
+ /**
+ * Indicates whether the custom page has valid data to proceed with defining
+ * a data set.
+ */
+ private boolean hasValidData() {
+ validateData();
+
+ return canLeave();
+ }
+
+ /**
+ * Saves the user-defined value in this page, and updates the specified
+ * dataSetDesign with the latest design definition.
+ */
+ private void savePage(DataSetDesign dataSetDesign) {
+ // save user-defined query text
+ String queryText = getQueryText();
+ dataSetDesign.setQueryText(queryText);
+
+ // obtain query's current runtime metadata, and maps it to the
+ // dataSetDesign
+ IConnection customConn = null;
+ try {
+ // instantiate your custom ODA runtime driver class
+ /*
+ * Note: You may need to manually update your ODA runtime
+ * extension's plug-in manifest to export its package for visibility
+ * here.
+ */
+ IDriver customDriver = new HibernateDriver();
+
+ // obtain and open a live connection
+ customConn = customDriver.getConnection(null);
+ java.util.Properties connProps = DesignUtil
+ .convertDataSourceProperties(getInitializationDesign()
+ .getDataSourceDesign());
+ customConn.open(connProps);
+
+ // update the data set design with the
+ // query's current runtime metadata
+ updateDesign(dataSetDesign, customConn, queryText);
+ } catch (OdaException e) {
+ // not able to get current metadata, reset previous derived metadata
+ dataSetDesign.setResultSets(null);
+ dataSetDesign.setParameters(null);
+
+ e.printStackTrace();
+ } finally {
+ closeConnection(customConn);
+ }
+ }
+
+ /**
+ * Updates the given dataSetDesign with the queryText and its derived
+ * metadata obtained from the ODA runtime connection.
+ */
+ private void updateDesign(DataSetDesign dataSetDesign, IConnection conn,
+ String queryText) throws OdaException {
+ IQuery query = conn.newQuery(null);
+ query.prepare(queryText);
+
+ try {
+ IResultSetMetaData md = query.getMetaData();
+ updateResultSetDesign(md, dataSetDesign);
+ } catch (OdaException e) {
+ // no result set definition available, reset previous derived
+ // metadata
+ dataSetDesign.setResultSets(null);
+ e.printStackTrace();
+ }
+
+ // proceed to get parameter design definition
+ try {
+ IParameterMetaData paramMd = query.getParameterMetaData();
+ updateParameterDesign(paramMd, dataSetDesign);
+ } catch (OdaException ex) {
+ // no parameter definition available, reset previous derived
+ // metadata
+ dataSetDesign.setParameters(null);
+ ex.printStackTrace();
+ }
+
+ /*
+ * See DesignSessionUtil for more convenience methods to define a data
+ * set design instance.
+ */
+ }
+
+ /**
+ * Updates the specified data set design's result set definition based on
+ * the specified runtime metadata.
+ *
+ * @param md
+ * runtime result set metadata instance
+ * @param dataSetDesign
+ * data set design instance to update
+ * @throws OdaException
+ */
+ private void updateResultSetDesign(IResultSetMetaData md,
+ DataSetDesign dataSetDesign) throws OdaException {
+ ResultSetColumns columns = DesignSessionUtil
+ .toResultSetColumnsDesign(md);
+
+ ResultSetDefinition resultSetDefn = DesignFactory.eINSTANCE
+ .createResultSetDefinition();
+ // resultSetDefn.setName( value ); // result set name
+ resultSetDefn.setResultSetColumns(columns);
+
+ // no exception in conversion; go ahead and assign to specified
+ // dataSetDesign
+ dataSetDesign.setPrimaryResultSet(resultSetDefn);
+ dataSetDesign.getResultSets().setDerivedMetaData(true);
+ }
+
+ /**
+ * Updates the specified data set design's parameter definition based on the
+ * specified runtime metadata.
+ *
+ * @param paramMd
+ * runtime parameter metadata instance
+ * @param dataSetDesign
+ * data set design instance to update
+ * @throws OdaException
+ */
+ private void updateParameterDesign(IParameterMetaData paramMd,
+ DataSetDesign dataSetDesign) throws OdaException {
+ DataSetParameters paramDesign = DesignSessionUtil
+ .toDataSetParametersDesign(
+ paramMd,
+ DesignSessionUtil
+ .toParameterModeDesign(IParameterMetaData.parameterModeIn));
+
+ // no exception in conversion; go ahead and assign to specified
+ // dataSetDesign
+ if (paramDesign == null)
+ return;
+ paramDesign.setDerivedMetaData(true);
+ dataSetDesign.setParameters(paramDesign);
+
+ // TODO replace below with data source specific implementation;
+ // hard-coded parameter's default value for demo purpose
+ if (paramDesign.getParameterDefinitions().size() > 0) {
+ ParameterDefinition paramDef = (ParameterDefinition) paramDesign
+ .getParameterDefinitions().get(0);
+ if (paramDef != null)
+ paramDef.setDefaultScalarValue("dummy default value");
+ }
+ }
+
+ /**
+ * Attempts to close given ODA connection.
+ */
+ private void closeConnection(IConnection conn) {
+ try {
+ if (conn != null && conn.isOpen())
+ conn.close();
+ } catch (OdaException e) {
+ // ignore
+ e.printStackTrace();
+ }
+ }
+
+ public void dispose() {
+ if (fActivation != null) {
+ fService.deactivateHandler(fActivation);
+ }
+ if (sourceViewer != null) {
+ sourceViewer.getTextWidget().dispose();
+ sourceViewer = null;
+ }
+
+ super.dispose();
+ }
+
+}
Added: trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/impl/HibernateDSDragSource.java
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/impl/HibernateDSDragSource.java (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/impl/HibernateDSDragSource.java 2008-05-16 20:30:42 UTC (rev 8160)
@@ -0,0 +1,54 @@
+package org.jboss.tools.birt.oda.ui.impl;
+
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DragSource;
+import org.eclipse.swt.dnd.DragSourceEvent;
+import org.eclipse.swt.dnd.DragSourceListener;
+import org.eclipse.swt.dnd.Transfer;
+import org.hibernate.console.node.BaseNode;
+import org.hibernate.mapping.Property;
+import org.hibernate.mapping.RootClass;
+
+public class HibernateDSDragSource implements DragSourceListener {
+
+ private TreeViewer viewer;
+
+ public HibernateDSDragSource(TreeViewer viewer) {
+ this.viewer = viewer;
+ DragSource source = new DragSource(viewer.getControl(),DND.DROP_COPY | DND.DROP_MOVE);
+ source.setTransfer(new Transfer[] { LocalSelectionTransfer.getTransfer()});
+ source.addDragListener(this);
+ }
+
+ public void dragFinished(DragSourceEvent event) {
+ }
+
+ public void dragSetData(DragSourceEvent event) {
+ if (LocalSelectionTransfer.getTransfer()
+ .isSupportedType(event.dataType)) {
+ LocalSelectionTransfer.getTransfer().setSelection(
+ viewer.getSelection());
+ }
+ }
+
+ public void dragStart(DragSourceEvent event) {
+ ISelection sel = viewer.getSelection();
+ if (sel instanceof IStructuredSelection) {
+ IStructuredSelection selection = (IStructuredSelection) sel;
+ if (selection.size() == 1) {
+ Object object = selection.getFirstElement();
+ if (object instanceof RootClass
+ || object instanceof Property || object instanceof BaseNode) {
+ event.doit = true;
+ return;
+ }
+ }
+ }
+ event.doit = false;
+ }
+
+}
Added: trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/impl/HibernateDSDropSource.java
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/impl/HibernateDSDropSource.java (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/impl/HibernateDSDropSource.java 2008-05-16 20:30:42 UTC (rev 8160)
@@ -0,0 +1,89 @@
+package org.jboss.tools.birt.oda.ui.impl;
+
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.dnd.DND;
+import org.eclipse.swt.dnd.DropTarget;
+import org.eclipse.swt.dnd.DropTargetEvent;
+import org.eclipse.swt.dnd.DropTargetListener;
+import org.eclipse.swt.dnd.Transfer;
+import org.hibernate.console.node.BaseNode;
+import org.hibernate.mapping.Property;
+import org.hibernate.mapping.RootClass;
+
+public class HibernateDSDropSource implements DropTargetListener {
+
+ private SourceViewer viewer;
+
+ public HibernateDSDropSource(SourceViewer viewer) {
+ this.viewer = viewer;
+ int operations = DND.DROP_COPY | DND.DROP_DEFAULT;
+ DropTarget target = new DropTarget(viewer.getTextWidget(), operations);
+ Transfer[] types = new Transfer[] { LocalSelectionTransfer
+ .getTransfer() };
+ target.setTransfer(types);
+ target.addDropListener(this);
+ }
+
+ public void dragEnter(DropTargetEvent event) {
+ viewer.getTextWidget().setFocus( );
+ if ( event.detail == DND.DROP_DEFAULT )
+ event.detail = DND.DROP_COPY;
+ if ( event.detail != DND.DROP_COPY )
+ event.detail = DND.DROP_NONE;
+
+ }
+
+ public void dragLeave(DropTargetEvent event) {
+ }
+
+ public void dragOperationChanged(DropTargetEvent event) {
+ dragEnter(event);
+ }
+
+ public void dragOver(DropTargetEvent event) {
+ event.feedback = DND.FEEDBACK_SCROLL | DND.FEEDBACK_SELECT;
+ }
+
+ public void drop(DropTargetEvent event) {
+ if (LocalSelectionTransfer.getTransfer().isSupportedType(
+ event.currentDataType)) {
+
+ Object data = LocalSelectionTransfer.getTransfer().getSelection();
+ if (data instanceof IStructuredSelection) {
+ IStructuredSelection selection = (IStructuredSelection) event.data;
+ Object source = selection.getFirstElement();
+ String text = null;
+ if (source instanceof RootClass) {
+ RootClass table = (RootClass) source;
+ text = getShortName(table.getEntityName());
+ } else if (source instanceof Property) {
+ Property property = (Property) source;
+ text = property.getName();
+ } else if (source instanceof BaseNode) {
+ BaseNode node = (BaseNode) source;
+ text = getShortName(node.getName());
+ }
+ if (text == null)
+ return;
+ StyledText textWidget = viewer.getTextWidget();
+ int selectionStart = textWidget.getSelection().x;
+ textWidget.insert(text);
+ textWidget.setSelection(selectionStart + text.length());
+ textWidget.setFocus();
+ }
+ }
+ }
+
+ private String getShortName(String name) {
+ while (name.indexOf(".") > -1)
+ name = name.substring(name.indexOf(".") + 1);
+ return name;
+ }
+
+ public void dropAccept(DropTargetEvent event) {
+ }
+
+}
Added: 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 (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/impl/HibernateDataSourcePropertyPage.java 2008-05-16 20:30:42 UTC (rev 8160)
@@ -0,0 +1,49 @@
+package org.jboss.tools.birt.oda.ui.impl;
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ *
+ ******************************************************************************/
+import java.util.Properties;
+
+import org.eclipse.datatools.connectivity.oda.design.ui.wizards.DataSourceEditorPage;
+import org.eclipse.swt.widgets.Composite;
+import org.jboss.tools.birt.oda.impl.HibernateConnection;
+
+/**
+ * Hibernate property page
+ *
+ * @author snjeza
+ **/
+public class HibernateDataSourcePropertyPage extends DataSourceEditorPage {
+
+ private HibernateSelectionPageHelper helper;
+
+ public HibernateDataSourcePropertyPage() {
+ super();
+ }
+
+ public Properties collectCustomProperties(Properties dataSourceProps) {
+ Properties props = dataSourceProps;
+ if (dataSourceProps == null) {
+ props = new Properties();
+ }
+ props.setProperty(HibernateConnection.CONFIGURATION, helper.getConfiguration());
+ props.setProperty(HibernateConnection.MAX_ROWS, helper.getMaxRows());
+ return props;
+ }
+
+ protected void createAndInitCustomControl(Composite parent,
+ Properties profileProps) {
+ if ( helper == null )
+ helper = new HibernateSelectionPageHelper( this );
+
+ helper.createCustomControl( parent );
+ setPingButtonVisible( false );
+ helper.initCustomControl( profileProps );
+ }
+
+}
Added: trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/impl/HibernateDataSourceWizardPage.java
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/impl/HibernateDataSourceWizardPage.java (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/impl/HibernateDataSourceWizardPage.java 2008-05-16 20:30:42 UTC (rev 8160)
@@ -0,0 +1,53 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ *
+ ******************************************************************************/
+package org.jboss.tools.birt.oda.ui.impl;
+
+import java.util.Properties;
+
+import org.eclipse.datatools.connectivity.oda.design.ui.wizards.DataSourceWizardPage;
+import org.eclipse.swt.widgets.Composite;
+/**
+ * Hibernate wizard page
+ *
+ * @author snjeza
+ **/
+public class HibernateDataSourceWizardPage extends DataSourceWizardPage {
+
+ private HibernateSelectionPageHelper helper;
+ private Properties folderProperties;
+
+ public HibernateDataSourceWizardPage(String pageName) {
+ super(pageName);
+ }
+
+ public Properties collectCustomProperties() {
+ if( helper != null )
+ return helper.collectCustomProperties( folderProperties );
+
+ return ( folderProperties != null ) ?
+ folderProperties : new Properties();
+ }
+
+ public void createPageCustomControl(Composite parent) {
+ if( helper == null )
+ helper = new HibernateSelectionPageHelper( this );
+ helper.createCustomControl( parent );
+ helper.initCustomControl( folderProperties );
+ this.setPingButtonVisible( false );
+ }
+
+ public void setInitialProperties(Properties dataSourceProps) {
+ folderProperties = dataSourceProps;
+ if( helper == null )
+ return;
+ helper.initCustomControl( folderProperties );
+ }
+
+
+}
Added: 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 (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/impl/HibernateSelectionPageHelper.java 2008-05-16 20:30:42 UTC (rev 8160)
@@ -0,0 +1,239 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ *
+ ******************************************************************************/
+package org.jboss.tools.birt.oda.ui.impl;
+
+import java.util.Properties;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.IMessageProvider;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.hibernate.HibernateException;
+import org.hibernate.SessionFactory;
+import org.hibernate.console.ConsoleConfiguration;
+import org.hibernate.console.KnownConfigurations;
+import org.jboss.tools.birt.oda.impl.HibernateConnection;
+import org.jboss.tools.birt.oda.ui.Activator;
+
+/**
+ * Helper class for Hibernate wizard and property page
+ *
+ * @author snjeza
+ *
+ */
+public class HibernateSelectionPageHelper {
+
+ private static final String DEFAULT_MAX_ROWS = "100";
+ private WizardPage wizardPage;
+ private PreferencePage propertyPage;
+ private Combo configurationCombo;
+ private Text maxRows;
+ private Button testButton;
+
+ public HibernateSelectionPageHelper(WizardPage page) {
+ this.wizardPage = page;
+ }
+
+ public HibernateSelectionPageHelper(PreferencePage page) {
+ propertyPage = page;
+ }
+
+ void createCustomControl(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 3;
+ layout.verticalSpacing = 10;
+ layout.marginBottom = 10;
+ composite.setLayout(layout);
+
+ GridData gridData;
+
+ Label configurationLabel = new Label(composite, SWT.RIGHT);
+ configurationLabel.setText("Configuration:");
+
+ configurationCombo = new Combo(composite, SWT.NONE);
+ gridData = new GridData();
+ gridData.horizontalSpan = 2;
+ gridData.horizontalAlignment = SWT.FILL;
+ gridData.grabExcessHorizontalSpace = true;
+ configurationCombo.setLayoutData(gridData);
+
+ ConsoleConfiguration[] configurations = KnownConfigurations
+ .getInstance().getConfigurations();
+ String[] configurationNames = new String[configurations.length];
+ for (int i = 0; i < configurations.length; i++) {
+ configurationNames[i] = configurations[i].getName();
+ }
+ configurationCombo.setItems(configurationNames);
+
+ Label maxFetchLabel = new Label(composite, SWT.NONE);
+ maxFetchLabel.setText("Max results:");
+
+ maxRows = new Text(composite, SWT.BORDER);
+ maxRows.setLayoutData(gridData);
+
+ configurationCombo.addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ validateData();
+ }
+
+ });
+
+ new Label(composite, SWT.NONE);
+ testButton = new Button(composite, SWT.PUSH);
+ testButton.setText("Test Connection...");
+
+ testButton.setLayoutData(new GridData(GridData.CENTER));
+ testButton.addSelectionListener(new SelectionAdapter() {
+
+ public void widgetSelected(SelectionEvent e) {
+ testConnection();
+ }
+
+ });
+
+ validateData();
+
+ }
+
+ private void setMessage(String message, int type) {
+ if (wizardPage != null)
+ wizardPage.setMessage(message, type);
+ else if (propertyPage != null)
+ propertyPage.setMessage(message, type);
+ }
+
+ private void setMessage(String message) {
+ if (wizardPage != null)
+ wizardPage.setMessage(message);
+ else if (propertyPage != null)
+ propertyPage.setMessage(message);
+ }
+
+ private void validateData() {
+ if (configurationCombo.getText().trim().length() > 0) {
+ setMessage("Edit the selected data source");
+ testButton.setEnabled(true);
+ setPageComplete(true);
+ } else {
+ setMessage("Configuration must not be empty",
+ IMessageProvider.ERROR);
+ testButton.setEnabled(false);
+ setPageComplete(false);
+ }
+ }
+
+ public void initCustomControl(Properties profileProps) {
+ if (profileProps != null) {
+ String confName = profileProps
+ .getProperty(HibernateConnection.CONFIGURATION);
+ if (confName != null) {
+ configurationCombo.setText(confName);
+ }
+ String maxResult = profileProps
+ .getProperty(HibernateConnection.MAX_ROWS);
+ maxRows.setText(maxResult);
+ } else {
+ if (configurationCombo.getItemCount() > 0) {
+ configurationCombo.select(0);
+ }
+ maxRows.setText(DEFAULT_MAX_ROWS);
+ }
+ }
+
+ protected void testConnection() {
+ String configurationName = configurationCombo.getText();
+ ConsoleConfiguration[] configurations = KnownConfigurations
+ .getInstance().getConfigurations();
+ ConsoleConfiguration consoleConfiguration = null;
+ String title = "Test connection";
+ for (int i = 0; i < configurations.length; i++) {
+ if (configurations[i].getName().equals(configurationName)) {
+ consoleConfiguration = configurations[i];
+ break;
+ }
+ }
+ if (consoleConfiguration != null) {
+ try {
+ SessionFactory sessionFactory = consoleConfiguration
+ .getSessionFactory();
+ if (sessionFactory == null) {
+ consoleConfiguration.build();
+ consoleConfiguration.buildSessionFactory();
+ sessionFactory = consoleConfiguration.getSessionFactory();
+ }
+ MessageDialog.openInformation(getShell(), title,
+ "Connection successfull.");
+ } catch (HibernateException e) {
+ String message = e.getLocalizedMessage();
+ IStatus status = new Status(Status.ERROR, Activator.PLUGIN_ID,
+ message, e);
+ Activator.getDefault().getLog().log(status);
+ ErrorDialog.openError(getShell(), title, message, status);
+ }
+ } else {
+ MessageDialog.openConfirm(getShell(), title,
+ "Invalid configuration '" + configurationName + "'.");
+
+ }
+
+ }
+
+ private Shell getShell() {
+ if (wizardPage != null)
+ return wizardPage.getShell();
+ if (propertyPage != null)
+ return propertyPage.getShell();
+ return null;
+ }
+
+ public String getConfiguration() {
+ return configurationCombo.getText();
+ }
+
+ public String getMaxRows() {
+ return maxRows.getText();
+ }
+
+ Properties collectCustomProperties(Properties props) {
+ if (props == null)
+ props = new Properties();
+
+ props
+ .setProperty(HibernateConnection.CONFIGURATION,
+ getConfiguration());
+ props.setProperty(HibernateConnection.MAX_ROWS, getMaxRows());
+ return props;
+ }
+
+ private void setPageComplete(boolean complete) {
+ if (wizardPage != null)
+ wizardPage.setPageComplete(complete);
+ else if (propertyPage != null)
+ propertyPage.setValid(complete);
+ }
+}
Added: trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/impl/TextMenuManager.java
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/impl/TextMenuManager.java (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda.ui/src/org/jboss/tools/birt/oda/ui/impl/TextMenuManager.java 2008-05-16 20:30:42 UTC (rev 8160)
@@ -0,0 +1,134 @@
+package org.jboss.tools.birt.oda.ui.impl;
+
+import java.util.Enumeration;
+import java.util.Hashtable;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.text.ITextOperationTarget;
+import org.eclipse.jface.text.TextViewer;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+
+
+/**
+ * Text menu manager contains 'undo,redo,cut,copy,paste,select all' menuItem. It
+ * displays on textVeiwer.
+ *
+ */
+class TextMenuManager
+{
+
+ private Hashtable htActions = new Hashtable( );
+ private MenuManager manager;
+
+ /**
+ * Constructor to specify the textMenuManager for a text viewer.
+ *
+ * @param viewer
+ */
+ TextMenuManager( TextViewer viewer )
+ {
+ manager = new MenuManager( );
+ Separator separator = new Separator( "undo" );//$NON-NLS-1$
+ manager.add( separator );
+ separator = new Separator( "copy" );//$NON-NLS-1$
+ manager.add( separator );
+ separator = new Separator( "select" );//$NON-NLS-1$
+ manager.add( separator );
+ manager.appendToGroup( "undo", getAction( "undo", viewer, "Undo", ITextOperationTarget.UNDO ) );
+ manager.appendToGroup( "undo", getAction( "redo", viewer, "Redo", ITextOperationTarget.REDO ) );
+ manager.appendToGroup( "copy", getAction( "cut", viewer, "Cut", ITextOperationTarget.CUT ) );
+ manager.appendToGroup( "copy", getAction( "copy", viewer, "Copy", ITextOperationTarget.COPY ) );//$NON-NLS-1$
+ manager.appendToGroup( "copy", getAction( "paste", viewer, "Paste", ITextOperationTarget.PASTE ) );//$NON-NLS-1$
+ manager.appendToGroup( "select", getAction( "selectall", viewer, "Select all", ITextOperationTarget.SELECT_ALL ) );//$NON-NLS-1$
+
+ manager.add( new Separator("hql") );
+ manager.appendToGroup( "hql", getAction("contentAssist", viewer, "Content Assist",13));
+ manager.appendToGroup( "hql", getAction("contentTip", viewer, "Content Tip",14));
+ manager.appendToGroup( "hql", getAction("format", viewer, "Format HQL source",15));
+
+ manager.addMenuListener( new IMenuListener( ) {
+
+ public void menuAboutToShow( IMenuManager manager )
+ {
+ Enumeration elements = htActions.elements( );
+ while ( elements.hasMoreElements( ) )
+ {
+ SourceViewerAction action = (SourceViewerAction) elements.nextElement( );
+ action.update( );
+ }
+ }
+ } );
+ }
+
+ /**
+ *
+ * @param control
+ * @return
+ */
+ public Menu getContextMenu( Control control )
+ {
+ return manager.createContextMenu( control );
+ }
+
+ /**
+ *
+ * @param id
+ * @param viewer
+ * @param name
+ * @param operation
+ * @return
+ */
+ private final SourceViewerAction getAction( String id, TextViewer viewer,
+ String name, int operation )
+ {
+ SourceViewerAction action = (SourceViewerAction) htActions.get( id );
+ if ( action == null )
+ {
+ action = new SourceViewerAction( viewer, name, operation );
+ htActions.put( id, action );
+ }
+ return action;
+ }
+
+
+ class SourceViewerAction extends Action
+ {
+
+ private int operationCode = -1;
+ private TextViewer viewer = null;
+
+ public SourceViewerAction( TextViewer viewer, String text,
+ int operationCode )
+ {
+ super( text );
+ this.operationCode = operationCode;
+ this.viewer = viewer;
+ }
+
+ /*
+ *
+ * @see org.eclipse.jface.action.IAction#run()
+ */
+ public void run( )
+ {
+ viewer.doOperation( operationCode );
+ }
+
+ /**
+ * update the operation
+ *
+ */
+ public void update( )
+ {
+ setEnabled( viewer.canDoOperation( operationCode ) );
+ }
+
+ }
+
+}
\ No newline at end of file
17 years, 11 months
JBoss Tools SVN: r8159 - trunk/birt/plugins.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-05-16 16:30:05 -0400 (Fri, 16 May 2008)
New Revision: 8159
Added:
trunk/birt/plugins/org.jboss.tools.birt.oda.ui/
Log:
Initial import.
17 years, 11 months
JBoss Tools SVN: r8158 - in trunk/birt/plugins/org.jboss.tools.birt.oda: META-INF and 7 other directories.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-05-16 16:29:20 -0400 (Fri, 16 May 2008)
New Revision: 8158
Added:
trunk/birt/plugins/org.jboss.tools.birt.oda/.classpath
trunk/birt/plugins/org.jboss.tools.birt.oda/.project
trunk/birt/plugins/org.jboss.tools.birt.oda/META-INF/
trunk/birt/plugins/org.jboss.tools.birt.oda/META-INF/MANIFEST.MF
trunk/birt/plugins/org.jboss.tools.birt.oda/build.properties
trunk/birt/plugins/org.jboss.tools.birt.oda/plugin.properties
trunk/birt/plugins/org.jboss.tools.birt.oda/plugin.xml
trunk/birt/plugins/org.jboss.tools.birt.oda/src/
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/Activator.java
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/DataTypes.java
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/HibernateDataSetMetaData.java
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateDriver.java
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateParameterMetaData.java
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateQuery.java
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateResultSet.java
trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateResultSetMetaData.java
Log:
Initial import.
Added: trunk/birt/plugins/org.jboss.tools.birt.oda/.classpath
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda/.classpath (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda/.classpath 2008-05-16 20:29:20 UTC (rev 8158)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Added: trunk/birt/plugins/org.jboss.tools.birt.oda/.project
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda/.project (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda/.project 2008-05-16 20:29:20 UTC (rev 8158)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.birt.oda</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
Added: trunk/birt/plugins/org.jboss.tools.birt.oda/META-INF/MANIFEST.MF
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda/META-INF/MANIFEST.MF (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda/META-INF/MANIFEST.MF 2008-05-16 20:29:20 UTC (rev 8158)
@@ -0,0 +1,16 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: %plugin.name
+Bundle-SymbolicName: org.jboss.tools.birt.oda;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-ClassPath: .
+Bundle-Activator: org.jboss.tools.birt.oda.Activator
+Bundle-Vendor: RedHat, Inc.
+Bundle-Localization: plugin
+Export-Package: org.jboss.tools.birt.oda.impl
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.datatools.connectivity.oda;bundle-version="[3.1.0,4.0.0)",
+ org.eclipse.datatools.connectivity.oda.profile;bundle-version="[3.0.4,4.0.0)",
+ org.hibernate.eclipse.console;visibility:=reexport,
+ org.hibernate.eclipse;visibility:=reexport
+Eclipse-LazyStart: true
Added: trunk/birt/plugins/org.jboss.tools.birt.oda/build.properties
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda/build.properties (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda/build.properties 2008-05-16 20:29:20 UTC (rev 8158)
@@ -0,0 +1,6 @@
+source.. = src/
+output.. = bin/
+bin.includes = plugin.xml,\
+ META-INF/,\
+ .,\
+ plugin.properties
Added: trunk/birt/plugins/org.jboss.tools.birt.oda/plugin.properties
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda/plugin.properties (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda/plugin.properties 2008-05-16 20:29:20 UTC (rev 8158)
@@ -0,0 +1,13 @@
+###############################################################################
+# Plug-in Configuration
+#
+oda.data.source.id=org.jboss.tools.birt.oda
+#
+###############################################################################
+# NLS String
+###############################################################################
+#
+plugin.name=Hibernate Data Source ODA Runtime Driver
+data.source.name=Hibernate Data Source
+data.set.name=Hibernate Data Set
+connection.profile.name=Hibernate Data Source Connection Profile
Added: trunk/birt/plugins/org.jboss.tools.birt.oda/plugin.xml
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda/plugin.xml (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda/plugin.xml 2008-05-16 20:29:20 UTC (rev 8158)
@@ -0,0 +1,100 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+
+ <extension
+ id="%oda.data.source.id"
+ point="org.eclipse.datatools.connectivity.oda.dataSource">
+ <dataSource
+ driverClass="org.jboss.tools.birt.oda.impl.HibernateDriver"
+ defaultDisplayName="%data.source.name"
+ setThreadContextClassLoader="false"
+ odaVersion="3.1"
+ id="%oda.data.source.id">
+ <properties>
+ <property
+ name="configuration"
+ allowsEmptyValueAsNull="true"
+ defaultDisplayName="Configuration"
+ type="string"
+ isEncryptable="false">
+ </property>
+ <property
+ allowsEmptyValueAsNull="true"
+ defaultDisplayName="Max results"
+ defaultValue="100"
+ isEncryptable="false"
+ name="maxRows"
+ type="string">
+ </property>
+ </properties>
+ </dataSource>
+ <dataSet
+ defaultDisplayName="%data.set.name"
+ id="org.jboss.tools.birt.oda.dataSet">
+ <dataTypeMapping
+ nativeDataTypeCode="1"
+ odaScalarDataType="String"
+ nativeDataType="String">
+ </dataTypeMapping>
+ <dataTypeMapping
+ nativeDataTypeCode="4"
+ odaScalarDataType="Integer"
+ nativeDataType="Integer">
+ </dataTypeMapping>
+ <dataTypeMapping
+ nativeDataTypeCode="8"
+ odaScalarDataType="Double"
+ nativeDataType="Double">
+ </dataTypeMapping>
+ <dataTypeMapping
+ nativeDataTypeCode="3"
+ odaScalarDataType="Decimal"
+ nativeDataType="BigDecimal">
+ </dataTypeMapping>
+ <dataTypeMapping
+ nativeDataTypeCode="91"
+ odaScalarDataType="Date"
+ nativeDataType="Date">
+ </dataTypeMapping>
+ <dataTypeMapping
+ nativeDataTypeCode="92"
+ odaScalarDataType="Time"
+ nativeDataType="Time">
+ </dataTypeMapping>
+ <dataTypeMapping
+ nativeDataTypeCode="93"
+ odaScalarDataType="Timestamp"
+ nativeDataType="Timestamp">
+ </dataTypeMapping>
+ <dataTypeMapping
+ nativeDataTypeCode="16"
+ odaScalarDataType="Boolean"
+ nativeDataType="Boolean">
+ </dataTypeMapping>
+ </dataSet>
+ </extension>
+ <!--
+ <extension
+ point="org.eclipse.datatools.connectivity.connectionProfile">
+ <category
+ name="%data.source.name"
+ parentCategory="org.eclipse.datatools.connectivity.oda.profileCategory"
+ id="%oda.data.source.id">
+ </category>
+ <connectionProfile
+ pingFactory="org.eclipse.datatools.connectivity.oda.profile.OdaConnectionFactory"
+ name="%connection.profile.name"
+ category="%oda.data.source.id"
+ id="%oda.data.source.id">
+ </connectionProfile>
+ <connectionFactory
+ name="ODA Connection Factory"
+ profile="%oda.data.source.id"
+ class="org.eclipse.datatools.connectivity.oda.profile.OdaConnectionFactory"
+ id="org.eclipse.datatools.connectivity.oda.IConnection">
+ </connectionFactory>
+ </extension>
+ -->
+
+</plugin>
Added: trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/Activator.java
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/Activator.java (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/Activator.java 2008-05-16 20:29:20 UTC (rev 8158)
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ *
+ ******************************************************************************/
+package org.jboss.tools.birt.oda;
+
+import org.eclipse.core.runtime.Plugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ *
+ * @author snjeza
+ */
+public class Activator extends Plugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "org.jboss.tools.birt.oda";
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+}
Added: trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/DataTypes.java
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/DataTypes.java (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/DataTypes.java 2008-05-16 20:29:20 UTC (rev 8158)
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * Copyright (c) 2004 Actuate Corporation.
+ * 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:
+ * Actuate Corporation - initial API and implementation
+ *******************************************************************************/
+package org.jboss.tools.birt.oda.impl;
+
+
+import java.sql.Types;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.datatools.connectivity.oda.OdaException;
+
+/**
+ * This class hosts the information of data types that are supported by flat
+ * file driver
+ */
+
+public final class DataTypes
+{
+
+ public static final String UNKNOWN = "UNKNOWN";
+ public static final int INT = Types.INTEGER;
+ public static final int LONG = Types.INTEGER;
+ public static final int SHORT = Types.INTEGER;
+ public static final int DOUBLE = Types.DOUBLE;
+ public static final int STRING = Types.VARCHAR;
+ public static final int DATE = Types.DATE;
+ public static final int TIME = Types.TIME;
+ public static final int TIMESTAMP = Types.TIMESTAMP;
+ public static final int BLOB = Types.BLOB;
+ public static final int BIGDECIMAL = Types.NUMERIC;
+ public static final int NULL = Types.NULL;
+
+ private static Map<String,Integer> typeStringIntPair = new HashMap<String,Integer>();
+
+ static
+ {
+ typeStringIntPair.put( "INTEGER", new Integer( INT ) ); //$NON-NLS-1$
+ typeStringIntPair.put( "INT", new Integer( INT ) ); //$NON-NLS-1$
+ typeStringIntPair.put( "LONG", new Integer( INT ) ); //$NON-NLS-1$
+ typeStringIntPair.put( "SHORT", new Integer( INT ) ); //$NON-NLS-1$
+ typeStringIntPair.put( "DOUBLE", new Integer( DOUBLE ) ); //$NON-NLS-1$
+ typeStringIntPair.put( "STRING", new Integer( STRING ) ); //$NON-NLS-1$
+ typeStringIntPair.put( "DATE", new Integer( DATE ) ); //$NON-NLS-1$
+ typeStringIntPair.put( "TIME", new Integer( TIME ) ); //$NON-NLS-1$
+ typeStringIntPair.put( "TIMESTAMP", new Integer( TIMESTAMP ) ); //$NON-NLS-1$
+ typeStringIntPair.put( "BLOB", new Integer( BLOB ) ); //$NON-NLS-1$
+ typeStringIntPair.put( "BIGDECIMAL", new Integer( BIGDECIMAL ) ); //$NON-NLS-1$
+ typeStringIntPair.put( "BIG_DECIMAL", new Integer( BIGDECIMAL ) ); //$NON-NLS-1$
+ typeStringIntPair.put( "BIG_INTEGER", new Integer( INT ) ); //$NON-NLS-1$
+ typeStringIntPair.put( "NULL", new Integer ( NULL ) );
+ typeStringIntPair.put( UNKNOWN, new Integer ( STRING ) );
+
+ }
+
+ /**
+ * Return the int which stands for the type specified by input argument
+ *
+ * @param typeName
+ * the String value of a Type
+ * @return the int which stands for the type specified by input typeName
+ * @throws OdaException
+ * Once the input argument is not a valid type name
+ */
+ public static int getType( String typeName ) throws OdaException
+ {
+ String name = typeName.trim( ).toUpperCase( );
+ while (name.indexOf(".") > 0) {
+ name = name.substring(name.indexOf(".")+1);
+ }
+ if ( typeStringIntPair.containsKey( name ) )
+ return ( (Integer) typeStringIntPair.get( name ) ).intValue( );
+ throw new OdaException( "Invalid type name : " + typeName);
+ }
+
+ /**
+ * Evaluate whether an input String is a valid type that is supported by driver
+ *
+ * @param typeName
+ * @return
+ */
+ public static boolean isValidType( String typeName )
+ {
+ String name = typeName.trim().toUpperCase();
+ boolean valid = typeStringIntPair.containsKey( name );
+ if (valid) {
+ return true;
+ }
+ while (name.indexOf(".") > 0) {
+ name = name.substring(name.indexOf(".")+1);
+ }
+ return typeStringIntPair.containsKey( name );
+ }
+
+ private DataTypes( )
+ {
+ }
+}
\ No newline at end of file
Added: 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 (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateConnection.java 2008-05-16 20:29:20 UTC (rev 8158)
@@ -0,0 +1,150 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ *
+ ******************************************************************************/
+package org.jboss.tools.birt.oda.impl;
+
+import java.util.Properties;
+
+import org.eclipse.datatools.connectivity.oda.IConnection;
+import org.eclipse.datatools.connectivity.oda.IDataSetMetaData;
+import org.eclipse.datatools.connectivity.oda.IQuery;
+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;
+
+/**
+ * Implementation class of IConnection for an ODA runtime driver.
+ *
+ * @author snjeza
+ */
+public class HibernateConnection implements IConnection
+{
+ public static final String MAX_ROWS = "maxRows";
+ public static final String CONFIGURATION = "configuration";
+ private boolean isOpen = false;
+ private ConsoleConfiguration consoleConfiguration;
+ private SessionFactory sessionFactory;
+ private Integer maxRows = -1;
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IConnection#open(java.util.Properties)
+ */
+ public void open( Properties connProperties ) throws OdaException
+ {
+ String configurationName = connProperties.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;
+ }
+ }
+ isOpen = (consoleConfiguration != null);
+ 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 + "'");
+ }
+ String maxRowString = connProperties.getProperty(MAX_ROWS);
+ try {
+ maxRows = new Integer(maxRowString);
+ } catch (NumberFormatException e) {
+ // ignore
+ }
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IConnection#setAppContext(java.lang.Object)
+ */
+ public void setAppContext( Object context ) throws OdaException
+ {
+ // do nothing; assumes no support for pass-through context
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IConnection#close()
+ */
+ public void close() throws OdaException
+ {
+ consoleConfiguration = null;
+ sessionFactory = null;
+ isOpen = false;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IConnection#isOpen()
+ */
+ public boolean isOpen() throws OdaException
+ {
+ return isOpen;
+ }
+
+ /*
+ * @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 );
+ }
+
+ /*
+ * @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
+ return new HibernateQuery(this);
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IConnection#getMaxQueries()
+ */
+ 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
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IConnection#rollback()
+ */
+ public void rollback() throws OdaException
+ {
+ // do nothing; assumes no transaction support needed
+ }
+
+ public Integer getMaxRows() {
+ return maxRows;
+ }
+
+ public SessionFactory getSessionFactory() {
+ return sessionFactory;
+ }
+
+}
Added: trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateDataSetMetaData.java
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateDataSetMetaData.java (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateDataSetMetaData.java 2008-05-16 20:29:20 UTC (rev 8158)
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ *
+ ******************************************************************************/
+
+package org.jboss.tools.birt.oda.impl;
+
+import org.eclipse.datatools.connectivity.oda.IConnection;
+import org.eclipse.datatools.connectivity.oda.IDataSetMetaData;
+import org.eclipse.datatools.connectivity.oda.IResultSet;
+import org.eclipse.datatools.connectivity.oda.OdaException;
+
+/**
+ * Implementation class of IDataSetMetaData for an ODA runtime driver.
+ *
+ * @author snjeza
+ */
+public class HibernateDataSetMetaData implements IDataSetMetaData
+{
+ private IConnection connection;
+
+ HibernateDataSetMetaData( IConnection connection )
+ {
+ this.connection = connection;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#getConnection()
+ */
+ public IConnection getConnection() throws OdaException
+ {
+ return connection;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#getDataSourceObjects(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
+ */
+ public IResultSet getDataSourceObjects( String catalog, String schema, String object, String version ) throws OdaException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#getDataSourceMajorVersion()
+ */
+ public int getDataSourceMajorVersion() throws OdaException
+ {
+ return 1;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#getDataSourceMinorVersion()
+ */
+ public int getDataSourceMinorVersion() throws OdaException
+ {
+ return 0;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#getDataSourceProductName()
+ */
+ public String getDataSourceProductName() throws OdaException
+ {
+ return "Hibernate Data Source";
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#getDataSourceProductVersion()
+ */
+ public String getDataSourceProductVersion() throws OdaException
+ {
+ return Integer.toString( getDataSourceMajorVersion() ) + "." + //$NON-NLS-1$
+ Integer.toString( getDataSourceMinorVersion() );
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#getSQLStateType()
+ */
+ public int getSQLStateType() throws OdaException
+ {
+ return IDataSetMetaData.sqlStateSQL99;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#supportsMultipleResultSets()
+ */
+ public boolean supportsMultipleResultSets() throws OdaException
+ {
+ return false;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#supportsMultipleOpenResults()
+ */
+ public boolean supportsMultipleOpenResults() throws OdaException
+ {
+ return false;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#supportsNamedResultSets()
+ */
+ public boolean supportsNamedResultSets() throws OdaException
+ {
+ return false;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#supportsNamedParameters()
+ */
+ public boolean supportsNamedParameters() throws OdaException
+ {
+ return false;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#supportsInParameters()
+ */
+ public boolean supportsInParameters() throws OdaException
+ {
+ return true;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#supportsOutParameters()
+ */
+ public boolean supportsOutParameters() throws OdaException
+ {
+ return false;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IDataSetMetaData#getSortMode()
+ */
+ public int getSortMode()
+ {
+ return IDataSetMetaData.sortModeNone;
+ }
+
+}
Added: trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateDriver.java
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateDriver.java (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateDriver.java 2008-05-16 20:29:20 UTC (rev 8158)
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ *
+ ******************************************************************************/
+package org.jboss.tools.birt.oda.impl;
+
+import org.eclipse.datatools.connectivity.oda.IConnection;
+import org.eclipse.datatools.connectivity.oda.IDriver;
+import org.eclipse.datatools.connectivity.oda.LogConfiguration;
+import org.eclipse.datatools.connectivity.oda.OdaException;
+import org.eclipse.datatools.connectivity.oda.util.manifest.DataTypeMapping;
+import org.eclipse.datatools.connectivity.oda.util.manifest.ExtensionManifest;
+import org.eclipse.datatools.connectivity.oda.util.manifest.ManifestExplorer;
+
+/**
+ * Implementation class of IDriver for an ODA runtime driver.
+ *
+ * @author snjeza
+ *
+ */
+public class HibernateDriver implements IDriver
+{
+ static String ODA_DATA_SOURCE_ID = "org.jboss.tools.birt.oda"; //$NON-NLS-1$
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IDriver#getConnection(java.lang.String)
+ */
+ public IConnection getConnection( String dataSourceType ) throws OdaException
+ {
+ // assumes that this driver supports only one type of data source,
+ // ignores the specified dataSourceType
+ return new HibernateConnection();
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IDriver#setLogConfiguration(org.eclipse.datatools.connectivity.oda.LogConfiguration)
+ */
+ public void setLogConfiguration( LogConfiguration logConfig ) throws OdaException
+ {
+ // do nothing; assumes simple driver has no logging
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IDriver#getMaxConnections()
+ */
+ public int getMaxConnections() throws OdaException
+ {
+ return 0; // no limit
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IDriver#setAppContext(java.lang.Object)
+ */
+ public void setAppContext( Object context ) throws OdaException
+ {
+ // do nothing; assumes no support for pass-through context
+ }
+
+ /**
+ * Returns the object that represents this extension's manifest.
+ * @throws OdaException
+ */
+ static ExtensionManifest getManifest()
+ throws OdaException
+ {
+ return ManifestExplorer.getInstance()
+ .getExtensionManifest( ODA_DATA_SOURCE_ID );
+ }
+
+ /**
+ * Returns the native data type name of the specified code, as
+ * defined in this data source extension's manifest.
+ * @param nativeTypeCode the native data type code
+ * @return corresponding native data type name
+ * @throws OdaException if lookup fails
+ */
+ static String getNativeDataTypeName( int nativeDataTypeCode )
+ throws OdaException
+ {
+ DataTypeMapping typeMapping =
+ getManifest().getDataSetType( null )
+ .getDataTypeMapping( nativeDataTypeCode );
+ if( typeMapping != null )
+ return typeMapping.getNativeType();
+ return "Non-defined";
+ }
+
+}
Added: trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateParameterMetaData.java
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateParameterMetaData.java (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateParameterMetaData.java 2008-05-16 20:29:20 UTC (rev 8158)
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ *
+ ******************************************************************************/
+
+package org.jboss.tools.birt.oda.impl;
+
+import org.eclipse.datatools.connectivity.oda.IParameterMetaData;
+import org.eclipse.datatools.connectivity.oda.OdaException;
+
+/**
+ * Implementation class of IParameterMetaData for an ODA runtime driver.
+ *
+ * @author snjeza
+ */
+public class HibernateParameterMetaData implements IParameterMetaData
+{
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IParameterMetaData#getParameterCount()
+ */
+ public int getParameterCount() throws OdaException
+ {
+ return 0;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IParameterMetaData#getParameterMode(int)
+ */
+ public int getParameterMode( int param ) throws OdaException
+ {
+ return IParameterMetaData.parameterModeIn;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.datatools.connectivity.oda.IParameterMetaData#getParameterName(int)
+ */
+ public String getParameterName( int param ) throws OdaException
+ {
+ return null; // name is not available
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IParameterMetaData#getParameterType(int)
+ */
+ public int getParameterType( int param ) throws OdaException
+ {
+ return java.sql.Types.CHAR; // as defined in data set extension manifest
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IParameterMetaData#getParameterTypeName(int)
+ */
+ public String getParameterTypeName( int param ) throws OdaException
+ {
+ int nativeTypeCode = getParameterType( param );
+ return HibernateDriver.getNativeDataTypeName( nativeTypeCode );
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IParameterMetaData#getPrecision(int)
+ */
+ public int getPrecision( int param ) throws OdaException
+ {
+ return -1;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IParameterMetaData#getScale(int)
+ */
+ public int getScale( int param ) throws OdaException
+ {
+ return -1;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IParameterMetaData#isNullable(int)
+ */
+ public int isNullable( int param ) throws OdaException
+ {
+ return IParameterMetaData.parameterNullableUnknown;
+ }
+
+}
Added: trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateQuery.java
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateQuery.java (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateQuery.java 2008-05-16 20:29:20 UTC (rev 8158)
@@ -0,0 +1,430 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ *
+ ******************************************************************************/
+package org.jboss.tools.birt.oda.impl;
+
+import java.math.BigDecimal;
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.eclipse.datatools.connectivity.oda.IParameterMetaData;
+import org.eclipse.datatools.connectivity.oda.IResultSet;
+import org.eclipse.datatools.connectivity.oda.IResultSetMetaData;
+import org.eclipse.datatools.connectivity.oda.IQuery;
+import org.eclipse.datatools.connectivity.oda.OdaException;
+import org.eclipse.datatools.connectivity.oda.SortSpec;
+import org.hibernate.Query;
+import org.hibernate.Session;
+import org.hibernate.SessionFactory;
+import org.hibernate.type.Type;
+
+/**
+ * Implementation class of IQuery for an ODA runtime driver.
+ *
+ * @author snjeza
+ */
+public class HibernateQuery implements IQuery
+{
+ private Integer _maxRows;
+ private HibernateConnection connection;
+ private HibernateResultSetMetaData resultSetMetaData;
+ private String queryText;
+
+ public HibernateQuery(HibernateConnection connection) {
+ this.connection = connection;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#prepare(java.lang.String)
+ */
+ public void 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 = connection.getSessionFactory().openSession();
+ Query query = session.createQuery(queryText);
+ int maxRows = connection.getMaxRows();
+ if (maxRows > 0) {
+ query.setFirstResult(0);
+ query.setMaxResults(maxRows);
+ }
+ _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('.', ':');
+ }
+
+ this.resultSetMetaData = 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 = connection.getSessionFactory();
+ String[] properties = sf.getClassMetadata(className).getPropertyNames();
+ return( properties);
+ }
+
+ private String getHibernatePropTypes(String className, String property){
+ SessionFactory sf = connection.getSessionFactory();
+ Type hibClassProps = sf.getClassMetadata(className).getPropertyType(property);
+ return(hibClassProps.getName());
+
+ }
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setAppContext(java.lang.Object)
+ */
+ public void setAppContext( Object context ) throws OdaException
+ {
+ // do nothing; assumes no support for pass-through context
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#close()
+ */
+ public void close() throws OdaException
+ {
+ // TODO Auto-generated method stub
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#getMetaData()
+ */
+ public IResultSetMetaData getMetaData() throws OdaException
+ {
+ return this.resultSetMetaData;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#executeQuery()
+ */
+ public IResultSet executeQuery() throws OdaException
+ {
+ try {
+ return new HibernateResultSet(this);
+ } catch (Exception e) {
+ throw new OdaException(e.getLocalizedMessage());
+ }
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setProperty(java.lang.String, java.lang.String)
+ */
+ public void setProperty( String name, String value ) throws OdaException
+ {
+ // do nothing; assumes no data set query property
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setMaxRows(int)
+ */
+ public void setMaxRows( int max ) throws OdaException
+ {
+ _maxRows = max;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#getMaxRows()
+ */
+ public int getMaxRows() throws OdaException
+ {
+ return _maxRows;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#clearInParameters()
+ */
+ public void clearInParameters() throws OdaException
+ {
+ // TODO Auto-generated method stub
+ // only applies to input parameter
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setInt(java.lang.String, int)
+ */
+ public void setInt( String parameterName, int value ) throws OdaException
+ {
+ // TODO Auto-generated method stub
+ // only applies to named input parameter
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setInt(int, int)
+ */
+ public void setInt( int parameterId, int value ) throws OdaException
+ {
+ // TODO Auto-generated method stub
+ // only applies to input parameter
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setDouble(java.lang.String, double)
+ */
+ public void setDouble( String parameterName, double value ) throws OdaException
+ {
+ // TODO Auto-generated method stub
+ // only applies to named input parameter
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setDouble(int, double)
+ */
+ public void setDouble( int parameterId, double value ) throws OdaException
+ {
+ // TODO Auto-generated method stub
+ // only applies to input parameter
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setBigDecimal(java.lang.String, java.math.BigDecimal)
+ */
+ public void setBigDecimal( String parameterName, BigDecimal value ) throws OdaException
+ {
+ // TODO Auto-generated method stub
+ // only applies to named input parameter
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setBigDecimal(int, java.math.BigDecimal)
+ */
+ public void setBigDecimal( int parameterId, BigDecimal value ) throws OdaException
+ {
+ // TODO Auto-generated method stub
+ // only applies to input parameter
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setString(java.lang.String, java.lang.String)
+ */
+ public void setString( String parameterName, String value ) throws OdaException
+ {
+ // TODO Auto-generated method stub
+ // only applies to named input parameter
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setString(int, java.lang.String)
+ */
+ public void setString( int parameterId, String value ) throws OdaException
+ {
+ // TODO Auto-generated method stub
+ // only applies to input parameter
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setDate(java.lang.String, java.sql.Date)
+ */
+ public void setDate( String parameterName, Date value ) throws OdaException
+ {
+ // TODO Auto-generated method stub
+ // only applies to named input parameter
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setDate(int, java.sql.Date)
+ */
+ public void setDate( int parameterId, Date value ) throws OdaException
+ {
+ // TODO Auto-generated method stub
+ // only applies to input parameter
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setTime(java.lang.String, java.sql.Time)
+ */
+ public void setTime( String parameterName, Time value ) throws OdaException
+ {
+ // TODO Auto-generated method stub
+ // only applies to named input parameter
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setTime(int, java.sql.Time)
+ */
+ public void setTime( int parameterId, Time value ) throws OdaException
+ {
+ // TODO Auto-generated method stub
+ // only applies to input parameter
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setTimestamp(java.lang.String, java.sql.Timestamp)
+ */
+ public void setTimestamp( String parameterName, Timestamp value ) throws OdaException
+ {
+ // TODO Auto-generated method stub
+ // only applies to named input parameter
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setTimestamp(int, java.sql.Timestamp)
+ */
+ public void setTimestamp( int parameterId, Timestamp value ) throws OdaException
+ {
+ // TODO Auto-generated method stub
+ // only applies to input parameter
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setBoolean(java.lang.String, boolean)
+ */
+ public void setBoolean( String parameterName, boolean value )
+ throws OdaException
+ {
+ // TODO Auto-generated method stub
+ // only applies to named input parameter
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setBoolean(int, boolean)
+ */
+ public void setBoolean( int parameterId, boolean value )
+ throws OdaException
+ {
+ // TODO Auto-generated method stub
+ // only applies to input parameter
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setNull(java.lang.String)
+ */
+ public void setNull( String parameterName ) throws OdaException
+ {
+ // TODO Auto-generated method stub
+ // only applies to named input parameter
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setNull(int)
+ */
+ public void setNull( int parameterId ) throws OdaException
+ {
+ // TODO Auto-generated method stub
+ // only applies to input parameter
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#findInParameter(java.lang.String)
+ */
+ public int findInParameter( String parameterName ) throws OdaException
+ {
+ // TODO Auto-generated method stub
+ // only applies to named input parameter
+ return 0;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#getParameterMetaData()
+ */
+ public IParameterMetaData getParameterMetaData() throws OdaException
+ {
+ /* TODO Auto-generated method stub
+ * Replace with implementation to return an instance
+ * based on this prepared query.
+ */
+ return new HibernateParameterMetaData();
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#setSortSpec(org.eclipse.datatools.connectivity.oda.SortSpec)
+ */
+ public void setSortSpec( SortSpec sortBy ) throws OdaException
+ {
+ // TODO Auto-generated method stub
+ // only applies to sorting, assumes not supported
+ throw new UnsupportedOperationException();
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IQuery#getSortSpec()
+ */
+ public SortSpec getSortSpec() throws OdaException
+ {
+ // TODO Auto-generated method stub
+ // only applies to sorting
+ return null;
+ }
+
+ public HibernateConnection getConnection() {
+ return connection;
+ }
+
+ public String getQueryText() {
+ return queryText;
+ }
+
+}
Added: trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateResultSet.java
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateResultSet.java (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateResultSet.java 2008-05-16 20:29:20 UTC (rev 8158)
@@ -0,0 +1,418 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ *
+ ******************************************************************************/
+
+package org.jboss.tools.birt.oda.impl;
+
+import java.math.BigDecimal;
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.datatools.connectivity.oda.IBlob;
+import org.eclipse.datatools.connectivity.oda.IClob;
+import org.eclipse.datatools.connectivity.oda.IResultSet;
+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.SessionFactory;
+import org.hibernate.classic.Session;
+import org.hibernate.metadata.ClassMetadata;
+import org.hibernate.type.Type;
+
+/**
+ * Implementation class of IResultSet for an ODA runtime driver.
+ *
+ * @author snjeza
+ */
+public class HibernateResultSet implements IResultSet {
+ private int _maxRows;
+ private HibernateQuery query;
+ private List result;
+ private Iterator iterator;
+ private Object currentRow;
+ private int rowNumber = -1;
+ private boolean wasNull;
+ private Type[] queryReturnTypes;
+ private static DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
+ private Session session;
+
+ public HibernateResultSet(HibernateQuery query) throws OdaException {
+ this.query = query;
+ try {
+ _maxRows = query.getMaxRows();
+ } catch (OdaException e) {
+ // ignore
+ }
+ try {
+ session = query.getConnection().getSessionFactory().openSession();
+ Query q = session.createQuery(query.getQueryText());
+ result = q.list();
+ iterator = result.iterator();
+ this.queryReturnTypes = q.getReturnTypes();
+ } catch (HibernateException e) {
+ throw new OdaException(e.getLocalizedMessage());
+ }
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSet#getMetaData()
+ */
+ public IResultSetMetaData getMetaData() throws OdaException {
+ return query.getMetaData();
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSet#setMaxRows(int)
+ */
+ public void setMaxRows(int max) throws OdaException {
+ _maxRows = max;
+ }
+
+ /**
+ * Returns the maximum number of rows that can be fetched from this result
+ * set.
+ *
+ * @return the maximum number of rows to fetch.
+ */
+ protected int getMaxRows() {
+ return _maxRows;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSet#next()
+ */
+ public boolean next() throws OdaException {
+ if (iterator.hasNext()) {
+ currentRow = iterator.next();
+ rowNumber++;
+ return true;
+ }
+ return false;
+
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSet#close()
+ */
+ public void close() throws OdaException {
+ if (result != null)
+ result.clear();
+ if (session != null)
+ session.close();
+ result = null;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSet#getRow()
+ */
+ public int getRow() throws OdaException {
+ testFetchStarted();
+ return rowNumber + 1;
+ }
+
+ private 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 = query.getConnection().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);
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSet#getString(int)
+ */
+ public String getString(int index) throws OdaException {
+ String result;
+ testFetchStarted();
+ Object rObj = getResult(index);
+ if (rObj == null) {
+ result = null;
+ } else {
+ result = rObj.toString();
+ }
+ this.wasNull = (result == null);
+ return result;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSet#getString(java.lang.String)
+ */
+ public String getString(String columnName) throws OdaException {
+ return getString(findColumn(columnName));
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSet#getInt(int)
+ */
+ public int getInt(int index) throws OdaException {
+ int result;
+ testFetchStarted();
+ Object rObj = getResult(index);
+ if (rObj == null) {
+ result = 0;
+ this.wasNull = true;
+ } else {
+ this.wasNull = false;
+ if (rObj instanceof Integer)
+ result = ((Integer) rObj).intValue();
+ else if (rObj instanceof Long)
+ result = ((Long) rObj).intValue();
+ else if (rObj instanceof Short)
+ result = ((Short) rObj).intValue();
+ else
+ throw new RuntimeException("The " + rObj.getClass() + " data type is not valid.");
+ }
+
+ return result;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSet#getInt(java.lang.String)
+ */
+ public int getInt(String columnName) throws OdaException {
+ return getInt(findColumn(columnName));
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSet#getDouble(int)
+ */
+ public double getDouble(int index) throws OdaException {
+ double result;
+ testFetchStarted();
+ Object rObj = getResult(index);
+ if (rObj == null) {
+ result = 0;
+ this.wasNull = true;
+ } else {
+ this.wasNull = false;
+ result = ((Double) rObj).doubleValue();
+ }
+
+ return result;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSet#getDouble(java.lang.String)
+ */
+ public double getDouble(String columnName) throws OdaException {
+ return getDouble(findColumn(columnName));
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSet#getBigDecimal(int)
+ */
+ public BigDecimal getBigDecimal(int index) throws OdaException {
+ BigDecimal result;
+ testFetchStarted();
+ Object rObj = getResult(index);
+ if (rObj == null) {
+ result = new BigDecimal(0);
+ this.wasNull = true;
+ } else {
+ this.wasNull = false;
+ result = (BigDecimal) rObj;
+ }
+
+ return result;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSet#getBigDecimal(java.lang.String)
+ */
+ public BigDecimal getBigDecimal(String columnName) throws OdaException {
+ return getBigDecimal(findColumn(columnName));
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSet#getDate(int)
+ */
+ public Date getDate(int index) throws OdaException {
+ Date result = null;
+ testFetchStarted();
+ Object rObj = getResult(index);
+ if (rObj == null) {
+ this.wasNull = true;
+ } else {
+ this.wasNull = false;
+ if (rObj instanceof String) {
+ try {
+ result = new Date(dateFormat.parse((String) rObj).getTime());
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ } else {
+ result = (Date) rObj;
+ }
+ }
+
+ return result;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSet#getDate(java.lang.String)
+ */
+ public Date getDate(String columnName) throws OdaException {
+ return getDate(findColumn(columnName));
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSet#getTime(int)
+ */
+ public Time getTime(int index) throws OdaException {
+ Time result = null;
+ testFetchStarted();
+ Object rObj = getResult(index);
+ if (rObj == null) {
+ this.wasNull = true;
+ } else {
+ this.wasNull = false;
+ result = (Time) rObj;
+ }
+ return result;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSet#getTime(java.lang.String)
+ */
+ public Time getTime(String columnName) throws OdaException {
+ return getTime(findColumn(columnName));
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSet#getTimestamp(int)
+ */
+ public Timestamp getTimestamp(int index) throws OdaException {
+ Timestamp result = null;
+ testFetchStarted();
+ Object rObj = getResult(index);
+ if (rObj == null) {
+ this.wasNull = true;
+ } else {
+ this.wasNull = false;
+ result = (Timestamp) rObj;
+ }
+ return result;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSet#getTimestamp(java.lang.String)
+ */
+ public Timestamp getTimestamp(String columnName) throws OdaException {
+ return getTimestamp(findColumn(columnName));
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSet#getBlob(int)
+ */
+ public IBlob getBlob(int index) throws OdaException {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException();
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSet#getBlob(java.lang.String)
+ */
+ public IBlob getBlob(String columnName) throws OdaException {
+ return getBlob(findColumn(columnName));
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSet#getClob(int)
+ */
+ public IClob getClob(int index) throws OdaException {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException();
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSet#getClob(java.lang.String)
+ */
+ public IClob getClob(String columnName) throws OdaException {
+ return getClob(findColumn(columnName));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.datatools.connectivity.oda.IResultSet#getBoolean(int)
+ */
+ public boolean getBoolean(int index) throws OdaException {
+ // TODO Auto-generated method stub
+ throw new UnsupportedOperationException();
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.datatools.connectivity.oda.IResultSet#getBoolean(java.lang.String)
+ */
+ public boolean getBoolean(String columnName) throws OdaException {
+ return getBoolean(findColumn(columnName));
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSet#wasNull()
+ */
+ public boolean wasNull() throws OdaException {
+ return wasNull;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSet#findColumn(java.lang.String)
+ */
+ public int findColumn(String columnName) throws OdaException {
+ // TODO replace with data source specific implementation
+
+ // hard-coded for demo purpose
+ int columnId = 1; // dummy column id
+ if (columnName == null || columnName.length() == 0)
+ return columnId;
+ String lastChar = columnName.substring(columnName.length() - 1, 1);
+ try {
+ columnId = Integer.parseInt(lastChar);
+ } catch (NumberFormatException e) {
+ // ignore, use dummy column id
+ }
+ return columnId;
+ }
+
+ private void testFetchStarted() throws OdaException {
+ if (rowNumber < 0)
+ throw new OdaException("Cursor has not been initialized");
+ }
+
+}
Added: trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateResultSetMetaData.java
===================================================================
--- trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateResultSetMetaData.java (rev 0)
+++ trunk/birt/plugins/org.jboss.tools.birt.oda/src/org/jboss/tools/birt/oda/impl/HibernateResultSetMetaData.java 2008-05-16 20:29:20 UTC (rev 8158)
@@ -0,0 +1,164 @@
+/*******************************************************************************
+ * Copyright (c) 2007 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
+ *
+ ******************************************************************************/
+
+package org.jboss.tools.birt.oda.impl;
+
+import java.util.StringTokenizer;
+
+import org.eclipse.datatools.connectivity.oda.IResultSetMetaData;
+import org.eclipse.datatools.connectivity.oda.OdaException;
+import org.hibernate.Query;
+import org.hibernate.type.Type;
+
+/**
+ * Implementation class of IResultSetMetaData for an ODA runtime driver.
+ *
+ * @author snjeza
+ */
+public class HibernateResultSetMetaData implements IResultSetMetaData
+{
+
+ private String[] columnName = null;
+ private String[] columnType = null;
+ private String[] columnLabel = null;
+ private String[] columnClass = null;
+ private HibernateQuery query;
+
+ HibernateResultSetMetaData( String[] cName, String[] cType, String[] cLabel, String[] cClass )
+ throws OdaException
+ {
+ if ( cName == null )
+ throw new OdaException( "Argument cannot be null" );
+ this.columnName = cName;
+ this.columnType = cType;
+ this.columnLabel = cLabel;
+ this.columnClass = cClass;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSetMetaData#getColumnCount()
+ */
+ public int getColumnCount() throws OdaException
+ {
+ return columnName.length;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSetMetaData#getColumnName(int)
+ */
+ public String getColumnName( int index ) throws OdaException
+ {
+ assertIndexValid( index );
+ String name = this.columnName[index - 1].trim( );
+ if (name.indexOf(" ") > 0) {
+ StringTokenizer tokenizer = new StringTokenizer(name," ");
+ String prettyName = null;
+ while (tokenizer.hasMoreTokens()) {
+ prettyName = tokenizer.nextToken();
+ }
+ if (prettyName != null) {
+ name = prettyName;
+ }
+ }
+ return name;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSetMetaData#getColumnLabel(int)
+ */
+ public String getColumnLabel( int index ) throws OdaException
+ {
+ assertIndexValid( index );
+ //"null" in lower case is the mark of "null value". We should not use
+ // "equalsIgnoreCase"
+ //here for "null" is not a keyword so that we cannot prevent user from
+ // using "null" as labels of
+ //certain columns.
+ if ( this.columnLabel == null
+ || this.columnLabel[index - 1].equals( "null" ) ) //$NON-NLS-1$
+ return this.getColumnName( index );
+
+ return this.columnLabel[index - 1].trim( );
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSetMetaData#getColumnType(int)
+ */
+ public int getColumnType( int index ) throws OdaException
+ {
+ assertIndexValid( index );
+ //get the integer value of the data type specified
+ return (this.columnType[index - 1] == null)? DataTypes.NULL : DataTypes.getType( columnType[index - 1] ) ;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSetMetaData#getColumnTypeName(int)
+ */
+ public String getColumnTypeName( int index ) throws OdaException
+ {
+ int nativeTypeCode = getColumnType( index );
+ return HibernateDriver.getNativeDataTypeName( nativeTypeCode );
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSetMetaData#getColumnDisplayLength(int)
+ */
+ public int getColumnDisplayLength( int index ) throws OdaException
+ {
+ // TODO replace with data source specific implementation
+ return 8;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSetMetaData#getPrecision(int)
+ */
+ public int getPrecision( int index ) throws OdaException
+ {
+ // TODO Auto-generated method stub
+ return -1;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSetMetaData#getScale(int)
+ */
+ public int getScale( int index ) throws OdaException
+ {
+ // TODO Auto-generated method stub
+ return -1;
+ }
+
+ /*
+ * @see org.eclipse.datatools.connectivity.oda.IResultSetMetaData#isNullable(int)
+ */
+ public int isNullable( int index ) throws OdaException
+ {
+ // TODO Auto-generated method stub
+ return IResultSetMetaData.columnNullableUnknown;
+ }
+
+ /**
+ * Evaluate whether the value of an index is valid
+ *
+ * @param index
+ * the value of an index
+ * @throws OdaException
+ * if the value is
+ */
+ private void assertIndexValid( int index ) throws OdaException
+ {
+ if ( index > getColumnCount( ) || index < 1 )
+ throw new OdaException( "Invalid index " + index );
+ }
+
+ public String getColumnClass( int index ) throws OdaException
+ {
+ assertIndexValid( index );
+ return ( this.columnClass[index - 1] ) ;
+ }
+}
17 years, 11 months
JBoss Tools SVN: r8157 - trunk/birt/plugins.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-05-16 16:28:50 -0400 (Fri, 16 May 2008)
New Revision: 8157
Added:
trunk/birt/plugins/org.jboss.tools.birt.oda/
Log:
Initial import.
17 years, 11 months
JBoss Tools SVN: r8156 - trunk/birt/features/org.jboss.tools.birt.feature.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-05-16 16:27:59 -0400 (Fri, 16 May 2008)
New Revision: 8156
Added:
trunk/birt/features/org.jboss.tools.birt.feature/.project
trunk/birt/features/org.jboss.tools.birt.feature/build.properties
trunk/birt/features/org.jboss.tools.birt.feature/feature.properties
trunk/birt/features/org.jboss.tools.birt.feature/feature.xml
Log:
Initial import.
Added: trunk/birt/features/org.jboss.tools.birt.feature/.project
===================================================================
--- trunk/birt/features/org.jboss.tools.birt.feature/.project (rev 0)
+++ trunk/birt/features/org.jboss.tools.birt.feature/.project 2008-05-16 20:27:59 UTC (rev 8156)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jboss.tools.birt.feature</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.pde.FeatureBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.FeatureNature</nature>
+ </natures>
+</projectDescription>
Added: trunk/birt/features/org.jboss.tools.birt.feature/build.properties
===================================================================
--- trunk/birt/features/org.jboss.tools.birt.feature/build.properties (rev 0)
+++ trunk/birt/features/org.jboss.tools.birt.feature/build.properties 2008-05-16 20:27:59 UTC (rev 8156)
@@ -0,0 +1,2 @@
+bin.includes = feature.xml,\
+ feature.properties
Added: trunk/birt/features/org.jboss.tools.birt.feature/feature.properties
===================================================================
Added: trunk/birt/features/org.jboss.tools.birt.feature/feature.xml
===================================================================
--- trunk/birt/features/org.jboss.tools.birt.feature/feature.xml (rev 0)
+++ trunk/birt/features/org.jboss.tools.birt.feature/feature.xml 2008-05-16 20:27:59 UTC (rev 8156)
@@ -0,0 +1,240 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+ id="org.jboss.tools.birt.feature"
+ label="JBoss BIRT Integration"
+ version="1.0.0"
+ provider-name="RedHat, Inc."
+ plugin="org.jboss.tools.birt.oda.ui">
+
+ <description url="http://www.example.com/description">
+ JBoss BIRT Integration
+ </description>
+
+ <copyright>
+ Copyright (c) 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
+Contributors:
+Red Hat, Inc. - initial API and implementation
+ </copyright>
+
+ <license url="http://www.eclipse.org/legal/epl-v10.html">
+ Eclipse Public License - v 1.0
+THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS
+ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR
+DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE
+OF THIS AGREEMENT.
+1. DEFINITIONS
+"Contribution" means:
+a) in the case of the initial Contributor, the initial code and
+documentation distributed under this Agreement, and
+b) in the case of each subsequent Contributor:
+i) changes to the Program, and
+ii) additions to the Program;
+where such changes and/or additions to the Program originate
+from and are distributed by that particular Contributor. A Contribution
+'originates' from a Contributor if it was added to the Program
+by such Contributor itself or anyone acting on such Contributor's
+behalf. Contributions do not include additions to the Program
+which: (i) are separate modules of software distributed in conjunction
+with the Program under their own license agreement, and (ii)
+are not derivative works of the Program.
+"Contributor" means any person or entity that distributes the
+Program.
+"Licensed Patents " mean patent claims licensable by a Contributor
+which are necessarily infringed by the use or sale of its Contribution
+alone or when combined with the Program.
+"Program" means the Contributions distributed in accordance with
+this Agreement.
+"Recipient" means anyone who receives the Program under this
+Agreement, including all Contributors.
+2. GRANT OF RIGHTS
+a) Subject to the terms of this Agreement, each Contributor hereby
+grants Recipient a non-exclusive, worldwide, royalty-free copyright
+license to reproduce, prepare derivative works of, publicly display,
+publicly perform, distribute and sublicense the Contribution
+of such Contributor, if any, and such derivative works, in source
+code and object code form.
+b) Subject to the terms of this Agreement, each Contributor hereby
+grants Recipient a non-exclusive, worldwide, royalty-free patent
+license under Licensed Patents to make, use, sell, offer to sell,
+import and otherwise transfer the Contribution of such Contributor,
+if any, in source code and object code form. This patent license
+shall apply to the combination of the Contribution and the Program
+if, at the time the Contribution is added by the Contributor,
+such addition of the Contribution causes such combination to
+be covered by the Licensed Patents. The patent license shall
+not apply to any other combinations which include the Contribution.
+No hardware per se is licensed hereunder.
+c) Recipient understands that although each Contributor grants
+the licenses to its Contributions set forth herein, no assurances
+are provided by any Contributor that the Program does not infringe
+the patent or other intellectual property rights of any other
+entity. Each Contributor disclaims any liability to Recipient
+for claims brought by any other entity based on infringement
+of intellectual property rights or otherwise. As a condition
+to exercising the rights and licenses granted hereunder, each
+Recipient hereby assumes sole responsibility to secure any other
+intellectual property rights needed, if any. For example, if
+a third party patent license is required to allow Recipient to
+distribute the Program, it is Recipient's responsibility to acquire
+that license before distributing the Program.
+d) Each Contributor represents that to its knowledge it has sufficient
+copyright rights in its Contribution, if any, to grant the copyright
+license set forth in this Agreement.
+3. REQUIREMENTS
+A Contributor may choose to distribute the Program in object
+code form under its own license agreement, provided that:
+a) it complies with the terms and conditions of this Agreement;
+and
+b) its license agreement:
+i) effectively disclaims on behalf of all Contributors all warranties
+and conditions, express and implied, including warranties or
+conditions of title and non-infringement, and implied warranties
+or conditions of merchantability and fitness for a particular
+purpose;
+ii) effectively excludes on behalf of all Contributors all liability
+for damages, including direct, indirect, special, incidental
+and consequential damages, such as lost profits;
+iii) states that any provisions which differ from this Agreement
+are offered by that Contributor alone and not by any other party;
+and
+iv) states that source code for the Program is available from
+such Contributor, and informs licensees how to obtain it in a
+reasonable manner on or through a medium customarily used for
+software exchange.
+When the Program is made available in source code form:
+a) it must be made available under this Agreement; and
+b) a copy of this Agreement must be included with each copy of
+the Program.
+Contributors may not remove or alter any copyright notices contained
+within the Program.
+Each Contributor must identify itself as the originator of its
+Contribution, if any, in a manner that reasonably allows subsequent
+Recipients to identify the originator of the Contribution.
+4. COMMERCIAL DISTRIBUTION
+Commercial distributors of software may accept certain responsibilities
+with respect to end users, business partners and the like. While
+this license is intended to facilitate the commercial use of
+the Program, the Contributor who includes the Program in a commercial
+product offering should do so in a manner which does not create
+potential liability for other Contributors. Therefore, if a Contributor
+includes the Program in a commercial product offering, such Contributor
+("Commercial Contributor") hereby agrees to defend and indemnify
+every other Contributor ("Indemnified Contributor") against any
+losses, damages and costs (collectively "Losses") arising from
+claims, lawsuits and other legal actions brought by a third party
+against the Indemnified Contributor to the extent caused by the
+acts or omissions of such Commercial Contributor in connection
+with its distribution of the Program in a commercial product
+offering. The obligations in this section do not apply to any
+claims or Losses relating to any actual or alleged intellectual
+property infringement. In order to qualify, an Indemnified Contributor
+must: a) promptly notify the Commercial Contributor in writing
+of such claim, and b) allow the Commercial Contributor to control,
+and cooperate with the Commercial Contributor in, the defense
+and any related settlement negotiations. The Indemnified Contributor
+may participate in any such claim at its own expense.
+For example, a Contributor might include the Program in a commercial
+product offering, Product X. That Contributor is then a Commercial
+Contributor. If that Commercial Contributor then makes performance
+claims, or offers warranties related to Product X, those performance
+claims and warranties are such Commercial Contributor's responsibility
+alone. Under this section, the Commercial Contributor would have
+to defend claims against the other Contributors related to those
+performance claims and warranties, and if a court requires any
+other Contributor to pay any damages as a result, the Commercial
+Contributor must pay those damages.
+5. NO WARRANTY
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM
+IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
+OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION,
+ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY
+OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely
+responsible for determining the appropriateness of using and
+distributing the Program and assumes all risks associated with
+its exercise of rights under this Agreement , including but not
+limited to the risks and costs of program errors, compliance
+with applicable laws, damage to or loss of data, programs or
+equipment, and unavailability or interruption of operations.
+6. DISCLAIMER OF LIABILITY
+EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT
+NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE
+OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY
+OF SUCH DAMAGES.
+7. GENERAL
+If any provision of this Agreement is invalid or unenforceable
+under applicable law, it shall not affect the validity or enforceability
+of the remainder of the terms of this Agreement, and without
+further action by the parties hereto, such provision shall be
+reformed to the minimum extent necessary to make such provision
+valid and enforceable.
+If Recipient institutes patent litigation against any entity
+(including a cross-claim or counterclaim in a lawsuit) alleging
+that the Program itself (excluding combinations of the Program
+with other software or hardware) infringes such Recipient's patent(s),
+then such Recipient's rights granted under Section 2(b) shall
+terminate as of the date such litigation is filed.
+All Recipient's rights under this Agreement shall terminate if
+it fails to comply with any of the material terms or conditions
+of this Agreement and does not cure such failure in a reasonable
+period of time after becoming aware of such noncompliance. If
+all Recipient's rights under this Agreement terminate, Recipient
+agrees to cease use and distribution of the Program as soon as
+reasonably practicable. However, Recipient's obligations under
+this Agreement and any licenses granted by Recipient relating
+to the Program shall continue and survive.
+Everyone is permitted to copy and distribute copies of this Agreement,
+but in order to avoid inconsistency the Agreement is copyrighted
+and may only be modified in the following manner. The Agreement
+Steward reserves the right to publish new versions (including
+revisions) of this Agreement from time to time. No one other
+than the Agreement Steward has the right to modify this Agreement.
+The Eclipse Foundation is the initial Agreement Steward. The
+Eclipse Foundation may assign the responsibility to serve as
+the Agreement Steward to a suitable separate entity. Each new
+version of the Agreement will be given a distinguishing version
+number. The Program (including Contributions) may always be distributed
+subject to the version of the Agreement under which it was received.
+In addition, after a new version of the Agreement is published,
+Contributor may elect to distribute the Program (including its
+Contributions) under the new version. Except as expressly stated
+in Sections 2(a) and 2(b) above, Recipient receives no rights
+or licenses to the intellectual property of any Contributor under
+this Agreement, whether expressly, by implication, estoppel or
+otherwise. All rights in the Program not expressly granted under
+this Agreement are reserved.
+This Agreement is governed by the laws of the State of New York
+and the intellectual property laws of the United States of America.
+No party to this Agreement will bring a legal action under this
+Agreement more than one year after the cause of action arose.
+Each party waives its rights to a jury trial in any resulting
+litigation.
+ </license>
+
+ <url>
+ <update label="JBossTools Update Site" url="http://download.jboss.org/jbosstools/updates/stable"/>
+ </url>
+
+ <plugin
+ id="org.jboss.tools.birt.oda"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+ <plugin
+ id="org.jboss.tools.birt.oda.ui"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"
+ unpack="false"/>
+
+</feature>
17 years, 11 months
JBoss Tools SVN: r8155 - trunk/birt/features.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-05-16 16:27:42 -0400 (Fri, 16 May 2008)
New Revision: 8155
Added:
trunk/birt/features/org.jboss.tools.birt.feature/
Log:
Initial import.
17 years, 11 months
JBoss Tools SVN: r8154 - trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/wst/server/ui/action.
by jbosstools-commits@lists.jboss.org
Author: rob.stryker(a)jboss.com
Date: 2008-05-16 16:05:41 -0400 (Fri, 16 May 2008)
New Revision: 8154
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/wst/server/ui/action/DebugServerActionDelegate.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/wst/server/ui/action/RunServerActionDelegate.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/wst/server/ui/action/SelectServerActionDelegate.java
Log:
JBIDE-2224
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/wst/server/ui/action/DebugServerActionDelegate.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/wst/server/ui/action/DebugServerActionDelegate.java 2008-05-16 18:57:35 UTC (rev 8153)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/wst/server/ui/action/DebugServerActionDelegate.java 2008-05-16 20:05:41 UTC (rev 8154)
@@ -24,7 +24,7 @@
protected String computeToolTip() {
IServer selected = ServerManager.getInstance().getSelectedServer();
String name = selected == null ? "" : selected.getName(); //$NON-NLS-1$
- if( selected.getServerState() == IServer.STATE_STARTED)
+ if( selected != null && selected.getServerState() == IServer.STATE_STARTED)
return NLS.bind(ServerActionMessages.RESTART_IN_DEBUG_MODE, name);
return NLS.bind(ServerActionMessages.START_IN_DEBUG_MODE, name); //$NON-NLS-2$
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/wst/server/ui/action/RunServerActionDelegate.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/wst/server/ui/action/RunServerActionDelegate.java 2008-05-16 18:57:35 UTC (rev 8153)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/wst/server/ui/action/RunServerActionDelegate.java 2008-05-16 20:05:41 UTC (rev 8154)
@@ -47,7 +47,7 @@
protected String computeToolTip() {
IServer selected = ServerManager.getInstance().getSelectedServer();
String name = selected == null ? "" : selected.getName(); //$NON-NLS-1$
- if( selected.getServerState() == IServer.STATE_STARTED)
+ if( selected != null && selected.getServerState() == IServer.STATE_STARTED)
return NLS.bind(ServerActionMessages.RESTART_IN_RUN_MODE, name);
return NLS.bind(ServerActionMessages.START_IN_RUN_MODE, name);
}
Modified: trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/wst/server/ui/action/SelectServerActionDelegate.java
===================================================================
--- trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/wst/server/ui/action/SelectServerActionDelegate.java 2008-05-16 18:57:35 UTC (rev 8153)
+++ trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/tools/wst/server/ui/action/SelectServerActionDelegate.java 2008-05-16 20:05:41 UTC (rev 8154)
@@ -56,8 +56,10 @@
private void update0() {
if(action == null) return;
IServer server = ServerManager.getInstance().getSelectedServer();
- ImageDescriptor id = ImageResource.getImageDescriptor(server.getServerType().getId());
- action.setImageDescriptor(id);
+ if( server != null ) {
+ ImageDescriptor id = ImageResource.getImageDescriptor(server.getServerType().getId());
+ action.setImageDescriptor(id);
+ }
action.setText(null);
action.setToolTipText(ServerActionMessages.SELECT_A_SERVER);
}
17 years, 11 months
JBoss Tools SVN: r8153 - trunk/birt/plugins.
by jbosstools-commits@lists.jboss.org
Author: snjeza
Date: 2008-05-16 14:57:35 -0400 (Fri, 16 May 2008)
New Revision: 8153
Removed:
trunk/birt/plugins/org.hibernate.birt.oda.ui/
trunk/birt/plugins/org.hibernate.birt.oda/
Log:
17 years, 11 months