private Map promptForOverwrite(List plugins, List locales) {
    Map overwrites = new HashMap();

    if (overwriteWithoutAsking) return overwrites;

    for (Iterator iter = plugins.iterator(); iter.hasNext(); ) {
      IPluginModelBase plugin = (IPluginModelBase) iter.next();
      for (Iterator it = locales.iterator(); it.hasNext(); ) {
        Locale locale = (Locale) it.next();
        IProject project = getNLProject(plugin, locale);

        if (project.exists() && !overwrites.containsKey(project.getName())) {
          boolean overwrite =
              MessageDialog.openConfirm(
                  PDEPlugin.getActiveWorkbenchShell(),
                  PDEUIMessages.InternationalizeWizard_NLSFragmentGenerator_overwriteTitle,
                  NLS.bind(
                      PDEUIMessages.InternationalizeWizard_NLSFragmentGenerator_overwriteMessage,
                      pluginName(plugin, locale)));
          overwrites.put(project.getName(), overwrite ? OVERWRITE : null);
        }
      }
    }

    return overwrites;
  }
  public void updateStatus() {
    if (project == null) {
      view.getStatusLine(0).setText(Messages.DashboardMediator_SelectProject);
      view.getStatusLine(1).setText(""); // $NON-NLS-1$
    } else {
      boolean isAliveProject = false;
      try {
        if (project.getNature("net.sf.ictalive.aliveclipse.projectNature") != null)
          isAliveProject = true;
      } catch (CoreException e) {
      }

      if (isAliveProject) {
        view.getStatusLine(0)
            .setText(
                MessageFormat.format(
                    Messages.DashboardMediator_Project, new Object[] {project.getName()}));
        double done = (double) state.getSpecifiedModelsCount() / state.getModelsCount();
        view.getStatusLine(1)
            .setText(
                MessageFormat.format(
                    Messages.DashboardMediator_Progress, new Object[] {new Double(done)}));
      } else {
        view.getStatusLine(0)
            .setText(
                MessageFormat.format(
                    Messages.DashboardMediator_Project, new Object[] {project.getName()}));
        view.getStatusLine(1).setText("Not an ALIVE project"); // $NON-NLS-1$			
      }
    }
    for (BoxFigure<AliveDashboardState> boxFigure : view.allBoxFigures) boxFigure.refresh();

    view.repaint(); // update hyperlinks
  }
示例#3
0
  public static List<LaunchConfigData> getProjectLaunchConfigs(final IProject project) {
    List<LaunchConfigData> matches = new LinkedList<>();

    try {
      ILaunchConfiguration[] configs =
          DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurations();

      for (ILaunchConfiguration launchConfig : configs) {
        String launchConfigProjectName =
            launchConfig.getAttribute(IDebugConstants.VDM_LAUNCH_CONFIG_PROJECT, "");

        if (launchConfigProjectName != null
            && !launchConfigProjectName.equals("")
            && launchConfigProjectName.equals(project.getName())) {
          String exp = launchConfig.getAttribute(IDebugConstants.VDM_LAUNCH_CONFIG_EXPRESSION, "");
          matches.add(new LaunchConfigData(launchConfig.getName(), exp));
        }
      }
    } catch (CoreException e) {

      CodeGenConsole.GetInstance()
          .printErrorln(
              "Problem looking up launch configurations for project "
                  + project.getName()
                  + ": "
                  + e.getMessage());
      e.printStackTrace();
    }

    return matches;
  }
示例#4
0
  @Override
  protected void initialSetup() throws Exception {
    // disable auto build
    WorkspaceUtil.setAutobuilding(false);

    TestingUtilities.importTestingProjectIntoWorkspace("RTOMoveTests");

    IProject testProject = getProjectHandle("RTOMoveTests");
    m_sys = getSystemModel(testProject.getName());
    m_sys.setUseglobals(true);
    m_sys.getPersistableComponent().loadComponentAndChildren(new NullProgressMonitor());

    IScopeContext projectScope = new ProjectScope(testProject);
    Preferences projectNode =
        projectScope.getNode(BridgePointProjectPreferences.BP_PROJECT_PREFERENCES_ID);
    projectNode.putBoolean(BridgePointProjectReferencesPreferences.BP_PROJECT_REFERENCES_ID, true);

    IProject inscope = TestingUtilities.createProject("InScope Other");
    inscopeOtherProject = getSystemModel(inscope.getName());
    inscopeOtherProject.setUseglobals(true);
    projectScope = new ProjectScope(inscope);
    projectNode = projectScope.getNode(BridgePointProjectPreferences.BP_PROJECT_PREFERENCES_ID);
    projectNode.putBoolean(BridgePointProjectReferencesPreferences.BP_PROJECT_REFERENCES_ID, true);
    inscopeOtherProject.Newpackage();
    IProject outOfScope = TestingUtilities.createProject("OutOfScope Other");
    outOfScopeOtherProject = getSystemModel(outOfScope.getName());
    outOfScopeOtherProject.Newpackage();
  }
