Java Code Examples for com.intellij.ui.content.Content#getUserData()

The following examples show how to use com.intellij.ui.content.Content#getUserData() . 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: ProjectViewImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public synchronized void removeProjectPane(@Nonnull AbstractProjectViewPane pane) {
  ApplicationManager.getApplication().assertIsDispatchThread();
  myUninitializedPanes.remove(pane);
  //assume we are completely initialized here
  String idToRemove = pane.getId();

  if (!myId2Pane.containsKey(idToRemove)) return;
  for (int i = getContentManager().getContentCount() - 1; i >= 0; i--) {
    Content content = getContentManager().getContent(i);
    String id = content != null ? content.getUserData(ID_KEY) : null;
    if (id != null && id.equals(idToRemove)) {
      getContentManager().removeContent(content, true);
    }
  }
  myId2Pane.remove(idToRemove);
  mySelectInTargets.remove(idToRemove);
  viewSelectionChanged();
}
 
Example 2
Source File: ProjectViewImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
private boolean viewSelectionChanged() {
  Content content = getContentManager().getSelectedContent();
  if (content == null) return false;
  final String id = content.getUserData(ID_KEY);
  String subId = content.getUserData(SUB_ID_KEY);
  if (content.equals(Pair.create(myCurrentViewId, myCurrentViewSubId))) return false;
  final AbstractProjectViewPane newPane = getProjectViewPaneById(id);
  if (newPane == null) return false;
  newPane.setSubId(subId);
  showPane(newPane);
  ProjectViewSelectInTarget target = getProjectViewSelectInTarget(newPane);
  if (target != null) target.setSubId(subId);
  if (isAutoscrollFromSource(id)) {
    myAutoScrollFromSourceHandler.scrollFromSource();
  }
  return true;
}
 
Example 3
Source File: UsageViewManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public UsageView getSelectedUsageView() {
  final Content content = com.intellij.usageView.UsageViewManager.getInstance(myProject).getSelectedContent();
  if (content != null) {
    return content.getUserData(USAGE_VIEW_KEY);
  }

  return null;
}
 
Example 4
Source File: RunnerLayout.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private static String getOrCreateContentId(@Nonnull Content content) {
  @NonNls String id = content.getUserData(ViewImpl.ID);
  if (id == null) {
    id = "UnknownView-" + content.getDisplayName();
    content.putUserData(ViewImpl.ID, id);
  }
  return id;
}
 
Example 5
Source File: LogviewFactory.java    From logviewer with Apache License 2.0 4 votes vote down vote up
@Override
public void createToolWindowContent(@NotNull final Project project, @NotNull final ToolWindow toolWindow) {

    final File adb = AndroidSdkUtils.getAdb(project);
    ExecutionManager.getInstance(project).getContentManager();

    RunnerLayoutUi layoutUi = RunnerLayoutUi.Factory.getInstance(project).create("LogViewer", TOOL_WINDOW_ID, "Logview Tools", project);

    toolWindow.setIcon(LogviewerPluginIcons.TOOL_ICON);
    toolWindow.setAvailable(true, null);
    toolWindow.setToHideOnEmptyContent(true);
    toolWindow.setTitle(TOOL_WINDOW_ID);


    DeviceContext deviceContext = new DeviceContext();

    Content logcatContent = createLogcatContent(layoutUi, project, deviceContext);
    final LogView logcatView = logcatContent.getUserData(LOG_VIEW_KEY);
    layoutUi.addContent(logcatContent, 0, PlaceInGrid.center, false);

    final JBLoadingPanel loadingPanel = new JBLoadingPanel(new BorderLayout(), project);
    loadingPanel.add(layoutUi.getComponent(), BorderLayout.CENTER);

    final ContentManager contentManager = toolWindow.getContentManager();
    Content c = contentManager.getFactory().createContent(loadingPanel, "", true);
    c.putUserData(LOG_VIEW_KEY, logcatView);
    contentManager.addContent(c);
    ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
            logcatView.activate();
        }
    }, project.getDisposed());


    if (adb != null) {
        loadingPanel.setLoadingText("Initializing ADB");
        loadingPanel.startLoading();

        //ListenableFuture<AndroidDebugBridge> future = AdbService.getInstance().getDebugBridge(adb);
        ListenableFuture<AndroidDebugBridge> future = AdbBridgeFactory.getAdb(adb);
        Futures.addCallback(future, new FutureCallback<AndroidDebugBridge>() {
            @Override
            public void onSuccess(@Nullable AndroidDebugBridge bridge) {
                Logger.getInstance(LogviewFactory.class).info("Successfully obtained debug bridge");
                loadingPanel.stopLoading();
            }

            @Override
            public void onFailure(@NotNull Throwable t) {
                loadingPanel.stopLoading();
                Logger.getInstance(LogviewFactory.class).info("Unable to obtain debug bridge", t);
                String msg;
                if (t.getMessage() != null) {
                    msg = t.getMessage();
                } else {
                    msg = String.format("Unable to establish a connection to adb",
                            ApplicationNamesInfo.getInstance().getProductName(), adb.getAbsolutePath());
                }
                Messages.showErrorDialog(msg, "ADB Connection Error");
            }
        }, EdtExecutor.INSTANCE);
    } else {
        logcatView.showHint("No adb connection!.\n\nDrag and drop log files to view them.");
    }
}
 
Example 6
Source File: RunnerLayoutUiImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isToFocus(@Nonnull final Content content, @Nonnull final String condition) {
  final String id = content.getUserData(ViewImpl.ID);
  return getLayout().isToFocus(id, condition);
}