diff --git a/platform/platform-api/src/com/intellij/ui/OrderPanel.java b/platform/platform-api/src/com/intellij/ui/OrderPanel.java index 76883cd2fd02..f8107af50aac 100644 --- a/platform/platform-api/src/com/intellij/ui/OrderPanel.java +++ b/platform/platform-api/src/com/intellij/ui/OrderPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 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,8 @@ */ package com.intellij.ui; -import com.intellij.util.ui.Table; +import com.intellij.openapi.util.text.StringUtil; +import com.intellij.ui.table.JBTable; import javax.swing.*; import javax.swing.table.DefaultTableModel; @@ -26,6 +27,7 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.util.ArrayList; +import java.util.List; public abstract class OrderPanel extends JPanel{ private String CHECKBOX_COLUMN_NAME; @@ -33,7 +35,7 @@ public abstract class OrderPanel extends JPanel{ private final Class myEntryClass; private final JTable myEntryTable; - private final java.util.List myListeners = new ArrayList(); + private final List myListeners = new ArrayList(); private boolean myEntryEditable = false; @@ -41,12 +43,12 @@ public abstract class OrderPanel extends JPanel{ this(entryClass, true); } - protected OrderPanel(Class entryClass, boolean showSheckboxes) { + protected OrderPanel(Class entryClass, boolean showCheckboxes) { super(new BorderLayout()); myEntryClass = entryClass; - myEntryTable = new Table(new MyTableModel(showSheckboxes)); + myEntryTable = new JBTable(new MyTableModel(showCheckboxes)); myEntryTable.setShowGrid(false); myEntryTable.setDragEnabled(false); myEntryTable.setShowHorizontalLines(false); @@ -89,11 +91,11 @@ public abstract class OrderPanel extends JPanel{ myEntryEditable = entryEditable; } - public void setCheckboxColumnName(String name) { + public void setCheckboxColumnName(final String name) { final int width; - if(name == null) { - width = 0; + if (StringUtil.isEmpty(name)) { CHECKBOX_COLUMN_NAME = ""; + width = new JCheckBox().getPreferredSize().width; } else { CHECKBOX_COLUMN_NAME = name; @@ -101,7 +103,7 @@ public abstract class OrderPanel extends JPanel{ width = fontMetrics.stringWidth(" " + name + " ") + 4; } - final TableColumn checkboxColumn = myEntryTable.getTableHeader().getColumnModel().getColumn(getCheckboxColumn()); + final TableColumn checkboxColumn = myEntryTable.getColumnModel().getColumn(getCheckboxColumn()); checkboxColumn.setWidth(width); checkboxColumn.setPreferredWidth(width); checkboxColumn.setMaxWidth(width); @@ -192,6 +194,7 @@ public abstract class OrderPanel extends JPanel{ private class MyTableModel extends DefaultTableModel { private final boolean myShowCheckboxes; + public MyTableModel(boolean showCheckboxes) { myShowCheckboxes = showCheckboxes; } @@ -244,7 +247,8 @@ public abstract class OrderPanel extends JPanel{ } public T getValueAt(int row) { - return (T)((MyTableModel)myEntryTable.getModel()).getValueAt(row, getEntryColumn()); + //noinspection unchecked + return (T)myEntryTable.getModel().getValueAt(row, getEntryColumn()); } public abstract boolean isCheckable(T entry); @@ -258,16 +262,14 @@ public abstract class OrderPanel extends JPanel{ return CHECKBOX_COLUMN_NAME; } - public java.util.List getEntries() { + public List getEntries() { final TableModel model = myEntryTable.getModel(); final int size = model.getRowCount(); - java.util.List result = new ArrayList(size); + List result = new ArrayList(size); for (int idx = 0; idx < size; idx++) { result.add(getValueAt(idx)); } return result; } - - } diff --git a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/DetectedPluginsPanel.java b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/DetectedPluginsPanel.java index fae9d89b8570..77bbdce5b179 100644 --- a/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/DetectedPluginsPanel.java +++ b/platform/platform-impl/src/com/intellij/openapi/updateSettings/impl/DetectedPluginsPanel.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 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. @@ -13,11 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - -/* - * User: anna - * Date: 04-Dec-2007 - */ package com.intellij.openapi.updateSettings.impl; import com.intellij.ide.plugins.IdeaPluginDescriptor; @@ -30,6 +25,10 @@ import com.intellij.ui.SimpleTextAttributes; import javax.swing.*; import java.util.ArrayList; +/** + * @author anna + * Date: 04-Dec-2007 + */ public class DetectedPluginsPanel extends OrderPanel { private final ArrayList myListeners = new ArrayList(); private static final String AVAILABLE_VERSION = "available version: "; @@ -37,14 +36,25 @@ public class DetectedPluginsPanel extends OrderPanel { protected DetectedPluginsPanel() { super(PluginDownloader.class); - getEntryTable().setDefaultRenderer(PluginDownloader.class, new ColoredTableCellRenderer(){ - protected void customizeCellRenderer(final JTable table, final Object value, final boolean selected, final boolean hasFocus, final int row, final int column) { + final JTable entryTable = getEntryTable(); + entryTable.setTableHeader(null); + entryTable.setDefaultRenderer(PluginDownloader.class, new ColoredTableCellRenderer() { + protected void customizeCellRenderer(final JTable table, + final Object value, + final boolean selected, + final boolean hasFocus, + final int row, + final int column) { final PluginDownloader downloader = (PluginDownloader)value; append(downloader.getPluginName(), SimpleTextAttributes.REGULAR_ATTRIBUTES); final IdeaPluginDescriptor ideaPluginDescriptor = PluginManager.getPlugin(PluginId.getId(downloader.getPluginId())); final String loadedVersion = downloader.getPluginVersion(); if (loadedVersion != null || (ideaPluginDescriptor != null && ideaPluginDescriptor.getVersion() != null)) { - append(" (" + (ideaPluginDescriptor != null && ideaPluginDescriptor.getVersion() != null ? INSTALLED_VERSION + ideaPluginDescriptor.getVersion() + (loadedVersion != null ? ", " : "") :"") + (loadedVersion != null ? AVAILABLE_VERSION + loadedVersion : "") + ")", SimpleTextAttributes.GRAY_ATTRIBUTES); + final String installedVersion = ideaPluginDescriptor != null && ideaPluginDescriptor.getVersion() != null + ? INSTALLED_VERSION + ideaPluginDescriptor.getVersion() + (loadedVersion != null ? ", " : "") + : ""; + final String availableVersion = loadedVersion != null ? AVAILABLE_VERSION + loadedVersion : ""; + append(" (" + installedVersion + availableVersion + ")", SimpleTextAttributes.GRAY_ATTRIBUTES); } } }); @@ -78,8 +88,7 @@ public class DetectedPluginsPanel extends OrderPanel { myListeners.add(l); } - public static interface Listener { + public interface Listener { void stateChanged(); } - } \ No newline at end of file