示例#5
0
  /**
   * This method is not meant for public use. Only for testing. use {@link
   * #removePluginDependency(IProject, IProject)} instead. If doMangle is true, then add an extra
   * space in the text to remove so that previously mangled plugin entries can be removed
   */
  public static IStatus removePluginDependency(
      IProject dependent, IProject plugin, boolean doMangle) throws CoreException {
    Assert.isTrue(
        GrailsNature.isGrailsProject(dependent), dependent.getName() + " is not a grails project");
    Assert.isTrue(
        GrailsNature.isGrailsPluginProject(plugin),
        plugin.getName() + " is not a grails plugin project");

    IFile buildConfigFile = dependent.getFile(BUILD_CONFIG_LOCATION);

    String textToRemove = createDependencyText(dependent, plugin, doMangle);

    if (dependencyExists(buildConfigFile, textToRemove)) {
      char[] contents = ((CompilationUnit) JavaCore.create(buildConfigFile)).getContents();
      String newText = String.valueOf(contents).replace(textToRemove, "");
      InputStream stream = createInputStream(dependent, newText);
      buildConfigFile.setContents(stream, true, true, null);
      return Status.OK_STATUS;
    } else {
      return new Status(
          IStatus.WARNING,
          GrailsCoreActivator.PLUGIN_ID,
          "Could not remove a dependency from "
              + dependent.getName()
              + " to in place plugin "
              + plugin.getName()
              + ". Try manually editing the BuildConfig.groovy file.");
    }
  }
