use of com.twinsoft.convertigo.beans.common.FormatedContent in project convertigo by convertigo.
the class MobilePageComponentTreeObject method editPageTsFile.
public void editPageTsFile() {
final PageComponent page = (PageComponent) getObject();
try {
// Refresh project resource
String projectName = page.getProject().getName();
IProject project = ConvertigoPlugin.getDefault().getProjectPluginResource(projectName);
project.refreshLocal(IResource.DEPTH_INFINITE, null);
// Close editor
String filePath = page.getProject().getMobileBuilder().getTempTsRelativePath(page);
IFile file = project.getFile(filePath);
closeComponentFileEditor(file);
// Write temporary file
page.getProject().getMobileBuilder().writePageTempTs(page);
file.refreshLocal(IResource.DEPTH_ZERO, null);
// Open file in editor
if (file.exists()) {
IEditorInput input = new ComponentFileEditorInput(file, page);
if (input != null) {
IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getName());
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
String editorId = desc.getId();
IEditorPart editorPart = activePage.openEditor(input, editorId);
addMarkers(file, editorPart);
editorPart.addPropertyListener(new IPropertyListener() {
boolean isFirstChange = false;
@Override
public void propertyChanged(Object source, int propId) {
if (source instanceof ITextEditor) {
if (propId == IEditorPart.PROP_DIRTY) {
if (!isFirstChange) {
isFirstChange = true;
return;
}
isFirstChange = false;
ITextEditor editor = (ITextEditor) source;
IDocumentProvider dp = editor.getDocumentProvider();
IDocument doc = dp.getDocument(editor.getEditorInput());
FormatedContent scriptContent = new FormatedContent(MobileBuilder.getMarkers(doc.get()));
MobilePageComponentTreeObject.this.setPropertyValue("scriptContent", scriptContent);
}
}
}
});
}
}
} catch (Exception e) {
ConvertigoPlugin.logException(e, "Unable to open typescript file for page '" + page.getName() + "'!");
}
}
use of com.twinsoft.convertigo.beans.common.FormatedContent in project convertigo by convertigo.
the class MobileApplicationComponentTreeObject method editAppComponentTsFile.
public void editAppComponentTsFile() {
final ApplicationComponent application = getObject();
try {
// Refresh project resource
String projectName = application.getProject().getName();
IProject project = ConvertigoPlugin.getDefault().getProjectPluginResource(projectName);
project.refreshLocal(IResource.DEPTH_INFINITE, null);
// Close editor
String filePath = application.getProject().getMobileBuilder().getTempTsRelativePath(application);
IFile file = project.getFile(filePath);
closeComponentFileEditor(file);
// Write temporary file
application.getProject().getMobileBuilder().writeAppComponentTempTs(application);
file.refreshLocal(IResource.DEPTH_ZERO, null);
// Open file in editor
if (file.exists()) {
IEditorInput input = new ComponentFileEditorInput(file, application);
if (input != null) {
IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file.getName());
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
String editorId = desc.getId();
IEditorPart editorPart = activePage.openEditor(input, editorId);
addMarkers(file, editorPart);
editorPart.addPropertyListener(new IPropertyListener() {
boolean isFirstChange = false;
@Override
public void propertyChanged(Object source, int propId) {
if (source instanceof ITextEditor) {
if (propId == IEditorPart.PROP_DIRTY) {
if (!isFirstChange) {
isFirstChange = true;
return;
}
isFirstChange = false;
ITextEditor editor = (ITextEditor) source;
IDocumentProvider dp = editor.getDocumentProvider();
IDocument doc = dp.getDocument(editor.getEditorInput());
FormatedContent componentScriptContent = new FormatedContent(MobileBuilder.getMarkers(doc.get()));
MobileApplicationComponentTreeObject.this.setPropertyValue("componentScriptContent", componentScriptContent);
}
}
}
});
}
}
} catch (Exception e) {
ConvertigoPlugin.logException(e, "Unable to open typescript file for page '" + application.getName() + "'!");
}
}
use of com.twinsoft.convertigo.beans.common.FormatedContent in project convertigo by convertigo.
the class PageComponent method preconfigure.
@Override
public void preconfigure(Element element) throws Exception {
super.preconfigure(element);
try {
long priority = Long.valueOf(element.getAttribute("priority")).longValue();
if (priority == 0L) {
priority = getNewOrderValue();
element.setAttribute("priority", "" + priority);
}
NodeList properties = element.getElementsByTagName("property");
// migration of scriptContent from String to FormatedContent
Element propElement = (Element) XMLUtils.findNodeByAttributeValue(properties, "name", "scriptContent");
if (propElement != null) {
Element valueElement = (Element) XMLUtils.findChildNode(propElement, Node.ELEMENT_NODE);
if (valueElement != null) {
Document document = valueElement.getOwnerDocument();
Object content = XMLUtils.readObjectFromXml(valueElement);
if (content instanceof String) {
FormatedContent formated = new FormatedContent((String) content);
Element newValueElement = (Element) XMLUtils.writeObjectToXml(document, formated);
propElement.replaceChild(newValueElement, valueElement);
hasChanged = true;
Engine.logBeans.warn("(PageComponent) 'scriptContent' has been updated for the object \"" + getName() + "\"");
}
}
}
} catch (Exception e) {
throw new EngineException("Unable to preconfigure the page component \"" + getName() + "\".", e);
}
}
use of com.twinsoft.convertigo.beans.common.FormatedContent in project convertigo by convertigo.
the class PageComponent method preconfigure.
@Override
public void preconfigure(Element element) throws Exception {
super.preconfigure(element);
try {
long priority = Long.valueOf(element.getAttribute("priority")).longValue();
if (priority == 0L) {
priority = getNewOrderValue();
element.setAttribute("priority", "" + priority);
}
NodeList properties = element.getElementsByTagName("property");
// migration of scriptContent from String to FormatedContent
Element propElement = (Element) XMLUtils.findNodeByAttributeValue(properties, "name", "scriptContent");
if (propElement != null) {
Element valueElement = (Element) XMLUtils.findChildNode(propElement, Node.ELEMENT_NODE);
if (valueElement != null) {
Document document = valueElement.getOwnerDocument();
Object content = XMLUtils.readObjectFromXml(valueElement);
if (content instanceof String) {
FormatedContent formated = new FormatedContent((String) content);
Element newValueElement = (Element) XMLUtils.writeObjectToXml(document, formated);
propElement.replaceChild(newValueElement, valueElement);
hasChanged = true;
Engine.logBeans.warn("(PageComponent) 'scriptContent' has been updated for the object \"" + getName() + "\"");
}
}
}
} catch (Exception e) {
throw new EngineException("Unable to preconfigure the page component \"" + getName() + "\".", e);
}
}
use of com.twinsoft.convertigo.beans.common.FormatedContent in project convertigo by convertigo.
the class ApplicationComponent method preconfigure.
@Override
public void preconfigure(Element element) throws Exception {
super.preconfigure(element);
try {
NodeList properties = element.getElementsByTagName("property");
// migration of componentScriptContent from String to FormatedContent
Element propElement = (Element) XMLUtils.findNodeByAttributeValue(properties, "name", "componentScriptContent");
if (propElement != null) {
Element valueElement = (Element) XMLUtils.findChildNode(propElement, Node.ELEMENT_NODE);
if (valueElement != null) {
Document document = valueElement.getOwnerDocument();
Object content = XMLUtils.readObjectFromXml(valueElement);
if (content instanceof String) {
FormatedContent formated = new FormatedContent((String) content);
Element newValueElement = (Element) XMLUtils.writeObjectToXml(document, formated);
propElement.replaceChild(newValueElement, valueElement);
hasChanged = true;
Engine.logBeans.warn("(ApplicationComponent) 'componentScriptContent' has been updated for the object \"" + getName() + "\"");
}
}
}
} catch (Exception e) {
throw new EngineException("Unable to preconfigure the application component \"" + getName() + "\".", e);
}
}
Aggregations