Example #1
0
 public static void updatePersistentProperties(
     IFile resource, SonarProject sonarProject, ISonarServer sonarServer) {
   try {
     resource.setPersistentProperty(
         MODIFICATION_STAMP_PERSISTENT_PROP_KEY, "" + resource.getModificationStamp());
     resource.setPersistentProperty(
         LAST_ANALYSIS_DATE_PERSISTENT_PROP_KEY,
         ""
             + WSClientFactory.getSonarClient(sonarServer)
                 .getLastAnalysisDate(sonarProject.getKey())
                 .getTime());
   } catch (CoreException e) {
     LOG.error("Unable to update persistent properties", e);
   }
 }
  @Override
  public IFile exportToIFile(
      AFileResource res, ResourceDescriptor rd, String fkeyname, IProgressMonitor monitor)
      throws Exception {
    IFile f = super.exportToIFile(res, rd, fkeyname, monitor);
    if (f != null) {
      JasperReportsConfiguration jrConfig = res.getJasperConfiguration();
      if (jrConfig == null) {
        jrConfig = JasperReportsConfiguration.getDefaultJRConfig(f);
        res.setJasperConfiguration(jrConfig);
      } else jrConfig.init(f);
      try {
        JasperDesign jd = JRXmlLoader.load(jrConfig, f.getContents());
        setPropServerURL(res, jd);
        setPropReportUnit(res, jd);
        getResources(res, jd);

        MServerProfile sp = (MServerProfile) res.getRoot();
        if (sp != null)
          f.setContents(
              new ByteArrayInputStream(
                  JRXmlWriterHelper.writeReport(null, jd, sp.getValue().getJrVersion())
                      .getBytes("UTF-8")),
              IFile.KEEP_HISTORY | IFile.FORCE,
              monitor);
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
    if (f != null) f.setPersistentProperty(KEY_REPORT_ISMAIN, Boolean.toString(rd.isMainReport()));
    return f;
  }
  public void overwriteTemplate(Template template) throws CoreException {
    try {
      // get the directory
      String projectName = folderSelected.getProject().getName();
      IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
      IProject project = root.getProject(projectName);
      IPath pathFolder = folderSelected.getProjectRelativePath();
      String templateFileName = template.getFileName();

      DataHandler dh = template.getContent();
      InputStream is = dh.getInputStream();

      IPath pathNewFile = pathFolder.append(templateFileName);
      IFile newFile = project.getFile(pathNewFile);

      // create new File
      if (newFile.exists()) {
        newFile.delete(true, null);
      }
      newFile.create(is, true, null);
      // set the dirty property to true
      newFile.setPersistentProperty(SpagoBIStudioConstants.DIRTY_MODEL, "true");

    } catch (IOException e1) {

      MessageDialog.openError(
          PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
          "Error",
          "Error in writing the file");
      logger.error("Error in writing the file", e1);

      return;
    }
  }
Example #4
0
 public static void setExecutionArguments(IFile rubyScriptFile, ExecutionArguments arguments) {
   try {
     rubyScriptFile.setPersistentProperty(
         EXECUTION_ARGUMENTS_PROPERTY, arguments.toPersistableFormat());
   } catch (CoreException e) {
   }
 }
 /**
  * Removes the TITAN related attributes from the provided file.
  *
  * @param file the file whose attributes are to be cleaned
  */
 public static void removeTITANAttributes(final IFile file) {
   try {
     file.setPersistentProperty(new QualifiedName(QUALIFIER, EXCLUDE_FROM_BUILD_PROPERTY), null);
   } catch (CoreException e) {
     ErrorReporter.logExceptionStackTrace(
         "While removing properties of `" + file.getName() + "'", e);
   }
 }
 /**
  * Sets the provided value, on the provided resource, for the provided property.
  *
  * @param file the file to work on.
  * @param property the property to change.
  * @param value the value to set.
  */
 private static void setPropertyValue(
     final IFile file, final String property, final String value) {
   try {
     file.setPersistentProperty(
         new QualifiedName(QUALIFIER, property),
         TRUE_STRING.equals(value) ? TRUE_STRING : FALSE_STRING);
   } catch (CoreException e) {
     ErrorReporter.logExceptionStackTrace(
         "While setting property `" + property + "' of `" + file.getName() + "'", e);
   }
 }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.jface.wizard.Wizard#performFinish()
   */
  @Override
  public boolean performFinish() {
    if (mainPage.getContainerFullPath().append(mainPage.getFileName()).getFileExtension() == null) {
      mainPage.setFileName(
          mainPage.getFileName() + '.' + GlobalParser.SUPPORTED_TTCN3_EXTENSIONS[1]);
    }
    final IFile newModule = mainPage.createNewFile();
    if (newModule != null) {
      try {
        if (optionsPage.isExcludeFromBuildSelected()) {
          newModule.setPersistentProperty(
              new QualifiedName(
                  FileBuildPropertyData.QUALIFIER,
                  FileBuildPropertyData.EXCLUDE_FROM_BUILD_PROPERTY),
              TRUE);
        }

        ProjectFileHandler pfHandler = new ProjectFileHandler(newModule.getProject());
        pfHandler.saveProjectSettings();
        newModule.touch(new NullProgressMonitor());

        WorkspaceJob refreshJob =
            new WorkspaceJob("Refreshing built resources") {
              @Override
              public IStatus runInWorkspace(final IProgressMonitor monitor) {
                boolean proceedingOK = SymbolicLinkHandler.createSymlinks(newModule);
                if (proceedingOK) {
                  proceedingOK = TITANBuilder.removeExecutable(newModule.getProject());
                }
                if (proceedingOK) {
                  proceedingOK = TITANBuilder.removeMakefile(newModule.getProject());
                }
                if (proceedingOK) {
                  TITANBuilder.invokeBuild(newModule.getProject());
                }

                return Status.OK_STATUS;
              }
            };
        refreshJob.setPriority(Job.LONG);
        refreshJob.setUser(false);
        refreshJob.setSystem(true);
        refreshJob.setProperty(
            IProgressConstants.ICON_PROPERTY, ImageCache.getImageDescriptor("titan.gif"));
        refreshJob.schedule();

        selectAndRevealNewModule(newModule);
      } catch (CoreException e) {
        ErrorReporter.logExceptionStackTrace(e);
      }
    }
    return true;
  }