<commit_before>// +build windows

package leaseui

import (
	"context"

	"github.com/lxn/walk"
	"github.com/scjalliance/resourceful/guardian"

	ui "github.com/lxn/walk/declarative"
)

// ConnectionDialog is a lost connection dialog.
type ConnectionDialog struct {
	ui        *ui.Dialog
	form      *walk.Dialog
	remaining *walk.Label
	model     *ConnectionModel
}

// NewConnectionDialog returns a new connection dialog with the given view
// model.
func NewConnectionDialog(model *ConnectionModel) (dlg *ConnectionDialog, err error) {
	dlg = &ConnectionDialog{
		model: model,
	}

	dlg.ui = &ui.Dialog{
		Icon:     (*walk.Icon)(model.Icon()),
		Title:    model.Title(),
		MinSize:  ui.Size{Width: 300, Height: 200},
		Layout:   ui.Grid{},
		AssignTo: &dlg.form,
		Children: []ui.Widget{
			ui.Composite{
				Layout: ui.Grid{Columns: 1},
				Children: []ui.Widget{
					ui.Label{Text: model.Description()},
					ui.Label{Text: model.Remaining(), AssignTo: &dlg.remaining},
					ui.Label{Text: model.Warning()},
				},
			},
		},
	}

	model.RefreshEvent().Attach(func() {
		dlg.remaining.SetText(model.Remaining())
	})

	err = dlg.ui.Create(nil)

	return
}

// Run will display the connection dialog.
//
// Run blocks until the dialog is closed. The dialog can be closed by the user
// or by cancelling the provided context.
//
// Run returns the result of the dialog. If the context was cancelled run will
// return walk.DlgCmdCancel.
func (dlg *ConnectionDialog) Run(ctx context.Context) int {
	return runDialog(ctx, dlg.form)<commit_msg>leaseui: Improved Windows connection dialog<commit_after>// +build windows

package leaseui

import (
	"context"

	"github.com/lxn/walk"
	"github.com/scjalliance/resourceful/guardian"

	ui "github.com/lxn/walk/declarative"
)

// ConnectionDialog is a lost connection dialog.
type ConnectionDialog struct {
	ui        *ui.Dialog
	form      *walk.Dialog
	remaining *walk.Label
	model     *ConnectionModel
}

// NewConnectionDialog returns a new connection dialog with the given view
// model.
func NewConnectionDialog(model *ConnectionModel) (dlg *ConnectionDialog, err error) {
	dlg = &ConnectionDialog{
		model: model,
	}

	size := ui.Size{Width: 500, Height: 200}

	dlg.ui = &ui.Dialog{
		Icon:     (*walk.Icon)(model.Icon()),
		Title:    model.Title(),
		MinSize:  size,
		MaxSize:  size,
		Layout:   ui.Grid{Columns: 2},
		AssignTo: &dlg.form,
		Children: []ui.Widget{
			ui.Label{Text: model.Description(), Row: 0, Column: 0, ColumnSpan: 2},
			ui.Label{Text: model.Remaining(), AssignTo: &dlg.remaining, Row: 1, Column: 0, ColumnSpan: 2},
			ui.Label{Text: model.Warning(), Row: 2, Column: 0, ColumnSpan: 2},
			ui.VSpacer{Row: 3, Column: 0, ColumnSpan: 2},
			ui.HSpacer{Row: 4, Column: 0},
			ui.PushButton{
				Row:    4,
				Column: 1,
				Text:   "Ignore",
				OnClicked: func() {
					dlg.form.Close(walk.DlgCmdAbort)
				},
			},
		},
	}

	model.RefreshEvent().Attach(func() {
		dlg.form.SetTitle(model.Title())
		dlg.remaining.SetText(model.Remaining())
	})

	err = dlg.ui.Create(nil)

	return
}

// Run will display the connection dialog.
//
// Run blocks until the dialog is closed. The dialog can be closed by the user
// or by cancelling the provided context.
//
// Run returns the result of the dialog. If the context was cancelled run will
// return walk.DlgCmdCancel.
func (dlg *ConnectionDialog) Run(ctx context.Context) int {
	return runDialog(ctx, dlg.form)
{'fraction_non_alphanumeric': 0.13428905792861323, 'fraction_numerical': 0.008777062609713282, 'mean_word_length': 3.5105540897097627, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '646577', 'n_tokens_mistral': 1277, 'n_tokens_neox': 1152, 'n_words': 317}