mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Cleanup (warnings; formatting)
This commit is contained in:
@@ -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("<html><body>" + plugin.getName() + "</body></html>");
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<IdeaPluginDescriptor, St
|
||||
return ourState.wasInstalled(pluginId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Comparator<IdeaPluginDescriptor> getComparator() {
|
||||
final Comparator<IdeaPluginDescriptor> comparator = getColumnComparator();
|
||||
if (isSortByStatus()) {
|
||||
@@ -208,68 +196,68 @@ public class PluginManagerColumnInfo extends ColumnInfo<IdeaPluginDescriptor, St
|
||||
return size;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getColumnClass() {
|
||||
if (columnIdx == COLUMN_DOWNLOADS) {
|
||||
return Integer.class;
|
||||
}
|
||||
else {
|
||||
return String.class;
|
||||
}
|
||||
return columnIdx == COLUMN_DOWNLOADS ? Integer.class : String.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableCellRenderer getRenderer(IdeaPluginDescriptor o) {
|
||||
if (columnIdx == COLUMN_RATE) {
|
||||
return new DefaultTableCellRenderer(){
|
||||
private final RatesPanel myPanel = new RatesPanel();
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
final Component orig = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
myPanel.setBackground(orig.getBackground());
|
||||
if (value != null) {
|
||||
myPanel.setRate((String)value);
|
||||
}
|
||||
return myPanel;
|
||||
}
|
||||
};
|
||||
return columnIdx == COLUMN_RATE ? new PluginRateTableCellRenderer() : new PluginTableCellRenderer((PluginNode)o);
|
||||
}
|
||||
|
||||
private static class PluginRateTableCellRenderer extends DefaultTableCellRenderer {
|
||||
private final RatesPanel myPanel = new RatesPanel();
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
Component orig = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
myPanel.setBackground(orig.getBackground());
|
||||
if (value != null) {
|
||||
myPanel.setRate((String)value);
|
||||
}
|
||||
return myPanel;
|
||||
}
|
||||
return new PluginTableCellRenderer((PluginNode)o);
|
||||
}
|
||||
|
||||
private static class PluginTableCellRenderer extends DefaultTableCellRenderer {
|
||||
private final JLabel myLabel = new JLabel();
|
||||
private final PluginNode myPluginDescriptor;
|
||||
private final PluginNode myPluginNode;
|
||||
|
||||
private PluginTableCellRenderer(PluginNode pluginDescriptor) {
|
||||
private PluginTableCellRenderer(PluginNode pluginNode) {
|
||||
myLabel.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL));
|
||||
myLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 2));
|
||||
myPluginDescriptor = pluginDescriptor;
|
||||
myPluginNode = pluginNode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
Component orig = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
|
||||
final Color bg = orig.getBackground();
|
||||
final Color grayedFg = isSelected ? orig.getForeground() : Color.GRAY;
|
||||
Color bg = orig.getBackground();
|
||||
Color grayedFg = isSelected ? orig.getForeground() : JBColor.GRAY;
|
||||
myLabel.setForeground(grayedFg);
|
||||
myLabel.setBackground(bg);
|
||||
myLabel.setOpaque(true);
|
||||
|
||||
if (column == COLUMN_DATE) {
|
||||
long date = myPluginDescriptor.getDate();
|
||||
long date = myPluginNode.getDate();
|
||||
myLabel.setText(date != 0 && date != Long.MAX_VALUE ? DateFormatUtil.formatDate(date) : "n/a");
|
||||
myLabel.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||
} else if (column == COLUMN_DOWNLOADS) {
|
||||
String downloads = myPluginDescriptor.getDownloads();
|
||||
}
|
||||
else if (column == COLUMN_DOWNLOADS) {
|
||||
String downloads = myPluginNode.getDownloads();
|
||||
myLabel.setText(!StringUtil.isEmpty(downloads) ? downloads : "n/a");
|
||||
myLabel.setHorizontalAlignment(SwingConstants.RIGHT);
|
||||
} else if (column == COLUMN_CATEGORY) {
|
||||
String category = myPluginDescriptor.getCategory();
|
||||
}
|
||||
else if (column == COLUMN_CATEGORY) {
|
||||
String category = myPluginNode.getCategory();
|
||||
if (StringUtil.isEmpty(category)) {
|
||||
category = myPluginDescriptor.getRepositoryName();
|
||||
category = myPluginNode.getRepositoryName();
|
||||
}
|
||||
myLabel.setText(!StringUtil.isEmpty(category) ? category : "n/a");
|
||||
}
|
||||
if (myPluginDescriptor.getStatus() == PluginNode.STATUS_INSTALLED) {
|
||||
PluginId pluginId = myPluginDescriptor.getPluginId();
|
||||
if (myPluginNode.getStatus() == PluginNode.STATUS_INSTALLED) {
|
||||
PluginId pluginId = myPluginNode.getPluginId();
|
||||
final boolean hasNewerVersion = ourState.hasNewerVersion(pluginId);
|
||||
if (hasNewerVersion) {
|
||||
if (!isSelected) myLabel.setBackground(LightColors.BLUE);
|
||||
@@ -278,4 +266,4 @@ public class PluginManagerColumnInfo extends ColumnInfo<IdeaPluginDescriptor, St
|
||||
return myLabel;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
-18
@@ -589,7 +589,7 @@ public class PluginManagerConfigurableNew extends BaseConfigurable
|
||||
if (StringUtil.isEmptyOrSpaces(category)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
ArrayList<String> tags = ContainerUtil.newArrayList(category.toLowerCase());
|
||||
List<String> 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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user