From fb287ba7c5fdacfefba0dabf81211b6d1759453e Mon Sep 17 00:00:00 2001
From: "Ocke Janssen [oj]" <Ocke.Janssen@sun.com>
Date: Thu, 19 Nov 2009 13:25:39 +0100
Subject: dba33d: #i104844# check name and do not close when name is wrong

---
 wizards/com/sun/star/wizards/query/Finalizer.java  | 16 +++++++----
 .../com/sun/star/wizards/query/QueryWizard.java    |  4 +++
 .../sun/star/wizards/report/IReportDocument.java   |  2 +-
 .../sun/star/wizards/report/ReportFinalizer.java   | 32 ++++++++++++++--------
 .../wizards/report/ReportTextImplementation.java   |  2 +-
 .../reportbuilder/ReportBuilderImplementation.java | 29 ++++++--------------
 6 files changed, 45 insertions(+), 40 deletions(-)

(limited to 'wizards')

diff --git a/wizards/com/sun/star/wizards/query/Finalizer.java b/wizards/com/sun/star/wizards/query/Finalizer.java
index 7079b1109742..0a7f0a42aec8 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 CurUnoDialog;
     private String resQuery;
     private Object m_aTxtSummary;
-    private Object m_aTxtTitle;
+    private XTextComponent m_aTxtTitle;
     private XRadioButton xRadioDisplayQuery;
     private XRadioButton xRadioModifyQuery;
     private QuerySummary CurDBMetaData;
@@ -75,7 +76,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 = CurUnoDialog.insertTextField("txtQueryTitle", 0, null, new String[]
+        m_aTxtTitle = CurUnoDialog.insertTextField("txtQueryTitle", "changeTitle", this, new String[]
                 {
                     "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width"
                 },
@@ -128,6 +129,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
      */
@@ -191,11 +197,11 @@ public class Finalizer
                                 CurUnoDialog.getCurFrame());
                     }
                     CurUnoDialog.xDialog.endExecute();
+                    CurDBMetaData.oSQLQueryComposer = null;
+                    CurDBMetaData = null;
+                    CurUnoDialog = null;
                 }
             }
-            CurDBMetaData.oSQLQueryComposer = null;
-            CurDBMetaData = null;
-            CurUnoDialog = null;
         }
         catch (IllegalArgumentException e)
         {
diff --git a/wizards/com/sun/star/wizards/query/QueryWizard.java b/wizards/com/sun/star/wizards/query/QueryWizard.java
index 181c83d9134a..468540f9569a 100644
--- a/wizards/com/sun/star/wizards/query/QueryWizard.java
+++ b/wizards/com/sun/star/wizards/query/QueryWizard.java
@@ -299,6 +299,10 @@ public class QueryWizard extends WizardDialog
         if ((switchToStep(ncurStep, SOSUMMARY_PAGE)) || (ncurStep == SOSUMMARY_PAGE))
         {
             components = CurFinalizer.finish();
+            if ( components == null )
+            {
+                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)
-- 
cgit