Search in sources :

Example 16 with FormatedContent

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);
    }
}
Also used : NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) EngineException(com.twinsoft.convertigo.engine.EngineException) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) JSONObject(org.codehaus.jettison.json.JSONObject) FormatedContent(com.twinsoft.convertigo.beans.common.FormatedContent) Document(org.w3c.dom.Document) IOException(java.io.IOException) JSONException(org.codehaus.jettison.json.JSONException) EngineException(com.twinsoft.convertigo.engine.EngineException)

Example 17 with FormatedContent

use of com.twinsoft.convertigo.beans.common.FormatedContent in project convertigo by convertigo.

the class UIStyle method preconfigure.

@Override
public void preconfigure(Element element) throws Exception {
    super.preconfigure(element);
    try {
        NodeList properties = element.getElementsByTagName("property");
        // migration of styleContent from String to FormatedContent
        Element propElement = (Element) XMLUtils.findNodeByAttributeValue(properties, "name", "styleContent");
        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("(UIStyle) 'styleContent' has been updated for the object \"" + getName() + "\"");
                }
            }
        }
    } catch (Exception e) {
        throw new EngineException("Unable to preconfigure the style component \"" + getName() + "\".", e);
    }
}
Also used : NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) EngineException(com.twinsoft.convertigo.engine.EngineException) DatabaseObject(com.twinsoft.convertigo.beans.core.DatabaseObject) FormatedContent(com.twinsoft.convertigo.beans.common.FormatedContent) Document(org.w3c.dom.Document) EngineException(com.twinsoft.convertigo.engine.EngineException)

Aggregations

FormatedContent (com.twinsoft.convertigo.beans.common.FormatedContent)17 EngineException (com.twinsoft.convertigo.engine.EngineException)15 DatabaseObject (com.twinsoft.convertigo.beans.core.DatabaseObject)13 IFile (org.eclipse.core.resources.IFile)9 IProject (org.eclipse.core.resources.IProject)9 IDocument (org.eclipse.jface.text.IDocument)9 IEditorInput (org.eclipse.ui.IEditorInput)9 IEditorPart (org.eclipse.ui.IEditorPart)9 IPropertyListener (org.eclipse.ui.IPropertyListener)9 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)9 IDocumentProvider (org.eclipse.ui.texteditor.IDocumentProvider)9 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)9 IEditorDescriptor (org.eclipse.ui.IEditorDescriptor)7 Document (org.w3c.dom.Document)6 Element (org.w3c.dom.Element)6 NodeList (org.w3c.dom.NodeList)6 ComponentFileEditorInput (com.twinsoft.convertigo.eclipse.editors.ngx.ComponentFileEditorInput)5 CoreException (org.eclipse.core.runtime.CoreException)5 ComponentFileEditorInput (com.twinsoft.convertigo.eclipse.editors.mobile.ComponentFileEditorInput)4 JSONException (org.codehaus.jettison.json.JSONException)4