Java 类com.intellij.ui.awt.RelativePoint 实例源码

项目:hybris-integration-intellij-idea-plugin    文件:ExecuteHybrisConsole.java   
private void handleBadRequest(final HybrisHttpResult httpResult, final Project project) {
    if (httpResult.getStatusCode() != SC_OK) {
        final StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);

        if (httpResult.getStatusCode() == SC_NOT_FOUND || httpResult.getStatusCode() == SC_MOVED_TEMPORARILY) {
            JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(
                "Hybris Host URL '" + httpResult.getErrorMessage() + "' was incorrect. Please, check your settings.",
                MessageType.ERROR,
                null
            ).setFadeoutTime(FADEOUT_TIME)
                          .createBalloon().show(
                RelativePoint.getCenterOf(statusBar.getComponent()),
                Balloon.Position.atRight
            );
        }
    }
}
项目:educational-plugin    文件:StudyStepicUserWidget.java   
public StudyStepicUserWidget() {
  StepicUser user = StudySettings.getInstance().getUser();
  Icon icon = user == null ? EducationalCoreIcons.StepikOff : EducationalCoreIcons.Stepik;
  myComponent = new JLabel(icon);

  new ClickListener() {
    @Override
    public boolean onClick(@NotNull MouseEvent e, int clickCount) {
      Point point = new Point(0, 0);
      StepicUserComponent component = new StepicUserComponent(StudySettings.getInstance().getUser());
      final Dimension dimension = component.getPreferredSize();
      point = new Point(point.x - dimension.width, point.y - dimension.height);
      component.showComponent(new RelativePoint(e.getComponent(), point));
      return true;
    }
  }.installOn(myComponent);
}
项目:educational-plugin    文件:StudyStepicUserWidget.java   
public void showComponent(RelativePoint point) {
  myPopup = JBPopupFactory.getInstance().createComponentPopupBuilder(this, this)
    .setRequestFocus(true)
    .setCancelOnOtherWindowOpen(true)
    .setCancelOnClickOutside(true)
    .setShowBorder(true)
    .createPopup();

  Disposer.register(ApplicationManager.getApplication(), new Disposable() {
    @Override
    public void dispose() {
      Disposer.dispose(myPopup);
    }
  });

  myPopup.show(point);
}
项目:educational-plugin    文件:CCSubtaskEditorNotificationProvider.java   
@Nullable
@Override
public EditorNotificationPanel createNotificationPanel(@NotNull VirtualFile file, @NotNull FileEditor fileEditor) {
  if (!CCUtils.isCourseCreator(myProject)) {
    return null;
  }
  boolean isTestFile = CCUtils.isTestsFile(myProject, file);
  if (!isTestFile && StudyUtils.getTaskFile(myProject, file) == null) {
    return null;
  }
  Task task = StudyUtils.getTaskForFile(myProject, file);
  if (task instanceof TaskWithSubtasks) {
    final TaskWithSubtasks withSubtasks = (TaskWithSubtasks)task;
    EditorNotificationPanel panel = new EditorNotificationPanel(EditorColors.GUTTER_BACKGROUND);
    String header = (isTestFile ? "test" : "task") + " file";
    int activeSubtaskIndex = withSubtasks.getActiveSubtaskIndex() + 1;
    int subtaskSize = withSubtasks.getLastSubtaskIndex() + 1;
    panel.setText("This is a " + header + " for " + EduNames.SUBTASK + " " + activeSubtaskIndex + "/" + subtaskSize);
    panel
      .createActionLabel(SWITCH_SUBTASK, () -> createPopup(withSubtasks, myProject).show(RelativePoint.getSouthEastOf(panel)));
    return panel;
  }
  return null;
}
项目:GravSupport    文件:GravProjectGenerator.java   
@Override
public void generateProject(@NotNull Project project, @NotNull VirtualFile baseDir, @NotNull GravProjectSettings settings, @NotNull Module module) {
    StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
    VirtualFile vf = LocalFileSystem.getInstance().findFileByIoFile(new File(settings.gravInstallationPath));
    if (vf == null || !GravSdkType.isValidGravSDK(vf)) {
        JBPopupFactory.getInstance()
                .createHtmlTextBalloonBuilder("Project couldn't be created because Grav Installation isn't valid", MessageType.ERROR, null)
                .setFadeoutTime(3500)
                .createBalloon()
                .show(RelativePoint.getSouthEastOf(statusBar.getComponent()), Balloon.Position.above);
    } else {
        storage.setDefaultGravDownloadPath(settings.gravInstallationPath);
        PropertiesComponent.getInstance().setValue(LAST_USED_GRAV_HOME, new File(settings.gravInstallationPath).getAbsolutePath());
        GravProjectGeneratorUtil projectGenerator = new GravProjectGeneratorUtil();
        projectGenerator.generateProject(project, baseDir, settings, module);
        try {
            List<String> includePath = new ArrayList<>();
            includePath.add(baseDir.getPath());
            PhpIncludePathManager.getInstance(project).setIncludePath(includePath);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
项目:GravSupport    文件:GravModuleBuilder.java   
@Override
    public void moduleCreated(@NotNull Module module) {
        StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
        String msg = String.format("Please wait while module for project %s is created", project.getName());
        settings = GravProjectSettings.getInstance(project);

        JBPopupFactory.getInstance()
                .createHtmlTextBalloonBuilder(msg, MessageType.WARNING, null)
                .setFadeoutTime(4000)
                .createBalloon()
                .show(RelativePoint.getSouthEastOf(statusBar.getComponent()), Balloon.Position.above);

        VirtualFile[] roots1 = ModuleRootManager.getInstance(module).getContentRoots();
        if (roots1.length != 0) {
            final VirtualFile src = roots1[0];
            settings.withSrcDirectory = withSrcDirectory;
            settings.gravInstallationPath = getGravInstallPath().getPath();
//            settings.withSrcDirectory =
            GravProjectGeneratorUtil generatorUtil = new GravProjectGeneratorUtil();
            generatorUtil.generateProject(project, src, settings, module);
        }
    }
项目:intellij-idea-plugin-connector-for-aws-lambda    文件:MessageHelper.java   
private static void showMessage(final Project project, final MessageType messageType, final String format, final Object[] args) {
    StatusBar statusBar = windowManager.getStatusBar(project);
    if(statusBar == null || statusBar.getComponent() == null){
        return;
    }
    String message = String.format(format, args);
    jbPopupFactory.createHtmlTextBalloonBuilder(message, messageType, null)
                .setFadeoutTime(7500)
                .createBalloon()
                .show(RelativePoint.getNorthEastOf(statusBar.getComponent()), Balloon.Position.atRight);

    if(messageType == MessageType.INFO){
        log.info(message);
    }
    else if(messageType == MessageType.WARNING) {
        log.warn(message);
    }
    else{
        log.debug(message);
    }
}
项目:NetSuite-Tools-For-WebStorm    文件:UploadTask.java   
private void displayUploadResultBalloonMessage(String fileName, Boolean isSuccess) {
    String message = fileName + " Uploaded Successfully";
    MessageType messageType = MessageType.INFO;

    if (!isSuccess) {
        message = fileName + " Failed to Upload";
        messageType = MessageType.ERROR;
    }

    JBPopupFactory.getInstance()
            .createHtmlTextBalloonBuilder("<h3>" + message + "</h3>", messageType, null)
            .setFadeoutTime(3000)
            .createBalloon()
            .show(RelativePoint.getNorthEastOf(WindowManager.getInstance().getIdeFrame(project).getComponent()),
                    Balloon.Position.above);
}
项目:samebug-idea-plugin    文件:IncomingChatInvitationPopupController.java   
public void showIncomingChatInvitation(@NotNull ChatInvitation chatInvitation, @NotNull IncomingChatInvitationNotification notification) {
    IncomingChatInvitationPopup.Model popupModel = IdeaSamebugPlugin.getInstance().conversionService.convertIncomingChatInvitationPopup(chatInvitation);
    IncomingChatInvitationPopup popup = new IncomingChatInvitationPopup(popupModel);
    IncomingChatInvitationPopupListener incomingChatInvitationPopupListener = new IncomingChatInvitationPopupListener(this, chatInvitation);
    ListenerService.putListenerToComponent(popup, IIncomingChatInvitationPopup.Listener.class, incomingChatInvitationPopupListener);

    BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createBalloonBuilder(popup);
    balloonBuilder.setFillColor(ColorService.forCurrentTheme(ColorService.Background));
    balloonBuilder.setContentInsets(new Insets(40, 0, 40, 0));
    balloonBuilder.setBorderInsets(new Insets(0, 0, 0, 0));
    balloonBuilder.setBorderColor(ColorService.forCurrentTheme(ColorService.Background));
    balloonBuilder.setShadow(true);
    IdeFrame window = (IdeFrame) NotificationsManagerImpl.findWindowForBalloon(myProject);
    RelativePoint pointToShowPopup = null;
    if (window != null) pointToShowPopup = RelativePoint.getSouthEastOf(window.getComponent());
    Balloon balloon = balloonBuilder.createBalloon();
    balloon.show(pointToShowPopup, Balloon.Position.atLeft);

    TrackingService.trace(SwingRawEvent.notificationShow(popup));
}
项目:samebug-idea-plugin    文件:HelpRequestPopupController.java   
public void showIncomingHelpRequest(@NotNull IncomingHelpRequest helpRequest, @NotNull IncomingHelpRequestNotification notification) {
    IHelpRequestPopup.Model popupModel = IdeaSamebugPlugin.getInstance().conversionService.convertHelpRequestPopup(helpRequest);
    HelpRequestPopup popup = new HelpRequestPopup(popupModel);
    DataService.putData(popup, TrackingKeys.Location, new Locations.HelpRequestNotification(helpRequest.getMatch().getHelpRequest().getId()));
    DataService.putData(popup, TrackingKeys.WriteTipTransaction, Funnels.newTransactionId());
    HelpRequestPopupListener helpRequestPopupListener = new HelpRequestPopupListener(this);
    ListenerService.putListenerToComponent(popup, IHelpRequestPopup.Listener.class, helpRequestPopupListener);

    BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createBalloonBuilder(popup);
    balloonBuilder.setFillColor(ColorService.forCurrentTheme(ColorService.Background));
    balloonBuilder.setContentInsets(new Insets(40, 0, 40, 0));
    balloonBuilder.setBorderInsets(new Insets(0, 0, 0, 0));
    balloonBuilder.setBorderColor(ColorService.forCurrentTheme(ColorService.Background));
    balloonBuilder.setShadow(true);
    IdeFrame window = (IdeFrame) NotificationsManagerImpl.findWindowForBalloon(myProject);
    RelativePoint pointToShowPopup = null;
    if (window != null) pointToShowPopup = RelativePoint.getSouthEastOf(window.getComponent());
    Balloon balloon = balloonBuilder.createBalloon();
    data.put(popup, helpRequest);
    notifications.put(popup, notification);
    balloons.put(popup, balloon);
    balloon.show(pointToShowPopup, Balloon.Position.atLeft);

    TrackingService.trace(SwingRawEvent.notificationShow(popup));
}
项目:intellij-ce-playground    文件:NavBarUpdateQueue.java   
private void queueRevalidate(@Nullable final Runnable after) {
  queue(new AfterModelUpdate(ID.REVALIDATE) {
    @Override
    protected void after() {
      final LightweightHint hint = myPanel.getHint();
      if (hint != null) {
        myPanel.getHintContainerShowPoint().doWhenDone(new Consumer<RelativePoint>() {
          @Override
          public void consume(final RelativePoint relativePoint) {
            hint.setSize(myPanel.getPreferredSize());
            hint.setLocation(relativePoint);
            if (after != null) {
              after.run();
            }
          }
        });
      }
      else {
        if (after != null) {
          after.run();
        }
      }
    }
  });
}
项目:intellij-ce-playground    文件:ProjectConfigurationProblem.java   
@Override
public void fix(final JComponent contextComponent, RelativePoint relativePoint) {
  JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<ConfigurationErrorQuickFix>(null, myDescription.getFixes()) {
    @NotNull
    @Override
    public String getTextFor(ConfigurationErrorQuickFix value) {
      return value.getActionName();
    }

    @Override
    public PopupStep onChosen(final ConfigurationErrorQuickFix selectedValue, boolean finalChoice) {
      return doFinalStep(new Runnable() {
        @Override
        public void run() {
          selectedValue.performFix();
        }
      });
    }
  }).show(relativePoint);
}
项目:intellij-ce-playground    文件:DirDiffTableModel.java   
private void reportException(final String htmlContent) {
  Runnable balloonShower = new Runnable() {
    @Override
    public void run() {
      Balloon balloon = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(htmlContent, MessageType.WARNING, null).
        setShowCallout(false).setHideOnClickOutside(true).setHideOnAction(true).setHideOnFrameResize(true).setHideOnKeyOutside(true).
        createBalloon();
      final Rectangle rect = myPanel.getPanel().getBounds();
      final Point p = new Point(rect.x + rect.width - 100, rect.y + 50);
      final RelativePoint point = new RelativePoint(myPanel.getPanel(), p);
      balloon.show(point, Balloon.Position.below);
      Disposer.register(myProject != null ? myProject : ApplicationManager.getApplication(), balloon);
    }
  };
  ApplicationManager.getApplication().invokeLater(balloonShower, new Condition() {
    @Override
    public boolean value(Object o) {
      return !(myProject == null || myProject.isDefault()) && ((!myProject.isOpen()) || myProject.isDisposed());
    }
  }
  );
}
项目:intellij-ce-playground    文件:NavigateToTestDataAction.java   
@Override
public void actionPerformed(AnActionEvent e) {
  final DataContext dataContext = e.getDataContext();
  final Project project = CommonDataKeys.PROJECT.getData(dataContext);
  List<String> fileNames = findTestDataFiles(dataContext);
  if (fileNames == null || fileNames.isEmpty()) {
    String testData = guessTestData(dataContext);
    if (testData == null) {
      String message = "Cannot find testdata files for class";
      final Notification notification = new Notification("testdata", "Found no testdata files", message, NotificationType.INFORMATION);
      Notifications.Bus.notify(notification, project);
      return;
    }
    fileNames = Collections.singletonList(testData);
  }

  final Editor editor = e.getData(CommonDataKeys.EDITOR);
  final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
  final RelativePoint point = editor != null ? popupFactory.guessBestPopupLocation(editor) : popupFactory.guessBestPopupLocation(dataContext);

  TestDataNavigationHandler.navigate(point, fileNames, project);
}
项目:intellij-ce-playground    文件:PopupUtil.java   
public static void showBalloonForComponent(@NotNull Component component, @NotNull final String message, final MessageType type,
                                           final boolean atTop, @Nullable final Disposable disposable) {
  final JBPopupFactory popupFactory = JBPopupFactory.getInstance();
  if (popupFactory == null) return;
  BalloonBuilder balloonBuilder = popupFactory.createHtmlTextBalloonBuilder(message, type, null);
  balloonBuilder.setDisposable(disposable == null ? ApplicationManager.getApplication() : disposable);
  Balloon balloon = balloonBuilder.createBalloon();
  Dimension size = component.getSize();
  Balloon.Position position;
  int x;
  int y;
  if (size == null) {
    x = y = 0;
    position = Balloon.Position.above;
  }
  else {
    x = Math.min(10, size.width / 2);
    y = size.height;
    position = Balloon.Position.below;
  }
  balloon.show(new RelativePoint(component, new Point(x, y)), position);
}
项目:intellij-ce-playground    文件:PyUtil.java   
/**
 * Shows an information balloon in a reasonable place at the top right of the window.
 *
 * @param project     our project
 * @param message     the text, HTML markup allowed
 * @param messageType message type, changes the icon and the background.
 */
// TODO: move to a better place
public static void showBalloon(Project project, String message, MessageType messageType) {
  // ripped from com.intellij.openapi.vcs.changes.ui.ChangesViewBalloonProblemNotifier
  final JFrame frame = WindowManager.getInstance().getFrame(project.isDefault() ? null : project);
  if (frame == null) return;
  final JComponent component = frame.getRootPane();
  if (component == null) return;
  final Rectangle rect = component.getVisibleRect();
  final Point p = new Point(rect.x + rect.width - 10, rect.y + 10);
  final RelativePoint point = new RelativePoint(component, p);

  JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(message, messageType.getDefaultIcon(), messageType.getPopupBackground(), null)
    .setShowCallout(false).setCloseButtonEnabled(true)
    .createBalloon().show(point, Balloon.Position.atLeft);
}
项目:intellij-ce-playground    文件:ColorPicker.java   
private void updateBalloonText() {
  final Point point = myVertical ? new Point(0, myPointerValue) : new Point(myPointerValue, 0);
  myLabel.setText(myTitle + ": " + Unit.formatValue(myValue, myUnit));
  if (myTooltipHint == null) {
    myTooltipHint = new LightweightHint(myLabel);
    myTooltipHint.setCancelOnClickOutside(false);
    myTooltipHint.setCancelOnOtherWindowOpen(false);

    final HintHint hint = new HintHint(this, point)
      .setPreferredPosition(myVertical ? Balloon.Position.atLeft : Balloon.Position.above)
      .setBorderColor(Color.BLACK)
      .setAwtTooltip(true)
      .setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD))
      .setTextBg(HintUtil.INFORMATION_COLOR)
      .setShowImmediately(true);

    final Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
    myTooltipHint.show(this, point.x, point.y, owner instanceof JComponent ? (JComponent)owner : null, hint);
  }
  else {
    myTooltipHint.setLocation(new RelativePoint(this, point));
  }
}
项目:intellij-ce-playground    文件:DragHelper.java   
@Override
protected void processDragFinish(MouseEvent event, boolean willDragOutStart) {
  super.processDragFinish(event, willDragOutStart);

  endDrag(willDragOutStart);

  final JBTabsPosition position = myTabs.getTabsPosition();

  if (!willDragOutStart && myTabs.isAlphabeticalMode() && position != JBTabsPosition.top && position != JBTabsPosition.bottom) {
    Point p = new Point(event.getPoint());
    p = SwingUtilities.convertPoint(event.getComponent(), p, myTabs);
    if (myTabs.getVisibleRect().contains(p) && myPressedOnScreenPoint.distance(new RelativePoint(event).getScreenPoint()) > 15) {
      final int answer = Messages.showOkCancelDialog(myTabs,
                                                     IdeBundle.message("alphabetical.mode.is.on.warning"),
                                                     IdeBundle.message("title.warning"),
                                                     Messages.getQuestionIcon());
      if (answer == Messages.OK) {
        JBEditorTabs.setAlphabeticalMode(false);
        myTabs.relayout(true, false);
        myTabs.revalidate();
      }
    }
  }
}
项目:intellij-ce-playground    文件:ChangesFragmentedDiffPanel.java   
@Override
public void actionPerformed(AnActionEvent e) {
  final DefaultActionGroup dag = new DefaultActionGroup();
  dag.add(myUsual);
  dag.add(myNumbered);
  dag.add(new Separator());
  dag.add(mySoftWrapsAction);
  final ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(null, dag, e.getDataContext(),
                                                                                   JBPopupFactory.ActionSelectionAid.SPEEDSEARCH,
                                                                                   false);
  if (e.getInputEvent() instanceof MouseEvent) {
    popup.show(new RelativePoint((MouseEvent)e.getInputEvent()));
  } else {
    // todo correct
    /*final Dimension dimension = popup.getContent().getPreferredSize();
    final Point at = new Point(-dimension.width / 2, 0);
    popup.show(new RelativePoint(myParent, at));*/
    popup.showInBestPositionFor(e.getDataContext());
  }
}
项目:intellij-ce-playground    文件:DockableEditorTabbedContainer.java   
@Override
public Image processDropOver(@NotNull DockableContent content, RelativePoint point) {
  JBTabs current = getTabsAt(content, point);

  if (myCurrentOver != null && myCurrentOver != current) {
    resetDropOver(content);
  }

  if (myCurrentOver == null && current != null) {
    myCurrentOver = current;
    Presentation presentation = content.getPresentation();
    myCurrentOverInfo = new TabInfo(new JLabel("")).setText(presentation.getText()).setIcon(presentation.getIcon());
    myCurrentOverImg = myCurrentOver.startDropOver(myCurrentOverInfo, point);
  }

  if (myCurrentOver != null) {
    myCurrentOver.processDropOver(myCurrentOverInfo, point);
  }

  return myCurrentOverImg;
}
项目: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    文件:LightweightHint.java   
@Override
public void setLocation(@NotNull RelativePoint point) {
  if (isRealPopup()) {
    myPopup.setLocation(point.getScreenPoint());
  }
  else {
    if (myCurrentIdeTooltip != null) {
      Point screenPoint = point.getScreenPoint();
      if (!screenPoint.equals(new RelativePoint(myCurrentIdeTooltip.getComponent(), myCurrentIdeTooltip.getPoint()).getScreenPoint())) {
        myCurrentIdeTooltip.setPoint(point.getPoint());
        myCurrentIdeTooltip.setComponent(point.getComponent());
        IdeTooltipManager.getInstance().show(myCurrentIdeTooltip, true, false);
      }
    }
    else {
      Point targetPoint = point.getPoint(myComponent.getParent());
      myComponent.setLocation(targetPoint);

      myComponent.revalidate();
      myComponent.repaint();
    }
  }
}
项目:intellij-ce-playground    文件:SlideComponent.java   
private void updateBalloonText() {
  final Point point = myVertical ? new Point(0, myPointerValue) : new Point(myPointerValue, 0);
  myLabel.setText(myTitle + ": " + Unit.formatValue(myValue, myUnit));
  if (myTooltipHint == null) {
    myTooltipHint = new LightweightHint(myLabel);
    myTooltipHint.setCancelOnClickOutside(false);
    myTooltipHint.setCancelOnOtherWindowOpen(false);

    final HintHint hint = new HintHint(this, point)
      .setPreferredPosition(myVertical ? Balloon.Position.atLeft : Balloon.Position.above)
      .setBorderColor(Color.BLACK)
      .setAwtTooltip(true)
      .setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD))
      .setTextBg(HintUtil.INFORMATION_COLOR)
      .setShowImmediately(true);

    final Component owner = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner();
    myTooltipHint.show(this, point.x, point.y, owner instanceof JComponent ? (JComponent)owner : null, hint);
  }
  else {
    myTooltipHint.setLocation(new RelativePoint(this, point));
  }
}
项目:intellij-ce-playground    文件:TogglePopupHintsPanel.java   
@Override
public Consumer<MouseEvent> getClickConsumer() {
  return new Consumer<MouseEvent>() {
    @Override
    public void consume(final MouseEvent e) {
      Point point = new Point(0, 0);
      final PsiFile file = getCurrentFile();
      if (file != null) {
        if (!DaemonCodeAnalyzer.getInstance(file.getProject()).isHighlightingAvailable(file)) return;
        final HectorComponent component = new HectorComponent(file);
        final Dimension dimension = component.getPreferredSize();
        point = new Point(point.x - dimension.width, point.y - dimension.height);
        component.showComponent(new RelativePoint(e.getComponent(), point));
      }
    }
  };
}
项目:intellij-ce-playground    文件:AnnotateDiffViewerAction.java   
private static void showNotification(@NotNull DiffViewerBase viewer, @NotNull Notification notification) {
  JComponent component = viewer.getComponent();

  Window window = UIUtil.getWindow(component);
  if (window instanceof IdeFrame && NotificationsManagerImpl.findWindowForBalloon(viewer.getProject()) == window) {
    notification.notify(viewer.getProject());
    return;
  }

  Balloon balloon = NotificationsManagerImpl.createBalloon(component, notification, false, true);
  Disposer.register(viewer, balloon);

  Dimension componentSize = component.getSize();
  Dimension balloonSize = balloon.getPreferredSize();

  int width = Math.min(balloonSize.width, componentSize.width);
  int height = Math.min(balloonSize.height, componentSize.height);

  // top-right corner, 20px to the edges
  RelativePoint point = new RelativePoint(component, new Point(componentSize.width - 20 - width / 2, 20 + height / 2));
  balloon.show(point, Balloon.Position.above);
}
项目:GitHub    文件:Toast.java   
/**
 * Display simple notification of given type
 *
 * @param project
 * @param type
 * @param text
 */
