Search in sources :

Example 51 with Path

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

the class DocrootRelativePathService method roots.

@Override
public List<Path> roots() {
    List<Path> roots = new ArrayList<>();
    Hook hook = context(Hook.class);
    if (hook != null) {
        IProject project = hook.adapt(IProject.class);
        // IDE-110
        IWebProject lrproject = LiferayCore.create(IWebProject.class, project);
        if (lrproject != null) {
            IFolder defaultDocroot = lrproject.getDefaultDocrootFolder();
            if (FileUtil.exists(defaultDocroot)) {
                roots.add(new Path(defaultDocroot.getLocation().toPortableString()));
            }
        }
    }
    return roots;
}
Also used : Path(org.eclipse.sapphire.modeling.Path) Hook(com.liferay.ide.hook.core.model.Hook) IWebProject(com.liferay.ide.core.IWebProject) ArrayList(java.util.ArrayList) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder)

Example 52 with Path

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

the class CreatePortletAppResourceBundleActionHandler method run.

/**
 * (non-Javadoc)
 *
 * @see
 * org.eclipse.sapphire.ui.SapphireActionHandler#run(org.eclipse.sapphire.ui.
 * SapphireRenderingContext)
 */
@Override
protected Object run(Presentation context) {
    Element element = getModelElement();
    IProject project = element.adapt(IProject.class);
    Property property = property();
    Value<Path> resourceBundle = element.property((ValueProperty) property.definition());
    String resourceBundleText = resourceBundle.text();
    int index = resourceBundleText.lastIndexOf(".");
    if (index == -1) {
        index = resourceBundleText.length();
    }
    String packageName = resourceBundleText.substring(0, index);
    String defaultRBFileName = PortletUtil.convertJavaToIoFileName(resourceBundleText, GenericResourceBundlePathService.RB_FILE_EXTENSION);
    IFolder rbSourecFolder = getResourceBundleFolderLocation(project, defaultRBFileName);
    IPath entryPath = rbSourecFolder.getLocation();
    if (getModelElement() instanceof PortletApp) {
        List<IFile> missingRBFiles = new ArrayList<>();
        StringBuilder rbFileBuffer = new StringBuilder("#Portlet Application Resource Bundle \n");
        IFile rbFile = wroot.getFileForLocation(entryPath.append(defaultRBFileName));
        missingRBFiles.add(rbFile);
        createFiles(context, project, packageName, missingRBFiles, rbFileBuffer);
        setEnabled(false);
        Property modelElement = getModelElement().property(property().definition());
        modelElement.refresh();
    }
    return null;
}
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) Element(org.eclipse.sapphire.Element) ArrayList(java.util.ArrayList) IProject(org.eclipse.core.resources.IProject) PortletApp(com.liferay.ide.portlet.core.model.PortletApp) ValueProperty(org.eclipse.sapphire.ValueProperty) Property(org.eclipse.sapphire.Property) IFolder(org.eclipse.core.resources.IFolder)

Example 53 with Path

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

the class PluginsSDKProjectProvider method _getSDK.

private static SDK _getSDK(NewLiferayPluginProjectOp op) {
    SDK sdk = null;
    try {
        boolean sdkValid = false;
        sdk = SDKUtil.getWorkspaceSDK();
        if (sdk != null) {
            IStatus sdkStatus = sdk.validate();
            if (sdkStatus.isOK()) {
                sdkValid = true;
            }
        }
        if (sdkValid == false) {
            Path sdkLocation = op.getSdkLocation().content(true);
            if (sdkLocation != null) {
                sdk = SDKUtil.createSDKFromLocation(PathBridge.create(sdkLocation));
                if (sdk != null) {
                    IStatus sdkStatus = sdk.validate();
                    if (sdkStatus.isOK()) {
                        sdkValid = true;
                    }
                }
            }
        }
        if (!sdkValid) {
            return null;
        }
    } catch (CoreException ce) {
        return null;
    }
    return sdk;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.sapphire.modeling.Path) IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) SDK(com.liferay.ide.sdk.core.SDK)

Example 54 with Path

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

the class PluginTypeValidationService method compute.

@Override
protected Status compute() {
    Status retval = Status.createOkStatus();
    NewLiferayPluginProjectOp op = _op();
    try {
        SDK sdk = SDKUtil.getWorkspaceSDK();
        if (sdk == null) {
            Path sdkLocation = op.getSdkLocation().content();
            if (sdkLocation != null) {
                sdk = SDKUtil.createSDKFromLocation(PathBridge.create(sdkLocation));
            }
        }
        PluginType pluginType = op.getPluginType().content();
        if (sdk != null) {
            if (pluginType.equals(PluginType.web) && !supportsTypePlugin(op, "web")) {
                StringBuilder sb = new StringBuilder();
                sb.append("The selected Plugins SDK does not support creating new web type plugins. ");
                sb.append("");
                sb.append("Please configure version 7.0 or greater.");
                return Status.createErrorStatus(sb.toString());
            } else if (pluginType.equals(PluginType.theme) && !supportsTypePlugin(op, "theme")) {
                StringBuilder sb = new StringBuilder();
                sb.append("The selected Plugins SDK does not support creating theme type plugins. ");
                sb.append("");
                sb.append("Please configure version 6.2 or less or using gulp way.");
                return Status.createErrorStatus(sb.toString());
            } else if (pluginType.equals(PluginType.ext) && !supportsTypePlugin(op, "ext")) {
                StringBuilder sb = new StringBuilder();
                sb.append("The selected Plugins SDK does not support creating ext type plugins. ");
                sb.append("");
                sb.append("Please try to confirm whether sdk has ext folder.");
                return Status.createErrorStatus(sb.toString());
            }
        } else if (pluginType.equals(PluginType.ext) && !supportsTypePlugin(op, "ext")) {
            retval = Status.createErrorStatus("New ext plugins with maven build type are no longer supported.");
        }
    } catch (CoreException ce) {
    }
    return retval;
}
Also used : Status(org.eclipse.sapphire.modeling.Status) Path(org.eclipse.sapphire.modeling.Path) CoreException(org.eclipse.core.runtime.CoreException) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) SDK(com.liferay.ide.sdk.core.SDK) PluginType(com.liferay.ide.project.core.model.PluginType)

Example 55 with Path

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

the class SDKImportDerivedValueService method compute.

@Override
protected String compute() {
    String retVal = null;
    ParentSDKProjectImportOp op = _op();
    Value<Path> path = op.getSdkLocation();
    if ((path != null) && (path.content() != null) && !path.content().isEmpty()) {
        Path sdkPath = path.content();
        SDK sdk = SDKUtil.createSDKFromLocation(PathBridge.create(sdkPath));
        if (sdk != null) {
            retVal = sdk.getVersion();
        }
    }
    return retVal;
}
Also used : Path(org.eclipse.sapphire.modeling.Path) ParentSDKProjectImportOp(com.liferay.ide.project.core.model.ParentSDKProjectImportOp) SDK(com.liferay.ide.sdk.core.SDK)

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