javax.swing.text.html.ImageView#com.intellij.openapi.util.registry.Registry源码实例Demo

下面列出了javax.swing.text.html.ImageView#com.intellij.openapi.util.registry.Registry 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Override
public void processElementsWithName(@Nonnull String name, @Nonnull final Processor<NavigationItem> _processor, @Nonnull FindSymbolParameters parameters) {
  final boolean globalSearch = parameters.getSearchScope().isSearchInLibraries();
  final Processor<PsiFileSystemItem> processor = item -> {
    if (!globalSearch && ProjectCoreUtil.isProjectOrWorkspaceFile(item.getVirtualFile())) {
      return true;
    }
    return _processor.process(item);
  };

  boolean directoriesOnly = isDirectoryOnlyPattern(parameters);
  if (!directoriesOnly) {
    FilenameIndex.processFilesByName(name, false, processor, parameters.getSearchScope(), parameters.getProject(), parameters.getIdFilter());
  }

  if (directoriesOnly || Registry.is("ide.goto.file.include.directories")) {
    FilenameIndex.processFilesByName(name, true, processor, parameters.getSearchScope(), parameters.getProject(), parameters.getIdFilter());
  }
}
 
源代码2 项目: consulo   文件: ChangesModuleGroupingPolicy.java
@Override
@Nullable
public ChangesBrowserNode getParentNodeFor(final StaticFilePath node, final ChangesBrowserNode rootNode) {
  if (myProject.isDefault()) return null;

  ProjectFileIndex index = ProjectRootManager.getInstance(myProject).getFileIndex();

  VirtualFile vFile = node.getVf();
  if (vFile == null) {
    vFile = LocalFileSystem.getInstance().findFileByIoFile(new File(node.getPath()));
  }
  boolean hideExcludedFiles = Registry.is("ide.hide.excluded.files");
  if (vFile != null && Comparing.equal(vFile, index.getContentRootForFile(vFile, hideExcludedFiles))) {
    Module module = index.getModuleForFile(vFile, hideExcludedFiles);
    return getNodeForModule(module, rootNode);
  }
  return null;
}
 
源代码3 项目: flutter-intellij   文件: WorkspaceCache.java
/**
 * Executes a cache refresh.
 */
private void refresh() {
  final Workspace workspace = Workspace.loadUncached(project);
  if (workspace == cache && !disconnected) return;
  if (cache != null && workspace == null) {
    disconnected = true;
    return;
  }

  disconnected = false;
  cache = workspace;

  // If the current workspace is a bazel workspace, update the Dart plugin
  // registry key to indicate that there are dart projects without pubspec
  // registry keys. TODO(jacobr): it would be nice if the Dart plugin was
  // instead smarter about handling Bazel projects.
  if (cache != null) {
    if (!Registry.is(dartProjectsWithoutPubspecRegistryKey, false)) {
      Registry.get(dartProjectsWithoutPubspecRegistryKey).setValue(true);
    }
  }
  notifyListeners();
}
 
源代码4 项目: consulo   文件: RegistryValueCommand.java
@Override
protected ActionCallback _execute(PlaybackContext context) {
  final String[] keyValue = getText().substring(PREFIX.length()).trim().split("=");
  if (keyValue.length != 2) {
    context.error("Expected expresstion: " + PREFIX + " key=value", getLine());
    return new ActionCallback.Rejected();
  }

  final String key = keyValue[0];
  final String value = keyValue[1];

  context.storeRegistryValue(key);

  Registry.get(key).setValue(value);

  return new ActionCallback.Done();
}
 
源代码5 项目: consulo   文件: MouseGestureManager.java
public void remove(IdeFrame frame) {
  if (!Registry.is("actionSystem.mouseGesturesEnabled")) return;

  if (SystemInfo.isMacOSSnowLeopard) {
    try {
      Object listener = myListeners.get(frame);
      JComponent cmp = frame.getComponent();
      myListeners.remove(frame);
      if (listener != null && cmp != null && cmp.isShowing()) {
        ((MacGestureAdapter)listener).remove(cmp);
      }
    }
    catch (Throwable e) {
      LOG.debug(e);
    }
  }

}
 
