Java Code Examples for com.intellij.openapi.util.ActionCallback#DONE

The following examples show how to use com.intellij.openapi.util.ActionCallback#DONE . 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: GridImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
public CellTransform.Restore detach() {
  if (getComponentCount() == 1) {
    myContent = (JComponent)getComponent(0);
    removeAll();
  }

  if (getParent() instanceof JComponent) {
    ((JComponent)getParent()).revalidate();
    getParent().repaint();
  }

  return new CellTransform.Restore() {
    @Override
    public ActionCallback restoreInGrid() {
      if (myContent != null) {
        setContent(myContent);
        myContent = null;
      }
      return ActionCallback.DONE;
    }
  };
}
 
Example 2
Source File: TogglePresentationModeAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static ActionCallback tweakFrameFullScreen(Project project, boolean inPresentation) {
  IdeFrameEx frame = (IdeFrameEx)IdeFrameUtil.findActiveRootIdeFrame();
  if (frame != null) {
    PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(project);
    if (inPresentation) {
      propertiesComponent.setValue("full.screen.before.presentation.mode", String.valueOf(frame.isInFullScreen()));
      return frame.toggleFullScreen(true);
    }
    else {
      if (frame.isInFullScreen()) {
        final String value = propertiesComponent.getValue("full.screen.before.presentation.mode");
        return frame.toggleFullScreen("true".equalsIgnoreCase(value));
      }
    }
  }
  return ActionCallback.DONE;
}
 
Example 3
Source File: FavoritesViewTreeBuilder.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public ActionCallback updateFromRootCB() {
  getStructure().rootsChanged();
  if (isDisposed()) return ActionCallback.DONE;
  getUpdater().cancelAllRequests();
  return queueUpdate();
}
 
Example 4
Source File: TreeUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static ActionCallback moveDown(@Nonnull final JTree tree) {
  final int size = tree.getRowCount();
  int row = tree.getLeadSelectionRow();
  if (row < size - 1) {
    row++;
    return showAndSelect(tree, row, row + 2, row, getSelectedRow(tree), false, true, true);
  }
  else {
    return ActionCallback.DONE;
  }
}
 
Example 5
Source File: TreeUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static ActionCallback moveUp(@Nonnull final JTree tree) {
  int row = tree.getLeadSelectionRow();
  if (row > 0) {
    row--;
    return showAndSelect(tree, row - 2, row, row, getSelectedRow(tree), false, true, true);
  }
  else {
    return ActionCallback.DONE;
  }
}
 
Example 6
Source File: TreeUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static ActionCallback selectInTree(Project project, @Nullable DefaultMutableTreeNode node, boolean requestFocus, @Nonnull JTree tree, boolean center) {
  if (node == null) return ActionCallback.DONE;

  final TreePath treePath = new TreePath(node.getPath());
  tree.expandPath(treePath);
  if (requestFocus) {
    ActionCallback result = new ActionCallback(2);
    IdeFocusManager.getInstance(project).requestFocus(tree, true).notifyWhenDone(result);
    selectPath(tree, treePath, center).notifyWhenDone(result);
    return result;
  }
  return selectPath(tree, treePath, center);
}
 
Example 7
Source File: UpdaterTreeState.java    From consulo with Apache License 2.0 5 votes vote down vote up
private ActionCallback processHangByParent(Set<Object> elements) {
  if (elements.isEmpty()) return ActionCallback.DONE;

  ActionCallback result = new ActionCallback(elements.size());
  for (Object hangElement : elements) {
    if (!myAdjustmentCause2Adjustment.containsKey(hangElement)) {
      processHangByParent(hangElement).notify(result);
    }
    else {
      result.setDone();
    }
  }
  return result;
}
 
Example 8
Source File: AbstractTreeStructure.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
public static ActionCallback asyncCommitDocuments(@Nonnull Project project) {
  if (project.isDisposed()) return ActionCallback.DONE;
  PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project);
  if (!documentManager.hasUncommitedDocuments()) {
    return ActionCallback.DONE;
  }
  final ActionCallback callback = new ActionCallback();
  documentManager.performWhenAllCommitted(callback.createSetDoneRunnable());
  return callback;
}
 
Example 9
Source File: IdeFrameDecorator.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public ActionCallback toggleFullScreen(boolean state) {
  JFrame jFrame = getJFrame();
  if (jFrame == null) {
    return ActionCallback.REJECTED;
  }

  GraphicsDevice device = ScreenUtil.getScreenDevice(jFrame.getBounds());
  if (device == null) return ActionCallback.REJECTED;

  try {
    jFrame.getRootPane().putClientProperty(ScreenUtil.DISPOSE_TEMPORARY, Boolean.TRUE);
    if (state) {
      jFrame.getRootPane().putClientProperty("oldBounds", jFrame.getBounds());
    }
    jFrame.dispose();
    jFrame.setUndecorated(state);
  }
  finally {
    if (state) {
      jFrame.setBounds(device.getDefaultConfiguration().getBounds());
    }
    else {
      Object o = jFrame.getRootPane().getClientProperty("oldBounds");
      if (o instanceof Rectangle) {
        jFrame.setBounds((Rectangle)o);
      }
    }
    jFrame.setVisible(true);
    jFrame.getRootPane().putClientProperty(ScreenUtil.DISPOSE_TEMPORARY, null);

    notifyFrameComponents(state);
  }
  return ActionCallback.DONE;
}
 
