Search in sources :

Example 26 with Path

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

the class NewLiferayPluginProjectOpMethods method getPossibleProfileIds.

public static Set<String> getPossibleProfileIds(NewLiferayPluginProjectOp op, boolean includeNewProfiles) {
    String activeProfilesValue = op.getActiveProfilesValue().content();
    Path currentLocation = op.getLocation().content();
    File param = currentLocation != null ? currentLocation.toFile() : null;
    NewLiferayProjectProvider<NewLiferayPluginProjectOp> provider = op.getProjectProvider().content(true);
    List<String> systemProfileIds = provider.getData("profileIds", String.class, param);
    ElementList<NewLiferayProfile> newLiferayProfiles = op.getNewLiferayProfiles();
    Set<String> possibleProfileIds = new HashSet<>();
    if (!CoreUtil.isNullOrEmpty(activeProfilesValue)) {
        String[] vals = activeProfilesValue.split(",");
        if (ListUtil.isNotEmpty(vals)) {
            for (String val : vals) {
                if (!possibleProfileIds.contains(val) && !val.contains(StringPool.SPACE)) {
                    possibleProfileIds.add(val);
                }
            }
        }
    }
    if (ListUtil.isNotEmpty(systemProfileIds)) {
        for (Object systemProfileId : systemProfileIds) {
            if (systemProfileId != null) {
                String val = systemProfileId.toString();
                if (!possibleProfileIds.contains(val) && !val.contains(StringPool.SPACE)) {
                    possibleProfileIds.add(val);
                }
            }
        }
    }
    if (includeNewProfiles) {
        for (NewLiferayProfile newLiferayProfile : newLiferayProfiles) {
            String newId = newLiferayProfile.getId().content();
            if (!CoreUtil.isNullOrEmpty(newId) && !possibleProfileIds.contains(newId) && !newId.contains(StringPool.SPACE)) {
                possibleProfileIds.add(newId);
            }
        }
    }
    return possibleProfileIds;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.sapphire.modeling.Path) IFile(org.eclipse.core.resources.IFile) File(java.io.File) HashSet(java.util.HashSet)

Example 27 with Path

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

the class NewLiferayPluginProjectOpMethods method updateLocation.

public static void updateLocation(NewLiferayPluginProjectOp op, Path baseLocation) {
    String projectName = getProjectNameWithSuffix(op);
    if (baseLocation == null) {
        return;
    }
    String lastSegment = baseLocation.lastSegment();
    if ((baseLocation != null) && (baseLocation.segmentCount() > 0)) {
        if (lastSegment.equals(projectName)) {
            return;
        }
    }
    Path newLocation = baseLocation.append(projectName);
    op.setLocation(newLocation);
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.sapphire.modeling.Path)

Example 28 with Path

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

the class NewLiferayPluginProjectOpMethods method supportsTypePlugin.

public static boolean supportsTypePlugin(NewLiferayPluginProjectOp op, String type) {
    boolean retval = false;
    NewLiferayProjectProvider<NewLiferayPluginProjectOp> provider = op.getProjectProvider().content(true);
    if (provider.getShortName().equals("maven") && (type.equals("web") || type.equals("theme"))) {
        return true;
    } else {
        SDK sdk = null;
        try {
            sdk = SDKUtil.getWorkspaceSDK();
        } catch (CoreException ce) {
        }
        if (sdk == null) {
            Path sdkLocation = op.getSdkLocation().content();
            if (sdkLocation != null) {
                sdk = SDKUtil.createSDKFromLocation(PathBridge.create(sdkLocation));
            }
        }
        if (sdk == null) {
            return true;
        }
        Version version = new Version(sdk.getVersion());
        boolean greaterThan700 = false;
        if (CoreUtil.compareVersions(version, ILiferayConstants.V700) >= 0) {
            greaterThan700 = true;
        }
        if ((greaterThan700 && "web".equals(type)) || ("theme".equals(type))) {
            retval = true;
        }
        if (greaterThan700 && "ext".equals(type)) {
            IPath extFolder = sdk.getLocation().append("ext");
            File buildXml = extFolder.append("build.xml").toFile();
            if (FileUtil.exists(extFolder) && FileUtil.exists(buildXml)) {
                return true;
            }
        } else if (!greaterThan700 && "ext".equals(type)) {
            return true;
        }
    }
    return retval;
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.sapphire.modeling.Path) CoreException(org.eclipse.core.runtime.CoreException) IPath(org.eclipse.core.runtime.IPath) Version(org.osgi.framework.Version) SDK(com.liferay.ide.sdk.core.SDK) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Example 29 with Path

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

