Java 类com.intellij.ui.HyperlinkAdapter 实例源码

项目:educational-plugin    文件:StepicStudyOptions.java   
@NotNull
private HyperlinkAdapter createAuthorizeListener() {
  return new HyperlinkAdapter() {

    @Override
    protected void hyperlinkActivated(HyperlinkEvent e) {
      ApplicationManager.getApplication().getMessageBus().connect().subscribe(StudySettings.SETTINGS_CHANGED, () -> {
        StepicUser user = StudySettings.getInstance().getUser();
        if (user != null && !user.equals(myStepicUser)) {
          StudySettings.getInstance().setUser(myStepicUser);
          myStepicUser = user;
          updateLoginLabels(myStepicUser);
        }
      });

      EduStepicConnector.doAuthorize(() -> showDialog());
    }
  };
}
项目:stylint-plugin    文件:StylintInspection.java   
@NotNull
private HyperlinkLabel createHyperLink() {
    List<String> path = ContainerUtil.newArrayList(StylintBundle.message("stylint.inspections.group.name"), StylintBundle.message("stylint.inspection.group.name"), getDisplayName());
    String title = Joiner.on(" / ").join(path);
    final HyperlinkLabel settingsLink = new HyperlinkLabel(title);
    settingsLink.addHyperlinkListener(new HyperlinkAdapter() {
        public void hyperlinkActivated(HyperlinkEvent e) {
            DataContext dataContext = DataManager.getInstance().getDataContext(settingsLink);
            Project project = CommonDataKeys.PROJECT.getData(dataContext);
            if (project != null) {
                showSettings(project);
            }
        }
    });
    return settingsLink;
}
项目:stylint-plugin    文件:PackagesNotificationPanel.java   
public PackagesNotificationPanel(Project project) {
    myProject = project;
    myEditorPane.setBackground(UIManager.getColor("ArrowButton.background"));
    myEditorPane.setContentType("text/html");
    myEditorPane.setEditable(false);
    myEditorPane.addHyperlinkListener(new HyperlinkAdapter() {
        @Override
        protected void hyperlinkActivated(HyperlinkEvent e) {
            final Runnable handler = myLinkHandlers.get(e.getDescription());
            if (handler != null) {
                handler.run();
            } else if (myErrorTitle != null && myErrorDescription != null) {
                showError(myProject, myErrorTitle, myErrorDescription);
            }
        }
    });
}
项目:sass-lint-plugin    文件:SassLintInspection.java   
@NotNull
    private HyperlinkLabel createHyperLink() {
//        List path = ContainerUtil.newArrayList(JSBundle.message("settings.javascript.root.configurable.name"), JSBundle.message("settings.javascript.linters.configurable.name"), getDisplayName());
        List path = ContainerUtil.newArrayList("JavaScript", SassLintBundle.message("sasslint.inspection.group.name"), getDisplayName());

        String title = Joiner.on(" / ").join(path);
        final HyperlinkLabel settingsLink = new HyperlinkLabel(title);
        settingsLink.addHyperlinkListener(new HyperlinkAdapter() {
            public void hyperlinkActivated(HyperlinkEvent e) {
                DataContext dataContext = DataManager.getInstance().getDataContext(settingsLink);
                OptionsEditor optionsEditor = OptionsEditor.KEY.getData(dataContext);
                if (optionsEditor == null) {
                    Project project = CommonDataKeys.PROJECT.getData(dataContext);
                    if (project != null) {
                        showSettings(project);
                    }
                    return;
                }
                Configurable configurable = optionsEditor.findConfigurableById(SassLintInspection.this.getId());
                if (configurable != null) {
                    optionsEditor.clearSearchAndSelect(configurable);
                }
            }
        });
        return settingsLink;
    }
