Example #1
0
    @Override
    public IStatus runInWorkspace(IProgressMonitor monitor) {
      Set<Repository> repos;
      synchronized (repositoriesChanged) {
        if (repositoriesChanged.isEmpty()) {
          return Status.OK_STATUS;
        }
        repos = new LinkedHashSet<>(repositoriesChanged);
        repositoriesChanged.clear();
      }
      IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
      Set<IProject> toRefresh = new LinkedHashSet<>();
      for (IProject p : projects) {
        if (!p.isAccessible()) {
          continue;
        }
        RepositoryMapping mapping = RepositoryMapping.getMapping(p);
        if (mapping != null && repos.contains(mapping.getRepository())) {
          toRefresh.add(p);
        }
      }
      monitor.beginTask(UIText.Activator_refreshingProjects, toRefresh.size());

      for (IProject p : toRefresh) {
        if (monitor.isCanceled()) {
          return Status.CANCEL_STATUS;
        }
        ISchedulingRule rule = p.getWorkspace().getRuleFactory().refreshRule(p);
        try {
          getJobManager().beginRule(rule, monitor);
          // handle missing projects after branch switch
          if (p.isAccessible()) {
            p.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(monitor, 1));
          }
        } catch (CoreException e) {
          handleError(UIText.Activator_refreshFailed, e, false);
          return new Status(IStatus.ERROR, getPluginId(), e.getMessage());
        } finally {
          getJobManager().endRule(rule);
        }
      }
      if (!monitor.isCanceled()) {
        // re-schedule if we got some changes in the meantime
        synchronized (repositoriesChanged) {
          if (!repositoriesChanged.isEmpty()) {
            schedule(100);
          }
        }
      }
      monitor.done();
      return Status.OK_STATUS;
    }
Example #2
0
 private static void deleteMarkersWithCompiledFile(final IProject project, final IFile file) {
   if (!project.isAccessible()) {
     return;
   }
   try {
     for (final IMarker m : project.findMarkers(PROBLEM_MARKER, true, IResource.DEPTH_INFINITE)) {
       final Object source_id = m.getAttribute(IMarker.SOURCE_ID);
       if (source_id != null
           && source_id instanceof String
           && source_id.equals(file.getFullPath().toString())) {
         try {
           m.delete();
         } catch (final CoreException e) {
           // not much to do
         }
       }
     }
     for (final IMarker m : project.findMarkers(TASK_MARKER, true, IResource.DEPTH_INFINITE)) {
       final Object source_id = m.getAttribute(IMarker.SOURCE_ID);
       if (source_id != null
           && source_id instanceof String
           && source_id.equals(file.getFullPath().toString())) {
         try {
           m.delete();
         } catch (final CoreException e) {
           // not much to do
         }
       }
     }
   } catch (final CoreException e) {
     // not much to do
   }
 }
    @Override
    public CExternalSetting[] getExternalSettings() {
      IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(fProjName);
      if (project.isAccessible()) {
        ICProjectDescription des =
            CProjectDescriptionManager.getInstance().getProjectDescription(project, false);
        if (des != null) {
          ICConfigurationDescription cfg =
              fCfgId.length() != 0
                  ? des.getConfigurationById(fCfgId)
                  : des.getActiveConfiguration();

          if (cfg != null) {
            CExternalSetting[] es;
            ICExternalSetting[] ies = cfg.getExternalSettings();
            if (ies instanceof CExternalSetting[]) es = (CExternalSetting[]) ies;
            else {
              es = new CExternalSetting[ies.length];
              System.arraycopy(ies, 0, es, 0, es.length);
            }
            // Update the cache with the real settings this configuration is exporting
            cachedSettings.put(fId, es);
            return es;
          }
        }
      }
      // If project not yet accessible, just return the previous settings
      // for the moment. We'll update again when the referenced project reappears
      if (!cachedSettings.containsKey(fId) && prevSettings.length > 0)
        cachedSettings.putIfAbsent(fId, prevSettings);
      if (prevSettings.length == 0 && cachedSettings.containsKey(fId))
        return cachedSettings.get(fId);
      return prevSettings;
    }
  protected List<String> getSourceFolders(IProject project) {
    List<String> result = new ArrayList<String>();
    IJavaProject javaProject = JavaCore.create(project);
    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();

    try {
      for (IPackageFragmentRoot packageFragmentRoot : javaProject.getPackageFragmentRoots()) {
        if (packageFragmentRoot.getKind() == IPackageFragmentRoot.K_SOURCE) {
          IPath path = packageFragmentRoot.getPath();
          IFolder folder = root.getFolder(path);
          String location = folder.getLocation().toString();

          if (!location.contains("src-gen")) {
            result.add(location);
          }
        }
      }

      for (IProject referencedProject : javaProject.getProject().getReferencedProjects()) {
        if (referencedProject.isAccessible() && referencedProject.hasNature(JavaCore.NATURE_ID)) {
          result.addAll(getSourceFolders(referencedProject));
        }
      }

    } catch (JavaModelException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();

    } catch (CoreException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }

    return result;
  }
