Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Web Tools Project (WTP) » Open web page programmatically
Open web page programmatically [message #1220759] Fri, 13 December 2013 12:46 Go to next message
no name no name is currently offline no name no name
Messages: 28
Registered: February 2012
Junior Member
Hi All,

Is there any way to open web page editor through code/program by providing appropriate html file path
I want to open some html files in web page editor for my plugin view on click of an action.

Also need to open css editor too programmatically.
Kindly replay asap

Any help would be really appreciable Smile
Re: Open web page programmatically [message #1220825 is a reply to message #1220759] Fri, 13 December 2013 21:37 Go to previous messageGo to next message
Nick Sandonato is currently offline Nick Sandonato
Messages: 126
Registered: July 2009
Senior Member
Hi,

I think you'll want to use the method
IDE.openEditor(IWorkbenchPage page, IFile input, String editorId)
The editorId for the Web Page Editor is org.eclipse.jst.pagedesigner.PageDesignerEditor. The editorId for the CSS editor is org.eclipse.wst.css.core.csssource.source.

But since the CSS editor is already the default for CSS files, to simplify things, you can just use
IDE.openEditor(IWorkbenchPage, IFile input)
Re: Open web page programmatically [message #1220906 is a reply to message #1220825] Mon, 16 December 2013 04:25 Go to previous messageGo to next message
no name no name is currently offline no name no name
Messages: 28
Registered: February 2012
Junior Member
Thanks for replying so soon


What if my html files are not in workspace?
In that case the above method is not at all useful.

Kindly help to open WTP editor for those html files which are stored as FILESTORE
not IFile of some project..

Thanks Smile





Re: Open web page programmatically [message #1220910 is a reply to message #1220825] Mon, 16 December 2013 05:36 Go to previous messageGo to next message
no name no name is currently offline no name no name
Messages: 28
Registered: February 2012
Junior Member
Hi once again.

I tried to open WTP editor using below code

IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
IProject project = root.getProject("Project");
IFolder folder = project.getFolder("src");
IFile file = folder.getFile("AllWidgets.htm");
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();

try {
IDE.openEditor( page, file, "org.eclipse.jst.pagedesigner.PageDesignerEditor");
} catch ( PartInitException e ) {
}


But is it giving me exception .
Attached exception log

Thanks Smile



  • Attachment: Log.txt
    (Size: 13.50KB, Downloaded 71 times)
Re: Open web page programmatically [message #1220998 is a reply to message #1220906] Mon, 16 December 2013 15:25 Go to previous messageGo to next message
Nick Sandonato is currently offline Nick Sandonato
Messages: 126
Registered: July 2009
Senior Member
To open a file outside of the workspace you can use
IDE.openEditor(IWorkbenchPage page, URI uri, String editorId, boolean activate)

where uri is the URI of the filesystem location of the resource you want to open.

Do you have the stacktrace for what caused the PartInitException? That IllegalArgumentException just seems to be a side effect of the PartInitException.
Re: Open web page programmatically [message #1221190 is a reply to message #1220998] Tue, 17 December 2013 04:35 Go to previous message
no name no name is currently offline no name no name
Messages: 28
Registered: February 2012
Junior Member
Hi thanks for response,


I tried to catch exception in catch block and tried to get stacktrace
after debugging i tried to see the exception log,, but it seems catch block in my piece of code is not getting executed.

Please tell me if i have done something wrong to catch exception..

Thanks
Smile
Previous Topic:How to extends Servers View
Next Topic:Cannot start up web server(s) from eclipse
Goto Forum:
  


Current Time: Thu Oct 23 13:47:27 GMT 2014

Powered by FUDForum. Page generated in 0.13614 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software