public static void make(Project project, JComponent jComponent, MessageType type, String text) {

    StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);

    JBPopupFactory.getInstance()
            .createHtmlTextBalloonBuilder(text, type, null)
            .setFadeoutTime(7500)
            .createBalloon()
            .show(RelativePoint.getCenterOf(jComponent), Balloon.Position.above);
}
项目:GitHub    文件:Toast.java   
/**
 * Display simple notification of given type
 *
 * @param project
 * @param type
 * @param text
 */
public static void make(Project project, MessageType type, String text) {

    StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);

    JBPopupFactory.getInstance()
            .createHtmlTextBalloonBuilder(text, type, null)
            .setFadeoutTime(7500)
            .createBalloon()
            .show(RelativePoint.getCenterOf(statusBar.getComponent()), Balloon.Position.atRight);
}
项目:CodeGenerate    文件:Toast.java   
/**
 * Display simple notification of given type
 *
 * @param project
 * @param type
 * @param text
 */
public static void make(Project project, JComponent jComponent, MessageType type, String text) {

    StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);

    JBPopupFactory.getInstance()
            .createHtmlTextBalloonBuilder(text, type, null)
            .setFadeoutTime(7500)
            .createBalloon()
            .show(RelativePoint.getCenterOf(jComponent), Balloon.Position.above);
}
项目:CodeGenerate    文件:Toast.java   
/**
 * Display simple notification of given type
 *
 * @param project
 * @param type
 * @param text
 */
