Browse Source
* commit '23e90d2b5f96007379d3e22305e100e3b82ce573': REPORT-69422 产品调整部分UI 【问题原因】有些小细节还需要调整下 【改动思路】调整 【review建议】无 Update designer-base/src/main/java/com/fr/design/record/analyzer/advice/MonitorAdvice.java 无jira任务,屏蔽部分功能入口 REPORT-69324 插件-新插件管理-设计器内插件管理版本号显示异常 REPORT-69422 && REPORT-69426 产品调整部分UI && 复制单元格会影响数据集的展开/收起状态 【问题原因】1.产品验收功能的时候改了一些UI;2.因为粘贴单元格的时候会获取当前数据集面板,getInstance方法里会refresh一次整个数据集树,然后将所有节点重置到收起状态 【改动思路】1.调整UI;2.提供一个获取数据集树面板单例不刷新自己的方法,粘贴时使用 【review建议】无 BI-103979 【6.0回归】fr连接bi闪退 REPORT-69213 函数在公式编辑器内不标蓝显示 REPORT-69213 函数在公式编辑器内不标蓝显示 REPORT-68212 表头排序功能-国际化-交互问题 && REPORT-68931 表头排序图标配置颜色后大小发生变化feature/x
superman
3 years ago
28 changed files with 3171 additions and 2827 deletions
@ -0,0 +1,170 @@ |
|||||||
|
package com.fr.design.gui.ilist; |
||||||
|
|
||||||
|
import com.fr.design.event.StateChangeListener; |
||||||
|
import com.fr.design.gui.icheckbox.UICheckBox; |
||||||
|
import com.fr.design.gui.itree.checkboxtree.TristateCheckBox; |
||||||
|
import com.fr.design.i18n.Toolkit; |
||||||
|
import com.fr.design.layout.FRGUIPaneFactory; |
||||||
|
|
||||||
|
import javax.swing.AbstractListModel; |
||||||
|
import javax.swing.DefaultListCellRenderer; |
||||||
|
import javax.swing.JList; |
||||||
|
import javax.swing.JPanel; |
||||||
|
import javax.swing.ListCellRenderer; |
||||||
|
import java.awt.BorderLayout; |
||||||
|
import java.awt.Component; |
||||||
|
import java.awt.event.MouseAdapter; |
||||||
|
import java.awt.event.MouseEvent; |
||||||
|
import java.awt.event.MouseListener; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* 支持全选、全不选、半选的CheckBoxList面板 |
||||||
|
* @author Yvan |
||||||
|
*/ |
||||||
|
public class CheckBoxListWithPartialSelect extends JPanel { |
||||||
|
|
||||||
|
private UICheckBox[] dataCheckBoxes; |
||||||
|
|
||||||
|
private TristateCheckBox chooseAllCheckBox; |
||||||
|
|
||||||
|
private UIList dataList; |
||||||
|
|
||||||
|
public CheckBoxListWithPartialSelect (Object[] data) { |
||||||
|
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||||
|
init(data); |
||||||
|
this.add(chooseAllCheckBox, BorderLayout.NORTH); |
||||||
|
this.add(dataList, BorderLayout.CENTER); |
||||||
|
} |
||||||
|
|
||||||
|
private void init(Object[] data) { |
||||||
|
// 复选框组
|
||||||
|
dataCheckBoxes = new UICheckBox[data.length]; |
||||||
|
for (int i = 0; i < dataCheckBoxes.length; i++) { |
||||||
|
dataCheckBoxes[i] = new UICheckBox(transferDataValue2Show(data[i])); |
||||||
|
dataCheckBoxes[i].setSelected(true); |
||||||
|
} |
||||||
|
|
||||||
|
// UIList
|
||||||
|
dataList = new UIList(dataCheckBoxes); |
||||||
|
dataList.setModel(getListModel()); |
||||||
|
dataList.setCellRenderer(getListCellRenderer()); |
||||||
|
|
||||||
|
// 全选框
|
||||||
|
chooseAllCheckBox = new TristateCheckBox(Toolkit.i18nText("Fine-Design_Basic_Remove_All_Selected")) { |
||||||
|
@Override |
||||||
|
protected State getNextState(State current) { |
||||||
|
if (current == TristateCheckBox.SELECTED || current == TristateCheckBox.DO_NOT_CARE) { |
||||||
|
return TristateCheckBox.NOT_SELECTED; |
||||||
|
} |
||||||
|
return TristateCheckBox.SELECTED; |
||||||
|
} |
||||||
|
}; |
||||||
|
chooseAllCheckBox.setState(TristateCheckBox.SELECTED); |
||||||
|
chooseAllCheckBox.setFocusable(false); |
||||||
|
chooseAllCheckBox.addStateChangeListener(getChooseAllCheckBoxStateChangeListener()); |
||||||
|
dataList.addMouseListener(getDataListMouseListener()); |
||||||
|
} |
||||||
|
|
||||||
|
public List<Object> getSelectedObjects() { |
||||||
|
return dataList.getSelectedValuesList(); |
||||||
|
} |
||||||
|
|
||||||
|
protected MouseListener getDataListMouseListener() { |
||||||
|
return new MouseAdapter() { |
||||||
|
@Override |
||||||
|
public void mousePressed(MouseEvent e) { |
||||||
|
super.mousePressed(e); |
||||||
|
int index = dataList.getSelectedIndex(); |
||||||
|
if (index < 0) { |
||||||
|
return; |
||||||
|
} |
||||||
|
UICheckBox checkBox = (UICheckBox) dataList.getModel().getElementAt(index); |
||||||
|
checkBox.setSelected(!checkBox.isSelected()); |
||||||
|
//根据CheckBoxes中的选择情况来更新全选框的状态
|
||||||
|
int selectedCount = calculateSelectedNum(); |
||||||
|
if (selectedCount == 0) { |
||||||
|
chooseAllCheckBox.setState(TristateCheckBox.NOT_SELECTED); |
||||||
|
} else if (selectedCount == dataCheckBoxes.length) { |
||||||
|
chooseAllCheckBox.setState(TristateCheckBox.SELECTED); |
||||||
|
} else { |
||||||
|
chooseAllCheckBox.setState(TristateCheckBox.DO_NOT_CARE); |
||||||
|
} |
||||||
|
dataList.repaint(); |
||||||
|
} |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取全选框状态改变监听 |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
protected StateChangeListener getChooseAllCheckBoxStateChangeListener() { |
||||||
|
return () -> { |
||||||
|
if (chooseAllCheckBox.getState() == TristateCheckBox.DO_NOT_CARE) { |
||||||
|
return; |
||||||
|
} |
||||||
|
boolean isSelected = chooseAllCheckBox.isSelected(); |
||||||
|
for (int i = 0; i < dataList.getModel().getSize(); i++) { |
||||||
|
UICheckBox checkBox = (UICheckBox) dataList.getModel().getElementAt(i); |
||||||
|
checkBox.setSelected(isSelected); |
||||||
|
} |
||||||
|
dataList.repaint(); |
||||||
|
}; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 计算CheckBox的选中情况,用来更新全选框的状态 |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
protected int calculateSelectedNum() { |
||||||
|
int count = 0; |
||||||
|
for (UICheckBox dataCheckBox : dataCheckBoxes) { |
||||||
|
if (dataCheckBox.isSelected()) { |
||||||
|
count++; |
||||||
|
} |
||||||
|
} |
||||||
|
return count; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 将传入的Object转化为字符串展示,默认调用toString方法 |
||||||
|
* @param object |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
protected String transferDataValue2Show(Object object) { |
||||||
|
return object.toString(); |
||||||
|
} |
||||||
|
|
||||||
|
protected AbstractListModel getListModel() { |
||||||
|
return new SelectedListDataModel(); |
||||||
|
} |
||||||
|
|
||||||
|
protected ListCellRenderer getListCellRenderer() { |
||||||
|
return new SelectedListCellRender(); |
||||||
|
} |
||||||
|
|
||||||
|
private class SelectedListCellRender extends DefaultListCellRenderer { |
||||||
|
|
||||||
|
@Override |
||||||
|
public Component getListCellRendererComponent(JList list, Object value, int index, final boolean isSelected, boolean cellHasFocus) { |
||||||
|
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
||||||
|
dataCheckBoxes[index] = (UICheckBox) value; |
||||||
|
dataCheckBoxes[index].setBackground(list.getBackground()); |
||||||
|
return dataCheckBoxes[index]; |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
private class SelectedListDataModel extends AbstractListModel { |
||||||
|
@Override |
||||||
|
public int getSize() { |
||||||
|
return dataCheckBoxes.length; |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public Object getElementAt(int index) { |
||||||
|
return (index > getSize() - 1 || index < 0) ? null : dataCheckBoxes[index]; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
File diff suppressed because it is too large
Load Diff
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 1.1 KiB |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 1014 B |
Loading…
Reference in new issue