源代码6 项目: consulo   文件: FindInProjectUtil.java
@Nonnull
public static String buildStringToFindForIndicesFromRegExp(@Nonnull String stringToFind, @Nonnull Project project) {
  if (!Registry.is("idea.regexp.search.uses.indices")) return "";

  return ReadAction.compute(() -> {
    final List<PsiElement> topLevelRegExpChars = getTopLevelRegExpChars("a", project);
    if (topLevelRegExpChars.size() != 1) return "";

    // leave only top level regExpChars
    return StringUtil.join(getTopLevelRegExpChars(stringToFind, project), new Function<PsiElement, String>() {
      final Class regExpCharPsiClass = topLevelRegExpChars.get(0).getClass();

      @Override
      public String fun(PsiElement element) {
        if (regExpCharPsiClass.isInstance(element)) {
          String text = element.getText();
          if (!text.startsWith("\\")) return text;
        }
        return " ";
      }
    }, "");
  });
}
 
源代码7 项目: consulo   文件: Breadcrumbs.java
@Override
protected void paintComponent(Graphics g) {
  // this custom component does not have a corresponding UI,
  // so we should care of painting its background
  if (isOpaque()) {
    g.setColor(getBackground());
    g.fillRect(0, 0, getWidth(), getHeight());
  }
  if (g instanceof Graphics2D) {
    Graphics2D g2d = (Graphics2D)g;
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, getKeyForCurrentScope(!Registry.is("editor.breadcrumbs.system.font")));
    for (CrumbView view : views) {
      if (view.crumb != null) view.paint(g2d);
    }
  }
}
 
源代码8 项目: consulo   文件: AbstractTreeUi.java
public static <T> T calculateYieldingToWriteAction(@RequiredReadAction @Nonnull Supplier<? extends T> producer) throws ProcessCanceledException {
  if (!Registry.is("ide.abstractTreeUi.BuildChildrenInBackgroundYieldingToWriteAction") || ApplicationManager.getApplication().isDispatchThread()) {
    return producer.get();
  }
  ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
  if (indicator != null && indicator.isRunning()) {
    return producer.get();
  }

  Ref<T> result = new Ref<>();
  boolean succeeded = ProgressManager.getInstance().runInReadActionWithWriteActionPriority(() -> result.set(producer.get()), indicator);

  if (!succeeded || indicator != null && indicator.isCanceled()) {
    throw new ProcessCanceledException();
  }
  return result.get();
}
 
源代码9 项目: consulo   文件: UIUtil.java
/**
 * Direct painting into component's graphics with XORMode is broken on retina-mode so we need to paint into an intermediate buffer first.
 */
public static void paintWithXorOnRetina(@Nonnull Dimension size, @Nonnull Graphics g, boolean useRetinaCondition, Consumer<Graphics2D> paintRoutine) {
  if (!useRetinaCondition || !isRetina() || Registry.is("ide.mac.retina.disableDrawingFix", false)) {
    paintRoutine.consume((Graphics2D)g);
  }
  else {
    Rectangle rect = g.getClipBounds();
    if (rect == null) rect = new Rectangle(size);

    //noinspection UndesirableClassUsage
    Image image = new BufferedImage(rect.width * 2, rect.height * 2, BufferedImage.TYPE_INT_RGB);
    Graphics2D imageGraphics = (Graphics2D)image.getGraphics();

    imageGraphics.scale(2, 2);
    imageGraphics.translate(-rect.x, -rect.y);
    imageGraphics.setClip(rect.x, rect.y, rect.width, rect.height);

    paintRoutine.consume(imageGraphics);
    image.flush();
    imageGraphics.dispose();

    ((Graphics2D)g).scale(0.5, 0.5);
    g.drawImage(image, rect.x * 2, rect.y * 2, null);
  }
}
 
源代码10 项目: consulo   文件: SearchEverywhereAction.java
@Nonnull
@Override
public JComponent createCustomComponent(Presentation presentation, String place) {
  return new ActionButton(this, presentation, place, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE) {
    @Override
    protected void updateToolTipText() {
      String shortcutText = getShortcut();

      if (Registry.is("ide.helptooltip.enabled")) {
        HelpTooltip.dispose(this);

        new HelpTooltip().setTitle(myPresentation.getText()).setShortcut(shortcutText).setDescription("Searches for:<br/> - Classes<br/> - Files<br/> - Tool Windows<br/> - Actions<br/> - Settings")
                .installOn(this);
      }
      else {
        setToolTipText("<html><body>Search Everywhere<br/>Press <b>" + shortcutText + "</b> to access<br/> - Classes<br/> - Files<br/> - Tool Windows<br/> - Actions<br/> - Settings</body></html>");
      }
    }
  };
}
 
