Java 类com.intellij.util.ui.UIUtil 实例源码

项目:logviewer    文件:LogView.java   
@Override
public void onProcessList(Set<LogProcess> processList) {
    ApplicationManager.getApplication().executeOnPooledThread(() -> {
        final List<LogProcess> sortedList = new ArrayList<>(processList);
        sortedList.sort((l, r) -> {
            int c = l.getProcessName().compareTo(r.getProcessName());
            if (c == 0) {
                c = l.getProcessID() < r.getProcessID() ? -1 : 1;
            }
            return c;
        });
        UIUtil.invokeLaterIfNeeded(() -> {
            processListModel.removeAllElements();

            for (LogProcess client : sortedList) {
                processListModel.addElement(client);
            }
        });
    });

}
项目:logviewer    文件:LogView.java   
/**
 * Refreshes the log console in background
 */
void refresh(final String task) {
    SingleTaskBackgroundExecutor.executeIfPossible(myProject, new SingleTaskBackgroundExecutor.BackgroundTask() {
        @Override
        public void run(ProgressIndicator progressIndicator) {
            try {
                UIUtil.invokeAndWaitIfNeeded((Runnable) () -> {
                    progressIndicator.setFraction(0);
                    doFilter(progressIndicator);
                });
            } catch (Throwable ex) {
                debug("Exception " + ex.getMessage());
            }
        }

        @Override
        public String getTaskName() {
            return task;
        }
    });
}
项目:logviewer    文件:DeviceLogDataProvider.java   
/**
 * Updates the process list
 */
public void updateProcessList() {
    if (logListener != null) {
        UIUtil.invokeLaterIfNeeded(() -> {
            try {
                if (device != null && logListener != null) {
                    List<Client> clients = Lists.newArrayList(device.getClients());
                    clients.sort(new ClientCellRenderer.ClientComparator());
                    logListener.onProcessList(toLogProcess(clients));
                }
            } catch (Exception ignored) {

            }
        });
    }
}
项目:logviewer    文件:GistCreator.java   
/**
 * Create gist and returns the gist url
 */
