/* (non-Javadoc)
  * @see com.aptana.ide.core.ftp.BaseFTPConnectionFileManager#renameFile(org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IProgressMonitor)
  */
 @Override
 protected void renameFile(IPath sourcePath, IPath destinationPath, IProgressMonitor monitor)
     throws CoreException, FileNotFoundException {
   try {
     changeCurrentDir(Path.ROOT);
     Policy.checkCanceled(monitor);
     try {
       ftpClient.rename(sourcePath.toPortableString(), destinationPath.toPortableString());
     } catch (FTPException e) {
       throwFileNotFound(e, sourcePath);
       System.out.println(e);
       throw e;
     }
   } catch (FileNotFoundException e) {
     throw e;
   } catch (OperationCanceledException e) {
     throw e;
   } catch (Exception e) {
     throw new CoreException(
         new Status(
             Status.ERROR,
             FTPPlugin.PLUGIN_ID,
             Messages.FTPConnectionFileManager_renaming_failed,
             e));
   } finally {
     monitor.done();
   }
 }
Ejemplo n.º 2
0
  private static void addRemoveProps(
      IPath deltaPath,
      IResource deltaResource,
      ZipOutputStream zip,
      Map<ZipEntry, String> deleteEntries,
      String deletePrefix)
      throws IOException {

    String archive = removeArchive(deltaPath.toPortableString());

    ZipEntry zipEntry = null;

    // check to see if we already have an entry for this archive
    for (ZipEntry entry : deleteEntries.keySet()) {
      if (entry.getName().startsWith(archive)) {
        zipEntry = entry;
      }
    }

    if (zipEntry == null) {
      zipEntry = new ZipEntry(archive + "META-INF/" + deletePrefix + "-partialapp-delete.props");
    }

    String existingFiles = deleteEntries.get(zipEntry);

    // String file = encodeRemovedPath(deltaPath.toPortableString().substring(archive.length()));
    String file = deltaPath.toPortableString().substring(archive.length());

    if (deltaResource.getType() == IResource.FOLDER) {
      file += "/.*";
    }

    deleteEntries.put(zipEntry, (existingFiles != null ? existingFiles : "") + (file + "\n"));
  }
 /**
  * Show source disassembly view.
  *
  * @param workingDir working directory.
  */
 private void showSourceDisassembly(IPath workingDir) {
   String title = renderProcessLabel(workingDir.toPortableString() + PerfPlugin.PERF_DEFAULT_DATA);
   SourceDisassemblyData sdData = new SourceDisassemblyData(title, workingDir, project);
   sdData.parse();
   PerfPlugin.getDefault().setSourceDisassemblyData(sdData);
   SourceDisassemblyView.refreshView();
 }
Ejemplo n.º 4
0
 /* (non-Javadoc)
  * @see com.aptana.ide.core.io.ConnectionPoint#saveState(com.aptana.ide.core.io.epl.IMemento)
  */
 @Override
 protected void saveState(IMemento memento) {
   super.saveState(memento);
   memento.createChild(ELEMENT_HOST).putTextData(host);
   if (IFTPSConstants.FTP_PORT_DEFAULT != port) {
     memento.createChild(ELEMENT_PORT).putTextData(Integer.toString(port));
   }
   if (!Path.ROOT.equals(path)) {
     memento.createChild(ELEMENT_PATH).putTextData(path.toPortableString());
   }
   if (login.length() != 0) {
     memento.createChild(ELEMENT_LOGIN).putTextData(login);
   }
   memento.createChild(ELEMENT_EXPLICIT).putTextData(Boolean.toString(explicit));
   memento
       .createChild(ELEMENT_VALIDATE_CERTIFICATE)
       .putTextData(Boolean.toString(validateCertificate));
   if (noSSLSessionResumption) {
     memento
         .createChild(ELEMENT_NO_SSL_SESSION_RESUMPTION)
         .putTextData(Boolean.toString(noSSLSessionResumption));
   }
   memento.createChild(ELEMENT_PASSIVE).putTextData(Boolean.toString(passiveMode));
   if (!IFTPSConstants.TRANSFER_TYPE_AUTO.equals(transferType)) {
     memento.createChild(ELEMENT_TRANSFER_TYPE).putTextData(transferType);
   }
   if (!IFTPSConstants.ENCODING_DEFAULT.equals(encoding)) {
     memento.createChild(ELEMENT_ENCODING).putTextData(encoding);
   }
   if (timezone != null && timezone.length() != 0) {
     memento.createChild(ELEMENT_TIMEZONE).putTextData(timezone);
   }
 }
