com.intellij.openapi.Disposable Java Examples

The following examples show how to use com.intellij.openapi.Disposable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: StableWidgetTracker.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public StableWidgetTracker(
  InspectorService.Location initialLocation,
  FlutterDartAnalysisServer flutterAnalysisServer,
  Project project,
  Disposable parentDisposable
) {
  Disposer.register(parentDisposable, this);
  converter = new OutlineOffsetConverter(project, initialLocation.getFile());
  currentOutlines = new EventStream<>(ImmutableList.of());
  this.flutterAnalysisServer = flutterAnalysisServer;
  this.initialLocation = initialLocation;

  final DartAnalysisServerService analysisServerService = DartAnalysisServerService.getInstance(project);
  currentFilePath = FileUtil.toSystemDependentName(initialLocation.getFile().getPath());
  flutterAnalysisServer.addOutlineListener(currentFilePath, outlineListener);
}
 
Example #2
Source File: InspectorTree.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public InspectorTree(final DefaultMutableTreeNode treemodel,
                     String treeName,
                     boolean detailsSubtree,
                     String parentTreeName,
                     boolean rootVisible,
                     boolean legacyMode,
                     Disposable parentDisposable) {
  super(treemodel);
  setUI(new InspectorTreeUI());
  final BasicTreeUI ui = (BasicTreeUI)getUI();
  this.detailsSubtree = detailsSubtree;

  setRootVisible(rootVisible);
  getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  registerShortcuts(parentDisposable);
  if (detailsSubtree) {
    // TODO(devoncarew): This empty text is not showing up for the details area, even when there are no detail nodes.
    getEmptyText().setText(treeName + " subtree of the selected " + parentTreeName);
  }
  else {
    getEmptyText().setText(treeName + " tree for the running app");
  }
}
 
Example #3
Source File: WidgetIndentsHighlightingPass.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void updatePreviewHighlighter(MarkupModel mm, WidgetIndentsPassData data) {
  final FlutterSettings settings = FlutterSettings.getInstance();
  if (!settings.isEnableHotUiInCodeEditor()) return;

  if (data.previewsForEditor == null && myEditor instanceof EditorImpl) {
    // TODO(jacobr): is there a way to get access to a disposable that will
    // trigger when the editor disposes than casting to EditorImpl?

    final Disposable parentDisposable = ((EditorImpl)myEditor).getDisposable();

    final TextRange range = new TextRange(0, Integer.MAX_VALUE);
    final RangeHighlighter highlighter =
      mm.addRangeHighlighter(
        0,
        myDocument.getTextLength(),
        HighlighterLayer.FIRST,
        null,
        HighlighterTargetArea.LINES_IN_RANGE
      );
    data.previewsForEditor = new PreviewsForEditor(context, editorEventService, myEditor, parentDisposable);
    highlighter.setCustomRenderer(data.previewsForEditor);
  }
  if (data.previewsForEditor != null) {
    data.previewsForEditor.outlinesChanged(data.myDescriptors);
  }
}
 
Example #4
Source File: WidgetIndentsHighlightingPass.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void updatePreviewHighlighter(MarkupModel mm, WidgetIndentsPassData data) {
  final FlutterSettings settings = FlutterSettings.getInstance();
  if (!settings.isEnableHotUiInCodeEditor()) return;

  if (data.previewsForEditor == null && myEditor instanceof EditorImpl) {
    // TODO(jacobr): is there a way to get access to a disposable that will
    // trigger when the editor disposes than casting to EditorImpl?

    final Disposable parentDisposable = ((EditorImpl)myEditor).getDisposable();

    final TextRange range = new TextRange(0, Integer.MAX_VALUE);
    final RangeHighlighter highlighter =
      mm.addRangeHighlighter(
        0,
        myDocument.getTextLength(),
        HighlighterLayer.FIRST,
        null,
        HighlighterTargetArea.LINES_IN_RANGE
      );
    data.previewsForEditor = new PreviewsForEditor(context, editorEventService, myEditor, parentDisposable);
    highlighter.setCustomRenderer(data.previewsForEditor);
  }
  if (data.previewsForEditor != null) {
    data.previewsForEditor.outlinesChanged(data.myDescriptors);
  }
}
 