public void createGist(Project project, final String content, final GistListener gistListener) {
    SingleTaskBackgroundExecutor.executeIfPossible(project, progressIndicator -> {
        try {
            String json = getCreateGistJson(content);
            UIUtil.invokeLaterIfNeeded(() -> progressIndicator.setFraction(.4));
            String result = callGistApi(json, gistListener);
            UIUtil.invokeLaterIfNeeded(() -> progressIndicator.setFraction(.8));
            if (result != null) {
                gistListener.onGistCreated(result);
            } else {
                gistListener.onGistFailed("Failed to share");
            }
            UIUtil.invokeLaterIfNeeded(() -> progressIndicator.setFraction(1));
        } catch (Exception ex) {
            gistListener.onGistFailed(ex.getMessage());
        }

    });
}
项目:ijphab    文件:PhabricatorRepositoryEditor.java   
@Nullable
@Override
protected JComponent createCustomPanel() {
  myIconProjectsLabel = new JBLabel("Icon Projects:", SwingConstants.RIGHT);
  myIconProjects = TextFieldWithAutoCompletion.create(
    myProject,
    Collections.emptyList(),
    true,
    myRepository.getIconProjects()
  );
  JBLabel descLabel = new JBLabel();
  descLabel.setCopyable(true);
  descLabel.setText("Only one icon is shown for each task. " +
                    "This icon is extracted from the projects the task belongs to.<br>" +
                    "You can specify the projects whose icons will be used first. " +
                    "Separate multiple projects with commas.");
  descLabel.setComponentStyle(UIUtil.ComponentStyle.SMALL);
  return FormBuilder.createFormBuilder()
    .addLabeledComponent(myIconProjectsLabel, myIconProjects)
    .addComponentToRightColumn(descLabel)
    .getPanel();
}
项目:jfrog-idea-plugin    文件:XrayToolWindow.java   
private JComponent createIssuesComponentsTreeView() {
    issuesCount = new JBLabel("Issues (0) ");

    JPanel componentsTreePanel = new JBPanel(new BorderLayout()).withBackground(UIUtil.getTableBackground());
    JLabel componentsTreeTitle = new JBLabel(" Components Tree");
    componentsTreeTitle.setFont(componentsTreeTitle.getFont().deriveFont(TITLE_FONT_SIZE));
    componentsTreePanel.add(componentsTreeTitle, BorderLayout.LINE_START);
    componentsTreePanel.add(issuesCount, BorderLayout.LINE_END);

    issuesCountPanel = new JBPanel().withBackground(UIUtil.getTableBackground());
    issuesCountPanel.setLayout(new BoxLayout(issuesCountPanel, BoxLayout.Y_AXIS));
    issuesComponentsTree.setCellRenderer(new IssuesTreeCellRenderer());
    issuesComponentsTree.expandRow(0);
    issuesComponentsTree.setRootVisible(false);
    issuesTreeExpansionListener = new IssuesTreeExpansionListener(issuesComponentsTree, issuesCountPanel, issuesCountPanels);

    JBPanel treePanel = new JBPanel(new BorderLayout()).withBackground(UIUtil.getTableBackground());
    TreeSpeedSearch treeSpeedSearch = new TreeSpeedSearch(issuesComponentsTree);
    treePanel.add(treeSpeedSearch.getComponent(), BorderLayout.WEST);
    treePanel.add(issuesCountPanel, BorderLayout.CENTER);
    JScrollPane treeScrollPane = ScrollPaneFactory.createScrollPane(treePanel);
    treeScrollPane.getVerticalScrollBar().setUnitIncrement(SCROLL_BAR_SCROLLING_UNITS);
    return new TitledPane(JSplitPane.VERTICAL_SPLIT, TITLE_LABEL_SIZE, componentsTreePanel, treeScrollPane);
}
项目:jfrog-idea-plugin    文件:XrayToolWindow.java   
private JComponent createLicensesComponentsTreeView() {
    JPanel componentsTreePanel = new JBPanel(new BorderLayout());
    componentsTreePanel.setBackground(UIUtil.getTableBackground());
    JLabel componentsTreeTitle = new JBLabel(" Components Tree");
    componentsTreeTitle.setFont(componentsTreeTitle.getFont().deriveFont(TITLE_FONT_SIZE));
    componentsTreePanel.add(componentsTreeTitle, BorderLayout.WEST);

    licensesComponentsTree.expandRow(0);
    licensesComponentsTree.setRootVisible(false);
    licensesComponentsTree.setCellRenderer(new LicensesTreeCellRenderer());
    TreeSpeedSearch treeSpeedSearch = new TreeSpeedSearch(licensesComponentsTree);
    JScrollPane treeScrollPane = ScrollPaneFactory.createScrollPane(treeSpeedSearch.getComponent());
    treeScrollPane.getVerticalScrollBar().setUnitIncrement(SCROLL_BAR_SCROLLING_UNITS);
    return new TitledPane(JSplitPane.VERTICAL_SPLIT, TITLE_LABEL_SIZE, componentsTreePanel, treeScrollPane);

}
项目:jfrog-idea-plugin    文件:DetailsViewFactory.java   
private static void addJtext(JPanel panel, int place, String header, String text) {
    JLabel headerLabel = new JBLabel(header);
    headerLabel.setOpaque(true);
    headerLabel.setBackground(UIUtil.getTableBackground());
    headerLabel.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0));

    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.ipadx = 20;
    c.ipady = 3;

    c.gridy = place;
    panel.add(headerLabel, c);

    c.gridx = 1;
    c.weightx = 0.9;
    panel.add(createJTextArea(text, true), c);
}
项目:hybris-integration-intellij-idea-plugin    文件:AbstractSelectModulesToImportStep.java   
@NotNull
protected String getModuleNameAndPath(@NotNull final HybrisModuleDescriptor moduleDescriptor) {
    Validate.notNull(moduleDescriptor);

    final StringBuilder builder = new StringBuilder();
    builder.append(moduleDescriptor.getName());

    final Font font = getComponent().getFont();
    final BufferedImage img = UIUtil.createImage(1, 1, BufferedImage.TYPE_INT_ARGB);
    final FontMetrics fm = img.getGraphics().getFontMetrics(font);

    final int currentWidth = fm.stringWidth(builder.toString());
    final int spaceWidth = fm.charWidth(' ');
    final int spaceCount = (COLUMN_WIDTH - currentWidth) / spaceWidth;

    for (int index = 0; index < spaceCount; index++) {
        builder.append(' ');
    }

    builder.append(" (");
    builder.append(moduleDescriptor.getRelativePath());
    builder.append(')');

    return builder.toString();
}
项目:hybris-integration-intellij-idea-plugin    文件:AntTreeUpdatingHack.java   
@Nullable
private static AbstractTreeBuilder getAntTreeBuilder(final AntExplorer antExplorer) {
    final JTree tree = UIUtil.findComponentOfType(antExplorer, JTree.class);

    if (tree == null) {
        LOG.info("Cannot get tree object from AntExplorer");
        return null;
    }
    final AbstractTreeBuilder antTreeBuilder = AbstractTreeBuilder.getBuilderFor(tree);

    if (antTreeBuilder == null) {
        LOG.info("Cannot get Ant tree builder");
        return null;
    }
    if (antTreeBuilder.isDisposed()) {
        LOG.info("Ant tree builder is disposed");
        return null;
    }
    return antTreeBuilder;
}
项目:SearchResourcePlugin    文件:ResultElementListCellRenderer.java   
@Override
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
    Color bgColor = UIUtil.getListBackground();
    setPaintFocusBorder(hasFocus && UIUtil.isToUseDottedCellBorder());

    if (value instanceof SearchResultElement) {
        SearchResultElement element = (SearchResultElement) value;
        String stringKeyText = "(" + element.getName() + ")";
        String text = new StringEllipsisPolicy().ellipsizeText(element.getValue(), matcher);

        SimpleTextAttributes nameAttributes = new SimpleTextAttributes(Font.PLAIN, list.getForeground());
        SpeedSearchUtil.appendColoredFragmentForMatcher(text, this, nameAttributes, matcher, bgColor, selected);
        append(" " + stringKeyText, new SimpleTextAttributes(Font.PLAIN, JBColor.GRAY));
    }

    setBackground(selected ? UIUtil.getListSelectionBackground() : bgColor);
}
项目:educational-plugin    文件:StepicAdaptiveReactionsPanel.java   
@Override
public void mouseClicked(MouseEvent e) {
  if (e.getClickCount() == 1 && isEnabled()) {
    final com.jetbrains.edu.learning.courseFormat.tasks.Task task = StudyUtils.getCurrentTask(myProject);
    if (task != null && task.getStatus() != StudyStatus.Solved) {
      final ProgressIndicatorBase progress = new ProgressIndicatorBase();
      progress.setText(EduAdaptiveStepicConnector.LOADING_NEXT_RECOMMENDATION);
      ProgressManager.getInstance().run(new Task.Backgroundable(myProject,
                                                                EduAdaptiveStepicConnector.LOADING_NEXT_RECOMMENDATION) {
        @Override
        public void run(@NotNull ProgressIndicator indicator) {
          StepicAdaptiveReactionsPanel.this.setEnabledRecursive(false);
          ApplicationManager.getApplication().invokeLater(()->setBackground(UIUtil.getLabelBackground()));
          EduAdaptiveStepicConnector.addNextRecommendedTask(StepicAdaptiveReactionsPanel.this.myProject, task.getLesson(), indicator,
                                                            myReaction);
          StepicAdaptiveReactionsPanel.this.setEnabledRecursive(true);
        }
      });
    }
  }
}
项目:educational-plugin    文件:EduCoursesPanel.java   
private void updateAdvancedSettings(Course selectedCourse) {
  myAdvancedSettingsPlaceholder.setVisible(true);
  myLocationField.getComponent().setText(nameToLocation(selectedCourse.getName()));
  EduPluginConfigurator configurator = EduPluginConfigurator.INSTANCE.forLanguage(selectedCourse.getLanguageById());
  if (configurator == null) {
    return;
  }
  EduCourseProjectGenerator generator = configurator.getEduCourseProjectGenerator();
  if (generator == null) {
    return;
  }
  LabeledComponent<JComponent> component = generator.getLanguageSettingsComponent(selectedCourse);
  myAdvancedSettings.removeAll();
  myAdvancedSettings.add(myLocationField, BorderLayout.NORTH);
  if (component != null) {
    myAdvancedSettings.add(component, BorderLayout.SOUTH);
    UIUtil.mergeComponentsWithAnchor(myLocationField, component);
  }
  myAdvancedSettings.revalidate();
  myAdvancedSettings.repaint();
}
项目:educational-plugin    文件:EduCoursesPanel.java   
private void createUIComponents() {
  mySearchField = new FilterComponent("Edu.NewCourse", 5, true) {
    @Override
    public void filter() {
      String filter = getFilter();
      List<Course> filtered = new ArrayList<>();
      for (Course course : myCourses) {
        if (accept(filter, course)) {
          filtered.add(course);
        }
      }
      updateModel(filtered, null);
    }
  };
  UIUtil.setBackgroundRecursively(mySearchField, UIUtil.getTextFieldBackground());
}
项目:educational-plugin    文件:StudySwingToolWindow.java   
@Override
public JComponent createTaskInfoPanel(Project project) {
  myTaskTextPane = new JTextPane();
  final JBScrollPane scrollPane = new JBScrollPane(myTaskTextPane);
  myTaskTextPane.setContentType(new HTMLEditorKit().getContentType());
  final EditorColorsScheme editorColorsScheme = EditorColorsManager.getInstance().getGlobalScheme();
  int fontSize = editorColorsScheme.getEditorFontSize();
  final String fontName = editorColorsScheme.getEditorFontName();
  final Font font = new Font(fontName, Font.PLAIN, fontSize);
  String bodyRule = "body { font-family: " + font.getFamily() + "; " +
                    "font-size: " + font.getSize() + "pt; }" +
                    "pre {font-family: Courier; display: inline; ine-height: 50px; padding-top: 5px; padding-bottom: 5px; padding-left: 5px; background-color:"
                    + ColorUtil.toHex(ColorUtil.dimmer(UIUtil.getPanelBackground())) + ";}" +
                    "code {font-family: Courier; display: flex; float: left; background-color:"
                    + ColorUtil.toHex(ColorUtil.dimmer(UIUtil.getPanelBackground())) + ";}";
  ((HTMLDocument)myTaskTextPane.getDocument()).getStyleSheet().addRule(bodyRule);
  myTaskTextPane.setEditable(false);
  if (!UIUtil.isUnderDarcula()) {
    myTaskTextPane.setBackground(EditorColorsManager.getInstance().getGlobalScheme().getDefaultBackground());
  }
  myTaskTextPane.setBorder(new EmptyBorder(20, 20, 0, 10));
  myTaskTextPane.addHyperlinkListener(BrowserHyperlinkListener.INSTANCE);
  return scrollPane;
}
项目:MultiHighlight    文件:ColorPreviewPanel.java   
private void highlightLine(int index, NamedTextAttr namedTextAttr) {
    UIUtil.invokeAndWaitIfNeeded((Runnable) () -> {
        try {
            MarkupModelEx markupModel = myEditor.getMarkupModel();
            final Document doc = markupModel.getDocument();
            final int lineStartOffset = doc.getLineStartOffset(index);
            final int lineEndOffset = doc.getLineEndOffset(index);
            // IDEA-53203: add ERASE_MARKER for manually defined attributes
            markupModel.addRangeHighlighter(lineStartOffset, lineEndOffset,
                    HighlighterLayer.SELECTION - 1, TextAttributes.ERASE_MARKER,
                    HighlighterTargetArea.EXACT_RANGE);
            RangeHighlighter rangeHighlight =
                    markupModel.addRangeHighlighter(lineStartOffset, lineEndOffset,
                            HighlighterLayer.SELECTION - 1, namedTextAttr,
                            HighlighterTargetArea.EXACT_RANGE);
            rangeHighlight.setErrorStripeMarkColor(namedTextAttr.getErrorStripeColor());
            rangeHighlight.setErrorStripeTooltip(namedTextAttr.getName());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    });
}
项目:intellij-ce-playground    文件:CommonActionsPanel.java   
@Override
public void addNotify() {
  if (getBackground() != null && !getBackground().equals(UIUtil.getPanelBackground())) {
    SwingUtilities.updateComponentTreeUI(this.getParent());
  }
  final JRootPane pane = getRootPane();
  for (AnActionButton button : myActions) {
    final ShortcutSet shortcut = button.getShortcut();
    if (shortcut != null) {
      if (button instanceof MyActionButton
          && ((MyActionButton)button).isAddButton()
          && UIUtil.isDialogRootPane(pane)) {
        button.registerCustomShortcutSet(shortcut, pane);
      } else {
        button.registerCustomShortcutSet(shortcut, button.getContextComponent());
      }
      if (button instanceof MyActionButton && ((MyActionButton)button).isRemoveButton()) {
        registerDeleteHook((MyActionButton)button);
      }
    }
  }

  super.addNotify(); // call after all to construct actions tooltips properly
}
项目:intellij-ce-playground    文件:SimpleNode.java   
protected void update(PresentationData presentation) {
  Object newElement = updateElement();
  if (getElement() != newElement) {
    presentation.setChanged(true);
  }
  if (newElement == null) return;

  Color oldColor = myColor;
  String oldName = myName;
  Icon oldIcon = getIcon();
  List<ColoredFragment> oldFragments = new ArrayList<ColoredFragment>(presentation.getColoredText());

  myColor = UIUtil.getTreeTextForeground();
  updateFileStatus();

  doUpdate();

  myName = getName();
  presentation.setPresentableText(myName);

  presentation.setChanged(!Comparing.equal(new Object[]{getIcon(), myName, oldFragments, myColor},
                                           new Object[]{oldIcon, oldName, oldFragments, oldColor}));

  presentation.setForcedTextForeground(myColor);
  presentation.setIcon(getIcon());
}
项目:intellij-ce-playground    文件:Stripe.java   
@Override
protected void paintComponent(final Graphics g) {
  super.paintComponent(g);
  if (!myFinishingDrop && isDroppingButton() && myDragButton.getParent() != this) {
    g.setColor(getBackground().brighter());
    g.fillRect(0, 0, getWidth(), getHeight());
  }
  if (UIUtil.isUnderDarcula()) return;
  ToolWindowAnchor anchor = getAnchor();
  g.setColor(new Color(255, 255, 255, 40));
  Rectangle r = getBounds();
  if (anchor == ToolWindowAnchor.LEFT || anchor == ToolWindowAnchor.RIGHT) {
    g.drawLine(0, 0, 0, r.height);
    g.drawLine(r.width - 2, 0, r.width - 2, r.height);
  }
  else {
    g.drawLine(0, 1, r.width, 1);
    g.drawLine(0, r.height - 1, r.width, r.height - 1);
  }
}
项目:intellij-ce-playground    文件:FileTypesTest.java   
public void testRenamedPropertiesToUnknownAndBack() throws Exception {
  FileType propFileType = myFileTypeManager.getFileTypeByFileName("xx.properties");
  assertEquals("Properties", propFileType.getName());
  File file = createTempFile("xx.properties", "xx=yy");
  VirtualFile vFile = getVirtualFile(file);
  assertEquals(propFileType, myFileTypeManager.getFileTypeByFile(vFile));

  rename(vFile, "xx.zxmcnbzmxnbc");
  UIUtil.dispatchAllInvocationEvents();
  assertEquals(PlainTextFileType.INSTANCE, myFileTypeManager.getFileTypeByFile(vFile));

  rename(vFile, "xx.properties");
  myFileTypeManager.drainReDetectQueue();
  for (int i=0; i<100;i++) {
    PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
    UIUtil.dispatchAllInvocationEvents();

    assertEquals(propFileType, myFileTypeManager.getFileTypeByFile(vFile));
    assertEmpty(myFileTypeManager.dumpReDetectQueue());
  }
}
项目:intellij-ce-playground    文件:AssociationsEditor.java   
private void initUI() {
  myComponent = new JPanel(new BorderLayout());
  mySplitter = new JBSplitter("AssociationsEditor.dividerProportion", 0.3f);
  myComponent.add(mySplitter, BorderLayout.CENTER);

  JPanel leftPanel = new JPanel(new BorderLayout());
  leftPanel.setBorder(IdeBorderFactory.createTitledBorder("Project XSLT Files", false, new Insets(0, 0, 0, 0)));
  myTree = new Tree();
  myTree.setRootVisible(false);
  myTree.setShowsRootHandles(false);
  leftPanel.add(new JBScrollPane(myTree), BorderLayout.CENTER);
  mySplitter.setFirstComponent(leftPanel);

  myList = new JBList();
  myList.setCellRenderer(new MyCellRenderer());
  myList.setMinimumSize(new Dimension(120, 200));
  myList.getEmptyText().setText("No associated files");
  JPanel rightPanel = ToolbarDecorator.createDecorator(myList)
    .addExtraAction(AnActionButton.fromAction(new AddAssociationActionWrapper()))
    .addExtraAction(AnActionButton.fromAction(new RemoveAssociationAction()))
    .disableUpDownActions().disableAddAction().disableRemoveAction().createPanel();
  UIUtil.addBorder(rightPanel, IdeBorderFactory.createTitledBorder("Associated Files", false, new Insets(0, 0, 0, 0)));
  mySplitter.setSecondComponent(rightPanel);
}
项目:intellij-ce-playground    文件:SearchEverywhereAction.java   
public MySearchTextField() {
  super(false);
  JTextField editor = getTextEditor();
  editor.setOpaque(false);
  if (SystemInfo.isMac && UIUtil.isUnderIntelliJLaF()) {
    editor.setUI((MacIntelliJTextFieldUI)MacIntelliJTextFieldUI.createUI(editor));
    editor.setBorder(new MacIntelliJTextBorder());
  } else {
    editor.setUI((DarculaTextFieldUI)DarculaTextFieldUI.createUI(editor));
    editor.setBorder(new DarculaTextBorder());
  }

  editor.putClientProperty("JTextField.Search.noBorderRing", Boolean.TRUE);
  if (UIUtil.isUnderDarcula()) {
    editor.setBackground(Gray._45);
    editor.setForeground(Gray._240);
  }
}
项目:intellij-ce-playground    文件:IgnoredSettingsPanel.java   
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
  if (UIUtil.isUnderGTKLookAndFeel()) {
    final Color background = selected ? UIUtil.getTreeSelectionBackground() : UIUtil.getTreeTextBackground();
    UIUtil.changeBackGround(this, background);
  }

  IgnoredFileBean bean = (IgnoredFileBean)value;
  final String path = bean.getPath();
  if (path != null) {
    if (path.endsWith("/")) {
      append(VcsBundle.message("ignored.configure.item.directory", path), SimpleTextAttributes.REGULAR_ATTRIBUTES);
    }
    else {
      append(VcsBundle.message("ignored.configure.item.file", path), SimpleTextAttributes.REGULAR_ATTRIBUTES);
    }
  }
  else if (bean.getMask() != null) {
    append(VcsBundle.message("ignored.configure.item.mask", bean.getMask()), SimpleTextAttributes.REGULAR_ATTRIBUTES);
  }
}
项目:intellij-ce-playground    文件:CodeInsightTestUtil.java   
@TestOnly
public static void doIntentionTest(@NotNull final CodeInsightTestFixture fixture, @NonNls final String action,
                                   @NotNull final String before, @NotNull final String after) {
  fixture.configureByFile(before);
  List<IntentionAction> availableIntentions = fixture.getAvailableIntentions();
  final IntentionAction intentionAction = findIntentionByText(availableIntentions, action);
  if (intentionAction == null) {
    Assert.fail("Action not found: " + action + " in place: " + fixture.getElementAtCaret() + " among " + availableIntentions);
  }
  new WriteCommandAction(fixture.getProject()) {
    @Override
    protected void run(@NotNull Result result) {
      fixture.launchAction(intentionAction);
    }
  }.execute();
  UIUtil.dispatchAllInvocationEvents();
  fixture.checkResultByFile(after, false);
}
项目:intellij-ce-playground    文件:LoadingDecorator.java   
public void startLoading(final boolean takeSnapshot) {
  if (isLoading() || myStartRequest || myStartAlarm.isDisposed()) return;

  myStartRequest = true;
  if (myDelay > 0) {
    myStartAlarm.addRequest(new Runnable() {
      public void run() {
        UIUtil.invokeLaterIfNeeded(new Runnable() {
          public void run() {
            if (!myStartRequest) return;
            _startLoading(takeSnapshot);
          }
        });
      }
    }, myDelay);
  } else {
    _startLoading(takeSnapshot);
  }
}
项目:intellij-ce-playground    文件:PydevConsoleRunner.java   
private void rerun() {
  new Task.Backgroundable(getProject(), "Restarting console", true) {
    @Override
    public void run(@NotNull ProgressIndicator indicator) {
      UIUtil.invokeLaterIfNeeded(new Runnable() {
        @Override
        public void run() {
          closeCommunication();
        }
      });

      myProcessHandler.waitFor();

      UIUtil.invokeLaterIfNeeded(new Runnable() {
        @Override
        public void run() {
          PydevConsoleRunner.this.run();
        }
      });
    }
  }.queue();
}
项目:intellij-ce-playground    文件:OrderEntryTest.java   
@Override
protected void setUpProject() throws Exception {
  final String root = PathManagerEx.getTestDataPath() + BASE_PATH;

  VirtualFile tempProjectRootDir =
    PsiTestUtil.createTestProjectStructure(getTestName(true), null, FileUtil.toSystemIndependentName(root), myFilesToDelete, false);

  VirtualFile projectFile = tempProjectRootDir.findChild("orderEntry.ipr");

  myProject = ProjectManagerEx.getInstanceEx().loadProject(projectFile.getPath());
  ProjectManagerEx.getInstanceEx().openTestProject(myProject);
  UIUtil.dispatchAllInvocationEvents(); // startup activities

  setUpJdk();
  myModule = ModuleManager.getInstance(getProject()).getModules()[0];
}
项目:intellij-ce-playground    文件:JBMacMessages.java   
@Override
public int showYesNoDialog(@NotNull String title,
                           String message,
                           @NotNull String yesButton,
                           @NotNull String noButton,
                           @Nullable Window window,
                           @Nullable DialogWrapper.DoNotAskOption doNotAskDialogOption) {
  if (window == null) {
    window = getForemostWindow(null);
  }
  SheetMessage sheetMessage = new SheetMessage(window, title, message, UIUtil.getQuestionIcon(),
                                               new String [] {yesButton, noButton}, doNotAskDialogOption, yesButton, noButton);
  int result = sheetMessage.getResult().equals(yesButton) ? Messages.YES : Messages.NO;
  if (doNotAskDialogOption != null && (result == Messages.YES || doNotAskDialogOption.shouldSaveOptionsOnCancel())) {
    doNotAskDialogOption.setToBeShown(sheetMessage.toBeShown(), result);
  }
  return result;
}
项目:intellij-ce-playground    文件:EditorPainter.java   
private void paintTextEffect(Graphics2D g, float xFrom, float xTo, int y, Color effectColor, EffectType effectType) {
  int xStart = (int)xFrom;
  int xEnd = (int)xTo;
  g.setColor(effectColor);
  if (effectType == EffectType.LINE_UNDERSCORE) {
    UIUtil.drawLine(g, xStart, y + 1, xEnd, y + 1);
  }
  else if (effectType == EffectType.BOLD_LINE_UNDERSCORE) {
    int height = JBUI.scale(Registry.intValue("editor.bold.underline.height", 2));
    g.fillRect(xStart, y, xEnd - xStart, height);
  }
  else if (effectType == EffectType.STRIKEOUT) {
    int y1 = y - myView.getCharHeight() / 2;
    UIUtil.drawLine(g, xStart, y1, xEnd, y1);
  }
  else if (effectType == EffectType.WAVE_UNDERSCORE) {
    UIUtil.drawWave(g, new Rectangle(xStart, y + 1, xEnd - xStart, myView.getDescent() - 1));
  }
  else if (effectType == EffectType.BOLD_DOTTED_LINE) {
    UIUtil.drawBoldDottedLine(g, xStart, xEnd, SystemInfo.isMac ? y : y + 1, myEditor.getBackgroundColor(), g.getColor(), false);
  }
}
项目:intellij-ce-playground    文件:VcsLogFiltererImpl.java   
VcsLogFiltererImpl(@NotNull final Project project,
                   @NotNull Map<VirtualFile, VcsLogProvider> providers,
                   @NotNull VcsLogHashMap hashMap,
                   @NotNull Map<Integer, VcsCommitMetadata> topCommitsDetailsCache,
                   @NotNull CommitDetailsGetter detailsGetter,
                   @NotNull final PermanentGraph.SortType initialSortType,
                   @NotNull final Consumer<VisiblePack> visiblePackConsumer) {
  myVisiblePackBuilder = new VisiblePackBuilder(providers, hashMap, topCommitsDetailsCache, detailsGetter);
  myFilters = new VcsLogFilterCollectionImpl(null, null, null, null, null, null, null);
  mySortType = initialSortType;

  myTaskController = new SingleTaskController<Request, VisiblePack>(visiblePackConsumer) {
    @Override
    protected void startNewBackgroundTask() {
      UIUtil.invokeLaterIfNeeded(new Runnable() {
        @Override
        public void run() {
          ((ProgressManagerImpl)ProgressManager.getInstance()).runProcessWithProgressAsynchronously(
            new MyTask(project, "Applying filters..."));
        }
      });
    }
  };
}
项目:intellij-ce-playground    文件:Browser.java   
public Browser(@NotNull InspectionResultsView view) {
  super(new BorderLayout());
  myView = view;

  myCurrentEntity = null;
  myCurrentDescriptor = null;

  myHTMLViewer = new JEditorPane(UIUtil.HTML_MIME, InspectionsBundle.message("inspection.offline.view.empty.browser.text"));
  myHTMLViewer.setEditable(false);
  myHyperLinkListener = new HyperlinkListener() {
    @Override
    public void hyperlinkUpdate(HyperlinkEvent e) {
      Browser.this.hyperlinkUpdate(e);
    }
  };
  myHTMLViewer.addHyperlinkListener(myHyperLinkListener);

  final JScrollPane pane = ScrollPaneFactory.createScrollPane(myHTMLViewer);
  pane.setBorder(null);
  add(pane, BorderLayout.CENTER);
  setupStyle();
}
项目:intellij-ce-playground    文件:WideSelectionTreeUI.java   
protected void paintSelectedRows(Graphics g, JTree tr) {
  final Rectangle rect = tr.getVisibleRect();
  final int firstVisibleRow = tr.getClosestRowForLocation(rect.x, rect.y);
  final int lastVisibleRow = tr.getClosestRowForLocation(rect.x, rect.y + rect.height);

  for (int row = firstVisibleRow; row <= lastVisibleRow; row++) {
    if (tr.getSelectionModel().isRowSelected(row) && myWideSelectionCondition.value(row)) {
        final Rectangle bounds = tr.getRowBounds(row);
        Color color = UIUtil.getTreeSelectionBackground(tr.hasFocus());
        if (color != null) {
          g.setColor(color);
          g.fillRect(0, bounds.y, tr.getWidth(), bounds.height);
        }
    }
  }
}
项目:intellij-ce-playground    文件:PluginsTableRenderer.java   
public PluginsTableRenderer(IdeaPluginDescriptor pluginDescriptor, boolean showFullInfo) {
  myPluginDescriptor = pluginDescriptor;
  myPluginsView = !showFullInfo;

  final Font smallFont;
  if (SystemInfo.isMac) {
    smallFont = UIUtil.getLabelFont(UIUtil.FontSize.MINI);
  } else {
    smallFont = UIUtil.getLabelFont().deriveFont(Math.max(UIUtil.getLabelFont().getSize() - 2, 10f));
  }
  myName.setFont(UIUtil.getLabelFont().deriveFont(UIUtil.getLabelFont().getSize() + 1.0f));
  myStatus.setFont(smallFont);
  myCategory.setFont(smallFont);
  myDownloads.setFont(smallFont);
  myStatus.setText("");
  myLastUpdated.setFont(smallFont);

  if (myPluginsView || pluginDescriptor.getDownloads() == null || !(pluginDescriptor instanceof PluginNode)) {
    myPanel.remove(myRightPanel);
  }
  if (myPluginsView) {
    myInfoPanel.remove(myBottomPanel);
  }

  myPanel.setBorder(UIUtil.isRetina() ? new EmptyBorder(4, 3, 4, 3) : new EmptyBorder(2, 3, 2, 3));
}
项目:intellij-ce-playground    文件:FlatComboAction.java   
public void showPopup() {
  myForcePressed = true;
  repaint();

  Runnable onDispose = new Runnable() {
    @Override
    public void run() {
      // give button chance to handle action listener
      UIUtil.invokeLaterIfNeeded(new Runnable() {
        @Override
        public void run() {
          myForcePressed = false;
          myPopup = null;
        }
      });
      repaint();
    }
  };

  myPopup = createPopup(onDispose);
  myPopup.show(new RelativePoint(this, new Point(0, this.getHeight() - 1)));
}
项目:intellij-ce-playground    文件:GenerateGetterSetterTest.java   
protected void doTest() throws Exception {
  configureByFile("/generateGetterSetter/before" + getTestName(false) + ".java");
  new GenerateGetterAndSetterHandler() {
    @Nullable
    @Override
    protected ClassMember[] chooseMembers(ClassMember[] members,
                                          boolean allowEmptySelection,
                                          boolean copyJavadocCheckbox,
                                          Project project,
                                          @Nullable Editor editor) {
      return members;
    }
  }.invoke(getProject(), getEditor(), getFile());
  UIUtil.dispatchAllInvocationEvents();
  checkResultByFile("/generateGetterSetter/after" + getTestName(false) + ".java");
}
项目:intellij-ce-playground    文件:JBCheckBox.java   
/**
 * Sets given icon to display between checkbox icon and text.
 *
 * @return true in case of success and false otherwise
 */
