示例#1
0
 /**
  * Returns the Show In... target part ids for the given source part. Merges the contributions from
  * the current perspective and the source part.
  */
 private ArrayList getShowInPartIds(IWorkbenchPart sourcePart) {
   ArrayList targetIds = new ArrayList();
   WorkbenchPage page = (WorkbenchPage) getWindow().getActivePage();
   if (page != null) {
     targetIds.addAll(page.getShowInPartIds());
   }
   IShowInTargetList targetList = getShowInTargetList(sourcePart);
   if (targetList != null) {
     String[] partIds = targetList.getShowInTargetIds();
     if (partIds != null) {
       for (int i = 0; i < partIds.length; ++i) {
         if (!targetIds.contains(partIds[i])) {
           targetIds.add(partIds[i]);
         }
       }
     }
   }
   page.sortShowInPartIds(targetIds);
   return targetIds;
 }
  /*
   * Creates the action bars for an editor. Editors of the same type should
   * share a single editor action bar, so this implementation may return an
   * existing action bar vector.
   */
  private static EditorActionBars createEditorActionBars(
      WorkbenchPage page, EditorDescriptor desc, final IEditorSite site) {
    // Get the editor type.
    String type = desc.getId();

    // If an action bar already exists for this editor type return it.
    Set<EditorActionBars> candidates = actionCache.get(type);
    if (candidates != null) {
      for (EditorActionBars candidate : candidates) {
        if (candidate.getPage() == page) {
          candidate.addRef();
          return candidate;
        }
      }
    }

    // Create a new action bar set.
    EditorActionBars actionBars = new EditorActionBars(page, page.getWorkbenchWindow(), type);
    actionBars.addRef();
    if (candidates == null) {
      candidates = new HashSet<EditorActionBars>(3);
      candidates.add(actionBars);
      actionCache.put(type, candidates);
    } else candidates.add(actionBars);

    // Read base contributor.
    IEditorActionBarContributor contr = desc.createActionBarContributor();
    if (contr != null) {
      actionBars.setEditorContributor(contr);
      contr.init(actionBars, page);
    }

    // Read action extensions.
    EditorActionBuilder builder = new EditorActionBuilder();
    contr = builder.readActionExtensions(desc);
    if (contr != null) {
      actionBars.setExtensionContributor(contr);
      contr.init(actionBars, page);
    }

    // Return action bars.
    return actionBars;
  }