protected void addPages() { editorPage = new RegistryInfoEditorPage( this, "org.wso2.developerstudio.eclipse.artifact.registry.handler.editor.design", "Design"); sourceEditor = new StructuredTextEditor(); sourceEditor.setEditorPart(this); try { editorPage.initContent(); formEditorIndex = addPage(editorPage); sourceEditorIndex = addPage(sourceEditor, getEditorInput()); setPageText(sourceEditorIndex, "Source"); getDocument() .addDocumentListener( new IDocumentListener() { public void documentAboutToBeChanged(final DocumentEvent event) { // nothing to do } public void documentChanged(final DocumentEvent event) { sourceDirty = true; updateDirtyState(); } }); } catch (Exception e) { log.error(e); } }
private void updateDesignFromSource() { try { editorPage.refreshContent(); } catch (Exception e) { e.printStackTrace(); } }
private void updateSourceFromDesign() { try { String source = editorPage.getSource(); getDocument().set(source); } catch (Exception e) { e.printStackTrace(); } }
public void doSave(IProgressMonitor monitor) { if ((getCurrentPage() == formEditorIndex) && (dirty)) { updateSourceFromDesign(); } else if ((getCurrentPage() == sourceEditorIndex) && (sourceDirty)) { updateDesignFromSource(); } sourceDirty = false; dirty = false; try { editorPage.save(); updateDirtyState(); } catch (Exception e) { e.printStackTrace(); } }
public void updateDirtyState() { dirty = editorPage.isDirty(); firePropertyChange(PROP_DIRTY); editorDirtyStateChanged(); }