Skip to content

Commit

Permalink
JBIDE-3000 Internationalize BIRT component
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.jboss.org/repos/jbosstools/trunk@11810 a97e2381-89e5-4abb-bab3-167db6db766c
  • Loading branch information
snjeza committed Nov 15, 2008
1 parent 52b96cf commit 8957255
Show file tree
Hide file tree
Showing 17 changed files with 118 additions and 63 deletions.
2 changes: 1 addition & 1 deletion plugins/org.jboss.tools.birt.oda/META-INF/MANIFEST.MF
Expand Up @@ -5,7 +5,7 @@ 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: JBoss, a division of Red Hat
Bundle-Vendor: %BundleVendor
Bundle-Localization: plugin
Export-Package: org.jboss.tools.birt.oda,
org.jboss.tools.birt.oda.impl
Expand Down
2 changes: 2 additions & 0 deletions plugins/org.jboss.tools.birt.oda/plugin.properties
Expand Up @@ -11,3 +11,5 @@ 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

BundleVendor = JBoss, a division of Red Hat
Expand Up @@ -19,7 +19,7 @@
public class Activator extends Plugin {

// The plug-in ID
public static final String PLUGIN_ID = "org.jboss.tools.birt.oda";
public static final String PLUGIN_ID = "org.jboss.tools.birt.oda"; //$NON-NLS-1$

// The shared instance
private static Activator plugin;
Expand Down
Expand Up @@ -24,10 +24,10 @@
*/
public interface IOdaFactory {

public static final String MAX_ROWS = "maxRows";
public static final String CONFIGURATION = "configuration";
public static final String JNDI_NAME = "jndiName";
public static final String ORG_HIBERNATE_ECLIPSE_BUNDLE_ID = "org.hibernate.eclipse";
public static final String MAX_ROWS = "maxRows"; //$NON-NLS-1$
public static final String CONFIGURATION = "configuration"; //$NON-NLS-1$
public static final String JNDI_NAME = "jndiName"; //$NON-NLS-1$
public static final String ORG_HIBERNATE_ECLIPSE_BUNDLE_ID = "org.hibernate.eclipse"; //$NON-NLS-1$

void close();
boolean isOpen();
Expand Down
@@ -0,0 +1,27 @@
package org.jboss.tools.birt.oda;

import org.eclipse.osgi.util.NLS;

public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.jboss.tools.birt.oda.messages"; //$NON-NLS-1$
public static String AbstractOdaFactory_The_type_is_not_valid;
public static String ConsoleConfigurationOdaFactory_Invalid_configuration;
public static String DataTypes_Invalid_type_name;
public static String HibernateConnection_Invalid_AppContext;
public static String HibernateDataSetMetaData_Hibernate_Data_Source;
public static String HibernateDriver_Non_defined;
public static String HibernateResultSet_Cursor_has_not_been_initialized;
public static String HibernateResultSet_The_data_type_is_not_valid;
public static String HibernateResultSetMetaData_Argument_cannot_be_null;
public static String HibernateResultSetMetaData_Invalid_index;
public static String ReflectServerOdaFactory_Cannot_create_Hibernate_session_factory;
public static String ReflectServerOdaFactory_The_type_is_not_valid;
public static String ServerOdaFactory_Cannot_create_Hibernate_session_factory;
static {
// initialize resource bundle
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}

private Messages() {
}
}
Expand Up @@ -9,6 +9,7 @@
import org.eclipse.datatools.connectivity.oda.IParameterMetaData;
import org.eclipse.datatools.connectivity.oda.IResultSetMetaData;
import org.eclipse.datatools.connectivity.oda.OdaException;
import org.eclipse.osgi.util.NLS;
import org.hibernate.EntityMode;
import org.hibernate.HibernateException;
import org.hibernate.Query;
Expand All @@ -19,6 +20,7 @@
import org.hibernate.metadata.ClassMetadata;
import org.hibernate.type.Type;
import org.jboss.tools.birt.oda.IOdaFactory;
import org.jboss.tools.birt.oda.Messages;

public abstract class AbstractOdaFactory implements IOdaFactory {

Expand Down Expand Up @@ -81,7 +83,7 @@ private HibernateResultSetMetaData parseQuery()
//throw new OdaException("Data Type is Not Valid");
arColsType.add(DataTypes.UNKNOWN);
arCols.add(props[x]);
arColClass.add("java.lang.String");
arColClass.add("java.lang.String"); //$NON-NLS-1$
}
}
}
Expand All @@ -92,9 +94,7 @@ private HibernateResultSetMetaData parseQuery()
arColsType.add(qryReturnTypes[t].getName());
arCols.add(props[t]);
} else {
throw new OdaException("'"
+ qryReturnTypes[t].getName()
+ "' is not a valid type.");
throw new OdaException(NLS.bind(Messages.AbstractOdaFactory_The_type_is_not_valid,qryReturnTypes[t].getName()));
}
}

