summaryrefslogtreecommitdiff
path: root/wizards
diff options
context:
space:
mode:
Diffstat (limited to 'wizards')
-rw-r--r--wizards/com/sun/star/wizards/db/DBMetaData.java32
-rw-r--r--wizards/com/sun/star/wizards/db/DatabaseObjectWizard.java3
-rw-r--r--wizards/com/sun/star/wizards/db/SQLQueryComposer.java82
-rw-r--r--wizards/com/sun/star/wizards/query/QueryWizard.java256
-rw-r--r--wizards/com/sun/star/wizards/ui/FilterComponent.java193
5 files changed, 273 insertions, 293 deletions
diff --git a/wizards/com/sun/star/wizards/db/DBMetaData.java b/wizards/com/sun/star/wizards/db/DBMetaData.java
index f46c3fd657d4..323ded34385a 100644
--- a/wizards/com/sun/star/wizards/db/DBMetaData.java
+++ b/wizards/com/sun/star/wizards/db/DBMetaData.java
@@ -38,12 +38,10 @@ import com.sun.star.awt.XWindowPeer;
import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.UnknownPropertyException;
import com.sun.star.beans.XPropertySet;
-import com.sun.star.container.XChild;
import com.sun.star.container.XHierarchicalNameAccess;
import com.sun.star.container.XHierarchicalNameContainer;
import com.sun.star.container.XNameAccess;
import com.sun.star.container.XNameContainer;
-import com.sun.star.frame.XComponentLoader;
import com.sun.star.frame.XModel;
import com.sun.star.frame.XStorable;
import com.sun.star.lang.XComponent;
@@ -91,7 +89,6 @@ import java.util.logging.Logger;
public class DBMetaData
{
-
private XNameAccess xQueryNames;
public XDatabaseMetaData xDBMetaData;
private XDataSource m_dataSource;
@@ -109,12 +106,8 @@ public class DBMetaData
public com.sun.star.lang.XMultiServiceFactory xMSF;
public XComponent xConnectionComponent;
- private XNameAccess m_xTableNames;
- private XInteractionHandler oInteractionHandler;
private XNameAccess xNameAccess;
private XInterface xDatabaseContext;
- private XCompletedConnection xCompleted;
- // private int[] nDataTypes = null;
private XWindowPeer xWindowPeer;
private String[] TableNames = new String[] {};
private String[] QueryNames = new String[] {};
@@ -212,15 +205,13 @@ public class DBMetaData
return lDateCorrection;
}
- void getInterfaces(XMultiServiceFactory xMSF)
+ private void getInterfaces(XMultiServiceFactory xMSF)
{
try
{
this.xMSF = xMSF;
xDatabaseContext = (XInterface) xMSF.createInstance("com.sun.star.sdb.DatabaseContext");
xNameAccess = UnoRuntime.queryInterface( XNameAccess.class, xDatabaseContext );
- XInterface xInteractionHandler = (XInterface) xMSF.createInstance("com.sun.star.task.InteractionHandler");
- oInteractionHandler = UnoRuntime.queryInterface( XInteractionHandler.class, xInteractionHandler );
DataSourceNames = xNameAccess.getElementNames();
}
catch (Exception exception)
@@ -257,7 +248,6 @@ public class DBMetaData
public boolean hasTableByName(String _stablename)
{
- // getTableNames();
return getTableNamesAsNameAccess().hasByName(_stablename);
}
@@ -371,11 +361,6 @@ public class DBMetaData
return bHasEscapeProcessing;
}
- // public void initCommandNames()
- // {
- // getTableNames();
- // }
-
public XNameAccess getQueryNamesAsNameAccess()
{
XQueriesSupplier xDBQueries = UnoRuntime.queryInterface( XQueriesSupplier.class, DBConnection );
@@ -416,7 +401,7 @@ public class DBMetaData
return TableNames;
}
- void InitializeWidthList()
+ private void InitializeWidthList()
{
WidthList = new int[17][2];
WidthList[0][0] = DataType.BIT; // == -7;
@@ -581,7 +566,7 @@ public class DBMetaData
return m_dataSource;
}
- private void setDataSourceByName(String _DataSourceName, boolean bgetInterfaces)
+ private void setDataSourceByName(String _DataSourceName)
{
try
{
@@ -601,7 +586,6 @@ public class DBMetaData
public void getDataSourceInterfaces() throws Exception
{
- xCompleted = UnoRuntime.queryInterface( XCompletedConnection.class, getDataSource() );
xDataSourcePropertySet = UnoRuntime.queryInterface( XPropertySet.class, getDataSource() );
bPasswordIsRequired = ((Boolean) xDataSourcePropertySet.getPropertyValue("IsPasswordRequired")).booleanValue();
}
@@ -684,8 +668,8 @@ public class DBMetaData
private boolean getConnection(String _DataSourceName)
{
- setDataSourceByName(_DataSourceName, true);
- return getConnection( getDataSource() );
+ setDataSourceByName(_DataSourceName);
+ return getConnection( getDataSource() );
}
private boolean getConnection(com.sun.star.sdbc.XConnection _DBConnection)
@@ -955,7 +939,7 @@ public class DBMetaData
NamedValueCollection creationArgs = new NamedValueCollection();
creationArgs.put( "Name", basename );
creationArgs.put( "URL", documentURL );
- creationArgs.put( "AsTemplate", new Boolean( i_createTemplate ) );
+ creationArgs.put( "AsTemplate", i_createTemplate );
XMultiServiceFactory xDocMSF = UnoRuntime.queryInterface( XMultiServiceFactory.class, _xDocNameAccess );
Object oDBDocument = xDocMSF.createInstanceWithArguments( "com.sun.star.sdb.DocumentDefinition", creationArgs.getPropertyValues() );
XHierarchicalNameContainer xHier = UnoRuntime.queryInterface( XHierarchicalNameContainer.class, _xDocNameAccess );
@@ -967,7 +951,7 @@ public class DBMetaData
}
catch (Exception e)
{
- e.printStackTrace(System.out);
+ e.printStackTrace();
}
}
@@ -1103,13 +1087,11 @@ public class DBMetaData
public void finish()
{
xQueryNames = null;
- oInteractionHandler = null;
xNameAccess = null;
xDatabaseContext = null;
xDBMetaData = null;
m_dataSource = null;
xModel = null;
- xCompleted = null;
xDataSourcePropertySet = null;
xWindowPeer = null;
DBConnection = null;
diff --git a/wizards/com/sun/star/wizards/db/DatabaseObjectWizard.java b/wizards/com/sun/star/wizards/db/DatabaseObjectWizard.java
index 5c65d73794f0..e03323c6ebbc 100644
--- a/wizards/com/sun/star/wizards/db/DatabaseObjectWizard.java
+++ b/wizards/com/sun/star/wizards/db/DatabaseObjectWizard.java
@@ -57,7 +57,8 @@ public abstract class DatabaseObjectWizard extends WizardDialog
{
try
{
- m_docUI.loadComponent( i_type, i_name, i_forEditing );
+ if ( m_docUI != null )
+ m_docUI.loadComponent( i_type, i_name, i_forEditing );
}
catch ( IllegalArgumentException ex )
{
diff --git a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
index 0a52f6a3a7a9..235da2d7c04a 100644
--- a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
+++ b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
@@ -47,6 +47,7 @@ import com.sun.star.uno.UnoRuntime;
import com.sun.star.sdbc.SQLException;
import com.sun.star.lang.XInitialization;
import com.sun.star.awt.XWindow;
+import com.sun.star.sdb.SQLFilterOperator;
import com.sun.star.wizards.common.*;
@@ -60,7 +61,7 @@ public class SQLQueryComposer
// String m_sFromClause;
public XSingleSelectQueryAnalyzer m_xQueryAnalyzer;
Vector composedCommandNames = new Vector(1);
- private XSingleSelectQueryComposer m_xQueryComposer;
+ private XSingleSelectQueryComposer m_queryComposer;
XMultiServiceFactory xMSF;
boolean bincludeGrouping = true;
@@ -72,7 +73,7 @@ public class SQLQueryComposer
xMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, CurDBMetaData.DBConnection);
final Object oQueryComposer = xMSF.createInstance("com.sun.star.sdb.SingleSelectQueryComposer");
m_xQueryAnalyzer = (XSingleSelectQueryAnalyzer) UnoRuntime.queryInterface(XSingleSelectQueryAnalyzer.class, oQueryComposer);
- m_xQueryComposer = (XSingleSelectQueryComposer) UnoRuntime.queryInterface(XSingleSelectQueryComposer.class, m_xQueryAnalyzer);
+ m_queryComposer = (XSingleSelectQueryComposer) UnoRuntime.queryInterface(XSingleSelectQueryComposer.class, m_xQueryAnalyzer);
XSQLQueryComposerFactory xSQLComposerFactory;
xSQLComposerFactory = (XSQLQueryComposerFactory) UnoRuntime.queryInterface(XSQLQueryComposerFactory.class, CurDBMetaData.DBConnection);
// /* XSQLQueryComposer */ xSQLQueryComposer = xSQLComposerFactory.createQueryComposer();
@@ -160,7 +161,7 @@ public class SQLQueryComposer
{
for (int i = 0; i < CurDBMetaData.getFilterConditions().length; i++)
{
- m_xQueryComposer.setStructuredFilter(CurDBMetaData.getFilterConditions());
+ m_queryComposer.setStructuredFilter(CurDBMetaData.getFilterConditions());
}
}
catch (Exception exception)
@@ -172,7 +173,7 @@ public class SQLQueryComposer
public void prependSortingCriteria() throws SQLException
{
XIndexAccess xColumnIndexAccess = m_xQueryAnalyzer.getOrderColumns();
- m_xQueryComposer.setOrder("");
+ m_queryComposer.setOrder("");
for (int i = 0; i < CurDBMetaData.getSortFieldNames().length; i++)
{
appendSortingCriterion(i, false);
@@ -186,7 +187,7 @@ public class SQLQueryComposer
if (JavaTools.FieldInTable(CurDBMetaData.getSortFieldNames(), sName) == -1)
{
boolean bascend = AnyConverter.toBoolean(xColumnPropertySet.getPropertyValue("IsAscending"));
- m_xQueryComposer.appendOrderByColumn(xColumnPropertySet, bascend);
+ m_queryComposer.appendOrderByColumn(xColumnPropertySet, bascend);
}
}
catch (Exception e)
@@ -203,13 +204,13 @@ public class SQLQueryComposer
String sSort = CurDBMetaData.getSortFieldNames()[_SortIndex][1];
boolean bascend = (sSort.equals("ASC"));
- m_xQueryComposer.appendOrderByColumn(xColumn, bascend);
+ m_queryComposer.appendOrderByColumn(xColumn, bascend);
}
public void appendSortingcriteria(boolean _baddAliasFieldNames) throws SQLException
{
String sOrder = "";
- m_xQueryComposer.setOrder("");
+ m_queryComposer.setOrder("");
for (int i = 0; i < CurDBMetaData.getSortFieldNames().length; i++)
{
String sSortValue = CurDBMetaData.getSortFieldNames()[i][0];
@@ -223,7 +224,7 @@ public class SQLQueryComposer
}
sOrder += CurDBMetaData.AggregateFieldNames[iAggregate][1] + "(" + CurDBMetaData.AggregateFieldNames[iAggregate][0] + ")";
sOrder += " " + CurDBMetaData.getSortFieldNames()[i][1];
- m_xQueryComposer.setOrder(sOrder);
+ m_queryComposer.setOrder(sOrder);
}
else
{
@@ -232,7 +233,7 @@ public class SQLQueryComposer
sOrder = m_xQueryAnalyzer.getOrder();
}
// just for debug!
- sOrder = m_xQueryComposer.getOrder();
+ sOrder = m_queryComposer.getOrder();
int dummy = 0;
}
@@ -241,7 +242,7 @@ public class SQLQueryComposer
for (int i = 0; i < CurDBMetaData.GroupFieldNames.length; i++)
{
XPropertySet xColumn = CurDBMetaData.getColumnObjectByFieldName(CurDBMetaData.GroupFieldNames[i], _baddAliasFieldNames);
- m_xQueryComposer.appendGroupByColumn(xColumn);
+ m_queryComposer.appendGroupByColumn(xColumn);
}
String s = m_xQueryAnalyzer.getQuery();
}
@@ -309,7 +310,7 @@ public class SQLQueryComposer
if (CurDBMetaData.getFilterConditions().length > 0)
{
CurDBMetaData.setFilterConditions(replaceConditionsByAlias(CurDBMetaData.getFilterConditions()));
- m_xQueryComposer.setStructuredFilter(CurDBMetaData.getFilterConditions());
+ m_queryComposer.setStructuredFilter(CurDBMetaData.getFilterConditions());
}
}
}
@@ -319,7 +320,7 @@ public class SQLQueryComposer
appendGroupByColumns(_baddAliasFieldNames);
if (CurDBMetaData.GroupByFilterConditions.length > 0)
{
- m_xQueryComposer.setStructuredHavingClause(CurDBMetaData.GroupByFilterConditions);
+ m_queryComposer.setStructuredHavingClause(CurDBMetaData.GroupByFilterConditions);
}
}
appendSortingcriteria(_baddAliasFieldNames);
@@ -426,8 +427,63 @@ public class SQLQueryComposer
typeexception.printStackTrace(System.out);
}
}
+
+ /**
+ * retrieves a normalized structured filter
+ *
+ * <p>XSingleSelectQueryComposer.getStructuredFilter has a strange habit of returning the predicate (equal, not equal, etc)
+ * effectively twice: Once as SQLFilterOperator, and once in the value. That is, if you have a term "column <> 3", then
+ * you'll get an SQLFilterOperator.NOT_EQUAL (which is fine), <strong>and</strong> the textual value of the condition
+ * will read "<> 3". The latter is strange enough, but even more strange is that this behavior is not even consistent:
+ * for SQLFilterOperator.EQUAL, the "=" sign is not include in the textual value.</p>
+ *
+ * <p>To abstract from this weirdness, use this function here, which strips the unwanted tokens from the textual value
+ * representation.</p>
+ */
+ public PropertyValue[][] getNormalizedStructuredFilter()
+ {
+ final PropertyValue[][] structuredFilter = m_queryComposer.getStructuredFilter();
+ for ( int i=0; i<structuredFilter.length; ++i )
+ {
+ for ( int j=0; j<structuredFilter[i].length; ++j )
+ {
+ if ( !( structuredFilter[i][j].Value instanceof String ) )
+ continue;
+ final StringBuffer textualValue = new StringBuffer( (String)structuredFilter[i][j].Value );
+ switch ( structuredFilter[i][j].Handle )
+ {
+ case SQLFilterOperator.EQUAL:
+ break;
+ case SQLFilterOperator.NOT_EQUAL:
+ case SQLFilterOperator.LESS_EQUAL:
+ case SQLFilterOperator.GREATER_EQUAL:
+ textualValue.delete( 0, 2 );
+ break;
+ case SQLFilterOperator.LESS:
+ case SQLFilterOperator.GREATER:
+ textualValue.delete( 0, 1 );
+ break;
+ case SQLFilterOperator.NOT_LIKE:
+ textualValue.delete( 0, 8 );
+ break;
+ case SQLFilterOperator.LIKE:
+ textualValue.delete( 0, 4 );
+ break;
+ case SQLFilterOperator.SQLNULL:
+ textualValue.delete( 0, 7 );
+ break;
+ case SQLFilterOperator.NOT_SQLNULL:
+ textualValue.delete( 0, 11 );
+ break;
+ }
+ structuredFilter[i][j].Value = textualValue.toString().trim();
+ }
+ }
+ return structuredFilter;
+ }
+
public XSingleSelectQueryComposer getQueryComposer()
{
- return m_xQueryComposer;
+ return m_queryComposer;
}
}
diff --git a/wizards/com/sun/star/wizards/query/QueryWizard.java b/wizards/com/sun/star/wizards/query/QueryWizard.java
index 53fc67f01192..a0970534d657 100644
--- a/wizards/com/sun/star/wizards/query/QueryWizard.java
+++ b/wizards/com/sun/star/wizards/query/QueryWizard.java
@@ -36,8 +36,10 @@ import com.sun.star.sdbc.SQLException;
import com.sun.star.uno.AnyConverter;
import com.sun.star.wizards.ui.UIConsts;
import com.sun.star.uno.UnoRuntime;
+import com.sun.star.wizards.common.Desktop;
import com.sun.star.wizards.common.Helper;
import com.sun.star.wizards.common.JavaTools;
+import com.sun.star.wizards.common.Properties;
import com.sun.star.wizards.common.Resource;
import com.sun.star.wizards.db.DatabaseObjectWizard;
import com.sun.star.wizards.db.QueryMetaData;
@@ -59,15 +61,15 @@ public class QueryWizard extends DatabaseObjectWizard
private static final int SOGROUPFILTER_PAGE = 6;
private static final int SOTITLES_PAGE = 7;
protected static final int SOSUMMARY_PAGE = 8;
- private CommandFieldSelection CurDBCommandFieldSelection;
- private SortingComponent CurSortingComponent;
- private FieldSelection CurGroupFieldSelection;
- private TitlesComponent CurTitlesComponent;
- private FilterComponent CurFilterComponent;
- private FilterComponent CurGroupFilterComponent;
- private AggregateComponent CurAggregateComponent;
- private Finalizer CurFinalizer;
- private QuerySummary CurDBMetaData;
+ private CommandFieldSelection m_DBCommandFieldSelectio;
+ private SortingComponent m_sortingComponent;
+ private FieldSelection m_groupFieldSelection;
+ private TitlesComponent m_titlesComponent;
+ private FilterComponent m_filterComponent;
+ private FilterComponent m_groupFilterComponent;
+ private AggregateComponent m_aggregateComponent;
+ private Finalizer m_finalizer;
+ private QuerySummary m_DBMetaData;
private String reslblFieldHeader;
private String reslblAliasHeader;
private String reslblFields;
@@ -82,30 +84,85 @@ public class QueryWizard extends DatabaseObjectWizard
{
super( xMSF, 40970, i_wizardContext );
addResourceHandler("QueryWizard", "dbw");
- CurDBMetaData = new QuerySummary(xMSF, m_oResource);
+ m_DBMetaData = new QuerySummary(xMSF, m_oResource);
}
-/* public static void main(String args[])
+ public static void main(String i_args[])
{
- String ConnectStr = "uno:pipe,name=foo;urp;StarOffice.ServiceManager";
+ final String settings[] = new String[] { null, null, null };
+ final int IDX_PIPE_NAME = 0;
+ final int IDX_LOCATION = 1;
+ final int IDX_DSN = 2;
+
+ // some simple parsing
+ boolean failure = false;
+ int settingsIndex = -1;
+ for ( int i=0; i<i_args.length; ++i )
+ {
+ if ( settingsIndex >= 0 )
+ {
+ settings[ settingsIndex ] = i_args[i];
+ settingsIndex = -1;
+ continue;
+ }
+
+ if ( i_args[i].equals( "--pipe-name" ) )
+ {
+ settingsIndex = IDX_PIPE_NAME;
+ continue;
+ }
+
+ if ( i_args[i].equals( "--database-location" ) )
+ {
+ settingsIndex = IDX_LOCATION;
+ continue;
+ }
+
+ if ( i_args[i].equals( "--data-source-name" ) )
+ {
+ settingsIndex = IDX_DSN;
+ continue;
+ }
+
+ failure = true;
+ }
+
+ if ( settings[ IDX_PIPE_NAME ] == null )
+ failure = true;
+
+ if ( ( settings[ IDX_DSN ] == null ) && ( settings[ IDX_LOCATION ] == null ) )
+ failure = true;
+
+ if ( failure )
+ {
+ System.err.println( "supported arguments: " );
+ System.err.println( " --pipe-name <name> : specifies the name of the pipe to connect to the running OOo instance" );
+ System.err.println( " --database-location <url> : specifies the URL of the database document to work with" );
+ System.err.println( " --data-source-name <name> : specifies the name of the data source to work with" );
+ return;
+ }
+
+ final String ConnectStr = "uno:pipe,name=" + settings[IDX_PIPE_NAME] + ";urp;StarOffice.ServiceManager";
try
{
- XMultiServiceFactory xLocMSF = Desktop.connect(ConnectStr);
- if (xLocMSF != null)
+ final XMultiServiceFactory serviceFactory = Desktop.connect(ConnectStr);
+ if (serviceFactory != null)
{
PropertyValue[] curproperties = new PropertyValue[1];
- curproperties[0] = Properties.createProperty("DatabaseLocation", "file:///G:/temp/abc.odb");
-// curproperties[0] = Properties.createProperty("DataSourceName", "TESTDB");
+ if ( settings[ IDX_LOCATION ] != null )
+ curproperties[0] = Properties.createProperty( "DatabaseLocation", settings[ IDX_LOCATION ] );
+ else
+ curproperties[0] = Properties.createProperty( "DataSourceName", settings[ IDX_DSN ] );
- QueryWizard CurQueryWizard = new QueryWizard(xLocMSF);
- CurQueryWizard.startQueryWizard(xLocMSF, curproperties);
+ QueryWizard CurQueryWizard = new QueryWizard( serviceFactory, curproperties );
+ CurQueryWizard.startQueryWizard();
}
}
catch (java.lang.Exception jexception)
{
jexception.printStackTrace(System.out);
}
- }*/
+ }
public final XFrame getFrame()
{
@@ -116,7 +173,7 @@ public class QueryWizard extends DatabaseObjectWizard
{
try
{
- if ( CurDBMetaData.getConnection( m_wizardContext ) )
+ if ( m_DBMetaData.getConnection( m_wizardContext ) )
{
reslblFields = m_oResource.getResText(UIConsts.RID_QUERY + 4);
reslblFieldHeader = m_oResource.getResText(UIConsts.RID_QUERY + 19); //Fielnames in AliasComponent
@@ -138,11 +195,11 @@ public class QueryWizard extends DatabaseObjectWizard
setRightPaneHeaders(m_oResource, UIConsts.RID_QUERY + 70, 8);
this.setMaxStep(8);
buildSteps();
- this.CurDBCommandFieldSelection.preselectCommand( m_wizardContext, false );
+ this.m_DBCommandFieldSelectio.preselectCommand( m_wizardContext, false );
XWindowPeer windowPeer = UnoRuntime.queryInterface( XWindowPeer.class, m_frame.getContainerWindow() );
createWindowPeer(windowPeer);
- CurDBMetaData.setWindowPeer(this.xControl.getPeer());
+ m_DBMetaData.setWindowPeer(this.xControl.getPeer());
insertQueryRelatedSteps();
executeDialog( m_frame.getContainerWindow().getPosSize() );
}
@@ -151,14 +208,14 @@ public class QueryWizard extends DatabaseObjectWizard
{
jexception.printStackTrace(System.out);
}
- CurGroupFilterComponent = null;
- CurTitlesComponent = null;
- CurAggregateComponent = null;
- CurDBCommandFieldSelection = null;
+ m_groupFilterComponent = null;
+ m_titlesComponent = null;
+ m_aggregateComponent = null;
+ m_DBCommandFieldSelectio = null;
xWindowPeer = null;
- CurFinalizer = null;
- CurDBMetaData.finish();
- CurDBMetaData = null;
+ m_finalizer = null;
+ m_DBMetaData.finish();
+ m_DBMetaData = null;
System.gc();
return m_createdQuery;
@@ -181,17 +238,17 @@ public class QueryWizard extends DatabaseObjectWizard
case SOAGGREGATE_PAGE:
if (_bEnabled == true)
{
- bEnabled = ((CurDBMetaData.hasNumericalFields()) && (CurDBMetaData.xDBMetaData.supportsCoreSQLGrammar()));
+ bEnabled = ((m_DBMetaData.hasNumericalFields()) && (m_DBMetaData.xDBMetaData.supportsCoreSQLGrammar()));
}
break;
case SOGROUPSELECTION_PAGE:
- bEnabled = CurDBMetaData.Type == QueryMetaData.QueryType.SOSUMMARYQUERY;
+ bEnabled = m_DBMetaData.Type == QueryMetaData.QueryType.SOSUMMARYQUERY;
break;
case SOGROUPFILTER_PAGE:
bEnabled = false;
if (_bEnabled == true)
{
- bEnabled = (CurDBMetaData.GroupByFilterConditions.length > 0);
+ bEnabled = (m_DBMetaData.GroupByFilterConditions.length > 0);
}
break;
@@ -225,11 +282,11 @@ public class QueryWizard extends DatabaseObjectWizard
i = insertRoadmapItem(0, true, SOFIELDSELECTION_PAGE - 1, SOFIELDSELECTION_PAGE);
i = insertRoadmapItem(i, false, SOSORTING_PAGE - 1, SOSORTING_PAGE); // Orderby is always supported
i = insertRoadmapItem(i, false, SOFILTER_PAGE - 1, SOFILTER_PAGE);
- if (CurDBMetaData.xDBMetaData.supportsCoreSQLGrammar())
+ if (m_DBMetaData.xDBMetaData.supportsCoreSQLGrammar())
{
- i = insertRoadmapItem(i, CurDBMetaData.hasNumericalFields(), SOAGGREGATE_PAGE - 1, SOAGGREGATE_PAGE);
+ i = insertRoadmapItem(i, m_DBMetaData.hasNumericalFields(), SOAGGREGATE_PAGE - 1, SOAGGREGATE_PAGE);
}
- if (CurDBMetaData.xDBMetaData.supportsGroupBy())
+ if (m_DBMetaData.xDBMetaData.supportsGroupBy())
{
i = insertRoadmapItem(i, false, SOGROUPSELECTION_PAGE - 1, SOGROUPSELECTION_PAGE);
i = insertRoadmapItem(i, false, SOGROUPFILTER_PAGE - 1, SOGROUPFILTER_PAGE);
@@ -251,28 +308,25 @@ public class QueryWizard extends DatabaseObjectWizard
{
try
{
-// curDBCommandFieldSelection = new CommandFieldSelection(this, curFormDocument.oMainFormDBMetaData, 92, slblFields, slblSelFields, slblTables, true, 34411);
-// curDBCommandFieldSelection.addFieldSelectionListener(new FieldSelectionListener());
-
- CurDBCommandFieldSelection = new CommandFieldSelection(this, CurDBMetaData, 120, reslblFields, reslblSelFields, reslblTables, true, 40850);
- CurDBCommandFieldSelection.setAppendMode(true);
- CurDBCommandFieldSelection.addFieldSelectionListener(new FieldSelectionListener());
- CurSortingComponent = new SortingComponent(this, SOSORTING_PAGE, 95, 27, 210, 40865);
- CurFilterComponent = new FilterComponent(this, xMSF, SOFILTER_PAGE, 97, 27, 209, 3, CurDBMetaData, 40878);
- CurFilterComponent.addNumberFormats();
+ m_DBCommandFieldSelectio = new CommandFieldSelection(this, m_DBMetaData, 120, reslblFields, reslblSelFields, reslblTables, true, 40850);
+ m_DBCommandFieldSelectio.setAppendMode(true);
+ m_DBCommandFieldSelectio.addFieldSelectionListener(new FieldSelectionListener());
+ m_sortingComponent = new SortingComponent(this, SOSORTING_PAGE, 95, 27, 210, 40865);
+ m_filterComponent = new FilterComponent(this, xMSF, SOFILTER_PAGE, 97, 27, 209, 3, m_DBMetaData, 40878);
+ m_filterComponent.addNumberFormats();
- if (CurDBMetaData.xDBMetaData.supportsCoreSQLGrammar())
+ if (m_DBMetaData.xDBMetaData.supportsCoreSQLGrammar())
{
- CurAggregateComponent = new AggregateComponent(this, CurDBMetaData, SOAGGREGATE_PAGE, 97, 69, 209, 5, 40895);
+ m_aggregateComponent = new AggregateComponent(this, m_DBMetaData, SOAGGREGATE_PAGE, 97, 69, 209, 5, 40895);
}
- if (CurDBMetaData.xDBMetaData.supportsGroupBy())
+ if (m_DBMetaData.xDBMetaData.supportsGroupBy())
{
- CurGroupFieldSelection = new FieldSelection(this, SOGROUPSELECTION_PAGE, 95, 27, 210, 150, reslblFields, this.reslblGroupBy, 40915, false);
- CurGroupFieldSelection.addFieldSelectionListener(new FieldSelectionListener());
- CurGroupFilterComponent = new FilterComponent(this, xMSF, SOGROUPFILTER_PAGE, 97, 27, 209, 3, CurDBMetaData, 40923);
+ m_groupFieldSelection = new FieldSelection(this, SOGROUPSELECTION_PAGE, 95, 27, 210, 150, reslblFields, this.reslblGroupBy, 40915, false);
+ m_groupFieldSelection.addFieldSelectionListener(new FieldSelectionListener());
+ m_groupFilterComponent = new FilterComponent(this, xMSF, SOGROUPFILTER_PAGE, 97, 27, 209, 3, m_DBMetaData, 40923);
}
- CurTitlesComponent = new TitlesComponent(this, SOTITLES_PAGE, 97, 37, 207, 7, reslblFieldHeader, reslblAliasHeader, 40940);
- CurFinalizer = new Finalizer(this, CurDBMetaData);
+ m_titlesComponent = new TitlesComponent(this, SOTITLES_PAGE, 97, 37, 207, 7, reslblFieldHeader, reslblAliasHeader, 40940);
+ m_finalizer = new Finalizer(this, m_DBMetaData);
enableNavigationButtons(false, false, false);
}
catch (com.sun.star.uno.Exception exception)
@@ -288,10 +342,10 @@ public class QueryWizard extends DatabaseObjectWizard
|| ( switchToStep( ncurStep, SOSUMMARY_PAGE ) )
)
{
- m_createdQuery = CurFinalizer.finish();
+ m_createdQuery = m_finalizer.finish();
if ( m_createdQuery.length() > 0 )
{
- loadSubComponent( CommandType.QUERY, m_createdQuery, CurFinalizer.displayQueryDesign() );
+ loadSubComponent( CommandType.QUERY, m_createdQuery, m_finalizer.displayQueryDesign() );
xDialog.endExecute();
return true;
}
@@ -305,11 +359,11 @@ public class QueryWizard extends DatabaseObjectWizard
{
if (nOldStep <= SOGROUPSELECTION_PAGE && nNewStep > SOGROUPSELECTION_PAGE)
{
- if (CurDBMetaData.xDBMetaData.supportsGroupBy())
+ if (m_DBMetaData.xDBMetaData.supportsGroupBy())
{
- CurDBMetaData.setGroupFieldNames(CurGroupFieldSelection.getSelectedFieldNames());
- CurDBMetaData.GroupFieldNames = JavaTools.removeOutdatedFields(CurDBMetaData.GroupFieldNames, CurDBMetaData.NonAggregateFieldNames);
- CurDBMetaData.GroupByFilterConditions = JavaTools.removeOutdatedFields(CurDBMetaData.GroupByFilterConditions, CurDBMetaData.GroupFieldNames);
+ m_DBMetaData.setGroupFieldNames(m_groupFieldSelection.getSelectedFieldNames());
+ m_DBMetaData.GroupFieldNames = JavaTools.removeOutdatedFields(m_DBMetaData.GroupFieldNames, m_DBMetaData.NonAggregateFieldNames);
+ m_DBMetaData.GroupByFilterConditions = JavaTools.removeOutdatedFields(m_DBMetaData.GroupByFilterConditions, m_DBMetaData.GroupFieldNames);
}
}
switch (nNewStep)
@@ -317,24 +371,24 @@ public class QueryWizard extends DatabaseObjectWizard
case SOFIELDSELECTION_PAGE:
break;
case SOSORTING_PAGE:
- CurSortingComponent.initialize(CurDBMetaData.getDisplayFieldNames(), CurDBMetaData.getSortFieldNames());
+ m_sortingComponent.initialize(m_DBMetaData.getDisplayFieldNames(), m_DBMetaData.getSortFieldNames());
break;
case SOFILTER_PAGE:
- CurFilterComponent.initialize(CurDBMetaData.getFilterConditions(), CurDBMetaData.getDisplayFieldNames());
+ m_filterComponent.initialize(m_DBMetaData.getFilterConditions(), m_DBMetaData.getDisplayFieldNames());
break;
case SOAGGREGATE_PAGE:
- CurAggregateComponent.initialize();
+ m_aggregateComponent.initialize();
break;
case SOGROUPSELECTION_PAGE:
break;
case SOGROUPFILTER_PAGE:
- CurGroupFilterComponent.initialize(CurDBMetaData.GroupByFilterConditions, CurDBMetaData.getGroupFieldNames());
+ m_groupFilterComponent.initialize(m_DBMetaData.GroupByFilterConditions, m_DBMetaData.getGroupFieldNames());
break;
case SOTITLES_PAGE:
- CurTitlesComponent.initialize(CurDBMetaData.getDisplayFieldNames(), CurDBMetaData.FieldTitleSet);
+ m_titlesComponent.initialize(m_DBMetaData.getDisplayFieldNames(), m_DBMetaData.FieldTitleSet);
break;
case SOSUMMARY_PAGE:
- CurFinalizer.initialize();
+ m_finalizer.initialize();
break;
default:
break;
@@ -351,27 +405,27 @@ public class QueryWizard extends DatabaseObjectWizard
switch (nOldStep)
{
case SOFIELDSELECTION_PAGE:
- CurDBMetaData.reorderFieldColumns(CurDBCommandFieldSelection.getSelectedFieldNames());
- CurDBMetaData.initializeFieldTitleSet(true);
- CurDBMetaData.setNumericFields();
+ m_DBMetaData.reorderFieldColumns(m_DBCommandFieldSelectio.getSelectedFieldNames());
+ m_DBMetaData.initializeFieldTitleSet(true);
+ m_DBMetaData.setNumericFields();
searchForOutdatedFields();
break;
case SOSORTING_PAGE:
- CurDBMetaData.setSortFieldNames(CurSortingComponent.getSortFieldNames());
+ m_DBMetaData.setSortFieldNames(m_sortingComponent.getSortFieldNames());
break;
case SOFILTER_PAGE:
- CurDBMetaData.setFilterConditions(CurFilterComponent.getFilterConditions());
+ m_DBMetaData.setFilterConditions(m_filterComponent.getFilterConditions());
break;
case SOAGGREGATE_PAGE:
- CurDBMetaData.AggregateFieldNames = CurAggregateComponent.getAggregateFieldNames();
+ m_DBMetaData.AggregateFieldNames = m_aggregateComponent.getAggregateFieldNames();
break;
case SOGROUPSELECTION_PAGE:
break;
case SOGROUPFILTER_PAGE:
- CurDBMetaData.setGroupByFilterConditions(this.CurGroupFilterComponent.getFilterConditions());
+ m_DBMetaData.setGroupByFilterConditions(this.m_groupFilterComponent.getFilterConditions());
break;
case SOTITLES_PAGE:
- CurDBMetaData.setFieldTitles(CurTitlesComponent.getFieldTitles());
+ m_DBMetaData.setFieldTitles(m_titlesComponent.getFieldTitles());
break;
case SOSUMMARY_PAGE:
break;
@@ -382,15 +436,15 @@ public class QueryWizard extends DatabaseObjectWizard
{
try
{
- if (CurDBMetaData.Type == QueryMetaData.QueryType.SOSUMMARYQUERY)
+ if (m_DBMetaData.Type == QueryMetaData.QueryType.SOSUMMARYQUERY)
{
- if (CurDBMetaData.xDBMetaData.supportsGroupBy())
+ if (m_DBMetaData.xDBMetaData.supportsGroupBy())
{
- CurDBMetaData.setNonAggregateFieldNames();
- CurGroupFieldSelection.initialize(CurDBMetaData.getUniqueAggregateFieldNames(), false, CurDBMetaData.xDBMetaData.getMaxColumnsInGroupBy());
- CurGroupFieldSelection.intializeSelectedFields(CurDBMetaData.NonAggregateFieldNames);
- CurGroupFieldSelection.setMultipleMode(false);
- setStepEnabled(SOGROUPFILTER_PAGE, CurAggregateComponent.isGroupingpossible() && CurDBMetaData.NonAggregateFieldNames.length > 0);
+ m_DBMetaData.setNonAggregateFieldNames();
+ m_groupFieldSelection.initialize(m_DBMetaData.getUniqueAggregateFieldNames(), false, m_DBMetaData.xDBMetaData.getMaxColumnsInGroupBy());
+ m_groupFieldSelection.intializeSelectedFields(m_DBMetaData.NonAggregateFieldNames);
+ m_groupFieldSelection.setMultipleMode(false);
+ setStepEnabled(SOGROUPFILTER_PAGE, m_aggregateComponent.isGroupingpossible() && m_DBMetaData.NonAggregateFieldNames.length > 0);
}
}
}
@@ -403,18 +457,18 @@ public class QueryWizard extends DatabaseObjectWizard
private void searchForOutdatedFields()
{
- String[] sFieldNames = CurDBMetaData.getFieldNames();
- String[][] sRemovedFields = JavaTools.removeOutdatedFields(CurDBMetaData.getSortFieldNames(), sFieldNames);
- CurDBMetaData.setSortFieldNames(sRemovedFields);
- CurDBMetaData.setFilterConditions(JavaTools.removeOutdatedFields(CurDBMetaData.getFilterConditions(), sFieldNames));
- CurDBMetaData.AggregateFieldNames = JavaTools.removeOutdatedFields(CurDBMetaData.AggregateFieldNames, sFieldNames);
+ String[] sFieldNames = m_DBMetaData.getFieldNames();
+ String[][] sRemovedFields = JavaTools.removeOutdatedFields(m_DBMetaData.getSortFieldNames(), sFieldNames);
+ m_DBMetaData.setSortFieldNames(sRemovedFields);
+ m_DBMetaData.setFilterConditions(JavaTools.removeOutdatedFields(m_DBMetaData.getFilterConditions(), sFieldNames));
+ m_DBMetaData.AggregateFieldNames = JavaTools.removeOutdatedFields(m_DBMetaData.AggregateFieldNames, sFieldNames);
}
private void enableWizardSteps(String[] NewItems)
{
boolean bEnabled = NewItems.length > 0;
- setControlProperty("btnWizardNext", "Enabled", new Boolean(bEnabled));
- setControlProperty("btnWizardFinish", "Enabled", new Boolean(bEnabled));
+ setControlProperty("btnWizardNext", "Enabled", bEnabled);
+ setControlProperty("btnWizardFinish", "Enabled", bEnabled);
enableRoadmapItems(NewItems, bEnabled); // Note: Performancewise this could be improved
}
@@ -446,15 +500,15 @@ public class QueryWizard extends DatabaseObjectWizard
{
if (ID == 1)
{
- CurDBMetaData.addSeveralFieldColumns(SelItems, CurDBCommandFieldSelection.getSelectedCommandName());
+ m_DBMetaData.addSeveralFieldColumns(SelItems, m_DBCommandFieldSelectio.getSelectedCommandName());
enableWizardSteps(NewItems);
- CurDBCommandFieldSelection.changeSelectedFieldNames(CurDBMetaData.getDisplayFieldNames());
- CurDBCommandFieldSelection.toggleCommandListBox(NewItems);
+ m_DBCommandFieldSelectio.changeSelectedFieldNames(m_DBMetaData.getDisplayFieldNames());
+ m_DBCommandFieldSelectio.toggleCommandListBox(NewItems);
}
else
{
- boolean bEnabled = (CurGroupFieldSelection.getSelectedFieldNames().length > 0);
- Helper.setUnoPropertyValue(getRoadmapItemByID(SOGROUPFILTER_PAGE), "Enabled", new Boolean(bEnabled));
+ boolean bEnabled = (m_groupFieldSelection.getSelectedFieldNames().length > 0);
+ Helper.setUnoPropertyValue(getRoadmapItemByID(SOGROUPFILTER_PAGE), "Enabled", bEnabled);
}
}
@@ -464,30 +518,30 @@ public class QueryWizard extends DatabaseObjectWizard
if (ID == 1)
{
enableWizardSteps(NewItems);
- String[] sSelfieldNames = CurDBMetaData.getFieldNames(SelItems, CurDBCommandFieldSelection.getSelectedCommandName());
- CurDBCommandFieldSelection.addItemsToFieldsListbox(sSelfieldNames);
- CurDBMetaData.removeSeveralFieldColumnsByDisplayFieldName(SelItems);
- CurDBCommandFieldSelection.toggleCommandListBox(NewItems);
+ String[] sSelfieldNames = m_DBMetaData.getFieldNames(SelItems, m_DBCommandFieldSelectio.getSelectedCommandName());
+ m_DBCommandFieldSelectio.addItemsToFieldsListbox(sSelfieldNames);
+ m_DBMetaData.removeSeveralFieldColumnsByDisplayFieldName(SelItems);
+ m_DBCommandFieldSelectio.toggleCommandListBox(NewItems);
}
else
{
- boolean bEnabled = (CurGroupFieldSelection.getSelectedFieldNames().length > 0);
+ boolean bEnabled = (m_groupFieldSelection.getSelectedFieldNames().length > 0);
String CurDisplayFieldName = SelItems[0];
- if (JavaTools.FieldInList(CurDBMetaData.NonAggregateFieldNames, CurDisplayFieldName) > -1)
+ if (JavaTools.FieldInList(m_DBMetaData.NonAggregateFieldNames, CurDisplayFieldName) > -1)
{
showMessageBox("ErrorBox", VclWindowPeerAttribute.OK, resmsgNonNumericAsGroupBy);
- CurGroupFieldSelection.xSelectedFieldsListBox.addItems(SelItems, CurGroupFieldSelection.xSelectedFieldsListBox.getItemCount());
- String FieldList[] = CurGroupFieldSelection.xFieldsListBox.getItems();
+ m_groupFieldSelection.xSelectedFieldsListBox.addItems(SelItems, m_groupFieldSelection.xSelectedFieldsListBox.getItemCount());
+ String FieldList[] = m_groupFieldSelection.xFieldsListBox.getItems();
int index = JavaTools.FieldInList(FieldList, CurDisplayFieldName);
if (index > -1)
{
- CurGroupFieldSelection.xFieldsListBox.removeItems((short) index, (short) 1);
+ m_groupFieldSelection.xFieldsListBox.removeItems((short) index, (short) 1);
}
}
else
{
- Helper.setUnoPropertyValue(getRoadmapItemByID(SOGROUPFILTER_PAGE), "Enabled", new Boolean(bEnabled));
+ Helper.setUnoPropertyValue(getRoadmapItemByID(SOGROUPFILTER_PAGE), "Enabled", bEnabled);
}
}
}
diff --git a/wizards/com/sun/star/wizards/ui/FilterComponent.java b/wizards/com/sun/star/wizards/ui/FilterComponent.java
index 2bb9e8765329..e53f0792e268 100644
--- a/wizards/com/sun/star/wizards/ui/FilterComponent.java
+++ b/wizards/com/sun/star/wizards/ui/FilterComponent.java
@@ -27,7 +27,6 @@
package com.sun.star.wizards.ui;
// import java.util.Vector;
-import com.sun.star.awt.ItemEvent;
import com.sun.star.awt.TextEvent;
import com.sun.star.awt.VclWindowPeerAttribute;
import com.sun.star.awt.XControl;
@@ -40,21 +39,22 @@ import com.sun.star.beans.XPropertySet;
import com.sun.star.lang.EventObject;
import com.sun.star.lang.IllegalArgumentException;
import com.sun.star.lang.XMultiServiceFactory;
-import com.sun.star.lib.uno.helper.PropertySet;
+import com.sun.star.sdb.SQLFilterOperator;
import com.sun.star.sdbc.DataType;
import com.sun.star.uno.Any;
import com.sun.star.uno.AnyConverter;
import com.sun.star.uno.Exception;
import com.sun.star.uno.Type;
+import com.sun.star.uno.TypeClass;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.XInterface;
import com.sun.star.wizards.common.NumberFormatter;
import com.sun.star.wizards.common.Helper;
import com.sun.star.wizards.common.HelpIds;
import com.sun.star.wizards.common.JavaTools;
-import com.sun.star.wizards.common.Properties;
import com.sun.star.wizards.db.FieldColumn;
import com.sun.star.wizards.db.QueryMetaData;
+import com.sun.star.wizards.db.SQLQueryComposer;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -62,19 +62,9 @@ public class FilterComponent
{
private Integer IStep;
- // private int iStartPosX;
- // private int iStartPosY;
- // int Count;
private int RowCount;
- // private int FilterCount;
private static String[] sLogicOperators;
- private static String[] sBooleanValues;
- // private /* public */ String[] FieldNames;
- private XRadioButton optMatchAll;
private XRadioButton optMatchAny;
- // private String soptMatchAll;
- // private String soptMatchAny;
- // private String[] sHeadLines;
private String slblFieldNames;
private String slblOperators;
private String slblValue;
@@ -82,7 +72,6 @@ public class FilterComponent
private int BaseID = 2300;
private String sIncSuffix;
private ControlRow[] oControlRows;
- // private Vector FilterNames;
private String sDuplicateCondition;
final int SOOPTORMODE = 100;
final int SOOPTANDMODE = 101;
@@ -128,20 +117,16 @@ public class FilterComponent
final int SO_OPTQUERYMODE = 5;
int SOI_MATCHALL = 0;
int SOI_MATCHANY = 1;
- // int ifilterstate = SOI_MATCHALL;
int curHelpID;
class ItemListenerImpl implements com.sun.star.awt.XItemListener
{
-
public void itemStateChanged(com.sun.star.awt.ItemEvent EventObject)
{
int iKey = CurUnoDialog.getControlKey(EventObject.Source, CurUnoDialog.ControlList);
String sControlName = "";
switch (iKey)
{
- // case SOOPTQUERYMODE:
- // getfilterstate();
case SO_FIRSTFIELDNAME:
case SO_SECONDFIELDNAME:
case SO_THIRDFIELDNAME:
@@ -153,24 +138,11 @@ public class FilterComponent
FieldColumn CurFieldColumn = new FieldColumn(oQueryMetaData, CurDisplayFieldName);
String sControlNameTextValue = "txtValue" + sControlNameSuffix;
-// String sControlNameBooleanList = "lstBoolean" + sControlNameSuffix;
-// if (aFieldColumn.FieldType == DataType.BOOLEAN)
-// {
-// // scheint aufgrund eines Fehlers in Toolkit nicht zu funktionieren
-// CurUnoDialog.setControlVisible(sControlNameTextValue, false);
-// CurUnoDialog.setControlVisible(sControlNameBooleanList, true);
-// }
-// else
-// {
-// CurUnoDialog.setControlVisible(sControlNameTextValue, true);
-// CurUnoDialog.setControlVisible(sControlNameBooleanList, false);
-
XControl xValueControl = CurUnoDialog.xDlgContainer.getControl(sControlNameTextValue);
XInterface xValueModel = (XInterface) UnoDialog.getModel(xValueControl);
Helper.setUnoPropertyValue(xValueModel, "TreatAsNumber", Boolean.valueOf(CurFieldColumn.isNumberFormat()));
final NumberFormatter aNumberFormatter = oQueryMetaData.getNumberFormatter();
aNumberFormatter.setNumberFormat(xValueModel, CurFieldColumn.getDBFormatKey(), aNumberFormatter);
-// }
break;
case SO_FIRSTCONDITION:
@@ -181,7 +153,6 @@ public class FilterComponent
break;
case SOOPTORMODE:
case SOOPTANDMODE:
- // getfilterstate();
return;
case SO_FIRSTBOOLFIELDNAME:
@@ -211,24 +182,6 @@ public class FilterComponent
togglefollowingControlRow(sName);
}
- public void disposing(EventObject EventObject)
- {
- }
- }
-
- public void fieldconditionchanged(ItemEvent EventObject)
- {
- String sName = getControlName(EventObject.Source);
- togglefollowingControlRow(sName);
- }
-
- public void disposing(com.sun.star.lang.EventObject eventObject)
- {
- }
-
- class ActionListenerImpl implements com.sun.star.awt.XActionListener
- {
-
public void disposing(EventObject eventObject)
{
}
@@ -285,6 +238,7 @@ public class FilterComponent
int nFilterCount = getFilterCount();
if (nFilterCount > 0)
{
+ final SQLQueryComposer composer = oQueryMetaData.getSQLQueryComposer();
try
{
final String serviceName = "com.sun.star.beans.PropertyBag";
@@ -292,31 +246,32 @@ public class FilterComponent
column.addProperty("Type", PropertyAttribute.BOUND, DataType.VARCHAR);
column.addProperty("Name", PropertyAttribute.BOUND, "");
+ column.addProperty("Value", (short)( PropertyAttribute.MAYBEVOID | PropertyAttribute.REMOVABLE ), null );
final XPropertySet columnSet = UnoRuntime.queryInterface(XPropertySet.class, column);
- if ( oQueryMetaData.getSQLQueryComposer().getQuery().length() == 0)
+ if ( composer.getQuery().length() == 0)
{
- final String fromClause = oQueryMetaData.getSQLQueryComposer().getFromClause();
- StringBuffer sql = new StringBuffer();
- sql.append(oQueryMetaData.getSQLQueryComposer().getSelectClause(true));
+ final String fromClause = composer.getFromClause();
+ StringBuilder sql = new StringBuilder();
+ sql.append(composer.getSelectClause(true));
sql.append(' ');
sql.append(fromClause);
- oQueryMetaData.getSQLQueryComposer().getQueryComposer().setElementaryQuery(sql.toString());
+ composer.getQueryComposer().setElementaryQuery(sql.toString());
}
- int a = 0;
+ composer.getQueryComposer().setStructuredFilter( new PropertyValue[][] {} );
for (int i = 0; i < RowCount; i++)
{
- ControlRow CurControlRow = oControlRows[i];
- if (CurControlRow.isEnabled())
+ ControlRow currentControlRow = oControlRows[i];
+ if (currentControlRow.isEnabled())
{
- if (CurControlRow.isConditionComplete())
+ if (currentControlRow.isConditionComplete())
{
- String sFieldName = CurControlRow.getSelectedFieldName();
- int nOperator = (int) CurControlRow.getSelectedOperator();
+ String sFieldName = currentControlRow.getSelectedFieldName();
+ int nOperator = (int) currentControlRow.getSelectedOperator();
FieldColumn aFieldColumn = oQueryMetaData.getFieldColumnByDisplayName(sFieldName);
columnSet.setPropertyValue("Name", aFieldColumn.getFieldName());
columnSet.setPropertyValue("Type", aFieldColumn.getXColumnPropertySet().getPropertyValue("Type"));
- Object value = CurControlRow.getValue();
+ Object value = currentControlRow.getValue();
switch(aFieldColumn.getFieldType())
{
case DataType.TIMESTAMP:
@@ -324,13 +279,24 @@ public class FilterComponent
value = ((Double)value) - oQueryMetaData.getNullDateCorrection();
break;
}
- column.addProperty("Value", PropertyAttribute.MAYBEVOID, value);
+ column.removeProperty( "Value" );
+ final short operator = currentControlRow.getSelectedOperator();
+ if ( ( operator == SQLFilterOperator.SQLNULL )
+ || ( operator == SQLFilterOperator.NOT_SQLNULL )
+ || AnyConverter.isVoid( value )
+ )
+ {
+ column.addProperty("Value", (short)( PropertyAttribute.MAYBEVOID | PropertyAttribute.REMOVABLE ), new String() );
+ value = new Any( new Type( TypeClass.VOID ), null );
+ }
+ else
+ column.addProperty("Value", (short)( PropertyAttribute.MAYBEVOID | PropertyAttribute.REMOVABLE ), value );
columnSet.setPropertyValue("Value", value);
- oQueryMetaData.getSQLQueryComposer().getQueryComposer().appendFilterByColumn(columnSet, getfilterstate() == this.SOI_MATCHALL,nOperator);
+ composer.getQueryComposer().appendFilterByColumn(columnSet, getfilterstate() == this.SOI_MATCHALL,nOperator);
}
}
}
- filterconditions = oQueryMetaData.getSQLQueryComposer().getQueryComposer().getStructuredFilter();
+ filterconditions = composer.getNormalizedStructuredFilter();
int[] iduplicate = JavaTools.getDuplicateFieldIndex(filterconditions);
if (iduplicate[0] != -1)
{
@@ -338,9 +304,7 @@ public class FilterComponent
String smsgDuplicateCondition = getDisplayCondition(sDuplicateCondition, aduplicatecondition, null);
CurUnoDialog.showMessageBox("WarningBox", VclWindowPeerAttribute.OK, smsgDuplicateCondition);
CurUnoDialog.vetoableChange(new java.beans.PropertyChangeEvent(CurUnoDialog, "Steps", Integer.valueOf(1), Integer.valueOf(2)));
- return new PropertyValue[][]
- {
- };
+ return new PropertyValue[][]{};
}
}
catch (Exception ex)
@@ -403,22 +367,6 @@ public class FilterComponent
return ifilterstate;
}
- private void addfiltercondition(int _index, String _curFieldName, Object _curValue, int _curOperator)
- {
- String ValString = String.valueOf(_curValue);
- PropertyValue oPropertyValue = Properties.createProperty(_curFieldName, ValString, _curOperator);
- getfilterstate();
- if (getfilterstate() == this.SOI_MATCHALL)
- {
- if (_index == 0)
- {
- filterconditions[0] = new PropertyValue[getFilterCount()];
- }
- filterconditions[0][_index] = new PropertyValue();
- filterconditions[0][_index] = oPropertyValue;
- }
- }
-
private int getFilterCount()
{
int a = 0;
@@ -430,8 +378,6 @@ public class FilterComponent
}
}
return a;
- // FilterCount = a;
- // return FilterCount;
}
/** Creates a new instance of FilterComponent
@@ -457,8 +403,6 @@ public class FilterComponent
this.oQueryMetaData = _oQueryMetaData;
boolean bEnabled;
sIncSuffix = com.sun.star.wizards.common.Desktop.getIncrementSuffix(CurUnoDialog.getDlgNameAccess(), "optMatchAll");
- // iStartPosX = iPosX;
- // iStartPosY = iPosY;
String soptMatchAll = CurUnoDialog.m_oResource.getResText(BaseID + 9);
String soptMatchAny = CurUnoDialog.m_oResource.getResText(BaseID + 10);
@@ -466,14 +410,13 @@ public class FilterComponent
slblOperators = CurUnoDialog.m_oResource.getResText(BaseID + 24);
slblValue = CurUnoDialog.m_oResource.getResText(BaseID + 25);
sLogicOperators = CurUnoDialog.m_oResource.getResArray(BaseID + 26, 10 /* 7 */); // =, <>, <, >, <=, >=, like, !like, is null, !is null
- sBooleanValues = CurUnoDialog.m_oResource.getResArray(BaseID + 36, 2); // true, false
sDuplicateCondition = CurUnoDialog.m_oResource.getResText(BaseID + 89);
// create Radiobuttons
// * match all
// * match one
- optMatchAll = CurUnoDialog.insertRadioButton("optMatchAll" + sIncSuffix, SOOPTANDMODE, new ItemListenerImpl(),
+ CurUnoDialog.insertRadioButton("optMatchAll" + sIncSuffix, SOOPTANDMODE, new ItemListenerImpl(),
new String[]
{
"Height",
@@ -534,13 +477,6 @@ public class FilterComponent
public void initialize(PropertyValue[][] _filterconditions, String[] _fieldnames)
{
- // String aFieldNamesWithAdditionalEmpty[] = new String[_fieldnames.length + 1];
- // for (int i = 0; i < _fieldnames.length; i++)
- // {
- // aFieldNamesWithAdditionalEmpty[i] = _fieldnames[i];
- // }
- // aFieldNamesWithAdditionalEmpty[_fieldnames.length] = "";
-
int i;
for (i = 0; i < RowCount; i++)
{
@@ -593,9 +529,8 @@ public class FilterComponent
//
//
// -------------------------------------------------------------------------
- class ControlRow
+ final class ControlRow
{
-
private final static int SOLSTFIELDNAME = 3;
private final static int SOLSTOPERATOR = 4;
private final static int SOTXTVALUE = 5;
@@ -776,7 +711,6 @@ public class FilterComponent
Short.valueOf(curtabindex++),
Integer.valueOf(nValueWidth)
});
-
}
catch (Exception exception)
{
@@ -821,13 +755,6 @@ public class FilterComponent
String sValue = (String.valueOf(oValue));
return (!sValue.equals(""));
}
-// String sBoolValue="";
-// short aSelectedBoolValue[] = (short[])Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[6]), "SelectedItems");
-// if (aSelectedBoolValue.length > 0)
-// {
-// sBoolValue = String.valueOf(aSelectedBoolValue[0] == 1);
-// return !sBoolValue.equals("");
-// }
}
}
return false;
@@ -839,16 +766,10 @@ public class FilterComponent
}
}
- private void fieldnamechanged(ItemEvent EventObject)
- {
- int i = 0;
- }
-
protected void setCondition(PropertyValue _filtercondition)
{
try
{
- int ikey;
XListBox xFieldsListBox = (XListBox) UnoRuntime.queryInterface(XListBox.class, ControlElements[SOLSTFIELDNAME]);
xFieldsListBox.selectItem(_filtercondition.Name, true);
XListBox xOperatorListBox = (XListBox) UnoRuntime.queryInterface(XListBox.class, ControlElements[SOLSTOPERATOR]);
@@ -918,8 +839,8 @@ public class FilterComponent
private void settovoid()
{
- CurUnoDialog.deselectListBox(ControlElements[SOLSTFIELDNAME]);
- CurUnoDialog.deselectListBox(ControlElements[SOLSTOPERATOR]);
+ WizardDialog.deselectListBox(ControlElements[SOLSTFIELDNAME]);
+ WizardDialog.deselectListBox(ControlElements[SOLSTOPERATOR]);
Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), "EffectiveValue", com.sun.star.uno.Any.VOID);
}
@@ -954,7 +875,7 @@ public class FilterComponent
}
else if (!isConditionComplete())
{
- CurUnoDialog.deselectListBox(ControlElements[SOLSTOPERATOR]);
+ WizardDialog.deselectListBox(ControlElements[SOLSTOPERATOR]);
}
}
@@ -1025,43 +946,9 @@ public class FilterComponent
protected String getDateTimeString(boolean bgetDate)
{
- double dblValue = ((Double) getValue()).doubleValue();
- NumberFormatter oNumberFormatter = oQueryMetaData.getNumberFormatter();
- return oNumberFormatter.convertNumberToString(iDateTimeFormat, dblValue);
+ double dblValue = ((Double) getValue()).doubleValue();
+ NumberFormatter oNumberFormatter = oQueryMetaData.getNumberFormatter();
+ return oNumberFormatter.convertNumberToString(iDateTimeFormat, dblValue);
}
}
}
-// com.sun.star.sdb.SQLFilterOperator.EQUAL
-// com.sun.star.sdb.SQLFilterOperator.NOT_EQUAL
-// com.sun.star.sdb.SQLFilterOperator.LESS
-// com.sun.star.sdb.SQLFilterOperator.GREATER
-// com.sun.star.sdb.SQLFilterOperator.LESS_EQUAL
-// com.sun.star.sdb.SQLFilterOperator.GREATER_EQUAL
-// com.sun.star.sdb.SQLFilterOperator.LIKE
-// com.sun.star.sdb.SQLFilterOperator.NOT_LIKE
-// com.sun.star.sdb.SQLFilterOperator.SQLNULL
-// com.sun.star.sdb.SQLFilterOperator.NOT_SQLNULL
-
-/* constants SQLFilterOperator
-{
-/// equal to
-const long EQUAL = 1;
-/// not equal to
-const long NOT_EQUAL = 2;
-/// less than
-const long LESS = 3;
-/// greater than
-const long GREATER = 4;
-/// less or eqal than
-const long LESS_EQUAL = 5;
-/// greater or eqal than
-const long GREATER_EQUAL = 6;
-/// like
-const long LIKE = 7;
-/// not like
-const long NOT_LIKE = 8;
-/// is null
-const long SQLNULL = 9;
-/// is not null
-const long NOT_SQLNULL = 10;
-}; */