Example #5
0
  /**
   * {@inheritDoc}
   *
   * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench,
   *     org.eclipse.jface.viewers.IStructuredSelection)
   */
  public void init(IWorkbench iWorkbench, IStructuredSelection iSelection) {
    this.workbench = iWorkbench;
    this.selection = iSelection;

    // load the ecore models from the workspace to ensure that all models are available in the
    // wizard
    IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
    for (IProject iProject : projects) {
      try {
        if (iProject.isAccessible()) {
          List<IFile> members = this.members(iProject, IAcceleoConstants.ECORE_FILE_EXTENSION);
          for (IFile iFile : members) {
            Map<String, String> dynamicEcorePackagePaths =
                AcceleoPackageRegistry.INSTANCE.getDynamicEcorePackagePaths();
            Collection<String> values = dynamicEcorePackagePaths.values();
            boolean contains = values.contains(iFile.getFullPath().toString());
            if (!contains) {
              AcceleoPackageRegistry.INSTANCE.registerEcorePackages(
                  iFile.getFullPath().toString(),
                  AcceleoDynamicMetamodelResourceSetImpl.DYNAMIC_METAMODEL_RESOURCE_SET);
            }
          }
        }
      } catch (CoreException e) {
        AcceleoUIActivator.log(e, false);
      }
    }
  }
  @Override
  public ModelWorkspaceItem getParent(final IResource resource) {
    CoreArgCheck.isNotNull(resource);

    IProject project = resource.getProject();
    if (project.isAccessible() && !ModelerCore.hasModelNature(project)) {
      return null;
    }

    // If the resource is an IProject... return the resource
    if (resource instanceof IProject) {
      return this;
    }

    // If the parent is null, return null
    final IResource parent = resource.getParent();
    if (parent == null) {
      return null;
    }

    // Calculate the parent path from the given resource
    final IPath path = resource.getFullPath();
    final IPath parentPath = path.removeLastSegments(1);

    // Find the workspaceItem for the parent path1
    return getWorkspaceItem(parentPath);
  }
  public synchronized void cleanUp(IProgressMonitor monitor) throws CoreException {
    DeltaProcessingState state = ModelManager.getModelManager().deltaState;
    HashMap roots = state.roots;
    // HashMap sourceAttachments = state.sourceAttachments;
    if (roots == null /* && sourceAttachments == null */) return;
    HashMap knownFolders = getFolders();
    Iterator iterator = knownFolders.keySet().iterator();
    while (iterator.hasNext()) {
      IPath path = (IPath) iterator.next();
      if ((roots != null && !roots.containsKey(path))
      /*
       * & (sourceAttachments != null && !sourceAttachments
       * .containsKey(path))
       */ ) {
        IFolder folder = (IFolder) knownFolders.get(path);
        if (folder != null) folder.delete(true, monitor);
      }
    }
    IProject project = getExternalFoldersProject();
    if (project.isAccessible() && project.members().length == 1 /*
																	 * remaining
																	 * member is
																	 * .project
																	 */) project.delete(true, monitor);
  }
  public void testResolutionOfArchetypeFromRepository() throws Exception {
    String oldSettings = mavenConfiguration.getUserSettingsFile();
    try {
      mavenConfiguration.setUserSettingsFile(
          new File("settingsWithDefaultRepos.xml").getAbsolutePath());

      Archetype archetype = new Archetype();
      archetype.setGroupId("org.eclipse.m2e.its");
      archetype.setArtifactId("mngeclipse-2110");
      archetype.setVersion("1.0");
      archetype.setRepository("http://bad.host"); // should be mirrored by settings

      IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("mngeclipse-2110");
      ProjectImportConfiguration pic = new ProjectImportConfiguration(new ResolverConfiguration());

      IProjectConfigurationManager manager =
          MavenPlugin.getDefault().getProjectConfigurationManager();
      manager.createArchetypeProject(
          project,
          null,
          archetype,
          "m2e.its",
          "mngeclipse-2110",
          "1.0-SNAPSHOT",
          "jar",
          new Properties(),
          pic,
          monitor);

      assertTrue(project.isAccessible());
    } finally {
      mavenConfiguration.setUserSettingsFile(oldSettings);
    }
  }
