Search in sources :

Example 1 with Path

use of org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.

the class PortalPropertiesFileListener method handleTypedEvent.

@Override
protected void handleTypedEvent(PropertyContentEvent event) {
    Property prop = event.property();
    if (Hook.PROP_PORTAL_PROPERTIES_FILE.equals(prop.definition())) {
        Hook hook = prop.element().nearest(Hook.class);
        PortalPropertiesFile ppf = hook.getPortalPropertiesFile().content(false);
        if (ppf != null) {
            Value<Path> value = ppf.getValue();
            if (value != null) {
                Path path = value.content(false);
                if (path == null) {
                    ppf.initialize();
                }
            }
        }
    }
}
Also used : Path(org.eclipse.sapphire.modeling.Path) Hook(com.liferay.ide.hook.core.model.Hook) PortalPropertiesFile(com.liferay.ide.hook.core.model.PortalPropertiesFile) Property(org.eclipse.sapphire.Property)

Example 2 with Path

use of org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.

the class CreateSrcFileActionHandler method _getSrcFile.

private IFile _getSrcFile() {
    IFile retval = null;
    ValueProperty valueProperty = ValueProperty.class.cast(property().definition());
    Value<Path> value = getModelElement().property(valueProperty);
    if ((value != null) && !CoreUtil.isNullOrEmpty(value.text())) {
        IPath defaultSrcFolderPath = _getDefaultSrcFolderPath();
        if (defaultSrcFolderPath != null) {
            IPath filePath = defaultSrcFolderPath.append(value.text());
            IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
            retval = root.getFile(filePath);
        }
    }
    return retval;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.sapphire.modeling.Path) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) ValueProperty(org.eclipse.sapphire.ValueProperty)

Example 3 with Path

use of org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.

the class HookXmlEditor method _copyCustomJspsToProject.

private void _copyCustomJspsToProject(IPath portalDir, ElementList<CustomJsp> customJsps) {
    try {
        Hook hook = getModelElement().nearest(Hook.class);
        ElementHandle<CustomJspDir> element = hook.getCustomJspDir();
        CustomJspDir customJspDirElement = element.content();
        if ((customJspDirElement != null) && customJspDirElement.validation().ok()) {
            Path customJspDir = customJspDirElement.getValue().content();
            IWebProject webproject = LiferayCore.create(IWebProject.class, getProject());
            if (webproject != null) {
                IFolder defaultDocroot = webproject.getDefaultDocrootFolder();
                IFolder customJspFolder = defaultDocroot.getFolder(customJspDir.toPortableString());
                for (CustomJsp customJsp : customJsps) {
                    String content = customJsp.getValue().content();
                    if (!empty(content)) {
                        IFile customJspFile = customJspFolder.getFile(content);
                        if (!customJspFile.exists()) {
                            IPath portalJsp = portalDir.append(content);
                            try {
                                CoreUtil.makeFolders((IFolder) customJspFile.getParent());
                                if (portalJsp.toFile().exists()) {
                                    customJspFile.create(Files.newInputStream(portalJsp.toFile().toPath()), true, null);
                                } else {
                                    CoreUtil.createEmptyFile(customJspFile);
                                }
                            } catch (Exception e) {
                                HookUI.logError(e);
                            }
                        }
                    }
                }
            }
        }
    } catch (Exception e) {
        HookUI.logError(e);
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.sapphire.modeling.Path) Hook(com.liferay.ide.hook.core.model.Hook) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) IWebProject(com.liferay.ide.core.IWebProject) CustomJsp(com.liferay.ide.hook.core.model.CustomJsp) CustomJspDir(com.liferay.ide.hook.core.model.CustomJspDir) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) MalformedURLException(java.net.MalformedURLException) IOException(java.io.IOException) IFolder(org.eclipse.core.resources.IFolder)

Example 4 with Path

use of org.eclipse.sapphire.modeling.Path 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 Path

use of org.eclipse.sapphire.modeling.Path in project liferay-ide by liferay.

the class CustomJspsEnablementService method compute.

@Override
protected Boolean compute() {
    boolean enablement = true;
    ElementHandle<CustomJspDir> elementHandle = _hook().getCustomJspDir();
    CustomJspDir customJspDir = elementHandle.content();
    if (customJspDir != null) {
        IProject project = _hook().adapt(IProject.class);
        Path customJspDirPath = customJspDir.getValue().content(true);
        if ((project != null) && (customJspDirPath != null)) {
            IWebProject lrproject = LiferayCore.create(IWebProject.class, project);
            if (lrproject != null) {
                IFolder defaultWebappDir = lrproject.getDefaultDocrootFolder();
                if (FileUtil.exists(defaultWebappDir)) {
                    IFolder customJspFolder = defaultWebappDir.getFolder(PathBridge.create(customJspDirPath));
                    enablement = FileUtil.exists(customJspFolder);
                }
            }
        }
    }
    return enablement;
}
Also used : Path(org.eclipse.sapphire.modeling.Path) IWebProject(com.liferay.ide.core.IWebProject) CustomJspDir(com.liferay.ide.hook.core.model.CustomJspDir) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder)

Aggregations

Path (org.eclipse.sapphire.modeling.Path)71 IPath (org.eclipse.core.runtime.IPath)37 IStatus (org.eclipse.core.runtime.IStatus)18 Status (org.eclipse.sapphire.modeling.Status)18 IProject (org.eclipse.core.resources.IProject)17 SDK (com.liferay.ide.sdk.core.SDK)16 CoreException (org.eclipse.core.runtime.CoreException)16 IFile (org.eclipse.core.resources.IFile)12 File (java.io.File)9 NewLiferayPluginProjectOp (com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)8 ArrayList (java.util.ArrayList)8 IFolder (org.eclipse.core.resources.IFolder)8 Hook (com.liferay.ide.hook.core.model.Hook)6 Element (org.eclipse.sapphire.Element)6 CustomJspDir (com.liferay.ide.hook.core.model.CustomJspDir)5 IWebProject (com.liferay.ide.core.IWebProject)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)3 ValueProperty (org.eclipse.sapphire.ValueProperty)3 ILiferayPortal (com.liferay.ide.core.ILiferayPortal)2