Esempio n. 1
0
  protected void applyDiffsDeltaToDocroot(
      final IResourceDelta delta, final IContainer docroot, final IProgressMonitor monitor) {
    int deltaKind = delta.getKind();

    switch (deltaKind) {
      case IResourceDelta.REMOVED_PHANTOM:
        break;
    }

    final IPath path = CoreUtil.getResourceLocation(docroot);
    // final IPath restoreLocation = getRestoreLocation(docroot);

    final ILiferayProject liferayProject = LiferayCore.create(getProject());

    final String themeParent = liferayProject.getProperty("theme.parent", "_styled");

    final ILiferayPortal portal = liferayProject.adapt(ILiferayPortal.class);

    if (portal != null) {
      final IPath themesPath = portal.getAppServerPortalDir().append("html/themes");
      final List<IPath> restorePaths = new ArrayList<IPath>();

      for (int i = 0; i < IPluginProjectDataModelProperties.THEME_PARENTS.length; i++) {
        if (IPluginProjectDataModelProperties.THEME_PARENTS[i].equals(themeParent)) {
          restorePaths.add(themesPath.append(IPluginProjectDataModelProperties.THEME_PARENTS[i]));
        } else {
          if (restorePaths.size() > 0) {
            restorePaths.add(themesPath.append(IPluginProjectDataModelProperties.THEME_PARENTS[i]));
          }
        }
      }

      new Job("publish theme delta") // $NON-NLS-1$
      {
        @Override
        protected IStatus run(IProgressMonitor monitor) {
          buildHelper.publishDelta(delta, path, restorePaths.toArray(new IPath[0]), monitor);

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

          return Status.OK_STATUS;
        }
      }.schedule();
    }
  }
Esempio n. 2
0
  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$
        }
      }
    }
  }