tune commit dialog to show global messages

This commit is contained in:
Konstantin Bulenkov
2014-03-14 15:23:33 +01:00
parent 105781fff4
commit d00772e6b6
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,7 +15,10 @@
*/
package com.intellij.openapi.vcs.changes.ui;
import com.intellij.icons.AllIcons;
import com.intellij.ide.BrowserUtil;
import com.intellij.ide.util.PropertiesComponent;
import com.intellij.notification.impl.ui.NotificationsUtil;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.DataKey;
@@ -23,6 +26,7 @@ import com.intellij.openapi.actionSystem.DataSink;
import com.intellij.openapi.actionSystem.TypeSafeDataProvider;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.ModalityState;
import com.intellij.openapi.application.ex.ApplicationManagerEx;
import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.fileEditor.FileDocumentManager;
import com.intellij.openapi.progress.ProgressManager;
@@ -35,23 +39,31 @@ import com.intellij.openapi.vcs.changes.*;
import com.intellij.openapi.vcs.changes.actions.DiffExtendUIFactory;
import com.intellij.openapi.vcs.checkin.*;
import com.intellij.openapi.vcs.impl.CheckinHandlersManager;
import com.intellij.openapi.vcs.impl.VcsGlobalMessage;
import com.intellij.openapi.vcs.impl.VcsGlobalMessageManager;
import com.intellij.openapi.vcs.ui.CommitMessage;
import com.intellij.openapi.vcs.ui.Refreshable;
import com.intellij.openapi.vcs.ui.RefreshableOnComponent;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.wm.IdeFocusManager;
import com.intellij.ui.IdeBorderFactory;
import com.intellij.ui.ScrollPaneFactory;
import com.intellij.ui.SplitterWithSecondHideable;
import com.intellij.ui.components.panels.NonOpaquePanel;
import com.intellij.util.Alarm;
import com.intellij.util.Consumer;
import com.intellij.util.OnOffListener;
import com.intellij.util.containers.ContainerUtilRt;
import com.intellij.util.ui.UIUtil;
import gnu.trove.THashSet;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.io.File;
@@ -988,6 +1000,54 @@ public class CommitChangeListDialog extends DialogWrapper implements CheckinProj
}
}
@Nullable
@Override
protected JComponent createNorthPanel() {
if (ApplicationManagerEx.getApplicationEx().isInternal()) {
final VcsGlobalMessage message = VcsGlobalMessageManager.getInstance(myProject).getState();
if (message != null && !StringUtil.isEmpty(message.message)) {
final JEditorPane text = new JEditorPane();
text.setEditorKit(UIUtil.getHTMLEditorKit());
text.addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
if (HyperlinkEvent.EventType.ACTIVATED == e.getEventType()) BrowserUtil.browse(e.getURL());
}
});
final JLabel label = new JLabel(NotificationsUtil.buildHtml("", message.message, null));
text.setText(NotificationsUtil.buildHtml("", message.message, "width:" + Math.min(400, label.getPreferredSize().width) + "px;"));
text.setEditable(false);
text.setOpaque(false);
text.setBorder(null);
final JPanel content =
new JPanel(new BorderLayout((int)(label.getIconTextGap() * 1.5), (int)(label.getIconTextGap() * 1.5)));
text.setCaretPosition(0);
JScrollPane pane = ScrollPaneFactory.createScrollPane(text,
ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
pane.setBorder(null);
pane.setOpaque(false);
pane.getViewport().setOpaque(false);
content.add(pane, BorderLayout.CENTER);
final NonOpaquePanel north = new NonOpaquePanel(new BorderLayout());
north.add(new JLabel(AllIcons.General.BalloonWarning), BorderLayout.NORTH);
content.add(north, BorderLayout.WEST);
content.setBorder(new EmptyBorder(8, 4, 8, 4));
content.setBackground(MessageType.WARNING.getPopupBackground());
return content;
}
}
return super.createNorthPanel();
}
@Override
@Nullable
protected JComponent createCenterPanel() {