### Eclipse Workspace Patch 1.0 #P org.eclipse.datatools.connectivity Index: META-INF/MANIFEST.MF =================================================================== RCS file: /cvsroot/datatools/org.eclipse.datatools.connectivity/plugins/org.eclipse.datatools.connectivity/META-INF/MANIFEST.MF,v retrieving revision 1.97 diff -u -r1.97 MANIFEST.MF --- META-INF/MANIFEST.MF 16 Jun 2010 03:04:38 -0000 1.97 +++ META-INF/MANIFEST.MF 16 Nov 2010 07:00:19 -0000 @@ -17,6 +17,7 @@ org.eclipse.datatools.connectivity.drivers.models, org.eclipse.datatools.connectivity.exceptions, org.eclipse.datatools.connectivity.internal, + org.eclipse.datatools.connectivity.internal.bidi, org.eclipse.datatools.connectivity.internal.repository, org.eclipse.datatools.connectivity.internal.security Bundle-RequiredExecutionEnvironment: J2SE-1.5 Index: src/org/eclipse/datatools/connectivity/internal/bidi/BidiConstants.java =================================================================== RCS file: src/org/eclipse/datatools/connectivity/internal/bidi/BidiConstants.java diff -N src/org/eclipse/datatools/connectivity/internal/bidi/BidiConstants.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/datatools/connectivity/internal/bidi/BidiConstants.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,21 @@ +package org.eclipse.datatools.connectivity.internal.bidi; + +public class BidiConstants { + public final static String BIDI_LOGICAL_TABLES_PROP = "bidiLogicalTables"; + public final static String BIDI_VISUAL_TABLES_PROP = "bidiVisualTables"; + public final static String BIDI_LTR_TABLES_PROP = "bidiLTRTables"; + public final static String BIDI_RTL_TABLES_PROP = "bidiRTLTables"; + public final static String BIDI_TABLES_PROP = "bidiTables_"; + public final static String BIDI_PROPS = "bidiProperties"; + public final static String DEFAULT_BIDI_FORMAT = "defaultBidiFormat"; + public final static String VISUAL_STR = "Visual"; + public final static String RTL_STR = "RightToLeft"; + public final static String LOGICAL_STR = "Logical"; + + public final static String LTR_STR = "LeftToRight"; + + public final static String BIDI_ENABLE_KEY = "org.eclipse.datatools.connectivity.sqm.core.ui.bidi.enabled"; //$NON-NLS-1$ + + public static final char LRO = '\u202d'; + +} Index: src/org/eclipse/datatools/connectivity/internal/bidi/BidiUtils.java =================================================================== RCS file: src/org/eclipse/datatools/connectivity/internal/bidi/BidiUtils.java diff -N src/org/eclipse/datatools/connectivity/internal/bidi/BidiUtils.java --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/org/eclipse/datatools/connectivity/internal/bidi/BidiUtils.java 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,94 @@ +package org.eclipse.datatools.connectivity.internal.bidi; + +import java.util.Properties; +import java.util.StringTokenizer; + +import org.eclipse.core.runtime.preferences.InstanceScope; +import org.eclipse.datatools.connectivity.IConnectionProfile; +import org.osgi.service.prefs.Preferences; + +public class BidiUtils { + public static boolean isBidiVisualSupportRequired(IConnectionProfile profile, String schemaName, String tableName) { + return isBidiEnabled() && isBidiSpecificSupportRequired(profile, schemaName, tableName, "visual"); + } + public static boolean isBidiRTLSupportRequired(IConnectionProfile profile, String schemaName, String tableName) { + return isBidiEnabled() && isBidiSpecificSupportRequired(profile, schemaName, tableName, "rtl"); + } + + private static boolean isBidiSpecificSupportRequired(IConnectionProfile profile, String schemaName, String tableName, String requiredPropName){ + String propStr = ""; + String propName = ""; + String oppositePropName = ""; + if (requiredPropName.equals("visual")){ + propStr = BidiConstants.VISUAL_STR; + propName = BidiConstants.BIDI_VISUAL_TABLES_PROP; + oppositePropName = BidiConstants.BIDI_LOGICAL_TABLES_PROP; + } else if (requiredPropName.equals("rtl")){ + propStr = BidiConstants.RTL_STR; + propName = BidiConstants.BIDI_RTL_TABLES_PROP; + oppositePropName = BidiConstants.BIDI_LTR_TABLES_PROP; + } else + return false; + if (profile == null || tableName == null || tableName.length() == 0) + return false; + Properties bidiProps = profile.getProperties(BidiConstants.BIDI_PROPS); + if (bidiProps != null){ + String bidiTablesStr = bidiProps.getProperty(BidiConstants.BIDI_TABLES_PROP + schemaName); + if (bidiTablesStr == null){ + //we need to check default Bidi format, it might be equal to required + String defaultBidiFormat = bidiProps.getProperty(BidiConstants.DEFAULT_BIDI_FORMAT); + if (defaultBidiFormat != null && defaultBidiFormat.toLowerCase().contains(propStr.toLowerCase())) + return true; + return false; + } + + Properties bidiTables = populateBidiTablesProp(bidiTablesStr); + String tablesListStr = ""; + if (!bidiTables.isEmpty()) { + tablesListStr = bidiTables.getProperty(propName); + } + if (tablesListStr != null && tablesListStr.contains(tableName)) + return true; + else { + String opposedTablesListStr = ""; + if (!bidiTables.isEmpty()) { + opposedTablesListStr = bidiTables.getProperty(oppositePropName); + } + if (opposedTablesListStr != null && opposedTablesListStr.contains(tableName)) + return false; //the table is defined in opposite to required format + else { //we need to check default Bidi format, it might be equal to required + String defaultBidiFormat = bidiProps.getProperty(BidiConstants.DEFAULT_BIDI_FORMAT); + if (defaultBidiFormat != null && defaultBidiFormat.toLowerCase().contains(propStr.toLowerCase())) + return true; + } + } + } + return false; + } + + + public static Properties populateBidiTablesProp(String bidiTablesStr) { + Properties result = new Properties(); + StringTokenizer st = new StringTokenizer (bidiTablesStr, ": "); + while(st.hasMoreTokens()){ + String key = st.nextToken(); + String value = st.nextToken(); + result.setProperty(key, value); + } + return result; + } + + public static boolean isBidiEnabled(){ + Preferences preferences = new InstanceScope().getNode("org.eclipse.datatools.connectivity.sqm.core.ui"); //$NON-NLS-1$ + if (preferences == null) + return false; + return preferences.getBoolean(BidiConstants.BIDI_ENABLE_KEY, false); + } + + public static String addMarkersToStr (String str){ + str = str.replaceAll("\n", "\n" + BidiConstants.LRO); + str = BidiConstants.LRO + str; + return str; + } + +}