use of javax.swing.event.HyperlinkEvent in project intellij-community by JetBrains.
the class DvcsBranchPopup method notifyAboutSyncedBranches.
private void notifyAboutSyncedBranches() {
String description = "You have several " + myVcs.getDisplayName() + " roots in the project and they all are checked out at the same branch. " + "We've enabled synchronous branch control for the project. <br/>" + "If you wish to control branches in different roots separately, " + "you may <a href='settings'>disable</a> the setting.";
NotificationListener listener = new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
ShowSettingsUtil.getInstance().showSettingsDialog(myProject, myVcs.getConfigurable().getDisplayName());
if (myVcsSettings.getSyncSetting() == DvcsSyncSettings.Value.DONT_SYNC) {
notification.expire();
}
}
}
};
VcsNotifier.getInstance(myProject).notifyImportantInfo("Synchronous branch control enabled", description, listener);
}
use of javax.swing.event.HyperlinkEvent in project intellij-community by JetBrains.
the class ArtifactEditorImpl method createMainComponent.
public JComponent createMainComponent() {
mySourceItemsTree.initTree();
myLayoutTreeComponent.initTree();
DataManager.registerDataProvider(myMainPanel, new TypeSafeDataProviderAdapter(new MyDataProvider()));
myErrorPanelPlace.add(myValidationManager.getMainErrorPanel(), BorderLayout.CENTER);
final JBSplitter splitter = new OnePixelSplitter(false);
final JPanel leftPanel = new JPanel(new BorderLayout());
JPanel treePanel = myLayoutTreeComponent.getTreePanel();
if (UIUtil.isUnderDarcula()) {
treePanel.setBorder(new EmptyBorder(3, 0, 0, 0));
} else {
treePanel.setBorder(new LineBorder(UIUtil.getBorderColor()));
}
leftPanel.add(treePanel, BorderLayout.CENTER);
if (UIUtil.isUnderDarcula()) {
CompoundBorder border = new CompoundBorder(new CustomLineBorder(0, 0, 0, 1), BorderFactory.createEmptyBorder(0, 0, 0, 0));
leftPanel.setBorder(border);
} else {
leftPanel.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 0));
}
splitter.setFirstComponent(leftPanel);
final JPanel rightPanel = new JPanel(new BorderLayout());
final JPanel rightTopPanel = new JPanel(new BorderLayout());
final JPanel labelPanel = new JPanel();
labelPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.X_AXIS));
labelPanel.add(new JLabel("Available Elements "));
final HyperlinkLabel link = new HyperlinkLabel("");
link.setIcon(AllIcons.General.Help_small);
link.setUseIconAsLink(true);
link.addHyperlinkListener(new HyperlinkAdapter() {
@Override
protected void hyperlinkActivated(HyperlinkEvent e) {
final JLabel label = new JLabel(ProjectBundle.message("artifact.source.items.tree.tooltip"));
label.setBorder(HintUtil.createHintBorder());
label.setBackground(HintUtil.getInformationColor());
label.setOpaque(true);
HintManager.getInstance().showHint(label, RelativePoint.getSouthWestOf(link), HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE, -1);
}
});
labelPanel.add(link);
rightTopPanel.add(labelPanel, BorderLayout.CENTER);
rightPanel.add(rightTopPanel, BorderLayout.NORTH);
JScrollPane scrollPane = ScrollPaneFactory.createScrollPane(mySourceItemsTree, true);
JPanel scrollPaneWrap = new JPanel(new BorderLayout());
scrollPaneWrap.add(scrollPane, BorderLayout.CENTER);
if (UIUtil.isUnderDarcula()) {
scrollPaneWrap.setBorder(new EmptyBorder(3, 0, 0, 0));
} else {
scrollPaneWrap.setBorder(new LineBorder(UIUtil.getBorderColor()));
}
rightPanel.add(scrollPaneWrap, BorderLayout.CENTER);
if (UIUtil.isUnderDarcula()) {
rightPanel.setBorder(new CompoundBorder(new CustomLineBorder(0, 1, 0, 0), BorderFactory.createEmptyBorder(0, 0, 0, 0)));
} else {
rightPanel.setBorder(BorderFactory.createEmptyBorder(3, 0, 3, 3));
}
splitter.setSecondComponent(rightPanel);
splitter.getDivider().setBackground(UIUtil.getPanelBackground());
treePanel.setBorder(JBUI.Borders.empty());
rightPanel.setBorder(JBUI.Borders.empty());
scrollPaneWrap.setBorder(JBUI.Borders.empty());
leftPanel.setBorder(JBUI.Borders.empty());
myShowContentCheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final ThreeStateCheckBox.State state = myShowContentCheckBox.getState();
if (state == ThreeStateCheckBox.State.SELECTED) {
mySubstitutionParameters.setSubstituteAll();
} else if (state == ThreeStateCheckBox.State.NOT_SELECTED) {
mySubstitutionParameters.setSubstituteNone();
}
myShowContentCheckBox.setThirdStateEnabled(false);
myLayoutTreeComponent.rebuildTree();
onShowContentSettingsChanged();
}
});
ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, createToolbarActionGroup(), true);
JComponent toolbarComponent = toolbar.getComponent();
if (UIUtil.isUnderDarcula()) {
toolbarComponent.setBorder(new CustomLineBorder(0, 0, 1, 0));
}
leftPanel.add(toolbarComponent, BorderLayout.NORTH);
toolbar.updateActionsImmediately();
rightTopPanel.setPreferredSize(new Dimension(-1, toolbarComponent.getPreferredSize().height));
myTabbedPane = new TabbedPaneWrapper(this);
myTabbedPane.addTab("Output Layout", splitter);
myPropertiesEditors.addTabs(myTabbedPane);
myEditorPanel.add(myTabbedPane.getComponent(), BorderLayout.CENTER);
final LayoutTree tree = myLayoutTreeComponent.getLayoutTree();
new ShowAddPackagingElementPopupAction(this).registerCustomShortcutSet(CommonShortcuts.getNew(), tree);
PopupHandler.installPopupHandler(tree, createPopupActionGroup(), ActionPlaces.UNKNOWN, ActionManager.getInstance());
ToolTipManager.sharedInstance().registerComponent(tree);
rebuildTries();
return getMainComponent();
}
use of javax.swing.event.HyperlinkEvent in project intellij-community by JetBrains.
the class IntentionDescriptionPanel method setupPoweredByPanel.
private void setupPoweredByPanel(final IntentionActionMetaData actionMetaData) {
PluginId pluginId = actionMetaData == null ? null : actionMetaData.getPluginId();
JComponent owner;
if (pluginId == null) {
@NonNls String label = XmlStringUtil.wrapInHtml("<b>" + ApplicationNamesInfo.getInstance().getFullProductName() + "</b>");
owner = new JLabel(label);
} else {
final IdeaPluginDescriptor pluginDescriptor = PluginManager.getPlugin(pluginId);
HyperlinkLabel label = new HyperlinkLabel(CodeInsightBundle.message("powered.by.plugin", pluginDescriptor.getName()));
label.addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
final ShowSettingsUtil util = ShowSettingsUtil.getInstance();
final PluginManagerConfigurable pluginConfigurable = new PluginManagerConfigurable(PluginManagerUISettings.getInstance());
final Project project = ProjectManager.getInstance().getDefaultProject();
util.editConfigurable(project, pluginConfigurable, () -> pluginConfigurable.select(pluginDescriptor));
}
});
owner = label;
}
//myPoweredByContainer.setVisible(true);
myPoweredByPanel.removeAll();
myPoweredByPanel.add(owner, BorderLayout.CENTER);
}
use of javax.swing.event.HyperlinkEvent in project intellij-community by JetBrains.
the class EventLog method formatForLog.
public static LogEntry formatForLog(@NotNull final Notification notification, final String indent) {
DocumentImpl logDoc = new DocumentImpl("", true);
AtomicBoolean showMore = new AtomicBoolean(false);
Map<RangeMarker, HyperlinkInfo> links = new LinkedHashMap<>();
List<RangeMarker> lineSeparators = new ArrayList<>();
String title = notification.getTitle();
String subtitle = notification.getSubtitle();
if (StringUtil.isNotEmpty(title) && StringUtil.isNotEmpty(subtitle)) {
title += " (" + subtitle + ")";
}
title = truncateLongString(showMore, title);
String content = truncateLongString(showMore, notification.getContent());
RangeMarker afterTitle = null;
boolean hasHtml = parseHtmlContent(addIndents(title, indent), notification, logDoc, showMore, links, lineSeparators);
if (StringUtil.isNotEmpty(title)) {
if (StringUtil.isNotEmpty(content)) {
appendText(logDoc, ": ");
afterTitle = logDoc.createRangeMarker(logDoc.getTextLength() - 2, logDoc.getTextLength());
}
}
int titleLength = logDoc.getTextLength();
hasHtml |= parseHtmlContent(addIndents(content, indent), notification, logDoc, showMore, links, lineSeparators);
List<AnAction> actions = notification.getActions();
if (!actions.isEmpty()) {
String text = "<p>" + StringUtil.join(actions, new Function<AnAction, String>() {
private int index;
@Override
public String fun(AnAction action) {
return "<a href=\"" + index++ + "\">" + action.getTemplatePresentation().getText() + "</a>";
}
}, isLongLine(actions) ? "<br>" : " ") + "</p>";
Notification n = new Notification("", "", ".", NotificationType.INFORMATION, new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification n, @NotNull HyperlinkEvent event) {
Notification.fire(notification, notification.getActions().get(Integer.parseInt(event.getDescription())));
}
});
if (title.length() > 0 || content.length() > 0) {
lineSeparators.add(logDoc.createRangeMarker(TextRange.from(logDoc.getTextLength(), 0)));
}
hasHtml |= parseHtmlContent(text, n, logDoc, showMore, links, lineSeparators);
}
String status = getStatusText(logDoc, showMore, lineSeparators, indent, hasHtml);
indentNewLines(logDoc, lineSeparators, afterTitle, hasHtml, indent);
ArrayList<Pair<TextRange, HyperlinkInfo>> list = new ArrayList<>();
for (RangeMarker marker : links.keySet()) {
if (!marker.isValid()) {
showMore.set(true);
continue;
}
list.add(Pair.create(new TextRange(marker.getStartOffset(), marker.getEndOffset()), links.get(marker)));
}
if (showMore.get()) {
String sb = "show balloon";
if (!logDoc.getText().endsWith(" ")) {
appendText(logDoc, " ");
}
appendText(logDoc, "(" + sb + ")");
list.add(new Pair<>(TextRange.from(logDoc.getTextLength() - 1 - sb.length(), sb.length()), new ShowBalloon(notification)));
}
return new LogEntry(logDoc.getText(), status, list, titleLength);
}
use of javax.swing.event.HyperlinkEvent in project intellij-community by JetBrains.
the class ProjectLoadingErrorsNotifierImpl method fireNotifications.
private void fireNotifications() {
final MultiMap<ConfigurationErrorType, ConfigurationErrorDescription> descriptionsMap = new MultiMap<>();
synchronized (myLock) {
if (myErrors.isEmpty())
return;
descriptionsMap.putAllValues(myErrors);
myErrors.clear();
}
for (final ConfigurationErrorType type : descriptionsMap.keySet()) {
final Collection<ConfigurationErrorDescription> descriptions = descriptionsMap.get(type);
if (descriptions.isEmpty())
continue;
final String invalidElements = getInvalidElementsString(type, descriptions);
final String errorText = ProjectBundle.message("error.message.configuration.cannot.load") + " " + invalidElements + " <a href=\"\">Details...</a>";
Notifications.Bus.notify(new Notification("Project Loading Error", "Error Loading Project", errorText, NotificationType.ERROR, new NotificationListener() {
@Override
public void hyperlinkUpdate(@NotNull Notification notification, @NotNull HyperlinkEvent event) {
final List<ConfigurationErrorDescription> validDescriptions = ContainerUtil.findAll(descriptions, errorDescription -> errorDescription.isValid());
if (RemoveInvalidElementsDialog.showDialog(myProject, CommonBundle.getErrorTitle(), type, invalidElements, validDescriptions)) {
notification.expire();
}
}
}), myProject);
}
}
Aggregations