Search in sources :

Example 1 with ILiferayProject

use of com.liferay.ide.core.ILiferayProject 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 ILiferayProject

use of com.liferay.ide.core.ILiferayProject 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 ILiferayProject

use of com.liferay.ide.core.ILiferayProject 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 ILiferayProject

use of com.liferay.ide.core.ILiferayProject 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 ILiferayProject

use of com.liferay.ide.core.ILiferayProject 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

ILiferayProject (com.liferay.ide.core.ILiferayProject)45 ILiferayPortal (com.liferay.ide.core.ILiferayPortal)29 IProject (org.eclipse.core.resources.IProject)21 IPath (org.eclipse.core.runtime.IPath)18 IFile (org.eclipse.core.resources.IFile)17 CoreException (org.eclipse.core.runtime.CoreException)15 ArrayList (java.util.ArrayList)9 IFolder (org.eclipse.core.resources.IFolder)8 Version (org.osgi.framework.Version)8 IOException (java.io.IOException)7 File (java.io.File)5 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 Test (org.junit.Test)5 IProjectBuilder (com.liferay.ide.project.core.IProjectBuilder)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 IStatus (org.eclipse.core.runtime.IStatus)4 Path (org.eclipse.core.runtime.Path)4 IWebProject (com.liferay.ide.core.IWebProject)3 Hook (com.liferay.ide.hook.core.model.Hook)3 IMavenProjectFacade (org.eclipse.m2e.core.project.IMavenProjectFacade)3