Example #9
0
  /**
   * Returns a commit comment specific to <code>task</code> and <code>resources</code>. If <code>
   * resources</code> is null or the associated projects do not specify a custom commit comment
   * template the global template is used.
   *
   * <p>This method must be invoked on the UI thread.
   *
   * @param checkTaskRepository if true, a warning dialog is displayed in case <code>task</code> is
   *     associated with a different repository than any of the <code>resources</code>
   * @param task the task to generate the commit comment for
   * @param resources that are being committed or null
   * @return a commit comment or an empty string if the user opted to abort generating the commit
   *     message
   * @since 3.5
   */
  public static String getComment(boolean checkTaskRepository, ITask task, IResource[] resources) {
    // lookup project specific template
    String template = null;
    Set<IProject> projects = new HashSet<IProject>();
    if (resources != null) {
      for (IResource resource : resources) {
        IProject project = resource.getProject();
        if (project != null && project.isAccessible() && !projects.contains(project)) {
          TeamPropertiesLinkProvider provider = new TeamPropertiesLinkProvider();
          template = provider.getCommitCommentTemplate(project);
          if (template != null) {
            break;
          }
          projects.add(project);
        }
      }
    }

    boolean proceed = true;

    // prompt if resources do not match task
    if (checkTaskRepository) {
      boolean unmatchedRepositoryFound = false;
      for (IProject project : projects) {
        TaskRepository repository = TasksUiPlugin.getDefault().getRepositoryForResource(project);
        if (repository != null) {
          if (!repository.getRepositoryUrl().equals(task.getRepositoryUrl())) {
            unmatchedRepositoryFound = true;
          }
        }
      }

      if (unmatchedRepositoryFound) {
        if (Display.getCurrent() != null) {
          proceed =
              MessageDialog.openQuestion(
                  WorkbenchUtil.getShell(),
                  Messages.ContextChangeSet_Mylyn_Change_Set_Management,
                  Messages.ContextChangeSet_ATTEMPTING_TO_COMMIT_RESOURCE);
        } else {
          proceed = false;
        }
      }
    }

    if (proceed) {
      if (template == null) {
        template =
            FocusedTeamUiPlugin.getDefault()
                .getPreferenceStore()
                .getString(FocusedTeamUiPlugin.COMMIT_TEMPLATE);
      }
      return FocusedTeamUiPlugin.getDefault()
          .getCommitTemplateManager()
          .generateComment(task, template);
    } else {
      return ""; //$NON-NLS-1$
    }
  }
