Debugger: Adjust TeamsWindow for connection selection.
TeamsWindow: - Add Listener interface for selected target host interface changes. - Add menu field to display/choose between active host connections. - Add button to create a new connection (not yet functional). TeamsListView: - Implement TeamsWindow Listener interface to decide when to update the displayed team list. - Remove unused current team ID.
This commit is contained in:
@@ -29,6 +29,7 @@
|
|||||||
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
MSG_SELECTED_INTERFACE_CHANGED = 'seic',
|
||||||
MSG_TEAM_ADDED = 'tead',
|
MSG_TEAM_ADDED = 'tead',
|
||||||
MSG_TEAM_REMOVED = 'tere',
|
MSG_TEAM_REMOVED = 'tere',
|
||||||
MSG_TEAM_RENAMED = 'tern'
|
MSG_TEAM_RENAMED = 'tern'
|
||||||
@@ -271,13 +272,12 @@ TeamRow::_SetTo(TeamInfo* info)
|
|||||||
// #pragma mark - TeamsListView
|
// #pragma mark - TeamsListView
|
||||||
|
|
||||||
|
|
||||||
TeamsListView::TeamsListView(const char* name, team_id currentTeam,
|
TeamsListView::TeamsListView(const char* name)
|
||||||
TargetHostInterface* interface)
|
|
||||||
:
|
:
|
||||||
Inherited(name, B_NAVIGABLE, B_PLAIN_BORDER),
|
Inherited(name, B_NAVIGABLE, B_PLAIN_BORDER),
|
||||||
TargetHost::Listener(),
|
TargetHost::Listener(),
|
||||||
fCurrentTeam(currentTeam),
|
TeamsWindow::Listener(),
|
||||||
fInterface(interface)
|
fInterface(NULL)
|
||||||
{
|
{
|
||||||
AddColumn(new TeamsColumn("Name", 400, 100, 600,
|
AddColumn(new TeamsColumn("Name", 400, 100, 600,
|
||||||
B_TRUNCATE_BEGINNING), kNameColumn);
|
B_TRUNCATE_BEGINNING), kNameColumn);
|
||||||
@@ -297,10 +297,6 @@ TeamsListView::AttachedToWindow()
|
|||||||
{
|
{
|
||||||
Inherited::AttachedToWindow();
|
Inherited::AttachedToWindow();
|
||||||
TeamsColumn::InitTextMargin(ScrollView());
|
TeamsColumn::InitTextMargin(ScrollView());
|
||||||
|
|
||||||
fInterface->GetTargetHost()->AddListener(this);
|
|
||||||
|
|
||||||
_InitList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -308,10 +304,7 @@ void
|
|||||||
TeamsListView::DetachedFromWindow()
|
TeamsListView::DetachedFromWindow()
|
||||||
{
|
{
|
||||||
Inherited::DetachedFromWindow();
|
Inherited::DetachedFromWindow();
|
||||||
|
_SetInterface(NULL);
|
||||||
fInterface->GetTargetHost()->RemoveListener(this);
|
|
||||||
|
|
||||||
Clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -319,6 +312,16 @@ void
|
|||||||
TeamsListView::MessageReceived(BMessage* message)
|
TeamsListView::MessageReceived(BMessage* message)
|
||||||
{
|
{
|
||||||
switch (message->what) {
|
switch (message->what) {
|
||||||
|
case MSG_SELECTED_INTERFACE_CHANGED:
|
||||||
|
{
|
||||||
|
TargetHostInterface* interface;
|
||||||
|
if (message->FindPointer("interface", reinterpret_cast<void**>(
|
||||||
|
&interface)) == B_OK) {
|
||||||
|
_SetInterface(interface);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case MSG_TEAM_ADDED:
|
case MSG_TEAM_ADDED:
|
||||||
{
|
{
|
||||||
TeamInfo* info;
|
TeamInfo* info;
|
||||||
@@ -420,6 +423,15 @@ TeamsListView::TeamRenamed(TeamInfo* info)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TeamsListView::SelectedInterfaceChanged(TargetHostInterface* interface)
|
||||||
|
{
|
||||||
|
BMessage message(MSG_SELECTED_INTERFACE_CHANGED);
|
||||||
|
message.AddPointer("interface", interface);
|
||||||
|
BMessenger(this).SendMessage(&message);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
TeamsListView::_InitList()
|
TeamsListView::_InitList()
|
||||||
{
|
{
|
||||||
@@ -431,3 +443,23 @@ TeamsListView::_InitList()
|
|||||||
AddRow(row);
|
AddRow(row);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TeamsListView::_SetInterface(TargetHostInterface* interface)
|
||||||
|
{
|
||||||
|
if (interface == fInterface)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (fInterface != NULL) {
|
||||||
|
Clear();
|
||||||
|
fInterface->GetTargetHost()->RemoveListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
fInterface = interface;
|
||||||
|
if (fInterface == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
fInterface->GetTargetHost()->AddListener(this);
|
||||||
|
_InitList();
|
||||||
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
#include "TargetHost.h"
|
#include "TargetHost.h"
|
||||||
#include "TeamInfo.h"
|
#include "TeamInfo.h"
|
||||||
|
#include "TeamsWindow.h"
|
||||||
|
|
||||||
|
|
||||||
class BBitmap;
|
class BBitmap;
|
||||||
@@ -89,12 +90,11 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class TeamsListView : public BColumnListView, public TargetHost::Listener {
|
class TeamsListView : public BColumnListView, public TargetHost::Listener,
|
||||||
|
public TeamsWindow::Listener {
|
||||||
typedef BColumnListView Inherited;
|
typedef BColumnListView Inherited;
|
||||||
public:
|
public:
|
||||||
TeamsListView(const char* name,
|
TeamsListView(const char* name);
|
||||||
team_id currentTeam,
|
|
||||||
TargetHostInterface* interface);
|
|
||||||
virtual ~TeamsListView();
|
virtual ~TeamsListView();
|
||||||
|
|
||||||
TeamRow* FindTeamRow(team_id teamId);
|
TeamRow* FindTeamRow(team_id teamId);
|
||||||
@@ -104,6 +104,10 @@ public:
|
|||||||
virtual void TeamRemoved(team_id team);
|
virtual void TeamRemoved(team_id team);
|
||||||
virtual void TeamRenamed(TeamInfo* info);
|
virtual void TeamRenamed(TeamInfo* info);
|
||||||
|
|
||||||
|
// TeamsWindow::Listener
|
||||||
|
virtual void SelectedInterfaceChanged(
|
||||||
|
TargetHostInterface* interface);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void AttachedToWindow();
|
virtual void AttachedToWindow();
|
||||||
virtual void DetachedFromWindow();
|
virtual void DetachedFromWindow();
|
||||||
@@ -112,9 +116,9 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void _InitList();
|
void _InitList();
|
||||||
|
void _SetInterface(TargetHostInterface* interface);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
team_id fCurrentTeam;
|
|
||||||
TargetHostInterface* fInterface;
|
TargetHostInterface* fInterface;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -19,10 +19,15 @@
|
|||||||
#include <FindDirectory.h>
|
#include <FindDirectory.h>
|
||||||
#include <LayoutBuilder.h>
|
#include <LayoutBuilder.h>
|
||||||
#include <ListView.h>
|
#include <ListView.h>
|
||||||
|
#include <Menu.h>
|
||||||
|
#include <MenuField.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
#include <Screen.h>
|
#include <Screen.h>
|
||||||
#include <ScrollView.h>
|
#include <ScrollView.h>
|
||||||
|
|
||||||
|
#include <AutoDeleter.h>
|
||||||
|
#include <AutoLocker.h>
|
||||||
|
|
||||||
#include "MessageCodes.h"
|
#include "MessageCodes.h"
|
||||||
#include "SettingsManager.h"
|
#include "SettingsManager.h"
|
||||||
#include "TargetHostInterface.h"
|
#include "TargetHostInterface.h"
|
||||||
@@ -32,7 +37,9 @@
|
|||||||
|
|
||||||
enum {
|
enum {
|
||||||
MSG_TEAM_SELECTION_CHANGED = 'tesc',
|
MSG_TEAM_SELECTION_CHANGED = 'tesc',
|
||||||
MSG_CHOSE_CORE_FILE = 'chcf'
|
MSG_CHOSE_CORE_FILE = 'chcf',
|
||||||
|
MSG_SWITCH_TARGET_CONNECTION = 'stco',
|
||||||
|
MSG_CREATE_NEW_CONNECTION = 'cnco'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -45,6 +52,7 @@ TeamsWindow::TeamsWindow(SettingsManager* settingsManager)
|
|||||||
fAttachTeamButton(NULL),
|
fAttachTeamButton(NULL),
|
||||||
fCreateTeamButton(NULL),
|
fCreateTeamButton(NULL),
|
||||||
fLoadCoreButton(NULL),
|
fLoadCoreButton(NULL),
|
||||||
|
fConnectionField(NULL),
|
||||||
fCoreSelectionPanel(NULL),
|
fCoreSelectionPanel(NULL),
|
||||||
fSettingsManager(settingsManager)
|
fSettingsManager(settingsManager)
|
||||||
{
|
{
|
||||||
@@ -165,6 +173,27 @@ TeamsWindow::MessageReceived(BMessage* message)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case MSG_CREATE_NEW_CONNECTION:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case MSG_SWITCH_TARGET_CONNECTION:
|
||||||
|
{
|
||||||
|
TargetHostInterface* interface;
|
||||||
|
if (message->FindPointer("interface", reinterpret_cast<void**>(
|
||||||
|
&interface)) != B_OK) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (interface == fTargetHostInterface)
|
||||||
|
break;
|
||||||
|
|
||||||
|
fTargetHostInterface = interface;
|
||||||
|
_NotifySelectedInterfaceChanged(interface);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
BWindow::MessageReceived(message);
|
BWindow::MessageReceived(message);
|
||||||
break;
|
break;
|
||||||
@@ -182,6 +211,22 @@ TeamsWindow::QuitRequested()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TeamsWindow::AddListener(Listener* listener)
|
||||||
|
{
|
||||||
|
AutoLocker<TeamsWindow> locker(this);
|
||||||
|
fListeners.Add(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TeamsWindow::RemoveListener(Listener* listener)
|
||||||
|
{
|
||||||
|
AutoLocker<TeamsWindow> locker(this);
|
||||||
|
fListeners.Remove(listener);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// #pragma mark --
|
// #pragma mark --
|
||||||
|
|
||||||
|
|
||||||
@@ -191,23 +236,49 @@ TeamsWindow::_Init()
|
|||||||
BMessage settings;
|
BMessage settings;
|
||||||
_LoadSettings(settings);
|
_LoadSettings(settings);
|
||||||
|
|
||||||
fTargetHostInterface = TargetHostInterfaceRoster::Default()
|
|
||||||
->ActiveInterfaceAt(0);
|
|
||||||
|
|
||||||
BRect frame;
|
BRect frame;
|
||||||
if (settings.FindRect("teams window frame", &frame) == B_OK) {
|
if (settings.FindRect("teams window frame", &frame) == B_OK) {
|
||||||
MoveTo(frame.LeftTop());
|
MoveTo(frame.LeftTop());
|
||||||
ResizeTo(frame.Width(), frame.Height());
|
ResizeTo(frame.Width(), frame.Height());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BMenu* connectionMenu = new BMenu("Connection");
|
||||||
|
ObjectDeleter<BMenu> menuDeleter(connectionMenu);
|
||||||
|
connectionMenu->SetLabelFromMarked(true);
|
||||||
|
|
||||||
|
TargetHostInterfaceRoster* roster = TargetHostInterfaceRoster::Default();
|
||||||
|
for (int32 i = 0; i < roster->CountActiveInterfaces(); i++) {
|
||||||
|
TargetHostInterface* interface = roster->ActiveInterfaceAt(i);
|
||||||
|
BMenuItem* item = new BMenuItem(interface->GetTargetHost()->Name(),
|
||||||
|
new BMessage(MSG_SWITCH_TARGET_CONNECTION));
|
||||||
|
if (item->Message()->AddPointer("interface", interface) != B_OK) {
|
||||||
|
delete item;
|
||||||
|
throw std::bad_alloc();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (interface->IsLocal()) {
|
||||||
|
item->SetMarked(true);
|
||||||
|
fTargetHostInterface = interface;
|
||||||
|
}
|
||||||
|
|
||||||
|
connectionMenu->AddItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
BLayoutBuilder::Group<>(this, B_VERTICAL)
|
BLayoutBuilder::Group<>(this, B_VERTICAL)
|
||||||
.Add(fTeamsListView = new TeamsListView("TeamsList", fCurrentTeam,
|
.AddGroup(B_HORIZONTAL)
|
||||||
fTargetHostInterface))
|
.SetInsets(B_USE_DEFAULT_SPACING)
|
||||||
|
.Add(fConnectionField = new BMenuField("Connected to:",
|
||||||
|
connectionMenu))
|
||||||
|
.AddGlue()
|
||||||
|
.Add(fCreateConnectionButton = new BButton("Create new connection"
|
||||||
|
B_UTF8_ELLIPSIS, new BMessage(MSG_CREATE_NEW_CONNECTION)))
|
||||||
|
.End()
|
||||||
|
.Add(fTeamsListView = new TeamsListView("TeamsList"))
|
||||||
.SetInsets(1.0f, 1.0f, 1.0f, 5.0f)
|
.SetInsets(1.0f, 1.0f, 1.0f, 5.0f)
|
||||||
.AddGroup(B_HORIZONTAL)
|
.AddGroup(B_HORIZONTAL)
|
||||||
.SetInsets(B_USE_DEFAULT_SPACING)
|
.SetInsets(B_USE_DEFAULT_SPACING)
|
||||||
.Add(fAttachTeamButton = new BButton("Attach", new BMessage(
|
.Add(fAttachTeamButton = new BButton("Attach", new BMessage(
|
||||||
MSG_DEBUG_THIS_TEAM)))
|
MSG_DEBUG_THIS_TEAM)))
|
||||||
.AddGlue()
|
.AddGlue()
|
||||||
.Add(fCreateTeamButton = new BButton("Start new team"
|
.Add(fCreateTeamButton = new BButton("Start new team"
|
||||||
B_UTF8_ELLIPSIS, new BMessage(MSG_SHOW_START_TEAM_WINDOW)))
|
B_UTF8_ELLIPSIS, new BMessage(MSG_SHOW_START_TEAM_WINDOW)))
|
||||||
@@ -216,13 +287,22 @@ TeamsWindow::_Init()
|
|||||||
.End()
|
.End()
|
||||||
.End();
|
.End();
|
||||||
|
|
||||||
|
menuDeleter.Detach();
|
||||||
|
|
||||||
|
AddListener(fTeamsListView);
|
||||||
|
|
||||||
|
connectionMenu->SetTargetForItems(this);
|
||||||
|
|
||||||
fTeamsListView->SetInvocationMessage(new BMessage(MSG_DEBUG_THIS_TEAM));
|
fTeamsListView->SetInvocationMessage(new BMessage(MSG_DEBUG_THIS_TEAM));
|
||||||
fTeamsListView->SetSelectionMessage(new BMessage(
|
fTeamsListView->SetSelectionMessage(new BMessage(
|
||||||
MSG_TEAM_SELECTION_CHANGED));
|
MSG_TEAM_SELECTION_CHANGED));
|
||||||
|
|
||||||
|
fCreateConnectionButton->SetEnabled(true);
|
||||||
fAttachTeamButton->SetEnabled(false);
|
fAttachTeamButton->SetEnabled(false);
|
||||||
fCreateTeamButton->SetTarget(this);
|
fCreateTeamButton->SetTarget(this);
|
||||||
fLoadCoreButton->SetTarget(this);
|
fLoadCoreButton->SetTarget(this);
|
||||||
|
|
||||||
|
_NotifySelectedInterfaceChanged(fTargetHostInterface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -271,3 +351,21 @@ TeamsWindow::_SaveSettings()
|
|||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TeamsWindow::_NotifySelectedInterfaceChanged(TargetHostInterface* interface)
|
||||||
|
{
|
||||||
|
for (ListenerList::Iterator it = fListeners.GetIterator();
|
||||||
|
Listener* listener = it.Next();) {
|
||||||
|
listener->SelectedInterfaceChanged(interface);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// #pragma mark - TeamsWindow::Listener
|
||||||
|
|
||||||
|
|
||||||
|
TeamsWindow::Listener::~Listener()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,17 +9,24 @@
|
|||||||
|
|
||||||
#include <Window.h>
|
#include <Window.h>
|
||||||
|
|
||||||
|
#include <util/DoublyLinkedList.h>
|
||||||
|
|
||||||
|
|
||||||
class BButton;
|
class BButton;
|
||||||
class BListView;
|
class BListView;
|
||||||
class BFile;
|
class BFile;
|
||||||
class BFilePanel;
|
class BFilePanel;
|
||||||
|
class BMenuField;
|
||||||
class BMessage;
|
class BMessage;
|
||||||
class SettingsManager;
|
class SettingsManager;
|
||||||
class TargetHostInterface;
|
class TargetHostInterface;
|
||||||
class TeamsListView;
|
class TeamsListView;
|
||||||
|
|
||||||
|
|
||||||
class TeamsWindow : public BWindow {
|
class TeamsWindow : public BWindow {
|
||||||
public:
|
public:
|
||||||
|
class Listener;
|
||||||
|
|
||||||
TeamsWindow(SettingsManager* settingsManager);
|
TeamsWindow(SettingsManager* settingsManager);
|
||||||
virtual ~TeamsWindow();
|
virtual ~TeamsWindow();
|
||||||
|
|
||||||
@@ -30,22 +37,43 @@ public:
|
|||||||
virtual void MessageReceived(BMessage* message);
|
virtual void MessageReceived(BMessage* message);
|
||||||
virtual bool QuitRequested();
|
virtual bool QuitRequested();
|
||||||
|
|
||||||
|
void AddListener(Listener* listener);
|
||||||
|
void RemoveListener(Listener* listener);
|
||||||
|
|
||||||
|
private:
|
||||||
|
typedef DoublyLinkedList<Listener> ListenerList;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void _Init();
|
void _Init();
|
||||||
status_t _OpenSettings(BFile& file, uint32 mode);
|
status_t _OpenSettings(BFile& file, uint32 mode);
|
||||||
status_t _LoadSettings(BMessage& settings);
|
status_t _LoadSettings(BMessage& settings);
|
||||||
status_t _SaveSettings();
|
status_t _SaveSettings();
|
||||||
|
|
||||||
|
void _NotifySelectedInterfaceChanged(
|
||||||
|
TargetHostInterface* interface);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
team_id fCurrentTeam;
|
team_id fCurrentTeam;
|
||||||
TargetHostInterface* fTargetHostInterface;
|
TargetHostInterface* fTargetHostInterface;
|
||||||
TeamsListView* fTeamsListView;
|
TeamsListView* fTeamsListView;
|
||||||
BButton* fAttachTeamButton;
|
BButton* fAttachTeamButton;
|
||||||
BButton* fCreateTeamButton;
|
BButton* fCreateTeamButton;
|
||||||
|
BButton* fCreateConnectionButton;
|
||||||
BButton* fLoadCoreButton;
|
BButton* fLoadCoreButton;
|
||||||
|
BMenuField* fConnectionField;
|
||||||
BFilePanel* fCoreSelectionPanel;
|
BFilePanel* fCoreSelectionPanel;
|
||||||
SettingsManager* fSettingsManager;
|
SettingsManager* fSettingsManager;
|
||||||
|
ListenerList fListeners;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
class TeamsWindow::Listener : public DoublyLinkedListLinkImpl<Listener>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~Listener();
|
||||||
|
|
||||||
|
virtual void SelectedInterfaceChanged(
|
||||||
|
TargetHostInterface* interface) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user