Debugger: Adjust TeamWindow to use ExpressionEvaluationWindow.

- Requesting expression evaluation from the top level menu now
  invokes an expression eval window, rather than the past prompt.

ExpressionPromptWindow:
- Simplify, as it's now strictly used to add persistent expressions.
This commit is contained in:
Rene Gollent
2015-11-10 14:38:24 -05:00
parent 94acd9251e
commit d6a334fa21
4 changed files with 46 additions and 50 deletions
@@ -40,6 +40,7 @@
#include "CpuState.h" #include "CpuState.h"
#include "DisassembledCode.h" #include "DisassembledCode.h"
#include "BreakpointEditWindow.h" #include "BreakpointEditWindow.h"
#include "ExpressionEvaluationWindow.h"
#include "ExpressionPromptWindow.h" #include "ExpressionPromptWindow.h"
#include "FileSourceCode.h" #include "FileSourceCode.h"
#include "GuiSettingsUtils.h" #include "GuiSettingsUtils.h"
@@ -145,6 +146,7 @@ TeamWindow::TeamWindow(::Team* team, UserInterfaceListener* listener)
fTeamSettingsWindow(NULL), fTeamSettingsWindow(NULL),
fBreakpointEditWindow(NULL), fBreakpointEditWindow(NULL),
fInspectorWindow(NULL), fInspectorWindow(NULL),
fExpressionEvalWindow(NULL),
fExpressionPromptWindow(NULL), fExpressionPromptWindow(NULL),
fFilePanel(NULL), fFilePanel(NULL),
fActiveSourceWorker(-1) fActiveSourceWorker(-1)
@@ -167,6 +169,10 @@ TeamWindow::~TeamWindow()
if (fInspectorWindow->Lock()) if (fInspectorWindow->Lock())
fInspectorWindow->Quit(); fInspectorWindow->Quit();
} }
if (fExpressionEvalWindow != NULL) {
if (fExpressionEvalWindow->Lock())
fExpressionEvalWindow->Quit();
}
if (fExpressionPromptWindow != NULL) { if (fExpressionPromptWindow != NULL) {
if (fExpressionPromptWindow->Lock()) if (fExpressionPromptWindow->Lock())
fExpressionPromptWindow->Quit(); fExpressionPromptWindow->Quit();
@@ -345,55 +351,49 @@ TeamWindow::MessageReceived(BMessage* message)
} }
case MSG_SHOW_EXPRESSION_WINDOW: case MSG_SHOW_EXPRESSION_WINDOW:
{
if (fExpressionEvalWindow != NULL) {
AutoLocker<BWindow> lock(fExpressionEvalWindow);
if (lock.IsLocked())
fExpressionEvalWindow->Activate(true);
} else {
try {
fExpressionEvalWindow = ExpressionEvaluationWindow::Create(
this, fTeam, fListener);
if (fExpressionEvalWindow != NULL)
fExpressionEvalWindow->Show();
} catch (...) {
// TODO: notify user
}
}
break;
}
case MSG_EXPRESSION_WINDOW_CLOSED:
{
fExpressionEvalWindow = NULL;
break;
}
case MSG_SHOW_EXPRESSION_PROMPT_WINDOW: case MSG_SHOW_EXPRESSION_PROMPT_WINDOW:
{ {
BHandler* addTarget;
if (message->what == MSG_SHOW_EXPRESSION_WINDOW)
addTarget = fVariablesView;
else if (message->FindPointer("target",
reinterpret_cast<void**>(&addTarget)) != B_OK) {
break;
}
if (fExpressionPromptWindow != NULL) { if (fExpressionPromptWindow != NULL) {
AutoLocker<BWindow> lock(fExpressionPromptWindow); AutoLocker<BWindow> lock(fExpressionPromptWindow);
if (lock.IsLocked()) if (lock.IsLocked())
fExpressionPromptWindow->Activate(true); fExpressionPromptWindow->Activate(true);
} else { } else {
try { try {
// if the request was initiated via the evaluate
// expression top level menu item, then this evaluation
// should not be persisted.
bool persistentExpression =
message->what == MSG_SHOW_EXPRESSION_PROMPT_WINDOW;
fExpressionPromptWindow = ExpressionPromptWindow::Create( fExpressionPromptWindow = ExpressionPromptWindow::Create(
addTarget, this, persistentExpression); fVariablesView, this);
if (fExpressionPromptWindow != NULL) if (fExpressionPromptWindow != NULL)
fExpressionPromptWindow->Show(); fExpressionPromptWindow->Show();
} catch (...) { } catch (...) {
// TODO: notify user // TODO: notify user
} }
} }
break; break;
} }
case MSG_EXPRESSION_WINDOW_CLOSED:
case MSG_EXPRESSION_PROMPT_WINDOW_CLOSED: case MSG_EXPRESSION_PROMPT_WINDOW_CLOSED:
{ {
fExpressionPromptWindow = NULL; fExpressionPromptWindow = NULL;
const char* expression;
BMessenger targetMessenger;
if (message->FindString("expression", &expression) == B_OK
&& message->FindMessenger("target", &targetMessenger)
== B_OK) {
BMessage addMessage(MSG_ADD_NEW_EXPRESSION);
addMessage.AddString("expression", expression);
addMessage.AddBool("persistent", message->FindBool(
"persistent"));
targetMessenger.SendMessage(&addMessage);
}
break; break;
} }
case MSG_SHOW_TEAM_SETTINGS_WINDOW: case MSG_SHOW_TEAM_SETTINGS_WINDOW:
@@ -33,6 +33,7 @@ class BStringView;
class BTabView; class BTabView;
class ConsoleOutputView; class ConsoleOutputView;
class BreakpointEditWindow; class BreakpointEditWindow;
class ExpressionEvaluationWindow;
class ExpressionPromptWindow; class ExpressionPromptWindow;
class Image; class Image;
class InspectorWindow; class InspectorWindow;
@@ -240,6 +241,7 @@ private:
TeamSettingsWindow* fTeamSettingsWindow; TeamSettingsWindow* fTeamSettingsWindow;
BreakpointEditWindow* fBreakpointEditWindow; BreakpointEditWindow* fBreakpointEditWindow;
InspectorWindow* fInspectorWindow; InspectorWindow* fInspectorWindow;
ExpressionEvaluationWindow* fExpressionEvalWindow;
ExpressionPromptWindow* fExpressionPromptWindow; ExpressionPromptWindow* fExpressionPromptWindow;
GuiTeamUiSettings fUiSettings; GuiTeamUiSettings fUiSettings;
BFilePanel* fFilePanel; BFilePanel* fFilePanel;
@@ -13,16 +13,15 @@
ExpressionPromptWindow::ExpressionPromptWindow(BHandler* addTarget, ExpressionPromptWindow::ExpressionPromptWindow(BHandler* addTarget,
BHandler* closeTarget, bool isPersistent) BHandler* closeTarget)
: :
BWindow(BRect(), isPersistent ? "Add Expression" : "Evaluate Expression", BWindow(BRect(), "Add Expression", B_FLOATING_WINDOW,
B_FLOATING_WINDOW, B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE), B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE),
fExpressionInput(NULL), fExpressionInput(NULL),
fCancelButton(NULL), fCancelButton(NULL),
fAddButton(NULL), fAddButton(NULL),
fAddTarget(addTarget), fAddTarget(addTarget),
fCloseTarget(closeTarget), fCloseTarget(closeTarget)
fPersistentExpression(isPersistent)
{ {
} }
@@ -33,11 +32,10 @@ ExpressionPromptWindow::~ExpressionPromptWindow()
ExpressionPromptWindow* ExpressionPromptWindow*
ExpressionPromptWindow::Create(BHandler* addTarget, BHandler* closeTarget, ExpressionPromptWindow::Create(BHandler* addTarget, BHandler* closeTarget)
bool isPersistent)
{ {
ExpressionPromptWindow* self = new ExpressionPromptWindow(addTarget, ExpressionPromptWindow* self = new ExpressionPromptWindow(addTarget,
closeTarget, isPersistent); closeTarget);
try { try {
self->_Init(); self->_Init();
@@ -54,8 +52,7 @@ ExpressionPromptWindow::Create(BHandler* addTarget, BHandler* closeTarget,
void void
ExpressionPromptWindow::_Init() ExpressionPromptWindow::_Init()
{ {
fExpressionInput = new BTextControl("Expression:", NULL, fExpressionInput = new BTextControl("Expression:", NULL, NULL);
new BMessage(MSG_EVALUATE_EXPRESSION));
BLayoutItem* labelItem = fExpressionInput->CreateLabelLayoutItem(); BLayoutItem* labelItem = fExpressionInput->CreateLabelLayoutItem();
BLayoutItem* inputItem = fExpressionInput->CreateTextViewLayoutItem(); BLayoutItem* inputItem = fExpressionInput->CreateTextViewLayoutItem();
inputItem->SetExplicitMinSize(BSize(200.0, B_SIZE_UNSET)); inputItem->SetExplicitMinSize(BSize(200.0, B_SIZE_UNSET));
@@ -108,12 +105,11 @@ ExpressionPromptWindow::MessageReceived(BMessage* message)
switch (message->what) { switch (message->what) {
case MSG_ADD_NEW_EXPRESSION: case MSG_ADD_NEW_EXPRESSION:
{ {
BMessage addMessage(MSG_EXPRESSION_PROMPT_WINDOW_CLOSED); BMessage addMessage(MSG_ADD_NEW_EXPRESSION);
addMessage.AddString("expression", fExpressionInput->Text()); addMessage.AddString("expression", fExpressionInput->Text());
addMessage.AddBool("persistent", fPersistentExpression); addMessage.AddBool("persistent", true);
addMessage.AddMessenger("target", BMessenger(fAddTarget));
BMessenger(fCloseTarget).SendMessage(&addMessage); BMessenger(fAddTarget).SendMessage(&addMessage);
Quit(); Quit();
break; break;
} }
@@ -17,13 +17,12 @@ class ExpressionPromptWindow : public BWindow
{ {
public: public:
ExpressionPromptWindow(BHandler* addTarget, ExpressionPromptWindow(BHandler* addTarget,
BHandler* closeTarget, bool isPersistent); BHandler* closeTarget);
~ExpressionPromptWindow(); ~ExpressionPromptWindow();
static ExpressionPromptWindow* Create(BHandler* addTarget, static ExpressionPromptWindow* Create(BHandler* addTarget,
BHandler* closeTarget, BHandler* closeTarget);
bool isPersistent);
// throws // throws
@@ -41,7 +40,6 @@ private:
BButton* fAddButton; BButton* fAddButton;
BHandler* fAddTarget; BHandler* fAddTarget;
BHandler* fCloseTarget; BHandler* fCloseTarget;
bool fPersistentExpression;
}; };
#endif // EXPRESSION_PROMPT_WINDOW_H #endif // EXPRESSION_PROMPT_WINDOW_H