summaryrefslogtreecommitdiff
path: root/dbaccess/source/ui/dlg/CollectionView.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'dbaccess/source/ui/dlg/CollectionView.cxx')
-rw-r--r--dbaccess/source/ui/dlg/CollectionView.cxx146
1 files changed, 86 insertions, 60 deletions
diff --git a/dbaccess/source/ui/dlg/CollectionView.cxx b/dbaccess/source/ui/dlg/CollectionView.cxx
index 8838514e130d..14f942902e9d 100644
--- a/dbaccess/source/ui/dlg/CollectionView.cxx
+++ b/dbaccess/source/ui/dlg/CollectionView.cxx
@@ -39,10 +39,16 @@
#include <com/sun/star/container/XHierarchicalNameContainer.hpp>
#include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
#include <com/sun/star/ucb/IOErrorCode.hpp>
+#include <com/sun/star/ucb/XContentAccess.hpp>
+#include <com/sun/star/ucb/XDynamicResultSet.hpp>
+#include <com/sun/star/sdbc/XRow.hpp>
#include <com/sun/star/task/InteractionHandler.hpp>
#include <com/sun/star/task/InteractionClassification.hpp>
#include <com/sun/star/sdbc/SQLException.hpp>
#include <com/sun/star/awt/XWindow.hpp>
+#include <comphelper/processfactory.hxx>
+#include <ucbhelper/commandenvironment.hxx>
+#include <ucbhelper/content.hxx>
#include <unotools/viewoptions.hxx>
#include <osl/thread.h>
#include <connectivity/dbexception.hxx>
@@ -58,61 +64,49 @@ using namespace ::com::sun::star::container;
using namespace ::com::sun::star::task;
using namespace ::com::sun::star::sdbc;
using namespace comphelper;
-OCollectionView::OCollectionView( vcl::Window * pParent
- ,const Reference< XContent>& _xContent
- ,const OUString& _sDefaultName
- ,const css::uno::Reference< css::uno::XComponentContext >& _rxContext)
- : ModalDialog( pParent, "CollectionView", "dbaccess/ui/collectionviewdialog.ui")
+
+OCollectionView::OCollectionView(weld::Window* pParent,
+ const Reference< XContent>& _xContent,
+ const OUString& _sDefaultName,
+ const css::uno::Reference< css::uno::XComponentContext >& _rxContext)
+ : GenericDialogController(pParent, "dbaccess/ui/collectionviewdialog.ui", "CollectionView")
, m_xContent(_xContent)
, m_xContext(_rxContext)
, m_bCreateForm(true)
+ , m_xFTCurrentPath(m_xBuilder->weld_label("currentPathLabel"))
+ , m_xNewFolder(m_xBuilder->weld_button("newFolderButton"))
+ , m_xUp(m_xBuilder->weld_button("upButton"))
+ , m_xView(m_xBuilder->weld_tree_view("viewTreeview"))
+ , m_xName(m_xBuilder->weld_entry("fileNameEntry"))
+ , m_xPB_OK(m_xBuilder->weld_button("ok"))
{
- get(m_pFTCurrentPath, "currentPathLabel");
- get(m_pNewFolder, "newFolderButton");
- get(m_pUp, "upButton");
- get(m_pView, "viewTreeview");
- get(m_pName, "fileNameEntry");
- get(m_pPB_OK, "ok");
+ Reference<XInteractionHandler2> xHandler(
+ InteractionHandler::createWithParent(m_xContext, m_xDialog->GetXWindow()));
+ m_xCmdEnv = new ::ucbhelper::CommandEnvironment(xHandler, nullptr);
OSL_ENSURE(m_xContent.is(),"No valid content!");
- m_pView->Initialize(m_xContent);
- m_pFTCurrentPath->SetStyle( m_pFTCurrentPath->GetStyle() | WB_PATHELLIPSIS );
+ m_xView->set_size_request(m_xView->get_approximate_digit_width() * 60, m_xView->get_height_rows(8));
+ m_xView->make_sorted();
+ Initialize();
initCurrentPath();
- m_pName->SetText(_sDefaultName);
- m_pName->GrabFocus();
-
- m_pUp->SetModeImage(Image(StockImage::Yes, BMP_NAVIGATION_BTN_UP_SC));
- m_pNewFolder->SetModeImage(Image(StockImage::Yes, BMP_NAVIGATION_CREATEFOLDER_SC));
+ m_xName->set_text(_sDefaultName);
+ m_xName->grab_focus();
- m_pView->SetDoubleClickHdl( LINK( this, OCollectionView, Dbl_Click_FileView ) );
- m_pView->EnableAutoResize();
- m_pView->EnableDelete(true);
- m_pUp->SetClickHdl( LINK( this, OCollectionView, Up_Click ) );
- m_pNewFolder->SetClickHdl( LINK( this, OCollectionView, NewFolder_Click ) );
- m_pPB_OK->SetClickHdl( LINK( this, OCollectionView, Save_Click ) );
+ m_xView->connect_row_activated( LINK( this, OCollectionView, Dbl_Click_FileView ) );
+ m_xUp->connect_clicked( LINK( this, OCollectionView, Up_Click ) );
+ m_xNewFolder->connect_clicked( LINK( this, OCollectionView, NewFolder_Click ) );
+ m_xPB_OK->connect_clicked( LINK( this, OCollectionView, Save_Click ) );
}
OCollectionView::~OCollectionView()
{
- disposeOnce();
-}
-
-void OCollectionView::dispose()
-{
- m_pFTCurrentPath.clear();
- m_pNewFolder.clear();
- m_pUp.clear();
- m_pView.clear();
- m_pName.clear();
- m_pPB_OK.clear();
- ModalDialog::dispose();
}
-IMPL_LINK_NOARG(OCollectionView, Save_Click, Button*, void)
+IMPL_LINK_NOARG(OCollectionView, Save_Click, weld::Button&, void)
{
- OUString sName = m_pName->GetText();
- if ( sName.isEmpty() )
+ OUString sName = m_xName->get_text();
+ if (sName.isEmpty())
return;
try
{
@@ -132,7 +126,7 @@ IMPL_LINK_NOARG(OCollectionView, Save_Click, Button*, void)
xChild.set(m_xContent,UNO_QUERY);
}
}
- m_pView->Initialize(m_xContent);
+ Initialize();
initCurrentPath();
}
OUString sSubFolder = sName.copy(0,nIndex-1);
@@ -157,7 +151,7 @@ IMPL_LINK_NOARG(OCollectionView, Save_Click, Button*, void)
IOErrorCode_NOT_EXISTING_PATH,aValues);
Reference<XInteractionHandler2> xHandler(
- InteractionHandler::createWithParent(m_xContext, VCLUnoHelper::GetInterface( this )));
+ InteractionHandler::createWithParent(m_xContext, m_xDialog->GetXWindow()));
OInteractionRequest* pRequest = new OInteractionRequest(makeAny(aException));
Reference< XInteractionRequest > xRequest(pRequest);
@@ -174,14 +168,14 @@ IMPL_LINK_NOARG(OCollectionView, Save_Click, Button*, void)
{
if ( xNameContainer->hasByName(sName) )
{
- std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(),
+ std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(m_xDialog.get(),
VclMessageType::Question, VclButtonsType::YesNo,
DBA_RES(STR_ALREADYEXISTOVERWRITE)));
if (xQueryBox->run() != RET_YES)
return;
}
- m_pName->SetText(sName);
- EndDialog( RET_OK );
+ m_xName->set_text(sName);
+ m_xDialog->response(RET_OK);
}
}
catch( const Exception& )
@@ -190,17 +184,17 @@ IMPL_LINK_NOARG(OCollectionView, Save_Click, Button*, void)
}
}
-IMPL_LINK_NOARG(OCollectionView, NewFolder_Click, Button*, void)
+IMPL_LINK_NOARG(OCollectionView, NewFolder_Click, weld::Button&, void)
{
try
{
Reference<XHierarchicalNameContainer> xNameContainer(m_xContent,UNO_QUERY);
- if ( dbaui::insertHierachyElement(GetFrameWeld(),m_xContext,xNameContainer,OUString(),m_bCreateForm) )
- m_pView->Initialize(m_xContent);
+ if ( dbaui::insertHierachyElement(m_xDialog.get(),m_xContext,xNameContainer,OUString(),m_bCreateForm) )
+ Initialize();
}
catch( const SQLException& )
{
- showError( ::dbtools::SQLExceptionInfo( ::cppu::getCaughtException() ), VCLUnoHelper::GetInterface(this), m_xContext );
+ showError(::dbtools::SQLExceptionInfo(::cppu::getCaughtException()), m_xDialog->GetXWindow(), m_xContext);
}
catch( const Exception& )
{
@@ -208,7 +202,7 @@ IMPL_LINK_NOARG(OCollectionView, NewFolder_Click, Button*, void)
}
}
-IMPL_LINK_NOARG(OCollectionView, Up_Click, Button*, void)
+IMPL_LINK_NOARG(OCollectionView, Up_Click, weld::Button&, void)
{
try
{
@@ -219,11 +213,11 @@ IMPL_LINK_NOARG(OCollectionView, Up_Click, Button*, void)
if ( xNameAccess.is() )
{
m_xContent.set(xNameAccess,UNO_QUERY);
- m_pView->Initialize(m_xContent);
+ Initialize();
initCurrentPath();
}
else
- m_pUp->Disable();
+ m_xUp->set_sensitive(false);
}
}
catch( const Exception& )
@@ -232,16 +226,15 @@ IMPL_LINK_NOARG(OCollectionView, Up_Click, Button*, void)
}
}
-IMPL_LINK_NOARG(OCollectionView, Dbl_Click_FileView, SvTreeListBox*, bool)
+IMPL_LINK_NOARG(OCollectionView, Dbl_Click_FileView, weld::TreeView&, void)
{
try
{
Reference<XNameAccess> xNameAccess(m_xContent,UNO_QUERY);
if ( xNameAccess.is() )
{
- OUString sSubFolder = m_pView->GetCurrentURL();
- sSubFolder = sSubFolder.copy(sSubFolder.lastIndexOf('/') + 1);
- if ( !sSubFolder.isEmpty() )
+ OUString sSubFolder = m_xView->get_selected_text();
+ if (!sSubFolder.isEmpty())
{
Reference< XContent> xContent;
if ( xNameAccess->hasByName(sSubFolder) )
@@ -249,7 +242,7 @@ IMPL_LINK_NOARG(OCollectionView, Dbl_Click_FileView, SvTreeListBox*, bool)
if ( xContent.is() )
{
m_xContent = xContent;
- m_pView->Initialize(m_xContent);
+ Initialize();
initCurrentPath();
}
}
@@ -259,7 +252,6 @@ IMPL_LINK_NOARG(OCollectionView, Dbl_Click_FileView, SvTreeListBox*, bool)
{
DBG_UNHANDLED_EXCEPTION("dbaccess");
}
- return false;
}
void OCollectionView::initCurrentPath()
@@ -279,7 +271,7 @@ void OCollectionView::initCurrentPath()
else if ( !m_bCreateForm && sCID.getLength() != static_cast<sal_Int32>(strlen(s_sReportsCID)) )
sPath = sCID.copy(strlen(s_sReportsCID) - 2);
- m_pFTCurrentPath->SetText(sPath);
+ m_xFTCurrentPath->set_label(sPath);
Reference<XChild> xChild(m_xContent,UNO_QUERY);
bEnable = xChild.is() && Reference<XNameAccess>(xChild->getParent(),UNO_QUERY).is();
}
@@ -288,12 +280,46 @@ void OCollectionView::initCurrentPath()
{
DBG_UNHANDLED_EXCEPTION("dbaccess");
}
- m_pUp->Enable(bEnable);
+ m_xUp->set_sensitive(bEnable);
}
OUString OCollectionView::getName() const
{
- return m_pName->GetText();
+ return m_xName->get_text();
+}
+
+#define ROW_TITLE 1
+#define ROW_IS_FOLDER 2
+
+void OCollectionView::Initialize()
+{
+ weld::WaitObject aWaitCursor(m_xDialog.get());
+
+ m_xView->clear();
+
+ try
+ {
+ ::ucbhelper::Content aContent(m_xContent, m_xCmdEnv, comphelper::getProcessComponentContext());
+ Sequence<OUString> aProps(2);
+ aProps[0] = "Title";
+ aProps[1] = "IsFolder";
+ auto xDynResultSet = aContent.createDynamicCursor(aProps, ucbhelper::INCLUDE_FOLDERS_ONLY);
+ if (!xDynResultSet.is())
+ return;
+
+ Reference<XResultSet> xResultSet = xDynResultSet->getStaticResultSet();
+ Reference<XRow> xRow(xResultSet, UNO_QUERY);
+ while (xResultSet->next())
+ {
+ if (!xRow->getBoolean(ROW_IS_FOLDER))
+ continue;
+ m_xView->append_text(xRow->getString(ROW_TITLE));
+ }
+ }
+ catch (const Exception&)
+ {
+ DBG_UNHANDLED_EXCEPTION("dbaccess");
+ }
}
} // namespace dbaui