MAJ (4.3.1 amélioration dans les copier, coller, déplacement yp et down

dans l'arbre)
This commit is contained in:
pablo rodriguez 2022-11-22 22:17:32 +01:00
parent cf5010dc22
commit f250c4ec7f
26 changed files with 137 additions and 31 deletions

View File

@ -14,6 +14,6 @@
<classpathentry kind="lib" path="C:/Users/pabr6/eclipse-workspace/zip4j-1.2.7.jar"/>
<classpathentry kind="lib" path="C:/Users/pabr6/git/analyseWriter/MEPTL/miglayout15-swing.jar"/>
<classpathentry kind="lib" path="jgoodies-forms-1.8.0.jar" sourcepath="jgoodies-forms-1.8.0-sources.jar"/>
<classpathentry kind="lib" path="C:/Users/pabr6/eclipse-workspace/cXML.jar"/>
<classpathentry kind="lib" path="C:/Users/pabr6/eclipse-workspace/cXML.jar" sourcepath="/cXML"/>
<classpathentry kind="output" path="bin"/>
</classpath>

1
bin/.gitignore vendored
View File

@ -4,3 +4,4 @@
/ou.png
/oumini.png
/resources/
/OU.svg

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -113,6 +113,8 @@ import list.listeRechercheParAnchorPageNumber;
import javax.swing.JToggleButton;
import java.awt.GridLayout;
import java.awt.event.ActionListener;
import javax.swing.JMenuItem;
import java.awt.event.InputEvent;
@ -614,14 +616,19 @@ public final class create extends JFrame {
//Menu arbre
JMenu mnManageTree = new JMenu("Arbre");
mnManageTree.add(new actUpNode());
mnManageTree.add(new actDownNode());
JMenuItem menuItem = mnManageTree.add(new actUpNode());
menuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_U, InputEvent.SHIFT_DOWN_MASK));
JMenuItem menuItem_2 = mnManageTree.add(new actDownNode());
menuItem_2.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.SHIFT_DOWN_MASK));
mnManageTree.addSeparator();
mnManageTree.add(new actExpandAll());
mnManageTree.add(new actExpandNode());
mnManageTree.addSeparator();
mnManageTree.add(new actCollapseAll());
mnManageTree.add(new actCollapseNode());
mnManageTree.addSeparator();
JMenuItem menuItem_1 = mnManageTree.add(new actDeleteNode());
menuItem_1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_D, InputEvent.CTRL_DOWN_MASK));
mnNode.add(mnManageTree);
mnNode.addSeparator();

View File

@ -1,11 +1,16 @@
package fenetres.create_act;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.KeyStroke;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import cXML.node;
import fenetres.create;
@ -20,6 +25,7 @@ public class actDeleteNode extends AbstractAction{
putValue( Action.NAME, "Supprime" );
putValue( Action.SMALL_ICON, new ImageIcon(create.class.getResource("/resources/supprimemini.png")) );
putValue( Action.SHORT_DESCRIPTION, "Supprime" );
putValue( Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_D, KeyEvent.CTRL_DOWN_MASK ) );
}
@Override
public void actionPerformed(ActionEvent e) {
@ -34,7 +40,21 @@ public class actDeleteNode extends AbstractAction{
||nod.getNomElt().equals("plagiarism")||nod.getNomElt().equals("text:similarity")||nod.getNomElt().equals("color") ||nod.getNomElt().equals("translation") )) {
nod.getParent().supprimeNodeEnfant(nod);
fenetres.create.constructionTree();
TreePath path = fenetres.create.getTree().getSelectionPath().getParentPath();
DefaultMutableTreeNode nodMu = fenetres.create.getSelectNode();
DefaultMutableTreeNode SelectParentNode = (DefaultMutableTreeNode) nodMu.getParent();
SelectParentNode.remove(nodMu);
DefaultTreeModel model = (DefaultTreeModel) fenetres.create.getTree().getModel();
DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
model.reload(root);
fenetres.create.getTree().setSelectionPath(path);
fenetres.create.getTree().expandPath(path);
// fenetres.create.constructionTree();
}else {
JOptionPane.showMessageDialog(null,"Vous ne devez pas supprimer ce node !", "Oh non!!!", JOptionPane.INFORMATION_MESSAGE);

View File

@ -1,11 +1,16 @@
package fenetres.create_act;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.KeyStroke;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import cXML.node;
import fenetres.create;
@ -19,7 +24,8 @@ public class actDownNode extends AbstractAction{
{
putValue( Action.NAME, "Descendre le node" );
putValue( Action.SMALL_ICON, new ImageIcon(create.class.getResource("/resources/downnodemini.png")) );
putValue( Action.SHORT_DESCRIPTION, "Descendre le node" );
putValue( Action.SHORT_DESCRIPTION, "Descendre le node (Shift + D)" );
putValue( Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_D, KeyEvent.SHIFT_DOWN_MASK) );
}
@Override
public void actionPerformed(ActionEvent e) {
@ -27,15 +33,48 @@ 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();
node nod = (node) fenetres.create.getSelectNode().getUserObject();
if(!nod.chemin().contains("setting")) {
DefaultMutableTreeNode selectNode = fenetres.create.getSelectNode();
TreePath path = fenetres.create.getTree().getSelectionPath().getParentPath();
nod.getParent().downNodeEnfant(nod);
fenetres.create.constructionTree();
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);
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);
}
}
}
}
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;
}
}