public static void make(Project project, MessageType type, String text) {

    StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);

    JBPopupFactory.getInstance()
            .createHtmlTextBalloonBuilder(text, type, null)
            .setFadeoutTime(7500)
            .createBalloon()
            .show(RelativePoint.getCenterOf(statusBar.getComponent()), Balloon.Position.atRight);
}
项目:OpenInExplorer-idea    文件:Toast.java   
/**
 * Display simple notification of given type
 *
 * @param project     project
 * @param messageType messageType
 * @param text        text
 */
public static void make(Project project, JComponent jComponent, MessageType messageType, String text) {
    JBPopupFactory.getInstance()
            .createHtmlTextBalloonBuilder(text, messageType, null)
            .setFadeoutTime(7500)
            .createBalloon()
            .show(RelativePoint.getCenterOf(jComponent), Balloon.Position.above);
}
项目:OpenInExplorer-idea    文件:Toast.java   
/**
 * Display simple notification of given type
 *
 * @param project     project
 * @param messageType messageType
 * @param text        text
 */
public static void make(Project project, MessageType messageType, String text) {
    StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
    JBPopupFactory.getInstance()
            .createHtmlTextBalloonBuilder(text, messageType, null)
            .setFadeoutTime(7500)
            .createBalloon()
            .show(RelativePoint.getCenterOf(statusBar.getComponent()), Balloon.Position.atRight);
}
项目:educational-plugin    文件:StudyUtils.java   
public static RelativePoint computeLocation(Editor editor){

    final Rectangle visibleRect = editor.getComponent().getVisibleRect();
    Point point = new Point(visibleRect.x + visibleRect.width + 10,
                            visibleRect.y + 10);
    return new RelativePoint(editor.getComponent(), point);
  }