示例#6
0
  /**
   * This method is not meant for public use. Only for testing. use {@link
   * #addPluginDependency(IProject, IProject)} instead. If doMangle is true, then add an extra space
   * in the added text so that it cannot be removed.
   */
  public static IStatus addPluginDependency(IProject dependent, IProject plugin, boolean doMangle)
      throws CoreException {
    Assert.isTrue(
        GrailsNature.isGrailsProject(dependent), dependent.getName() + " is not a grails project");
    Assert.isTrue(
        GrailsNature.isGrailsPluginProject(plugin),
        plugin.getName() + " is not a grails plugin project");

    IFile buildConfigFile = dependent.getFile(BUILD_CONFIG_LOCATION);

    // next create the text to add to BuildConfig.groovy

    String textToAdd = createDependencyText(dependent, plugin, doMangle);

    if (!dependencyExists(buildConfigFile, textToAdd)) {
      InputStream stream = createInputStream(dependent, textToAdd);
      buildConfigFile.appendContents(stream, true, true, null);
      return Status.OK_STATUS;
    } else {
      return new Status(
          IStatus.WARNING,
          GrailsCoreActivator.PLUGIN_ID,
          "Could not add a dependency from "
              + dependent.getName()
              + " to in place plugin "
              + plugin.getName()
              + ". Try manually editing the BuildConfig.groovy file.");
    }
  }
  /**
   * The default implementation recursively traverses the folders of the imported projects and
   * copies all contents into a feature folder with the imported projects name in {@code
   * newProject}. Can be overwritten by extending classes to accomodate {@link
   * IComposerExtensionBase Composers} needs.
   */
  protected void migrateProjects() {
    for (IProject project : projects) {
      IPath destinationPath = new Path(configurationData.sourcePath);

      assert newProject.getFolder(destinationPath).isAccessible()
          : DESTINATIONFOLDER_NOT_ACCESSIBLE_OR_WRONG_PATH;
      assert project.isOpen() : PROJECT + project.getName() + IS_NOT_OPEN_;

      IPath featureFolderPath =
          SPLMigrationUtils.setupFolder(
              newProject.getFolder(destinationPath).getFolder(project.getName()));

      try {
        migrateClassPathDependentContent(project, featureFolderPath);
      } catch (JavaModelException e) {
        e.printStackTrace();
      }

      //			try
      //			{
      //				if(project.hasNature(ANDROID_NATURE))
      //					copyProjectProperties(project, featureFolderPath);
      //			} catch (CoreException e)
      //			{
      //				e.printStackTrace();
      //			}
    }
  }
 private boolean isDerivedEncodingStoredSeparately(IProject project) {
   // be careful looking up for our node so not to create any nodes as side effect
   Preferences node = Platform.getPreferencesService().getRootNode().node(ProjectScope.SCOPE);
   try {
     // TODO once bug 90500 is fixed, should be as simple as this:
     //			String path = project.getName() + IPath.SEPARATOR + ResourcesPlugin.PI_RESOURCES;
     //			return node.nodeExists(path) ?
     // node.node(path).getBoolean(ResourcesPlugin.PREF_SEPARATE_DERIVED_ENCODINGS, false) : false;
     // for now, take the long way
     if (!node.nodeExists(project.getName()))
       return ResourcesPlugin.DEFAULT_PREF_SEPARATE_DERIVED_ENCODINGS;
     node = node.node(project.getName());
     if (!node.nodeExists(ResourcesPlugin.PI_RESOURCES))
       return ResourcesPlugin.DEFAULT_PREF_SEPARATE_DERIVED_ENCODINGS;
     node = node.node(ResourcesPlugin.PI_RESOURCES);
     return node.getBoolean(
         ResourcesPlugin.PREF_SEPARATE_DERIVED_ENCODINGS,
         ResourcesPlugin.DEFAULT_PREF_SEPARATE_DERIVED_ENCODINGS);
   } catch (BackingStoreException e) {
     // nodeExists failed
     String message = Messages.resources_readingEncoding;
     Policy.log(
         new ResourceStatus(
             IResourceStatus.FAILED_GETTING_CHARSET, project.getFullPath(), message, e));
     return ResourcesPlugin.DEFAULT_PREF_SEPARATE_DERIVED_ENCODINGS;
   }
 }
  @Override
  protected IStatus run(IProgressMonitor monitor) {
    monitor.beginTask("", IProgressMonitor.UNKNOWN); // $NON-NLS-1$
    while (true) {
      ICProject cproject = fManager.getNextProject();
      if (cproject == null) return Status.OK_STATUS;

      final IProject project = cproject.getProject();
      monitor.setTaskName(project.getName());
      if (!project.isOpen()) {
        if (fManager.fTraceIndexerSetup)
          System.out.println("Indexer: Project is not open: " + project.getName()); // $NON-NLS-1$
      } else if (fManager.postponeSetup(cproject)) {
        if (fManager.fTraceIndexerSetup)
          System.out.println("Indexer: Setup is postponed: " + project.getName()); // $NON-NLS-1$
      } else {
        syncronizeProjectSettings(project, new SubProgressMonitor(monitor, 1));
        if (fManager.getIndexer(cproject) == null) {
          try {
            fManager.createIndexer(cproject, new SubProgressMonitor(monitor, 99));
          } catch (InterruptedException e) {
            Thread.currentThread().interrupt();
            return Status.CANCEL_STATUS;
          }
        } else if (fManager.fTraceIndexerSetup) {
          System.out.println(
              "Indexer: No action, indexer already exists: " + project.getName()); // $NON-NLS-1$
        }
      }
    }
  }
  public void elementChanged(ElementChangedEvent event) {
    IJavaElementDelta[] children = event.getDelta().getChangedChildren(); // children = IProjects
    for (IJavaElementDelta child : children) {
      IProject project = child.getElement().getJavaProject().getProject();
      int size = child.getAffectedChildren().length; // .getChangedElement() = JavaProject
      if (size == 1) {
        IJavaElementDelta elementDelta =
            child.getAffectedChildren()[0]; // if it is only 1, name is ".tmp"
        // and elementDelta.kind = 4
        // (CHANGED)
        IJavaElement changedElement = elementDelta.getElement();
        if (changedElement
            .getElementName()
            .equals(ImportUtils.getImportPref(ResourceBuilder.LOCALE_INTERFACES_FOLDER_NAME))) {
          _changedBuildClasspath.put(project.getName(), Boolean.FALSE);
          break;
        }
      }
      if (isClasspathChange(
          child)) { // adding classpath entries might induce reordering the classpath entries
        _changedBuildClasspath.put(project.getName(), Boolean.TRUE);
        // notify the listeners
        EJDEEventNotifier.getInstance()
            .notifyClassPathChanged(child.getElement().getJavaProject(), hasCPRemoved(child));
        // validate the project
        ValidationManager.getInstance()
            .validateProjects(
                ProjectUtils.getAllReferencingProjects(
                    new IProject[] {child.getElement().getJavaProject().getProject()}),
                null);
      }
      if ((child.getFlags() & IJavaElementDelta.F_CLASSPATH_CHANGED) != 0
          || (child.getFlags() & IJavaElementDelta.F_RESOLVED_CLASSPATH_CHANGED) != 0) {
        IJavaElement javaElement = child.getElement();
        final IJavaProject javaProject = javaElement.getJavaProject();
        classPathChanged(javaProject, child);
      }
      checkSourceAttachement(child.getAffectedChildren());
    }

    for (final IJavaElementDelta addedElemDelta : event.getDelta().getAddedChildren()) {
      final IJavaProject javaProject = addedElemDelta.getElement().getJavaProject();
      try {
        if (javaProject.getProject().hasNature(BlackBerryProjectCoreNature.NATURE_ID)) {
          if (addedElemDelta.getAffectedChildren().length == 0) {
            final IJavaElement addedElement = addedElemDelta.getElement();
            if (addedElement instanceof IJavaProject) {
              final IJavaProject addedJavaProj = (IJavaProject) addedElement;
              if (addedJavaProj.equals(javaProject)) {
                projectCreated(javaProject);
              }
            }
          }
        }
      } catch (final CoreException ce) {
        _log.error("", ce);
      }
    }
  }
 private Map<String, IAConfiguration> getTmpConfigs(IProject p) {
   Map<String, IAConfiguration> tmpList = tmpConfigs.get(p.getName());
   if (tmpList == null) {
     tmpList = new HashMap<>();
     tmpConfigs.put(p.getName(), tmpList);
   }
   return tmpList;
 }
  private MavenProblemInfo installNewLiferayFacet(
      IFacetedProject facetedProject, MavenProject mavenProject, IProgressMonitor monitor) {
    MavenProblemInfo retval = null;

    final String pluginType = getLiferayMavenPluginType(mavenProject);
    final Plugin liferayMavenPlugin = LiferayMavenUtil.getLiferayMavenPlugin(mavenProject);
    final Action action = getNewLiferayFacetInstallAction(pluginType);

    if (action != null) {
      try {
        facetedProject.modify(Collections.singleton(action), monitor);
      } catch (Exception e) {
        final SourceLocation location = SourceLocationHelper.findLocation(liferayMavenPlugin, null);
        final String problemMsg =
            NLS.bind(
                Msgs.facetInstallError,
                pluginType,
                e.getCause() != null ? e.getCause().getMessage() : e.getMessage());

        retval = new MavenProblemInfo(location, e);
        retval.setMessage(problemMsg);

        LiferayMavenCore.logError(
            "Unable to install liferay facet " + action.getProjectFacetVersion(),
            e.getCause()); // $NON-NLS-1$
      }

      final IProject project = facetedProject.getProject();

      try {
        // IDE-817 we need to mak sure that on deployment it will have the correct suffix for
        // project name
        final IVirtualComponent projectComponent = ComponentCore.createComponent(project);

        if (projectComponent != null) {
          final String deployedName = projectComponent.getDeployedName();

          if (deployedName == null
              || (deployedName != null && !deployedName.endsWith(pluginType))) {
            final String deployedFileName = project.getName() + "-" + pluginType; // $NON-NLS-1$

            configureDeployedName(project, deployedFileName);
            projectComponent.setMetaProperty("context-root", deployedFileName); // $NON-NLS-1$
          }
        }
      } catch (Exception e) {
        LiferayMavenCore.logError(
            "Unable to configure component for liferay deployment." + project.getName(),
            e); //$NON-NLS-1$
      }
    }

    return retval;
  }
  /**
   * This method will ensure that the Acceleo project has a dependency with all the project
   * containing a dynamic metamodels used in the module.
   *
   * @param module The Acceleo module
   * @param inputFile The file in the Acceleo editor
   */
  private void checkDependenciesWithDynamicMetamodels(Module module, IFile inputFile) {
    List<TypedModel> input = module.getInput();
    for (TypedModel typedModel : input) {
      List<EPackage> takesTypesFrom = typedModel.getTakesTypesFrom();
      for (EPackage ePackage : takesTypesFrom) {
        Map<String, String> dynamicEcorePackagePaths =
            AcceleoPackageRegistry.INSTANCE.getDynamicEcorePackagePaths();
        String packagePath = dynamicEcorePackagePaths.get(ePackage.getNsURI());
        if (packagePath == null) {
          return;
        }
        IPath path = new Path(packagePath);
        IFile metamodelFile = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
        if (metamodelFile != null && metamodelFile.isAccessible()) {
          // We have found the "ecore" file for the dynamic metamodel
          IProject metamodelProject = metamodelFile.getProject();
          IProject inputProject = inputFile.getProject();
          if (!inputProject.equals(metamodelProject)) {
            // The dynamic metamodel is not in the project of the generator, let's find if
            // this dynamic metamodel is in a dependency of the project of the generator.
            boolean foundProject = false;

            AcceleoProject acceleoProject = new AcceleoProject(inputProject);
            List<IProject> recursivelyAccessibleProjects =
                acceleoProject.getRecursivelyAccessibleProjects();
            for (IProject iProject : recursivelyAccessibleProjects) {
              if (iProject.equals(metamodelProject)) {
                foundProject = true;
              }
            }

            if (!foundProject) {
              // The dynamic metamodel is not in a dependency of the current project, log a
              // warning.
              try {
                AcceleoMarkerUtils.createMarkerOnFile(
                    AcceleoMarkerUtils.WARNING_MARKER_ID,
                    inputFile,
                    0,
                    typedModel.getStartPosition(),
                    typedModel.getEndPosition(),
                    AcceleoUIMessages.getString(
                        "AcceleoCompileOperation.NoDependencyWithDynamicMetamodelProject", //$NON-NLS-1$
                        metamodelProject.getName(),
                        inputProject.getName()));
              } catch (CoreException e) {
                AcceleoUIActivator.log(e, true);
              }
            }
          }
        }
      }
    }
  }
  public BadaBuildOption getTargetOption(IProject project) {
    BadaBuildOption option = (BadaBuildOption) taregtOptionList.get(project.getName());

    if (option != null) return option;

    option = LoadOption(project);

    taregtOptionList.put(project.getName(), option);

    return option;
  }
