Java Code Examples for com.intellij.openapi.util.registry.Registry#intValue()

The following examples show how to use com.intellij.openapi.util.registry.Registry#intValue() . 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: WindowAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  if (mySizeHelper == null) {
    mySizeHelper = new JLabel("W"); // Must be sure to invoke label constructor from EDT thread or it may lead to a deadlock
  }

  int baseValue = myHorizontal ? mySizeHelper.getPreferredSize().width : mySizeHelper.getPreferredSize().height;

  int inc = baseValue * Registry.intValue(myHorizontal ? "ide.windowSystem.hScrollChars" : "ide.windowSystem.vScrollChars");
  if (!myPositive) {
    inc = -inc;
  }

  Rectangle bounds = myWindow.getBounds();
  if (myHorizontal) {
    bounds.width += inc;
  }
  else {
    bounds.height += inc;
  }

  myWindow.setBounds(bounds);
}
 
Example 2
Source File: LocalFileSystemRefreshWorker.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private RefreshContext createRefreshContext(@Nonnull NewVirtualFileSystem fs, @Nonnull PersistentFS persistentFS, @Nonnull TObjectHashingStrategy<String> strategy) {
  int parallelism = Registry.intValue("vfs.use.nio-based.local.refresh.worker.parallelism", Runtime.getRuntime().availableProcessors() - 1);

  if (myIsRecursive && parallelism > 0 && !ApplicationManager.getApplication().isDispatchThread()) {
    return new ConcurrentRefreshContext(fs, persistentFS, strategy, parallelism);
  }
  return new SequentialRefreshContext(fs, persistentFS, strategy);
}
 
Example 3
Source File: RecentProjectsManagerBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
void validateRecentProjects() {
  //noinspection StatementWithEmptyBody
  while (recentPaths.remove(null)) ;
  Collection<String> displayNames = names.values();
  //noinspection StatementWithEmptyBody
  while (displayNames.remove("")) ;

  while (recentPaths.size() > Registry.intValue("ide.max.recent.projects")) {
    int index = recentPaths.size() - 1;
    names.remove(recentPaths.get(index));
    recentPaths.remove(index);
  }
}
 
Example 4
Source File: DesktopEditorImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void mouseMoved(@Nonnull MouseEvent e) {
  if (getMouseSelectionState() != MOUSE_SELECTION_STATE_NONE) {
    if (myMousePressedEvent != null && myMousePressedEvent.getComponent() == e.getComponent()) {
      Point lastPoint = myMousePressedEvent.getPoint();
      Point point = e.getPoint();
      int deadZone = Registry.intValue("editor.mouseSelectionStateResetDeadZone");
      if (Math.abs(lastPoint.x - point.x) >= deadZone || Math.abs(lastPoint.y - point.y) >= deadZone) {
        resetMouseSelectionState(e);
      }
    }
    else {
      validateMousePointer(e);
    }
  }
  else {
    validateMousePointer(e);
  }

  myMouseMovedEvent = e;

  EditorMouseEvent event = new EditorMouseEvent(DesktopEditorImpl.this, e, getMouseEventArea(e));
  if (e.getSource() == myGutterComponent) {
    myGutterComponent.mouseMoved(e);
  }

  for (EditorMouseMotionListener listener : myMouseMotionListeners) {
    listener.mouseMoved(event);
    if (isReleased) return;
  }
}
 