Example 10
Source File: IdeFrameDecorator.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public ActionCallback toggleFullScreen(boolean state) {
  JFrame jFrame = getJFrame();
  if (jFrame != null) {
    myRequestedState = state;
    X11UiUtil.toggleFullScreenMode(jFrame);
  }
  return ActionCallback.DONE;
}
 
Example 11
Source File: TogglePresentationModeAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static void setPresentationMode(final Project project, final boolean inPresentation) {
  final UISettings settings = UISettings.getInstance();
  settings.PRESENTATION_MODE = inPresentation;

  final boolean layoutStored = storeToolWindows(project);

  tweakUIDefaults(settings, inPresentation);

  ActionCallback callback = project == null ? ActionCallback.DONE : tweakFrameFullScreen(project, inPresentation);
  callback.doWhenProcessed(() -> {
    tweakEditorAndFireUpdateUI(settings, inPresentation);

    restoreToolWindows(project, layoutStored, inPresentation);
  });
}
 
Example 12
Source File: RunAnythingPopupUI.java    From consulo with Apache License 2.0 4 votes vote down vote up
public RunAnythingPopupUI(@Nonnull AnActionEvent actionEvent) {
  super(actionEvent.getProject());

  myActionEvent = actionEvent;

  myCurrentWorker = ActionCallback.DONE;
  myVirtualFile = actionEvent.getData(CommonDataKeys.VIRTUAL_FILE);

  myProject = ObjectUtils.notNull(myActionEvent.getData(CommonDataKeys.PROJECT));
  myModule = myActionEvent.getData(LangDataKeys.MODULE);

  init();

  initSearchActions();

  initResultsList();

  initSearchField();

  initMySearchField();
}
 
Example 13
Source File: BlazeProblemsViewPanel.java    From intellij with Apache License 2.0 4 votes vote down vote up
private ActionCallback getReady(DataContext context) {
  ToolWindow toolWindow = PlatformDataKeys.TOOL_WINDOW.getData(context);
  return toolWindow != null
      ? toolWindow.getReady(autoScrollToConsoleHandler)
      : ActionCallback.DONE;
}
 
Example 14
Source File: SearchResults.java    From consulo with Apache License 2.0 4 votes vote down vote up
ActionCallback updateThreadSafe(@Nonnull FindModel findModel, final boolean toChangeSelection, @Nullable final TextRange next, final int stamp) {
  if (myDisposed) return ActionCallback.DONE;

  ActionCallback result = new ActionCallback();
  final Editor editor = getEditor();

  updatePreviousFindModel(findModel);
  final FutureResult<int[]> startsRef = new FutureResult<>();
  final FutureResult<int[]> endsRef = new FutureResult<>();
  getSelection(editor, startsRef, endsRef);

  List<FindResult> results = new ArrayList<>();
  ApplicationManager.getApplication().runReadAction(() -> {
    Project project = getProject();
    if (myDisposed || project != null && project.isDisposed()) return;
    int[] starts = new int[0];
    int[] ends = new int[0];
    try {
      starts = startsRef.get();
      ends = endsRef.get();
    }
    catch (InterruptedException | ExecutionException ignore) {
    }

    if (starts.length == 0 || findModel.isGlobal()) {
      findInRange(new TextRange(0, Integer.MAX_VALUE), editor, findModel, results);
    }
    else {
      for (int i = 0; i < starts.length; ++i) {
        findInRange(new TextRange(starts[i], ends[i]), editor, findModel, results);
      }
    }

    long documentTimeStamp = editor.getDocument().getModificationStamp();

    UIUtil.invokeLaterIfNeeded(() -> {
      if (editor.getDocument().getModificationStamp() == documentTimeStamp) {
        searchCompleted(results, editor, findModel, toChangeSelection, next, stamp);
        result.setDone();
      }
      else {
        result.setRejected();
      }
    });
  });
  return result;
}
 
Example 15
Source File: GridCellImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
ActionCallback restore(Content content) {
  myMinimizedContents.remove(content);
  return ActionCallback.DONE;
}
 
Example 16
Source File: GridCellImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public ActionCallback select(final Content content, final boolean requestFocus) {
  final TabInfo tabInfo = myContents.getValue(content);
  return tabInfo != null ? myTabs.select(tabInfo, requestFocus) : ActionCallback.DONE;
}
 
Example 17
Source File: AbstractTreeUpdater.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected ActionCallback beforeUpdate(TreeUpdatePass pass) {
  return ActionCallback.DONE;
}
 
Example 18
Source File: SourceJarGenerator.java    From intellij-pants-plugin with Apache License 2.0 4 votes vote down vote up
public ActionCallback perform(Collection<Library> libraries) {
  attach(sourceJar, libraries);
  return ActionCallback.DONE;
}
 
Example 19
Source File: KnowledgeViewPane.java    From netbeans-mmd-plugin with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public ActionCallback updateFromRoot(boolean restoreExpandedPaths) {
  return ActionCallback.DONE;
}
 
Example 20
Source File: AbstractTreeStructure.java    From consulo with Apache License 2.0 2 votes vote down vote up
/**
 * @return callback which is set to {@link ActionCallback#setDone()} when the tree structure is committed.
 * By default it just calls {@link #commit()} synchronously but it is desirable to override it
 * to provide asynchronous commit to the tree structure to make it more responsible.
 * E.g. when you should commit all documents during the {@link #commit()},
 * you can use {@link #asyncCommitDocuments(Project)} to do it asynchronously.
 */
@Nonnull
public ActionCallback asyncCommit() {
  if (hasSomethingToCommit()) commit();
  return ActionCallback.DONE;
}