示例#15
0
  public static void updateTransientProperties(QsarType qsarModel, IProject project) {

    // If exists in prefs, add them
    IEclipsePreferences node =
        new InstanceScope().getNode(net.bioclipse.qsar.ui.Activator.PLUGIN_ID);

    ICDKManager cdk = Activator.getDefault().getJavaCDKManager();

    // NoMols is easy, just count number of structures
    for (ResourceType resource : qsarModel.getStructurelist().getResources()) {
      if (resource.getStructure() != null) {
        resource.setNoMols(resource.getStructure().size());
      }

      int pno2D = node.getInt(project.getName() + "_" + resource.getId() + "_no2d", -1);
      int pno3D = node.getInt(project.getName() + "_" + resource.getId() + "_no3d", -1);
      if (pno2D < 0 || pno3D < 0) {

        // At least one missing attribute, parse and read mols
        // Load molecules into file
        try {
          List<ICDKMolecule> mollist = cdk.loadMolecules(resource.getFile());
          if (mollist != null) {

            // Count no of 2D and 3D
            int no2d = 0;
            int no3d = 0;
            for (ICDKMolecule mol : mollist) {
              if (cdk.has2d(mol)) no2d++;
              if (cdk.has3d(mol)) no3d++;
            }

            resource.setNo2d(no2d);
            resource.setNo3d(no3d);

            // Also store as preferences
            node.putInt(project.getName() + "_" + resource.getId() + "_no2d", no2d);
            node.putInt(project.getName() + "_" + resource.getId() + "_no3d", no3d);

            //                        System.out.println("* No2D and no3D calculated and stored as
            // prefs");

          }
        } catch (Exception e) {
          logger.error("Could not parse molecule file: " + resource.getFile());
        }
      } else {
        resource.setNo2d(pno2D);
        resource.setNo3d(pno3D);
        //                System.out.println("* No2D and no3D read from prefs; no calc required");
      }
    }
  }
  public IProject createNewProject(IPath newPath, String name, IProgressMonitor monitor) {
    IProject newProject = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
    IWorkspace workspace = ResourcesPlugin.getWorkspace();

    final IProjectDescription description = workspace.newProjectDescription(newProject.getName());
    description.setLocation(newPath);

    // run the new project creation operation
    try {
      boolean doit = false;

      if (!newProject.exists()) {
        // Defect 24558 - Text Importer may result in New Project being created with NO PATH, so
        // check if NULL
        // before
        if (newPath != null && OSPlatformUtil.isWindows()) {
          // check to see if path exists but case is different
          IPath path = new Path(FileUiUtils.INSTANCE.getExistingCaseVariantFileName(newPath));

          newProject = ResourcesPlugin.getWorkspace().getRoot().getProject(path.lastSegment());
          description.setLocation(path);
          doit = !newProject.exists();
        } else {
          doit = true;
        }

        if (doit) {
          createProject(description, newProject, monitor);
        }
      }
    } catch (CoreException e) {
      if (e.getStatus().getCode() == IResourceStatus.CASE_VARIANT_EXISTS) {
        MessageDialog.openError(
            getShell(),
            ResourceMessages.NewProject_errorMessage,
            NLS.bind(ResourceMessages.NewProject_caseVariantExistsError, newProject.getName()));
      } else {
        ErrorDialog.openError(
            getShell(),
            ResourceMessages.NewProject_errorMessage,
            null, // no special message
            e.getStatus());
      }

      return null;
    } catch (Exception theException) {
      return null;
    }

    configureProject(newProject);

    return newProject;
  }