the class NewLiferayPluginProjectOpMethods method updateLocation.

public static void updateLocation(NewLiferayPluginProjectOp op) {
    String currentProjectName = op.getProjectName().content();
    if (currentProjectName == null) {
        return;
    }
    boolean useDefaultLocation = op.getUseDefaultLocation().content(true);
    NewLiferayProjectProvider<NewLiferayPluginProjectOp> provider = op.getProjectProvider().content(true);
    String providerShortName = provider.getShortName();
    if (useDefaultLocation) {
        Path newLocationBase = null;
        if (providerShortName.equals("ant")) {
            SDK sdk = null;
            try {
                sdk = SDKUtil.getWorkspaceSDK();
                if (sdk != null) {
                    IStatus sdkStatus = sdk.validate();
                    if (!sdkStatus.isOK()) {
                        sdk = null;
                    }
                }
            } catch (CoreException ce) {
            }
            if (sdk == null) {
                if (op.getSdkLocation() != null) {
                    Path sdkPath = op.getSdkLocation().content();
                    if (sdkPath != null) {
                        IPath sdkLocation = PathBridge.create(sdkPath);
                        sdk = SDKUtil.createSDKFromLocation(sdkLocation);
                    }
                }
            }
            if (sdk != null) {
                Path sdkLocation = PathBridge.create(sdk.getLocation());
                switch(op.getPluginType().content(true)) {
                    case portlet:
                    case servicebuilder:
                        newLocationBase = sdkLocation.append("portlets");
                        break;
                    case ext:
                        newLocationBase = sdkLocation.append("ext");
                        break;
                    case hook:
                        newLocationBase = sdkLocation.append("hooks");
                        break;
                    case layouttpl:
                        newLocationBase = sdkLocation.append("layouttpl");
                        break;
                    case theme:
                        newLocationBase = sdkLocation.append("themes");
                        break;
                    case web:
                        newLocationBase = sdkLocation.append("webs");
                        break;
                }
            } else {
                return;
            }
        } else {
            newLocationBase = PathBridge.create(CoreUtil.getWorkspaceRoot().getLocation());
        }
        if (newLocationBase != null) {
            updateLocation(op, newLocationBase);
        }
    }
}
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) IPath(org.eclipse.core.runtime.IPath) SDK(com.liferay.ide.sdk.core.SDK)

Example 30 with Path

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

the class ParentSDKProjectImportOpMethods method execute.

public static final Status execute(ParentSDKProjectImportOp op, ProgressMonitor pm) {
    IProgressMonitor monitor = ProgressMonitorBridge.create(pm);
    monitor.beginTask("Importing Liferay parent sdk project...", 100);
    Status retval = Status.createOkStatus();
    Path sdkLocation = op.getSdkLocation().content();
    if ((sdkLocation == null) || sdkLocation.isEmpty()) {
        return Status.createErrorStatus("SDK folder cannot be empty");
    }
    SDK sdk = SDKUtil.createSDKFromLocation(PathBridge.create(sdkLocation));
    try {
        SDKUtil.openAsProject(sdk, monitor);
    } catch (CoreException ce) {
        retval = StatusBridge.create(ProjectCore.createErrorStatus(ce));
    }
    return retval;
}
Also used : Status(org.eclipse.sapphire.modeling.Status) Path(org.eclipse.sapphire.modeling.Path) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) 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