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 {
|
||||
MSG_SELECTED_INTERFACE_CHANGED = 'seic',
|
||||
MSG_TEAM_ADDED = 'tead',
|
||||
MSG_TEAM_REMOVED = 'tere',
|
||||
MSG_TEAM_RENAMED = 'tern'
|
||||
@@ -271,13 +272,12 @@ TeamRow::_SetTo(TeamInfo* info)
|
||||
// #pragma mark - TeamsListView
|
||||
|
||||
|
||||
TeamsListView::TeamsListView(const char* name, team_id currentTeam,
|
||||
TargetHostInterface* interface)
|
||||
TeamsListView::TeamsListView(const char* name)
|
||||
:
|
||||
Inherited(name, B_NAVIGABLE, B_PLAIN_BORDER),
|
||||
TargetHost::Listener(),
|
||||
fCurrentTeam(currentTeam),
|
||||
fInterface(interface)
|
||||
TeamsWindow::Listener(),
|
||||
fInterface(NULL)
|
||||
{
|
||||
AddColumn(new TeamsColumn("Name", 400, 100, 600,
|
||||
B_TRUNCATE_BEGINNING), kNameColumn);
|
||||
@@ -297,10 +297,6 @@ TeamsListView::AttachedToWindow()
|
||||
{
|
||||
Inherited::AttachedToWindow();
|
||||
TeamsColumn::InitTextMargin(ScrollView());
|
||||
|
||||
fInterface->GetTargetHost()->AddListener(this);
|
||||
|
||||
_InitList();
|
||||
}
|
||||
|
||||
|
||||
@@ -308,10 +304,7 @@ void
|
||||
TeamsListView::DetachedFromWindow()
|
||||
{
|
||||
Inherited::DetachedFromWindow();
|
||||
|
||||
fInterface->GetTargetHost()->RemoveListener(this);
|
||||
|
||||
Clear();
|
||||
_SetInterface(NULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -319,6 +312,16 @@ void
|
||||
TeamsListView::MessageReceived(BMessage* message)
|
||||
{
|
||||
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:
|
||||
{
|
||||
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
|
||||
TeamsListView::_InitList()
|
||||
{
|
||||
@@ -431,3 +443,23 @@ TeamsListView::_InitList()
|
||||
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 "TeamInfo.h"
|
||||
#include "TeamsWindow.h"
|
||||
|
||||
|
||||
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;
|
||||
public:
|
||||
TeamsListView(const char* name,
|
||||
team_id currentTeam,
|
||||
TargetHostInterface* interface);
|
||||
TeamsListView(const char* name);
|
||||
virtual ~TeamsListView();
|
||||
|
||||
TeamRow* FindTeamRow(team_id teamId);
|
||||
@@ -104,6 +104,10 @@ public:
|
||||
virtual void TeamRemoved(team_id team);
|
||||
virtual void TeamRenamed(TeamInfo* info);
|
||||
|
||||
// TeamsWindow::Listener
|
||||
virtual void SelectedInterfaceChanged(
|
||||
TargetHostInterface* interface);
|
||||
|
||||
protected:
|
||||
virtual void AttachedToWindow();
|
||||
virtual void DetachedFromWindow();
|
||||
@@ -112,9 +116,9 @@ protected:
|
||||
|
||||
private:
|
||||
void _InitList();
|
||||
void _SetInterface(TargetHostInterface* interface);
|
||||
|
||||
private:
|
||||
team_id fCurrentTeam;
|
||||
TargetHostInterface* fInterface;
|
||||
};
|
||||
|
||||
|
||||
@@ -19,10 +19,15 @@
|
||||
#include <FindDirectory.h>
|
||||
#include <LayoutBuilder.h>
|
||||
#include <ListView.h>
|
||||
#include <Menu.h>
|
||||
#include <MenuField.h>
|
||||
#include <Path.h>
|
||||
#include <Screen.h>
|
||||
#include <ScrollView.h>
|
||||
|
||||
#include <AutoDeleter.h>
|
||||
#include <AutoLocker.h>
|
||||
|
||||
#include "MessageCodes.h"
|
||||
#include "SettingsManager.h"
|
||||
#include "TargetHostInterface.h"
|
||||
@@ -32,7 +37,9 @@
|
||||
|
||||
enum {
|
||||
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),
|
||||
fCreateTeamButton(NULL),
|
||||
fLoadCoreButton(NULL),
|
||||
fConnectionField(NULL),
|
||||
fCoreSelectionPanel(NULL),
|
||||
fSettingsManager(settingsManager)
|
||||
{
|
||||
@@ -165,6 +173,27 @@ TeamsWindow::MessageReceived(BMessage* message)
|
||||
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:
|
||||
BWindow::MessageReceived(message);
|
||||
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 --
|
||||
|
||||
|
||||
@@ -191,23 +236,49 @@ TeamsWindow::_Init()
|
||||
BMessage settings;
|
||||
_LoadSettings(settings);
|
||||
|
||||
fTargetHostInterface = TargetHostInterfaceRoster::Default()
|
||||
->ActiveInterfaceAt(0);
|
||||
|
||||
BRect frame;
|
||||
if (settings.FindRect("teams window frame", &frame) == B_OK) {
|
||||
MoveTo(frame.LeftTop());
|
||||
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)
|
||||
.Add(fTeamsListView = new TeamsListView("TeamsList", fCurrentTeam,
|
||||
fTargetHostInterface))
|
||||
.AddGroup(B_HORIZONTAL)
|
||||
.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)
|
||||
.AddGroup(B_HORIZONTAL)
|
||||
.SetInsets(B_USE_DEFAULT_SPACING)
|
||||
.Add(fAttachTeamButton = new BButton("Attach", new BMessage(
|
||||
MSG_DEBUG_THIS_TEAM)))
|
||||
MSG_DEBUG_THIS_TEAM)))
|
||||
.AddGlue()
|
||||
.Add(fCreateTeamButton = new BButton("Start new team"
|
||||
B_UTF8_ELLIPSIS, new BMessage(MSG_SHOW_START_TEAM_WINDOW)))
|
||||
@@ -216,13 +287,22 @@ TeamsWindow::_Init()
|
||||
.End()
|
||||
.End();
|
||||
|
||||
menuDeleter.Detach();
|
||||
|
||||
AddListener(fTeamsListView);
|
||||
|
||||
connectionMenu->SetTargetForItems(this);
|
||||
|
||||
fTeamsListView->SetInvocationMessage(new BMessage(MSG_DEBUG_THIS_TEAM));
|
||||
fTeamsListView->SetSelectionMessage(new BMessage(
|
||||
MSG_TEAM_SELECTION_CHANGED));
|
||||
|
||||
fCreateConnectionButton->SetEnabled(true);
|
||||
fAttachTeamButton->SetEnabled(false);
|
||||
fCreateTeamButton->SetTarget(this);
|
||||
fLoadCoreButton->SetTarget(this);
|
||||
|
||||
_NotifySelectedInterfaceChanged(fTargetHostInterface);
|
||||
}
|
||||
|
||||
|
||||
@@ -271,3 +351,21 @@ TeamsWindow::_SaveSettings()
|
||||
|
||||
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 <util/DoublyLinkedList.h>
|
||||
|
||||
|
||||
class BButton;
|
||||
class BListView;
|
||||
class BFile;
|
||||
class BFilePanel;
|
||||
class BMenuField;
|
||||
class BMessage;
|
||||
class SettingsManager;
|
||||
class TargetHostInterface;
|
||||
class TeamsListView;
|
||||
|
||||
|
||||
class TeamsWindow : public BWindow {
|
||||
public:
|
||||
class Listener;
|
||||
|
||||
TeamsWindow(SettingsManager* settingsManager);
|
||||
virtual ~TeamsWindow();
|
||||
|
||||
@@ -30,22 +37,43 @@ public:
|
||||
virtual void MessageReceived(BMessage* message);
|
||||
virtual bool QuitRequested();
|
||||
|
||||
void AddListener(Listener* listener);
|
||||
void RemoveListener(Listener* listener);
|
||||
|
||||
private:
|
||||
typedef DoublyLinkedList<Listener> ListenerList;
|
||||
|
||||
private:
|
||||
void _Init();
|
||||
status_t _OpenSettings(BFile& file, uint32 mode);
|
||||
status_t _LoadSettings(BMessage& settings);
|
||||
status_t _SaveSettings();
|
||||
|
||||
void _NotifySelectedInterfaceChanged(
|
||||
TargetHostInterface* interface);
|
||||
|
||||
private:
|
||||
team_id fCurrentTeam;
|
||||
TargetHostInterface* fTargetHostInterface;
|
||||
TeamsListView* fTeamsListView;
|
||||
BButton* fAttachTeamButton;
|
||||
BButton* fCreateTeamButton;
|
||||
BButton* fCreateConnectionButton;
|
||||
BButton* fLoadCoreButton;
|
||||
BMenuField* fConnectionField;
|
||||
BFilePanel* fCoreSelectionPanel;
|
||||
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