com.intellij.ui.HyperlinkAdapter Java Examples

The following examples show how to use com.intellij.ui.HyperlinkAdapter. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SassLintInspection.java    From sass-lint-plugin with MIT License 6 votes vote down vote up
@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;
    }
 
Example #2
Source File: RTInspection.java    From react-templates-plugin with MIT License 6 votes vote down vote up
@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;
    }
 
Example #3
Source File: PackagesNotificationPanel.java    From vue-for-idea with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
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);
            }
        }
    });
}
 
Example #4
Source File: RTInspection.java    From react-templates-plugin with MIT License 6 votes vote down vote up
@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;
    }
 
Example #5
Source File: ESLintInspection.java    From eslint-plugin with MIT License 6 votes vote down vote up
@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;
    }
 
Example #6
Source File: VcsCommitInfoBalloon.java    From consulo with Apache License 2.0 6 votes vote down vote up
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));
}
 
Example #7
Source File: PackagesNotificationPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
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);
      }
    }
  });
}
 
Example #8
Source File: JUnitPluginDependencyWarning.java    From intellij with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example #9
Source File: BlamePopup.java    From GitToolBox with Apache License 2.0 5 votes vote down vote up
private HyperlinkListener createLinkListener() {
  return new HyperlinkAdapter() {
    @Override
    protected void hyperlinkActivated(HyperlinkEvent e) {
      handleLinkClick(e.getDescription());
    }
  };
}
 
Example #10
Source File: SearchForUsagesRunnable.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static HyperlinkListener addHrefHandling(@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);
      }
    }
  };
}
 
Example #11
Source File: SearchForUsagesRunnable.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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));
      }
    }
  };
}
 
Example #12
Source File: SearchForUsagesRunnable.java    From consulo with Apache License 2.0 5 votes vote down vote up
@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)));
        }
      }
    }
  };
}
 
Example #13
Source File: FileInEditorProcessor.java    From consulo with Apache License 2.0 5 votes vote down vote up
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();
}