public boolean setTextIcon(@NotNull Icon icon) {
  if (UIUtil.isUnderDarcula() || UIUtil.isUnderIntelliJLaF()) {
    return false;
  }
  ButtonUI ui = getUI();
  if (ui instanceof BasicRadioButtonUI) {
    Icon defaultIcon = ((BasicRadioButtonUI) ui).getDefaultIcon();
    if (defaultIcon != null) {
      MergedIcon mergedIcon = new MergedIcon(defaultIcon, 10, icon);
      setIcon(mergedIcon);
      return true;
    }
  }
  return false;
}
项目:intellij-ce-playground    文件:ListUtil.java   
public static MouseMotionListener installAutoSelectOnMouseMove(final JList list) {
  final MouseMotionAdapter listener = new MouseMotionAdapter() {
    boolean myIsEngaged = false;

    public void mouseMoved(MouseEvent e) {
      Component focusOwner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
      if (myIsEngaged && !UIUtil.isSelectionButtonDown(e) && !(focusOwner instanceof JRootPane)) {
        Point point = e.getPoint();
        int index = list.locationToIndex(point);
        list.putClientProperty(SELECTED_BY_MOUSE_EVENT, Boolean.TRUE);
        list.setSelectedIndex(index);
        list.putClientProperty(SELECTED_BY_MOUSE_EVENT, Boolean.FALSE);
      }
      else {
        myIsEngaged = true;
      }
    }
  };
  list.addMouseMotionListener(listener);
  return listener;
}
项目:intellij-ce-playground    文件:ActionMenu.java   
private void fillMenu() {
  DataContext context;
  boolean mayContextBeInvalid;

  if (myContext != null) {
    context = myContext;
    mayContextBeInvalid = false;
  }
  else {
    @SuppressWarnings("deprecation") DataContext contextFromFocus = DataManager.getInstance().getDataContext();
    context = contextFromFocus;
    if (PlatformDataKeys.CONTEXT_COMPONENT.getData(context) == null) {
      IdeFrame frame = UIUtil.getParentOfType(IdeFrame.class, this);
      context = DataManager.getInstance().getDataContext(IdeFocusManager.getGlobalInstance().getLastFocusedFor(frame));
    }
    mayContextBeInvalid = true;
  }

  Utils.fillMenu(myGroup.getAction(), this, myMnemonicEnabled, myPresentationFactory, context, myPlace, true, mayContextBeInvalid);
}
项目:intellij-ce-playground    文件:ToolWindowsPane.java   
private Pair<BufferedImage, SoftReference<BufferedImage>> getImage(SoftReference<BufferedImage> imageRef) {
  LOG.assertTrue(UISettings.getInstance().ANIMATE_WINDOWS);
  BufferedImage image = imageRef.get();
  if (
    image == null ||
    image.getWidth(null) < getWidth() || image.getHeight(null) < getHeight()
    ) {
    final int width = Math.max(Math.max(1, getWidth()), myFrame.getWidth());
    final int height = Math.max(Math.max(1, getHeight()), myFrame.getHeight());
    if (SystemInfo.isWindows) {
      image = myFrame.getGraphicsConfiguration().createCompatibleImage(width, height);
    }
    else {
      // Under Linux we have found that images created by createCompatibleImage(),
      // createVolatileImage(), etc extremely slow for rendering. TrueColor buffered image
      // is MUCH faster.
      // On Mac we create a retina-compatible image

      image = UIUtil.createImage(width, height, BufferedImage.TYPE_INT_RGB);
    }
    imageRef = new SoftReference<BufferedImage>(image);
  }
  return Pair.create(image, imageRef);
}
项目:react-native-console    文件:SimpleToolWindowPanel.java   
public void setContent(JComponent c) {
  myContent = c;
  add(c, BorderLayout.CENTER);

  if (myBorderless) {
    UIUtil.removeScrollBorder(c);
  }

  revalidate();
  repaint();
}