Example #10
0
 /*
  * (non-Javadoc)
  *
  * @see featureide.core.internal.IMarkerHandler#deleteAllModelMarkers()
  */
 public void deleteAllModelMarkers() {
   try {
     if (project.isAccessible()) project.deleteMarkers(MODEL_MARKER, false, IResource.DEPTH_ZERO);
     if (modelFile.exists()) modelFile.deleteMarkers(MODEL_MARKER, false, IResource.DEPTH_ZERO);
   } catch (CoreException e) {
     e.printStackTrace();
   }
 }
Example #11
0
 /**
  * Return if the project has the given nature.
  *
  * @param project
  * @param natureId
  * @return <code>true</code> if project has given nature
  * @since 1.0.0
  */
 public static boolean hasRuntime(IProject project, String natureId) {
   if (project == null || !project.isAccessible()) return false;
   try {
     return project.hasNature(natureId);
   } catch (CoreException e) {
     return false;
   }
 }
 private void triggerRebuild() throws CoreException {
   IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
   for (IProject project : projects) {
     if (project.isAccessible()) {
       BuilderUtil.triggerClean(project, JSHintBuilder.ID);
     }
   }
 }
 private boolean isJavaProject(IProject project) {
   try {
     return project.isAccessible() && project.hasNature(JavaCore.NATURE_ID);
   } catch (CoreException e) {
     SpringPropertiesEditorPlugin.log(e);
   }
   return false;
 }
  @Override
  protected synchronized void doCloudOp(IProgressMonitor monitor) throws Exception {
    if (model.getCloudTarget().isConnected()) {
      model.setRefreshState(RefreshState.loading("Fetching Apps..."));
      try {

        // 1. Fetch basic list of applications. Should be the "faster" of
        // the
        // two refresh operations

        List<CloudApplication> apps = requests.getApplicationsWithBasicInfo();

        Map<CloudAppInstances, IProject> updatedApplications =
            new HashMap<CloudAppInstances, IProject>();
        if (apps != null) {

          Map<String, String> existingProjectToAppMappings =
              this.model.getProjectToAppMappingStore().getMapping();

          for (CloudApplication app : apps) {

            String projectName = existingProjectToAppMappings.get(app.getName());
            IProject project = null;
            if (projectName != null) {
              project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
              if (project == null || !project.isAccessible()) {
                project = null;
              }
            }

            // No stats available at this stage. Just set stats to null
            // for now.
            updatedApplications.put(new CloudAppInstances(app, null), project);
          }
        }

        this.model.updateElements(updatedApplications);

        // 2. Launch the slower app stats/instances refresh operation.
        this.model
            .getOperationsExecution(ui)
            .runOpAsynch(new AppInstancesRefreshOperation(this.model));
        this.model
            .getOperationsExecution(ui)
            .runOpAsynch(new HealthCheckRefreshOperation(this.model));
        model.setRefreshState(RefreshState.READY);
      } catch (Exception e) {
        /*
         * Failed to obtain applications list from CF
         */
        model.updateElements(null);
        model.setRefreshState(RefreshState.error(e));
        throw e;
      }
    } else {
      model.updateElements(null);
    }
  }
 @Override
 protected IStatus run(IProgressMonitor monitor) {
   MultiStatus result =
       new MultiStatus(
           ResourcesPlugin.PI_RESOURCES,
           IResourceStatus.FAILED_SETTING_CHARSET,
           Messages.resources_updatingEncoding,
           null);
   monitor = Policy.monitorFor(monitor);
   try {
     monitor.beginTask(Messages.resources_charsetUpdating, Policy.totalWork);
     final ISchedulingRule rule = workspace.getRuleFactory().modifyRule(workspace.getRoot());
     try {
       workspace.prepareOperation(rule, monitor);
       workspace.beginOperation(true);
       Map.Entry<IProject, Boolean> next;
       while ((next = getNextChange()) != null) {
         // just exit if the system is shutting down or has been shut down
         // it is too late to change the workspace at this point anyway
         if (systemBundle.getState() != Bundle.ACTIVE) return Status.OK_STATUS;
         IProject project = next.getKey();
         try {
           if (project.isAccessible()) {
             boolean shouldDisableCharsetDeltaJob = next.getValue().booleanValue();
             // flush preferences for non-derived resources
             flushPreferences(
                 getPreferences(project, false, false, true), shouldDisableCharsetDeltaJob);
             // flush preferences for derived resources
             flushPreferences(
                 getPreferences(project, false, true, true), shouldDisableCharsetDeltaJob);
           }
         } catch (BackingStoreException e) {
           // we got an error saving
           String detailMessage = Messages.resources_savingEncoding;
           result.add(
               new ResourceStatus(
                   IResourceStatus.FAILED_SETTING_CHARSET,
                   project.getFullPath(),
                   detailMessage,
                   e));
         }
       }
       monitor.worked(Policy.opWork);
     } catch (OperationCanceledException e) {
       workspace.getWorkManager().operationCanceled();
       throw e;
     } finally {
       workspace.endOperation(rule, true, Policy.subMonitorFor(monitor, Policy.endOpWork));
     }
   } catch (CoreException ce) {
     return ce.getStatus();
   } finally {
     monitor.done();
   }
   return result;
 }
 private void checkXtextNature() {
   IFileEditorInput editorInput = (IFileEditorInput) getEditorInput();
   IProject project = editorInput.getFile().getProject();
   if (project != null
       && !XtextProjectHelper.hasNature(project)
       && project.isAccessible()
       && !project.isHidden()) {
     addNature(project);
   }
 }
 private IProject findAppEngineProject(IProject project) {
   if (project != null && project.isAccessible()) {
     try {
       return AppEngineConnectedNature.getAppEngineProject(project);
     } catch (CoreException e) {
       AppEngineRPCPlugin.log(e);
     }
   }
   return null;
 }
  @Override
  public IProject resolveProject() {
    IProject result = ResourcesPlugin.getWorkspace().getRoot().getProject(getProjectName());

    if ((result != null) && !result.isAccessible()) {
      result = null;
    }

    return result;
  }
