コード例 #1
0
  public static IStatus cssBuild(IProject project) throws CoreException {

    SDK sdk = SDKUtil.getSDK(project);

    if (sdk == null) {
      throw new CoreException(
          ThemeCore.createErrorStatus("No SDK for project configured. Could not build theme."));
    }

    ILiferayRuntime liferayRuntime = ServerUtil.getLiferayRuntime(project);

    if (liferayRuntime == null) {
      throw new CoreException(
          ThemeCore.createErrorStatus(
              "Could not get portal runtime for project.  Could not build theme."));
    }

    Map<String, String> appServerProperties = ServerUtil.configureAppServerProperties(project);

    IStatus status = sdk.compileThemePlugin(project, null, appServerProperties);

    if (!status.isOK()) {
      throw new CoreException(status);
    }

    IFolder docroot = CoreUtil.getDocroot(project);

    IFile lookAndFeelFile =
        docroot.getFile("WEB-INF/" + ILiferayConstants.LIFERAY_LOOK_AND_FEEL_XML_FILE);

    if (!lookAndFeelFile.exists()) {
      String id = project.getName().replaceAll(ISDKConstants.THEME_PLUGIN_PROJECT_SUFFIX, "");
      IFile propsFile =
          docroot.getFile("WEB-INF/" + ILiferayConstants.LIFERAY_PLUGIN_PACKAGE_PROPERTIES_FILE);
      String name = id;
      if (propsFile.exists()) {
        Properties props = new Properties();
        try {
          props.load(propsFile.getContents());
          String nameValue = props.getProperty("name");
          if (!CoreUtil.isNullOrEmpty(nameValue)) {
            name = nameValue;
          }
        } catch (IOException e) {
          ThemeCore.logError("Unable to load plugin package properties.", e);
        }
      }

      if (liferayRuntime != null) {
        ThemeDescriptorHelper.createDefaultFile(
            lookAndFeelFile, liferayRuntime.getPortalVersion() + "+", id, name);
      }
    }

    if (docroot != null && docroot.exists()) {
      docroot.refreshLocal(IResource.DEPTH_INFINITE, null);
    }

    return status;
  }
コード例 #2
0
ファイル: ThemeCSSBuilder.java プロジェクト: of17/liferay-ide
  public static IStatus compileTheme(IProject project) throws CoreException {
    final SDK sdk = SDKUtil.getSDK(project);

    if (sdk == null) {
      throw new CoreException(
          ThemeCore.createErrorStatus(
              "No SDK for project configured. Could not build theme.")); //$NON-NLS-1$
    }

    final IStatus status = sdk.compileThemePlugin(project, null);

    if (!status.isOK()) {
      throw new CoreException(status);
    }

    ensureLookAndFeelFileExists(project);

    try {
      project.refreshLocal(IResource.DEPTH_INFINITE, null);
    } catch (Exception e) {
      ThemeCore.logError(e);
    }

    return status;
  }
コード例 #3
0
ファイル: ThemeCSSBuilder.java プロジェクト: of17/liferay-ide
  protected void incrementalBuild(IResourceDelta delta, final IProgressMonitor monitor) {
    int deltaKind = delta.getKind();

    if (deltaKind == IResourceDelta.REMOVED) {
      return;
    }

    // final boolean[] buildCSS = new boolean[1];

    try {
      delta.accept(
          new IResourceDeltaVisitor() {
            public boolean visit(IResourceDelta delta) {
              final IResource resource = delta.getResource();
              IPath fullResourcePath = resource.getFullPath();

              for (String segment : fullResourcePath.segments()) {
                if ("_diffs".equals(segment)) // $NON-NLS-1$
                {
                  // IDE-110 IDE-648
                  final IWebProject webproject =
                      LiferayCore.create(IWebProject.class, getProject());

                  if (webproject != null && webproject.getDefaultDocrootFolder() != null) {
                    IFolder webappRoot = webproject.getDefaultDocrootFolder();

                    if (webappRoot != null) {
                      IFolder diffs = webappRoot.getFolder(new Path("_diffs")); // $NON-NLS-1$

                      if (diffs != null
                          && diffs.exists()
                          && diffs.getFullPath().isPrefixOf(fullResourcePath)) {
                        applyDiffsDeltaToDocroot(delta, diffs.getParent(), monitor);

                        return false;
                      }
                    }
                  }
                } else if ("build.xml".equals(segment)) // IDE-828 //$NON-NLS-1$
                {
                  IPath relPath = resource.getProjectRelativePath();

                  if (relPath != null && relPath.segmentCount() == 1) {
                    try {
                      compileTheme(resource.getProject());
                    } catch (CoreException e) {
                      ThemeCore.logError("Error compiling theme.", e); // $NON-NLS-1$
                    }
                  }
                }
              }

              return true; // visit children too
            }
          });
    } catch (CoreException e) {
      ThemeCore.logError(e);
    }
  }
