@Override
  protected Object run(Presentation context) {
    final NewModuleFragmentOp op =
        context.part().getModelElement().nearest(NewModuleFragmentOp.class);

    final ElementList<OverrideFilePath> currentFiles = op.getOverrideFiles();

    final String projectName = op.getProjectName().content();

    final OSGiBundleFileSelectionDialog dialog =
        new OSGiBundleFileSelectionDialog(null, currentFiles, projectName);

    final String runtimeName = op.getLiferayRuntimeName().content();

    final IRuntime runtime = ServerUtil.getRuntime(runtimeName);

    final IPath temp = GradleCore.getDefault().getStateLocation();

    dialog.setTitle("Add files from OSGi bundle to override");

    final PortalBundle portalBundle = LiferayServerCore.newPortalBundle(runtime.getLocation());
    String currentOSGiBundle = op.getHostOsgiBundle().content();

    if (!currentOSGiBundle.endsWith("jar")) {
      currentOSGiBundle = currentOSGiBundle + ".jar";
    }

    ServerUtil.getModuleFileFrom70Server(runtime, currentOSGiBundle, temp);

    if (portalBundle != null) {
      try {
        File module =
            portalBundle.getOSGiBundlesDir().append("modules").append(currentOSGiBundle).toFile();

        if (!module.exists()) {
          module = GradleCore.getDefault().getStateLocation().append(currentOSGiBundle).toFile();
        }

        dialog.setInput(module);
      } catch (Exception e) {
      }
    }

    if (dialog.open() == Window.OK) {
      Object[] selected = dialog.getResult();

      for (int i = 0; i < selected.length; i++) {
        OverrideFilePath file = op.getOverrideFiles().insert();
        file.setValue(selected[i].toString());
      }
    }

    return Status.createOkStatus();
  }
  @Override
  public void initialize(IPath containerPath, IJavaProject project) throws CoreException {
    IClasspathContainer classpathContainer = null;

    String root = containerPath.segment(0);

    if (!SDKClasspathContainer.ID.equals(root)) {
      final String msg =
          "Invalid plugin classpath container, expecting container root "; //$NON-NLS-1$
      throw new CoreException(ProjectCore.createErrorStatus(msg + SDKClasspathContainer.ID));
    }

    PortalBundle bundle = ServerUtil.getPortalBundle(project.getProject());

    if (bundle == null) {
      final String msg = "Invalid sdk properties setting.";
      throw new CoreException(ProjectCore.createErrorStatus(msg));
    }

    IPath globalDir = bundle.getAppServerLibGlobalDir();

    IPath portalDir = bundle.getAppServerPortalDir();

    IPath bundleDir = bundle.getAppServerDir();

    IPath[] bundleDependencyLibDir = bundle.getBundleDependencyJars();

    if (portalDir == null) {
      return;
    }

    classpathContainer =
        new SDKClasspathContainer(
            containerPath,
            project,
            portalDir,
            null,
            null,
            globalDir,
            bundleDir,
            bundleDependencyLibDir);

    JavaCore.setClasspathContainer(
        containerPath,
        new IJavaProject[] {project},
        new IClasspathContainer[] {classpathContainer},
        null);
  }
  @Override
  public void requestClasspathContainerUpdate(
      IPath containerPath, IJavaProject project, IClasspathContainer containerSuggestion)
      throws CoreException {

    final String key =
        SDKClasspathContainer.getDecorationManagerKey(
            project.getProject(), containerPath.toString());

    final IClasspathEntry[] entries = containerSuggestion.getClasspathEntries();

    cpDecorations.clearAllDecorations(key);

    for (int i = 0; i < entries.length; i++) {
      final IClasspathEntry entry = entries[i];

      final IPath srcpath = entry.getSourceAttachmentPath();
      final IPath srcrootpath = entry.getSourceAttachmentRootPath();
      final IClasspathAttribute[] attrs = entry.getExtraAttributes();

      if (srcpath != null || attrs.length > 0) {
        final String eid = entry.getPath().toString();
        final ClasspathDecorations dec = new ClasspathDecorations();

        dec.setSourceAttachmentPath(srcpath);
        dec.setSourceAttachmentRootPath(srcrootpath);
        dec.setExtraAttributes(attrs);

        cpDecorations.setDecorations(key, eid, dec);
      }
    }

    cpDecorations.save();

    IPath portalDir = null;
    IPath portalGlobalDir = null;
    String javadocURL = null;
    IPath sourceLocation = null;
    IPath bundleDir = null;
    IPath[] bundleLibDependencyPath = null;

    if (containerSuggestion instanceof SDKClasspathContainer) {
      portalDir = ((SDKClasspathContainer) containerSuggestion).getPortalDir();
      bundleDir = ((SDKClasspathContainer) containerSuggestion).getBundleDir();
      portalGlobalDir = ((SDKClasspathContainer) containerSuggestion).getPortalGlobalDir();
      javadocURL = ((SDKClasspathContainer) containerSuggestion).getJavadocURL();
      sourceLocation = ((SDKClasspathContainer) containerSuggestion).getSourceLocation();
      bundleLibDependencyPath =
          ((SDKClasspathContainer) containerSuggestion).getBundleLibDependencyPath();
    } else {
      PortalBundle bundle = ServerUtil.getPortalBundle(project.getProject());

      if (bundle == null) {
        final String msg = "Invalid sdk properties setting.";
        throw new CoreException(ProjectCore.createErrorStatus(msg));
      }

      portalDir = bundle.getAppServerPortalDir();
      portalGlobalDir = bundle.getAppServerLibGlobalDir();
      bundleLibDependencyPath = bundle.getBundleDependencyJars();
    }

    if (portalDir != null && portalGlobalDir != null) {
      IClasspathContainer newContainer =
          new SDKClasspathContainer(
              containerPath,
              project,
              portalDir,
              javadocURL,
              sourceLocation,
              portalGlobalDir,
              bundleDir,
              bundleLibDependencyPath);

      JavaCore.setClasspathContainer(
          containerPath,
          new IJavaProject[] {project},
          new IClasspathContainer[] {newContainer},
          null);
    }
  }