Search in sources :

Example 1 with ILiferayPortal

use of com.liferay.ide.core.ILiferayPortal in project liferay-ide by liferay.

the class NewCustomJSPsHookWizardPage method createCustomJSPsGroup.

protected void createCustomJSPsGroup(Composite parent) {
    Composite composite = SWTUtil.createTopComposite(parent, 2);
    composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 3, 1));
    jspItemsSection = new CustomJSPsTableWizardSection(composite, Msgs.jspFilesOverride, Msgs.jspFilePath, Msgs.add, Msgs.edit, Msgs.remove, new String[] { Msgs.add }, new String[] { Msgs.jspFilePath }, null, getDataModel(), CUSTOM_JSPS_ITEMS);
    GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, true, 1, 1);
    gd.heightHint = 175;
    jspItemsSection.setLayoutData(gd);
    jspItemsSection.setCallback(new StringArrayTableWizardSectionCallback());
    IProject project = CoreUtil.getProject(getDataModel().getStringProperty(PROJECT_NAME));
    ILiferayProject liferayProject = LiferayCore.create(project);
    if (liferayProject != null) {
        ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
        if (portal != null) {
            IPath portalDir = portal.getAppServerPortalDir();
            if (FileUtil.exists(portalDir)) {
                jspItemsSection.setPortalDir(portalDir.toFile());
            }
        }
    }
}
Also used : StringArrayTableWizardSectionCallback(com.liferay.ide.project.ui.wizard.StringArrayTableWizardSectionCallback) Composite(org.eclipse.swt.widgets.Composite) IPath(org.eclipse.core.runtime.IPath) ILiferayProject(com.liferay.ide.core.ILiferayProject) GridData(org.eclipse.swt.layout.GridData) ILiferayPortal(com.liferay.ide.core.ILiferayPortal) IProject(org.eclipse.core.resources.IProject)

Example 2 with ILiferayPortal

use of com.liferay.ide.core.ILiferayPortal in project liferay-ide by liferay.

the class StrutsActionPathPossibleValuesService method initPossibleValuesService.

@Override
protected void initPossibleValuesService() {
    super.initPossibleValuesService();
    ILiferayProject liferayProject = LiferayCore.create(project());
    if (liferayProject != null) {
        ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
        if (portal != null) {
            _portalDir = portal.getAppServerPortalDir();
        }
    }
}
Also used : ILiferayProject(com.liferay.ide.core.ILiferayProject) ILiferayPortal(com.liferay.ide.core.ILiferayPortal)

Example 3 with ILiferayPortal

use of com.liferay.ide.core.ILiferayPortal in project liferay-ide by liferay.

the class AddHookOperation method createCustomJSPs.

protected IStatus createCustomJSPs(IDataModel dm) {
    IProject project = getTargetProject();
    IFolder defaultWebappRootFolder = LiferayCore.create(IWebProject.class, project).getDefaultDocrootFolder();
    String customJSPsFolder = dm.getStringProperty(CUSTOM_JSPS_FOLDER);
    IPath fullPath = defaultWebappRootFolder.getFullPath();
    String customFolderValue = fullPath.append(customJSPsFolder).toPortableString();
    IWorkspaceRoot root = project.getWorkspace().getRoot();
    IFolder customFolder = root.getFolder(new Path(customFolderValue));
    try {
        CoreUtil.prepareFolder(customFolder);
    } catch (CoreException ce) {
        return HookCore.createErrorStatus(ce);
    }
    List<String[]> customJsps = (List<String[]>) dm.getProperty(CUSTOM_JSPS_ITEMS);
    ILiferayProject liferayProject = LiferayCore.create(getTargetProject());
    ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
    IStatus status = null;
    if (portal != null) {
        IPath portalDir = portal.getAppServerPortalDir();
        if ((customJsps != null) && (portalDir != null)) {
            for (String[] customJsp : customJsps) {
                try {
                    IFile copiedFile = copyPortalJSPToProject(portalDir, customJsp[0], customFolder);
                    if (copiedFile != null) {
                        Set<IFile> jspFilesCreated = (Set<IFile>) dm.getProperty(CUSTOM_JSPS_FILES_CREATED);
                        jspFilesCreated.add(copiedFile);
                        dm.setProperty(CUSTOM_JSPS_FILES_CREATED, jspFilesCreated);
                    }
                } catch (Exception e) {
                    HookCore.logError(e);
                }
            }
        }
        HookDescriptorHelper hookDescHelper = new HookDescriptorHelper(getTargetProject());
        status = hookDescHelper.setCustomJSPDir(model);
        if (model.getBooleanProperty(DISABLE_CUSTOM_JSP_FOLDER_VALIDATION)) {
            HookUtil.configureJSPSyntaxValidationExclude(getTargetProject(), customFolder, true);
        }
    } else {
        status = HookCore.createErrorStatus("Could not get portal info from project " + project.getName());
    }
    return status;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IStatus(org.eclipse.core.runtime.IStatus) IFile(org.eclipse.core.resources.IFile) Set(java.util.Set) IPath(org.eclipse.core.runtime.IPath) IWebProject(com.liferay.ide.core.IWebProject) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) TemplateException(org.eclipse.jface.text.templates.TemplateException) BadLocationException(org.eclipse.jface.text.BadLocationException) IOException(java.io.IOException) ExecutionException(org.eclipse.core.commands.ExecutionException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) CoreException(org.eclipse.core.runtime.CoreException) ILiferayProject(com.liferay.ide.core.ILiferayProject) HookDescriptorHelper(com.liferay.ide.hook.core.dd.HookDescriptorHelper) ArrayList(java.util.ArrayList) List(java.util.List) ILiferayPortal(com.liferay.ide.core.ILiferayPortal) IFolder(org.eclipse.core.resources.IFolder)

