use of org.eclipse.wst.sse.ui.StructuredTextEditor in project tmdm-studio-se by Talend.
the class XSDEditor method doSave.
@Override
public void doSave(IProgressMonitor monitor) {
XSDDirectivesManager.removeUnusedXSDImports(getXSDSchema());
structuredTextEditor.doSave(monitor);
InputStream stream = null;
try {
EditorPart part = (EditorPart) getSelectedPage();
String xsd = null;
if (null != part) {
if (part instanceof StructuredTextEditor) {
xsd = ((StructuredTextEditor) part).getTextViewer().getDocument().get();
} else {
// main page or er editor
DataModelMainPage dmp = getdMainPage();
xsd = dmp.getXSDSchemaString();
}
}
if (null != xsd) {
DataModelMainPage mainPage = getdMainPage();
WSDataModel wsDataModel = (WSDataModel) xobject.getWsObject();
wsDataModel.setXsdSchema(xsd);
if (mainPage != null) {
mainPage.save(xsd);
}
// $NON-NLS-1$
fileContents = xsd.getBytes("utf-8");
}
getDataModelEditorPage().setDirty(false);
} catch (Exception e) {
log.error(e.getMessage(), e);
} finally {
IOUtils.closeQuietly(stream);
if (null != monitor) {
monitor.done();
}
}
}
use of org.eclipse.wst.sse.ui.StructuredTextEditor in project tmdm-studio-se by Talend.
the class XSDEditor method createSourcePage.
protected void createSourcePage() {
this.structuredTextEditor = new StructuredTextEditor() {
@Override
public boolean isEditable() {
if (isReadOnly()) {
return false;
}
return super.isEditable();
}
};
try {
int index = addPage(this.structuredTextEditor, getEditorInput());
setPageText(index, org.eclipse.wst.xsd.ui.internal.adt.editor.Messages._UI_LABEL_SOURCE);
this.structuredTextEditor.update();
this.structuredTextEditor.setEditorPart(this);
this.structuredTextEditor.addPropertyListener(this);
/*
* **please don't remove this annotation util the problem is really resolve.
*
* Here add a property listener to source editor to achieve a effect that when source editor is modified by
* user, notify the model editor that it should be in dirty state.
*
* this is not a perfect resolution of issue TMDM-6403, because we have not find the real reason that lead
* to that result. the more detailed thing is the variable 'fSynchronizationStamp' in class
* 'ResourceTextFileBuffer' is updated in some place and this variable finally affect the variable
* 'fCanBeSaved' (see documentChanged method of the inner class DocumentListener)which indicated the source
* editor's dirty state, so affect combined editor's dirty state,then affect the combined editor's property
* listener's execution, then lead to the editor's save and model validation.
*/
firePropertyChange(1);
} catch (PartInitException e) {
ErrorDialog.openError(getSite().getShell(), Messages.XSDEditor_ErrorMessage, null, e.getStatus());
}
}
use of org.eclipse.wst.sse.ui.StructuredTextEditor in project liferay-ide by liferay.
the class LayoutTplEditor method createEditorPages.
@Override
protected void createEditorPages() throws PartInitException {
_sourcePage = new StructuredTextEditor();
_sourcePage.setEditorPart(this);
addPage(_SOURCE_PAGE_INDEX, _sourcePage, getEditorInput());
setPageText(_SOURCE_PAGE_INDEX, _SOURCE_PAGE_TITLE);
initSourceModel();
addDeferredPage(1, _PREVIEW_PAGE_TITLE, "preview");
addDeferredPage(2, _DESIGN_PAGE_TITLE, "designPage");
}
use of org.eclipse.wst.sse.ui.StructuredTextEditor in project liferay-ide by liferay.
the class UITestsUtils method getEditor.
public static StructuredTextEditor getEditor(IFile file) {
StructuredTextEditor editor = (StructuredTextEditor) fileToEditorMap.get(file);
if (editor == null) {
try {
final IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
final IWorkbenchPage page = workbenchWindow.getActivePage();
final IEditorPart editorPart = IDE.openEditor(page, file, true, true);
assertNotNull(editorPart);
if (editorPart instanceof SapphireEditorForXml) {
editor = ((SapphireEditorForXml) editorPart).getXmlEditor();
} else if (editorPart instanceof StructuredTextEditor) {
editor = ((StructuredTextEditor) editorPart);
} else if (editorPart instanceof XMLMultiPageEditorPart) {
XMLMultiPageEditorPart xmlEditorPart = (XMLMultiPageEditorPart) editorPart;
editor = (StructuredTextEditor) xmlEditorPart.getAdapter(StructuredTextEditor.class);
}
assertNotNull(editor);
standardizeLineEndings(editor);
fileToEditorMap.put(file, editor);
} catch (Exception e) {
fail("Could not open editor for " + file + " exception: " + e.getMessage());
}
}
return editor;
}
use of org.eclipse.wst.sse.ui.StructuredTextEditor in project liferay-ide by liferay.
the class UITestsUtils method getSourceViewerConfiguraionFromOpenedEditor.
// open the editor and get the actual SourceViewerConfiguration
public static SourceViewerConfiguration getSourceViewerConfiguraionFromOpenedEditor(IFile file) throws Exception {
StructuredTextEditor editor = getEditor(file);
Method getConfMethod = ReflectionUtil.getDeclaredMethod(editor.getClass(), "getSourceViewerConfiguration", true);
if (getConfMethod != null) {
getConfMethod.setAccessible(true);
Object obj = getConfMethod.invoke(editor);
if (obj != null && obj instanceof SourceViewerConfiguration) {
return (SourceViewerConfiguration) obj;
}
}
return null;
}
Aggregations