あなたの仕事を行うのに十分なヒントを与えるべきである、このスニペットを試してみてください。
try {
IEditorPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (part instanceof ITextEditor) {
final ITextEditor editor = (ITextEditor)part;
IDocumentProvider prov = editor.getDocumentProvider();
IDocument doc = prov.getDocument(editor.getEditorInput());
ISelection sel = editor.getSelectionProvider().getSelection();
if (sel instanceof TextSelection) {
final TextSelection textSel = (TextSelection)sel;
String newText = "/*" + textSel.getText() + "*/";
doc.replace(textSel.getOffset(), textSel.getLength(), newText);
}
}
} catch (Exception ex) {
ex.printStackTrace();
}