Ejemplo n.º 5
0
 public static IErlProject createProject(final IPath path, final String name)
     throws CoreException {
   final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
   final IProject project2 = root.getProject(name);
   try {
     project2.delete(true, null);
   } catch (final CoreException x) {
     // ignore
   }
   final IErlProject erlProject =
       ErlangEngine.getInstance().getModel().newProject(name, path.toPortableString());
   final IProject project = erlProject.getWorkspaceProject();
   final IErlangProjectProperties prefs = new OldErlangProjectProperties(project);
   final List<IPath> srcDirs = new ArrayList<IPath>();
   srcDirs.add(new Path("src"));
   prefs.setSourceDirs(srcDirs);
   buildPaths(root, project, srcDirs);
   final List<IPath> includeDirs = new ArrayList<IPath>();
   includeDirs.add(new Path("include"));
   buildPaths(root, project, includeDirs);
   prefs.setIncludeDirs(includeDirs);
   final List<IPath> ebinDirs = new ArrayList<IPath>();
   ebinDirs.add(new Path("ebin"));
   buildPaths(root, project, ebinDirs);
   prefs.setOutputDir(ebinDirs.get(0));
   projects.add(erlProject);
   return erlProject;
 }
  private void saveConfigInfoIntoCache(String configType, String configInfo, IPath portalDir) {
    IPath versionsInfoPath = null;

    if (configType.equals(CONFIG_TYPE_VERSION)) {
      versionsInfoPath =
          LiferayServerCore.getDefault().getStateLocation().append("version.properties");
    } else if (configType.equals(CONFIG_TYPE_SERVER)) {
      versionsInfoPath =
          LiferayServerCore.getDefault().getStateLocation().append("serverInfos.properties");
    }

    if (versionsInfoPath != null) {
      File versionInfoFile = versionsInfoPath.toFile();

      if (configInfo != null) {
        String portalDirKey = CoreUtil.createStringDigest(portalDir.toPortableString());
        Properties properties = new Properties();

        try (FileInputStream fileInput = new FileInputStream(versionInfoFile)) {
          properties.load(fileInput);
        } catch (Exception e) {
        }

        try (FileOutputStream fileOutput = new FileOutputStream(versionInfoFile)) {
          properties.put(portalDirKey, configInfo);
          properties.store(fileOutput, StringPool.EMPTY);
        } catch (Exception e) {
          LiferayServerCore.logError(e);
        }
      }
    }
  }
 /* (non-Javadoc)
  * @see com.aptana.ide.core.ftp.BaseFTPConnectionFileManager#createDirectory(org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IProgressMonitor)
  */
 @Override
 protected void createDirectory(IPath path, IProgressMonitor monitor)
     throws CoreException, FileNotFoundException {
   try {
     try {
       try {
         changeCurrentDir(path);
         return; // directory exists - return
       } catch (FileNotFoundException ignore) {
       }
       ftpClient.mkdir(path.toPortableString());
       changeFilePermissions(path, PreferenceUtils.getDirectoryPermissions(), monitor);
     } catch (FTPException e) {
       throwFileNotFound(e, path);
     }
   } catch (FileNotFoundException e) {
     throw e;
   } catch (Exception e) {
     throw new CoreException(
         new Status(
             Status.ERROR,
             FTPPlugin.PLUGIN_ID,
             Messages.FTPConnectionFileManager_creating_directory_failed,
             e));
   }
 }
 @Override
 public void setPageComplete(boolean complete) {
   if (packageNameIsDiscouraged()) {
     setMessage(getDiscouragedNamespaceMessage(), WARNING);
   } else {
     setMessage(null);
   }
   if (complete) {
     if (!packageFragment.exists()) {
       setMessage(
           "Package does not exist: " + packageFragment.getElementName(), IMessageProvider.ERROR);
       super.setPageComplete(false);
       return;
     }
     for (String file : getFileNames()) {
       IPath path = packageFragment.getPath().append(file).addFileExtension("ceylon");
       if (getWorkspace().getRoot().getFile(path).exists()) {
         setMessage(
             "Existing unit will not be overwritten: " + path.toPortableString(),
             IMessageProvider.ERROR);
         super.setPageComplete(false);
         return;
       }
     }
     MoveToNewUnitRefactoring refactoring = (MoveToNewUnitRefactoring) getRefactoring();
     refactoring.setTargetProject(getPackageFragment().getResource().getProject());
     refactoring.setTargetFile(getFile());
     refactoring.setTargetPackage(getPackageFragment());
     refactoring.setIncludePreamble(isIncludePreamble());
   }
   super.setPageComplete(complete);
 }
 private static void throwFileNotFound(FTPException e, IPath path)
     throws FileNotFoundException, FTPException {
   int code = e.getReplyCode();
   if (code == 550 || code == 450) {
     throw new FileNotFoundException(path.toPortableString());
   }
   throw e;
 }
 private static String encodePath(IPath path) {
   if (path == null) {
     return "#"; //$NON-NLS-1$
   } else if (path.isEmpty()) {
     return "&"; //$NON-NLS-1$
   } else {
     return encode(path.toPortableString());
   }
 }
