Skip to content

Commit

Permalink
Open resource dialog: you can now select multiple files to open
Browse files Browse the repository at this point in the history
  • Loading branch information
Eran Ifrah committed Apr 23, 2017
1 parent 0da7ea5 commit ff6a665
Show file tree
Hide file tree
Showing 11 changed files with 726 additions and 534 deletions.
23 changes: 15 additions & 8 deletions Gizmos/newclassdlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,8 @@ bool NewClassDlg::ValidateInput()
if(wxFileName::FileExists(cpp_file)) {
if(wxMessageBox(
wxString::Format(_("A file with this name: '%s' already exists, continue anyway?"), cpp_file.GetData()),
_("CodeLite"), wxYES_NO | wxICON_WARNING) == wxNO) {
_("CodeLite"),
wxYES_NO | wxICON_WARNING) == wxNO) {
return false;
}
}
Expand All @@ -236,7 +237,8 @@ bool NewClassDlg::ValidateInput()
if(wxFileName::FileExists(h_file)) {
if(wxMessageBox(
wxString::Format(_("A file with this name: '%s' already exists, continue anyway?"), h_file.GetData()),
_("CodeLite"), wxYES_NO | wxICON_WARNING) == wxNO) {
_("CodeLite"),
wxYES_NO | wxICON_WARNING) == wxNO) {
return false;
}
}
Expand Down Expand Up @@ -324,13 +326,18 @@ void NewClassDlg::OnBrowseNamespace(wxCommandEvent& e)
kinds.Add(wxT("namespace"));