Example #19
0
    public void resourceChanged(IResourceChangeEvent event) {
      if (event.getBuildKind() == IncrementalProjectBuilder.CLEAN_BUILD) {
        Object source = event.getSource();
        try {
          if (source instanceof IProject) {
            IProject project = (IProject) source;
            ProjectIndexerManager.removeProject(project.getFullPath());
            ProjectIndexerManager.indexProject(project);

          } else if (source instanceof IWorkspace) {
            IWorkspace workspace = (IWorkspace) source;
            IProject[] projects = workspace.getRoot().getProjects();

            // remove from index:
            for (IProject project : projects) {
              if (!project.isAccessible()) {
                continue;
              }
              IScriptProject scriptProject = DLTKCore.create(project);
              if (scriptProject.isOpen()) {
                IProjectFragment[] projectFragments = scriptProject.getProjectFragments();
                for (IProjectFragment projectFragment : projectFragments) {
                  ProjectIndexerManager.removeProjectFragment(
                      scriptProject, projectFragment.getPath());
                }
                ProjectIndexerManager.removeProject(project.getFullPath());
              }
            }

            // add to index:
            for (IProject project : projects) {
              if (!project.isAccessible()) {
                continue;
              }
              ProjectIndexerManager.indexProject(project);
            }
          }
        } catch (CoreException e) {
          Logger.logException(e);
        }
      }
    }
