diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/PluginHeaderPanel.java b/platform/platform-impl/src/com/intellij/ide/plugins/PluginHeaderPanel.java index 829b6b7817a2..4418a89fd750 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/PluginHeaderPanel.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/PluginHeaderPanel.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 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. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ide.plugins; import com.intellij.icons.AllIcons; @@ -34,8 +20,7 @@ import org.jetbrains.annotations.Nullable; import javax.swing.*; import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; +import java.util.Locale; /** * @author Konstantin Bulenkov @@ -91,7 +76,7 @@ public class PluginHeaderPanel { //data myName.setText("" + plugin.getName() + ""); - myCategory.setText(plugin.getCategory() == null ? "UNKNOWN" : plugin.getCategory().toUpperCase()); + myCategory.setText(plugin.getCategory() == null ? "UNKNOWN" : plugin.getCategory().toUpperCase(Locale.US)); final boolean hasNewerVersion = ourState.hasNewerVersion(plugin.getPluginId()); if (plugin instanceof PluginNode) { final PluginNode node = (PluginNode)plugin; @@ -141,9 +126,11 @@ public class PluginHeaderPanel { else if (!plugin.isBundled() || hasNewerVersion) { if (((IdeaPluginDescriptorImpl)plugin).isDeleted()) { myActionId = ACTION_ID.RESTART; - } else if (hasNewerVersion) { + } + else if (hasNewerVersion) { myActionId = ACTION_ID.UPDATE; - } else { + } + else { myActionId = ACTION_ID.UNINSTALL; } } @@ -160,9 +147,9 @@ public class PluginHeaderPanel { UIUtil.setEnabled(myButtonPanel, false, true); } myRoot.revalidate(); - ((JComponent)myInstallButton.getParent()).revalidate(); + myInstallButton.getParent().revalidate(); myInstallButton.revalidate(); - ((JComponent)myVersion.getParent()).revalidate(); + myVersion.getParent().revalidate(); myVersion.revalidate(); } @@ -177,23 +164,19 @@ public class PluginHeaderPanel { case RESTART: case UNINSTALL: return new JBColor(Gray._0, Gray._210); } - return new JBColor(Gray._80, Gray._60); } @NotNull protected Paint getBackgroundPaint() { switch (myActionId) { - case UPDATE: return new JBGradientPaint(this, - new JBColor(0x629ee1, 0x629ee1), - new JBColor(0x3a5bb5, 0x3a5bb5)); - case INSTALL: return new JBGradientPaint(this, - new JBColor(0x60cc69, 0x519557), - new JBColor(0x326529, 0x28462f)); + case UPDATE: return new JBGradientPaint(this, new JBColor(0x629ee1, 0x629ee1), new JBColor(0x3a5bb5, 0x3a5bb5)); + case INSTALL: return new JBGradientPaint(this, new JBColor(0x60cc69, 0x519557), new JBColor(0x326529, 0x28462f)); case RESTART: - case UNINSTALL: return UIUtil.isUnderDarcula() - ? new JBGradientPaint(this, UIManager.getColor("Button.darcula.startColor"), UIManager.getColor("Button.darcula.endColor")) - : Gray._240; + case UNINSTALL: + return UIUtil.isUnderDarcula() + ? new JBGradientPaint(this, UIManager.getColor("Button.darcula.startColor"), UIManager.getColor("Button.darcula.endColor")) + : Gray._240; } return Gray._238; } @@ -230,41 +213,38 @@ public class PluginHeaderPanel { case RESTART: return AllIcons.Actions.Restart; } return super.getIcon(); - } }; - myInstallButton.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - switch (myActionId) { - case UPDATE: - case INSTALL: - Runnable setPlugin = () -> setPlugin(myPlugin); - new InstallPluginAction(myManager.getAvailable(), myManager.getInstalled()).install(setPlugin, setPlugin, true); - break; - case UNINSTALL: - UninstallPluginAction.uninstall(myManager.getInstalled(), true, myPlugin); - break; - case RESTART: - if (myManager != null) { - myManager.apply(); + + myInstallButton.addActionListener(e -> { + switch (myActionId) { + case UPDATE: + case INSTALL: + Runnable setPlugin = () -> setPlugin(myPlugin); + new InstallPluginAction(myManager.getAvailable(), myManager.getInstalled()).install(setPlugin, setPlugin, true); + break; + case UNINSTALL: + UninstallPluginAction.uninstall(myManager.getInstalled(), true, myPlugin); + break; + case RESTART: + if (myManager != null) { + myManager.apply(); + } + final DialogWrapper dialog = + DialogWrapper.findInstance(KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()); + if (dialog != null && dialog.isModal()) { + dialog.close(DialogWrapper.OK_EXIT_CODE); + } + IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> { + DialogWrapper settings = DialogWrapper.findInstance(IdeFocusManager.findInstance().getFocusOwner()); + if (settings instanceof SettingsDialog) { + ((SettingsDialog)settings).doOKAction(); } - final DialogWrapper dialog = - DialogWrapper.findInstance(KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner()); - if (dialog != null && dialog.isModal()) { - dialog.close(DialogWrapper.OK_EXIT_CODE); - } - IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(() -> { - DialogWrapper settings = DialogWrapper.findInstance(IdeFocusManager.findInstance().getFocusOwner()); - if (settings instanceof SettingsDialog) { - ((SettingsDialog)settings).doOKAction(); - } - ApplicationManager.getApplication().restart(); - }, ModalityState.current()); - break; - } - setPlugin(myPlugin); + ApplicationManager.getApplication().restart(); + }, ModalityState.current()); + break; } + setPlugin(myPlugin); }); } @@ -295,4 +275,4 @@ public class PluginHeaderPanel { public JPanel getPanel() { return myRoot; } -} +} \ No newline at end of file diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerColumnInfo.java b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerColumnInfo.java index 377acbf9356c..e53aab645d04 100644 --- a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerColumnInfo.java +++ b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManagerColumnInfo.java @@ -1,24 +1,11 @@ -/* - * Copyright 2000-2017 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. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.ide.plugins; import com.intellij.ide.IdeBundle; import com.intellij.openapi.extensions.PluginId; import com.intellij.openapi.util.Comparing; import com.intellij.openapi.util.text.StringUtil; +import com.intellij.ui.JBColor; import com.intellij.ui.LightColors; import com.intellij.util.text.DateFormatUtil; import com.intellij.util.ui.ColumnInfo; @@ -119,6 +106,7 @@ public class PluginManagerColumnInfo extends ColumnInfo getComparator() { final Comparator comparator = getColumnComparator(); if (isSortByStatus()) { @@ -208,68 +196,68 @@ public class PluginManagerColumnInfo extends ColumnInfo tags = ContainerUtil.newArrayList(category.toLowerCase()); + List tags = ContainerUtil.newArrayList(category.toLowerCase(Locale.US)); if (plugin.getName().length() < 10) { tags.add("languages"); } @@ -605,20 +605,17 @@ public class PluginManagerConfigurableNew extends BaseConfigurable @Nullable private static String getDownloads(@NotNull IdeaPluginDescriptor plugin) { String downloads = plugin.getDownloads(); - if (StringUtil.isEmptyOrSpaces(downloads)) { - return null; - } - - try { - Long value = Long.valueOf(downloads); - if (value > 1000) { - return value < 1000000 ? K_FORMAT.format(value / 1000D) : M_FORMAT.format(value / 1000000D); + if (!StringUtil.isEmptyOrSpaces(downloads)) { + try { + Long value = Long.valueOf(downloads); + if (value > 1000) { + return value < 1000000 ? K_FORMAT.format(value / 1000D) : M_FORMAT.format(value / 1000000D); + } } - } - catch (NumberFormatException ignore) { + catch (NumberFormatException ignore) { } } - return downloads; + return null; } @Nullable @@ -633,15 +630,12 @@ public class PluginManagerConfigurableNew extends BaseConfigurable if (rating != null) { try { if (Double.valueOf(rating) > 0) { - if (rating.endsWith(".0")) { - return rating.substring(0, rating.length() - 2); - } - return rating; + return StringUtil.trimEnd(rating, ".0"); } } - catch (NumberFormatException ignore) { - } + catch (NumberFormatException ignore) { } } + return null; }