OpenResourceDialog dlg(this, m_mgr, "");
if(dlg.ShowModal() == wxID_OK && dlg.GetSelection()) {
wxString nameSpace;
if(dlg.GetSelection()->m_scope.IsEmpty() == false && dlg.GetSelection()->m_scope != wxT("<global>")) {
nameSpace << dlg.GetSelection()->m_scope << wxT("::");
if(dlg.ShowModal() == wxID_OK) {
std::vector<OpenResourceDialogItemData*> selections = dlg.GetSelections();
if(!selections.empty()) {
OpenResourceDialogItemData* item = selections.at(0);
wxString nameSpace;
if(item->m_scope.IsEmpty() == false && item->m_scope != wxT("<global>")) {
nameSpace << item->m_scope << wxT("::");
}
nameSpace << item->m_name;
m_textCtrlNamespace->ChangeValue(nameSpace);

}
nameSpace << dlg.GetSelection()->m_name;
m_textCtrlNamespace->ChangeValue(nameSpace);
}
}

Expand Down
11 changes: 6 additions & 5 deletions Gizmos/newinheritancedlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,15 @@ void NewIneritanceDlg::OnButtonMore(wxCommandEvent& event)
dlg.GetFilters().Add(TagEntry::KIND_CLASS);
dlg.GetFilters().Add(TagEntry::KIND_STRUCT);

if((dlg.ShowModal() == wxID_OK) && (dlg.GetSelection() != NULL)) {
if((dlg.ShowModal() == wxID_OK) && !dlg.GetSelections().empty()) {
OpenResourceDialogItemData* item = dlg.GetSelections().at(0);
wxString parentName;
if(dlg.GetSelection()->m_scope.IsEmpty() == false && dlg.GetSelection()->m_scope != wxT("<global>")) {
parentName << dlg.GetSelection()->m_scope << wxT("::");
if(item->m_scope.IsEmpty() == false && item->m_scope != wxT("<global>")) {
parentName << item->m_scope << wxT("::");
}
parentName << dlg.GetSelection()->m_name;
parentName << item->m_name;
m_textCtrlInhertiance->SetValue(parentName);

m_fileName = dlg.GetSelection()->m_file;
m_fileName = item->m_file;
}
}
735 changes: 473 additions & 262 deletions LiteEditor/frame.cpp

Large diffs are not rendered by default.

49 changes: 31 additions & 18 deletions Plugin/open_resource_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ void OpenResourceDialog::DoPopulateList()
wxString modFilter;
GetLineNumberFromFilter(name, modFilter, nLineNumber);
name.swap(modFilter);

m_lineNumber = nLineNumber;

// Prepare the user filter
m_userFilters.Clear();
m_userFilters = ::wxStringTokenize(name, " \t", wxTOKEN_STRTOK);
Expand Down Expand Up @@ -340,7 +340,14 @@ void OpenResourceDialog::OnKeyDown(wxKeyEvent& event)
bool down = (event.GetKeyCode() == WXK_DOWN || event.GetKeyCode() == WXK_NUMPAD_DOWN);
wxDataViewItemArray children;
m_dataviewModel->GetChildren(wxDataViewItem(0), children);
wxDataViewItem selection = m_dataview->GetSelection();
wxDataViewItemArray selections;
wxDataViewItem selection;
m_dataview->GetSelections(selections);

if(!selections.IsEmpty()) {
selection = selections.Item(0);
}

if(!selection.IsOk()) {
// No selection, select the first
DoSelectItem(children.Item(0));
Expand Down Expand Up @@ -370,15 +377,15 @@ void OpenResourceDialog::OnOK(wxCommandEvent& event) { event.Skip(); }

void OpenResourceDialog::OnOKUI(wxUpdateUIEvent& event)
{
wxDataViewItem item = m_dataview->GetSelection();
event.Enable(item.IsOk());
event.Enable(m_dataview->GetSelectedItemsCount());
}

bool OpenResourceDialogItemData::IsOk() const { return m_file.IsEmpty() == false; }

void OpenResourceDialog::DoSelectItem(const wxDataViewItem& item)
{
CHECK_ITEM_RET(item);
m_dataview->UnselectAll();
m_dataview->Select(item);
m_dataview->EnsureVisible(item);
}
Expand Down Expand Up @@ -474,26 +481,32 @@ void OpenResourceDialog::OnCheckboxshowsymbolsCheckboxClicked(wxCommandEvent& ev

void OpenResourceDialog::OnEnter(wxCommandEvent& event)
{
wxDataViewItem item = m_dataview->GetSelection();

if(item.IsOk()) {
EndModal(wxID_OK);
}
event.Skip();
EndModal(wxID_OK);
}

void OpenResourceDialog::OnEntrySelected(wxDataViewEvent& event) { event.Skip(); }

OpenResourceDialogItemData* OpenResourceDialog::GetSelection() const
std::vector<OpenResourceDialogItemData*> OpenResourceDialog::GetSelections() const
{
wxDataViewItem item = m_dataview->GetSelection();
if(!item.IsOk()) return NULL;
std::vector<OpenResourceDialogItemData*> selections;
wxDataViewItemArray items;
m_dataview->GetSelections(items);
if(items.IsEmpty()) {
return selections;
}

OpenResourceDialogItemData* data =
dynamic_cast<OpenResourceDialogItemData*>(m_dataviewModel->GetClientObject(item));
if(data && GetLineNumber() != wxNOT_FOUND) {
data->m_line = GetLineNumber();
for(size_t i = 0; i < items.GetCount(); ++i) {
OpenResourceDialogItemData* data =
dynamic_cast<OpenResourceDialogItemData*>(m_dataviewModel->GetClientObject(items.Item(i)));
if(data) {
if(m_lineNumber != wxNOT_FOUND) {
data->m_line = m_lineNumber;
}
selections.push_back(data);
}
}
return data;
return selections;
}

void OpenResourceDialog::GetLineNumberFromFilter(const wxString& filter, wxString& modFilter, long& lineNumber)
Expand Down
4 changes: 1 addition & 3 deletions Plugin/open_resource_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ class WXDLLIMPEXP_SDK OpenResourceDialog : public OpenResourceDialogBase
OpenResourceDialog(wxWindow* parent, IManager* manager, const wxString& initialSelection);
virtual ~OpenResourceDialog();

OpenResourceDialogItemData* GetSelection() const;
long GetLineNumber() const { return m_lineNumber; }

std::vector<OpenResourceDialogItemData*> GetSelections() const;
wxArrayString& GetFilters() { return m_filters; }

/**
Expand Down
31 changes: 15 additions & 16 deletions Plugin/openresourcedialogbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,51 +42,51 @@ OpenResourceDialogBase::OpenResourceDialogBase(wxWindow* parent, wxWindowID id,
wxBoxSizer* mainSizer = new wxBoxSizer(wxVERTICAL);
this->SetSizer(mainSizer);

m_textCtrlResourceName = new wxTextCtrl(this, wxID_ANY, wxT(""), wxDefaultPosition, wxSize(-1,-1), wxTE_PROCESS_ENTER);
m_textCtrlResourceName = new wxTextCtrl(this, wxID_ANY, wxT(""), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1,-1)), wxTE_PROCESS_ENTER);
m_textCtrlResourceName->SetToolTip(_("Type resource name to open.\nYou may use a space delimited list of words to narrow down the list of choices\ne.g. Typing: 'Open Dialog' will include results that contain both words \"Open\" _and_ \"Dialog\""));
m_textCtrlResourceName->SetFocus();
#if wxVERSION_NUMBER >= 3000
m_textCtrlResourceName->SetHint(wxT(""));
#endif

mainSizer->Add(m_textCtrlResourceName, 0, wxALL|wxEXPAND, 5);
mainSizer->Add(m_textCtrlResourceName, 0, wxALL|wxEXPAND, WXC_FROM_DIP(5));

m_dataview = new wxDataViewCtrl(this, wxID_ANY, wxDefaultPosition, wxSize(300,200), wxDV_VERT_RULES|wxDV_ROW_LINES|wxDV_SINGLE);
m_dataview = new wxDataViewCtrl(this, wxID_ANY, wxDefaultPosition, wxDLG_UNIT(this, wxSize(300,200)), wxDV_VERT_RULES|wxDV_ROW_LINES|wxDV_MULTIPLE|wxDV_SINGLE);

m_dataviewModel = new OpenResourceDialogModel;
m_dataviewModel->SetColCount( 3 );
m_dataview->AssociateModel(m_dataviewModel.get() );

mainSizer->Add(m_dataview, 1, wxALL|wxEXPAND, 5);
mainSizer->Add(m_dataview, 1, wxALL|wxEXPAND, WXC_FROM_DIP(5));

m_dataview->AppendIconTextColumn(_("Name"), m_dataview->GetColumnCount(), wxDATAVIEW_CELL_INERT, 500, wxALIGN_LEFT);
m_dataview->AppendTextColumn(_("Impl?"), m_dataview->GetColumnCount(), wxDATAVIEW_CELL_INERT, 60, wxALIGN_LEFT);
m_dataview->AppendTextColumn(_("Full Name"), m_dataview->GetColumnCount(), wxDATAVIEW_CELL_INERT, 500, wxALIGN_LEFT);
m_dataview->AppendIconTextColumn(_("Name"), m_dataview->GetColumnCount(), wxDATAVIEW_CELL_INERT, WXC_FROM_DIP(500), wxALIGN_LEFT);
m_dataview->AppendTextColumn(_("Impl?"), m_dataview->GetColumnCount(), wxDATAVIEW_CELL_INERT, WXC_FROM_DIP(60), wxALIGN_LEFT);
m_dataview->AppendTextColumn(_("Full Name"), m_dataview->GetColumnCount(), wxDATAVIEW_CELL_INERT, WXC_FROM_DIP(500), wxALIGN_LEFT);
wxFlexGridSizer* fgSizer1 = new wxFlexGridSizer(0, 2, 0, 0);
fgSizer1->SetFlexibleDirection( wxBOTH );
fgSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED );

mainSizer->Add(fgSizer1, 0, wxALL|wxALIGN_LEFT, 5);
mainSizer->Add(fgSizer1, 0, wxALL|wxALIGN_LEFT, WXC_FROM_DIP(5));

m_checkBoxFiles = new wxCheckBox(this, wxID_ANY, _("Show &files"), wxDefaultPosition, wxSize(-1,-1), 0);
m_checkBoxFiles = new wxCheckBox(this, wxID_ANY, _("Show &files"), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1,-1)), 0);
m_checkBoxFiles->SetValue(false);

fgSizer1->Add(m_checkBoxFiles, 0, wxALL|wxEXPAND, 5);
fgSizer1->Add(m_checkBoxFiles, 0, wxALL|wxEXPAND, WXC_FROM_DIP(5));

m_checkBoxShowSymbols = new wxCheckBox(this, wxID_ANY, _("Show &symbols"), wxDefaultPosition, wxSize(-1,-1), 0);
m_checkBoxShowSymbols = new wxCheckBox(this, wxID_ANY, _("Show &symbols"), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1,-1)), 0);
m_checkBoxShowSymbols->SetValue(false);

fgSizer1->Add(m_checkBoxShowSymbols, 0, wxALL|wxEXPAND, 5);
fgSizer1->Add(m_checkBoxShowSymbols, 0, wxALL|wxEXPAND, WXC_FROM_DIP(5));

m_stdBtnSizer2 = new wxStdDialogButtonSizer();

mainSizer->Add(m_stdBtnSizer2, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 10);
mainSizer->Add(m_stdBtnSizer2, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, WXC_FROM_DIP(10));

m_buttonOK = new wxButton(this, wxID_OK, wxT(""), wxDefaultPosition, wxSize(-1, -1), 0);
m_buttonOK = new wxButton(this, wxID_OK, wxT(""), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);
m_buttonOK->SetDefault();
m_stdBtnSizer2->AddButton(m_buttonOK);

m_button6 = new wxButton(this, wxID_CANCEL, wxT(""), wxDefaultPosition, wxSize(-1, -1), 0);
m_button6 = new wxButton(this, wxID_CANCEL, wxT(""), wxDefaultPosition, wxDLG_UNIT(this, wxSize(-1, -1)), 0);
m_stdBtnSizer2->AddButton(m_button6);
m_stdBtnSizer2->Realize();

Expand All @@ -95,7 +95,6 @@ OpenResourceDialogBase::OpenResourceDialogBase(wxWindow* parent, wxWindowID id,
SetSize(-1,-1);
if (GetSizer()) {
GetSizer()->Fit(this);
SetMinClientSize(GetMinClientSize());
}
if(GetParent()) {
CentreOnParent(wxBOTH);
Expand Down
39 changes: 12 additions & 27 deletions Plugin/openresourcedialogbase.h
Original file line number Diff line number Diff line change
@@ -1,36 +1,11 @@
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//
// Copyright : (C) 2015 Eran Ifrah
// File name : openresourcedialogbase.h
//
// -------------------------------------------------------------------------
// A
// _____ _ _ _ _
// / __ \ | | | | (_) |
// | / \/ ___ __| | ___| | _| |_ ___
// | | / _ \ / _ |/ _ \ | | | __/ _ )
// | \__/\ (_) | (_| | __/ |___| | || __/
// \____/\___/ \__,_|\___\_____/_|\__\___|
//
// F i l e
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////
// This file was auto-generated by codelite's wxCrafter Plugin
// wxCrafter project file: openresourcedialogbase.wxcp
// Do not modify this file by hand!
//////////////////////////////////////////////////////////////////////

#ifndef CODELITE_PLUGIN_OPENRESOURCEDIALOGBASE_BASE_CLASSES_H
#define CODELITE_PLUGIN_OPENRESOURCEDIALOGBASE_BASE_CLASSES_H
#ifndef _CODELITE_PLUGIN_OPENRESOURCEDIALOGBASE_BASE_CLASSES_H
#define _CODELITE_PLUGIN_OPENRESOURCEDIALOGBASE_BASE_CLASSES_H

#include <wx/settings.h>
#include <wx/xrc/xmlres.h>
Expand All @@ -51,6 +26,16 @@
#include <wx/persist/treebook.h>
#endif

#ifdef WXC_FROM_DIP
#undef WXC_FROM_DIP
#endif
#if wxVERSION_NUMBER >= 3100
#define WXC_FROM_DIP(x) wxWindow::FromDIP(x, NULL)
#else
#define WXC_FROM_DIP(x) x
#endif


class OpenResourceDialogBase : public wxDialog
{
protected:
Expand Down
3 changes: 2 additions & 1 deletion Plugin/openresourcedialogbase.wxcp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"m_firstWindowId": 1000,
"m_useEnum": false,
"m_useUnderscoreMacro": true,
"m_addHandlers": true,
"m_templateClasses": []
},
"windows": [{
Expand Down Expand Up @@ -264,7 +265,7 @@
"border": 5,
"gbSpan": "1,1",
"gbPosition": "0,0",
"m_styles": ["wxDV_VERT_RULES", "wxDV_ROW_LINES", "wxDV_SINGLE"],
"m_styles": ["wxDV_VERT_RULES", "wxDV_ROW_LINES", "wxDV_MULTIPLE", "wxDV_SINGLE"],
"m_sizerFlags": ["wxALL", "wxLEFT", "wxRIGHT", "wxTOP", "wxBOTTOM", "wxEXPAND"],
"m_properties": [{
"type": "winid",
Expand Down
Loading

0 comments on commit ff6a665

Please sign in to comment.