Advertisement
KosIvantsov

replace_with_source_no_tags.groovy

Jun 26th, 2013
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Groovy 0.66 KB | None | 0 0
  1. /*
  2.  * #Purpose: Replace current target with tag-free source
  3.  * #Details: http: // wp.me/p3fHEs-4W
  4.  *
  5.  * @author   Kos Ivantsov
  6.  * @date     2013-06-26
  7.  * @version  0.1
  8.  */
  9.  
  10. import static javax.swing.JOptionPane.*
  11. import static org.omegat.util.Platform.*
  12.  
  13. // abort if a project is not opened yet
  14. def prop = project.projectProperties
  15. if (!prop) {
  16.   final def title = 'Replace with Source (no tags)'
  17.   final def msg   = 'Please try again after you open a project.'
  18.   showMessageDialog null, msg, title, INFORMATION_MESSAGE
  19.   return
  20. }
  21.  
  22. def stext = editor.currentEntry.getSrcText().replaceAll(/<\/?[a-z]+[0-9]* ?\/?>/, '')
  23. editor.replaceEditText(stext)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement