예제 #1
0
 private ResolveMode getResolveMode() {
   ResolveMode resolveMode = ResolveMode.manual;
   try {
     String str = (String) model.genericGet(BndConstants.RESOLVE_MODE);
     if (str != null) resolveMode = Enum.valueOf(ResolveMode.class, str);
   } catch (Exception e) {
     logger.logError("Error parsing '-resolve' header.", e);
   }
   return resolveMode;
 }
예제 #2
0
 private void reallySave(IProgressMonitor monitor) {
   // Actually save, via the source editor
   try {
     boolean saveLocked = this.saving.compareAndSet(false, true);
     if (!saveLocked) {
       logger.logError("Tried to save while already saving", null);
       return;
     }
     sourcePage.doSave(monitor);
     updatePages();
   } finally {
     this.saving.set(false);
   }
 }
예제 #3
0
  public BndEditor() {
    pageFactories.put(WORKSPACE_PAGE, WorkspacePage.MAIN_FACTORY);
    pageFactories.put(WORKSPACE_EXT_PAGE, WorkspacePage.EXT_FACTORY);
    pageFactories.put(CONTENT_PAGE, BundleContentPage.FACTORY);
    pageFactories.put(DESCRIPTION_PAGE, BundleDescriptionPage.FACTORY);
    pageFactories.put(BUILD_PAGE, ProjectBuildPage.FACTORY);
    pageFactories.put(PROJECT_RUN_PAGE, ProjectRunPage.FACTORY);
    pageFactories.put(TEST_SUITES_PAGE, TestSuitesPage.FACTORY);

    IConfigurationElement[] configElems =
        Platform.getExtensionRegistry()
            .getConfigurationElementsFor(Plugin.PLUGIN_ID, "editorPages");
    if (configElems != null)
      for (IConfigurationElement configElem : configElems) {
        String id = configElem.getAttribute("id");
        if (id != null) {
          if (pageFactories.containsKey(id)) logger.logError("Duplicate form page ID: " + id, null);
          else pageFactories.put(id, new DelayedPageFactory(configElem));
        }
      }
  }
예제 #4
0
  public static List<RepositoryPlugin> listRepositories(boolean hideCache) {
    Workspace workspace;
    try {
      workspace = Central.getWorkspace();
    } catch (Exception e1) {
      return Collections.emptyList();
    }

    try {
      List<RepositoryPlugin> plugins = workspace.getPlugins(RepositoryPlugin.class);
      List<RepositoryPlugin> repos = new ArrayList<RepositoryPlugin>(plugins.size() + 1);

      repos.add(Central.getWorkspaceRepository());

      for (RepositoryPlugin plugin : plugins) {
        if (!hideCache || !CACHE_REPO.equals(plugin.getName())) repos.add(plugin);
      }
      return repos;
    } catch (Exception e) {
      logger.logError("Error loading repositories", e);
      return Collections.emptyList();
    }
  }
예제 #5
0
  void updatePages() {
    List<String> requiredPageIds = new LinkedList<String>();

    // Need to know the file and project names.
    Pair<String, String> fileAndProject = getFileAndProject(getEditorInput());
    String path = fileAndProject.getFirst();
    String projectName = fileAndProject.getSecond();

    if (isMainWorkspaceConfig(path, projectName)) {
      requiredPageIds.add(WORKSPACE_PAGE);
    } else if (isExtWorkspaceConfig(path, projectName)) {
      requiredPageIds.add(WORKSPACE_EXT_PAGE);
      setTitleImage(buildFileImg);
    } else if (path.endsWith(LaunchConstants.EXT_BNDRUN)) {
      requiredPageIds.addAll(getPagesBndRun());
    } else {
      requiredPageIds.addAll(getPagesBnd(path));
    }
    requiredPageIds.add(SOURCE_PAGE);

    // Remove pages no longer required and remember the rest in a map
    int i = 0;
    Map<String, IFormPage> pageCache = new HashMap<String, IFormPage>(requiredPageIds.size());
    while (i < getPageCount()) {
      IFormPage current = (IFormPage) pages.get(i);
      if (!requiredPageIds.contains(current.getId())) removePage(i);
      else {
        pageCache.put(current.getId(), current);
        i++;
      }
    }

    // Cache new pages
    for (String pageId : requiredPageIds) {
      if (!pageCache.containsKey(pageId)) {
        IFormPage page =
            SOURCE_PAGE.equals(pageId)
                ? sourcePage
                : pageFactories.get(pageId).createPage(this, model, pageId);
        pageCache.put(pageId, page);
      }
    }

    // Add pages back in
    int requiredPointer = 0;
    int existingPointer = 0;

    while (requiredPointer < requiredPageIds.size()) {
      try {
        String requiredId = requiredPageIds.get(requiredPointer);
        if (existingPointer >= getPageCount()) {
          if (SOURCE_PAGE.equals(requiredId)) addPage(sourcePage, getEditorInput());
          else addPage(pageCache.get(requiredId));
        } else {
          IFormPage existingPage = (IFormPage) pages.get(existingPointer);
          if (!requiredId.equals(existingPage.getId())) {
            if (SOURCE_PAGE.equals(requiredId))
              addPage(existingPointer, sourcePage, getEditorInput());
            else addPage(existingPointer, pageCache.get(requiredId));
          }
        }
        existingPointer++;
      } catch (PartInitException e) {
        logger.logError("Error adding page(s) to the editor.", e);
      }
      requiredPointer++;
    }

    // Set the source page title
    setPageText(sourcePage.getIndex(), "Source");
  }