Example 4 with ILiferayPortal

use of com.liferay.ide.core.ILiferayPortal in project liferay-ide by liferay.

the class HookXmlEditor method doSave.

@Override
public void doSave(IProgressMonitor monitor) {
    if (customModelDirty) {
        Hook hook = getModelElement().nearest(Hook.class);
        ElementList<CustomJsp> customJsps = hook.getCustomJsps();
        ILiferayProject liferayProject = LiferayCore.create(getProject());
        ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
        if (portal != null) {
            IPath portalDir = portal.getAppServerPortalDir();
            if (portalDir != null) {
                _copyCustomJspsToProject(portalDir, customJsps);
            }
        }
        customModelDirty = false;
        super.doSave(monitor);
        firePropertyChange(IEditorPart.PROP_DIRTY);
        ElementHandle<CustomJspDir> customJspDir = hook.getCustomJspDir();
        if ((customJspDir != null) && !customJspDir.empty()) {
            Value<Path> customJspPath = customJspDir.content().getValue();
            Path path = customJspPath.content().makeRelative();
            String customeJspValue = path.toPortableString();
            _configureCustomJspValidation(getProject(), customeJspValue);
        }
    } else {
        super.doSave(monitor);
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.sapphire.modeling.Path) Hook(com.liferay.ide.hook.core.model.Hook) IPath(org.eclipse.core.runtime.IPath) CustomJsp(com.liferay.ide.hook.core.model.CustomJsp) ILiferayProject(com.liferay.ide.core.ILiferayProject) CustomJspDir(com.liferay.ide.hook.core.model.CustomJspDir) ILiferayPortal(com.liferay.ide.core.ILiferayPortal)

Example 5 with ILiferayPortal

use of com.liferay.ide.core.ILiferayPortal in project liferay-ide by liferay.

the class CustomJspValidationService method _getPortalDir.

private IPath _getPortalDir() {
    if (_portalDir == null) {
        try {
            Element element = context().find(Element.class);
            IFile file = element.nearest(Hook.class).adapt(IFile.class);
            IProject project = file.getProject();
            ILiferayProject liferayProject = LiferayCore.create(project);
            if (liferayProject != null) {
                ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);
                if (portal != null) {
                    _portalDir = portal.getAppServerPortalDir();
                }
            }
        } catch (Exception e) {
            HookCore.logError(e);
        }
    }
    return _portalDir;
}
Also used : Hook(com.liferay.ide.hook.core.model.Hook) IFile(org.eclipse.core.resources.IFile) ILiferayProject(com.liferay.ide.core.ILiferayProject) Element(org.eclipse.sapphire.Element) ILiferayPortal(com.liferay.ide.core.ILiferayPortal) IProject(org.eclipse.core.resources.IProject)

Aggregations

ILiferayPortal (com.liferay.ide.core.ILiferayPortal)32 ILiferayProject (com.liferay.ide.core.ILiferayProject)29 IPath (org.eclipse.core.runtime.IPath)13 IFile (org.eclipse.core.resources.IFile)10 IProject (org.eclipse.core.resources.IProject)10 CoreException (org.eclipse.core.runtime.CoreException)8 IOException (java.io.IOException)7 Version (org.osgi.framework.Version)7 ArrayList (java.util.ArrayList)4 IWebProject (com.liferay.ide.core.IWebProject)3 Hook (com.liferay.ide.hook.core.model.Hook)3 File (java.io.File)3 Properties (java.util.Properties)3 JarFile (java.util.jar.JarFile)3 Path (org.eclipse.core.runtime.Path)3 InputStream (java.io.InputStream)2 HashSet (java.util.HashSet)2 ZipEntry (java.util.zip.ZipEntry)2 ConfigurationException (org.apache.commons.configuration.ConfigurationException)2 ExecutionException (org.eclipse.core.commands.ExecutionException)2