Search in sources :

Example 36 with Status

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

the class NewLiferayModuleProjectOpTests method testNewLiferayModuleProjectNewProperties.

@Test
public void testNewLiferayModuleProjectNewProperties() throws Exception {
    NewLiferayModuleProjectOp op = NewLiferayModuleProjectOp.TYPE.instantiate();
    op.setProjectName("test-properties-in-portlet");
    op.setProjectTemplateName("portlet");
    op.setComponentName("Test");
    PropertyKey pk = op.getPropertyKeys().insert();
    pk.setName("property-test-key");
    pk.setValue("property-test-value");
    Status exStatus = NewLiferayModuleProjectOpMethods.execute(op, ProgressMonitorBridge.create(new NullProgressMonitor()));
    assertEquals("OK", exStatus.message());
    IProject modPorject = CoreUtil.getProject(op.getProjectName().content());
    modPorject.open(new NullProgressMonitor());
    SearchFilesVisitor sv = new SearchFilesVisitor();
    List<IFile> searchFiles = sv.searchFiles(modPorject, "TestPortlet.java");
    IFile componentClassFile = searchFiles.get(0);
    assertEquals(componentClassFile.exists(), true);
    String actual = CoreUtil.readStreamToString(componentClassFile.getContents());
    assertTrue(actual, actual.contains("\"property-test-key=property-test-value\""));
}
Also used : Status(org.eclipse.sapphire.modeling.Status) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) NewLiferayModuleProjectOp(com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp) SearchFilesVisitor(com.liferay.ide.project.core.util.SearchFilesVisitor) PropertyKey(com.liferay.ide.project.core.modules.PropertyKey) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 37 with Status

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

the class NewLiferayModuleProjectOpTests method testNewLiferayPortletProviderNewProperties.

@Test
public void testNewLiferayPortletProviderNewProperties() throws Exception {
    NewLiferayModuleProjectOp op = NewLiferayModuleProjectOp.TYPE.instantiate();
    op.setProjectName("test-properties-in-portlet-provider");
    op.setComponentName("Test");
    op.setProjectTemplateName("portlet-provider");
    PropertyKey pk = op.getPropertyKeys().insert();
    pk.setName("property-test-key");
    pk.setValue("property-test-value");
    Status exStatus = NewLiferayModuleProjectOpMethods.execute(op, ProgressMonitorBridge.create(new NullProgressMonitor()));
    assertTrue(exStatus.message(), exStatus.ok());
    IProject modPorject = CoreUtil.getProject(op.getProjectName().content());
    modPorject.open(new NullProgressMonitor());
    IFile testAddPortletProvider = modPorject.getFile("src/main/java/test/properties/in/portlet/provider/portlet/TestAddPortletProvider.java");
    assertTrue(testAddPortletProvider.exists());
    SearchFilesVisitor sv = new SearchFilesVisitor();
    List<IFile> searchFiles = sv.searchFiles(modPorject, "TestAddPortletProvider.java");
    IFile componentClassFile = searchFiles.get(0);
    assertEquals(componentClassFile.exists(), true);
    String actual = CoreUtil.readStreamToString(componentClassFile.getContents());
    assertTrue(actual.contains("property-test-key=property-test-value"));
}
Also used : Status(org.eclipse.sapphire.modeling.Status) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) NewLiferayModuleProjectOp(com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp) SearchFilesVisitor(com.liferay.ide.project.core.util.SearchFilesVisitor) PropertyKey(com.liferay.ide.project.core.modules.PropertyKey) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 38 with Status

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

the class NewLiferayPluginProjectOp625Tests method testProjectNameValidationServiceAfterProjectCreated.

