Browse Source

增加批量删除,小修小改

master
hejl 3 weeks ago
parent
commit
9186d87b77
  1. 36
      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

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

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

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

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

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

@ -13,6 +13,7 @@ class NodeTable extends StatefulWidget {
final List<OutlineNode> members; final List<OutlineNode> members;
final Function(int, int) onMoveMember; final Function(int, int) onMoveMember;
final Function(int) onDeleteMember; final Function(int) onDeleteMember;
final Function() onDeleteAll;
final Function(int) onMoveToTop; final Function(int) onMoveToTop;
final Function(int) onMoveToBottom; final Function(int) onMoveToBottom;
final Function(int, String)? onActionTypeChanged; // final Function(int, String)? onActionTypeChanged; //
@ -22,6 +23,7 @@ class NodeTable extends StatefulWidget {
required this.members, required this.members,
required this.onMoveMember, required this.onMoveMember,
required this.onDeleteMember, required this.onDeleteMember,
required this.onDeleteAll,
required this.onMoveToTop, required this.onMoveToTop,
required this.onMoveToBottom, required this.onMoveToBottom,
this.onActionTypeChanged, // this.onActionTypeChanged, //
@ -108,6 +110,7 @@ class NodeTableState extends State<NodeTable> {
final canMoveUp = _selectedRowIndex != null && _selectedRowIndex! > 0; final canMoveUp = _selectedRowIndex != null && _selectedRowIndex! > 0;
final canMoveDown = _selectedRowIndex != null && _selectedRowIndex! < widget.members.length - 1; final canMoveDown = _selectedRowIndex != null && _selectedRowIndex! < widget.members.length - 1;
final canDelete = _selectedRowIndex != null; final canDelete = _selectedRowIndex != null;
final canDeleteAll = widget.members.isNotEmpty;
return Padding( return Padding(
padding: const EdgeInsets.all(2.0), padding: const EdgeInsets.all(2.0),
@ -158,6 +161,15 @@ class NodeTableState extends State<NodeTable> {
onPressed: canDelete ? () => widget.onDeleteMember(_selectedRowIndex!) : null, onPressed: canDelete ? () => widget.onDeleteMember(_selectedRowIndex!) : null,
tooltip: '删除行', 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> {
); );
} }
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() { void _handleRowSelection() {
if (_stateManager?.currentRow == null) return; if (_stateManager?.currentRow == null) return;
setState(() { setState(() {

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

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

Loading…
Cancel
Save