Ejemplo n.º 11
0
 private File getCoreStubsDir() {
   IPath[] paths = RubyCore.getLoadpathVariable(RubyRuntime.RUBYLIB_VARIABLE);
   for (int i = 0; i < paths.length; i++) {
     IPath path = paths[i];
     if (path.toPortableString().contains(".metadata")) {
       return path.toFile();
     }
   }
   return null;
 }
 private void recursiveDeleteTree(IPath path, IProgressMonitor monitor, MultiStatus status)
     throws IOException, ParseException {
   try {
     changeCurrentDir(path);
     FTPFile[] ftpFiles = listFiles(path, monitor);
     List<String> dirs = new ArrayList<String>();
     for (FTPFile ftpFile : ftpFiles) {
       String name = ftpFile.getName();
       if (".".equals(name) || "..".equals(name)) { // $NON-NLS-1$ //$NON-NLS-2$
         continue;
       }
       if (ftpFile.isDir()) {
         dirs.add(name);
         continue;
       }
       Policy.checkCanceled(monitor);
       monitor.subTask(path.append(name).toPortableString());
       try {
         ftpClient.delete(name);
       } catch (FTPException e) {
         status.add(
             new Status(
                 IStatus.ERROR,
                 FTPPlugin.PLUGIN_ID,
                 StringUtils.format(
                     Messages.FTPConnectionFileManager_deleting_failed,
                     path.append(name).toPortableString()),
                 e));
       }
       monitor.worked(1);
     }
     for (String name : dirs) {
       monitor.subTask(path.append(name).toPortableString());
       recursiveDeleteTree(path.append(name), monitor, status);
       Policy.checkCanceled(monitor);
       changeCurrentDir(path);
       Policy.checkCanceled(monitor);
       ftpClient.rmdir(name);
       monitor.worked(1);
     }
   } catch (IOException e) {
     throw e;
   } catch (Exception e) {
     status.add(
         new Status(
             IStatus.ERROR,
             FTPPlugin.PLUGIN_ID,
             StringUtils.format(
                 Messages.FTPConnectionFileManager_deleting_failed, path.toPortableString()),
             e));
   }
 }
  private IStatus remoteDeploy(String bsn, IPath output) {
    IStatus retval = null;

    final BundleDeployer deployer = getBundleDeployer();

    if (output != null && output.toFile().exists()) {
      try {
        long bundleId = deployer.deployBundle(bsn, output.toFile());

        retval = new Status(IStatus.OK, LiferayServerCore.PLUGIN_ID, (int) bundleId, null, null);
      } catch (Exception e) {
        retval =
            LiferayServerCore.error(
                "Unable to deploy bundle remotely " + output.toPortableString(), e);
      }
    } else {
      retval =
          LiferayServerCore.error("Unable to deploy bundle remotely " + output.toPortableString());
    }

    return retval;
  }
 private String getPathString(IPath path, boolean isExternal) {
   //		if (ArchiveFileFilter.isArchivePath(path)) {
   //			IPath appendedPath = path.removeLastSegments(1);
   //			String appended = isExternal ? appendedPath.toPortableString() :
   // appendedPath.makeRelative().toString();
   //			return
   // CPathEntryMessages.getFormattedString("CPListLabelProvider.twopart",
   // //$NON-NLS-1$
   //					new String[] { path.lastSegment(), appended});
   //		} else {
   return isExternal ? path.toPortableString() : path.makeRelative().toString();
   //		}
 }
 private void addBaseString(IPath endPath, CPElement cpentry, StringBuffer str) {
   IPath baseRef = (IPath) cpentry.getAttribute(CPElement.BASE_REF);
   if (!baseRef.isEmpty()) {
     if (baseRef.isAbsolute()) {
       //				str.append("From project ");
       IPath path = baseRef;
       if (endPath != null) {
         path = path.append(endPath);
       }
       str.append(path.makeRelative().toPortableString());
     } else {
       //				str.append("From contribution ");
       IPathEntryContainer container;
       if (endPath != null) {
         str.append(endPath.toPortableString());
       }
       str.append(" - ("); // $NON-NLS-1$
       try {
         container = CoreModel.getPathEntryContainer(baseRef, cpentry.getCProject());
         if (container != null) {
           str.append(container.getDescription());
         }
       } catch (CModelException e1) {
       }
       str.append(')');
     }
   } else {
     IPath path = (IPath) cpentry.getAttribute(CPElement.BASE);
     if (!path.isEmpty()) {
       if (endPath != null) {
         path = path.append(endPath);
       }
       str.insert(0, path.toPortableString());
     } else if (endPath != null) {
       str.insert(0, endPath.toPortableString());
     }
   }
 }