Example 5
Source File: RecentLocationsDataModel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private TextRange getLinesRange(Document document, int line) {
  int lineCount = document.getLineCount();
  if (lineCount == 0) {
    return TextRange.EMPTY_RANGE;
  }

  int beforeAfterLinesCount = Registry.intValue("recent.locations.lines.before.and.after", 2);

  int before = Math.min(beforeAfterLinesCount, line);
  int after = Math.min(beforeAfterLinesCount, lineCount - line);

  int linesBefore = before + beforeAfterLinesCount - after;
  int linesAfter = after + beforeAfterLinesCount - before;

  int startLine = Math.max(line - linesBefore, 0);
  int endLine = Math.min(line + linesAfter, lineCount - 1);

  int startOffset = document.getLineStartOffset(startLine);
  int endOffset = document.getLineEndOffset(endLine);

  if (startOffset <= endOffset) {
    return TextRange.create(startOffset, endOffset);
  }
  else {
    return TextRange.create(DocumentUtil.getLineTextRange(document, line));
  }
}
 
Example 6
Source File: LocalHistoryImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void doDispose() {
  if (!isInitialized.getAndSet(false)) return;

  long period = Registry.intValue("localHistory.daysToKeep") * 1000L * 60L * 60L * 24L;

  myConnection.disconnect();
  myConnection = null;

  LocalHistoryLog.LOG.debug("Purging local history...");
  myChangeList.purgeObsolete(period);
  myChangeList.close();
  LocalHistoryLog.LOG.debug("Local history storage successfully closed.");

  ShutDownTracker.getInstance().unregisterShutdownTask(myShutdownTask);
}
 
Example 7
Source File: ThreeComponentsSplitter.java    From consulo with Apache License 2.0 5 votes vote down vote up
private boolean isInside(Point p) {
  if (!isVisible()) return false;

  int dndOff = myIsOnePixel ? Registry.intValue("ide.splitter.mouseZone") / 2 : 0;
  if (myVerticalSplit) {
    if (p.x >= 0 && p.x < getWidth()) {
      if (getHeight() > 0) {
        return p.y >= -dndOff && p.y < getHeight() + dndOff;
      }
      else {
        return p.y >= -myDividerZone / 2 && p.y <= myDividerZone / 2;
      }
    }
  }
  else {
    if (p.y >= 0 && p.y < getHeight()) {
      if (getWidth() > 0) {
        return p.x >= -dndOff && p.x < getWidth() + dndOff;
      }
      else {
        return p.x >= -myDividerZone / 2 && p.x <= myDividerZone / 2;
      }
    }
  }

  return false;
}
 
Example 8
Source File: PackageDirectoryCache.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nullable
private PackageInfo getPackageInfo(@Nonnull final String packageName) {
  PackageInfo info = myDirectoriesByPackageNameCache.get(packageName);
  if (info == null) {
    if (myNonExistentPackages.contains(packageName)) return null;

    if (packageName.length() > Registry.intValue("java.max.package.name.length") || StringUtil.containsAnyChar(packageName, ";[/")) {
      return null;
    }

    List<VirtualFile> result = ContainerUtil.newSmartList();

    if (StringUtil.isNotEmpty(packageName) && !StringUtil.startsWithChar(packageName, '.')) {
      int i = packageName.lastIndexOf('.');
      while (true) {
        PackageInfo parentInfo = getPackageInfo(i > 0 ? packageName.substring(0, i) : "");
        if (parentInfo != null) {
          result.addAll(parentInfo.getSubPackageDirectories(packageName.substring(i + 1)));
        }
        if (i < 0) break;
        i = packageName.lastIndexOf('.', i - 1);
        ProgressManager.checkCanceled();
      }
    }

    for (VirtualFile file : myRootsByPackagePrefix.get(packageName)) {
      if (file.isDirectory()) {
        result.add(file);
      }
    }

    if (!result.isEmpty()) {
      myDirectoriesByPackageNameCache.put(packageName, info = new PackageInfo(packageName, result));
    } else {
      myNonExistentPackages.add(packageName);
    }
  }

  return info;
}
 