源代码11 项目: consulo   文件: PackageDirectoryCache.java
@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;
}
 
源代码12 项目: flutter-intellij   文件: ToolbarComboBoxAction.java
public void showPopup() {
  JBPopup popup = createPopup(setForcePressed());
  if (Registry.is("ide.helptooltip.enabled")) {
    HelpTooltip.setMasterPopup(this, popup);
  }

  popup.showUnderneathOf(this);
}
 
源代码13 项目: flutter-intellij   文件: ToolbarComboBoxAction.java
private void updateTooltipText(String description) {
  String tooltip = KeymapUtil.createTooltipText(description, ToolbarComboBoxAction.this);
  if (Registry.is("ide.helptooltip.enabled") && StringUtil.isNotEmpty(tooltip)) {
    HelpTooltip.dispose(this);
    new HelpTooltip().setDescription(tooltip).setLocation(HelpTooltip.Alignment.BOTTOM).installOn(this);
  }
  else {
    setToolTipText(!tooltip.isEmpty() ? tooltip : null);
  }
}
 
源代码14 项目: consulo   文件: ChangeListManagerImpl.java
private void initializeForNewProject() {
  ApplicationManager.getApplication().runReadAction(() -> {
    synchronized (myDataLock) {
      if (myWorker.isEmpty()) {
        setDefaultChangeList(myWorker.addChangeList(LocalChangeList.DEFAULT_NAME, null, null));
      }
      if (!Registry.is("ide.hide.excluded.files") && !myExcludedConvertedToIgnored) {
        convertExcludedToIgnored();
        myExcludedConvertedToIgnored = true;
      }
    }
  });
}
 
源代码15 项目: flutter-intellij   文件: ToolbarComboBoxAction.java
private void updateTooltipText(String description) {
  String tooltip = KeymapUtil.createTooltipText(description, ToolbarComboBoxAction.this);
  if (Registry.is("ide.helptooltip.enabled") && StringUtil.isNotEmpty(tooltip)) {
    HelpTooltip.dispose(this);
    new HelpTooltip().setDescription(tooltip).setLocation(HelpTooltip.Alignment.BOTTOM).installOn(this);
  }
  else {
    setToolTipText(!tooltip.isEmpty() ? tooltip : null);
  }
}
 
源代码16 项目: consulo   文件: DesktopEditorImpl.java
void paint(@Nonnull Graphics2D g) {
  Rectangle clip = g.getClipBounds();

  if (clip == null) {
    return;
  }

  BufferedImage buffer = Registry.is("editor.dumb.mode.available") ? getUserData(BUFFER) : null;
  if (buffer != null) {
    Rectangle rect = getContentComponent().getVisibleRect();
    UIUtil.drawImage(g, buffer, null, rect.x, rect.y);
    return;
  }

  if (isReleased) {
    g.setColor(getDisposedBackground());
    g.fillRect(clip.x, clip.y, clip.width, clip.height);
    return;
  }
  if (myUpdateCursor) {
    setCursorPosition();
    myUpdateCursor = false;
  }
  if (myProject != null && myProject.isDisposed()) return;

  myView.paint(g);

  //boolean isBackgroundImageSet = IdeBackgroundUtil.isEditorBackgroundImageSet(myProject);
  //if (myBackgroundImageSet != isBackgroundImageSet) {
  //  myBackgroundImageSet = isBackgroundImageSet;
  //  updateOpaque(myScrollPane.getHorizontalScrollBar());
  //  updateOpaque(myScrollPane.getVerticalScrollBar());
  //}
}
 
public PantsInitComponentImpl() {
  // The Pants plugin doesn't do so many computations for building a project
  // to start an external JVM each time.
  // The plugin only calls `export` goal and parses JSON response.
  // So it will be in process all the time.
  final String key = PantsConstants.SYSTEM_ID.getId() + ExternalSystemConstants.USE_IN_PROCESS_COMMUNICATION_REGISTRY_KEY_SUFFIX;
  Registry.get(key).setValue(true);
}
 
