2023-02-05 17:46:02 +01:00
|
|
|
package action;
|
2022-06-22 16:15:17 +02:00
|
|
|
|
|
|
|
import java.awt.Toolkit;
|
|
|
|
import java.awt.datatransfer.Clipboard;
|
|
|
|
import java.awt.datatransfer.StringSelection;
|
|
|
|
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.KeyStroke;
|
|
|
|
|
|
|
|
import cXML.Run;
|
|
|
|
import cXML.node;
|
|
|
|
import fenetres.baliseStyle;
|
|
|
|
|
|
|
|
public class actCopy extends AbstractAction{
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
{
|
|
|
|
putValue( Action.NAME, "Copier" );
|
|
|
|
putValue( Action.SMALL_ICON, new ImageIcon( getClass().getResource("/copy.png") ) );
|
|
|
|
putValue( Action.SHORT_DESCRIPTION, "Copier (CTRL+C)" );
|
|
|
|
putValue( Action.ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.CTRL_DOWN_MASK ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void actionPerformed(ActionEvent e) {
|
2022-06-23 10:14:21 +02:00
|
|
|
node nod = (node) fenetres.create.getSelectNode().getUserObject();
|
2022-06-22 16:15:17 +02:00
|
|
|
|
2022-06-23 10:14:21 +02:00
|
|
|
Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
|
|
|
|
|
2022-11-20 18:03:14 +01:00
|
|
|
String textNodes = Run.ecritureNode(nod, 0).toString().replace("\t","").replace("\r", "").replace("\n", "");
|
|
|
|
StringSelection texto = new StringSelection(textNodes);
|
2022-06-22 16:15:17 +02:00
|
|
|
|
2022-11-20 18:03:14 +01:00
|
|
|
cb.setContents(texto, null);
|
|
|
|
|
|
|
|
System.out.println(texto.toString());
|
2022-06-22 16:15:17 +02:00
|
|
|
|
2022-06-23 10:14:21 +02:00
|
|
|
fenetres.create.getTextNodeSelect().setText(baliseStyle.balise()+"<hr><h2>Le node est copié dans le presse papier.</h2><hr>");
|
2022-06-22 16:15:17 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|