Expand All @@ -120,11 +120,11 @@ private HibernateResultSetMetaData parseQuery()
}

private static String[] extractColumns(final String query) {
int fromPosition = query.toLowerCase().indexOf("from");
int selectPosition = query.toLowerCase().indexOf("select");
int fromPosition = query.toLowerCase().indexOf("from"); //$NON-NLS-1$
int selectPosition = query.toLowerCase().indexOf("select"); //$NON-NLS-1$
if (selectPosition >= 0) {
String columns = query.substring(selectPosition + 6, fromPosition);
StringTokenizer st = new StringTokenizer(columns, ",");
StringTokenizer st = new StringTokenizer(columns, ","); //$NON-NLS-1$
List columnList = new ArrayList();
while (st.hasMoreTokens()) {
columnList.add(st.nextToken().trim());
Expand Down
Expand Up @@ -13,11 +13,13 @@
import java.util.Properties;

import org.eclipse.datatools.connectivity.oda.OdaException;
import org.eclipse.osgi.util.NLS;
import org.hibernate.HibernateException;
import org.hibernate.SessionFactory;
import org.hibernate.console.ConsoleConfiguration;
import org.hibernate.console.KnownConfigurations;
import org.jboss.tools.birt.oda.IOdaFactory;
import org.jboss.tools.birt.oda.Messages;

/**
*
Expand Down Expand Up @@ -59,7 +61,7 @@ public SessionFactory getSessionFactory(Properties properties) throws OdaExcepti
throw new OdaException(e.getLocalizedMessage());
}
} else {
throw new OdaException("Invalid configuration '" + configurationName + "'");
throw new OdaException(NLS.bind(Messages.ConsoleConfigurationOdaFactory_Invalid_configuration, configurationName));
}
return sessionFactory;
}
Expand Down
Expand Up @@ -16,6 +16,8 @@
import java.util.Map;

import org.eclipse.datatools.connectivity.oda.OdaException;
import org.eclipse.osgi.util.NLS;
import org.jboss.tools.birt.oda.Messages;

/**
* This class hosts the information of data types that are supported by flat
Expand All @@ -25,7 +27,7 @@
public final class DataTypes
{

public static final String UNKNOWN = "UNKNOWN";
public static final String UNKNOWN = "UNKNOWN"; //$NON-NLS-1$
public static final int INT = Types.INTEGER;
public static final int LONG = Types.INTEGER;
public static final int SHORT = Types.INTEGER;
Expand Down Expand Up @@ -55,7 +57,7 @@ public final class DataTypes
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( "NULL", new Integer ( NULL ) ); //$NON-NLS-1$
typeStringIntPair.put( UNKNOWN, new Integer ( STRING ) );

}
Expand All @@ -72,12 +74,12 @@ public final class DataTypes
public static int getType( String typeName ) throws OdaException
{
String name = typeName.trim( ).toUpperCase( );
while (name.indexOf(".") > 0) {
name = name.substring(name.indexOf(".")+1);
while (name.indexOf(".") > 0) { //$NON-NLS-1$
name = name.substring(name.indexOf(".")+1); //$NON-NLS-1$
}
if ( typeStringIntPair.containsKey( name ) )
return ( (Integer) typeStringIntPair.get( name ) ).intValue( );
throw new OdaException( "Invalid type name : " + typeName);
throw new OdaException( NLS.bind(Messages.DataTypes_Invalid_type_name, typeName));
}

/**
Expand All @@ -93,8 +95,8 @@ public static boolean isValidType( String typeName )
if (valid) {
return true;
}
while (name.indexOf(".") > 0) {
name = name.substring(name.indexOf(".")+1);
while (name.indexOf(".") > 0) { //$NON-NLS-1$
name = name.substring(name.indexOf(".")+1); //$NON-NLS-1$
}
return typeStringIntPair.containsKey( name );
}
Expand Down
Expand Up @@ -17,6 +17,7 @@
import org.eclipse.datatools.connectivity.oda.IQuery;
import org.eclipse.datatools.connectivity.oda.OdaException;
import org.jboss.tools.birt.oda.IOdaFactory;
import org.jboss.tools.birt.oda.Messages;
import org.osgi.framework.Bundle;

/**
Expand Down Expand Up @@ -51,7 +52,7 @@ public void open(Properties connProperties) throws OdaException {
*/
public void setAppContext(Object context) throws OdaException {
if (!(context instanceof Map)) {
throw new OdaException("Invalid AppContext");
throw new OdaException(Messages.HibernateConnection_Invalid_AppContext);
}
this.appContext = (Map) context;
}
Expand Down
Expand Up @@ -13,6 +13,7 @@
import org.eclipse.datatools.connectivity.oda.IDataSetMetaData;
import org.eclipse.datatools.connectivity.oda.IResultSet;
import org.eclipse.datatools.connectivity.oda.OdaException;
import org.jboss.tools.birt.oda.Messages;

/**
* Implementation class of IDataSetMetaData for an ODA runtime driver.
Expand Down Expand Up @@ -65,7 +66,7 @@ public int getDataSourceMinorVersion() throws OdaException
*/
public String getDataSourceProductName() throws OdaException
{
return "Hibernate Data Source";
return Messages.HibernateDataSetMetaData_Hibernate_Data_Source;
}

/*
Expand Down
Expand Up @@ -15,6 +15,7 @@
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;
import org.jboss.tools.birt.oda.Messages;

/**
* Implementation class of IDriver for an ODA runtime driver.
Expand Down Expand Up @@ -86,7 +87,7 @@ static String getNativeDataTypeName( int nativeDataTypeCode )
.getDataTypeMapping( nativeDataTypeCode );
if( typeMapping != null )
return typeMapping.getNativeType();
return "Non-defined";
return Messages.HibernateDriver_Non_defined;
}

}
Expand Up @@ -20,6 +20,7 @@
import org.eclipse.datatools.connectivity.oda.IResultSetMetaData;
import org.eclipse.datatools.connectivity.oda.OdaException;
import org.eclipse.datatools.connectivity.oda.SortSpec;
import org.jboss.tools.birt.oda.Messages;

/**
* Implementation class of IQuery for an ODA runtime driver.
Expand Down Expand Up @@ -150,7 +151,7 @@ public void setInt(int parameterId, int value) throws OdaException {

private void setParameter(int parameterId,int type,Object value) {
List<Parameter> parameters = parameterMetaData.getParameters();
String parameterName = "parameter" + parameterId;
String parameterName = "parameter" + parameterId; //$NON-NLS-1$
if (parameters.size() < parameterId) {
Parameter parameter = new Parameter(type, parameterName,
value);
Expand Down
Expand Up @@ -24,6 +24,8 @@
import org.eclipse.datatools.connectivity.oda.IResultSet;
import org.eclipse.datatools.connectivity.oda.IResultSetMetaData;
import org.eclipse.datatools.connectivity.oda.OdaException;
import org.eclipse.osgi.util.NLS;
import org.jboss.tools.birt.oda.Messages;

/**
* Implementation class of IResultSet for an ODA runtime driver.
Expand All @@ -37,7 +39,7 @@ public class HibernateResultSet implements IResultSet {
private int rowNumber = -1;
private boolean wasNull;

private static DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
private static DateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy"); //$NON-NLS-1$

public HibernateResultSet(HibernateOdaQuery query) throws OdaException {
this.query = query;
Expand Down Expand Up @@ -154,7 +156,7 @@ else if (rObj instanceof Long)
else if (rObj instanceof Short)
result = ((Short) rObj).intValue();
else
throw new RuntimeException("The " + rObj.getClass() + " data type is not valid.");
throw new RuntimeException(NLS.bind(Messages.HibernateResultSet_The_data_type_is_not_valid, rObj.getClass()));
}

return result;
Expand Down Expand Up @@ -372,7 +374,7 @@ public int findColumn(String columnName) throws OdaException {

private void testFetchStarted() throws OdaException {
if (rowNumber < 0)
throw new OdaException("Cursor has not been initialized");
throw new OdaException(Messages.HibernateResultSet_Cursor_has_not_been_initialized);
}

}
Expand Up @@ -13,6 +13,8 @@

import org.eclipse.datatools.connectivity.oda.IResultSetMetaData;
import org.eclipse.datatools.connectivity.oda.OdaException;
import org.eclipse.osgi.util.NLS;
import org.jboss.tools.birt.oda.Messages;

/**
* Implementation class of IResultSetMetaData for an ODA runtime driver.
Expand All @@ -32,7 +34,7 @@ public class HibernateResultSetMetaData implements IResultSetMetaData
throws OdaException
{
if ( cName == null )
throw new OdaException( "Argument cannot be null" );
throw new OdaException( Messages.HibernateResultSetMetaData_Argument_cannot_be_null );
this.columnName = cName;
this.columnType = cType;
this.columnLabel = cLabel;
Expand All @@ -54,8 +56,8 @@ 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," ");
if (name.indexOf(" ") > 0) { //$NON-NLS-1$
StringTokenizer tokenizer = new StringTokenizer(name," "); //$NON-NLS-1$
String prettyName = null;
while (tokenizer.hasMoreTokens()) {
prettyName = tokenizer.nextToken();
Expand Down Expand Up @@ -151,7 +153,7 @@ public int isNullable( int index ) throws OdaException
private void assertIndexValid( int index ) throws OdaException
{
if ( index > getColumnCount( ) || index < 1 )
throw new OdaException( "Invalid index " + index );
throw new OdaException( NLS.bind(Messages.HibernateResultSetMetaData_Invalid_index, new Integer(index).toString()) );
}

public String getColumnClass( int index ) throws OdaException
Expand Down

0 comments on commit 8957255

Please sign in to comment.