源代码18 项目: consulo   文件: DaemonListeners.java
@Override
public void mouseMoved(@Nonnull EditorMouseEvent e) {
  if (Registry.is("ide.disable.editor.tooltips") || Registry.is("editor.new.mouse.hover.popups")) {
    return;
  }
  Editor editor = e.getEditor();
  if (myProject != editor.getProject()) return;
  if (EditorMouseHoverPopupControl.arePopupsDisabled(editor)) return;

  boolean shown = false;
  try {
    if (e.getArea() == EditorMouseEventArea.EDITING_AREA &&
        !UIUtil.isControlKeyDown(e.getMouseEvent()) &&
        DocumentationManager.getInstance(myProject).getDocInfoHint() == null &&
        EditorUtil.isPointOverText(editor, e.getMouseEvent().getPoint())) {
      LogicalPosition logical = editor.xyToLogicalPosition(e.getMouseEvent().getPoint());
      int offset = editor.logicalPositionToOffset(logical);
      HighlightInfo info = myDaemonCodeAnalyzer.findHighlightByOffset(editor.getDocument(), offset, false);
      if (info == null || info.getDescription() == null || info.getHighlighter() != null && FoldingUtil.isHighlighterFolded(editor, info.getHighlighter())) {
        IdeTooltipManager.getInstance().hideCurrent(e.getMouseEvent());
        return;
      }
      DaemonTooltipUtil.showInfoTooltip(info, editor, offset);
      shown = true;
    }
  }
  finally {
    if (!shown && !TooltipController.getInstance().shouldSurvive(e.getMouseEvent())) {
      DaemonTooltipUtil.cancelTooltips();
    }
  }
}
 
源代码19 项目: consulo   文件: IdeMouseEventDispatcher.java
private static int getScrollAmount(Component c, MouseWheelEvent me, JScrollBar scrollBar) {
  final int scrollBarWidth = scrollBar.getWidth();
  final int ratio = Registry.is("ide.smart.horizontal.scrolling") && scrollBarWidth > 0
                    ? Math.max((int)Math.pow(c.getWidth() / scrollBarWidth, 2), 10)
                    : 10; // do annoying scrolling faster if smart scrolling is on
  return me.getUnitsToScroll() * scrollBar.getUnitIncrement() * ratio;
}
 
private static JMenuItem createExportMenuItem(UberTreeViewer parseTreeViewer, String label, boolean useTransparentBackground) {
    JMenuItem item = new JMenuItem(label);
    boolean isMacNativSaveDialog = SystemInfo.isMac && Registry.is("ide.mac.native.save.dialog");

    item.addActionListener(event -> {
        String[] extensions = useTransparentBackground ? new String[]{"png", "svg"} : new String[]{"png", "jpg", "svg"};
        FileSaverDescriptor descriptor = new FileSaverDescriptor("Export Image to", "Choose the destination file", extensions);
        FileSaverDialog dialog = FileChooserFactory.getInstance().createSaveFileDialog(descriptor, (Project) null);

        String fileName = "parseTree" + (isMacNativSaveDialog ? ".png" : "");
        VirtualFileWrapper vf = dialog.save(null, fileName);

        if (vf == null) {
            return;
        }

        File file = vf.getFile();
        String imageFormat = FileUtilRt.getExtension(file.getName());
        if (StringUtils.isBlank(imageFormat)) {
            imageFormat = "png";
        }

        if ("svg".equals(imageFormat)) {
            exportToSvg(parseTreeViewer, file, useTransparentBackground);
        } else {
            exportToImage(parseTreeViewer, file, useTransparentBackground, imageFormat);
        }
    });

    return item;
}
 
源代码21 项目: buck   文件: BuckCellFinderTest.java
@Override
protected void setUp() throws Exception {
  Registry.get("ide.mac.touchbar.use").setValue(false);
  super.setUp();
  tmpDir = this.createTempDirectory();
  Project project = getProject();
  buckCellSettingsProvider = BuckCellSettingsProvider.getInstance(project);
  buckCellManager = BuckCellManager.getInstance(project);
  buckTargetLocator = BuckTargetLocator.getInstance(project);
}
 
