Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Rich Client Platform (RCP) » Integrate XML Editor
Integrate XML Editor [message #518235] Wed, 03 March 2010 14:57 Go to next message
mohamed  is currently offline mohamed Friend
Messages: 2
Registered: March 2010
Junior Member
Hello,

Please how can i use rcp xml editor in my rcp?
How can i open an xml file with the editor
Regards

[Updated on: Wed, 03 March 2010 14:58]

Report message to a moderator

Re: Integrate XML Editor [message #523430 is a reply to message #518235] Fri, 26 March 2010 13:27 Go to previous message
Zied is currently offline ZiedFriend
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

Previous Topic:Embed native app
Next Topic:customise the content of the OutlineView
Goto Forum:
  


Current Time: Fri Apr 26 14:17:06 GMT 2024

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

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

Back to the top