项目:intellij-ce-playground    文件:TooltipUtil.java   
public static HyperlinkLabel createTooltip(final String message) {
  final HyperlinkLabel link = new HyperlinkLabel("");
  link.setIcon(AllIcons.General.Help_small);
  link.setUseIconAsLink(true);
  link.setIconTextGap(0);
  link.addHyperlinkListener(new HyperlinkAdapter() {
    @Override
    protected void hyperlinkActivated(HyperlinkEvent e) {
      final JLabel label = new JLabel(message);
      label.setBorder(HintUtil.createHintBorder());
      label.setBackground(HintUtil.INFORMATION_COLOR);
      label.setOpaque(true);
      HintManager.getInstance()
        .showHint(label, RelativePoint.getSouthEastOf(link), HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE, -1);
    }
  });
  return link;
}
项目:intellij-ce-playground    文件:VcsCommitInfoBalloon.java   
public VcsCommitInfoBalloon(@NotNull JTree tree) {
  myTree = tree;
  myEditorPane = new JEditorPane(UIUtil.HTML_MIME, "");
  myEditorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
  myEditorPane.setEditable(false);
  myEditorPane.setBackground(HintUtil.INFORMATION_COLOR);
  myEditorPane.setFont(UIUtil.getToolTipFont());
  myEditorPane.setBorder(HintUtil.createHintBorder());
  Border margin = IdeBorderFactory.createEmptyBorder(3, 3, 3, 3);
  myEditorPane.setBorder(new CompoundBorder(myEditorPane.getBorder(), margin));
  myEditorPane.addHyperlinkListener(new HyperlinkAdapter() {
    @Override
    protected void hyperlinkActivated(HyperlinkEvent e) {
      BrowserUtil.browse(e.getURL());
    }
  });
  myWrapper = new Wrapper(myEditorPane);
  myPopupBuilder = JBPopupFactory.getInstance().createComponentPopupBuilder(myWrapper, null);
  myPopupBuilder.setCancelOnClickOutside(true).setResizable(true).setMovable(true).setRequestFocus(false)
    .setMinSize(new Dimension(80, 30));
}
项目:intellij-ce-playground    文件:PackagesNotificationPanel.java   
public PackagesNotificationPanel() {
  myHtmlViewer = SwingHelper.createHtmlViewer(true, null, null, null);
  myHtmlViewer.setVisible(false);
  myHtmlViewer.setOpaque(true);
  myHtmlViewer.addHyperlinkListener(new HyperlinkAdapter() {
    @Override
    protected void hyperlinkActivated(HyperlinkEvent e) {
      final Runnable handler = myLinkHandlers.get(e.getDescription());
      if (handler != null) {
        handler.run();
      }
      else if (myErrorTitle != null && myErrorDescription != null) {
        showError(myErrorTitle, myErrorDescription);
      }
    }
  });
}
项目:intellij-ce-playground    文件:DefaultSdksConfigurable.java   
private void createNdkDownloadLink() {
  myNdkDownloadHyperlinkLabel = new HyperlinkLabel();
  myNdkDownloadHyperlinkLabel.setHyperlinkText("", "Download", " Android NDK.");
  myNdkDownloadHyperlinkLabel.addHyperlinkListener(new HyperlinkAdapter() {
    @Override
    protected void hyperlinkActivated(HyperlinkEvent e) {
      List<IPkgDesc> requested = ImmutableList.of(PkgDesc.Builder.newNdk(FullRevision.NOT_SPECIFIED).create());
      SdkQuickfixWizard wizard = new SdkQuickfixWizard(null, null, requested);
      wizard.init();
      if (wizard.showAndGet()) {
        File ndk = IdeSdks.getAndroidNdkPath();
        if (ndk != null) {
          myNdkLocationTextField.setText(ndk.getPath());
        }
        validateState();
      }
    }
  });
}
项目:intellij-ce-playground    文件:DeveloperServicePanel.java   
private void addToLinkPanel(@NotNull String text, @NotNull final URI uri) {
  HyperlinkLabel hyperlinkLabel = new HyperlinkLabel(text);
  hyperlinkLabel.addHyperlinkListener(new HyperlinkAdapter() {
    @Override
    protected void hyperlinkActivated(HyperlinkEvent e) {
      try {
        Desktop.getDesktop().browse(uri);
      }
      catch (IOException ex) {
        // Don't care
      }
    }
  });

  // Setting the padding on myLinksPanel puts in ugly leading space, so we instead space links
  // apart using invisible rigid areas instead.
  if (myLinksPanel.getComponentCount() > 0) {
    myLinksPanel.add(Box.createRigidArea(new Dimension(10, 0)));
  }
  myLinksPanel.add(hyperlinkLabel);
}
项目:react-templates-plugin    文件:RTInspection.java   
@NotNull
    private HyperlinkLabel createHyperLink() {
        //JSBundle.message("settings.javascript.root.configurable.name")
        List<String> path = ContainerUtil.newArrayList("HTML", getDisplayName());

        String title = Joiner.on(" / ").join(path);
        final HyperlinkLabel settingsLink = new HyperlinkLabel(title);
        settingsLink.addHyperlinkListener(new HyperlinkAdapter() {
            public void hyperlinkActivated(HyperlinkEvent e) {
//                DataContext dataContext = DataManager.getInstance().getDataContext(settingsLink);
//                OptionsEditor optionsEditor = OptionsEditor.KEY.getData(dataContext);
//                if (optionsEditor == null) {
//                    Project project = CommonDataKeys.PROJECT.getData(dataContext);
//                    if (project != null) {
//                        showSettings(project);
//                    }
//                    return;
//                }
//                Configurable configurable = optionsEditor.findConfigurableById(RTInspection.this.getId());
//                if (configurable != null) {
//                    optionsEditor.clearSearchAndSelect(configurable);
//                }
            }
        });
        return settingsLink;
    }
