コード例 #1
0
 @Inject
 void setPart(@Optional @Named(IServiceConstants.ACTIVE_PART) final MPart part) {
   activePart = null;
   if (part != null) {
     Object client = part.getObject();
     if (client instanceof CompatibilityPart) {
       IWorkbenchPart workbenchPart = ((CompatibilityPart) client).getPart();
       activePart = workbenchPart;
     } else if (client != null) {
       if (part.getTransientData().get(E4PartWrapper.E4_WRAPPER_KEY) instanceof E4PartWrapper) {
         activePart = (IWorkbenchPart) part.getTransientData().get(E4PartWrapper.E4_WRAPPER_KEY);
       }
     }
   }
 }
コード例 #2
0
  public EditorReference(
      IEclipseContext windowContext,
      IWorkbenchPage page,
      MPart part,
      IEditorInput input,
      EditorDescriptor descriptor,
      IMemento editorState) {
    super(windowContext, page, part);
    this.input = input;
    this.descriptor = descriptor;
    this.editorState = editorState;

    if (descriptor == null) {
      try {
        String memento = getModel().getPersistedState().get(MEMENTO_KEY);
        if (memento == null) {
          descriptorId = EditorRegistry.EMPTY_EDITOR_ID;
        } else {
          XMLMemento createReadRoot = XMLMemento.createReadRoot(new StringReader(memento));
          IEditorRegistry registry =
              getPage().getWorkbenchWindow().getWorkbench().getEditorRegistry();
          descriptorId = createReadRoot.getString(IWorkbenchConstants.TAG_ID);
          this.descriptor = (EditorDescriptor) registry.findEditor(descriptorId);

          boolean pinnedVal =
              "true"
                  .equals(createReadRoot.getString(IWorkbenchConstants.TAG_PINNED)); // $NON-NLS-1$
          setPinned(pinnedVal);

          String ttip = createReadRoot.getString(IWorkbenchConstants.TAG_TOOLTIP);
          part.getTransientData().put(IPresentationEngine.OVERRIDE_TITLE_TOOL_TIP_KEY, ttip);
        }
      } catch (WorkbenchException e) {
        WorkbenchPlugin.log(e);
      }
    } else {
      descriptorId = this.descriptor.getId();
    }
  }
コード例 #3
0
 private void replacePlaceholder(MPlaceholder ph) {
   MPart part = createModelElement(MPart.class);
   part.setElementId(ph.getElementId());
   part.getTransientData()
       .put(
           IPresentationEngine.OVERRIDE_ICON_IMAGE_KEY,
           ImageDescriptor.getMissingImageDescriptor().createImage());
   String label = (String) ph.getTransientData().get(TAG_LABEL);
   if (label != null) {
     part.setLabel(label);
   } else {
     part.setLabel(getLabel(ph.getElementId()));
   }
   part.setContributionURI(COMPATIBILITY_VIEW_URI);
   part.setCloseable(true);
   MElementContainer<MUIElement> curParent = ph.getParent();
   int curIndex = curParent.getChildren().indexOf(ph);
   curParent.getChildren().remove(curIndex);
   curParent.getChildren().add(curIndex, part);
   if (curParent.getSelectedElement() == ph) {
     curParent.setSelectedElement(part);
   }
 }