Ejemplo n.º 16
0
 public static void addDialyzerWarningMarker(
     final IProject project, final String filename, final int line, final String message) {
   final IPath projectPath = project.getLocation();
   final String projectPathString = projectPath.toPortableString();
   IResource file;
   if (filename.startsWith(projectPathString)) {
     final String relFilename = filename.substring(projectPathString.length());
     final IPath relPath = Path.fromPortableString(relFilename);
     file = project.findMember(relPath);
   } else {
     file = null;
   }
   MarkerUtils.addDialyzerWarningMarker(file, filename, message, line, IMarker.SEVERITY_WARNING);
 }
Ejemplo n.º 17
0
    /**
     * @return String - The path to the item, or
     *     <pre>null</pre>
     *     <p>if it is not found.
     */
    public String getPath() {
      StringBuffer sb = new StringBuffer(0);

      if (_foundItem != null) {
        sb.append(_foundItem.getParentItem().toString());
        sb.append(File.separatorChar);
        sb.append(_foundItem.toString());
        IPath path = new Path(sb.toString());

        return path.toPortableString();
      } else {
        return null;
      }
    }
  @Override
  public IPath resolvePath(IPath path) {
    if (path == null) return null;

    String str = path.toPortableString();

    try {
      str = CdtVariableResolver.resolveToString(str, fSubstitutor);
    } catch (CdtVariableException e) {
      CCorePlugin.log(e);
    }

    return new Path(str);
  }