Example #5
Source File: InspectorTree.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public InspectorTree(final DefaultMutableTreeNode treemodel,
                     String treeName,
                     boolean detailsSubtree,
                     String parentTreeName,
                     boolean rootVisible,
                     boolean legacyMode,
                     Disposable parentDisposable) {
  super(treemodel);
  setUI(new InspectorTreeUI());
  final BasicTreeUI ui = (BasicTreeUI)getUI();
  this.detailsSubtree = detailsSubtree;

  setRootVisible(rootVisible);
  getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
  registerShortcuts(parentDisposable);
  if (detailsSubtree) {
    // TODO(devoncarew): This empty text is not showing up for the details area, even when there are no detail nodes.
    getEmptyText().setText(treeName + " subtree of the selected " + parentTreeName);
  }
  else {
    getEmptyText().setText(treeName + " tree for the running app");
  }
}
 
Example #6
Source File: ServiceHelper.java    From intellij with Apache License 2.0 6 votes vote down vote up
private static <T> void registerService(
    ComponentManager componentManager,
    Class<T> key,
    T implementation,
    Disposable parentDisposable) {
  boolean exists = componentManager.getService(key) != null;
  if (exists) {
    // upstream code can do it all for us
    ServiceContainerUtil.replaceService(componentManager, key, implementation, parentDisposable);
    return;
  }

  // otherwise we should manually unregister on disposal
  ServiceContainerUtil.registerServiceInstance(componentManager, key, implementation);
  Disposer.register(
      parentDisposable,
      () ->
          ((MutablePicoContainer) componentManager.getPicoContainer())
              .unregisterComponent(key.getName()));
}
 
Example #7
Source File: WidgetViewController.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
WidgetViewController(WidgetViewModelData data, Disposable parent) {
  this.data = data;
  Disposer.register(parent, this);
  groupClient = new InspectorGroupManagerService.Client(this) {
    @Override
    public void onInspectorAvailabilityChanged() {
      WidgetViewController.this.onInspectorAvailabilityChanged();
    }

    @Override
    public void requestRepaint(boolean force) {
      onFlutterFrame();
    }

    @Override
    public void onFlutterFrame() {
      WidgetViewController.this.onFlutterFrame();
    }

    public void onSelectionChanged(DiagnosticsNode selection) {
      WidgetViewController.this.onSelectionChanged(selection);
    }
  };
  data.context.inspectorGroupManagerService.addListener(groupClient, parent);
}
 
Example #8
Source File: ServiceHelperCompat.java    From intellij with Apache License 2.0 6 votes vote down vote up
public static <T> void registerService(
    ComponentManager componentManager,
    Class<T> key,
    T implementation,
    Disposable parentDisposable) {
  @SuppressWarnings({"rawtypes", "unchecked"}) // #api193: wildcard generics added in 2020.1
  List<? extends IdeaPluginDescriptor> loadedPlugins = (List) PluginManager.getLoadedPlugins();
  Optional<? extends IdeaPluginDescriptor> platformPlugin =
      loadedPlugins.stream()
          .filter(descriptor -> descriptor.getName().startsWith("IDEA CORE"))
          .findAny();

  Verify.verify(platformPlugin.isPresent());

  ((ComponentManagerImpl) componentManager)
      .registerServiceInstance(key, implementation, platformPlugin.get());
}
 