示例#17
0
 /**
  * Get the Mule model for the given project.
  *
  * @param project the project
  * @return the model, or null if nature not configured
  * @throws MuleModelException
  */
 public IMuleModel getMuleModel(IProject project) throws MuleModelException {
   MuleNature nature = getMuleNature(project);
   if (nature != null) {
     IMuleModel model = nature.getMuleModel();
     if (model != null) {
       return model;
     }
     throw new MuleModelException(
         createErrorStatus("Mule model is null for project: " + project.getName(), null));
   }
   throw new MuleModelException(
       createErrorStatus(
           "Project does not have the Mule nature configured: " + project.getName(), null));
 }
示例#18
0
  @Override
  protected void clean(final IProgressMonitor monitor) throws CoreException {
    final IProject currentProject = getProject();
    if (currentProject == null || !currentProject.isAccessible()) {
      return;
    }

    if (BuilderHelper.isDebugging()) {
      ErlLogger.debug(
          "Cleaning "
              + currentProject.getName() // $NON-NLS-1$
              + " @ "
              + new Date(System.currentTimeMillis()));
    }

    try {
      initializeBuilder(monitor);
      MarkerUtils.removeProblemsAndTasksFor(currentProject);
      final IErlProject erlProject = CoreScope.getModel().getErlangProject(currentProject);
      final IFolder bf = currentProject.getFolder(erlProject.getOutputLocation());
      if (bf.exists()) {
        final IResource[] beams = bf.members();
        monitor.beginTask("Cleaning Erlang files", beams.length);
        if (beams.length > 0) {
          final float delta = 1.0f / beams.length;
          for (final IResource element : beams) {
            if ("beam".equals(element.getFileExtension())) {
              element.delete(true, monitor);
              notifier.updateProgressDelta(delta);
            }
          }
        }
      }

    } catch (final Exception e) {
      ErlLogger.error(e);
      final String msg =
          NLS.bind(BuilderMessages.build_inconsistentProject, e.getLocalizedMessage());
      MarkerUtils.addProblemMarker(currentProject, null, null, msg, 0, IMarker.SEVERITY_ERROR);
    } finally {
      cleanup();
      if (BuilderHelper.isDebugging()) {
        ErlLogger.debug(
            "Finished cleaning "
                + currentProject.getName() // $NON-NLS-1$
                + " @ "
                + new Date(System.currentTimeMillis()));
      }
    }
  }
  /** Fix the Launch configurations. */
  @Override
  public void run() {

    if (mDisplayPrompt) {
      // ask the user if he really wants to fix the launch config
      boolean res =
          AdtPlugin.displayPrompt(
              "Launch Configuration Update",
              "The package definition in the manifest changed.\nDo you want to update your Launch Configuration(s)?");

      if (res == false) {
        return;
      }
    }

    // get the list of config for the project
    String projectName = mProject.getName();
    ILaunchConfiguration[] configs = findConfigs(mProject.getName());

    // loop through all the config and update the package
    for (ILaunchConfiguration config : configs) {
      try {
        // get the working copy so that we can make changes.
        ILaunchConfigurationWorkingCopy copy = config.getWorkingCopy();

        // get the attributes for the activity
        String activity =
            config.getAttribute(LaunchConfigDelegate.ATTR_ACTIVITY, ""); // $NON-NLS-1$

        // manifests can define activities that are not in the defined package,
        // so we need to make sure the activity is inside the old package.
        if (activity.startsWith(mOldPackage)) {
          // create the new activity
          activity = mNewPackage + activity.substring(mOldPackage.length());

          // put it in the copy
          copy.setAttribute(LaunchConfigDelegate.ATTR_ACTIVITY, activity);

          // save the config
          copy.doSave();
        }
      } catch (CoreException e) {
        // couldn't get the working copy. we output the error in the console
        String msg = String.format("Failed to modify %1$s: %2$s", projectName, e.getMessage());
        AdtPlugin.printErrorToConsole(mProject, msg);
      }
    }
  }
  /** https://bugs.eclipse.org/bugs/show_bug.cgi?id=400193 */
  @Test
  public void testSourceRelativeOutput() throws Exception {
    IProject project = testHelper.getProject();
    String srcFolder = "/foo/bar/bug";
    JavaProjectSetupUtil.addSourceFolder(JavaCore.create(project), srcFolder);

    String path = srcFolder + "/Foo.xtend";
    String fullFileName = project.getName() + path;
    IFile sourceFile = testHelper.createFileImpl(fullFileName, "class Foo {}");
    assertTrue(sourceFile.exists());
    waitForBuild();

    IFile generatedFile = project.getFile("foo/bar/xtend-gen/Foo.java");
    assertTrue(generatedFile.exists());
    IFile traceFile = testHelper.getProject().getFile("foo/bar/xtend-gen/.Foo.java._trace");
    assertTrue(traceFile.exists());
    IFile classFile = testHelper.getProject().getFile("/bin/Foo.class");
    assertTrue(classFile.exists());

    List<IPath> traceFiles = traceMarkers.findTraceFiles(sourceFile);
    assertTrue(traceFiles.contains(traceFile.getFullPath()));

    sourceFile.delete(false, new NullProgressMonitor());
    waitForBuild();
    assertFalse(generatedFile.exists());
    assertFalse(traceFile.exists());
  }
  /**
   * Creates a new project resource with the selected name.
   *
   * <p>In normal usage, this method is invoked after the user has pressed Finish on the wizard; the
   * enablement of the Finish button implies that all controls on the pages currently contain valid
   * values.
   *
   * <p>Note that this wizard caches the new project once it has been successfully created;
   * subsequent invocations of this method will answer the same project resource without attempting
   * to create it again.
   *
   * @param monitor TODO
   * @return the created project resource, or <code>null</code> if the project was not created
   */
  protected IProject createNewProject(IProgressMonitor monitor) throws InvocationTargetException {
    SubMonitor sub = SubMonitor.convert(monitor, 100);
    // Project description creation
    IProjectDescription description =
        ResourceUtil.getProjectDescription(destPath, getProjectNatures(), getProjectBuilders());
    description.setName(newProject.getName());
    description.setLocationURI(location);
    // Update the referenced project in case it was initialized.
    if (refProjects != null && refProjects.length > 0) {
      description.setReferencedProjects(refProjects);
    }
    sub.worked(10);

    if (!applySourcedProjectFilesAfterProjectCreated() && isCloneFromGit()) {
      cloneFromGit(newProject, description, sub.newChild(90));
    } else {
      doBasicCreateProject(newProject, description, sub.newChild(75));
      if (!applySourcedProjectFilesAfterProjectCreated()
          && selectedTemplate != null
          && !isCloneFromGit()) {
        selectedTemplate.apply(newProject, true);
      }
    }

    return newProject;
  }
  @Override
  public boolean performFinish() {
    newProject = mainPage.getProjectHandle();
    destPath = mainPage.getLocationPath();
    location = null;
    if (!mainPage.useDefaults()) {
      location = mainPage.getLocationURI();
    } else {
      destPath = destPath.append(newProject.getName());
    }

    if (templatesPage != null) {
      selectedTemplate = templatesPage.getSelectedTemplate();
    }

    if (referencePage != null) {
      refProjects = referencePage.getReferencedProjects();
    }

    if (!deferCreatingProject()) {
      IStatus projectStatus = createAndRefreshProject(true, true, new NullProgressMonitor());
      return projectStatus.isOK();
    }
    return true;
  }
  /**
   * Creates an NL fragment project along with the locale specific properties files.
   *
   * @throws CoreException
   * @throws IOException
   * @throws InvocationTargetException
   * @throws InterruptedException
   */
  private void internationalizePlugins(List plugins, List locales, Map overwrites)
      throws CoreException, IOException, InvocationTargetException, InterruptedException {

    Set created = new HashSet();

    for (Iterator it = plugins.iterator(); it.hasNext(); ) {
      IPluginModelBase plugin = (IPluginModelBase) it.next();

      for (Iterator iter = locales.iterator(); iter.hasNext(); ) {
        Locale locale = (Locale) iter.next();

        IProject project = getNLProject(plugin, locale);
        if (created.contains(project)
            || overwriteWithoutAsking
            || !project.exists()
            || OVERWRITE == overwrites.get(project.getName())) {
          if (!created.contains(project) && project.exists()) {
            project.delete(true, getProgressMonitor());
          }

          if (!created.contains(project)) {
            createNLFragment(plugin, project, locale);
            created.add(project);
            project.getFolder(RESOURCE_FOLDER_PARENT).create(false, true, getProgressMonitor());
          }

          project
              .getFolder(RESOURCE_FOLDER_PARENT)
              .getFolder(locale.toString())
              .create(true, true, getProgressMonitor());
          createLocaleSpecificPropertiesFile(project, plugin, locale);
        }
      }
    }
  }
 private SoftPkg getSoftPkg(final IProject project) {
   final ResourceSet set = ScaResourceFactoryUtil.createResourceSet();
   final IFile softPkgFile = project.getFile(project.getName() + ".spd.xml");
   final Resource resource =
       set.getResource(URI.createFileURI(softPkgFile.getLocation().toString()), true);
   return SoftPkg.Util.getSoftPkg(resource);
 }