项目:GravSupport    文件:NotificationHelper.java   
public static void showBaloon(String msg, MessageType messageType, Project project) {
    StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
    JBPopupFactory.getInstance()
            .createHtmlTextBalloonBuilder(msg, messageType, null)
            .setFadeoutTime(3500)
            .createBalloon()
            .show(RelativePoint.getSouthEastOf(statusBar.getComponent()), Balloon.Position.above);
}
项目:GravSupport    文件:InstallDevtoolsPlugin.java   
@Override
public void onSuccess() {
    super.onSuccess();
    StatusBar statusBar = WindowManager.getInstance().getStatusBar(getProject());
    if (processUtils.getErrorOutput() != null && !processUtils.getErrorOutput().isEmpty()) {
        NotificationHelper.showBaloon(processUtils.getErrorOutput(), MessageType.ERROR, getProject());
    } else {
        JBPopupFactory.getInstance()
                .createHtmlTextBalloonBuilder("Devtools plugin installed", MessageType.INFO, null)
                .setFadeoutTime(3500)
                .createBalloon()
                .show(RelativePoint.getSouthEastOf(statusBar.getComponent()), Balloon.Position.above);
    }
}
项目:sutr-io    文件:ActionUtil.java   
public static void ShowErrorMessage(final String message, AnActionEvent e) {
    StatusBar statusBar = WindowManager.getInstance().getStatusBar(LangDataKeys.PROJECT.getData(e.getDataContext()));

    JBPopupFactory.getInstance()
            .createHtmlTextBalloonBuilder(message, MessageType.ERROR, null)
            .setFadeoutTime(5000)
            .createBalloon()
            .show(RelativePoint.getCenterOf(statusBar.getComponent()), Balloon.Position.atRight);
}
项目:intellij-ce-playground    文件:ShowUsagesAction.java   
private static Rectangle fitToScreen(@NotNull Dimension newDim, @NotNull RelativePoint popupPosition, JTable table) {
  Rectangle rectangle = new Rectangle(popupPosition.getScreenPoint(), newDim);
  ScreenUtil.fitToScreen(rectangle);
  if (rectangle.getHeight() != newDim.getHeight()) {
    int newHeight = (int)rectangle.getHeight();
    int roundedHeight = newHeight - newHeight % table.getRowHeight();
    rectangle.setSize((int)rectangle.getWidth(), Math.max(roundedHeight, table.getRowHeight()));
  }
  return rectangle;

}
项目:intellij-ce-playground    文件:StudyUtils.java   
public static RelativePoint computeLocation(Editor editor){

    final Rectangle visibleRect = editor.getComponent().getVisibleRect();
    Point point = new Point(visibleRect.x + visibleRect.width + 10,
                            visibleRect.y + 10);
    return new RelativePoint(editor.getComponent(), point);
  }