Ejemplo n.º 19
0
  public void store(final IEclipsePreferences root) throws BackingStoreException {
    CodePathLocation.clearAll(root);
    root.put(ProjectPreferencesConstants.OUTPUT, output.toPortableString());
    if (requiredRuntimeVersion != null) {
      root.put(
          ProjectPreferencesConstants.REQUIRED_BACKEND_VERSION, requiredRuntimeVersion.toString());
    }
    root.put(ProjectPreferencesConstants.INCLUDES, PathSerializer.packList(includes));
    final Preferences srcNode = root.node(ProjectPreferencesConstants.SOURCES);
    for (final SourceLocation loc : sources) {
      loc.store((IEclipsePreferences) srcNode.node(Integer.toString(loc.getId())));
    }

    root.flush();
  }
    /**
     * Initializes the {@link ContainerModel} from the specified path.
     *
     * @param path The Path to the ContainerModel
     * @throws Exception
     */
    protected void load(final IProgressMonitor progressMonitor) {
      InputStream input = getInputStream(_path);

      if (input == null) {
        showMessage(progressMonitor, "Could not load display: " + _path.toPortableString());
      } else {
        final DisplayModel tempModel = new DisplayModel();

        PersistenceUtil.asyncFillModel(
            tempModel,
            input,
            new DisplayModelLoadAdapter() {

              @Override
              public void onErrorsOccured(final List<String> errors) {
                showMessage(progressMonitor, "Error occurred: " + errors.get(0));
              }

              public void onDisplayModelLoaded() {
                // remove old widgets
                _container.removeWidgets(_container.getWidgets());

                // add new widgets
                List<AbstractWidgetModel> widgets = tempModel.getWidgets();

                tempModel.removeWidgets(widgets);
                _container.addWidgets(widgets);

                // update zoom
                if (!progressMonitor.isCanceled()) {
                  updateZoom();
                }

                // use background-color of the loaded display
                _container.setColor(
                    AbstractWidgetModel.PROP_COLOR_BACKGROUND,
                    tempModel.getColor(AbstractWidgetModel.PROP_COLOR_BACKGROUND));
                _container.setColor(
                    AbstractWidgetModel.PROP_COLOR_FOREGROUND,
                    tempModel.getColor(AbstractWidgetModel.PROP_COLOR_FOREGROUND));
                // _container.setAliases(tempModel.getAliases());
                _container.setPrimarPv(tempModel.getPrimaryPV());

                _container.setResourceLoaded(true);
              }
            });
      }
    }
 protected void changeCurrentDir(IPath path) throws FTPException, IOException {
   try {
     if (cwd == null) {
       cwd = new Path(ftpClient.pwd());
     }
     if (!cwd.equals(path)) {
       ftpClient.chdir(path.toPortableString());
       cwd = path;
     }
   } catch (FTPException e) {
     throwFileNotFound(e, path);
   } catch (IOException e) {
     cwd = null;
     throw e;
   }
 }
Ejemplo n.º 22
0
 public static IPath getAbsolutLibraryPath(final IPath libPath, final IWARProduct product) {
   IPath result = null;
   boolean fromTarget = product.isLibraryFromTarget(libPath);
   if (fromTarget) {
     String absoluteBridgePath = getServletBridgeAbsolutePath();
     if (absoluteBridgePath != null) {
       if (absoluteBridgePath.indexOf(libPath.toPortableString()) != -1) {
         result = new Path(absoluteBridgePath);
       }
     }
   } else {
     IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
     IFile lib = root.getFile(libPath);
     result = lib.getLocation();
   }
   return result;
 }
    public boolean include(Object object) {
      if (object instanceof IResource) {
        IResource resource = (IResource) object;
        IPath path =
            IResource.FILE == resource.getType()
                ? resource.getFullPath()
                : resource.getFullPath().addTrailingSeparator();
        object = path.toPortableString();
      }

      for (Iterator iter = filters.iterator(); iter.hasNext(); ) {
        Filter filter = (Filter) iter.next();
        if (filter.matches(object)) {
          return filter.inclusive();
        }
      }
      return default_;
    }
  @Override
  protected IResource createElementResource(IProgressMonitor monitor, IPath path) {
    try {

      if (monitor == null) {
        monitor = new NullProgressMonitor();
      }

      monitor.beginTask(Messages.NewMechanoidOpsFileWizard_Progress_Message, 1);

      URI newEmfResourceURI =
          URI.createURI(
              "platform:/resource"
                  + //$NON-NLS-1$
                  path.toPortableString());

      Resource emfResource = mResourceSet.createResource(newEmfResourceURI);

      Model model = OpServiceModelFactory.eINSTANCE.createModel();
      model.setPackageName(mSelectedPackageName);

      emfResource.getContents().add(model);

      ServiceBlock service = (ServiceBlock) OpServiceModelFactory.eINSTANCE.createServiceBlock();
      service.setName(mSelectedElementName);
      model.setService(service);

      emfResource.save(Collections.EMPTY_MAP);

      IResource resource =
          ResourcesPlugin.getWorkspace()
              .getRoot()
              .findMember(newEmfResourceURI.toPlatformString(true));

      monitor.worked(1);

      return resource;

    } catch (Exception e) {
      e.printStackTrace();
    }

    return null;
  }
  /**
   * Show statistics view.
   *
   * @param config launch configuration
   * @param launch launch
   * @throws CoreException
   */
  private void showStat(ILaunchConfiguration config, ILaunch launch) throws CoreException {
    // Build the command line string
    String arguments[] = getProgramArgumentsArray(config);

    // Get working directory
    int runCount =
        config.getAttribute(PerfPlugin.ATTR_StatRunCount, PerfPlugin.ATTR_StatRunCount_default);
    StringBuffer args = new StringBuffer();
    for (String arg : arguments) {
      args.append(arg);
      args.append(" "); // $NON-NLS-1$
    }
    URI binURI = null;
    try {
      binURI = new URI(binPath.toPortableString());
    } catch (URISyntaxException e) {
      MessageDialog.openError(
          Display.getCurrent().getActiveShell(), Messages.MsgProxyError, Messages.MsgProxyError);
    }
    Object[] titleArgs = new Object[] {binURI.getPath(), args.toString(), String.valueOf(runCount)};
    String title =
        renderProcessLabel(
            MessageFormat.format(Messages.PerfLaunchConfigDelegate_stat_title, titleArgs));

    List<String> configEvents =
        config.getAttribute(PerfPlugin.ATTR_SelectedEvents, PerfPlugin.ATTR_SelectedEvents_default);

    String[] statEvents = new String[] {};

    if (!config.getAttribute(PerfPlugin.ATTR_DefaultEvent, PerfPlugin.ATTR_DefaultEvent_default)) {
      // gather selected events
      statEvents = (configEvents == null) ? statEvents : configEvents.toArray(new String[] {});
    }

    StatData sd =
        new StatData(
            title, workingDirPath, binURI.getPath(), arguments, runCount, statEvents, project);
    sd.setLaunch(launch);
    sd.parse();
    PerfPlugin.getDefault().setStatData(sd);
    sd.updateStatData();
    StatView.refreshView();
  }