コード例 #4
0
 protected void fullBuild(Map args, IProgressMonitor monitor) {
   try {
     if (shouldFullBuild(args)) {
       cssBuild(getProject(args));
     }
   } catch (Exception e) {
     ThemeCore.logError("Full build failed for Theme CSS Builder", e);
   }
 }
コード例 #5
0
  protected void incrementalBuild(IResourceDelta delta, IProgressMonitor monitor) {
    int deltaKind = delta.getKind();

    if (deltaKind == IResourceDelta.REMOVED || deltaKind == IResourceDelta.REMOVED_PHANTOM) {
      return;
    }

    final boolean[] buildCSS = new boolean[1];

    try {
      delta.accept(
          new IResourceDeltaVisitor() {

            private IFolder docroot = null;

            public boolean visit(IResourceDelta delta) {
              IPath fullResourcePath = delta.getResource().getFullPath();

              for (String segment : fullResourcePath.segments()) {
                if ("_diffs".equals(segment)) {
                  if (docroot == null) {
                    docroot = CoreUtil.getDocroot(getProject());
                  }

                  IFolder diffs = docroot.getFolder("_diffs");

                  if (diffs.exists() && diffs.getFullPath().isPrefixOf(fullResourcePath)) {
                    buildCSS[0] = true;

                    return false;
                  }
                }
              }

              return true; // visit children too
            }
          });
    } catch (CoreException e) {
      e.printStackTrace();
    }

    if (buildCSS[0]) {
      try {
        cssBuild(getProject());
      } catch (CoreException e) {
        ThemeCore.logError("Error in Theme CSS Builder", e);
      }
    }
  }
コード例 #6
0
ファイル: ThemeCSSBuilder.java プロジェクト: of17/liferay-ide
  public static void ensureLookAndFeelFileExists(IProject project) throws CoreException {
    // IDE-110 IDE-648
    final IWebProject lrProject = LiferayCore.create(IWebProject.class, project);

    if (lrProject == null) {
      return;
    }

    IFile lookAndFeelFile = null;

    final IResource res =
        lrProject.findDocrootResource(
            new Path("WEB-INF/" + ILiferayConstants.LIFERAY_LOOK_AND_FEEL_XML_FILE));

    if (res instanceof IFile && res.exists()) {
      lookAndFeelFile = (IFile) res;
    }

    if (lookAndFeelFile == null) {
      // need to generate a new lnf file in deafult docroot
      String id =
          project.getName().replaceAll(ISDKConstants.THEME_PLUGIN_PROJECT_SUFFIX, StringPool.EMPTY);

      final IResource propertiesFileRes =
          lrProject.findDocrootResource(
              new Path("WEB-INF/" + ILiferayConstants.LIFERAY_PLUGIN_PACKAGE_PROPERTIES_FILE));
      String name = id;

      if (propertiesFileRes instanceof IFile && propertiesFileRes.exists()) {
        Properties props = new Properties();

        try {
          final IFile propsFile = (IFile) propertiesFileRes;
          final InputStream contents = propsFile.getContents();

          props.load(contents);
          contents.close();

          final String nameValue = props.getProperty("name"); // $NON-NLS-1$

          if (!CoreUtil.isNullOrEmpty(nameValue)) {
            name = nameValue;
          }

          final ThemeDescriptorHelper themeDescriptorHelper = new ThemeDescriptorHelper(project);

          final ILiferayProject lProject = lrProject;
          final ILiferayPortal portal = lProject.adapt(ILiferayPortal.class);
          String version = "6.2.0";

          if (portal != null) {
            version = portal.getVersion();
          }

          final String themeType = lProject.getProperty("theme.type", "vm");

          themeDescriptorHelper.createDefaultFile(
              lrProject.getDefaultDocrootFolder().getFolder("WEB-INF"),
              version,
              id,
              name,
              themeType);
        } catch (IOException e) {
          ThemeCore.logError("Unable to load plugin package properties.", e); // $NON-NLS-1$
        }
      }
    }
  }