Skip to content

Commit

Permalink
Merge pull request #438 from 1c-syntax/feature/forms
Browse files Browse the repository at this point in the history
Упрощенная реализация хранения содержимого форм
  • Loading branch information
theshadowco authored Dec 26, 2023
2 parents 6075b20 + ce57395 commit 7c14fad
Show file tree
Hide file tree
Showing 193 changed files with 82,295 additions and 231,559 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,5 @@ build/
*.iml
/.idea/workspace.xml
/.idea/sonar*

/.idea/misc.xml
1 change: 0 additions & 1 deletion .idea/.name

This file was deleted.

35 changes: 15 additions & 20 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions .idea/mdclasses.iml

This file was deleted.

7 changes: 0 additions & 7 deletions .idea/misc.xml

This file was deleted.

10 changes: 0 additions & 10 deletions .idea/modules.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@
*/
package com.github._1c_syntax.bsl.mdo.storage;

import lombok.Value;

/**
* Реализация пустого содержимого макета
* Реализация содержимого пустой формы
*/
@Value
public class EmptyFormData implements FormData {

private static final EmptyFormData EMPTY = new EmptyFormData();

/**
Expand Down
47 changes: 41 additions & 6 deletions src/main/java/com/github/_1c_syntax/bsl/mdo/storage/FormData.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,14 @@
*/
package com.github._1c_syntax.bsl.mdo.storage;

import javax.annotation.Nullable;
import java.nio.file.Path;
import com.github._1c_syntax.bsl.mdo.storage.form.FormAttribute;
import com.github._1c_syntax.bsl.mdo.storage.form.FormHandler;
import com.github._1c_syntax.bsl.mdo.storage.form.FormItem;
import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
* Интерфейс содержимого форм
Expand All @@ -34,10 +40,39 @@ public interface FormData {
boolean isEmpty();

/**
* Путь к файлу с содержимым. Может быть незаполнен
* Заголовок формы
*/
default MultiLanguageString getTitle() {
return MultiLanguageString.EMPTY;
}

/**
* Обработчики событий формы
*/
default List<FormHandler> getHandlers() {
return Collections.emptyList();
}

/**
* Список визуальных элементов формы первого уровня (т.е. с родителем - форма)
*/
default List<FormItem> getItems() {
return Collections.emptyList();
}

/**
* Список всех визуальных элементов формы
*/
default List<FormItem> getPlainItems() {
List<FormItem> allItems = new ArrayList<>(getItems());
getItems().forEach(formItem -> allItems.addAll(formItem.getPlainItems()));
return allItems;
}

/**
* Список реквизитов формы
*/
@Nullable
default Path getDataPath() {
return null;
default List<FormAttribute> getAttributes() {
return Collections.emptyList();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* This file is a part of MDClasses.
*
* Copyright (c) 2019 - 2023
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*
* MDClasses is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* MDClasses is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with MDClasses.
*/
package com.github._1c_syntax.bsl.mdo.storage;

import com.github._1c_syntax.bsl.mdo.storage.form.FormAttribute;
import com.github._1c_syntax.bsl.mdo.storage.form.FormHandler;
import com.github._1c_syntax.bsl.mdo.storage.form.FormItem;
import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString;
import lombok.Builder;
import lombok.Builder.Default;
import lombok.Singular;
import lombok.Value;

import java.util.List;

/**
* Реализация содержимого управляемой формы
*/
@Value
@Builder
public class ManagedFormData implements FormData {
@Default
MultiLanguageString title = MultiLanguageString.EMPTY;
@Singular("addHandlers")
List<FormHandler> handlers;
@Singular("addItems")
List<FormItem> items;
@Singular("addAttributes")
List<FormAttribute> attributes;

@Override
public boolean isEmpty() {
return false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* This file is a part of MDClasses.
*
* Copyright (c) 2019 - 2023
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*
* MDClasses is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* MDClasses is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with MDClasses.
*/
package com.github._1c_syntax.bsl.mdo.storage.form;

import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString;
import lombok.Builder;
import lombok.Builder.Default;
import lombok.Value;

/**
* Хранит описание атрибута формы
*/
@Value
@Builder
public class FormAttribute {

/**
* Идентификатор
*/
@Default
int id = -1;

/**
* Имя
*/
@Default
String name = "";

/**
* Синоним
*/
@Default
MultiLanguageString title = MultiLanguageString.EMPTY;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* This file is a part of MDClasses.
*
* Copyright (c) 2019 - 2023
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*
* MDClasses is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* MDClasses is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with MDClasses.
*/
package com.github._1c_syntax.bsl.mdo.storage.form;

import lombok.Getter;
import lombok.Value;

/**
* Путь к реквизиту атрибута форма
*/
@Value
public class FormDataPath {

/**
* ссылка на пустой элемент
*/
public static final FormDataPath EMPTY = new FormDataPath();

/**
* Путь к реквизиту
*/
String segments;

/**
* Признак отсутствия пути
*/
@Getter
boolean empty;

private FormDataPath() {
segments = "";
empty = true;
}

public FormDataPath(String segments) {
this.segments = segments;
this.empty = false;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* This file is a part of MDClasses.
*
* Copyright (c) 2019 - 2023
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
*
* SPDX-License-Identifier: LGPL-3.0-or-later
*
* MDClasses is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* MDClasses is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with MDClasses.
*/
package com.github._1c_syntax.bsl.mdo.storage.form;

/**
* Обработчик события формы
*
* @param event Имя события
* @param name Имя обработчика (метода) формы
*/
public record FormHandler(String event, String name) {
}
Loading

0 comments on commit 7c14fad

Please sign in to comment.