Ejemplo n.º 26
0
  private String saveICMAssembly(AssemblyInstance assembly) {

    // configure this RF with the configuration file
    try {
      URL url =
          FileLocator.find(Platform.getBundle("SEI.ArchE.Performance"), new Path("/temp"), null);
      String tempPathName = FileLocator.resolve(url).getPath();

      ResourceSet resourceSet = new ResourceSetImpl();

      IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
      IPath path = new Path(tempPathName + assembly.getName() + ".icm");

      IFile xmlFile = workspaceRoot.getFile(path);

      // Get the URI of the model file
      URI fileURI = URI.createFileURI(path.toString());

      // Create a resource for this file.
      Resource resource = resourceSet.createResource(fileURI);

      // Add the assembly to the resource contents
      resource.getContents().add(assembly);

      // Save the contents of the resource to the file system.
      String xmlAssemblyFile = null;
      try {
        resource.save(Collections.EMPTY_MAP);
      } catch (IOException e) {
      }

      xmlAssemblyFile = fileURI.toFileString();

      return (path.toPortableString());

    } catch (MalformedURLException e1) {
      e1.printStackTrace();
    } catch (IOException e1) {
      e1.printStackTrace();
    }

    return null; // for error
  }
Ejemplo n.º 27
0
  private ILaunchConfiguration createLaunchConfiguration(IContainer basedir, String goal) {
    try {
      ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
      ILaunchConfigurationType launchConfigurationType =
          launchManager.getLaunchConfigurationType(
              MavenLaunchConstants.LAUNCH_CONFIGURATION_TYPE_ID);

      String launchSafeGoalName = goal.replace(':', '-');

      ILaunchConfigurationWorkingCopy workingCopy =
          launchConfigurationType.newInstance(
              null, //
              NLS.bind(
                  Messages.ExecutePomAction_executing,
                  launchSafeGoalName,
                  basedir.getLocation().toString().replace('/', '-')));
      workingCopy.setAttribute(
          MavenLaunchConstants.ATTR_POM_DIR, basedir.getLocation().toOSString());
      workingCopy.setAttribute(MavenLaunchConstants.ATTR_GOALS, goal);
      workingCopy.setAttribute(IDebugUIConstants.ATTR_PRIVATE, true);
      workingCopy.setAttribute(RefreshTab.ATTR_REFRESH_SCOPE, "${project}"); // $NON-NLS-1$
      workingCopy.setAttribute(RefreshTab.ATTR_REFRESH_RECURSIVE, true);

      setProjectConfiguration(workingCopy, basedir);

      IPath path = getJREContainerPath(basedir);
      if (path != null) {
        workingCopy.setAttribute(
            IJavaLaunchConfigurationConstants.ATTR_JRE_CONTAINER_PATH, path.toPortableString());
      }

      // TODO when launching Maven with debugger consider to add the following property
      // -Dmaven.surefire.debug="-Xdebug
      // -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -Xnoagent
      // -Djava.compiler=NONE"

      return workingCopy;
    } catch (CoreException ex) {
      log.error(ex.getMessage(), ex);
    }
    return null;
  }
