Skip to content

Commit 7c14fad

Browse files
authored
Merge pull request #438 from 1c-syntax/feature/forms
Упрощенная реализация хранения содержимого форм
2 parents 6075b20 + ce57395 commit 7c14fad

File tree

193 files changed

+82295
-231559
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

193 files changed

+82295
-231559
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@ build/
1010
*.iml
1111
/.idea/workspace.xml
1212
/.idea/sonar*
13+
14+
/.idea/misc.xml

.idea/.name

Lines changed: 0 additions & 1 deletion
This file was deleted.

.idea/gradle.xml

Lines changed: 15 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/mdclasses.iml

Lines changed: 0 additions & 2 deletions
This file was deleted.

.idea/misc.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.

.idea/modules.xml

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/main/java/com/github/_1c_syntax/bsl/mdo/storage/EmptyFormData.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,11 @@
2121
*/
2222
package com.github._1c_syntax.bsl.mdo.storage;
2323

24-
import lombok.Value;
25-
2624
/**
27-
* Реализация пустого содержимого макета
25+
* Реализация содержимого пустой формы
2826
*/
29-
@Value
3027
public class EmptyFormData implements FormData {
28+
3129
private static final EmptyFormData EMPTY = new EmptyFormData();
3230

3331
/**

src/main/java/com/github/_1c_syntax/bsl/mdo/storage/FormData.java

Lines changed: 41 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,14 @@
2121
*/
2222
package com.github._1c_syntax.bsl.mdo.storage;
2323

24-
import javax.annotation.Nullable;
25-
import java.nio.file.Path;
24+
import com.github._1c_syntax.bsl.mdo.storage.form.FormAttribute;
25+
import com.github._1c_syntax.bsl.mdo.storage.form.FormHandler;
26+
import com.github._1c_syntax.bsl.mdo.storage.form.FormItem;
27+
import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString;
28+
29+
import java.util.ArrayList;
30+
import java.util.Collections;
31+
import java.util.List;
2632

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

3642
/**
37-
* Путь к файлу с содержимым. Может быть незаполнен
43+
* Заголовок формы
44+
*/
45+
default MultiLanguageString getTitle() {
46+
return MultiLanguageString.EMPTY;
47+
}
48+
49+
/**
50+
* Обработчики событий формы
51+
*/
52+
default List<FormHandler> getHandlers() {
53+
return Collections.emptyList();
54+
}
55+
56+
/**
57+
* Список визуальных элементов формы первого уровня (т.е. с родителем - форма)
58+
*/
59+
default List<FormItem> getItems() {
60+
return Collections.emptyList();
61+
}
62+
63+
/**
64+
* Список всех визуальных элементов формы
65+
*/
66+
default List<FormItem> getPlainItems() {
67+
List<FormItem> allItems = new ArrayList<>(getItems());
68+
getItems().forEach(formItem -> allItems.addAll(formItem.getPlainItems()));
69+
return allItems;
70+
}
71+
72+
/**
73+
* Список реквизитов формы
3874
*/
39-
@Nullable
40-
default Path getDataPath() {
41-
return null;
75+
default List<FormAttribute> getAttributes() {
76+
return Collections.emptyList();
4277
}
4378
}
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
* This file is a part of MDClasses.
3+
*
4+
* Copyright (c) 2019 - 2023
5+
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* MDClasses is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* MDClasses is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with MDClasses.
21+
*/
22+
package com.github._1c_syntax.bsl.mdo.storage;
23+
24+
import com.github._1c_syntax.bsl.mdo.storage.form.FormAttribute;
25+
import com.github._1c_syntax.bsl.mdo.storage.form.FormHandler;
26+
import com.github._1c_syntax.bsl.mdo.storage.form.FormItem;
27+
import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString;
28+
import lombok.Builder;
29+
import lombok.Builder.Default;
30+
import lombok.Singular;
31+
import lombok.Value;
32+
33+
import java.util.List;
34+
35+
/**
36+
* Реализация содержимого управляемой формы
37+
*/
38+
@Value
39+
@Builder
40+
public class ManagedFormData implements FormData {
41+
@Default
42+
MultiLanguageString title = MultiLanguageString.EMPTY;
43+
@Singular("addHandlers")
44+
List<FormHandler> handlers;
45+
@Singular("addItems")
46+
List<FormItem> items;
47+
@Singular("addAttributes")
48+
List<FormAttribute> attributes;
49+
50+
@Override
51+
public boolean isEmpty() {
52+
return false;
53+
}
54+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* This file is a part of MDClasses.
3+
*
4+
* Copyright (c) 2019 - 2023
5+
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* MDClasses is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* MDClasses is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with MDClasses.
21+
*/
22+
package com.github._1c_syntax.bsl.mdo.storage.form;
23+
24+
import com.github._1c_syntax.bsl.mdo.support.MultiLanguageString;
25+
import lombok.Builder;
26+
import lombok.Builder.Default;
27+
import lombok.Value;
28+
29+
/**
30+
* Хранит описание атрибута формы
31+
*/
32+
@Value
33+
@Builder
34+
public class FormAttribute {
35+
36+
/**
37+
* Идентификатор
38+
*/
39+
@Default
40+
int id = -1;
41+
42+
/**
43+
* Имя
44+
*/
45+
@Default
46+
String name = "";
47+
48+
/**
49+
* Синоним
50+
*/
51+
@Default
52+
MultiLanguageString title = MultiLanguageString.EMPTY;
53+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
/*
2+
* This file is a part of MDClasses.
3+
*
4+
* Copyright (c) 2019 - 2023
5+
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* MDClasses is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* MDClasses is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with MDClasses.
21+
*/
22+
package com.github._1c_syntax.bsl.mdo.storage.form;
23+
24+
import lombok.Getter;
25+
import lombok.Value;
26+
27+
/**
28+
* Путь к реквизиту атрибута форма
29+
*/
30+
@Value
31+
public class FormDataPath {
32+
33+
/**
34+
* ссылка на пустой элемент
35+
*/
36+
public static final FormDataPath EMPTY = new FormDataPath();
37+
38+
/**
39+
* Путь к реквизиту
40+
*/
41+
String segments;
42+
43+
/**
44+
* Признак отсутствия пути
45+
*/
46+
@Getter
47+
boolean empty;
48+
49+
private FormDataPath() {
50+
segments = "";
51+
empty = true;
52+
}
53+
54+
public FormDataPath(String segments) {
55+
this.segments = segments;
56+
this.empty = false;
57+
}
58+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* This file is a part of MDClasses.
3+
*
4+
* Copyright (c) 2019 - 2023
5+
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* MDClasses is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* MDClasses is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with MDClasses.
21+
*/
22+
package com.github._1c_syntax.bsl.mdo.storage.form;
23+
24+
/**
25+
* Обработчик события формы
26+
*
27+
* @param event Имя события
28+
* @param name Имя обработчика (метода) формы
29+
*/
30+
public record FormHandler(String event, String name) {
31+
}

0 commit comments

Comments
 (0)