View File

@ -31,6 +31,8 @@ public class actOu extends AbstractAction{
nodeOu.setNomElt("OU");
nod.getNodes().add(nodeOu);
nodeOu.setParent(nod);
DefaultMutableTreeNode node1 = new DefaultMutableTreeNode(nodeOu);
nodMu.add(node1);

View File

@ -46,26 +46,24 @@ public class actPaste extends AbstractAction{
node nodCopy =new node(paste);
if(!nodCopy.getNomElt().isEmpty()) {
TreePath path = fenetres.create.getTree().getSelectionPath();
TreePath path = fenetres.create.getTree().getSelectionPath();
node nod = (node) fenetres.create.getSelectNode().getUserObject();
DefaultMutableTreeNode nodeMu = fenetres.create.getSelectNode();
node nod = (node) fenetres.create.getSelectNode().getUserObject();
DefaultMutableTreeNode nodeMu = fenetres.create.getSelectNode();
nod.getNodes().add(nodCopy);
DefaultMutableTreeNode node1 = new DefaultMutableTreeNode(nodCopy);
nodeMu.add(node1);
nod.getNodes().add(nodCopy);
DefaultMutableTreeNode node1 = new DefaultMutableTreeNode(nodCopy);
nodeMu.add(node1);
nodeMu = addNodeMutable(nodCopy,node1);
nodeMu = addNodeMutable(nodCopy,node1);
DefaultTreeModel model = (DefaultTreeModel) fenetres.create.getTree().getModel();
DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
model.reload(root);
DefaultTreeModel model = (DefaultTreeModel) fenetres.create.getTree().getModel();
DefaultMutableTreeNode root = (DefaultMutableTreeNode) model.getRoot();
model.reload(root);
// fenetres.create.constructionTree();
fenetres.create.getTree().setSelectionPath(path);
fenetres.create.getTree().expandPath(path);
fenetres.create.getTree().setSelectionPath(path);
fenetres.create.getTree().expandPath(path);
// initial = paste;
}else {
JOptionPane.showMessageDialog(null, "Le collage n'est pas réalisé.");
}

View File

@ -1,12 +1,16 @@
package fenetres.create_act;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.KeyStroke;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;
import cXML.node;
import fenetres.create;
@ -20,25 +24,60 @@ public class actUpNode extends AbstractAction{
{
putValue( Action.NAME, "Monter le node" );
putValue( Action.SMALL_ICON, new ImageIcon(create.class.getResource("/resources/upnodemini.png")) );
putValue( Action.SHORT_DESCRIPTION, "Monter le node" );
putValue( Action.SHORT_DESCRIPTION, "Monter le node (CTRL+SHIFT+C)" );
putValue( Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_U, KeyEvent.SHIFT_DOWN_MASK) );
}
@Override
public void actionPerformed(ActionEvent e) {
if(fenetres.create.getTree().getSelectionPath()!=null) {
DefaultMutableTreeNode selectNode = (DefaultMutableTreeNode) fenetres.create.getTree().getSelectionPath().getLastPathComponent();
// DefaultMutableTreeNode selectNode = (DefaultMutableTreeNode) fenetres.create.getTree().getSelectionPath().getLastPathComponent();
int a = JOptionPane.showConfirmDialog(null,"Voulez-vous monter le node " + selectNode.toString() + "?", "Sélectionner un choix", JOptionPane.YES_NO_OPTION);
node nod = (node) fenetres.create.getSelectNode().getUserObject();
DefaultMutableTreeNode selectNode = fenetres.create.getSelectNode();
int a = JOptionPane.showConfirmDialog(null,"Voulez-vous monter le node " + selectNode.toString()+ "?", "Sélectionner un choix", JOptionPane.YES_NO_OPTION);
if(a == JOptionPane.YES_NO_OPTION) {
node nod = (node) selectNode.getUserObject();
if(!nod.chemin().contains("setting")) {
nod.getParent().upNodeEnfant(nod);
fenetres.create.constructionTree();
}else {
JOptionPane.showMessageDialog(null,"Vous ne devez pas déplacer ce node !", "Oh non!!!", JOptionPane.INFORMATION_MESSAGE);
}
if(!nod.chemin().contains("setting")) {
TreePath path = fenetres.create.getTree().getSelectionPath().getParentPath();
nod.getParent().upNodeEnfant(nod);
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);
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);
}
}
}
}
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;
}
}