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-08-02 22:16:04 -04:00
parent 94acd9251e
commit d6a334fa21
4 changed files with 46 additions and 50 deletions

View File

@ -40,6 +40,7 @@
#include "CpuState.h"
#include "DisassembledCode.h"
#include "BreakpointEditWindow.h"
#include "ExpressionEvaluationWindow.h"
#include "ExpressionPromptWindow.h"
#include "FileSourceCode.h"
#include "GuiSettingsUtils.h"
@ -145,6 +146,7 @@ TeamWindow::TeamWindow(::Team* team, UserInterfaceListener* listener)
fTeamSettingsWindow(NULL),
fBreakpointEditWindow(NULL),
fInspectorWindow(NULL),
fExpressionEvalWindow(NULL),
fExpressionPromptWindow(NULL),
fFilePanel(NULL),
fActiveSourceWorker(-1)
@ -167,6 +169,10 @@ TeamWindow::~TeamWindow()
if (fInspectorWindow->Lock())
fInspectorWindow->Quit();
}
if (fExpressionEvalWindow != NULL) {
if (fExpressionEvalWindow->Lock())
fExpressionEvalWindow->Quit();
}
if (fExpressionPromptWindow != NULL) {
if (fExpressionPromptWindow->Lock())
fExpressionPromptWindow->Quit();
@ -345,55 +351,49 @@ TeamWindow::MessageReceived(BMessage* message)
}
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:
{
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) {
AutoLocker<BWindow> lock(fExpressionPromptWindow);
if (lock.IsLocked())
fExpressionPromptWindow->Activate(true);
} else {
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(
addTarget, this, persistentExpression);
fVariablesView, this);
if (fExpressionPromptWindow != NULL)
fExpressionPromptWindow->Show();
} catch (...) {
// TODO: notify user
}
} catch (...) {
// TODO: notify user
}
}
break;
}
case MSG_EXPRESSION_WINDOW_CLOSED:
case MSG_EXPRESSION_PROMPT_WINDOW_CLOSED:
{
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;
}
case MSG_SHOW_TEAM_SETTINGS_WINDOW:

View File

@ -33,6 +33,7 @@ class BStringView;
class BTabView;
class ConsoleOutputView;
class BreakpointEditWindow;
class ExpressionEvaluationWindow;
class ExpressionPromptWindow;
class Image;
class InspectorWindow;
@ -240,6 +241,7 @@ private:
TeamSettingsWindow* fTeamSettingsWindow;
BreakpointEditWindow* fBreakpointEditWindow;
InspectorWindow* fInspectorWindow;
ExpressionEvaluationWindow* fExpressionEvalWindow;
ExpressionPromptWindow* fExpressionPromptWindow;
GuiTeamUiSettings fUiSettings;
BFilePanel* fFilePanel;

View File

@ -13,16 +13,15 @@
ExpressionPromptWindow::ExpressionPromptWindow(BHandler* addTarget,
BHandler* closeTarget, bool isPersistent)
BHandler* closeTarget)
:
BWindow(BRect(), isPersistent ? "Add Expression" : "Evaluate Expression",
B_FLOATING_WINDOW, B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE),
BWindow(BRect(), "Add Expression", B_FLOATING_WINDOW,
B_AUTO_UPDATE_SIZE_LIMITS | B_CLOSE_ON_ESCAPE),
fExpressionInput(NULL),
fCancelButton(NULL),
fAddButton(NULL),
fAddTarget(addTarget),
fCloseTarget(closeTarget),
fPersistentExpression(isPersistent)
fCloseTarget(closeTarget)
{
}
@ -33,11 +32,10 @@ ExpressionPromptWindow::~ExpressionPromptWindow()
ExpressionPromptWindow*
ExpressionPromptWindow::Create(BHandler* addTarget, BHandler* closeTarget,
bool isPersistent)
ExpressionPromptWindow::Create(BHandler* addTarget, BHandler* closeTarget)
{
ExpressionPromptWindow* self = new ExpressionPromptWindow(addTarget,
closeTarget, isPersistent);
closeTarget);
try {
self->_Init();
@ -54,8 +52,7 @@ ExpressionPromptWindow::Create(BHandler* addTarget, BHandler* closeTarget,
void
ExpressionPromptWindow::_Init()
{
fExpressionInput = new BTextControl("Expression:", NULL,
new BMessage(MSG_EVALUATE_EXPRESSION));
fExpressionInput = new BTextControl("Expression:", NULL, NULL);
BLayoutItem* labelItem = fExpressionInput->CreateLabelLayoutItem();
BLayoutItem* inputItem = fExpressionInput->CreateTextViewLayoutItem();
inputItem->SetExplicitMinSize(BSize(200.0, B_SIZE_UNSET));
@ -108,12 +105,11 @@ ExpressionPromptWindow::MessageReceived(BMessage* message)
switch (message->what) {
case MSG_ADD_NEW_EXPRESSION:
{
BMessage addMessage(MSG_EXPRESSION_PROMPT_WINDOW_CLOSED);
BMessage addMessage(MSG_ADD_NEW_EXPRESSION);
addMessage.AddString("expression", fExpressionInput->Text());
addMessage.AddBool("persistent", fPersistentExpression);
addMessage.AddMessenger("target", BMessenger(fAddTarget));
addMessage.AddBool("persistent", true);
BMessenger(fCloseTarget).SendMessage(&addMessage);
BMessenger(fAddTarget).SendMessage(&addMessage);
Quit();
break;
}

View File

@ -17,13 +17,12 @@ class ExpressionPromptWindow : public BWindow
{
public:
ExpressionPromptWindow(BHandler* addTarget,
BHandler* closeTarget, bool isPersistent);
BHandler* closeTarget);
~ExpressionPromptWindow();
static ExpressionPromptWindow* Create(BHandler* addTarget,
BHandler* closeTarget,
bool isPersistent);
BHandler* closeTarget);
// throws
@ -41,7 +40,6 @@ private:
BButton* fAddButton;
BHandler* fAddTarget;
BHandler* fCloseTarget;
bool fPersistentExpression;
};
#endif // EXPRESSION_PROMPT_WINDOW_H