示例#25
0
  @Override
  public void doRun(ISelection selection, Event event, UIInstrumentationBuilder instrumentation) {
    instrumentation.metric("command", command);

    if (!(selection instanceof ITextSelection)) {
      instrumentation.metric("Problem", "Selection was not a TextSelection");
    }

    IWorkbenchPage page = DartToolsPlugin.getActivePage();
    if (page == null) {
      instrumentation.metric("Problem", "Page was null");
      return;
    }

    IEditorPart part = page.getActiveEditor();
    if (part == null) {
      instrumentation.metric("Problem", "Part was null");
      return;
    }

    IEditorInput editorInput = part.getEditorInput();
    IProject project = EditorUtility.getProject(editorInput);
    instrumentation.data("Project", project.getName());
    savePubspecFile(project);
    runPubJob(project);
  }
示例#26
0
  protected void execute(GeneralProjectMigration page, String libraryId, IProgressMonitor monitor2)
      throws Exception {

    IProject target = ToolingUtils.importLibrary(libraryId);
    IProject project2Update = this.project;
    // copy projects before as requested
    Boolean projectCopy =
        page.getFieldValueBoolean(GeneralProjectMigration.Fields.copybefore.toString());
    if (projectCopy) {
      project2Update = null;
      String newNameParam =
          page.getFieldValueString(GeneralProjectMigration.Fields.newName.toString());

      if (StringUtils.trimToNull(newNameParam) == null) {
        newNameParam = GeneralProjectMigration.DEFAULT_VALUE_NEWNAME;
      }

      IProjectDescription description = project.getDescription();
      String newName = newNameParam;
      description.setName(newName);
      description.setLocationURI(null);
      System.out.println(
          "ModelMigrationWizard.execute() rename project " + project.getName() + " -> " + newName);
      project.copy(description, true, monitor2);
      IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(description.getName());
      project2Update = project;
    }

    // execute models conversion
    ModelMigrationHelper modelMigrationHelper = new ModelMigrationHelper();
    modelMigrationHelper.updateProject(project2Update, target, libraryId, projectCopy, monitor2);
    monitor2.subTask("Refresh project");
    IFileHelper.refreshFolder(project2Update);
    monitor2.done();
  }