项目:intellij-ce-playground    文件:BaseStructureConfigurable.java   
@Override
protected RelativePoint getPointToShowResults() {
  final int selectedRow = myTree.getSelectionRows()[0];
  final Rectangle rowBounds = myTree.getRowBounds(selectedRow);
  final Point location = rowBounds.getLocation();
  location.x += rowBounds.width;
  return new RelativePoint(myTree, location);
}
项目:intellij-ce-playground    文件:ArtifactEditorFindUsagesActionBase.java   
@Override
protected RelativePoint getPointToShowResults() {
  final int selectedRow = myTree.getSelectionRows()[0];
  final Rectangle rowBounds = myTree.getRowBounds(selectedRow);
  final Point location = rowBounds.getLocation();
  location.y += rowBounds.height;
  return new RelativePoint(myTree, location);
}
项目:intellij-ce-playground    文件:ShowUsagesAction.java   
private void showDialogAndFindUsages(@NotNull FindUsagesHandler handler,
                                     @NotNull RelativePoint popupPosition,
                                     Editor editor,
                                     int maxUsages) {
  AbstractFindUsagesDialog dialog = handler.getFindUsagesDialog(false, false, false);
  if (dialog.showAndGet()) {
    dialog.calcFindUsagesOptions();
    FindUsagesOptions options = handler.getFindUsagesOptions(DataManager.getInstance().getDataContext());
    showElementUsages(editor, popupPosition, handler, maxUsages, options);
  }
}