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:
parent
9b292d46e3
commit
80e246ea09
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -31,8 +31,8 @@ public class MyTreeCellRenderer extends DefaultTreeCellRenderer {
|
|||||||
cellRenderer.setClosedIcon(new ImageIcon(create.class.getResource("/resources/treeClose.png")));
|
cellRenderer.setClosedIcon(new ImageIcon(create.class.getResource("/resources/treeClose.png")));
|
||||||
cellRenderer.setLeafIcon(new ImageIcon(create.class.getResource("/resources/treeLeaf.png")));
|
cellRenderer.setLeafIcon(new ImageIcon(create.class.getResource("/resources/treeLeaf.png")));
|
||||||
|
|
||||||
cellRenderer.setBackgroundNonSelectionColor(new Color(255, 255, 221));
|
cellRenderer.setBackgroundNonSelectionColor(new Color(255, 255, 255));
|
||||||
cellRenderer.setBackgroundSelectionColor(new Color(160, 160, 230));
|
cellRenderer.setBackgroundSelectionColor(new Color(171, 255, 243)); //160,160,230
|
||||||
cellRenderer.setBorderSelectionColor(Color.black);
|
cellRenderer.setBorderSelectionColor(Color.black);
|
||||||
cellRenderer.setTextSelectionColor(Color.white);
|
cellRenderer.setTextSelectionColor(Color.white);
|
||||||
cellRenderer.setTextNonSelectionColor(Color.blue);
|
cellRenderer.setTextNonSelectionColor(Color.blue);
|
||||||
@ -48,7 +48,7 @@ public class MyTreeCellRenderer extends DefaultTreeCellRenderer {
|
|||||||
|
|
||||||
if(data!=null) {
|
if(data!=null) {
|
||||||
if(data.isEvaluate()) {
|
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));
|
setFont(new Font("Tahoma", Font.BOLD, 14));
|
||||||
}else {
|
}else {
|
||||||
setForeground(new Color(0, 0 ,0));
|
setForeground(new Color(0, 0 ,0));
|
||||||
|
@ -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);
|
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) {
|
if(a == JOptionPane.YES_NO_OPTION) {
|
||||||
|
|
||||||
node nod = (node) fenetres.create.getSelectNode().getUserObject();
|
node nod = (node) fenetres.create.getSelectNode().getUserObject();
|
||||||
|
|
||||||
|
|
||||||
if(!nod.chemin().contains("setting")) {
|
if(!nod.chemin().contains("setting")) {
|
||||||
|
|
||||||
DefaultMutableTreeNode selectNode = fenetres.create.getSelectNode();
|
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);
|
nod.getParent().downNodeEnfant(nod);
|
||||||
|
|
||||||
DefaultMutableTreeNode SelectParentNode = (DefaultMutableTreeNode) selectNode.getParent();
|
DefaultTreeModel treeModel = (DefaultTreeModel) fenetres.create.getTree().getModel();
|
||||||
SelectParentNode.removeAllChildren();
|
treeModel.insertNodeInto(selectNode, selectParentNode, selectedNodeIndex+1);
|
||||||
SelectParentNode = addNodeMutable(nod.getParent(),SelectParentNode);
|
|
||||||
|
|
||||||
DefaultTreeModel model = (DefaultTreeModel) fenetres.create.getTree().getModel();
|
DefaultMutableTreeNode root = (DefaultMutableTreeNode) treeModel.getRoot();
|
||||||
DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
|
fenetres.create.setTree(treeModel);
|
||||||
model.reload(root);
|
treeModel.reload(root);
|
||||||
|
|
||||||
fenetres.create.getTree().setSelectionPath(path);
|
fenetres.create.getTree().setSelectionPath(path);
|
||||||
fenetres.create.getTree().expandPath(path);
|
fenetres.create.getTree().expandPath(path);
|
||||||
|
|
||||||
// fenetres.create.constructionTree();
|
}
|
||||||
|
|
||||||
}else {
|
}else {
|
||||||
JOptionPane.showMessageDialog(null,"Vous ne devez pas déplacer ce node !", "Oh non!!!", JOptionPane.INFORMATION_MESSAGE);
|
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) {
|
private static DefaultMutableTreeNode addNodeMutable(node nod, DefaultMutableTreeNode parent) {
|
||||||
if(nod!=null) {
|
if(nod!=null) {
|
||||||
DefaultMutableTreeNode node1 = null;
|
DefaultMutableTreeNode node1 = null;
|
||||||
|
@ -10,7 +10,6 @@ import javax.swing.JOptionPane;
|
|||||||
import javax.swing.KeyStroke;
|
import javax.swing.KeyStroke;
|
||||||
import javax.swing.tree.DefaultMutableTreeNode;
|
import javax.swing.tree.DefaultMutableTreeNode;
|
||||||
import javax.swing.tree.DefaultTreeModel;
|
import javax.swing.tree.DefaultTreeModel;
|
||||||
import javax.swing.tree.TreeNode;
|
|
||||||
import javax.swing.tree.TreePath;
|
import javax.swing.tree.TreePath;
|
||||||
|
|
||||||
import cXML.node;
|
import cXML.node;
|
||||||
@ -48,32 +47,17 @@ public class actUpNode extends AbstractAction{
|
|||||||
|
|
||||||
if(!nod.chemin().contains("setting")) {
|
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) {
|
if(selectedNodeIndex>0) {
|
||||||
nod.getParent().upNodeEnfant(nod);
|
nod.getParent().upNodeEnfant(nod);
|
||||||
|
|
||||||
DefaultTreeModel treeModel = (DefaultTreeModel) fenetres.create.getTree().getModel();
|
DefaultTreeModel treeModel = (DefaultTreeModel) fenetres.create.getTree().getModel();
|
||||||
treeModel.insertNodeInto(selectNode, selectParentNode, selectedNodeIndex-1);
|
treeModel.insertNodeInto(selectNode, selectParentNode, selectedNodeIndex-1);
|
||||||
treeModel.reload();
|
|
||||||
DefaultMutableTreeNode root = (DefaultMutableTreeNode) treeModel.getRoot();
|
DefaultMutableTreeNode root = (DefaultMutableTreeNode) treeModel.getRoot();
|
||||||
// path = (TreePath) selectParentNode.getChildAt(selectedNodeIndex-1);
|
|
||||||
System.out.println(path.toString());
|
|
||||||
fenetres.create.setTree(treeModel);
|
fenetres.create.setTree(treeModel);
|
||||||
treeModel.reload(root);
|
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().setSelectionPath(path);
|
||||||
fenetres.create.getTree().expandPath(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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user