@Test
public void testProjectNameValidationServiceAfterProjectCreated() throws Exception {
    if (shouldSkipBundleTests())
        return;
    // test service-builder project
    NewLiferayPluginProjectOp opCreateProjectA = newProjectOp("test-project-name");
    opCreateProjectA.setIncludeSampleCode(false);
    opCreateProjectA.setPluginType(PluginType.portlet);
    createAntProject(opCreateProjectA);
    Status projectNameAValidationResult = opCreateProjectA.getProjectName().validation();
    assertEquals(true, projectNameAValidationResult.ok());
    NewLiferayPluginProjectOp opCreateProjectB = newProjectOp("test-project-name");
    Status projectNameBValidationResult = opCreateProjectB.getProjectName().validation();
    assertEquals(false, projectNameBValidationResult.ok());
}
Also used : Status(org.eclipse.sapphire.modeling.Status) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) Test(org.junit.Test)

Example 39 with Status

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

the class BundleUrlValidationService method compute.

@Override
protected Status compute() {
    Status retval = Status.createOkStatus();
    Value<String> bundleUrlValue = _op().getBundleUrl();
    String bundleUrl = bundleUrlValue.content();
    try {
        new URI(bundleUrl);
    } catch (Exception e) {
        retval = Status.createErrorStatus("The bundle URL should be a vaild URL.");
    }
    return retval;
}
Also used : Status(org.eclipse.sapphire.modeling.Status) URI(org.apache.xerces.util.URI)

Example 40 with Status

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

the class ProjectLocationValidationService method compute.

@Override
protected Status compute() {
    Status retval = Status.createOkStatus();
    int countPossibleWorkspaceSDKProjects = SDKUtil.countPossibleWorkspaceSDKProjects();
    if (countPossibleWorkspaceSDKProjects > 1) {
        return StatusBridge.create(ProjectCore.createErrorStatus("This workspace has more than one SDK."));
    }
    Value<Path> sdkLocation = _op().getSdkLocation();
    final Path location = sdkLocation.content(true);
    if ((location == null) || location.isEmpty()) {
        return StatusBridge.create(ProjectCore.createErrorStatus("Liferay Plugins SDK or Maven location is empty."));
    }
    IStatus buildType = ImportLiferayModuleProjectOpMethods.getBuildType(location.removeFileExtension().toPortableString());
    SDK sdk = SDKUtil.createSDKFromLocation(PathBridge.create(location));
    if (sdk != null) {
        String version = sdk.getVersion();
        if (version != null) {
            Version sdkVersion = new Version(version);
            int result = sdkVersion.compareTo(new Version("6.1.0"));
            if (result < 0) {
                return StatusBridge.create(ProjectCore.createErrorStatus("This tool doesn't support 6.0.x."));
            }
        }
    } else if (!buildType.getMessage().equals("maven")) {
        return StatusBridge.create(ProjectCore.createErrorStatus("Plugins SDK or Maven location is not valid."));
    }
    return retval;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.sapphire.modeling.Status) Path(org.eclipse.sapphire.modeling.Path) IStatus(org.eclipse.core.runtime.IStatus) Version(org.osgi.framework.Version) SDK(com.liferay.ide.sdk.core.SDK)

Aggregations

Status (org.eclipse.sapphire.modeling.Status)83 IProject (org.eclipse.core.resources.IProject)33 Test (org.junit.Test)31 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)29 IStatus (org.eclipse.core.runtime.IStatus)25 Path (org.eclipse.sapphire.modeling.Path)18 CoreException (org.eclipse.core.runtime.CoreException)15 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)15 NewLiferayJSFModuleProjectOp (com.liferay.ide.project.core.jsf.NewLiferayJSFModuleProjectOp)14 IFile (org.eclipse.core.resources.IFile)12 IPath (org.eclipse.core.runtime.IPath)11 NewLiferayPluginProjectOp (com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)10 NewLiferayModuleProjectOp (com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp)9 SDK (com.liferay.ide.sdk.core.SDK)9 File (java.io.File)6 NewLiferayComponentOp (com.liferay.ide.project.core.modules.NewLiferayComponentOp)5 IRuntime (org.eclipse.wst.server.core.IRuntime)5 PropertyKey (com.liferay.ide.project.core.modules.PropertyKey)3 NewModuleFragmentOp (com.liferay.ide.project.core.modules.fragment.NewModuleFragmentOp)3 ArrayList (java.util.ArrayList)3