源代码22 项目: consulo   文件: EditorMouseHoverPopupManager.java
@Override
public void beforeActionPerformed(@Nonnull AnAction action, @Nonnull DataContext dataContext, @Nonnull AnActionEvent event) {
  if (!Registry.is("editor.new.mouse.hover.popups")) {
    return;
  }
  if (action instanceof HintManagerImpl.ActionToIgnore) return;
  getInstance().cancelProcessingAndCloseHint();
}
 
源代码23 项目: consulo   文件: ChunkOptimizer.java
public LineChunkOptimizer(@Nonnull List<Line> lines1,
                          @Nonnull List<Line> lines2,
                          @Nonnull FairDiffIterable changes,
                          @Nonnull ProgressIndicator indicator) {
  super(lines1, lines2, changes, indicator);
  myThreshold = Registry.intValue("diff.unimportant.line.char.count");
}
 
源代码24 项目: consulo   文件: ByLine.java
@Nonnull
private static FairDiffIterable compareSmart(@Nonnull List<Line> lines1,
                                             @Nonnull List<Line> lines2,
                                             @Nonnull ProgressIndicator indicator) {
  int threshold = Registry.intValue("diff.unimportant.line.char.count");
  if (threshold == 0) return diff(lines1, lines2, indicator);

  Pair<List<Line>, TIntArrayList> bigLines1 = getBigLines(lines1, threshold);
  Pair<List<Line>, TIntArrayList> bigLines2 = getBigLines(lines2, threshold);

  FairDiffIterable changes = diff(bigLines1.first, bigLines2.first, indicator);
  return new ChangeCorrector.SmartLineChangeCorrector(bigLines1.second, bigLines2.second, lines1, lines2, changes, indicator).build();
}
 
源代码25 项目: consulo   文件: RecentLocationsDataModel.java
@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));
  }
}
 
源代码26 项目: consulo   文件: FocusManagerImpl.java
private FurtherRequestor(@Nonnull IdeFocusManager manager, @Nonnull Expirable expirable) {
  myManager = manager;
  myExpirable = expirable;
  if (Registry.is("ide.debugMode")) {
    myAllocation = new Exception();
  }
}
 
源代码27 项目: consulo   文件: AppIcon.java
@Override
public final void setErrorBadge(Project project, String text) {
  if (!isAppActive() && Registry.is("ide.appIcon.badge")) {
    _setOkBadge(getIdeFrame(project), false);
    _setTextBadge(getIdeFrame(project), text);
  }
}
 
源代码28 项目: consulo   文件: MnemonicHelper.java
/**
 * Initializes mnemonics support for the specified component and for its children if needed.
 *
 * @param component the root component of the hierarchy
 */
public static void init(Component component) {
  if (Registry.is("ide.mnemonic.helper.old", false) || Registry.is("ide.checkDuplicateMnemonics", false)) {
    new MnemonicHelper().register(component);
  }
  else {
    ourMnemonicFixer.addTo(component);
  }
}
 
源代码29 项目: consulo   文件: KeyboardSettingsExternalizable.java
public static boolean isSupportedKeyboardLayout(@Nonnull Component component) {
  if (Registry.is("ide.keyboard.dvorak")) return true;
  if (SystemInfo.isMac) return false;
  String keyboardLayoutLanguage = getLanguageForComponent(component);
  for (String language : supportedNonEnglishLanguages) {
    if (language.equals(keyboardLayoutLanguage)) {
      return true;
    }
  }
  return false;
}
 
源代码30 项目: consulo   文件: DialogWrapper.java
private void resizeWithAnimation(@Nonnull final Dimension size) {
  //todo[kb]: fix this PITA
  myResizeInProgress = true;
  if (!Registry.is("enable.animation.on.dialogs")) {
    setSize(size.width, size.height);
    myResizeInProgress = false;
    return;
  }

  new Thread("DialogWrapper resizer") {
    int time = 200;
    int steps = 7;

    @Override
    public void run() {
      int step = 0;
      final Dimension cur = getSize();
      int h = (size.height - cur.height) / steps;
      int w = (size.width - cur.width) / steps;
      while (step++ < steps) {
        setSize(cur.width + w * step, cur.height + h * step);
        TimeoutUtil.sleep(time / steps);
      }
      setSize(size.width, size.height);
      //repaint();
      if (myErrorText.shouldBeVisible()) {
        myErrorText.setVisible(true);
      }
      myResizeInProgress = false;
    }
  }.start();
}