コード例 #1
0
  public static final Status execute(final NewLiferayPluginProjectOp op, final ProgressMonitor pm) {
    final IProgressMonitor monitor = ProgressMonitorBridge.create(pm);

    monitor.beginTask(
        "Creating Liferay plugin project (this process may take several minutes)",
        100); //$NON-NLS-1$

    Status retval = null;

    try {
      final NewLiferayProjectProvider<NewLiferayPluginProjectOp> projectProvider =
          op.getProjectProvider().content(true);

      // IDE-1306  If the user types too quickly all the model changes may not have propagated
      final Path projectLocation = op.getLocation().content();
      updateLocation(op, projectLocation);

      final IStatus status = projectProvider.createNewProject(op, monitor);

      if (status.isOK()) {
        updateProjectPrefs(op);

        removeSampleCodeAndFiles(op);
      }

      retval = StatusBridge.create(status);
    } catch (Exception e) {
      final String msg = "Error creating Liferay plugin project."; // $NON-NLS-1$
      ProjectCore.logError(msg, e);

      return Status.createErrorStatus(msg + " Please see Eclipse error log for more details.", e);
    }

    return retval;
  }
コード例 #2
0
  @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\""));
  }
コード例 #3
0
  public static final Status execute(final UpgradeLiferayProjectsOp op, final ProgressMonitor pm) {
    Status retval = Status.createOkStatus();

    final IProgressMonitor monitor = ProgressMonitorBridge.create(pm);

    monitor.beginTask(
        "Upgrading Liferay plugin projects (this process may take several minutes)", 30);

    final ElementList<NamedItem> projectItems = op.getSelectedProjects();
    final ElementList<NamedItem> upgradeActions = op.getSelectedActions();
    final String runtimeName = op.getRuntimeName().content();
    final List<String> projectItemNames = new ArrayList<String>();
    final List<String> projectActionItems = new ArrayList<String>();

    for (NamedItem projectItem : projectItems) {
      projectItemNames.add(projectItem.getName().content());
    }

    for (NamedItem upgradeAction : upgradeActions) {
      projectActionItems.add(upgradeAction.getName().content());
    }

    Status[] upgradeStatuses =
        performUpgrade(projectItemNames, projectActionItems, runtimeName, monitor);

    for (Status s : upgradeStatuses) {
      if (!s.ok()) {
        retval =
            Status.createErrorStatus(
                "Some upgrade actions failed, please see Eclipse error log for more details");
      }
    }

    return retval;
  }