示例#27
0
  public static List<INamespaceDefinition> getNamespaceDefinitions(
      final IProject project, final INamespaceDefinitionTemplate definitionTemplate) {
    if (definitionTemplate != null) {

      Job namespaceDefinitionJob =
          new Job(
              (project != null
                  ? String.format("Loading namespaces for project '%s'", project.getName())
                  : "Loading namespaces")) {

            @Override
            protected IStatus run(IProgressMonitor monitor) {
              List<INamespaceDefinition> namespaceDefinitions = getNamespaceDefinitions(project);
              definitionTemplate.doWithNamespaceDefinitions(
                  (INamespaceDefinition[])
                      namespaceDefinitions.toArray(
                          new INamespaceDefinition[namespaceDefinitions.size()]),
                  project);
              return Status.OK_STATUS;
            }
          };
      namespaceDefinitionJob.setPriority(Job.INTERACTIVE);
      namespaceDefinitionJob.schedule();

      return Collections.emptyList();
    }
    return getNamespaceDefinitions(project);
  }
示例#28
0
  /**
   * @param project
   * @param attInfo
   * @param counter
   */
  public static String createDefaultName(IProject project, ISchemaAttribute attInfo, int counter) {
    if (attInfo.getType().getName().equals("boolean")) // $NON-NLS-1$
    return "true"; //$NON-NLS-1$

    String tag = attInfo.getParent().getName();
    return project.getName() + "." + tag + counter; // $NON-NLS-1$
  }
  /**
   * ************************************************************************ Get the database path
   * for this project
   *
   * @return ***********************************************************************
   */
  @SuppressWarnings("unchecked")
  public String getDatabasePath() {
    HashMap<QualifiedName, Object> properties = null;
    try {
      properties = new HashMap<QualifiedName, Object>(m_project.getPersistentProperties());
    } catch (CoreException e1) {
      System.err.println(
          "Cannot retrieve persistent properties for project " + m_project.getName());
      return null;
    }
    if (!properties.containsKey(ProjectDatabaseProperty.GCS_DATABASE.getKey())) {
      restoreProjectProperties(ProjectDatabaseProperty.GCS_DATABASE);
    }

    try {
      String path = m_project.getPersistentProperty(ProjectDatabaseProperty.GCS_DATABASE.getKey());
      // Relative path
      boolean absolute = true;
      if (!path.isEmpty()) {
        absolute = new File(path).isAbsolute();
      }
      if (!path.isEmpty() && !absolute) {
        IPath projAbsolute = m_project.getLocation();
        String projectPath = projAbsolute.toFile().getAbsolutePath();
        path = projectPath + File.separator + path;
      }
      return path;
    } catch (CoreException e) {
      return null;
    }
  }
  private OMElement getDocumentElement() {
    OMElement documentElement = getElement("libraries", "");
    if (getFragmentHost() != null && !getFragmentHost().trim().equals("")) {
      addAttribute(documentElement, "fragment-host", getFragmentHost().trim());
    }
    for (String jarFileName : getExportedPackageListsFromJar().keySet()) {
      OMElement jarElement = getElement("jar", "");
      addAttribute(jarElement, "name", jarFileName);
      OMElement exportPac = getElement("export-packages", "");
      jarElement.addChild(exportPac);
      List<String> exportedPackagesList = getExportedPackageListsFromJar().get(jarFileName);
      for (String p : exportedPackagesList) {
        exportPac.addChild(getElement("export-package", p));
      }
      documentElement.addChild(jarElement);
    }

    for (IProject project : getExportedPackageListsFromProject().keySet()) {
      OMElement projectElement = getElement("project", "");
      addAttribute(projectElement, "name", project.getName());
      OMElement exportPac = getElement("export-packages", "");
      projectElement.addChild(exportPac);
      List<String> exportedPackagesList = getExportedPackageListsFromProject().get(project);
      for (String p : exportedPackagesList) {
        exportPac.addChild(getElement("export-package", p));
      }
      documentElement.addChild(projectElement);
    }
    return documentElement;
  }