修改菜单权限分配问题
This commit is contained in:
parent
37bbfe74c9
commit
5b94f1c7bd
@ -17,7 +17,7 @@
|
||||
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<openjfx.version>22.0.1</openjfx.version>
|
||||
<openjfx.version>22.0.2</openjfx.version>
|
||||
|
||||
<sass.version>1.54.4</sass.version>
|
||||
<atlantafx.version>2.0.1</atlantafx.version>
|
||||
|
5
dillon-ui/dillon-ui-fx/src/test/java/App.java
Normal file
5
dillon-ui/dillon-ui-fx/src/test/java/App.java
Normal file
@ -0,0 +1,5 @@
|
||||
public class App {
|
||||
public static void main(String[] args) {
|
||||
SimpleJavaFXApp.main(args);
|
||||
}
|
||||
}
|
67
dillon-ui/dillon-ui-fx/src/test/java/SimpleJavaFXApp.java
Normal file
67
dillon-ui/dillon-ui-fx/src/test/java/SimpleJavaFXApp.java
Normal file
@ -0,0 +1,67 @@
|
||||
import javafx.application.Application;
|
||||
import javafx.application.Platform;
|
||||
import javafx.css.PseudoClass;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.stage.Window;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class SimpleJavaFXApp extends Application {
|
||||
|
||||
@Override
|
||||
public void start(Stage stage) throws Exception {
|
||||
|
||||
|
||||
|
||||
|
||||
// 创建一个标签并设置文本
|
||||
Label label = new Label("Hello, JavaFX!");
|
||||
|
||||
// 创建一个根布局
|
||||
StackPane root = new StackPane();
|
||||
root.getChildren().add(label);
|
||||
|
||||
// 创建一个场景,设置根布局和窗口大小
|
||||
Scene scene = new Scene(root, 300, 200);
|
||||
|
||||
// 设置窗口标题
|
||||
stage.setTitle("Simple JavaFX App");
|
||||
|
||||
// 设置场景到窗口
|
||||
stage.setScene(scene);
|
||||
|
||||
//
|
||||
// Method tkStageGetter = Window.class.getDeclaredMethod("getPeer");;
|
||||
//
|
||||
// tkStageGetter.setAccessible(true);
|
||||
// Object tkStage = tkStageGetter.invoke(stage);
|
||||
// Method getPlatformWindow = tkStage.getClass().getDeclaredMethod("getPlatformWindow");
|
||||
//// getPlatformWindow.setAccessible(true);
|
||||
//// Object platformWindow = getPlatformWindow.invoke(tkStage);
|
||||
// Method getNativeHandle = platformWindow.getClass().getMethod("getNativeHandle");
|
||||
// getNativeHandle.setAccessible(true);
|
||||
// Object nativeHandle = getNativeHandle.invoke(platformWindow);
|
||||
// getNativeHandle.setAccessible(true);
|
||||
|
||||
var seamlessFrameApplied = false;
|
||||
stage.getScene()
|
||||
.getRoot()
|
||||
.pseudoClassStateChanged(PseudoClass.getPseudoClass("seamless-frame"), seamlessFrameApplied);
|
||||
stage.getScene()
|
||||
.getRoot()
|
||||
.pseudoClassStateChanged(PseudoClass.getPseudoClass("separate-frame"), !seamlessFrameApplied);
|
||||
|
||||
|
||||
// 显示窗口
|
||||
stage.show();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
// 启动 JavaFX 应用
|
||||
launch(args);
|
||||
}
|
||||
}
|
@ -214,22 +214,29 @@ public class DataPermissionPane extends JPanel {
|
||||
private void treeDataScopeDeptIds(DefaultMutableTreeNode treeNode, Set<Long> deptIdlist) {
|
||||
|
||||
|
||||
if (treeNode.getUserObject() instanceof DeptSimpleRespVO) {
|
||||
DeptSimpleRespVO deptSimpleRespVO = (DeptSimpleRespVO) treeNode.getUserObject();
|
||||
deptIdlist.add(deptSimpleRespVO.getId());
|
||||
}
|
||||
addDeptIdIfApplicable(treeNode, deptIdlist);
|
||||
|
||||
|
||||
// 处理子节点
|
||||
for (int i = 0; i < treeNode.getChildCount(); i++) {
|
||||
DefaultMutableTreeNode node = (DefaultMutableTreeNode) treeNode.getChildAt(i);
|
||||
if (node.getUserObject() instanceof DeptSimpleRespVO) {
|
||||
DeptSimpleRespVO deptSimpleRespVO = (DeptSimpleRespVO) node.getUserObject();
|
||||
deptIdlist.add(deptSimpleRespVO.getId());
|
||||
DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) treeNode.getChildAt(i);
|
||||
treeDataScopeDeptIds(childNode, deptIdlist);
|
||||
}
|
||||
treeDataScopeDeptIds(node,deptIdlist);
|
||||
|
||||
// 处理父节点
|
||||
while (treeNode.getParent() != null) {
|
||||
treeNode = (DefaultMutableTreeNode) treeNode.getParent();
|
||||
addDeptIdIfApplicable(treeNode, deptIdlist);
|
||||
}
|
||||
}
|
||||
|
||||
// 将添加菜单ID的逻辑提取成一个方法
|
||||
private void addDeptIdIfApplicable(DefaultMutableTreeNode treeNode, Set<Long> deptIdList) {
|
||||
if (treeNode.getUserObject() instanceof DeptSimpleRespVO) {
|
||||
DeptSimpleRespVO respVO = (DeptSimpleRespVO) treeNode.getUserObject();
|
||||
deptIdList.add(respVO.getId());
|
||||
}
|
||||
}
|
||||
|
||||
public void updateData(RoleRespVO roleRespVO) {
|
||||
|
||||
@ -258,11 +265,13 @@ public class DataPermissionPane extends JPanel {
|
||||
Map<Long, DefaultMutableTreeNode> nodeMap = new HashMap<>();
|
||||
nodeMap.put(0l, deptRoot); // Root node
|
||||
|
||||
List<TreePath> selTreePth = new ArrayList<>();
|
||||
List<DefaultMutableTreeNode> selNodes = new ArrayList<>();
|
||||
for (DeptSimpleRespVO simpleRespVO : deptResult.getData()) {
|
||||
DefaultMutableTreeNode node = new DefaultMutableTreeNode(simpleRespVO);
|
||||
nodeMap.put(simpleRespVO.getId(), node);
|
||||
|
||||
if (roleRespVO.getDataScopeDeptIds().contains(simpleRespVO.getId())) {
|
||||
selNodes.add(node);
|
||||
}
|
||||
}
|
||||
|
||||
deptResult.getData().forEach(deptSimpleRespVO -> {
|
||||
@ -271,15 +280,13 @@ public class DataPermissionPane extends JPanel {
|
||||
if (parentNode != null) {
|
||||
parentNode.add(childNode);
|
||||
}
|
||||
if (roleRespVO.getDataScopeDeptIds().contains(deptSimpleRespVO.getId())) {
|
||||
selTreePth.add(new TreePath(nodeMap.get(deptSimpleRespVO.getId()).getPath()));
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
resultMap.put("deptRoot", deptRoot);
|
||||
resultMap.put("selTreePth", selTreePth);
|
||||
resultMap.put("selNodes", selNodes);
|
||||
|
||||
return resultMap;
|
||||
}
|
||||
@ -289,10 +296,16 @@ public class DataPermissionPane extends JPanel {
|
||||
try {
|
||||
|
||||
deptTree.setModel(new DefaultTreeModel((TreeNode) get().get("deptRoot")));
|
||||
List<TreePath> selTreePth = (List<TreePath>) get().get("selTreePth");
|
||||
if (selTreePth != null) {
|
||||
deptTree.getCheckBoxTreeSelectionModel().setSelectionPaths(selTreePth.toArray(new TreePath[0]));
|
||||
List<DefaultMutableTreeNode> selNodes = (List<DefaultMutableTreeNode>) get().get("selNodes");
|
||||
if (selNodes != null) {
|
||||
for (DefaultMutableTreeNode node : selNodes) {
|
||||
if (node.isLeaf()) {
|
||||
deptTree.getCheckBoxTreeSelectionModel().addSelectionPath(new TreePath(node.getPath()));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
TreeUtils.expandAll(deptTree);
|
||||
TreeUtils.expandAll(deptTree);
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
|
@ -171,19 +171,26 @@ public class RoleAssignMenuPane extends JPanel {
|
||||
private void treeDataScopeDeptIds(DefaultMutableTreeNode treeNode, Set<Long> menuIdlist) {
|
||||
|
||||
|
||||
// 处理当前节点
|
||||
addMenuIdIfApplicable(treeNode, menuIdlist);
|
||||
|
||||
// 处理子节点
|
||||
for (int i = 0; i < treeNode.getChildCount(); i++) {
|
||||
DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) treeNode.getChildAt(i);
|
||||
treeDataScopeDeptIds(childNode, menuIdlist);
|
||||
}
|
||||
|
||||
// 处理父节点
|
||||
while (treeNode.getParent() != null) {
|
||||
treeNode = (DefaultMutableTreeNode) treeNode.getParent();
|
||||
addMenuIdIfApplicable(treeNode, menuIdlist);
|
||||
}
|
||||
}
|
||||
// 将添加菜单ID的逻辑提取成一个方法
|
||||
private void addMenuIdIfApplicable(DefaultMutableTreeNode treeNode, Set<Long> menuIdList) {
|
||||
if (treeNode.getUserObject() instanceof MenuSimpleRespVO) {
|
||||
MenuSimpleRespVO menuSimpleRespVO = (MenuSimpleRespVO) treeNode.getUserObject();
|
||||
menuIdlist.add(menuSimpleRespVO.getId());
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < treeNode.getChildCount(); i++) {
|
||||
DefaultMutableTreeNode node = (DefaultMutableTreeNode) treeNode.getChildAt(i);
|
||||
if (node.getUserObject() instanceof MenuSimpleRespVO) {
|
||||
MenuSimpleRespVO menuSimpleRespVO = (MenuSimpleRespVO) node.getUserObject();
|
||||
menuIdlist.add(menuSimpleRespVO.getId());
|
||||
}
|
||||
treeDataScopeDeptIds(node, menuIdlist);
|
||||
menuIdList.add(menuSimpleRespVO.getId());
|
||||
}
|
||||
}
|
||||
|
||||
@ -208,9 +215,7 @@ public class RoleAssignMenuPane extends JPanel {
|
||||
|
||||
java.util.List<DefaultMutableTreeNode> selNodes = new ArrayList<>();
|
||||
for (MenuSimpleRespVO simpleRespVO : menuResult.getData()) {
|
||||
if (simpleRespVO.getType() == 3) {
|
||||
continue;
|
||||
}
|
||||
|
||||
DefaultMutableTreeNode node = new DefaultMutableTreeNode(simpleRespVO);
|
||||
nodeMap.put(simpleRespVO.getId(), node);
|
||||
|
||||
@ -220,7 +225,6 @@ public class RoleAssignMenuPane extends JPanel {
|
||||
}
|
||||
|
||||
menuResult.getData().forEach(menuSimpleRespVO -> {
|
||||
if (menuSimpleRespVO.getType() != 3) {
|
||||
|
||||
|
||||
DefaultMutableTreeNode parentNode = nodeMap.get(menuSimpleRespVO.getParentId());
|
||||
@ -231,7 +235,7 @@ public class RoleAssignMenuPane extends JPanel {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
@ -249,7 +253,9 @@ public class RoleAssignMenuPane extends JPanel {
|
||||
java.util.List<DefaultMutableTreeNode> selNodes = (List<DefaultMutableTreeNode>) get().get("selNodes");
|
||||
if (selNodes != null) {
|
||||
for (DefaultMutableTreeNode node : selNodes) {
|
||||
if (node.isLeaf()) {
|
||||
menuTree.getCheckBoxTreeSelectionModel().addSelectionPath(new TreePath(node.getPath()));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user