Kaydet (Commit) 33242092 authored tarafından Ocke Janssen's avatar Ocke Janssen

#90580# introduce new file for relation control

üst cbd12ea2
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: querydlg.cxx,v $ * $RCSfile: querydlg.cxx,v $
* *
* $Revision: 1.3 $ * $Revision: 1.4 $
* *
* last change: $Author: oj $ $Date: 2001-10-05 12:31:27 $ * last change: $Author: oj $ $Date: 2002-02-06 07:45:42 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -85,91 +85,99 @@ ...@@ -85,91 +85,99 @@
#ifndef DBAUI_QUERYDESIGNVIEW_HXX #ifndef DBAUI_QUERYDESIGNVIEW_HXX
#include "QueryDesignView.hxx" #include "QueryDesignView.hxx"
#endif #endif
#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
#include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
#endif
#ifndef DBAUI_RELATIONCONTROL_HXX
#include "RelationControl.hxx"
#endif
#ifndef _SV_MSGBOX_HXX
#include <vcl/msgbox.hxx>
#endif
using namespace dbaui; using namespace dbaui;
using namespace ::com::sun::star::uno; using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::sdbc; using namespace ::com::sun::star::sdbc;
DBG_NAME(DlgQryJoin); DBG_NAME(DlgQryJoin);
DlgQryJoin::DlgQryJoin( Window * pParent,OQueryTableConnectionData* pData, DlgQryJoin::DlgQryJoin( Window * pParent,
const Reference< XDatabaseMetaData >& _rxMetaData) OQueryTableConnectionData* _pData,
OJoinTableView::OTableWindowMap* _pTableMap,
const Reference< XConnection >& _xConnection,
BOOL _bAllowTableSelect)
: ModalDialog( pParent, ModuleRes(DLG_QRY_JOIN) ), : ModalDialog( pParent, ModuleRes(DLG_QRY_JOIN) ),
aFL_Join( this, ResId( FL_JOIN ) ), aFL_Join( this, ResId( FL_JOIN ) ),
aRB_Inner( this, ResId( RB_INNER ) ),
aRB_Left( this, ResId( RB_LEFT ) ),
aRB_Right( this, ResId( RB_RIGHT ) ),
aRB_Full( this, ResId( RB_FULL ) ),
aML_HelpText( this, ResId(ML_HELPTEXT) ), aML_HelpText( this, ResId(ML_HELPTEXT) ),
aFT_Title( this, ResId(FT_LISTBOXTITLE) ),
aLB_JoinType( this, ResId(LB_JOINTYPE) ),
aPB_OK( this, ResId( PB_OK ) ), aPB_OK( this, ResId( PB_OK ) ),
aPB_CANCEL( this, ResId( PB_CANCEL ) ), aPB_CANCEL( this, ResId( PB_CANCEL ) ),
aPB_HELP( this, ResId( PB_HELP ) ), aPB_HELP( this, ResId( PB_HELP ) ),
eJoinType(pData->GetJoinType()), eJoinType(_pData->GetJoinType()),
pConnData(pData) m_pConnData(NULL),
m_xConnection(_xConnection),
m_pTableMap(_pTableMap),
m_pOrigConnData(_pData)
{ {
DBG_CTOR(DlgQryJoin,NULL); DBG_CTOR(DlgQryJoin,NULL);
aRB_Left.Disable(); aML_HelpText.SetControlBackground( GetSettings().GetStyleSettings().GetFaceColor() );
aRB_Right.Disable(); //////////////////////////////////////////////////////////////////////
aRB_Full.Disable(); // Connection kopieren
m_pConnData = static_cast<OQueryTableConnectionData*>(_pData->NewInstance());
m_pConnData->CopyFrom(*_pData);
sal_Bool bFull = sal_False; m_pTableControl = new OTableListBoxControl(this,ModuleRes(LB_CONTROL),m_pTableMap,this);
sal_Bool bOuter = sal_False;
try if( _bAllowTableSelect )
{ {
bFull = _rxMetaData->supportsFullOuterJoins(); m_pTableControl->Init( m_pConnData );
bOuter= _rxMetaData->supportsOuterJoins(); m_pTableControl->fillListBoxes();
} }
catch(SQLException&) else
{ {
m_pTableControl->fillAndDisable(m_pConnData);
m_pTableControl->Init( m_pConnData );
} }
if(bFull)
sal_Bool bFull = sal_False;
sal_Bool bOuter = sal_False;
try
{ {
aRB_Left.Enable(); Reference<XDatabaseMetaData> xMeta = m_xConnection->getMetaData();
aRB_Right.Enable(); bFull = xMeta->supportsFullOuterJoins();
aRB_Full.Enable(); bOuter= xMeta->supportsOuterJoins();
} }
else if(bOuter) catch(SQLException&)
{ {
aRB_Left.Enable();
aRB_Right.Enable();
} }
switch(eJoinType) setJoinType(eJoinType);
{
case INNER_JOIN:
aRB_Inner.Check(sal_True);
RBTogleHdl(&aRB_Inner);
break;
case LEFT_JOIN:
aRB_Left.Check(sal_True);
RBTogleHdl(&aRB_Left);
break;
case RIGHT_JOIN:
aRB_Right.Check(sal_True);
RBTogleHdl(&aRB_Right);
break;
case FULL_JOIN:
aRB_Full.Check(sal_True);
RBTogleHdl(&aRB_Full);
break;
}
aPB_OK.SetClickHdl( LINK(this, DlgQryJoin, OKClickHdl) ); aPB_OK.SetClickHdl( LINK(this, DlgQryJoin, OKClickHdl) );
aRB_Inner.SetToggleHdl(LINK(this,DlgQryJoin,RBTogleHdl)); aLB_JoinType.SetSelectHdl(LINK(this,DlgQryJoin,LBChangeHdl));
aRB_Left.SetToggleHdl(LINK(this,DlgQryJoin,RBTogleHdl));
aRB_Right.SetToggleHdl(LINK(this,DlgQryJoin,RBTogleHdl));
aRB_Full.SetToggleHdl(LINK(this,DlgQryJoin,RBTogleHdl));
if (static_cast<OQueryTableView*>(pParent)->getDesignView()->getController()->isReadOnly()) if (static_cast<OQueryTableView*>(pParent)->getDesignView()->getController()->isReadOnly())
{ {
aRB_Inner.Disable(); aLB_JoinType.Disable();
aRB_Left.Disable(); m_pTableControl->Disable();
aRB_Right.Disable(); }
aRB_Full.Disable(); else
{
if ( !bFull )
aLB_JoinType.RemoveEntry(3);
if ( !(bFull || bOuter) )
{
aLB_JoinType.RemoveEntry(0);
aLB_JoinType.RemoveEntry(0);
aLB_JoinType.RemoveEntry(0);
}
m_pTableControl->NotifyCellChange();
} }
FreeResource(); FreeResource();
...@@ -179,51 +187,115 @@ DlgQryJoin::DlgQryJoin( Window * pParent,OQueryTableConnectionData* pData, ...@@ -179,51 +187,115 @@ DlgQryJoin::DlgQryJoin( Window * pParent,OQueryTableConnectionData* pData,
DlgQryJoin::~DlgQryJoin() DlgQryJoin::~DlgQryJoin()
{ {
DBG_DTOR(DlgQryJoin,NULL); DBG_DTOR(DlgQryJoin,NULL);
delete m_pTableControl;
delete m_pConnData;
} }
IMPL_LINK( DlgQryJoin, RBTogleHdl, RadioButton*, pButton ) // -----------------------------------------------------------------------------
IMPL_LINK( DlgQryJoin, LBChangeHdl, ListBox*, pListBox )
{ {
DBG_CHKTHIS(DlgQryJoin,NULL); DBG_CHKTHIS(DlgQryJoin,NULL);
aML_HelpText.SetText(String()); aML_HelpText.SetText(String());
String aStr;
if(pButton == &aRB_Inner) String sFirstWinName,sSecondWinName;
{ USHORT nResId = 0;
aStr = String(ModuleRes(STR_QUERY_INNER_JOIN)); USHORT nPos = aLB_JoinType.GetSelectEntryPos();
} switch ( nPos )
else if(pButton == &aRB_Left)
{
aStr = String(ModuleRes(STR_QUERY_LEFTRIGHT_JOIN));
aStr.SearchAndReplace(String::CreateFromAscii("%1"),pConnData->GetSourceWinName());
aStr.SearchAndReplace(String::CreateFromAscii("%2"),pConnData->GetDestWinName());
}
else if(pButton == &aRB_Right)
{ {
aStr = String(ModuleRes(STR_QUERY_LEFTRIGHT_JOIN)); default:
aStr.SearchAndReplace(String::CreateFromAscii("%1"),pConnData->GetDestWinName()); case 0:
aStr.SearchAndReplace(String::CreateFromAscii("%2"),pConnData->GetSourceWinName()); nResId = STR_QUERY_INNER_JOIN;
break;
case 1:
nResId = STR_QUERY_LEFTRIGHT_JOIN;
sFirstWinName = m_pConnData->GetSourceWinName();
sSecondWinName = m_pConnData->GetDestWinName();
break;
case 2:
case 3:
nResId = (nPos == 2) ? STR_QUERY_LEFTRIGHT_JOIN : STR_QUERY_FULL_JOIN;
sFirstWinName = m_pConnData->GetDestWinName();
sSecondWinName = m_pConnData->GetSourceWinName();
break;
} }
else if(pButton == &aRB_Full)
String sStr = String(ModuleRes(nResId));
if( sFirstWinName.Len() )
{ {
aStr = String(ModuleRes(STR_QUERY_FULL_JOIN)); sStr.SearchAndReplace(String(RTL_CONSTASCII_STRINGPARAM("%1")),sFirstWinName);
aStr.SearchAndReplace(String::CreateFromAscii("%1"),pConnData->GetDestWinName()); sStr.SearchAndReplace(String(RTL_CONSTASCII_STRINGPARAM("%2")),sSecondWinName);
aStr.SearchAndReplace(String::CreateFromAscii("%2"),pConnData->GetSourceWinName());
} }
aML_HelpText.SetText(aStr); aML_HelpText.SetText(sStr);
return 1; return 1;
} }
// -----------------------------------------------------------------------------
IMPL_LINK( DlgQryJoin, OKClickHdl, Button*, pButton ) IMPL_LINK( DlgQryJoin, OKClickHdl, Button*, pButton )
{ {
DBG_CHKTHIS(DlgQryJoin,NULL); DBG_CHKTHIS(DlgQryJoin,NULL);
if( aRB_Inner.IsChecked() ) USHORT nPos = aLB_JoinType.GetSelectEntryPos();
eJoinType = INNER_JOIN; switch ( nPos )
else if( aRB_Left.IsChecked() ) {
eJoinType = LEFT_JOIN; case 0:
else if( aRB_Right.IsChecked() ) eJoinType = INNER_JOIN;
eJoinType = RIGHT_JOIN; break;
else if( aRB_Full.IsChecked() ) case 1:
eJoinType = FULL_JOIN; eJoinType = LEFT_JOIN;
EndDialog(); break;
case 2:
eJoinType = RIGHT_JOIN;
break;
case 3:
eJoinType = FULL_JOIN;
break;
}
m_pConnData->Update();
m_pOrigConnData->CopyFrom( *m_pConnData );
EndDialog(RET_OK);
return 1; return 1;
} }
// -----------------------------------------------------------------------------
OTableConnectionData* DlgQryJoin::getConnectionData() const
{
return m_pConnData;
}
// -----------------------------------------------------------------------------
void DlgQryJoin::setValid(sal_Bool _bValid)
{
LBChangeHdl(&aLB_JoinType);
aPB_OK.Enable(_bValid);
}
// -----------------------------------------------------------------------------
void DlgQryJoin::notifyConnectionChange(OTableConnectionData* _pConnectionData)
{
setJoinType(m_pConnData->GetJoinType());
}
// -----------------------------------------------------------------------------
void DlgQryJoin::setJoinType(EJoinType _eNewJoinType)
{
eJoinType = _eNewJoinType;
USHORT nPos = 0;
switch(eJoinType)
{
case INNER_JOIN:
break;
case LEFT_JOIN:
nPos = 1;
break;
case RIGHT_JOIN:
nPos = 2;
break;
case FULL_JOIN:
nPos = 3;
break;
}
aLB_JoinType.SelectEntryPos(nPos);
LBChangeHdl(&aLB_JoinType);
}
// -----------------------------------------------------------------------------
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: querydlg.hrc,v $ * $RCSfile: querydlg.hrc,v $
* *
* $Revision: 1.2 $ * $Revision: 1.3 $
* *
* last change: $Author: fme $ $Date: 2001-06-21 15:32:06 $ * last change: $Author: oj $ $Date: 2002-02-06 07:45:42 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -63,11 +63,9 @@ ...@@ -63,11 +63,9 @@
#define DBAUI_QUERYDLG_HRC #define DBAUI_QUERYDLG_HRC
#define FL_JOIN 1 #define FL_JOIN 1
#define FT_LISTBOXTITLE 2
#define RB_INNER 1 #define LB_JOINTYPE 1
#define RB_LEFT 2
#define RB_RIGHT 3
#define RB_FULL 4
#define GB_FIELDS 1 #define GB_FIELDS 1
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
* *
* $RCSfile: querydlg.hxx,v $ * $RCSfile: querydlg.hxx,v $
* *
* $Revision: 1.2 $ * $Revision: 1.3 $
* *
* last change: $Author: fme $ $Date: 2001-06-21 15:32:06 $ * last change: $Author: oj $ $Date: 2002-02-06 07:45:42 $
* *
* The Contents of this file are made available subject to the terms of * The Contents of this file are made available subject to the terms of
* either of the following licenses * either of the following licenses
...@@ -71,6 +71,9 @@ ...@@ -71,6 +71,9 @@
#ifndef _SV_FIXED_HXX //autogen #ifndef _SV_FIXED_HXX //autogen
#include <vcl/fixed.hxx> #include <vcl/fixed.hxx>
#endif #endif
#ifndef _SV_LSTBOX_HXX
#include <vcl/lstbox.hxx>
#endif
#ifndef _SVEDIT_HXX //autogen #ifndef _SVEDIT_HXX //autogen
#include <svtools/svmedit.hxx> #include <svtools/svmedit.hxx>
...@@ -78,36 +81,71 @@ ...@@ -78,36 +81,71 @@
#ifndef DBAUI_ENUMTYPES_HXX #ifndef DBAUI_ENUMTYPES_HXX
#include "QEnumTypes.hxx" #include "QEnumTypes.hxx"
#endif #endif
#ifndef _COM_SUN_STAR_SDBC_XDATABASEMETADATA_HPP_
#include <com/sun/star/sdbc/XDatabaseMetaData.hpp> #ifndef DBAUI_RELCONTROLIFACE_HXX
#include "RelControliFace.hxx"
#endif
#ifndef DBAUI_JOINTABLEVIEW_HXX
#include "JoinTableView.hxx"
#endif #endif
namespace dbaui namespace dbaui
{ {
class OQueryTableConnectionData; class OQueryTableConnectionData;
class DlgQryJoin : public ModalDialog class OTableListBoxControl;
class DlgQryJoin : public ModalDialog
,public IRelationControlInterface
{ {
protected: protected:
FixedLine aFL_Join; FixedLine aFL_Join;
RadioButton aRB_Inner; FixedText aFT_Title;
RadioButton aRB_Left; ListBox aLB_JoinType;
RadioButton aRB_Right; MultiLineEdit aML_HelpText;
RadioButton aRB_Full; OKButton aPB_OK;
MultiLineEdit aML_HelpText; CancelButton aPB_CANCEL;
OKButton aPB_OK; HelpButton aPB_HELP;
CancelButton aPB_CANCEL;
HelpButton aPB_HELP; OTableListBoxControl* m_pTableControl;
OJoinTableView::OTableWindowMap* m_pTableMap;
EJoinType eJoinType;
OQueryTableConnectionData* pConnData; // enth"alt linke und rechte Tabelle EJoinType eJoinType;
OQueryTableConnectionData* m_pConnData; // enth"alt linke und rechte Tabelle
OQueryTableConnectionData* m_pOrigConnData;
::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > m_xConnection;
DECL_LINK( OKClickHdl, Button* ); DECL_LINK( OKClickHdl, Button* );
DECL_LINK( RBTogleHdl, RadioButton* ); DECL_LINK( LBChangeHdl, ListBox* );
/** setJoinType enables and set the new join type
@param _eNewJoinType the new jointype
*/
void setJoinType(EJoinType _eNewJoinType);
public: public:
DlgQryJoin( Window * pParent, OQueryTableConnectionData* pData, DlgQryJoin( Window * pParent,
const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxMetaData); OQueryTableConnectionData* pData,
OJoinTableView::OTableWindowMap* _pTableMap,
const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _xConnection,
BOOL _bAllowTableSelect);
virtual ~DlgQryJoin(); virtual ~DlgQryJoin();
EJoinType GetJoinType() const { return eJoinType; }; EJoinType GetJoinType() const { return eJoinType; };
/** getConnectionData returns the current connection data
@return the current connectiondata
*/
virtual OTableConnectionData* getConnectionData() const;
/** setValid set the valid inside, can be used for OK buttons
@param _bValid true when the using control allows an update
*/
virtual void setValid(sal_Bool _bValid);
virtual ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection > getConnection() { return m_xConnection; }
/** notifyConnectionChange is callback which is called when the table selection has changed and a new connection exists
@param _pConnectionData the connection which exists between the new tables
*/
virtual void notifyConnectionChange(OTableConnectionData* _pConnectionData);
}; };
} }
#endif // DBAUI_QUERYDLG_HXX #endif // DBAUI_QUERYDLG_HXX
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment