Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-ui-dev] Write into an opened file


The Eclipse Corner newgroup is a more appropriate forum for these types of 
This mailing list is intended for discussions on the design and 
development of Eclipse UI, rather than questions on how to use it or its 

However (just this once ;-)):

        IWorkbenchWindow window = ...;
        IWorkbenchPage page = window.getActivePage();
        if (page != null) {
                IEditorPart editor = page.getActiveEditor();
                if (editor instanceof ITextEditor) {
                        ITextEditor textEditor = (ITextEditor) editor;
                        IDocument document = 
                        document.replace(document.getLength(), 0, "Text to 

If you want the current selection range, use:
        ITextSelection sel = (ITextSelection) 


"N V S Rama Krishna" <ram_kri@xxxxxxxxx>
Sent by: platform-ui-dev-admin@xxxxxxxxxxx
12/01/01 04:04 AM
Please respond to platform-ui-dev

        To:     <platform-ui-dev@xxxxxxxxxxx>
        Subject:        [platform-ui-dev] Write into an opened file

  I would like to know the way one can modify the opened file in response 
to an action in the Workbench UI (say my custom menu's action). Let me be 
more clear :
        Say I created my Menu, call it MyMenu with 2 menu-items m1 and m2. 
Now i click on m1 or m2  I want to push some custom-code into the opened 
JSP file. So, how do I write into an already opened JSP file as an action 
of clicking on the menu....
        I am getting the class invoked as a result of the click but the 
problem is not able to write into the file..say some hard-coded string. 
        Thanks in advance.

Back to the top