Skip to content

Dev 56 add jvm args editor#109

Open
D1edDuck wants to merge 3 commits into
masterfrom
dev-56-add-jvm-args-editor
Open

Dev 56 add jvm args editor#109
D1edDuck wants to merge 3 commits into
masterfrom
dev-56-add-jvm-args-editor

Conversation

@D1edDuck

@D1edDuck D1edDuck commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@IgorShaposhnikov
IgorShaposhnikov force-pushed the dev-56-add-jvm-args-editor branch from c84d0bf to f38e236 Compare July 1, 2026 09:56

<!-- Content -->
<controls:AdvancedTextBox
<StackPanel

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А в использование StackPanel есть какая-та секретная логика или можем просто удалить?

{
get => RelayCommand.GetCommand(ref _bulkPasteCommand, obj =>
{
if (string.IsNullOrWhiteSpace(BulkPasteText))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Думаю все содержимое этой компанды лучше вынести в отдельный метод для читабельности


namespace Lexplosion.UI.WPF.Core.Converters
{
public class EmptyValueToDashConverter : ConverterBase<EmptyValueToDashConverter>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

можно добавить sealed

private List<string> SplitArgs(string args)
{
var result = new List<string>();
var regex = new Regex(@"[\""'].+?[\""']|[^\s]+");

@IgorShaposhnikov IgorShaposhnikov Jul 1, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

думаю стоит вынести за метод как поле класса в формате:

private static readonly Regex SplitArgsRegex = new(
    @"[\""'].+?[\""']|[^\s]+", 
    RegexOptions.Compiled
);


if (token.StartsWith("-X"))
{
var match = Regex.Match(token, @"^(-X\w+?)(\d+[gGmMkKbB]?)$");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Тоже самое для для всех regex, что и в методе SplitArgs выше.


namespace Lexplosion.UI.WPF.Mvvm.ViewModels.Modal
{
public class JvmArgsEditorViewModel : ActionModalViewModelBase

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

думаю стоит все viewmodel запечатывать через sealed


public event Action<JvmArgEntry> FocusNewEntryRequested;

public ObservableCollection<JvmArgEntry> Entries { get; }

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Стоит подумать можно ли большую часть логики отсюда вынести в JvmArgsEditorModel. Во viewmodel останется только команды и ссылка на Model.

В качестве примера можно взять GeneralSettingsViewModel

public string Rebuild(List<JvmArgEntry> entries)
{
if (entries == null || entries.Count == 0)
return "";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

думаю можно вернуть string.Empty заместо ""

}

private void OnLoaded(object sender, RoutedEventArgs e)
{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

думаю лучше вот так метод сделать

private void OnFocusNewEntryRequested(JvmArgEntry entry)
{
    // Fail-fast guard clauses to prevent NullReference and ArgumentOutOfRange exceptions
    if (entry == null || ArgsDataGrid == null || ArgsDataGrid.Columns.Count == 0)
        return;

    // 1. Instantly select and start the scroll action
    ArgsDataGrid.SelectedItem = entry;
    ArgsDataGrid.ScrollIntoView(entry);

    // 2. Queue the remaining work until after the DataGrid finishes rendering the row
    Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Background, new Action(() =>
    {
        // Re-verify the item is still valid after the brief async delay
        if (ArgsDataGrid.Columns.Count == 0) return;

        var column = ArgsDataGrid.Columns[0];
        ArgsDataGrid.CurrentCell = new DataGridCellInfo(entry, column);

        // 3. Move keyboard focus to the grid and start editing the cell
        ArgsDataGrid.Focus();
        ArgsDataGrid.BeginEdit();
    }));
}

@D1edDuck
D1edDuck force-pushed the dev-56-add-jvm-args-editor branch from 73f98be to 2cb905c Compare July 1, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants