mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-60990 Add an arrow to the Scope dropdown
This commit is contained in:
+10
-1
@@ -39,6 +39,7 @@ import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.ProjectStr
|
||||
import com.intellij.openapi.roots.ui.configuration.projectRoot.daemon.SdkProjectStructureElement;
|
||||
import com.intellij.openapi.roots.ui.util.CellAppearance;
|
||||
import com.intellij.openapi.roots.ui.util.OrderEntryCellAppearanceUtils;
|
||||
import com.intellij.openapi.ui.ComboBoxTableRenderer;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.ui.popup.JBPopupFactory;
|
||||
@@ -89,6 +90,13 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
|
||||
|
||||
JComboBox scopeEditor = new JComboBox(new EnumComboBoxModel<DependencyScope>(DependencyScope.class));
|
||||
myEntryTable.setDefaultEditor(DependencyScope.class, new DefaultCellEditor(scopeEditor));
|
||||
myEntryTable.setDefaultRenderer(DependencyScope.class, new ComboBoxTableRenderer<DependencyScope>(DependencyScope.values()) {
|
||||
@Override
|
||||
protected String getTextFor(@NotNull final DependencyScope value) {
|
||||
return value.getDisplayName();
|
||||
}
|
||||
});
|
||||
|
||||
myEntryTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
|
||||
|
||||
new SpeedSearchBase<Table>(myEntryTable) {
|
||||
@@ -187,7 +195,8 @@ public class ClasspathPanelImpl extends JPanel implements ClasspathPanel {
|
||||
}
|
||||
}
|
||||
};
|
||||
navigateAction.registerCustomShortcutSet(ActionManager.getInstance().getAction(IdeActions.ACTION_EDIT_SOURCE).getShortcutSet(), myEntryTable);
|
||||
navigateAction.registerCustomShortcutSet(ActionManager.getInstance().getAction(IdeActions.ACTION_EDIT_SOURCE).getShortcutSet(),
|
||||
myEntryTable);
|
||||
actionGroup.add(navigateAction);
|
||||
actionGroup.add(new MyFindUsagesAction());
|
||||
PopupHandler.installPopupHandler(myEntryTable, actionGroup, ActionPlaces.UNKNOWN, ActionManager.getInstance());
|
||||
|
||||
@@ -92,11 +92,11 @@ public class ComboBoxTableRenderer<T> extends JLabel implements TableCellRendere
|
||||
final Rectangle r = getBounds();
|
||||
final Insets i = getInsets();
|
||||
|
||||
ARROW_ICON.paintIcon(this, g, r.width - i.right - ARROW_ICON.getIconWidth(), i.top);
|
||||
if (getText() != null && getText().length() != 0) ARROW_ICON.paintIcon(this, g, r.width - i.right - ARROW_ICON.getIconWidth(), i.top);
|
||||
}
|
||||
|
||||
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
|
||||
if (value != null) customizeComponent((T) value, isSelected);
|
||||
customizeComponent((T) value, isSelected);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ public class ComboBoxTableRenderer<T> extends JLabel implements TableCellRendere
|
||||
|
||||
protected void customizeComponent(T value, boolean isSelected) {
|
||||
setOpaque(true);
|
||||
setText(getTextFor(value));
|
||||
setText(value == null ? "" : getTextFor(value));
|
||||
setBackground(isSelected ? UIUtil.getTableSelectionBackground() : UIUtil.getTableBackground());
|
||||
setForeground(isSelected ? UIUtil.getTableSelectionForeground() : UIUtil.getTableForeground());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user