|
|
@ -1,6 +1,9 @@ |
|
|
|
package com.fr.design.gui.controlpane; |
|
|
|
package com.fr.design.gui.controlpane; |
|
|
|
|
|
|
|
|
|
|
|
import com.fine.theme.icon.LazyIcon; |
|
|
|
import com.fine.theme.icon.LazyIcon; |
|
|
|
|
|
|
|
import com.fine.theme.utils.FineUIScale; |
|
|
|
|
|
|
|
import com.formdev.flatlaf.ui.FlatUIUtils; |
|
|
|
|
|
|
|
import com.formdev.flatlaf.util.ScaledEmptyBorder; |
|
|
|
import com.fr.design.actions.UpdateAction; |
|
|
|
import com.fr.design.actions.UpdateAction; |
|
|
|
import com.fr.design.border.FineBorderFactory; |
|
|
|
import com.fr.design.border.FineBorderFactory; |
|
|
|
import com.fr.design.constants.UIConstants; |
|
|
|
import com.fr.design.constants.UIConstants; |
|
|
@ -9,6 +12,7 @@ import com.fr.design.gui.icontainer.UIScrollPane; |
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
import com.fr.design.gui.ilist.ListModelElement; |
|
|
|
import com.fr.design.gui.ilist.ListModelElement; |
|
|
|
import com.fr.design.gui.ilist.UIList; |
|
|
|
import com.fr.design.gui.ilist.UIList; |
|
|
|
|
|
|
|
import com.fr.design.gui.ilist.UINameEdList; |
|
|
|
import com.fr.design.gui.itoolbar.UIToolbar; |
|
|
|
import com.fr.design.gui.itoolbar.UIToolbar; |
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
import com.fr.design.menu.ShortCut; |
|
|
|
import com.fr.design.menu.ShortCut; |
|
|
@ -26,12 +30,14 @@ import javax.swing.JList; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.ListCellRenderer; |
|
|
|
import javax.swing.ListCellRenderer; |
|
|
|
import javax.swing.ListSelectionModel; |
|
|
|
import javax.swing.ListSelectionModel; |
|
|
|
|
|
|
|
import javax.swing.UIManager; |
|
|
|
import javax.swing.border.Border; |
|
|
|
import javax.swing.border.Border; |
|
|
|
import javax.swing.event.ListSelectionEvent; |
|
|
|
import javax.swing.event.ListSelectionEvent; |
|
|
|
import javax.swing.event.ListSelectionListener; |
|
|
|
import javax.swing.event.ListSelectionListener; |
|
|
|
import java.awt.BorderLayout; |
|
|
|
import java.awt.BorderLayout; |
|
|
|
import java.awt.Color; |
|
|
|
import java.awt.Color; |
|
|
|
import java.awt.Component; |
|
|
|
import java.awt.Component; |
|
|
|
|
|
|
|
import java.awt.Dimension; |
|
|
|
import java.awt.Point; |
|
|
|
import java.awt.Point; |
|
|
|
import java.awt.Toolkit; |
|
|
|
import java.awt.Toolkit; |
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
import java.awt.event.ActionEvent; |
|
|
@ -49,7 +55,7 @@ import java.util.Comparator; |
|
|
|
public class UISimpleListControlPane extends BasicPane { |
|
|
|
public class UISimpleListControlPane extends BasicPane { |
|
|
|
public static final String LIST_NAME = "UISimpleControl_List"; |
|
|
|
public static final String LIST_NAME = "UISimpleControl_List"; |
|
|
|
|
|
|
|
|
|
|
|
protected UIList nameList; |
|
|
|
protected UINameEdList nameList; |
|
|
|
protected String selectedName; |
|
|
|
protected String selectedName; |
|
|
|
private ShortCut4JControlPane[] shorts; |
|
|
|
private ShortCut4JControlPane[] shorts; |
|
|
|
private ToolBarDef toolbarDef; |
|
|
|
private ToolBarDef toolbarDef; |
|
|
@ -108,10 +114,8 @@ public class UISimpleListControlPane extends BasicPane { |
|
|
|
protected void initListPane(JPanel listPane) { |
|
|
|
protected void initListPane(JPanel listPane) { |
|
|
|
nameList = createJNameList(); |
|
|
|
nameList = createJNameList(); |
|
|
|
nameList.setName(LIST_NAME); |
|
|
|
nameList.setName(LIST_NAME); |
|
|
|
nameList.setSelectionBackground(UIConstants.ATTRIBUTE_PRESS); |
|
|
|
|
|
|
|
listPane.add(new UIScrollPane(nameList), BorderLayout.CENTER); |
|
|
|
listPane.add(new UIScrollPane(nameList), BorderLayout.CENTER); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
nameList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); |
|
|
|
nameList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); |
|
|
|
nameList.addMouseListener(listMouseListener); |
|
|
|
nameList.addMouseListener(listMouseListener); |
|
|
|
nameList.addListSelectionListener(new ListSelectionListener() { |
|
|
|
nameList.addListSelectionListener(new ListSelectionListener() { |
|
|
@ -124,8 +128,12 @@ public class UISimpleListControlPane extends BasicPane { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public UIList createJNameList() { |
|
|
|
/** |
|
|
|
UIList nameList = new UIList(new DefaultListModel()) { |
|
|
|
* 构造 list,设置 render |
|
|
|
|
|
|
|
* @return UINameEdList |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public UINameEdList createJNameList() { |
|
|
|
|
|
|
|
UINameEdList nameList = new UINameEdList(new DefaultListModel()) { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public int locationToIndex(Point location) { |
|
|
|
public int locationToIndex(Point location) { |
|
|
|
int index = super.locationToIndex(location); |
|
|
|
int index = super.locationToIndex(location); |
|
|
@ -411,6 +419,7 @@ public class UISimpleListControlPane extends BasicPane { |
|
|
|
label = new UILabel(); |
|
|
|
label = new UILabel(); |
|
|
|
initialLabelForeground = label.getForeground(); |
|
|
|
initialLabelForeground = label.getForeground(); |
|
|
|
this.setLayout(new BorderLayout()); |
|
|
|
this.setLayout(new BorderLayout()); |
|
|
|
|
|
|
|
label.setBorder(new ScaledEmptyBorder(0, 6, 0, 0)); |
|
|
|
this.add(label, BorderLayout.CENTER); |
|
|
|
this.add(label, BorderLayout.CENTER); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -425,6 +434,7 @@ public class UISimpleListControlPane extends BasicPane { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Component getListCellRendererComponent(JList list, Object value, |
|
|
|
public Component getListCellRendererComponent(JList list, Object value, |
|
|
|
int index, boolean isSelected, boolean cellHasFocus) { |
|
|
|
int index, boolean isSelected, boolean cellHasFocus) { |
|
|
|
|
|
|
|
setPreferredSize(new Dimension(list.getWidth(), FineUIScale.scale(UIManager.getInt("List.cellRender.height")))); |
|
|
|
setComponentOrientation(list.getComponentOrientation()); |
|
|
|
setComponentOrientation(list.getComponentOrientation()); |
|
|
|
|
|
|
|
|
|
|
|
Color bg = null; |
|
|
|
Color bg = null; |
|
|
@ -442,9 +452,7 @@ public class UISimpleListControlPane extends BasicPane { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (isSelected) { |
|
|
|
if (isSelected) { |
|
|
|
setBackground(bg == null ? list.getSelectionBackground() : bg); |
|
|
|
setBackground(FlatUIUtils.getUIColor("List.selectionInactiveBackground", Color.GRAY)); |
|
|
|
setForeground(fg == null ? list.getSelectionForeground() : fg); |
|
|
|
|
|
|
|
label.setForeground(Color.WHITE); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
else { |
|
|
|
setBackground(list.getBackground()); |
|
|
|
setBackground(list.getBackground()); |
|
|
|