analyseWriter/src/action/actCopy.java

48 lines
1.5 KiB
Java
Raw Normal View History

package action;
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-23 10:14:21 +02:00
Clipboard cb = Toolkit.getDefaultToolkit().getSystemClipboard();
String textNodes = Run.ecritureNode(nod, 0).toString().replace("\t","").replace("\r", "").replace("\n", "");
StringSelection texto = new StringSelection(textNodes);
cb.setContents(texto, null);
System.out.println(texto.toString());
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>");
}
}