@ -1,59 +0,0 @@
|
||||
package com.fr.design.gui; |
||||
|
||||
import com.fr.design.file.HistoryTemplateListPane; |
||||
import com.fr.design.mainframe.BaseJForm; |
||||
import com.fr.design.mainframe.JTemplate; |
||||
import com.fr.general.ComparatorUtils; |
||||
|
||||
|
||||
/** |
||||
* Created by mengao on 2017/9/22. |
||||
* 单元格超链、图表超链在不同类型模版中,下拉选项不同 |
||||
*/ |
||||
public class HyperlinkFilterHelper { |
||||
|
||||
public static boolean whetherAddHyperlink4cell(String itemName) { |
||||
JTemplate jTemplate = getCurrentEditingTemplate(); |
||||
if (jTemplate == null) { |
||||
return false; |
||||
} |
||||
//先屏蔽掉这个,之后还有别的
|
||||
String[] names = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_ Hyperlink_Chart_Float")}; |
||||
for (String name : names) { |
||||
if (!jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName, name)) { |
||||
return false; |
||||
} |
||||
} |
||||
return whetherAddFormLink(jTemplate, itemName); |
||||
} |
||||
|
||||
public static boolean whetherAddHyperlink4Chart(String itemName) { |
||||
JTemplate jTemplate = getCurrentEditingTemplate(); |
||||
if (jTemplate == null) { |
||||
return false; |
||||
} |
||||
//先屏蔽掉这个,之后还有别的
|
||||
String[] names = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_ Hyperlink_Chart_Float"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Chart_Cell")}; |
||||
for (String name : names) { |
||||
if (!jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName, name)) { |
||||
if (jTemplate.getEditingReportIndex() == BaseJForm.ELEMENTCASE_TAB && ComparatorUtils.equals(itemName, names[0])) { |
||||
//表单报表块中图表悬浮元素超链,只屏蔽联动悬浮元素
|
||||
return false; |
||||
} else if (jTemplate.getEditingReportIndex() == BaseJForm.FORM_TAB) { |
||||
//表单图表超链屏蔽掉联动悬浮元素和联动单元格
|
||||
return false; |
||||
} |
||||
} |
||||
} |
||||
return whetherAddFormLink(jTemplate, itemName); |
||||
} |
||||
|
||||
private static JTemplate getCurrentEditingTemplate() { |
||||
return HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); |
||||
} |
||||
|
||||
private static boolean whetherAddFormLink(JTemplate jTemplate, String itemName) { |
||||
String formName = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Hyperlink_Form_Link"); |
||||
return !(jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName, formName)); |
||||
} |
||||
} |
@ -0,0 +1,233 @@
|
||||
package com.fr.design.gui.icombocheckbox; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.constants.UIConstants; |
||||
import com.fr.design.gui.icontainer.UIScrollPane; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.imenu.UIPopupMenu; |
||||
import com.fr.design.icon.IconPathConstants; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.awt.event.*; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
public class UICheckListPopup extends UIPopupMenu { |
||||
private List<ActionListener> listeners = new ArrayList<ActionListener>(); |
||||
private List<JCheckBox> checkBoxList = new ArrayList<JCheckBox>(); |
||||
|
||||
private Object[] values; |
||||
private JPanel checkboxPane; |
||||
private UIScrollPane jScrollPane; |
||||
private Color mouseEnteredColor = UIConstants.CHECKBOX_HOVER_SELECTED; |
||||
private int maxDisplayNumber = 8; |
||||
|
||||
public static final String COMMIT_EVENT = "commit"; |
||||
public static final String SELECT_ALL = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Choose_All"); |
||||
private static final int CHECKBOX_HEIGHT = 25; |
||||
|
||||
public UICheckListPopup(Object[] value) { |
||||
super(); |
||||
values = value; |
||||
initComponent(); |
||||
} |
||||
|
||||
public void setMouseEnteredColor(Color color) { |
||||
this.mouseEnteredColor = color; |
||||
} |
||||
|
||||
public void setMaxDisplayNumber(int maxDisplayNumber) { |
||||
this.maxDisplayNumber = maxDisplayNumber; |
||||
addCheckboxValues(values); |
||||
} |
||||
|
||||
private void initComponent() { |
||||
checkboxPane = new JPanel(); |
||||
checkboxPane.setLayout(new GridLayout(checkBoxList.size(), 1, 0, 0)); |
||||
checkboxPane.setBackground(Color.WHITE); |
||||
jScrollPane = new UIScrollPane(checkboxPane); |
||||
|
||||
this.setLayout(new BorderLayout()); |
||||
this.add(jScrollPane, BorderLayout.CENTER); |
||||
|
||||
addCheckboxValues(values); |
||||
} |
||||
|
||||
public void addCheckboxValues(Object[] value) { |
||||
checkboxPane.removeAll(); |
||||
checkBoxList.clear(); |
||||
|
||||
//全选加在第一个位置
|
||||
addOneCheckValue(SELECT_ALL); |
||||
for (Object checkValue : value) { |
||||
addOneCheckValue(checkValue); |
||||
} |
||||
addSelectListener(); |
||||
|
||||
jScrollPane.setPreferredSize(new Dimension(200, checkBoxList.size() * CHECKBOX_HEIGHT + 10)); |
||||
//超过1页的数量时显示滚动条
|
||||
if (checkBoxList.size() > maxDisplayNumber) { |
||||
jScrollPane.setPreferredSize(new Dimension(200, maxDisplayNumber * CHECKBOX_HEIGHT)); |
||||
} |
||||
checkboxPane.repaint(); |
||||
jScrollPane.repaint(); |
||||
} |
||||
|
||||
private void addOneCheckValue(Object checkValue) { |
||||
JPanel checkPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); |
||||
checkPane.setPreferredSize(new Dimension(185, CHECKBOX_HEIGHT)); |
||||
final JCheckBox temp = createCheckbox(); |
||||
final UILabel label = new UILabel(checkValue.toString()); |
||||
label.setBackground(Color.WHITE); |
||||
label.setPreferredSize(new Dimension(156, 20)); |
||||
checkPane.setBackground(Color.WHITE); |
||||
checkPane.add(temp); |
||||
checkPane.add(label); |
||||
addMouseListener(temp, label); |
||||
|
||||
checkBoxList.add(temp); |
||||
checkboxPane.add(checkPane); |
||||
} |
||||
|
||||
private JCheckBox createCheckbox() { |
||||
JCheckBox checkBox = new JCheckBox(); |
||||
checkBox.setPreferredSize(new Dimension(20, 20)); |
||||
checkBox.setBackground(Color.WHITE); |
||||
checkBox.setIcon(BaseUtils.readIcon(IconPathConstants.CHECKBOX_NORMAL)); |
||||
checkBox.setSelectedIcon(BaseUtils.readIcon(IconPathConstants.CHECKBOX_SELECTED)); |
||||
|
||||
return checkBox; |
||||
} |
||||
|
||||
/** |
||||
* 设置鼠标事件,鼠标进入时背景色变换 |
||||
* |
||||
* @param checkBox |
||||
* @param label |
||||
*/ |
||||
private void addMouseListener(final JCheckBox checkBox, final UILabel label) { |
||||
label.addMouseListener(new MouseAdapter() { |
||||
public void mouseExited(MouseEvent e) { |
||||
label.setBackground(Color.WHITE); |
||||
} |
||||
|
||||
public void mouseEntered(MouseEvent e) { |
||||
label.setOpaque(true); |
||||
label.setBackground(mouseEnteredColor); |
||||
} |
||||
|
||||
@Override |
||||
public void mouseClicked(MouseEvent e) { |
||||
checkBox.doClick(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
/** |
||||
* 单选框选中事件 |
||||
*/ |
||||
private void addSelectListener() { |
||||
for (int i = 0; i < checkBoxList.size(); i++) { |
||||
JCheckBox checkBox = checkBoxList.get(i); |
||||
if (i == 0) { |
||||
checkBox.addItemListener(new ItemListener() { |
||||
public void itemStateChanged(ItemEvent e) { |
||||
//全选checkbox事件
|
||||
doSelectAll(checkBoxList.get(0).isSelected()); |
||||
} |
||||
}); |
||||
} else { |
||||
checkBox.addItemListener(new ItemListener() { |
||||
public void itemStateChanged(ItemEvent e) { |
||||
//do半选判断放在commit事件里
|
||||
commit(); |
||||
} |
||||
}); |
||||
} |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 全选 |
||||
* |
||||
* @param isSelected 选中是true,未选是false |
||||
*/ |
||||
private void doSelectAll(boolean isSelected) { |
||||
for (int i = 1; i < checkBoxList.size(); i++) { |
||||
//全选和反全选都不考虑全选按钮本身
|
||||
if (!SELECT_ALL.equals(checkBoxList.get(i).getText())) |
||||
checkBoxList.get(i).setSelected(isSelected); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 获取所有选中的值 |
||||
* |
||||
* @return |
||||
*/ |
||||
public Object[] getSelectedValues() { |
||||
List<Object> selectedValues = new ArrayList<Object>(); |
||||
int selectCount = 0; |
||||
|
||||
for (int i = 1; i < checkBoxList.size(); i++) { |
||||
if (checkBoxList.get(i).isSelected()) { |
||||
selectedValues.add(values[i - 1]); |
||||
selectCount++; |
||||
} |
||||
} |
||||
//全选半选切换
|
||||
switchSelectIcon(selectCount); |
||||
|
||||
return selectedValues.toArray(new Object[selectedValues.size()]); |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 切换全选半选图片 |
||||
*/ |
||||
private void switchSelectIcon(int selectCount) { |
||||
JCheckBox checkBox = checkBoxList.get(0); |
||||
if (selectCount == 0) { |
||||
checkBox.setIcon(BaseUtils.readIcon(IconPathConstants.CHECKBOX_NORMAL)); |
||||
} else if (selectCount < checkBoxList.size() - 1) { |
||||
//虽然有选中,但是要判断此时全选状态去换图标
|
||||
if (checkBoxList.get(0).isSelected()) { |
||||
checkBox.setSelectedIcon(BaseUtils.readIcon(IconPathConstants.CHECKBOX_HATFSELECT)); |
||||
} else { |
||||
checkBox.setIcon(BaseUtils.readIcon(IconPathConstants.CHECKBOX_HATFSELECT)); |
||||
} |
||||
} else { |
||||
//全选了,图标要换回来
|
||||
checkBox.setSelectedIcon(BaseUtils.readIcon(IconPathConstants.CHECKBOX_SELECTED)); |
||||
} |
||||
} |
||||
|
||||
public void commit() { |
||||
fireActionPerformed(new ActionEvent(this, 0, COMMIT_EVENT)); |
||||
} |
||||
|
||||
@Override |
||||
public Insets getInsets() { |
||||
return new Insets(0, 0, 0, 0); |
||||
} |
||||
|
||||
public void addActionListener(ActionListener listener) { |
||||
if (!listeners.contains(listener)) |
||||
listeners.add(listener); |
||||
} |
||||
|
||||
public void removeActionListener(ActionListener listener) { |
||||
if (listeners.contains(listener)) { |
||||
listeners.remove(listener); |
||||
} |
||||
} |
||||
|
||||
protected void fireActionPerformed(ActionEvent e) { |
||||
for (ActionListener l : listeners) { |
||||
l.actionPerformed(e); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,330 @@
|
||||
package com.fr.design.gui.icombocheckbox; |
||||
|
||||
import com.fr.base.BaseUtils; |
||||
import com.fr.design.event.GlobalNameListener; |
||||
import com.fr.design.event.GlobalNameObserver; |
||||
import com.fr.design.event.UIObserver; |
||||
import com.fr.design.event.UIObserverListener; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.design.icon.IconPathConstants; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.*; |
||||
import java.awt.*; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.awt.event.MouseAdapter; |
||||
import java.awt.event.MouseEvent; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* 设计器下拉复选框组件 |
||||
* 支持全选、半选 |
||||
* 可以设置悬停颜色、一页最多显示单选框个数 |
||||
* 可以省略显示 |
||||
*/ |
||||
public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNameObserver { |
||||
//下拉框的值
|
||||
private Object[] values; |
||||
//已经选中的值
|
||||
private Object[] selectedValues; |
||||
|
||||
private List<ActionListener> listeners = new ArrayList<ActionListener>(); |
||||
private UICheckListPopup popup; |
||||
private UITextField editor; |
||||
private UIButton arrowButton; |
||||
//选中的值之间显示的分隔符
|
||||
private String valueSperator; |
||||
private static final String DEFAULT_VALUE_SPERATOR = ","; |
||||
private static final String OMIT_TEXT = "..."; |
||||
|
||||
private UIObserverListener uiObserverListener; |
||||
private GlobalNameListener globalNameListener = null; |
||||
private String multiComboName = StringUtils.EMPTY; |
||||
private boolean showOmitText = true; |
||||
|
||||
public UIComboCheckBox(Object[] value) { |
||||
this(value, DEFAULT_VALUE_SPERATOR); |
||||
} |
||||
|
||||
/** |
||||
* 自定义分隔符的复选框 |
||||
* |
||||
* @param value |
||||
* @param valueSperator |
||||
*/ |
||||
public UIComboCheckBox(Object[] value, String valueSperator) { |
||||
values = value; |
||||
this.valueSperator = valueSperator; |
||||
initComponent(); |
||||
} |
||||
|
||||
/** |
||||
* 设置鼠标悬停的背景色 |
||||
* |
||||
* @param color |
||||
*/ |
||||
public void setCheckboxEnteredColor(Color color) { |
||||
this.popup.setMouseEnteredColor(color); |
||||
} |
||||
|
||||
/** |
||||
* 设置弹出框最多显示单选的个数,超过显示滚动条 |
||||
*/ |
||||
public void setPopupMaxDisplayNumber(int maxDisplayNumber) { |
||||
this.popup.setMaxDisplayNumber(maxDisplayNumber); |
||||
} |
||||
|
||||
/** |
||||
* 是否要超过文本框长度后显示省略号 |
||||
* |
||||
* @param isShowOmitText |
||||
*/ |
||||
public void isShowOmitText(boolean isShowOmitText) { |
||||
this.showOmitText = isShowOmitText; |
||||
} |
||||
|
||||
private void initComponent() { |
||||
this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); |
||||
this.popup = new UICheckListPopup(values); |
||||
this.popup.addActionListener(new PopupAction()); |
||||
this.editor = createEditor(); |
||||
this.arrowButton = createArrowButton(); |
||||
this.add(editor); |
||||
this.add(arrowButton); |
||||
setText(); |
||||
} |
||||
|
||||
private UIButton createArrowButton() { |
||||
final UIButton arrowBtn = new UIButton(); |
||||
arrowBtn.setNormalPainted(false); |
||||
arrowBtn.setPreferredSize(new Dimension(20, 5)); |
||||
arrowBtn.setBackground(new Color(218, 218, 218)); |
||||
arrowBtn.setOpaque(true); |
||||
arrowBtn.setIcon(getIcon()); |
||||
arrowBtn.setExtraPainted(false); |
||||
addPopupListener(arrowBtn); |
||||
arrowBtn.addMouseListener(new MouseAdapter() { |
||||
@Override |
||||
public void mouseEntered(MouseEvent e) { |
||||
arrowBtn.setBackground(new Color(200, 200, 200)); |
||||
} |
||||
|
||||
@Override |
||||
public void mouseExited(MouseEvent e) { |
||||
arrowBtn.setBackground(new Color(218, 218, 218)); |
||||
} |
||||
}); |
||||
|
||||
return arrowBtn; |
||||
} |
||||
|
||||
private UITextField createEditor() { |
||||
UITextField editor = new UITextField(); |
||||
editor.setEditable(false); |
||||
editor.setPreferredSize(new Dimension(180, 20)); |
||||
addPopupListener(editor); |
||||
|
||||
return editor; |
||||
} |
||||
|
||||
/** |
||||
* 弹出框事件 |
||||
* |
||||
* @param component |
||||
*/ |
||||
private void addPopupListener(Component component) { |
||||
component.addMouseListener(new MouseAdapter() { |
||||
public void mouseClicked(MouseEvent e) { |
||||
togglePopup(); |
||||
} |
||||
}); |
||||
|
||||
} |
||||
|
||||
/** |
||||
* 刷新复选框的列表值 |
||||
* |
||||
* @param value |
||||
*/ |
||||
public void refreshCombo(Object[] value) { |
||||
this.values = value; |
||||
this.popup.addCheckboxValues(value); |
||||
} |
||||
|
||||
/** |
||||
* 获取复选框选中的值 |
||||
* |
||||
* @return 复选框选中的值 |
||||
*/ |
||||
public Object[] getSelectedValues() { |
||||
return popup.getSelectedValues(); |
||||
} |
||||
|
||||
private class PopupAction implements ActionListener { |
||||
|
||||
public void actionPerformed(ActionEvent e) { |
||||
if (e.getActionCommand().equals(UICheckListPopup.COMMIT_EVENT)) { |
||||
selectedValues = popup.getSelectedValues(); |
||||
setText(); |
||||
//把事件继续传递出去
|
||||
fireActionPerformed(e); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private void togglePopup() { |
||||
if (this.arrowButton.isEnabled()) { |
||||
popup.show(this, 0, getHeight()); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 清除文本框 |
||||
*/ |
||||
public void clearText() { |
||||
editor.setText(StringUtils.EMPTY); |
||||
} |
||||
|
||||
/** |
||||
* 获取文本框内容 |
||||
*/ |
||||
public String getText() { |
||||
return editor.getText(); |
||||
} |
||||
|
||||
/** |
||||
* 文本框设置显示值 |
||||
*/ |
||||
private void setText() { |
||||
StringBuilder builder = new StringBuilder(); |
||||
if (selectedValues != null) { |
||||
for (Object value : selectedValues) { |
||||
builder.append(value); |
||||
builder.append(valueSperator); |
||||
} |
||||
} |
||||
//去掉末尾多余的逗号
|
||||
String text = builder.length() > 0 ? builder.substring(0, builder.length() - 1) : StringUtils.EMPTY; |
||||
//计算加省略号后的文本
|
||||
editor.setText(this.showOmitText ? omitEditorText(editor, text) : text); |
||||
} |
||||
|
||||
/** |
||||
* 根据字体大小计算得到省略后的文字 |
||||
* |
||||
* @param textEditor |
||||
* @param text |
||||
* @return 省略后的文字 |
||||
*/ |
||||
private static String omitEditorText(UITextField textEditor, String text) { |
||||
char[] omitChars = OMIT_TEXT.toCharArray(); |
||||
//获取字体的大小
|
||||
FontMetrics fontMetrics = textEditor.getFontMetrics(textEditor.getFont()); |
||||
//计算省略号的长度
|
||||
int omitLength = fontMetrics.charsWidth(omitChars, 0, omitChars.length); |
||||
String omitText = StringUtils.EMPTY; |
||||
char[] chars = text.toCharArray(); |
||||
|
||||
for (int i = 1; i <= chars.length; i++) { |
||||
//如果原文本+省略号长度超过文本框
|
||||
if (fontMetrics.charsWidth(chars, 0, i) + omitLength > textEditor.getPreferredSize().getWidth()) { |
||||
//从第i-1的位置截断再拼上省略号
|
||||
omitText = text.substring(0, i - 2) + OMIT_TEXT; |
||||
break; |
||||
} |
||||
} |
||||
|
||||
return omitText == StringUtils.EMPTY ? text : omitText; |
||||
} |
||||
|
||||
/** |
||||
* 给组件登记一个观察者监听事件 |
||||
* |
||||
* @param listener 观察者监听事件 |
||||
*/ |
||||
@Override |
||||
public void registerChangeListener(UIObserverListener listener) { |
||||
this.uiObserverListener = listener; |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public void setGlobalName(String name) { |
||||
multiComboName = name; |
||||
} |
||||
|
||||
/** |
||||
* 组件是否需要响应添加的观察者事件 |
||||
* |
||||
* @return 如果需要响应观察者事件则返回true,否则返回false |
||||
*/ |
||||
@Override |
||||
public boolean shouldResponseChangeListener() { |
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* 注册观察者监听事件 |
||||
* |
||||
* @param listener 观察者监听事件 |
||||
*/ |
||||
@Override |
||||
public void registerNameListener(GlobalNameListener listener) { |
||||
globalNameListener = listener; |
||||
} |
||||
|
||||
private Icon getIcon() { |
||||
return BaseUtils.readIcon(IconPathConstants.ARROW_ICON_PATH); |
||||
} |
||||
|
||||
/** |
||||
* 组件是否需要响应观察者事件 |
||||
* |
||||
* @return 如果需要响应观察者事件则返回true,否则返回false |
||||
*/ |
||||
@Override |
||||
public boolean shouldResponseNameListener() { |
||||
return true; |
||||
} |
||||
|
||||
public void addActionListener(ActionListener listener) { |
||||
if (!listeners.contains(listener)) |
||||
listeners.add(listener); |
||||
} |
||||
|
||||
public void removeActionListener(ActionListener listener) { |
||||
if (listeners.contains(listener)) |
||||
listeners.remove(listener); |
||||
} |
||||
|
||||
protected void fireActionPerformed(ActionEvent e) { |
||||
for (ActionListener l : listeners) { |
||||
l.actionPerformed(e); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 简单的测试demo |
||||
* @param args |
||||
*/ |
||||
public static void main(String args[]) { |
||||
UIComboCheckBox comboBox = new UIComboCheckBox(new Object[] |
||||
{"MATA", "HANA", "KAKA", "KUKA", "INFI", "LILY", "RIBO", "CUBE", "MATA", "HANA", "KAKA", "KUKA"}); |
||||
|
||||
comboBox.isShowOmitText(false); |
||||
comboBox.setPopupMaxDisplayNumber(6); |
||||
|
||||
JPanel jPanel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); |
||||
jPanel.add(comboBox); |
||||
|
||||
JFrame jFrame = new JFrame(); |
||||
jFrame.setVisible(true); |
||||
jFrame.setSize(600, 400); |
||||
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
||||
jFrame.add(jPanel, BorderLayout.CENTER); |
||||
} |
||||
} |
@ -1,6 +0,0 @@
|
||||
package com.fr.design; |
||||
|
||||
public class mingche |
||||
{ |
||||
|
||||
} |
After Width: | Height: | Size: 164 B |
After Width: | Height: | Size: 200 B |
After Width: | Height: | Size: 337 B |
After Width: | Height: | Size: 444 B |
After Width: | Height: | Size: 844 B |
@ -0,0 +1,44 @@
|
||||
package com.fr.extended.chart; |
||||
|
||||
import com.fr.design.gui.icombobox.UIComboBox; |
||||
import com.fr.design.i18n.Toolkit; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* Created by shine on 2018/9/27. |
||||
*/ |
||||
public class UIComboBoxWithNone extends UIComboBox { |
||||
|
||||
protected String getDefaultLocaleString() { |
||||
return Toolkit.i18nText("Fine-Design_Chart_Use_None"); |
||||
} |
||||
|
||||
@Override |
||||
public void refreshBoxItems(List list) { |
||||
super.refreshBoxItems(list); |
||||
addDefaultItem(); |
||||
} |
||||
|
||||
@Override |
||||
public void clearBoxItems() { |
||||
super.clearBoxItems(); |
||||
addDefaultItem(); |
||||
} |
||||
|
||||
|
||||
private void addDefaultItem() { |
||||
addItem(getDefaultLocaleString()); |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void setSelectedItem(Object anObject) { |
||||
super.setSelectedItem(anObject); |
||||
|
||||
if (getSelectedIndex() == -1) {//找不到的都选中无。中文的无 英文下是none。
|
||||
super.setSelectedItem(getDefaultLocaleString()); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,91 @@
|
||||
package com.fr.design.webattr.printsettings; |
||||
|
||||
import com.fr.base.print.NativePrintAttr; |
||||
import com.fr.design.gui.icheckbox.UICheckBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.layout.TableLayoutHelper; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import java.awt.Component; |
||||
|
||||
/** |
||||
* 本地打印设置面板——全局 |
||||
* Created by plough on 2018/10/31. |
||||
*/ |
||||
public class GlobalNativePrintSettingPane extends AbstractNativePrintSettingPane { |
||||
// 服务器配置面板特有的组件
|
||||
private UICheckBox defaultDownloadUrlCheck; // 采用默认的软件下载地址
|
||||
private UITextField customUrlFieldWin; |
||||
private UITextField customUrlFieldMac; |
||||
|
||||
|
||||
@Override |
||||
JPanel createHeaderPane(Component... comps) { |
||||
|
||||
Component[] newComps = { |
||||
getDownloadUrlSettingPane() |
||||
}; |
||||
Component[] allComps = new Component[comps.length + newComps.length]; |
||||
System.arraycopy(comps, 0, allComps, 0, comps.length); |
||||
System.arraycopy(newComps, 0, allComps, comps.length, newComps.length); |
||||
|
||||
JPanel headerPane = createHeaderLayoutPane(allComps); |
||||
headerPane.setBorder(BorderFactory.createEmptyBorder(2, 12, 5, 0)); |
||||
return headerPane; |
||||
} |
||||
|
||||
|
||||
@Override |
||||
protected void extraUpdate(NativePrintAttr nativePrintAttr) { |
||||
if (defaultDownloadUrlCheck.isSelected()) { |
||||
nativePrintAttr.setUseDefaultDownloadUrl(true); |
||||
} else { |
||||
nativePrintAttr.setUseDefaultDownloadUrl(false); |
||||
nativePrintAttr.setCustomDownloadUrlMac(customUrlFieldMac.getText()); |
||||
nativePrintAttr.setCustomDownloadUrlWin(customUrlFieldWin.getText()); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
protected void extraPopulate(NativePrintAttr nativePrintAttr) { |
||||
defaultDownloadUrlCheck.setSelected(nativePrintAttr.isUseDefaultDownloadUrl()); |
||||
customUrlFieldMac.setText(nativePrintAttr.getCustomDownloadUrlMac()); |
||||
customUrlFieldWin.setText(nativePrintAttr.getCustomDownloadUrlWin()); |
||||
} |
||||
|
||||
private JPanel getDownloadUrlSettingPane() { |
||||
defaultDownloadUrlCheck = GUICoreUtils.createNoBorderCheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Default")); |
||||
JPanel downloadUrlSettingCheckPane = GUICoreUtils.createCheckboxAndDynamicPane(defaultDownloadUrlCheck, getCustomUrlSettingPane(), true); |
||||
downloadUrlSettingCheckPane.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 0)); |
||||
|
||||
// TableLayout
|
||||
double p = TableLayout.PREFERRED; |
||||
double[] rowSize = {p}; |
||||
double[] columnSize = {p, p}; |
||||
Component[][] components = { |
||||
{getTopAlignLabelPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Software_Download_Url") + ": "), downloadUrlSettingCheckPane} |
||||
}; |
||||
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 15); |
||||
} |
||||
|
||||
private JPanel getCustomUrlSettingPane() { |
||||
customUrlFieldWin = new UITextField(20); |
||||
customUrlFieldMac = new UITextField(20); |
||||
|
||||
// TableLayout
|
||||
double p = TableLayout.PREFERRED; |
||||
double[] rowSize = {p, p}; |
||||
double[] columnSize = {60, p}; |
||||
Component[][] components = { |
||||
{new UILabel("windows: "), customUrlFieldWin}, |
||||
{new UILabel("macOS: "), customUrlFieldMac} |
||||
}; |
||||
JPanel urlSettingPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 0, 10); |
||||
urlSettingPane.setBorder(BorderFactory.createEmptyBorder(5, 0, 0, 0)); |
||||
return urlSettingPane; |
||||
} |
||||
} |
@ -0,0 +1,18 @@
|
||||
package com.fr.design.webattr.printsettings; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.JPanel; |
||||
import java.awt.Component; |
||||
|
||||
/** |
||||
* 本地打印设置面板——单模版 |
||||
* Created by plough on 2018/10/31. |
||||
*/ |
||||
public class ReportNativePrintSettingPane extends AbstractNativePrintSettingPane { |
||||
@Override |
||||
JPanel createHeaderPane(Component... comps) { |
||||
JPanel headerPane = createHeaderLayoutPane(comps); |
||||
headerPane.setBorder(BorderFactory.createEmptyBorder(2, 12, 12, 0)); |
||||
return headerPane; |
||||
} |
||||
} |
After Width: | Height: | Size: 221 B |
After Width: | Height: | Size: 336 B |
@ -0,0 +1,94 @@
|
||||
package com.fr.design.mainframe.alphafine.cell.model; |
||||
|
||||
import com.fr.design.mainframe.alphafine.AlphaFineConstants; |
||||
import com.fr.design.mainframe.alphafine.CellType; |
||||
import com.fr.json.JSONException; |
||||
import com.fr.json.JSONObject; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
public class ModelTest { |
||||
@Test |
||||
public void documentModelTest() { |
||||
DocumentModel documentModel = new DocumentModel("name", "content", 1); |
||||
Assert.assertEquals("name", documentModel.getName()); |
||||
Assert.assertEquals("content", documentModel.getContent()); |
||||
Assert.assertEquals(1, documentModel.getDocumentId()); |
||||
Assert.assertEquals(AlphaFineConstants.DOCUMENT_DOC_URL + documentModel.getDocumentId() + ".html", documentModel.getDocumentUrl()); |
||||
Assert.assertEquals(AlphaFineConstants.DOCUMENT_INFORMATION_URL + documentModel.getDocumentId(), documentModel.getInformationUrl()); |
||||
Assert.assertEquals(documentModel.getStoreInformation(), documentModel.getInformationUrl()); |
||||
Assert.assertEquals(CellType.DOCUMENT, documentModel.getType()); |
||||
Assert.assertEquals(true, documentModel.hasAction()); |
||||
Assert.assertEquals(true, documentModel.isNeedToSendToServer()); |
||||
|
||||
documentModel.setDescription("test"); |
||||
Assert.assertEquals("test", documentModel.getDescription()); |
||||
|
||||
DocumentModel another = new DocumentModel("another", "another", 1); |
||||
documentModel.doAction(); |
||||
Assert.assertTrue(another.equals(documentModel)); |
||||
Assert.assertNotNull(documentModel.modelToJson()); |
||||
} |
||||
|
||||
@Test |
||||
public void bottomModelTest() { |
||||
BottomModel bottomModel = new BottomModel(); |
||||
Assert.assertEquals(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Internet_Forum"), bottomModel.getGoToWeb()); |
||||
Assert.assertEquals(CellType.BOTTOM, bottomModel.getType()); |
||||
try { |
||||
Assert.assertEquals(JSONObject.EMPTY, bottomModel.modelToJson()); |
||||
} catch (JSONException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
Assert.assertEquals(true, bottomModel.hasAction()); |
||||
bottomModel.doAction(); |
||||
|
||||
} |
||||
|
||||
@Test |
||||
public void fileModelTest() { |
||||
FileModel fileModel = new FileModel("name", "test\\\\"); |
||||
Assert.assertEquals(CellType.FILE, fileModel.getType()); |
||||
Assert.assertNotNull(fileModel.modelToJson()); |
||||
FileModel anotherFileModel = new FileModel("anotherFileModel", "test\\\\"); |
||||
Assert.assertTrue(anotherFileModel.equals(fileModel)); |
||||
} |
||||
|
||||
@Test |
||||
public void moreModelTest() { |
||||
MoreModel moreModel = new MoreModel("name"); |
||||
Assert.assertTrue(!moreModel.hasAction()); |
||||
Assert.assertTrue(!moreModel.isNeedToSendToServer()); |
||||
Assert.assertEquals(CellType.MORE, moreModel.getType()); |
||||
} |
||||
|
||||
@Test |
||||
public void noResultModelTest() { |
||||
NoResultModel noResultModel = new NoResultModel("test"); |
||||
Assert.assertTrue(!noResultModel.hasAction()); |
||||
Assert.assertTrue(!noResultModel.isNeedToSendToServer()); |
||||
Assert.assertEquals(CellType.NO_RESULT, noResultModel.getType()); |
||||
} |
||||
|
||||
@Test |
||||
public void pluginModelTest() { |
||||
PluginModel pluginModel = new PluginModel("name", "content", "url", "version", "jartime", "link", "pluginId", CellType.PLUGIN, 10000, 1); |
||||
Assert.assertTrue(pluginModel.hasAction()); |
||||
Assert.assertTrue(pluginModel.isNeedToSendToServer()); |
||||
Assert.assertEquals(CellType.PLUGIN, pluginModel.getType()); |
||||
Assert.assertNotNull(pluginModel.modelToJson()); |
||||
} |
||||
|
||||
@Test |
||||
public void robotModelTest(){ |
||||
RobotModel robotModel = new RobotModel("title","content"); |
||||
Assert.assertTrue(robotModel.hasAction()); |
||||
Assert.assertTrue(robotModel.isNeedToSendToServer()); |
||||
Assert.assertEquals(CellType.ROBOT, robotModel.getType()); |
||||
try { |
||||
Assert.assertNotNull(robotModel.modelToJson()); |
||||
} catch (JSONException e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,80 @@
|
||||
package com.fr.design.mainframe.alphafine.search.manager.impl; |
||||
|
||||
import com.fr.design.mainframe.alphafine.AlphaFineHelper; |
||||
import com.fr.design.mainframe.alphafine.CellType; |
||||
import com.fr.design.mainframe.alphafine.model.SearchResult; |
||||
import com.fr.json.JSONObject; |
||||
import org.junit.Assert; |
||||
import org.junit.Before; |
||||
import org.junit.Test; |
||||
|
||||
public class SearchManegerTest { |
||||
SimilarSearchManager similarSearchManager; |
||||
ComplementAdviceManager complementAdviceManager; |
||||
DocumentSearchManager documentSearchManager; |
||||
PluginSearchManager pluginSearchManager; |
||||
RecommendSearchManager recommendSearchManager; |
||||
RecentSearchManager recentSearchManager; |
||||
ActionSearchManager actionSearchManager; |
||||
FileSearchManager fileSearchManager; |
||||
SegmentationManager segmentationManager; |
||||
|
||||
@Before |
||||
public void setUp() { |
||||
recentSearchManager = RecentSearchManager.getInstance(); |
||||
recommendSearchManager = RecommendSearchManager.getInstance(); |
||||
similarSearchManager = SimilarSearchManager.getInstance(); |
||||
complementAdviceManager = ComplementAdviceManager.getInstance(); |
||||
documentSearchManager = DocumentSearchManager.getInstance(); |
||||
pluginSearchManager = PluginSearchManager.getInstance(); |
||||
actionSearchManager = ActionSearchManager.getInstance(); |
||||
fileSearchManager = FileSearchManager.getInstance(); |
||||
segmentationManager = SegmentationManager.getInstance(); |
||||
} |
||||
|
||||
@Test |
||||
public void getSearchResultTest() { |
||||
|
||||
//检测网络情况
|
||||
Assert.assertTrue(AlphaFineHelper.isNetworkOk()); |
||||
|
||||
//正常搜索情况
|
||||
SearchResult lessModelList; |
||||
lessModelList = recentSearchManager.getLessSearchResult(new String[]{"数据集"}); |
||||
Assert.assertNotNull(lessModelList); |
||||
|
||||
lessModelList = similarSearchManager.getLessSearchResult(new String[]{"数据集"}); |
||||
Assert.assertEquals(lessModelList.get(1).getType(), CellType.ROBOT); |
||||
|
||||
lessModelList = complementAdviceManager.getAllSearchResult(new String[]{"数据集"}); |
||||
Assert.assertEquals(lessModelList.get(1).getType(), CellType.ROBOT); |
||||
|
||||
//返回MoreSearchResult
|
||||
SearchResult moreModelList; |
||||
moreModelList = similarSearchManager.getMoreSearchResult("数据集"); |
||||
Assert.assertNotNull(moreModelList); |
||||
|
||||
moreModelList = recommendSearchManager.getMoreSearchResult("数据集"); |
||||
Assert.assertNotNull(moreModelList); |
||||
} |
||||
|
||||
@Test |
||||
public void getModelFromCloudTest() { |
||||
Assert.assertNotNull(SimilarSearchManager.getModelFromCloud(new JSONObject())); |
||||
Assert.assertNotNull(DocumentSearchManager.getModelFromCloud(new JSONObject())); |
||||
Assert.assertNotNull(PluginSearchManager.getModelFromCloud(new JSONObject())); |
||||
} |
||||
|
||||
@Test |
||||
public void isNeedSegmentationTest() { |
||||
Assert.assertEquals(segmentationManager.isNeedSegmentation("多维数据集"), true); |
||||
} |
||||
|
||||
@Test |
||||
public void startSegmentationTest() { |
||||
String[] result = {"结果报表", "结果", "报表"}; |
||||
Assert.assertEquals(segmentationManager.startSegmentation("结果报表"), result); |
||||
|
||||
} |
||||
|
||||
} |