summaryrefslogtreecommitdiff
path: root/wizards
diff options
context:
space:
mode:
authorFrank Schoenheit [fs] <frank.schoenheit@sun.com>2010-02-04 10:38:39 +0100
committerFrank Schoenheit [fs] <frank.schoenheit@sun.com>2010-02-04 10:38:39 +0100
commit2176aee8e22caf0396c1b3b544a3549a0a417a8f (patch)
tree36d0682e2aec8719ac65b8ca0be0d050d75a925f /wizards
parent722556b9cd099cbb352cb11692ec1b27adfac5dd (diff)
parent055bc5c7f48cd556d256dedc32671f60ad30ccf4 (diff)
autorecovery: commit resolved merge (after rebase to m71)
Diffstat (limited to 'wizards')
-rw-r--r--wizards/com/sun/star/wizards/db/DBMetaData.java89
-rw-r--r--wizards/com/sun/star/wizards/query/Finalizer.java10
-rw-r--r--wizards/com/sun/star/wizards/query/QueryWizard.java4
-rw-r--r--wizards/com/sun/star/wizards/report/IReportDocument.java2
-rw-r--r--wizards/com/sun/star/wizards/report/ReportFinalizer.java32
-rw-r--r--wizards/com/sun/star/wizards/report/ReportTextImplementation.java2
-rw-r--r--wizards/com/sun/star/wizards/reportbuilder/ReportBuilderImplementation.java29
-rw-r--r--wizards/com/sun/star/wizards/table/TableWizard.java6
8 files changed, 101 insertions, 73 deletions
diff --git a/wizards/com/sun/star/wizards/db/DBMetaData.java b/wizards/com/sun/star/wizards/db/DBMetaData.java
index 296d73c5c31a..74981293a085 100644
--- a/wizards/com/sun/star/wizards/db/DBMetaData.java
+++ b/wizards/com/sun/star/wizards/db/DBMetaData.java
@@ -76,6 +76,7 @@ import com.sun.star.sdb.XCompletedConnection;
import com.sun.star.lang.Locale;
import com.sun.star.lang.XSingleServiceFactory;
import com.sun.star.sdb.XQueriesSupplier;
+import com.sun.star.sdbc.XConnection;
import com.sun.star.sdbcx.XTablesSupplier;
import com.sun.star.wizards.common.Configuration;
import com.sun.star.wizards.common.Desktop;
@@ -85,14 +86,18 @@ import com.sun.star.wizards.common.NumberFormatter;
import com.sun.star.wizards.common.Properties;
import com.sun.star.wizards.common.Resource;
import com.sun.star.wizards.common.SystemDialog;
+import com.sun.star.uno.Any;
import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;
public class DBMetaData
{
private XNameAccess xQueryNames;
public XDatabaseMetaData xDBMetaData;
- private XDataSource xDataSource;
+ private XDataSource m_dataSource;
+ private XPropertySet m_dataSourceSettings;
private XOfficeDatabaseDocument xModel;
private XPropertySet xDataSourcePropertySet;
public String[] DataSourceNames;
@@ -150,13 +155,10 @@ public class DBMetaData
private int iMaxColumnNameLength = -1;
private int iMaxTableNameLength = -1;
private boolean bPasswordIsRequired;
- // private boolean bFormatKeysareset = false;
private final static int NOLIMIT = 9999999;
protected final static int RID_DB_COMMON = 1000;
private final static int INVALID = 9999999;
public TypeInspector oTypeInspector;
- private PropertyValue[] aInfoPropertyValues = null;
- private boolean bisSQL92CheckEnabled = false;
private NumberFormatter oNumberFormatter = null;
private long lDateCorrection = INVALID;
private boolean bdisposeConnection = false;
@@ -526,24 +528,28 @@ public class DBMetaData
}
}
+ private void ensureDataSourceSettings() throws UnknownPropertyException, WrappedTargetException
+ {
+ if ( m_dataSourceSettings != null )
+ return;
+
+ XPropertySet dataSourceProperties = UnoRuntime.queryInterface( XPropertySet.class, getDataSource() );
+ m_dataSourceSettings = UnoRuntime.queryInterface( XPropertySet.class, dataSourceProperties.getPropertyValue( "Settings" ) );
+ }
+
public boolean isSQL92CheckEnabled()
{
+ boolean isSQL92CheckEnabled = false;
try
{
- if (aInfoPropertyValues == null)
- {
- aInfoPropertyValues = (PropertyValue[]) AnyConverter.toArray(this.xDataSourcePropertySet.getPropertyValue("Info"));
- if (Properties.hasPropertyValue(aInfoPropertyValues, "EnableSQL92Check"))
- {
- bisSQL92CheckEnabled = AnyConverter.toBoolean(Properties.getPropertyValue(aInfoPropertyValues, "EnableSQL92Check"));
- }
- }
+ ensureDataSourceSettings();
+ isSQL92CheckEnabled = AnyConverter.toBoolean( m_dataSourceSettings.getPropertyValue( "EnableSQL92Check" ) );
}
catch (Exception e)
{
e.printStackTrace();
}
- return bisSQL92CheckEnabled;
+ return isSQL92CheckEnabled;
}
public String verifyName(String _sname, int _maxlen)
@@ -561,12 +567,12 @@ public class DBMetaData
public XDataSource getDataSource()
{
- if (xDataSource == null)
+ if (m_dataSource == null)
{
try
{
Object oDataSource = xNameAccess.getByName(DataSourceName);
- xDataSource = UnoRuntime.queryInterface( XDataSource.class, oDataSource );
+ m_dataSource = UnoRuntime.queryInterface( XDataSource.class, oDataSource );
}
catch (com.sun.star.container.NoSuchElementException e)
{
@@ -575,7 +581,7 @@ public class DBMetaData
{
}
}
- return xDataSource;
+ return m_dataSource;
}
private void setDataSourceByName(String _DataSourceName, boolean bgetInterfaces)
@@ -607,22 +613,21 @@ public class DBMetaData
{
try
{
- com.sun.star.sdbc.XConnection xConnection = null;
+ XConnection xConnection = null;
if (Properties.hasPropertyValue(curproperties, "ActiveConnection"))
{
- xConnection = (com.sun.star.sdbc.XConnection) AnyConverter.toObject(com.sun.star.sdbc.XConnection.class,
- Properties.getPropertyValue(curproperties, "ActiveConnection"));
+ xConnection = UnoRuntime.queryInterface( XConnection.class, Properties.getPropertyValue( curproperties, "ActiveConnection" ) );
if (xConnection != null)
{
com.sun.star.container.XChild child = UnoRuntime.queryInterface( com.sun.star.container.XChild.class, xConnection );
- xDataSource = UnoRuntime.queryInterface( XDataSource.class, child.getParent() );
- XDocumentDataSource xDocu = UnoRuntime.queryInterface( XDocumentDataSource.class, this.xDataSource );
+ m_dataSource = UnoRuntime.queryInterface( XDataSource.class, child.getParent() );
+ XDocumentDataSource xDocu = UnoRuntime.queryInterface( XDocumentDataSource.class, m_dataSource );
if (xDocu != null)
{
xModel = xDocu.getDatabaseDocument();
}
- XPropertySet xPSet = UnoRuntime.queryInterface( XPropertySet.class, xDataSource );
+ XPropertySet xPSet = UnoRuntime.queryInterface( XPropertySet.class, m_dataSource );
if (xPSet != null)
{
DataSourceName = AnyConverter.toString(xPSet.getPropertyValue("Name"));
@@ -645,13 +650,13 @@ public class DBMetaData
}
else if (Properties.hasPropertyValue(curproperties, "DataSource"))
{
- xDataSource = UnoRuntime.queryInterface( XDataSource.class, Properties.getPropertyValue( curproperties, "DataSource" ) );
- XDocumentDataSource xDocu = UnoRuntime.queryInterface( XDocumentDataSource.class, this.xDataSource );
+ m_dataSource = UnoRuntime.queryInterface( XDataSource.class, Properties.getPropertyValue( curproperties, "DataSource" ) );
+ XDocumentDataSource xDocu = UnoRuntime.queryInterface( XDocumentDataSource.class, this.m_dataSource );
if (xDocu != null)
{
xModel = xDocu.getDatabaseDocument();
}
- return getConnection(xDataSource);
+ return getConnection(m_dataSource);
}
if (Properties.hasPropertyValue(curproperties, "DatabaseLocation"))
{
@@ -702,7 +707,7 @@ public class DBMetaData
}
}
- private boolean getConnection(XDataSource xDataSource)
+ private boolean getConnection(XDataSource _dataSource)
{
Resource oResource = new Resource(xMSF, "Database", "dbw");
try
@@ -716,20 +721,19 @@ public class DBMetaData
getDataSourceInterfaces();
if (bPasswordIsRequired == false)
{
- DBConnection = xDataSource.getConnection("", "");
+ DBConnection = _dataSource.getConnection("", "");
bgetConnection = true;
}
else
{
- XInterface xInteractionHandler = (XInterface) xMSF.createInstance("com.sun.star.task.InteractionHandler");
- XInteractionHandler oInteractionHandler2 = UnoRuntime.queryInterface( XInteractionHandler.class, xInteractionHandler );
+ XInteractionHandler xInteractionHandler = UnoRuntime.queryInterface( XInteractionHandler.class, xMSF.createInstance("com.sun.star.task.InteractionHandler") );
boolean bExitLoop = true;
do
{
- XCompletedConnection xCompleted2 = UnoRuntime.queryInterface( XCompletedConnection.class, xDataSource );
+ XCompletedConnection xCompleted2 = UnoRuntime.queryInterface( XCompletedConnection.class, _dataSource );
try
{
- DBConnection = xCompleted2.connectWithCompletion(oInteractionHandler2);
+ DBConnection = xCompleted2.connectWithCompletion( xInteractionHandler );
bgetConnection = DBConnection != null;
if (bgetConnection == false)
{
@@ -803,6 +807,25 @@ public class DBMetaData
}
}
+ public boolean supportsPrimaryKeys()
+ {
+ boolean supportsPrimaryKeys = false;
+ try
+ {
+ ensureDataSourceSettings();
+ Any primaryKeySupport = (Any)m_dataSourceSettings.getPropertyValue( "PrimaryKeySupport" );
+ if ( AnyConverter.isVoid( primaryKeySupport ) )
+ supportsPrimaryKeys = supportsCoreSQLGrammar();
+ else
+ supportsPrimaryKeys = AnyConverter.toBoolean( primaryKeySupport );
+ }
+ catch ( Exception ex )
+ {
+ Logger.getLogger( DBMetaData.class.getName() ).log( Level.SEVERE, null, ex );
+ }
+ return supportsPrimaryKeys;
+ }
+
public boolean supportsCoreSQLGrammar()
{
try
@@ -830,7 +853,7 @@ public class DBMetaData
{
try
{
- XQueryDefinitionsSupplier xQueryDefinitionsSuppl = UnoRuntime.queryInterface( XQueryDefinitionsSupplier.class, xDataSource );
+ XQueryDefinitionsSupplier xQueryDefinitionsSuppl = UnoRuntime.queryInterface( XQueryDefinitionsSupplier.class, m_dataSource );
XNameAccess xQueryDefs = xQueryDefinitionsSuppl.getQueryDefinitions();
XSingleServiceFactory xSSFQueryDefs = UnoRuntime.queryInterface( XSingleServiceFactory.class, xQueryDefs );
Object oQuery = xSSFQueryDefs.createInstance(); //"com.sun.star.sdb.QueryDefinition"
@@ -1136,7 +1159,7 @@ public class DBMetaData
xNameAccess = null;
xDatabaseContext = null;
xDBMetaData = null;
- xDataSource = null;
+ m_dataSource = null;
xModel = null;
xCompleted = null;
xDataSourcePropertySet = null;
diff --git a/wizards/com/sun/star/wizards/query/Finalizer.java b/wizards/com/sun/star/wizards/query/Finalizer.java
index 24f71220c5c7..083669192bab 100644
--- a/wizards/com/sun/star/wizards/query/Finalizer.java
+++ b/wizards/com/sun/star/wizards/query/Finalizer.java
@@ -31,6 +31,7 @@ package com.sun.star.wizards.query;
import com.sun.star.wizards.common.*;
import com.sun.star.awt.XRadioButton;
+import com.sun.star.awt.XTextComponent;
import com.sun.star.wizards.db.*;
import com.sun.star.lang.IllegalArgumentException;
import com.sun.star.lang.XComponent;
@@ -44,7 +45,7 @@ public class Finalizer
{
private QueryWizard m_queryWizard;
private String resQuery;
- private Object m_aTxtTitle;
+ private XTextComponent m_aTxtTitle;
private XRadioButton xRadioDisplayQuery;
private QuerySummary CurDBMetaData;
@@ -74,7 +75,7 @@ public class Finalizer
{
new Integer(8), reslblQueryTitle, new Integer(95), new Integer(27), new Integer(QueryWizard.SOSUMMARY_PAGE), new Short(curtabindex++), new Integer(52)
});
- m_aTxtTitle = m_queryWizard.insertTextField("txtQueryTitle", 0, null, new String[]
+ m_aTxtTitle = m_queryWizard.insertTextField("txtQueryTitle", "changeTitle", this, new String[]
{
"Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width"
},
@@ -127,6 +128,11 @@ public class Finalizer
});
}
+ public void changeTitle()
+ {
+ final String TitleName = m_aTxtTitle.getText();
+ CurUnoDialog.enableFinishButton(!"".equals(TitleName));
+ }
/* TODO: The title textbox always has to be updated when
a new Table has been selected if it is clear that the user has not made any input meanwhile
*/
diff --git a/wizards/com/sun/star/wizards/query/QueryWizard.java b/wizards/com/sun/star/wizards/query/QueryWizard.java
index e46065a4d430..c9e4148dd3e1 100644
--- a/wizards/com/sun/star/wizards/query/QueryWizard.java
+++ b/wizards/com/sun/star/wizards/query/QueryWizard.java
@@ -295,6 +295,10 @@ public class QueryWizard extends DatabaseObjectWizard
loadSubComponent( CommandType.QUERY, m_createdQuery, CurFinalizer.displayQueryDesign() );
xDialog.endExecute();
}
+ else
+ {
+ setControlProperty("btnWizardFinish", "Enabled", false);
+ }
}
}
diff --git a/wizards/com/sun/star/wizards/report/IReportDocument.java b/wizards/com/sun/star/wizards/report/IReportDocument.java
index af8476f5c3e9..e94f93bf9d2e 100644
--- a/wizards/com/sun/star/wizards/report/IReportDocument.java
+++ b/wizards/com/sun/star/wizards/report/IReportDocument.java
@@ -204,7 +204,7 @@ public interface IReportDocument
* @param Name
* @param OpenMode
*/
- public void store(String Name, int OpenMode);
+ public void store(String Name, int OpenMode) throws com.sun.star.uno.Exception;
/**
* The current report is added to the DB View under the given name
diff --git a/wizards/com/sun/star/wizards/report/ReportFinalizer.java b/wizards/com/sun/star/wizards/report/ReportFinalizer.java
index 8c0df7c36c5c..9ffb89b768f5 100644
--- a/wizards/com/sun/star/wizards/report/ReportFinalizer.java
+++ b/wizards/com/sun/star/wizards/report/ReportFinalizer.java
@@ -244,8 +244,9 @@ public class ReportFinalizer
public void changeReportTitle()
{
- String TitleName = xTitleTextBox.getText();
+ final String TitleName = xTitleTextBox.getText();
CurReportDocument.liveupdate_updateReportTitle(TitleName);
+ CurUnoDialog.enableFinishButton(!"".equals(TitleName));
}
public int getReportOpenMode()
@@ -272,18 +273,25 @@ public class ReportFinalizer
public boolean finish()
{
StoreName = getStoreName();
- if (CurReportDocument.getRecordParser().getReportDocuments().hasByHierarchicalName(StoreName))
+ if (!CurReportDocument.getRecordParser().getReportDocuments().hasByHierarchicalName(StoreName))
{
- String sMsgReportDocumentNameDuplicate = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 76);
- String sShowMsgReportNameisDuplicate = JavaTools.replaceSubString(sMsgReportDocumentNameDuplicate, StoreName, "%REPORTNAME");
- /* int iMsg = */ CurUnoDialog.showMessageBox("ErrorBox", VclWindowPeerAttribute.OK, sShowMsgReportNameisDuplicate);
- return false;
- }
- else
- {
- CurReportDocument.store(StoreName, getReportOpenMode());
- ReportWizard.bCloseDocument = false;
- return true;
+ try
+ {
+ CurReportDocument.store(StoreName, getReportOpenMode());
+ ReportWizard.bCloseDocument = false;
+ return true;
+ }
+ catch(Exception e)
+ {
+ CurUnoDialog.showMessageBox("ErrorBox", VclWindowPeerAttribute.OK,e.getLocalizedMessage() );
+ CurUnoDialog.enableFinishButton(false);
+ return false;
+ }
}
+ String sMsgReportDocumentNameDuplicate = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 76);
+ String sShowMsgReportNameisDuplicate = JavaTools.replaceSubString(sMsgReportDocumentNameDuplicate, StoreName, "%REPORTNAME");
+ /* int iMsg = */ CurUnoDialog.showMessageBox("ErrorBox", VclWindowPeerAttribute.OK, sShowMsgReportNameisDuplicate);
+ CurUnoDialog.enableFinishButton(false);
+ return false;
}
}
diff --git a/wizards/com/sun/star/wizards/report/ReportTextImplementation.java b/wizards/com/sun/star/wizards/report/ReportTextImplementation.java
index 3d79c5d2d8ac..6e0091b52ef5 100644
--- a/wizards/com/sun/star/wizards/report/ReportTextImplementation.java
+++ b/wizards/com/sun/star/wizards/report/ReportTextImplementation.java
@@ -480,7 +480,7 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme
return m_aDoc.xMSFDoc;
}
- public void store(String _sName, int _nOpenMode)
+ public void store(String _sName, int _nOpenMode) throws com.sun.star.uno.Exception
{
getDoc().createReportForm(ReportWizard.SOREPORTFORMNAME);
// int nOpenMode = getReportOpenMode();
diff --git a/wizards/com/sun/star/wizards/reportbuilder/ReportBuilderImplementation.java b/wizards/com/sun/star/wizards/reportbuilder/ReportBuilderImplementation.java
index dad827841e96..2972e8153787 100644
--- a/wizards/com/sun/star/wizards/reportbuilder/ReportBuilderImplementation.java
+++ b/wizards/com/sun/star/wizards/reportbuilder/ReportBuilderImplementation.java
@@ -37,7 +37,7 @@ import com.sun.star.wizards.report.*;
import com.sun.star.awt.XWindowPeer;
import com.sun.star.beans.PropertyValue;
import com.sun.star.beans.XPropertySet;
-import com.sun.star.container.XNameAccess;
+import com.sun.star.container.XHierarchicalNameContainer;
import com.sun.star.container.XNameContainer;
import com.sun.star.frame.XController;
import com.sun.star.frame.XDispatch;
@@ -340,7 +340,7 @@ public class ReportBuilderImplementation extends ReportImplementationHelper
throw new UnsupportedOperationException("Not supported yet.");
}
- public void store(String Name, int OpenMode)
+ public void store(String Name, int OpenMode) throws com.sun.star.uno.Exception
{
// throw new UnsupportedOperationException("Not supported yet.");
// getReportBuilderLayouter().store(Name);
@@ -351,27 +351,14 @@ public class ReportBuilderImplementation extends ReportImplementationHelper
return;
}
- try
- {
- final XNameAccess aNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, m_aReportDocument);
- final String[] aNames = aNameAccess.getElementNames();
-
-// m_xReportDefinition.storeToStorage(m_xReportDefinition.getDocumentStorage(), m_xReportDefinition.getArgs());
-
- final XCommandProcessor xProcessor = (XCommandProcessor) UnoRuntime.queryInterface(XCommandProcessor.class, m_aDocumentDefinition);
- com.sun.star.ucb.Command aCommand = new com.sun.star.ucb.Command();
- aCommand.Name = "storeOwn";
+ final XCommandProcessor xProcessor = UnoRuntime.queryInterface(XCommandProcessor.class, m_aDocumentDefinition);
+ final com.sun.star.ucb.Command aCommand = new com.sun.star.ucb.Command();
+ aCommand.Name = "storeOwn";
- final Object aObj2 = xProcessor.execute(aCommand, xProcessor.createCommandIdentifier(), null);
+ final Object aObj2 = xProcessor.execute(aCommand, xProcessor.createCommandIdentifier(), null);
- final XNameContainer aNameContainer = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, m_aReportDocument);
-// aNameContainer.insertByName(Name, m_xReportDefinition);
- aNameContainer.insertByName(Name, m_aDocumentDefinition);
- }
- catch (Exception e)
- {
- int dummy = 0;
- }
+ final XHierarchicalNameContainer aNameContainer = UnoRuntime.queryInterface(XHierarchicalNameContainer.class, m_aReportDocument);
+ aNameContainer.insertByHierarchicalName(Name, m_aDocumentDefinition);
}
public boolean liveupdate_addGroupNametoDocument(String[] GroupNames, String CurGroupTitle, Vector GroupFieldVector, ArrayList ReportPath, int iSelCount)
diff --git a/wizards/com/sun/star/wizards/table/TableWizard.java b/wizards/com/sun/star/wizards/table/TableWizard.java
index 84accf582174..18a0a2a80e65 100644
--- a/wizards/com/sun/star/wizards/table/TableWizard.java
+++ b/wizards/com/sun/star/wizards/table/TableWizard.java
@@ -250,7 +250,7 @@ public class TableWizard extends DatabaseObjectWizard implements XTextListener,
{
curScenarioSelector = new ScenarioSelector(this, this.curTableDescriptor, slblFields, slblSelFields);
curFieldFormatter = new FieldFormatter(this, curTableDescriptor);
- if (this.curTableDescriptor.supportsCoreSQLGrammar())
+ if ( this.curTableDescriptor.supportsPrimaryKeys() )
{
curPrimaryKeyHandler = new PrimaryKeyHandler(this, curTableDescriptor);
}
@@ -264,7 +264,7 @@ public class TableWizard extends DatabaseObjectWizard implements XTextListener,
boolean bTableCreated = false;
String schemaname = curFinalizer.getSchemaName();
String catalogname = curFinalizer.getCatalogName();
- if (curTableDescriptor.supportsCoreSQLGrammar())
+ if (curTableDescriptor.supportsPrimaryKeys())
{
String[] keyfieldnames = curPrimaryKeyHandler.getPrimaryKeyFields(curTableDescriptor);
if (keyfieldnames != null)
@@ -353,7 +353,7 @@ public class TableWizard extends DatabaseObjectWizard implements XTextListener,
int i = 0;
i = insertRoadmapItem(0, true, m_oResource.getResText(UIConsts.RID_TABLE + 2), SOMAINPAGE);
i = insertRoadmapItem(i, false, m_oResource.getResText(UIConsts.RID_TABLE + 3), SOFIELDSFORMATPAGE);
- if (this.curTableDescriptor.supportsCoreSQLGrammar())
+ if (this.curTableDescriptor.supportsPrimaryKeys())
{
i = insertRoadmapItem(i, false, m_oResource.getResText(UIConsts.RID_TABLE + 4), SOPRIMARYKEYPAGE);
}