Example #9
Source File: StableWidgetTracker.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public StableWidgetTracker(
  InspectorService.Location initialLocation,
  FlutterDartAnalysisServer flutterAnalysisServer,
  Project project,
  Disposable parentDisposable
) {
  Disposer.register(parentDisposable, this);
  converter = new OutlineOffsetConverter(project, initialLocation.getFile());
  currentOutlines = new EventStream<>(ImmutableList.of());
  this.flutterAnalysisServer = flutterAnalysisServer;
  this.initialLocation = initialLocation;

  final DartAnalysisServerService analysisServerService = DartAnalysisServerService.getInstance(project);
  currentFilePath = FileUtil.toSystemDependentName(initialLocation.getFile().getPath());
  flutterAnalysisServer.addOutlineListener(currentFilePath, outlineListener);
}
 
Example #10
Source File: PerfMemoryPanel.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
PerfMemoryPanel(@NotNull FlutterApp app, @NotNull Disposable parentDisposable) {
  setLayout(new BorderLayout());
  setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), MEMORY_TAB_LABEL));
  setMinimumSize(new Dimension(0, PerfMemoryPanel.HEIGHT));
  setPreferredSize(new Dimension(Short.MAX_VALUE, PerfMemoryPanel.HEIGHT));

  final JPanel heapDisplay = HeapDisplay.createJPanelView(parentDisposable, app);
  add(heapDisplay, BorderLayout.CENTER);

  if (app.getVMServiceManager() != null) {
    app.getVMServiceManager().getHeapMonitor().addPollingClient();
  }

  Disposer.register(parentDisposable, () -> {
    if (app.getVMServiceManager() != null) {
      app.getVMServiceManager().getHeapMonitor().removePollingClient();
    }
  });
}
 
Example #11
Source File: GradleDependencyFetcherTest.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@BeforeClass
public static void setUp() {
  Disposable disposable = Disposer.newDisposable();
  ApplicationManager.setApplication(new MockApplication(disposable), disposable);
  Extensions.registerAreaClass("IDEA_PROJECT", null);
  ourProject = new MockProject(ApplicationManager.getApplication().getPicoContainer(), disposable);
}
 
Example #12
Source File: TestUtils.java    From intellij with Apache License 2.0 5 votes vote down vote up
@NotNull
public static MockProject mockProject(
    @Nullable PicoContainer container, Disposable parentDisposable) {
  Extensions.registerAreaClass("IDEA_PROJECT", null);
  container = container != null ? container : new DefaultPicoContainer();
  return new MockProject(container, parentDisposable);
}
 
Example #13
Source File: WorkspaceFileTextField.java    From intellij with Apache License 2.0 5 votes vote down vote up
private WorkspaceFileTextField(
    WorkspacePathResolver pathResolver,
    JTextField textField,
    LookupFilter filter,
    Disposable parent) {
  super(textField, new WorkspaceFinder(pathResolver), filter, ImmutableMap.of(), parent);
}
 
Example #14
Source File: WidgetPerfTipsPanel.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public WidgetPerfTipsPanel(Disposable parentDisposable, @NotNull FlutterApp app) {
  setLayout(new VerticalLayout(5));

  add(new JSeparator());

  perfManager = FlutterWidgetPerfManager.getInstance(app.getProject());
  perfTips = new JPanel();
  perfTips.setLayout(new VerticalLayout(0));

  linkListener = (source, tip) -> handleTipSelection(tip);
  final Project project = app.getProject();
  final MessageBusConnection bus = project.getMessageBus().connect(project);
  final FileEditorManagerListener listener = new FileEditorManagerListener() {
    @Override
    public void selectionChanged(@NotNull FileEditorManagerEvent event) {
      selectedEditorChanged();
    }
  };
  selectedEditorChanged();
  bus.subscribe(FileEditorManagerListener.FILE_EDITOR_MANAGER, listener);

  // Computing performance tips is somewhat expensive so we don't want to
  // compute them too frequently. Performance tips are only computed when
  // new performance stats are available but performance stats are updated
  // at 60fps so to be conservative we delay computing perf tips.
  final Timer perfTipComputeDelayTimer = new Timer(PERF_TIP_COMPUTE_DELAY, this::onComputePerfTips);
  perfTipComputeDelayTimer.start();
  Disposer.register(parentDisposable, perfTipComputeDelayTimer::stop);
}
 