Example 9
Source File: AbstractTreeUi.java    From consulo with Apache License 2.0 4 votes vote down vote up
private void expandNext(@Nonnull final Object[] elements,
                        final int index,
                        final boolean parentsOnly,
                        final boolean checkIfInStricture,
                        final boolean canSmartExpand,
                        @Nonnull final ActionCallback done,
                        final int currentDepth) {
  if (elements.length <= 0) {
    done.setDone();
    return;
  }

  if (index >= elements.length) {
    return;
  }

  final int[] actualDepth = {currentDepth};
  boolean breakCallChain = false;
  if (actualDepth[0] > Registry.intValue("ide.tree.expandRecursionDepth")) {
    actualDepth[0] = 0;
    breakCallChain = true;
  }

  Runnable expandRunnable = new TreeRunnable("AbstractTreeUi.expandNext") {
    @Override
    public void perform() {
      _expand(elements[index], new TreeRunnable("AbstractTreeUi.expandNext: on done") {
        @Override
        public void perform() {
          done.setDone();
          expandNext(elements, index + 1, parentsOnly, checkIfInStricture, canSmartExpand, done, actualDepth[0] + 1);
        }
      }, parentsOnly, checkIfInStricture, canSmartExpand);
    }
  };

  if (breakCallChain && !isPassthroughMode()) {
    //noinspection SSBasedInspection
    SwingUtilities.invokeLater(expandRunnable);
  }
  else {
    expandRunnable.run();
  }
}
 
Example 10
Source File: HelpTooltip.java    From consulo with Apache License 2.0 4 votes vote down vote up
protected final void getDismissDelay() {
  myDismissDelay = Registry.intValue(isMultiline ? "ide.helptooltip.full.dismissDelay" : "ide.helptooltip.regular.dismissDelay");
}
 
Example 11
Source File: Breadcrumbs.java    From consulo with Apache License 2.0 4 votes vote down vote up
private int getRightGap() {
  return !Registry.is("editor.breadcrumbs.marker") ? Registry.intValue("editor.breadcrumbs.gap.right", 9) : 0;
}
 
Example 12
Source File: ResizeToolWindowAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
public int getNextVerticalScroll() {
  return getReferenceSize().height * Registry.intValue("ide.windowSystem.vScrollChars");
}
 
Example 13
Source File: ScratchFileActions.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public void update(@Nonnull AnActionEvent e) {
  boolean enabled = e.getProject() != null && Registry.intValue("ide.scratch.buffers") > 0;
  e.getPresentation().setEnabledAndVisible(enabled);
}
 
Example 14
Source File: ReadOnlyStatusDialog.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public long getTypeAheadTimeoutMs() {
  return Registry.intValue("actionSystem.typeAheadTimeBeforeDialog");
}
 
Example 15
Source File: UndoManagerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static int getGlobalUndoLimit() {
  return Registry.intValue("undo.globalUndoLimit");
}
 
Example 16
Source File: ResizeToolWindowAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
public int getNextHorizontalScroll() {
  return getReferenceSize().width * Registry.intValue("ide.windowSystem.hScrollChars");
}
 
Example 17
Source File: EditorUtil.java    From consulo with Apache License 2.0 4 votes vote down vote up
public static int getDefaultCaretWidth() {
  return Registry.intValue("editor.caret.width", 2);
}
 
Example 18
Source File: Breadcrumbs.java    From consulo with Apache License 2.0 4 votes vote down vote up
private int getLeftGap() {
  return !Registry.is("editor.breadcrumbs.marker") ? Registry.intValue("editor.breadcrumbs.gap.left", 5) : parent != null ? 10 : 0;
}
 
Example 19
Source File: IdeTooltip.java    From consulo with Apache License 2.0 4 votes vote down vote up
public int getShowDelay() {
  return myHighlighter ? Registry.intValue("ide.tooltip.initialDelay.highlighter") : Registry.intValue("ide.tooltip.initialDelay");
}
 
Example 20
Source File: IdeTooltip.java    From consulo with Apache License 2.0 4 votes vote down vote up
public int getInitialReshowDelay() {
  return Registry.intValue("ide.tooltip.initialReshowDelay");
}