Search in sources :

Example 11 with FormatProcessorXML

use of org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML in project liferay-ide by liferay.

the class ThemeDescriptorHelper method createDefaultFile.

public void createDefaultFile(IContainer container, String version, String id, String name, String themeType) {
    if ((container == null) || (id == null) || (name == null)) {
        return;
    }
    try {
        Path path = new Path(ILiferayConstants.LIFERAY_LOOK_AND_FEEL_XML_FILE);
        IFile lookAndFeelFile = container.getFile(path);
        String descriptorVersion = getDescriptorVersionFromPortalVersion(version);
        CoreUtil.prepareFolder((IFolder) lookAndFeelFile.getParent());
        String contents = MessageFormat.format(DEFUALT_FILE_TEMPLATE, descriptorVersion, descriptorVersion.replace('.', '_'));
        contents = contents.replaceAll("__VERSION__", version + "+");
        contents = contents.replaceAll("__ID__", id);
        contents = contents.replaceAll("__NAME__", name);
        lookAndFeelFile.create(new ByteArrayInputStream(contents.getBytes()), true, null);
        if (!themeType.equals("vm")) {
            setTemplateExtension(lookAndFeelFile, themeType);
        }
        FormatProcessorXML processor = new FormatProcessorXML();
        try {
            processor.formatFile(lookAndFeelFile);
        } catch (IOException ioe) {
        }
    } catch (CoreException ce) {
        ThemeCore.logError("Error creating default descriptor file", ce);
    }
}
Also used : Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) CoreException(org.eclipse.core.runtime.CoreException) ByteArrayInputStream(java.io.ByteArrayInputStream) IOException(java.io.IOException) FormatProcessorXML(org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML)

Example 12 with FormatProcessorXML

use of org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML in project liferay-ide by liferay.

the class ServiceBuilderDescriptorHelper method doAddDefaultColumns.

protected IStatus doAddDefaultColumns(IDOMDocument document, String entityName) {
    Element entityElement = null;
    NodeList nodes = document.getDocumentElement().getChildNodes();
    if ((nodes != null) && (nodes.getLength() > 0)) {
        for (int i = 0; i < nodes.getLength(); i++) {
            Node node = nodes.item(i);
            if (node.getNodeName().equals("entity") && (node instanceof Element)) {
                if (entityName.equals(((Element) node).getAttribute("name"))) {
                    entityElement = (Element) node;
                }
            }
        }
    }
    if (entityElement == null) {
        return Status.CANCEL_STATUS;
    }
    // <!-- PK fields -->
    _appendComment(entityElement, " PK fields ");
    Element columnElem = NodeUtil.appendChildElement(entityElement, "column");
    columnElem.setAttribute("name", _generateEntityId(entityName));
    columnElem.setAttribute("primary", "true");
    columnElem.setAttribute("type", "long");
    // <!-- Group instance -->
    _appendComment(entityElement, " Group instance ");
    columnElem = NodeUtil.appendChildElement(entityElement, "column");
    columnElem.setAttribute("name", "groupId");
    columnElem.setAttribute("type", "long");
    // <!-- Aduit fields -->
    _appendComment(entityElement, " Audit fields ");
    columnElem = NodeUtil.appendChildElement(entityElement, "column");
    columnElem.setAttribute("name", "companyId");
    columnElem.setAttribute("type", "long");
    columnElem = NodeUtil.appendChildElement(entityElement, "column");
    columnElem.setAttribute("name", "userId");
    columnElem.setAttribute("type", "long");
    columnElem = NodeUtil.appendChildElement(entityElement, "column");
    columnElem.setAttribute("name", "userName");
    columnElem.setAttribute("type", "String");
    columnElem = NodeUtil.appendChildElement(entityElement, "column");
    columnElem.setAttribute("name", "createDate");
    columnElem.setAttribute("type", "Date");
    columnElem = NodeUtil.appendChildElement(entityElement, "column");
    columnElem.setAttribute("name", "modifiedDate");
    columnElem.setAttribute("type", "Date");
    entityElement.appendChild(document.createTextNode(_NEW_LINE));
    new FormatProcessorXML().formatNode(entityElement);
    return Status.OK_STATUS;
}
Also used : Element(org.w3c.dom.Element) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) FormatProcessorXML(org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML)

Example 13 with FormatProcessorXML

use of org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML in project webtools.sourceediting by eclipse.

the class XSDCommonUIUtils method formatChild.

public static void formatChild(Node child) {
    if (child instanceof IDOMNode) {
        IDOMModel model = ((IDOMNode) child).getModel();
        try {
            // tell the model that we are about to make a big model change
            model.aboutToChangeModel();
            IStructuredFormatProcessor formatProcessor = new FormatProcessorXML();
            formatProcessor.formatNode(child);
        } finally {
            // tell the model that we are done with the big model change
            model.changedModel();
        }
    }
}
Also used : IStructuredFormatProcessor(org.eclipse.wst.sse.core.internal.format.IStructuredFormatProcessor) IDOMNode(org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode) IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) FormatProcessorXML(org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML)

Example 14 with FormatProcessorXML

use of org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML in project webtools.sourceediting by eclipse.

the class XSDDOMHelper method formatChild.

public static void formatChild(Node child) {
    if (child instanceof IDOMNode) {
        IDOMModel model = ((IDOMNode) child).getModel();
        try {
            // tell the model that we are about to make a big model change
            model.aboutToChangeModel();
            IStructuredFormatProcessor formatProcessor = new FormatProcessorXML();
            formatProcessor.formatNode(child);
        } finally {
            // tell the model that we are done with the big model change
            model.changedModel();
        }
    }
}
Also used : IStructuredFormatProcessor(org.eclipse.wst.sse.core.internal.format.IStructuredFormatProcessor) IDOMNode(org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode) IDOMModel(org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel) FormatProcessorXML(org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML)

Example 15 with FormatProcessorXML

use of org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML in project webtools.sourceediting by eclipse.

the class XMLNodeActionManager method reformat.

@Override
public void reformat(Node newElement, boolean deep) {
    try {
        // tell the model that we are about to make a big model change
        fModel.aboutToChangeModel();
        // format selected node
        IStructuredFormatProcessor formatProcessor = new FormatProcessorXML();
        formatProcessor.formatNode(newElement);
    } finally {
        // tell the model that we are done with the big model change
        fModel.changedModel();
    }
}
Also used : IStructuredFormatProcessor(org.eclipse.wst.sse.core.internal.format.IStructuredFormatProcessor) FormatProcessorXML(org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML)

Aggregations

FormatProcessorXML (org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML)28 Element (org.w3c.dom.Element)16 Node (org.w3c.dom.Node)14 NodeList (org.w3c.dom.NodeList)9 IStructuredFormatProcessor (org.eclipse.wst.sse.core.internal.format.IStructuredFormatProcessor)8 IDOMModel (org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel)6 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)6 CoreException (org.eclipse.core.runtime.CoreException)3 IWebProject (com.liferay.ide.core.IWebProject)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 IFile (org.eclipse.core.resources.IFile)2 ITemplateContext (com.liferay.ide.core.templates.ITemplateContext)1 ITemplateOperation (com.liferay.ide.core.templates.ITemplateOperation)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 IFolder (org.eclipse.core.resources.IFolder)1 IPath (org.eclipse.core.runtime.IPath)1 Path (org.eclipse.core.runtime.Path)1 BadLocationException (org.eclipse.jface.text.BadLocationException)1