Example #15
Source File: MuleMavenModuleBuilder.java    From mule-intellij-plugins with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public ModuleWizardStep getCustomOptionsStep(WizardContext context, Disposable parentDisposable) {
    MuleVersionConfiguration step = new MuleVersionConfiguration(this, muleVersion);
    Disposer.register(parentDisposable, step);
    return step;
}
 
Example #16
Source File: IdeaFrameFixture.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected IdeaFrameFixture(@NotNull Robot robot, @NotNull IdeFrameImpl target) {
  super(IdeaFrameFixture.class, robot, target);
  Project project = getProject();
  myIdeFrameFixture = IdeFrameFixture.find(robot);

  Disposable disposable = new IdeaFrameFixture.NoOpDisposable();
  Disposer.register(project, disposable);

  GradleBuildState.subscribe(project, myGradleProjectEventListener);
}
 
Example #17
Source File: MuleDomainMavenModuleBuilder.java    From mule-intellij-plugins with Apache License 2.0 5 votes vote down vote up
@Nullable
@Override
public ModuleWizardStep getCustomOptionsStep(WizardContext context, Disposable parentDisposable) {
    MuleVersionConfiguration step = new MuleVersionConfiguration(this, muleVersion);
    Disposer.register(parentDisposable, step);
    return step;
}
 
Example #18
Source File: InspectorGroupManagerService.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public Client(Disposable parent) {
  Disposer.register(parent, () -> {
    if (groupManager != null) {
      groupManager.clear(false);
    }
  });
}
 
Example #19
Source File: ServiceHelper.java    From intellij with Apache License 2.0 5 votes vote down vote up
public static <T> void registerProjectComponent(
    Project project, Class<T> key, T implementation, Disposable parentDisposable) {
  // #api193 (or #api201?): ComponentManagerImpl moved in 2020.1 dot releases. Check
  // ComponentManagerImpl directly when earlier releases are no longer supported
  boolean isComponentManagerImpl = project instanceof ProjectImpl;
  if (isComponentManagerImpl) {
    ServiceContainerUtil.registerComponentInstance(
        project, key, implementation, parentDisposable);
  } else {
    registerComponentInstance(
        (MutablePicoContainer) project.getPicoContainer(), key, implementation, parentDisposable);
  }
}
 
Example #20
Source File: InlinePreviewViewController.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public InlinePreviewViewController(InlineWidgetViewModelData data, boolean drawBackground, Disposable disposable) {
  super(data, drawBackground, disposable);
  data.context.editorPositionService.addListener(getEditor(), new EditorPositionService.Listener() {
                                                   @Override
                                                   public void updateVisibleArea(Rectangle newRectangle) {
                                                     InlinePreviewViewController.this.updateVisibleArea(newRectangle);
                                                   }

                                                   @Override
                                                   public void onVisibleChanged() {
                                                     InlinePreviewViewController.this.onVisibleChanged();
                                                   }
                                                 },
                                                 this);
}
 