项目:vue-for-idea    文件:PackagesNotificationPanel.java   
public PackagesNotificationPanel(Project project) {
    myProject = project;
    myEditorPane.setBackground(UIManager.getColor("ArrowButton.background"));
    myEditorPane.setContentType("text/html");
    myEditorPane.setEditable(false);
    myEditorPane.addHyperlinkListener(new HyperlinkAdapter() {
        @Override
        protected void hyperlinkActivated(HyperlinkEvent e) {
            final Runnable handler = myLinkHandlers.get(e.getDescription());
            if (handler != null) {
                handler.run();
            } else if (myErrorTitle != null && myErrorDescription != null) {
                showError(myProject, myErrorTitle, myErrorDescription);
            }
        }
    });
}
项目:coffee-lint-plugin    文件:CoffeeLintInspection.java   
@NotNull
    private HyperlinkLabel createHyperLink() {
//        List path = ContainerUtil.newArrayList(JSBundle.message("settings.javascript.root.configurable.name"), JSBundle.message("settings.javascript.linters.configurable.name"), getDisplayName());
        List path = ContainerUtil.newArrayList("JavaScript", CoffeeLintBundle.message("coffeelint.inspection.group.name"), getDisplayName());

        String title = Joiner.on(" / ").join(path);
        final HyperlinkLabel settingsLink = new HyperlinkLabel(title);
        settingsLink.addHyperlinkListener(new HyperlinkAdapter() {
            public void hyperlinkActivated(HyperlinkEvent e) {
                DataContext dataContext = DataManager.getInstance().getDataContext(settingsLink);
                OptionsEditor optionsEditor = OptionsEditor.KEY.getData(dataContext);
                if (optionsEditor == null) {
                    Project project = CommonDataKeys.PROJECT.getData(dataContext);
                    if (project != null) {
                        showSettings(project);
                    }
                    return;
                }
                Configurable configurable = optionsEditor.findConfigurableById(CoffeeLintInspection.this.getId());
                if (configurable != null) {
                    optionsEditor.clearSearchAndSelect(configurable);
                }
            }
        });
        return settingsLink;
    }
项目:react-templates-plugin    文件:RTInspection.java   
@NotNull
    private HyperlinkLabel createHyperLink() {
        //JSBundle.message("settings.javascript.root.configurable.name")
        List<String> path = ContainerUtil.newArrayList("HTML", getDisplayName());

        String title = Joiner.on(" / ").join(path);
        final HyperlinkLabel settingsLink = new HyperlinkLabel(title);
        settingsLink.addHyperlinkListener(new HyperlinkAdapter() {
            public void hyperlinkActivated(HyperlinkEvent e) {
//                DataContext dataContext = DataManager.getInstance().getDataContext(settingsLink);
//                OptionsEditor optionsEditor = OptionsEditor.KEY.getData(dataContext);
//                if (optionsEditor == null) {
//                    Project project = CommonDataKeys.PROJECT.getData(dataContext);
//                    if (project != null) {
//                        showSettings(project);
//                    }
//                    return;
//                }
//                Configurable configurable = optionsEditor.findConfigurableById(RTInspection.this.getId());
//                if (configurable != null) {
//                    optionsEditor.clearSearchAndSelect(configurable);
//                }
            }
        });
        return settingsLink;
    }