Example #20
0
  /**
   * Gets the CDT environment from the CDT project's configuration referenced by the launch
   *
   * @since 3.0
   */
  public static String[] getLaunchEnvironment(ILaunchConfiguration config) throws CoreException {
    // Get the project
    String projectName =
        config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String) null);
    if (projectName == null) {
      return null;
    }
    projectName = projectName.trim();
    if (projectName.length() == 0) {
      return null;
    }
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
    if (project == null || !project.isAccessible()) return null;

    ICProjectDescription projDesc = CoreModel.getDefault().getProjectDescription(project, false);

    // Not a CDT project?
    if (projDesc == null) return null;

    String buildConfigID =
        config.getAttribute(
            ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_ID, ""); // $NON-NLS-1$
    ICConfigurationDescription cfg = null;
    if (buildConfigID.length() != 0) cfg = projDesc.getConfigurationById(buildConfigID);

    // if configuration is null fall-back to active
    if (cfg == null) cfg = projDesc.getActiveConfiguration();

    // Environment variables and inherited vars
    HashMap<String, String> envMap = new HashMap<String, String>();
    IEnvironmentVariable[] vars =
        CCorePlugin.getDefault().getBuildEnvironmentManager().getVariables(cfg, true);
    for (IEnvironmentVariable var : vars) envMap.put(var.getName(), var.getValue());

    // Add variables from build info
    ICdtVariable[] build_vars = CCorePlugin.getDefault().getCdtVariableManager().getVariables(cfg);
    for (ICdtVariable var : build_vars) {
      try {
        envMap.put(var.getName(), var.getStringValue());
      } catch (CdtVariableException e) {
        // Some Eclipse dynamic variables can't be resolved dynamically... we don't care.
      }
    }

    // Turn it into an envp format
    List<String> strings = new ArrayList<String>(envMap.size());
    for (Entry<String, String> entry : envMap.entrySet()) {
      StringBuffer buffer = new StringBuffer(entry.getKey());
      buffer.append('=').append(entry.getValue());
      strings.add(buffer.toString());
    }

    return strings.toArray(new String[strings.size()]);
  }
 protected boolean hasModelNature(IProject project) {
   String nature = getModelNatureName();
   if (nature == null) return super.hasModelNature(project);
   if (project == null || !project.isAccessible()) return false;
   try {
     if (project.hasNature(nature)) return true;
   } catch (CoreException e) {
     ModelUIPlugin.getPluginLog().logError(e);
   }
   return false;
 }
Example #22
0
 /**
  * Iterates through the list of projects and adds the first open project to the list of projects
  */
 private void findOpenProjects() {
   IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
   for (IProject proj : projects) {
     // TODO: Still need to check if this is a java project or not
     if (proj.isAccessible()) {
       openProjects.add(proj);
       break; // Only deal with one project for now
       // Support for more projects later...maybe
     }
   }
 }
 public IProject createExternalSourceArchivesProject(IProgressMonitor monitor)
     throws CoreException {
   IProject project = getExternalSourceArchivesProject();
   if (!project.isAccessible()) {
     if (!project.exists()) {
       createExternalSourceArchivesProject(project, monitor);
     }
     openExternalSourceArchivesProject(project, monitor);
   }
   return project;
 }
 @Override
 public IJavaProject getJavaProject() {
   try {
     IProject p = getProject();
     if (p != null && p.isAccessible() && p.hasNature(JavaCore.NATURE_ID)) {
       return JavaCore.create(p);
     }
   } catch (Exception e) {
     EditorSupportActivator.log(e);
   }
   return null;
 }
 protected static boolean isOldProject(IProject project) throws CoreException {
   if (project.isAccessible()) {
     IProjectDescription desc = project.getDescription();
     ICommand builder[] = desc.getBuildSpec();
     for (int j = 0; j < builder.length; j++) {
       if (builder[j].getBuilderName().equals(MakeCorePlugin.OLD_BUILDER_ID)) {
         return true;
       }
     }
   }
   return false;
 }
