Browse Source

增加批量删除,小修小改

master
hejl 3 weeks ago
parent
commit
9186d87b77
  1. 38
      win_text_editor/lib/modules/code_creater/services/code_create_service.dart
  2. 8
      win_text_editor/lib/modules/code_creater/widgets/code_creater_view.dart
  3. 42
      win_text_editor/lib/modules/code_creater/widgets/node_table.dart
  4. 7
      win_text_editor/lib/modules/uft_component/services/uft_component_service.dart

38
win_text_editor/lib/modules/code_creater/services/code_create_service.dart

@ -228,35 +228,47 @@ class CodeCreateService { @@ -228,35 +228,47 @@ class CodeCreateService {
iteratePartnerMap.values.expand((partners) => partners).toList(),
);
List<String> fieldNames = component.fields.map((col) => col.name).toList();
switch (action) {
case "获取组件":
case "遍历组件":
List<String> fieldNames = component.fields.map((col) => col.name).toList();
iterateStack.add(component.name); //
iterateOutputFields.putIfAbsent(iterateStack.last, () => []).addAll(fieldNames);
iterateOutputFields[iterateStack.last]!.add(component.name);
iteratePartnerMap
.putIfAbsent(member.name, () => [])
.add(CodePartner(name: member.name, fields: fieldNames));
break;
case "插入组件":
case "修改组件":
for (var field in component.fields) {
if (!outputFields.contains(field.name) &&
!inputFields.contains(field.name) &&
!iterateOutputFields.values.expand((list) => list).contains(field.name)) {
inputFields.add(field.name);
}
}
continue case_get;
case_get:
case "获取组件":
//
if (iterateStack.isNotEmpty) {
//
iterateOutputFields.putIfAbsent(iterateStack.last, () => []).addAll(fieldNames);
iterateOutputFields[iterateStack.last]!.add(component.name);
iteratePartnerMap
.putIfAbsent(member.name, () => [])
.add(CodePartner(name: member.name, fields: fieldNames));
} else {
//
outputFields.addAll(fieldNames);
outputFields.add(component.name);
beforePartner.add(CodePartner(name: member.name, fields: fieldNames));
}
iterateStack.add(component.name); //
break;
default:
for (var field in component.fields) {
if (!outputFields.contains(field.name) &&
!inputFields.contains(field.name) &&
!iterateOutputFields.values.expand((list) => list).contains(field.name)) {
inputFields.add(field.name);
}
}
break;
}

8
win_text_editor/lib/modules/code_creater/widgets/code_creater_view.dart

@ -71,6 +71,7 @@ class _CodeCreaterViewState extends State<CodeCreaterView> { @@ -71,6 +71,7 @@ class _CodeCreaterViewState extends State<CodeCreaterView> {
members: _controller.members,
onMoveMember: _moveMember,
onDeleteMember: _deleteMember,
onDeleteAll: _deleteAll,
onMoveToTop: _moveToTop,
onMoveToBottom: _moveToBottom,
onActionTypeChanged:
@ -144,6 +145,13 @@ class _CodeCreaterViewState extends State<CodeCreaterView> { @@ -144,6 +145,13 @@ class _CodeCreaterViewState extends State<CodeCreaterView> {
});
}
void _deleteAll() {
setState(() {
_controller.members.clear();
_updateDisplay();
});
}
void _selectOperation(String? operation) {
if (operation == null || operation.isEmpty) {
return;

42
win_text_editor/lib/modules/code_creater/widgets/node_table.dart

@ -13,6 +13,7 @@ class NodeTable extends StatefulWidget { @@ -13,6 +13,7 @@ class NodeTable extends StatefulWidget {
final List<OutlineNode> members;
final Function(int, int) onMoveMember;
final Function(int) onDeleteMember;
final Function() onDeleteAll;
final Function(int) onMoveToTop;
final Function(int) onMoveToBottom;
final Function(int, String)? onActionTypeChanged; //
@ -22,6 +23,7 @@ class NodeTable extends StatefulWidget { @@ -22,6 +23,7 @@ class NodeTable extends StatefulWidget {
required this.members,
required this.onMoveMember,
required this.onDeleteMember,
required this.onDeleteAll,
required this.onMoveToTop,
required this.onMoveToBottom,
this.onActionTypeChanged, //
@ -108,6 +110,7 @@ class NodeTableState extends State<NodeTable> { @@ -108,6 +110,7 @@ class NodeTableState extends State<NodeTable> {
final canMoveUp = _selectedRowIndex != null && _selectedRowIndex! > 0;
final canMoveDown = _selectedRowIndex != null && _selectedRowIndex! < widget.members.length - 1;
final canDelete = _selectedRowIndex != null;
final canDeleteAll = widget.members.isNotEmpty;
return Padding(
padding: const EdgeInsets.all(2.0),
@ -158,6 +161,15 @@ class NodeTableState extends State<NodeTable> { @@ -158,6 +161,15 @@ class NodeTableState extends State<NodeTable> {
onPressed: canDelete ? () => widget.onDeleteMember(_selectedRowIndex!) : null,
tooltip: '删除行',
),
IconButton(
icon: Icon(
Icons.delete_forever,
size: 14,
color: canDeleteAll ? Colors.red : Colors.grey,
),
onPressed: canDeleteAll ? _showDeleteAllConfirmation : null,
tooltip: '全部删除',
),
],
),
],
@ -165,6 +177,36 @@ class NodeTableState extends State<NodeTable> { @@ -165,6 +177,36 @@ class NodeTableState extends State<NodeTable> {
);
}
void _showDeleteAllConfirmation() {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: const Text('确认删除'),
content: const Text('确定要删除所有节点吗?此操作不可撤销。'),
actions: [
TextButton(onPressed: () => Navigator.of(context).pop(false), child: const Text('取消')),
TextButton(
onPressed: () {
Navigator.of(context).pop(true);
_deleteAllMembers();
},
child: const Text('删除', style: TextStyle(color: Colors.red)),
),
],
);
},
);
}
//
void _deleteAllMembers() {
setState(() {
_selectedRowIndex = null;
});
widget.onDeleteAll();
}
void _handleRowSelection() {
if (_stateManager?.currentRow == null) return;
setState(() {

7
win_text_editor/lib/modules/uft_component/services/uft_component_service.dart

@ -68,10 +68,6 @@ class UftComponentService { @@ -68,10 +68,6 @@ class UftComponentService {
final name = node.getAttribute('name') ?? '';
final chineseName = node.getAttribute('chineseName') ?? '';
if (filterName != null && filterName.isNotEmpty && filterName != name) {
continue; //
}
final fields = <Field>[];
List<Index>? indexes = [];
int index = 1;
@ -130,6 +126,9 @@ class UftComponentService { @@ -130,6 +126,9 @@ class UftComponentService {
);
}
if (filterName != null && filterName.isNotEmpty) {
return _components.where((com) => com.name == filterName).toList();
}
return _components;
} on xml.XmlParserException catch (e) {
_logger.error("XML解析错误: ${e.message}");

Loading…
Cancel
Save