Search in sources :

Example 1 with RemoveSampleElementsOperation

use of com.liferay.ide.project.core.descriptor.RemoveSampleElementsOperation in project liferay-ide by liferay.

the class LiferayDisplayDescriptorHelper method addDescriptorOperations.

@Override
protected void addDescriptorOperations() {
    AddNewPortletOperation anpOperation = new AddNewPortletOperation() {

        @Override
        public IStatus addNewPortlet(IDataModel model) {
            IStatus status = Status.OK_STATUS;
            IFile descriptorFile = getDescriptorFile();
            if (descriptorFile != null) {
                DOMModelEditOperation domModelOperation = new DOMModelEditOperation(descriptorFile) {

                    protected void createDefaultFile() {
                        createDefaultDescriptor(_DESCRIPTOR_TEMPLATE, getDescriptorVersion());
                    }

                    protected IStatus doExecute(IDOMDocument document) {
                        return doAddNewPortlet(document, model);
                    }
                };
                status = domModelOperation.execute();
            }
            return status;
        }
    };
    addDescriptorOperation(anpOperation);
    RemoveAllPortletsOperation rapOperation = new RemoveAllPortletsOperation() {

        @Override
        public IStatus removeAllPortlets() {
            return removeAllPortlets();
        }
    };
    addDescriptorOperation(rapOperation);
    RemoveSampleElementsOperation rseOperation = new RemoveSampleElementsOperation() {

        @Override
        public IStatus removeSampleElements() {
            return removeAllPortlets();
        }
    };
    addDescriptorOperation(rseOperation);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) IFile(org.eclipse.core.resources.IFile) RemoveSampleElementsOperation(com.liferay.ide.project.core.descriptor.RemoveSampleElementsOperation) RemoveAllPortletsOperation(com.liferay.ide.project.core.descriptor.RemoveAllPortletsOperation) AddNewPortletOperation(com.liferay.ide.project.core.descriptor.AddNewPortletOperation) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument) IDataModel(org.eclipse.wst.common.frameworks.datamodel.IDataModel)

Example 2 with RemoveSampleElementsOperation

use of com.liferay.ide.project.core.descriptor.RemoveSampleElementsOperation in project liferay-ide by liferay.

the class LiferayPortletDescriptorHelper method addDescriptorOperations.

@Override
protected void addDescriptorOperations() {
    AddNewPortletOperation apOperation = new AddNewPortletOperation() {

        @Override
        public IStatus addNewPortlet(IDataModel model) {
            IStatus status = Status.OK_STATUS;
            if (canAddNewPortlet(model)) {
                IFile descriptorFile = getDescriptorFile();
                if (descriptorFile != null) {
                    DOMModelEditOperation domModelOperation = new DOMModelEditOperation(descriptorFile) {

                        protected void createDefaultFile() {
                            createDefaultDescriptor(_DESCRIPTOR_TEMPLATE, getDescriptorVersion());
                        }

                        protected IStatus doExecute(IDOMDocument document) {
                            return doAddNewPortlet(document, model);
                        }
                    };
                    status = domModelOperation.execute();
                }
            }
            return status;
        }
    };
    addDescriptorOperation(apOperation);
    RemoveAllPortletsOperation rapOperation = new RemoveAllPortletsOperation() {

        @Override
        public IStatus removeAllPortlets() {
            return doRemoveAllPortlets();
        }
    };
    addDescriptorOperation(rapOperation);
    RemoveSampleElementsOperation rseOperation = new RemoveSampleElementsOperation() {

        @Override
        public IStatus removeSampleElements() {
            return doRemoveAllPortlets();
        }
    };
    addDescriptorOperation(rseOperation);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) IFile(org.eclipse.core.resources.IFile) RemoveSampleElementsOperation(com.liferay.ide.project.core.descriptor.RemoveSampleElementsOperation) RemoveAllPortletsOperation(com.liferay.ide.project.core.descriptor.RemoveAllPortletsOperation) AddNewPortletOperation(com.liferay.ide.project.core.descriptor.AddNewPortletOperation) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument) IDataModel(org.eclipse.wst.common.frameworks.datamodel.IDataModel)

Example 3 with RemoveSampleElementsOperation

use of com.liferay.ide.project.core.descriptor.RemoveSampleElementsOperation in project liferay-ide by liferay.

the class PortletDescriptorHelper method addDescriptorOperations.

protected void addDescriptorOperations() {
    RemoveSampleElementsOperation rseOperation = new RemoveSampleElementsOperation() {

        @Override
        public IStatus removeSampleElements() {
            return doRemoveAllPortlets();
        }
    };
    addDescriptorOperation(rseOperation);
    AddNewPortletOperation apOperation = new AddNewPortletOperation() {

        @Override
        public IStatus addNewPortlet(IDataModel model) {
            IStatus status = Status.OK_STATUS;
            if (canAddNewPortlet(model)) {
                IFile descriptorFile = getDescriptorFile();
                if (descriptorFile != null) {
                    DOMModelOperation domModelOperation = new DOMModelEditOperation(descriptorFile) {

                        protected void createDefaultFile() {
                            createDefaultDescriptor(_DESCRIPTOR_TEMPLATE, "");
                        }

                        protected IStatus doExecute(IDOMDocument document) {
                            return doAddNewPortlet(document, model);
                        }
                    };
                    status = domModelOperation.execute();
                }
            }
            return status;
        }
    };
    addDescriptorOperation(apOperation);
    RemoveAllPortletsOperation rapOperation = new RemoveAllPortletsOperation() {

        @Override
        public IStatus removeAllPortlets() {
            return doRemoveAllPortlets();
        }
    };
    addDescriptorOperation(rapOperation);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) RemoveSampleElementsOperation(com.liferay.ide.project.core.descriptor.RemoveSampleElementsOperation) IFile(org.eclipse.core.resources.IFile) RemoveAllPortletsOperation(com.liferay.ide.project.core.descriptor.RemoveAllPortletsOperation) AddNewPortletOperation(com.liferay.ide.project.core.descriptor.AddNewPortletOperation) IDOMDocument(org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument) IDataModel(org.eclipse.wst.common.frameworks.datamodel.IDataModel)

Aggregations

AddNewPortletOperation (com.liferay.ide.project.core.descriptor.AddNewPortletOperation)3 RemoveAllPortletsOperation (com.liferay.ide.project.core.descriptor.RemoveAllPortletsOperation)3 RemoveSampleElementsOperation (com.liferay.ide.project.core.descriptor.RemoveSampleElementsOperation)3 IFile (org.eclipse.core.resources.IFile)3 IStatus (org.eclipse.core.runtime.IStatus)3 IDataModel (org.eclipse.wst.common.frameworks.datamodel.IDataModel)3 IDOMDocument (org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument)3