项目:eslint-plugin    文件:ESLintInspection.java   
@NotNull
private HyperlinkLabel createHyperLink() {
    List path = ContainerUtil.newArrayList(JSBundle.message("settings.javascript.root.configurable.name"), JSBundle.message("settings.javascript.linters.configurable.name"), getDisplayName());

    String title = Joiner.on(" / ").join(path);
    final HyperlinkLabel settingsLink = new HyperlinkLabel(title);
    settingsLink.addHyperlinkListener(new HyperlinkAdapter() {
        public void hyperlinkActivated(HyperlinkEvent e) {
            DataContext dataContext = DataManager.getInstance().getDataContext(settingsLink);
            OptionsEditor optionsEditor = OptionsEditor.KEY.getData(dataContext);
            if (optionsEditor == null) {
                Project project = CommonDataKeys.PROJECT.getData(dataContext);
                if (project != null) {
                    showSettings(project);
                }
                return;
            }
            Configurable configurable = optionsEditor.findConfigurableById(ESLintInspection.this.getId());
            if (configurable != null) {
                optionsEditor.clearSearchAndSelect(configurable);
            }
        }
    });
    return settingsLink;
}
项目:consulo    文件:VcsCommitInfoBalloon.java   
public VcsCommitInfoBalloon(@Nonnull JTree tree) {
  myTree = tree;
  myEditorPane = new JEditorPane(UIUtil.HTML_MIME, "");
  myEditorPane.putClientProperty(JEditorPane.HONOR_DISPLAY_PROPERTIES, Boolean.TRUE);
  myEditorPane.setEditable(false);
  myEditorPane.setBackground(HintUtil.INFORMATION_COLOR);
  myEditorPane.setFont(UIUtil.getToolTipFont());
  myEditorPane.setBorder(HintUtil.createHintBorder());
  Border margin = IdeBorderFactory.createEmptyBorder(3, 3, 3, 3);
  myEditorPane.setBorder(new CompoundBorder(myEditorPane.getBorder(), margin));
  myEditorPane.addHyperlinkListener(new HyperlinkAdapter() {
    @Override
    protected void hyperlinkActivated(HyperlinkEvent e) {
      BrowserUtil.browse(e.getURL());
    }
  });
  myWrapper = new Wrapper(myEditorPane);
  myPopupBuilder = JBPopupFactory.getInstance().createComponentPopupBuilder(myWrapper, null);
  myPopupBuilder.setCancelOnClickOutside(true).setResizable(true).setMovable(true).setRequestFocus(false)
          .setMinSize(new Dimension(80, 30));
}
项目:consulo    文件:PackagesNotificationPanel.java   
public PackagesNotificationPanel() {
  myHtmlViewer = SwingHelper.createHtmlViewer(true, null, null, null);
  myHtmlViewer.setVisible(false);
  myHtmlViewer.setOpaque(true);
  myHtmlViewer.addHyperlinkListener(new HyperlinkAdapter() {
    @Override
    protected void hyperlinkActivated(HyperlinkEvent e) {
      final Runnable handler = myLinkHandlers.get(e.getDescription());
      if (handler != null) {
        handler.run();
      }
      else if (myErrorTitle != null && myErrorDescription != null) {
        showError(myErrorTitle, myErrorDescription);
      }
    }
  });
}
项目:educational-plugin    文件:StepicStudyOptions.java   
@NotNull
private HyperlinkAdapter createLogoutListener() {
  return new HyperlinkAdapter() {
    @Override
    protected void hyperlinkActivated(HyperlinkEvent e) {
      removeCredentials();
      updateLoginLabels(null);
    }
  };
}
项目:educational-plugin    文件:StudyStepicUserWidget.java   
@NotNull
private HyperlinkAdapter createAuthorizeUserListener() {
  return new HyperlinkAdapter() {
    @Override
    protected void hyperlinkActivated(HyperlinkEvent e) {
      EduStepicConnector.doAuthorize(() -> StudyUtils.showOAuthDialog());
      myPopup.cancel();
    }
  };
}
项目:educational-plugin    文件:StudyStepicUserWidget.java   
@NotNull
private HyperlinkAdapter createLogoutListener() {
  return new HyperlinkAdapter() {
    @Override
    protected void hyperlinkActivated(HyperlinkEvent e) {
      StudySettings.getInstance().setUser(null);
      myPopup.cancel();
    }
  };
}
项目:educational-plugin    文件:StudyStepicUserWidget.java   
private void createUserPanel(@NotNull String statusText, @NotNull String actionLabelText, @NotNull HyperlinkAdapter listener) {
  int left_margin = 10;
  int top_margin = 6;
  int action_label_indent = 260;

  JPanel statusPanel = new JPanel(new BorderLayout());
  JLabel statusLabel = new JLabel(statusText);
  statusPanel.add(Box.createVerticalStrut(top_margin), BorderLayout.PAGE_START);
  statusPanel.add(Box.createHorizontalStrut(left_margin), BorderLayout.WEST);
  statusPanel.add(statusLabel, BorderLayout.CENTER);

  JPanel actionPanel = new JPanel(new BorderLayout());
  HoverHyperlinkLabel actionLabel = new HoverHyperlinkLabel(actionLabelText);
  actionLabel.addHyperlinkListener(listener);
  actionPanel.add(Box.createHorizontalStrut(action_label_indent), BorderLayout.LINE_START);
  actionPanel.add(actionLabel, BorderLayout.CENTER);
  actionPanel.add(Box.createHorizontalStrut(left_margin), BorderLayout.EAST);

  JPanel mainPanel = new JPanel();
  BoxLayout layout = new BoxLayout(mainPanel, BoxLayout.PAGE_AXIS);
  mainPanel.setLayout(layout);
  mainPanel.add(statusPanel);
  mainPanel.add(Box.createVerticalStrut(6));
  mainPanel.add(actionPanel);

  add(mainPanel, BorderLayout.PAGE_START);
}
项目:intellij-ce-playground    文件:TextMergeTool.java   
private void onChangeResolved(@NotNull TextMergeChange change) {
  if (change.isResolved()) {
    onChangeRemoved(change);
  }
  else {
    onChangeAdded(change);
  }
  if (getChangesCount() == 0 && getConflictsCount() == 0) {
    LOG.assertTrue(getFirstUnresolvedChange(true, null) == null);
    ApplicationManager.getApplication().invokeLater(new Runnable() {
      @Override
      public void run() {
        String message = "All changes have been processed.<br><a href=\"\">Save changes and finish merging</a>";
        HyperlinkListener listener = new HyperlinkAdapter() {
          @Override
          protected void hyperlinkActivated(HyperlinkEvent e) {
            destroyChangedBlocks();
            myMergeContext.finishMerge(MergeResult.RESOLVED);
          }
        };

        JComponent component = getEditor(ThreeSide.BASE).getComponent();
        Point point = new Point(component.getWidth() / 2, JBUI.scale(5));
        Color bgColor = MessageType.INFO.getPopupBackground();

        BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(message, null, bgColor, listener)
                                                                    .setAnimationCycle(200);
        Balloon balloon = balloonBuilder.createBalloon();
        balloon.show(new RelativePoint(component, point), Balloon.Position.below);
        Disposer.register(MyThreesideViewer.this, balloon);
      }
    });
  }
}
项目:intellij-ce-playground    文件:SearchForUsagesRunnable.java   
private static HyperlinkListener addHrefHandling(@Nullable final HyperlinkListener listener,
                                                 @NotNull final String hrefTarget, @NotNull final Runnable handler) {
  return new HyperlinkAdapter() {
    @Override
    protected void hyperlinkActivated(HyperlinkEvent e) {
      if (e.getDescription().equals(hrefTarget)) {
        handler.run();
      }
      else if (listener != null) {
        listener.hyperlinkUpdate(e);
      }
    }
  };
}
项目:intellij-ce-playground    文件:SearchForUsagesRunnable.java   
@NotNull
private HyperlinkListener createGotToOptionsListener(@NotNull final UsageTarget[] targets) {
  return new HyperlinkAdapter() {
    @Override
    protected void hyperlinkActivated(HyperlinkEvent e) {
      if (e.getDescription().equals(FIND_OPTIONS_HREF_TARGET)) {
        FindManager.getInstance(myProject).showSettingsAndFindUsages(targets);
      }
    }
  };
}
项目:intellij-ce-playground    文件:SearchForUsagesRunnable.java   
@NotNull
private HyperlinkListener createSearchInProjectListener() {
  return new HyperlinkAdapter() {
    @Override
    protected void hyperlinkActivated(HyperlinkEvent e) {
      if (e.getDescription().equals(SEARCH_IN_PROJECT_HREF_TARGET)) {
        PsiElement psiElement = getPsiElement(mySearchFor);
        if (psiElement != null) {
          FindManager.getInstance(myProject).findUsagesInScope(psiElement, GlobalSearchScope.projectScope(myProject));
        }
      }
    }
  };
}
项目:intellij-ce-playground    文件:FileInEditorProcessor.java   
public void processCode() {
  if (myShouldOptimizeImports) {
    myProcessor = new OptimizeImportsProcessor(myProject, myFile);
  }

  if (myProcessChangesTextOnly && !FormatChangedTextUtil.hasChanges(myFile)) {
    myNoChangesDetected = true;
  }

  myProcessor = mixWithReformatProcessor(myProcessor);
  if (myShouldRearrangeCode) {
    myProcessor = mixWithRearrangeProcessor(myProcessor);
  }

  if (shouldNotify()) {
    myProcessor.setCollectInfo(true);
    myProcessor.setPostRunnable(new Runnable() {
      @Override
      public void run() {
        String message = prepareMessage();
        if (!myEditor.isDisposed() && myEditor.getComponent().isShowing()) {
          HyperlinkListener hyperlinkListener = new HyperlinkAdapter() {
            @Override
            protected void hyperlinkActivated(HyperlinkEvent e) {
              AnAction action = ActionManager.getInstance().getAction("ShowReformatFileDialog");
              DataManager manager = DataManager.getInstance();
              if (manager != null) {
                DataContext context = manager.getDataContext(myEditor.getContentComponent());
                action.actionPerformed(AnActionEvent.createFromAnAction(action, null, "", context));
              }
            }
          };
          showHint(myEditor, message, hyperlinkListener);
        }
      }
    });
  }

  myProcessor.run();
}
项目:intellij-ce-playground    文件:IpnbConnectionManager.java   
private static void showWarning(@NotNull final IpnbFileEditor fileEditor, @NotNull final String message,
                                @Nullable final HyperlinkAdapter listener) {
  BalloonBuilder balloonBuilder = JBPopupFactory.getInstance().createHtmlTextBalloonBuilder(
    message, null, MessageType.WARNING.getPopupBackground(), listener);
  final Balloon balloon = balloonBuilder.createBalloon();
  ApplicationManager.getApplication().invokeLater(new Runnable() {
    @Override
    public void run() {
      balloon.showInCenterOf(fileEditor.getRunCellButton());
    }
  });
}
项目:intellij-ce-playground    文件:DefaultSdksConfigurable.java   
private void createNdkResetLink() {
  myNdkResetHyperlinkLabel = new HyperlinkLabel();
  myNdkResetHyperlinkLabel.setHyperlinkText("", "Select", " default NDK");
  myNdkResetHyperlinkLabel.addHyperlinkListener(new HyperlinkAdapter() {
    @Override
    protected void hyperlinkActivated(HyperlinkEvent e) {
      // known non-null since otherwise we won't show the link
      //noinspection ConstantConditions
      myNdkLocationTextField.setText(IdeSdks.getAndroidNdkPath().getPath());
    }
  });
}
项目:intellij-ce-playground    文件:ConfigureFormFactorStep.java   
private void showDownloadLink(final HyperlinkLabel link, final RemotePkgInfo remote, final JPanel cardPanel) {
  link.addHyperlinkListener(new HyperlinkAdapter() {
    @Override
    protected void hyperlinkActivated(HyperlinkEvent e) {
      showDownloadWizard(remote.getPkgDesc());
      populateAdditionalFormFactors();
      myFormFactorPanel.validate();
    }
  });
  ((JBCardLayout)cardPanel.getLayout()).show(cardPanel, DOWNLOAD_LINK_CARD);
}
项目:intellij    文件:JUnitPluginDependencyWarning.java   
private static void showPopupNotification(String message) {
  JComponent component = WindowManager.getInstance().findVisibleFrame().getRootPane();
  if (component == null) {
    return;
  }
  Rectangle rect = component.getVisibleRect();
  JBPopupFactory.getInstance()
      .createHtmlTextBalloonBuilder(
          message,
          MessageType.WARNING,
          new HyperlinkAdapter() {
            @Override
            protected void hyperlinkActivated(HyperlinkEvent e) {
              PluginUtils.installOrEnablePlugin(JUNIT_PLUGIN_ID);
            }
          })
      .setFadeoutTime(-1)
      .setHideOnLinkClick(true)
      .setHideOnFrameResize(false)
      .setHideOnClickOutside(false)
      .setHideOnKeyOutside(false)
      .setDisposable(ApplicationManager.getApplication())
      .createBalloon()
      .show(
          new RelativePoint(component, new Point(rect.x + 30, rect.y + rect.height - 10)),
          Balloon.Position.above);
}
项目:tools-idea    文件:UsageViewManagerImpl.java   
@NotNull
private HyperlinkListener createGotToOptionsListener(@NotNull final UsageTarget[] targets) {
  return new HyperlinkAdapter() {
    @Override
    protected void hyperlinkActivated(HyperlinkEvent e) {
      if (e.getDescription().equals(FIND_OPTIONS_HREF_TARGET)) {
        FindManager.getInstance(myProject).showSettingsAndFindUsages(targets);
      }
    }
  };
}
项目:asciidoctor-intellij-plugin    文件:AsciiDocToolbarPanel.java   
public HyperlinkLabel createActionLabel(@NotNull final AnAction anAction) {
  Icon icon = anAction.getTemplatePresentation().getIcon();
  HyperlinkLabel label = new HyperlinkLabel(icon == null ? anAction.getTemplatePresentation().getText() : "");
  if (icon != null) {
    label.setIcon(icon);
    label.setUseIconAsLink(true);
  }
  label.addHyperlinkListener(new HyperlinkAdapter() {
    protected void hyperlinkActivated(HyperlinkEvent e) {
      executeAction(anAction);
    }
  });
  this.myLinksPanel.add(label);
  return label;
}
项目:consulo    文件:SearchForUsagesRunnable.java   
private static HyperlinkListener addHrefHandling(@javax.annotation.Nullable final HyperlinkListener listener,
                                                 @Nonnull final String hrefTarget,
                                                 @Nonnull final Runnable handler) {
  return new HyperlinkAdapter() {
    @Override
    protected void hyperlinkActivated(HyperlinkEvent e) {
      if (e.getDescription().equals(hrefTarget)) {
        handler.run();
      }
      else if (listener != null) {
        listener.hyperlinkUpdate(e);
      }
    }
  };
}
项目:consulo    文件:SearchForUsagesRunnable.java   
@Nonnull
private HyperlinkListener createGotToOptionsListener(@Nonnull final UsageTarget[] targets) {
  return new HyperlinkAdapter() {
    @Override
    protected void hyperlinkActivated(HyperlinkEvent e) {
      if (e.getDescription().equals(FIND_OPTIONS_HREF_TARGET)) {
        TransactionGuard.getInstance().submitTransactionAndWait(() -> FindManager.getInstance(myProject).showSettingsAndFindUsages(targets));
      }
    }
  };
}
项目:consulo    文件:SearchForUsagesRunnable.java   
@Nonnull
private HyperlinkListener createSearchInProjectListener() {
  return new HyperlinkAdapter() {
    @Override
    protected void hyperlinkActivated(HyperlinkEvent e) {
      if (e.getDescription().equals(SEARCH_IN_PROJECT_HREF_TARGET)) {
        PsiElement psiElement = getPsiElement(mySearchFor);
        if (psiElement != null) {
          TransactionGuard.getInstance().submitTransactionAndWait(
                  () -> FindManager.getInstance(myProject).findUsagesInScope(psiElement, GlobalSearchScope.projectScope(myProject)));
        }
      }
    }
  };
}
项目:consulo    文件:FileInEditorProcessor.java   
public void processCode() {
  if (myShouldOptimizeImports) {
    myProcessor = new OptimizeImportsProcessor(myProject, myFile);
  }

  if (myProcessChangesTextOnly && !FormatChangedTextUtil.hasChanges(myFile)) {
    myNoChangesDetected = true;
  }

  myProcessor = mixWithReformatProcessor(myProcessor);
  if (myShouldRearrangeCode) {
    myProcessor = mixWithRearrangeProcessor(myProcessor);
  }

  if (shouldNotify()) {
    myProcessor.setCollectInfo(true);
    myProcessor.setPostRunnable(new Runnable() {
      @Override
      public void run() {
        String message = prepareMessage();
        if (!myEditor.isDisposed() && myEditor.getComponent().isShowing()) {
          HyperlinkListener hyperlinkListener = new HyperlinkAdapter() {
            @Override
            protected void hyperlinkActivated(HyperlinkEvent e) {
              AnAction action = ActionManager.getInstance().getAction("ShowReformatFileDialog");
              DataManager manager = DataManager.getInstance();
              if (manager != null) {
                DataContext context = manager.getDataContext(myEditor.getContentComponent());
                action.actionPerformed(AnActionEvent.createFromAnAction(action, null, "", context));
              }
            }
          };
          showHint(myEditor, message, hyperlinkListener);
        }
      }
    });
  }

  myProcessor.run();
}
项目:intellij-ce-playground    文件:SystemHealthMonitor.java   
private void showNotification(@PropertyKey(resourceBundle = "messages.IdeBundle") String key) {
  final String ignoreKey = "ignore." + key;
  if (myProperties.isValueSet(ignoreKey)) {
    return;
  }

  final String message = IdeBundle.message(key) + IdeBundle.message("sys.health.acknowledge.link");

  final Application app = ApplicationManager.getApplication();
  app.getMessageBus().connect(app).subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener.Adapter() {
    @Override
    public void appFrameCreated(String[] commandLineArgs, @NotNull Ref<Boolean> willOpenProject) {
      app.invokeLater(new Runnable() {
        @Override
        public void run() {
          JComponent component = WindowManager.getInstance().findVisibleFrame().getRootPane();
          if (component != null) {
            Rectangle rect = component.getVisibleRect();
            JBPopupFactory.getInstance()
              .createHtmlTextBalloonBuilder(message, MessageType.WARNING, new HyperlinkAdapter() {
                @Override
                protected void hyperlinkActivated(HyperlinkEvent e) {
                  String url = e.getDescription();
                  if ("ack".equals(url)) {
                    myProperties.setValue(ignoreKey, "true");
                  }
                  else {
                    BrowserUtil.browse(url);
                  }
                }
              })
              .setFadeoutTime(-1)
              .setHideOnFrameResize(false)
              .setHideOnLinkClick(true)
              .setDisposable(app)
              .createBalloon()
              .show(new RelativePoint(component, new Point(rect.x + 30, rect.y + rect.height - 10)), Balloon.Position.above);
          }

          Notification notification = LOG_GROUP.createNotification(message, NotificationType.WARNING);
          notification.setImportant(true);
          Notifications.Bus.notify(notification);
        }
      });
    }
  });
}
项目:intellij-ce-playground    文件:ConfigureFormFactorStep.java   
@Override
public void init() {
  super.init();

  myHelpMeChooseLink.addHyperlinkListener(new HyperlinkAdapter() {
    @Override
    protected void hyperlinkActivated(HyperlinkEvent e) {
      Integer minApiLevel = myState.get(getMinApiLevelKey(MOBILE));
      myChooseApiLevelDialog = new ChooseApiLevelDialog(null, minApiLevel == null ? 0 : minApiLevel);
      Disposer.register(myDisposable, myChooseApiLevelDialog.getDisposable());
      if (myChooseApiLevelDialog.showAndGet()) {
        int selectedApiLevel = myChooseApiLevelDialog.getSelectedApiLevel();
        myFormFactorApiSelectors.get(MOBILE).setSelectedItem(Integer.toString(selectedApiLevel));
      }
    }
  });
  register(API_FEEDBACK_KEY, myHelpMeChooseLabel, new ComponentBinding<String, JBLabel>() {
    @Override
    public void setValue(@Nullable String newValue, @NotNull JBLabel label) {
      final JBLabel referenceLabel = label;
      final String referenceString = newValue;
      ApplicationManager.getApplication().invokeLater(new Runnable() {
        @Override
        public void run() {
          referenceLabel.setText(referenceString);
        }
      });
    }
  });
  registerValueDeriver(API_FEEDBACK_KEY, new ValueDeriver<String>() {
    @Nullable
    @Override
    public Set<Key<?>> getTriggerKeys() {
      return makeSetOf(getTargetComboBoxKey(MOBILE));
    }

    @Nullable
    @Override
    public String deriveValue(@NotNull ScopedStateStore state, Key changedKey, @Nullable String currentValue) {
      AndroidTargetComboBoxItem selectedItem = state.get(getTargetComboBoxKey(MOBILE));
      String name = Integer.toString(selectedItem == null ? 0 : selectedItem.apiLevel);
      if (selectedItem != null && selectedItem.target != null) {
        name = selectedItem.target.getVersion().getApiString();
      }
      return getApiHelpText(selectedItem == null ? 0 : selectedItem.apiLevel, name);
    }
  });

  Set<Key> keys = Sets.newHashSet();
  for (Pair<Key<Boolean>, JCheckBox> item : myCheckboxKeys) {
    keys.add(item.getFirst());
    register(item.getFirst(), item.getSecond());
  }
  myState.put(myCheckboxKeys.get(0).getFirst(), true);
  // Since the controls are created before the state is completely set up (before the step is
  // attached to the wizard) we have to explicitly load the saved state here.
  for (FormFactorSdkControls control : myFormFactorApiSelectors.values()) {
    control.getMinSdkCombo().loadSavedApi();
  }
}