Ejemplo n.º 28
0
  /**
   * Creates the text that will be added to the BuildConfig.groovy file
   *
   * @param dependent the target grails project
   * @param plugin the plugin project that will be depended on
   * @param doMangle if true, add an extra space in the returned text
   * @return A string containing the "grails.plugin.location" property for the dependent project
   */
  private static String createDependencyText(
      IProject dependent, IProject plugin, boolean doMangle) {
    // if plugin path and dependent path are both in same directory use relative path
    // otherwise, use full path.
    IPath pathToPluginProject = plugin.getLocation();
    IPath pathToDependentProject = dependent.getLocation();
    boolean isColocated =
        pathToDependentProject.segmentCount() == pathToPluginProject.segmentCount()
            && pathToDependentProject.removeLastSegments(1).isPrefixOf(pathToPluginProject);

    String textToAdd =
        "grails.plugin.location."
            + maybeQuote(plugin.getName())
            + (doMangle ? " " : "")
            + " = \""
            + (isColocated
                ? "../" + pathToPluginProject.lastSegment()
                : pathToPluginProject.toPortableString())
            + "\"\n";
    return textToAdd;
  }
  private String getConfigInfoFromCache(String configType, IPath portalDir) {
    File configInfoFile = getConfigInfoPath(configType).toFile();

    String portalDirKey = CoreUtil.createStringDigest(portalDir.toPortableString());

    Properties properties = new Properties();

    if (configInfoFile.exists()) {
      try (FileInputStream fileInput = new FileInputStream(configInfoFile)) {
        properties.load(fileInput);
        String configInfo = (String) properties.get(portalDirKey);

        if (!CoreUtil.isNullOrEmpty(configInfo)) {
          return configInfo;
        }
      } catch (IOException e) {
        LiferayServerCore.logError(e);
      }
    }

    return null;
  }
Ejemplo n.º 30
0
  /**
   * Method updateFileVersion
   *
   * @param aTargetFileVer R4EFileVersion
   * @param aScmArt ScmArtifact
   * @throws CoreException
   */
  public static void updateFileVersion(R4EFileVersion aTargetFileVer, ScmArtifact aScmArt)
      throws CoreException {

    if ((null != aTargetFileVer) && (null != aScmArt)) {
      aTargetFileVer.setName(aScmArt.getFileRevision(null).getName());
      aTargetFileVer.setVersionID(aScmArt.getId());
      final IFileRevision fileRev = aScmArt.getFileRevision(null);
      if (null != fileRev) {
        final IStorage fileStore = fileRev.getStorage(null);
        if (null != fileStore) {
          final IPath filePath = fileStore.getFullPath();
          if (null != filePath) {
            aTargetFileVer.setRepositoryPath(filePath.toPortableString());
          }
        }
      }

      final String fileRelPath = aScmArt.getProjectRelativePath();
      if (null == fileRelPath) {
        R4EUIPlugin.Ftracer.traceDebug(
            "Invalid relative file path in scmArtifact with path: " + aScmArt.getPath());
      }
      final IProject project = ResourceUtils.getProject(aScmArt.getProjectName());
      final IResource resource = ResourceUtils.findResource(project, fileRelPath);

      aTargetFileVer.setPlatformURI(ResourceUtils.toPlatformURIStr(resource));
      aTargetFileVer.setResource(resource);

      final String projPlatformURI = ResourceUtils.toPlatformURIStr(project);
      if (null == projPlatformURI) {
        R4EUIPlugin.Ftracer.traceDebug(
            "Unable to resolve the project: "
                + aScmArt.getProjectName()
                + " platform's URI, in scmArtifact with path: "
                + aScmArt.getPath());
      }
    }
  }