Example #21
Source File: HeapDisplay.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static JPanel createJPanelView(Disposable parentDisposable, FlutterApp app) {
  final JPanel panel = new JPanel(new BorderLayout());

  final JBLabel heapLabel = new JBLabel("", SwingConstants.RIGHT);
  heapLabel.setAlignmentY(Component.BOTTOM_ALIGNMENT);
  heapLabel.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL));
  heapLabel.setForeground(UIUtil.getLabelDisabledForeground());
  heapLabel.setBorder(JBUI.Borders.empty(4));

  final HeapState heapState = new HeapState(60 * 1000);
  final HeapDisplay graph = new HeapDisplay(state -> {
    heapLabel.setText(heapState.getHeapSummary());
    SwingUtilities.invokeLater(heapLabel::repaint);
  });

  graph.setLayout(new BoxLayout(graph, BoxLayout.X_AXIS));
  graph.add(Box.createHorizontalGlue());
  graph.add(heapLabel);

  panel.add(graph, BorderLayout.CENTER);

  final HeapListener listener = memoryUsages -> SwingUtilities.invokeLater(() -> {
    heapState.handleMemoryUsage(memoryUsages);
    graph.updateFrom(heapState);
    panel.repaint();
  });

  assert app.getVMServiceManager() != null;
  app.getVMServiceManager().addHeapListener(listener);
  Disposer.register(parentDisposable, () -> app.getVMServiceManager().removeHeapListener(listener));

  return panel;
}
 
Example #22
Source File: InspectorGroupManagerService.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public Client(Disposable parent) {
  Disposer.register(parent, () -> {
    if (groupManager != null) {
      groupManager.clear(false);
    }
  });
}
 
Example #23
Source File: InspectorGroupManagerService.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void addListener(@NotNull Listener listener, Disposable disposable) {
  synchronized (listeners) {
    listeners.add(listener);
  }
  // Update the listener with the current active state if any.
  if (inspectorService != null) {
    listener.onInspectorAvailable(inspectorService);
  }
  if (selection != null) {
    listener.onSelectionChanged(selection);
  }
  Disposer.register(disposable, () -> removeListener(listener));
}
 
Example #24
Source File: ServiceHelperCompat.java    From intellij with Apache License 2.0 5 votes vote down vote up
public static <T> void registerService(
    ComponentManager componentManager,
    Class<T> key,
    T implementation,
    Disposable parentDisposable) {
  Optional<IdeaPluginDescriptor> platformPlugin =
      PluginManager.getLoadedPlugins().stream()
          .filter(descriptor -> descriptor.getName().startsWith("IDEA CORE"))
          .findAny();

  Verify.verify(platformPlugin.isPresent());

  ((PlatformComponentManagerImpl) componentManager)
      .registerServiceInstance(key, implementation, platformPlugin.get());
}
 
Example #25
Source File: PropertyEditorPanel.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static Balloon showPopupHelper(
  InspectorGroupManagerService inspectorService,
  Project project,
  @Nullable DiagnosticsNode node,
  @NotNull InspectorService.Location location,
  FlutterDartAnalysisServer service
) {
  final Color GRAPHITE_COLOR = new JBColor(new Color(236, 236, 236, 215), new Color(60, 63, 65, 215));

  final Disposable panelDisposable = Disposer.newDisposable();
  final PropertyEditorPanel panel =
    new PropertyEditorPanel(inspectorService, project, service, true, true, panelDisposable);

  final StableWidgetTracker tracker = new StableWidgetTracker(location, service, project, panelDisposable);

  final EventStream<VirtualFile> activeFile = new EventStream<>(location.getFile());
  panel.initalize(node, tracker.getCurrentOutlines(), activeFile);

  panel.setBackground(GRAPHITE_COLOR);
  panel.setOpaque(false);
  final BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createBalloonBuilder(panel);
  balloonBuilder.setFadeoutTime(0);
  balloonBuilder.setFillColor(GRAPHITE_COLOR);
  balloonBuilder.setAnimationCycle(0);
  balloonBuilder.setHideOnClickOutside(true);
  balloonBuilder.setHideOnKeyOutside(false);
  balloonBuilder.setHideOnAction(false);
  balloonBuilder.setCloseButtonEnabled(false);
  balloonBuilder.setBlockClicksThroughBalloon(true);
  balloonBuilder.setRequestFocus(true);
  balloonBuilder.setShadow(true);
  final Balloon balloon = balloonBuilder.createBalloon();
  Disposer.register(balloon, panelDisposable);

  return balloon;
}
 
