|
Re: Integrate XML Editor [message #523430 is a reply to message #518235] |
Fri, 26 March 2010 13:27 |
Zied Messages: 26 Registered: February 2010 |
Junior Member |
|
|
Hi mohamed,
to integrate eclipse's default xml Editor in your RCP application you should
extend a new Class from XMLMultipageEditorPart and override the createPage method to add new pages.
it 's simple.
Example:
@SuppressWarnings("restriction")
public class PersFlowChartEditor extends XMLMultiPageEditorPart implements
IResourceChangeListener {
/** The text editor used in page 0. */
private FlowchartDiagramEditor editor = new FlowchartDiagramEditor();
public PersFlowChartEditor() {
super();
}
@Override
protected void createPages() {
super.createPages();
createDiagramPage();
}
public void createDiagramPage(){
File file = new File("D:/PFE_WORKSPACE/FlowChart.diagram/wrkspc/hkl/defaultx.flowchart_diagram");
IFile iFile = null;
if (file.exists() && file.isFile() ) {
IWorkspace workspace= ResourcesPlugin.getWorkspace();
IPath location= Path.fromOSString(file.getAbsolutePath());
iFile= workspace.getRoot().getFileForLocation(location);
} else {
//Do something if the file does not exist
}
IEditorInput editorInput = new FileEditorInput(iFile);
try {
int index = addPage(editor, editorInput);
setPageText(index, "Diagram Editor");
//setActivePage(2);
} catch (PartInitException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public void doSave(IProgressMonitor monitor) {
// TODO Auto-generated method stub
super.doSave(monitor);
//save the opened diagram file
editor.doSave(monitor);
// ici il faut aussi sauvgarder le fichier xml
}
@Override
public boolean isSaveOnCloseNeeded() {
// TODO Auto-generated method stub
System.out.println("exit the editor");
return super.isSaveOnCloseNeeded() || editor.isSaveOnCloseNeeded();
}
@Override
public void resourceChanged(IResourceChangeEvent event) {
// TODO Auto-generated method stub
}
}
[Updated on: Fri, 26 March 2010 14:22] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.03315 seconds