MAJ (V4.3.1 Amélioration de l'affichage de l'arbre durant le Up et les

Down des nodes)
This commit is contained in:
pablo rodriguez 2022-11-30 21:18:53 +01:00
parent 9b292d46e3
commit 80e246ea09
8 changed files with 28 additions and 60 deletions

Binary file not shown.

Binary file not shown.

View File

@ -31,8 +31,8 @@ public class MyTreeCellRenderer extends DefaultTreeCellRenderer {
cellRenderer.setClosedIcon(new ImageIcon(create.class.getResource("/resources/treeClose.png")));
cellRenderer.setLeafIcon(new ImageIcon(create.class.getResource("/resources/treeLeaf.png")));
cellRenderer.setBackgroundNonSelectionColor(new Color(255, 255, 221));
cellRenderer.setBackgroundSelectionColor(new Color(160, 160, 230));
cellRenderer.setBackgroundNonSelectionColor(new Color(255, 255, 255));
cellRenderer.setBackgroundSelectionColor(new Color(171, 255, 243)); //160,160,230
cellRenderer.setBorderSelectionColor(Color.black);
cellRenderer.setTextSelectionColor(Color.white);
cellRenderer.setTextNonSelectionColor(Color.blue);
@ -48,7 +48,7 @@ public class MyTreeCellRenderer extends DefaultTreeCellRenderer {
if(data!=null) {
if(data.isEvaluate()) {
setForeground(new Color(230, 20 ,30));
setForeground(new Color(0, 105 ,5)); //230,20,30
setFont(new Font("Tahoma", Font.BOLD, 14));
}else {
setForeground(new Color(0, 0 ,0));

View File

@ -33,28 +33,31 @@ public class actDownNode extends AbstractAction{
int a = JOptionPane.showConfirmDialog(null,"Voulez-vous descendre le node " + fenetres.create.getSelectNode().toString() + "?", "Sélectionner un choix", JOptionPane.YES_NO_OPTION);
if(a == JOptionPane.YES_NO_OPTION) {
node nod = (node) fenetres.create.getSelectNode().getUserObject();
if(!nod.chemin().contains("setting")) {
DefaultMutableTreeNode selectNode = fenetres.create.getSelectNode();
TreePath path = fenetres.create.getTree().getSelectionPath().getParentPath();
DefaultMutableTreeNode selectParentNode = (DefaultMutableTreeNode) selectNode.getParent();
int selectedNodeIndex = selectNode.getParent().getIndex(selectNode);
int count = selectNode.getParent().getChildCount();
if(selectedNodeIndex<count-1) {
TreePath path = fenetres.create.getTree().getSelectionPath();
nod.getParent().downNodeEnfant(nod);
DefaultMutableTreeNode SelectParentNode = (DefaultMutableTreeNode) selectNode.getParent();
SelectParentNode.removeAllChildren();
SelectParentNode = addNodeMutable(nod.getParent(),SelectParentNode);
DefaultTreeModel treeModel = (DefaultTreeModel) fenetres.create.getTree().getModel();
treeModel.insertNodeInto(selectNode, selectParentNode, selectedNodeIndex+1);
DefaultTreeModel model = (DefaultTreeModel) fenetres.create.getTree().getModel();
DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
model.reload(root);
DefaultMutableTreeNode root = (DefaultMutableTreeNode) treeModel.getRoot();
fenetres.create.setTree(treeModel);
treeModel.reload(root);
fenetres.create.getTree().setSelectionPath(path);
fenetres.create.getTree().expandPath(path);
// fenetres.create.constructionTree();
}
}else {
JOptionPane.showMessageDialog(null,"Vous ne devez pas déplacer ce node !", "Oh non!!!", JOptionPane.INFORMATION_MESSAGE);
}
@ -62,6 +65,7 @@ public class actDownNode extends AbstractAction{
}
}
@SuppressWarnings("unused")
private static DefaultMutableTreeNode addNodeMutable(node nod, DefaultMutableTreeNode parent) {
if(nod!=null) {
DefaultMutableTreeNode node1 = null;

View File

@ -10,7 +10,6 @@ import javax.swing.JOptionPane;
import javax.swing.KeyStroke;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import cXML.node;
@ -48,32 +47,17 @@ public class actUpNode extends AbstractAction{
if(!nod.chemin().contains("setting")) {
TreePath path = fenetres.create.getTree().getSelectionPath().getParentPath();
// TreePath path = fenetres.create.getTree().getSelectionPath();
TreePath path = fenetres.create.getTree().getSelectionPath();
if(selectedNodeIndex>0) {
nod.getParent().upNodeEnfant(nod);
DefaultTreeModel treeModel = (DefaultTreeModel) fenetres.create.getTree().getModel();
treeModel.insertNodeInto(selectNode, selectParentNode, selectedNodeIndex-1);
treeModel.reload();
DefaultMutableTreeNode root = (DefaultMutableTreeNode) treeModel.getRoot();
// path = (TreePath) selectParentNode.getChildAt(selectedNodeIndex-1);
System.out.println(path.toString());
fenetres.create.setTree(treeModel);
treeModel.reload(root);
fenetres.create.getTree().repaint();
// DefaultMutableTreeNode SelectParentNode = (DefaultMutableTreeNode) selectNode.getParent();
// SelectParentNode.removeAllChildren();
// SelectParentNode = addNodeMutable(nod.getParent(),SelectParentNode);
//
//
// DefaultTreeModel model = (DefaultTreeModel) fenetres.create.getTree().getModel();
// DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
// model.reload(root);
//// path= (TreePath) SelectParentNode.getFirstChild();
// model.reload(root);
fenetres.create.getTree().setSelectionPath(path);
fenetres.create.getTree().expandPath(path);
@ -87,24 +71,4 @@ public class actUpNode extends AbstractAction{
}
}
private TreePath TreePath(TreeNode childAt) {
// TODO Auto-generated method stub
return null;
}
private static DefaultMutableTreeNode addNodeMutable(node nod, DefaultMutableTreeNode parent) {
if(nod!=null) {
DefaultMutableTreeNode node1 = null;
for(int i = 0 ; i < nod.getNodes().size(); i++) {
if(!nod.getNodes().get(i).getNomElt().equals("setting")) {
node1 = new DefaultMutableTreeNode(nod.getNodes().get(i));
addNodeMutable(nod.getNodes().get(i), node1);
parent.add(node1);
}
}
}
return parent;
}
}