Example #26
Source File: InlinePreviewViewController.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public InlinePreviewViewController(InlineWidgetViewModelData data, boolean drawBackground, Disposable disposable) {
  super(data, drawBackground, disposable);
  data.context.editorPositionService.addListener(getEditor(), new EditorPositionService.Listener() {
                                                   @Override
                                                   public void updateVisibleArea(Rectangle newRectangle) {
                                                     InlinePreviewViewController.this.updateVisibleArea(newRectangle);
                                                   }

                                                   @Override
                                                   public void onVisibleChanged() {
                                                     InlinePreviewViewController.this.onVisibleChanged();
                                                   }
                                                 },
                                                 this);
}
 
Example #27
Source File: ProjectModuleMocker.java    From intellij with Apache License 2.0 5 votes vote down vote up
ProjectModuleMocker(Project project, Disposable parentDisposable) {
  ServiceHelper.registerApplicationService(
      ModuleEditorProvider.class, MockModuleEditor::new, parentDisposable);
  ServiceHelper.registerProjectService(
      project, ModuleFinder.class, new MockModuleFinder(), parentDisposable);
  Disposer.register(parentDisposable, this);
}
 
Example #28
Source File: FlutterTestUtils.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public static void configureFlutterSdk(@NotNull final Module module, @NotNull final Disposable disposable, final boolean realSdk) {
  final String sdkHome;
  if (realSdk) {
    sdkHome = System.getProperty("flutter.sdk");
    if (sdkHome == null) {
      Assert.fail("To run tests that use the flutter tools you need to add '-Dflutter.sdk=[real SDK home]' to the VM Options field of " +
                  "the corresponding JUnit run configuration (Run | Edit Configurations)");
    }
    if (!FlutterSdkUtil.isFlutterSdkHome(sdkHome)) {
      Assert.fail("Incorrect path to the Flutter SDK (" + sdkHome + ") is set as '-Dflutter.sdk' VM option of " +
                  "the corresponding JUnit run configuration (Run | Edit Configurations)");
    }
    VfsRootAccess.allowRootAccess(disposable, sdkHome);
  }
  else {
    sdkHome = SDK_HOME_PATH;
  }

  ApplicationManager.getApplication().runWriteAction(() -> {
    FlutterSdkUtil.setFlutterSdkPath(module.getProject(), sdkHome);
    DartPlugin.enableDartSdk(module);
  });

  Disposer.register(disposable, () -> ApplicationManager.getApplication().runWriteAction(() -> {
    if (!module.isDisposed()) {
      DartPlugin.disableDartSdk(Collections.singletonList(module));
    }

    final ApplicationLibraryTable libraryTable = ApplicationLibraryTable.getApplicationTable();
    final Library library = libraryTable.getLibraryByName(FlutterSdk.FLUTTER_SDK_GLOBAL_LIB_NAME);
    if (library != null) {
      libraryTable.removeLibrary(library);
    }
  }));
}
 
Example #29
Source File: FlutterLog.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public void listenToProcess(@NotNull ProcessHandler processHandler, @NotNull Disposable parent) {
  processHandler.addProcessListener(new ProcessAdapter() {
    @Override
    public void onTextAvailable(@NotNull ProcessEvent event, @NotNull Key outputType) {
      onEntry(logEntryParser.parseDaemonEvent(event, outputType));
    }
  }, parent);
}
 
Example #30
Source File: JavaSourceFolderProviderTest.java    From intellij with Apache License 2.0 5 votes vote down vote up
private ContentEntry getContentEntry(VirtualFile root) {
  ContentEntry entry =
      ModuleRootManager.getInstance(testFixture.getModule())
          .getModifiableModel()
          .addContentEntry(root);
  if (entry instanceof Disposable) {
    // need to dispose the content entry and child disposables before the TestFixture is disposed
    Disposer.register(thisClassDisposable, (Disposable) entry);
  }
  return entry;
}