diff options
Diffstat (limited to 'platform/lang-impl/src/com/intellij/webcore')
-rw-r--r-- | platform/lang-impl/src/com/intellij/webcore/packaging/ManagePackagesDialog.java | 18 | ||||
-rw-r--r-- | platform/lang-impl/src/com/intellij/webcore/packaging/PackagesNotificationPanel.java | 58 |
2 files changed, 49 insertions, 27 deletions
diff --git a/platform/lang-impl/src/com/intellij/webcore/packaging/ManagePackagesDialog.java b/platform/lang-impl/src/com/intellij/webcore/packaging/ManagePackagesDialog.java index 18961ca843c3..fcbaa21f330b 100644 --- a/platform/lang-impl/src/com/intellij/webcore/packaging/ManagePackagesDialog.java +++ b/platform/lang-impl/src/com/intellij/webcore/packaging/ManagePackagesDialog.java @@ -1,3 +1,18 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.intellij.webcore.packaging; import com.intellij.icons.AllIcons; @@ -93,6 +108,7 @@ public class ManagePackagesDialog extends DialogWrapper { public void run() { try { myController.reloadAllPackages(); + initModel(); myPackages.setPaintBusy(false); } catch (final IOException e) { @@ -310,6 +326,7 @@ public class ManagePackagesDialog extends DialogWrapper { @Override public void run() { myPackages.setModel(myPackagesModel); + ((MyPackageFilter)myFilter).filter(); doSelectPackage(mySelectedPackageName); setDownloadStatus(false); } @@ -473,6 +490,7 @@ public class ManagePackagesDialog extends DialogWrapper { final Object pyPackage = myPackages.getSelectedValue(); if (pyPackage instanceof RepoPackage) { final String packageName = ((RepoPackage)pyPackage).getName(); + mySelectedPackageName = packageName; myVersionComboBox.removeAllItems(); if (myVersionCheckBox.isEnabled()) { myController.fetchPackageVersions(packageName, new CatchingConsumer<List<String>, Exception>() { diff --git a/platform/lang-impl/src/com/intellij/webcore/packaging/PackagesNotificationPanel.java b/platform/lang-impl/src/com/intellij/webcore/packaging/PackagesNotificationPanel.java index cb281cb3d7af..1513bb451aa2 100644 --- a/platform/lang-impl/src/com/intellij/webcore/packaging/PackagesNotificationPanel.java +++ b/platform/lang-impl/src/com/intellij/webcore/packaging/PackagesNotificationPanel.java @@ -8,6 +8,7 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.ui.HyperlinkAdapter; import com.intellij.ui.ScrollPaneFactory; import com.intellij.ui.components.JBLabel; +import com.intellij.util.ui.SwingHelper; import com.intellij.util.ui.UIUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -22,18 +23,17 @@ import java.util.Map; * @author yole */ public class PackagesNotificationPanel { - private final JEditorPane myEditorPane = new MyNotificationPane(); private final Project myProject; + private final JEditorPane myHtmlViewer; private final Map<String, Runnable> myLinkHandlers = new HashMap<String, Runnable>(); private String myErrorTitle; private String myErrorDescription; - public PackagesNotificationPanel(Project project) { + public PackagesNotificationPanel(@NotNull Project project) { myProject = project; - myEditorPane.setBackground(UIManager.getColor("ArrowButton.background")); - myEditorPane.setContentType("text/html"); - myEditorPane.setEditable(false); - myEditorPane.addHyperlinkListener(new HyperlinkAdapter() { + myHtmlViewer = SwingHelper.createHtmlViewer(true, null, null, null); + myHtmlViewer.setVisible(false); + myHtmlViewer.addHyperlinkListener(new HyperlinkAdapter() { @Override protected void hyperlinkActivated(HyperlinkEvent e) { final Runnable handler = myLinkHandlers.get(e.getDescription()); @@ -76,11 +76,18 @@ public class PackagesNotificationPanel { public void showResult(String packageName, @Nullable String errorDescription) { if (StringUtil.isEmpty(errorDescription)) { - showSuccess("Package successfully installed."); + String message = "Package installed successfully"; + if (packageName != null) { + message = "Package '" + packageName + "' installed successfully"; + } + showSuccess(message); } else { - String title = "Install packages failed"; - final String firstLine = title + ": Error occurred when installing package " + packageName + ". "; + String title = "Failed to install packages"; + if (packageName != null) { + title = "Failed to install package '" + packageName + "'"; + } + String firstLine = "Error occurred when installing package '" + packageName + "'. "; showError(firstLine + "<a href=\"xxx\">Details...</a>", title, firstLine + errorDescription); @@ -96,19 +103,18 @@ public class PackagesNotificationPanel { } public JComponent getComponent() { - return myEditorPane; + return myHtmlViewer; } public void showSuccess(String text) { showContent(text, MessageType.INFO.getPopupBackground()); } - private void showContent(String text, final Color background) { - myEditorPane.removeAll(); + private void showContent(@NotNull String text, @NotNull Color background) { String htmlText = text.startsWith("<html>") ? text : UIUtil.toHtml(text); - myEditorPane.setText(htmlText); - myEditorPane.setBackground(background); - myEditorPane.setVisible(true); + myHtmlViewer.setText(htmlText); + myHtmlViewer.setBackground(background); + setVisibleEditorPane(true); myErrorTitle = null; myErrorDescription = null; } @@ -124,22 +130,20 @@ public class PackagesNotificationPanel { } public void hide() { - myEditorPane.setVisible(false); + setVisibleEditorPane(false); } - public boolean hasLinkHandler(String key) { - return myLinkHandlers.containsKey(key); + private void setVisibleEditorPane(boolean visible) { + boolean oldVisible = myHtmlViewer.isVisible(); + myHtmlViewer.setVisible(visible); + if (oldVisible != visible) { + myHtmlViewer.revalidate(); + myHtmlViewer.repaint(); + } } - private static class MyNotificationPane extends JEditorPane { - @Override - public Dimension getPreferredSize() { - // This trick makes text component to carry text over to the next line - // iff the text line width exceeds parent's width - Dimension dimension = super.getPreferredSize(); - dimension.width = 0; - return dimension; - } + public boolean hasLinkHandler(String key) { + return myLinkHandlers.containsKey(key); } public void removeLinkHandler(String key) { |