use of com.amalto.workbench.editors.DataModelMainPage in project tmdm-studio-se by Talend.
the class AnnotationOrderedListsDialog method getConceptElements.
private List<String> getConceptElements() {
DataModelMainPage page = parentPage;
IStructuredSelection selection = (IStructuredSelection) page.getTreeViewer().getSelection();
List<String> childNames = new ArrayList<String>();
XSDElementDeclaration decl = null;
if (selection.getFirstElement() instanceof XSDElementDeclaration) {
decl = (XSDElementDeclaration) selection.getFirstElement();
// childNames = Util.getChildElementNames(decl.getElement());
} else if (selection.getFirstElement() instanceof Element) {
TreePath tPath = ((TreeSelection) selection).getPaths()[0];
XSDComponent xSDCom = null;
for (int i = 0; i < tPath.getSegmentCount(); i++) {
if (tPath.getSegment(i) instanceof XSDAnnotation) {
xSDCom = (XSDAnnotation) (tPath.getSegment(i));
break;
}
}
decl = (XSDElementDeclaration) xSDCom.getContainer();
}
try {
childNames = Util.getChildElementNames(decl.getName(), decl);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
return childNames;
}
use of com.amalto.workbench.editors.DataModelMainPage in project tmdm-studio-se by Talend.
the class ComplexTypeWrapper method changeTypeName.
public boolean changeTypeName() {
if (curXSDComplexType.getName().equals(newTypeName))
return false;
curXSDComplexType.setName(newTypeName);
curXSDComplexType.updateElement();
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorPart activeEditor = activePage.getActiveEditor();
if (activeEditor instanceof XSDEditor) {
XSDEditor editor = (XSDEditor) activeEditor;
DataModelMainPage page = editor.getdMainPage();
IStructuredContentProvider provider = (IStructuredContentProvider) page.getSchemaContentProvider();
Util.updateReferenceToXSDTypeDefinition(page.getSite(), curXSDComplexType, provider);
}
return true;
}
use of com.amalto.workbench.editors.DataModelMainPage in project tmdm-studio-se by Talend.
the class SimpleTypeWrapper method changeTypeName.
public boolean changeTypeName() {
if (getNewTypeName().trim().equals(getOldTypeName()))
return false;
xsdSimpleType.setName(getNewTypeName().trim());
xsdSimpleType.updateElement();
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorPart activeEditor = activePage.getActiveEditor();
if (activeEditor instanceof XSDEditor) {
XSDEditor editor = (XSDEditor) activeEditor;
DataModelMainPage page = editor.getdMainPage();
IStructuredContentProvider provider = (IStructuredContentProvider) page.getSchemaContentProvider();
Util.updateReferenceToXSDTypeDefinition(page.getSite(), xsdSimpleType, provider);
}
return true;
}
use of com.amalto.workbench.editors.DataModelMainPage 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 com.amalto.workbench.editors.DataModelMainPage in project tmdm-studio-se by Talend.
the class XSDEditor method doPageChanged.
protected void doPageChanged(int newPageIndex, int lastPageIndex) {
if (xobject == null) {
return;
}
try {
if (newPageIndex == MODEL_PAGE_INDEX) {
DataModelMainPage mainPage = getDataModelEditorPage();
if (mainPage != null) {
if (lastPageIndex == SOURCE_PAGE_INDEX) {
validateXsdSourceEditor();
if (!hasXSDErrors) {
String xsd = getSourcePageDocument();
XSDSchema schema = Util.createXsdSchema(xsd, xobject);
mainPage.setXsdSchema(schema);
}
}
mainPage.refresh();
//
expandHelper.recoverExpandState(mainPage);
}
} else if (newPageIndex == SOURCE_PAGE_INDEX) {
if (hasXSDErrors) {
return;
}
// save DataModelMainPage's contents to file
DataModelMainPage mainPage = getDataModelEditorPage();
expandHelper.recordExpandState(mainPage);
if (mainPage != null && this.isDirty()) {
String xsd = mainPage.getXSDSchemaString();
xsd = Util.formatXsdSource(xsd);
WSDataModel wsDataModel = (WSDataModel) xobject.getWsObject();
wsDataModel.setXsdSchema(xsd);
IFile file = getXSDFile(xobject);
// $NON-NLS-1$
file.setCharset("utf-8", null);
// $NON-NLS-1$
file.setContents(new ByteArrayInputStream(xsd.getBytes("utf-8")), IFile.FORCE, null);
}
}
} catch (SAXParseException ex) {
// do nothing
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
Aggregations