Example #26
0
 public static void updateAllSonarMarkerSeverity() throws CoreException {
   for (IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
     if (project.isAccessible()) {
       for (IMarker marker :
           project.findMarkers(SonarCorePlugin.MARKER_ID, true, IResource.DEPTH_INFINITE)) {
         boolean isNew = marker.getAttribute(SONAR_MARKER_IS_NEW_ATTR, false);
         marker.setAttribute(
             IMarker.SEVERITY, isNew ? markerSeverityForNewIssues : markerSeverity);
       }
     }
   }
 }
 protected IStatus run(IProgressMonitor monitor) {
   MultiStatus result =
       new MultiStatus(
           CSSContentProperties.CSSCORE_ID,
           IResourceStatus.FAILED_SETTING_CHARSET,
           CSSCoreMessages.CSSContentPropertiesManager_Updating,
           null);
   monitor = monitor == null ? new NullProgressMonitor() : monitor;
   try {
     monitor.beginTask(
         CSSCoreMessages.CSSContentPropertiesManager_Updating, asyncChanges.size());
     try {
       IProject next;
       while ((next = getNextChange()) != null) {
         // just exit if the system is shutting down or has
         // been shut down
         // it is too late to change the workspace at this
         // point anyway
         if (Platform.getBundle("org.eclipse.osgi").getState() != Bundle.ACTIVE) // $NON-NLS-1$
         return Status.OK_STATUS;
         try {
           // save the preferences nodes
           if (next.isAccessible()) {
             // save css profile preferences
             Preferences projectPrefs =
                 CSSContentProperties.getPreferences(
                     next, CSSContentProperties.CSS_PROFILE, false);
             if (projectPrefs != null) projectPrefs.flush();
           }
         } catch (BackingStoreException e) {
           // we got an error saving
           String detailMessage =
               NLS.bind(
                   CSSCoreMessages.CSSContentPropertiesManager_Problems_Updating,
                   next.getFullPath());
           result.add(
               new Status(
                   1 << (IResourceStatus.FAILED_SETTING_CHARSET % 100 / 33),
                   ResourcesPlugin.PI_RESOURCES,
                   IResourceStatus.FAILED_SETTING_CHARSET,
                   detailMessage,
                   e));
         }
       }
       monitor.worked(1);
     } catch (OperationCanceledException e) {
       throw e;
     }
   } finally {
     monitor.done();
   }
   return result;
 }
Example #28
0
 /**
  * Returns the corresponding Java project or <code>null</code> a for given project.
  *
  * @param project the project the Java project is requested for
  * @return the requested Java project or <code>null</code> if the Java project is not defined or
  *     the project is not accessible
  */
 public static IJavaProject getJavaProject(IProject project) {
   if (project.isAccessible()) {
     try {
       if (project.hasNature(JavaCore.NATURE_ID)) {
         return (IJavaProject) project.getNature(JavaCore.NATURE_ID);
       }
     } catch (CoreException e) {
       SpringCore.log("Error getting Java project for project '" + project.getName() + "'", e);
     }
   }
   return null;
 }
 public static String evaluateEnclosingProject(IAdaptable adaptable) {
   IProject project = (IProject) adaptable.getAdapter(IProject.class);
   if (project == null) {
     IResource resource = (IResource) adaptable.getAdapter(IResource.class);
     if (resource != null) {
       project = resource.getProject();
     }
   }
   if (project != null && project.isAccessible()) {
     return project.getName();
   }
   return null;
 }
Example #30
0
 @Override
 public boolean visit(IResourceDelta delta) throws CoreException {
   IResource res = delta.getResource();
   if (res instanceof IProject && delta.getKind() == IResourceDelta.CHANGED) {
     IProject project = (IProject) res;
     if (!project.isAccessible()) {
       // only track open C projects
       return false;
     }
   }
   checkInvalidate(delta, res);
   return true;
 }