Browse Source

表格编辑器

pull/1/head
richie 5 years ago
parent
commit
4c1fccba39
  1. 31
      src/main/java/com/fanruan/api/cal/ParameterKit.java
  2. 14
      src/main/java/com/fanruan/api/design/ui/component/UIDictionaryComboBox.java
  3. 19
      src/main/java/com/fanruan/api/design/ui/component/UIPasswordField.java
  4. 27
      src/main/java/com/fanruan/api/design/ui/component/UIPlaceholderTextField.java
  5. 20
      src/main/java/com/fanruan/api/design/ui/component/table/UITableEditorPane.java
  6. 3
      src/main/java/com/fanruan/api/design/ui/component/table/action/UITableEditAction.java
  7. 343
      src/main/java/com/fanruan/api/design/ui/component/table/model/ParameterTableModel.java
  8. 61
      src/main/java/com/fanruan/api/design/ui/component/table/model/UITableModelAdapter.java
  9. 482
      src/main/java/com/fanruan/api/design/ui/editor/ValueEditors.java
  10. 4
      src/main/java/com/fanruan/api/design/util/I18nDesignKit.java

31
src/main/java/com/fanruan/api/cal/ParameterKit.java

@ -1,8 +1,8 @@
package com.fanruan.api.cal; package com.fanruan.api.cal;
import com.fr.base.Parameter;
import com.fr.base.ParameterHelper; import com.fr.base.ParameterHelper;
import com.fr.base.ParameterMapNameSpace; import com.fr.base.ParameterMapNameSpace;
import com.fr.script.CalculatorMap;
import com.fr.stable.ParameterProvider; import com.fr.stable.ParameterProvider;
import com.fr.stable.script.NameSpace; import com.fr.stable.script.NameSpace;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -15,17 +15,41 @@ import java.util.Map;
* Created by richie on 2019-08-16 * Created by richie on 2019-08-16
* 参数相关的工具类 * 参数相关的工具类
*/ */
public class ParameterKit{ public class ParameterKit {
/**
* 创建一个参数对象实例
*
* @return 参数对象
*/
public static ParameterProvider newParameter() {
return new Parameter();
}
/**
* 创建一个参数对象实例
*
* @param name 参数名
* @param value 参数值
* @return 参数对象
*/
public static ParameterProvider newParameter(String name, Object value) {
return new Parameter(name, value);
}
/** /**
* 分析公式中所携带的参数 * 分析公式中所携带的参数
*
* @param text 公式内容 * @param text 公式内容
* @return 参数数组 * @return 参数数组
*/ */
public static @NotNull ParameterProvider[] analyze4ParametersFromFormula(String text) { public static @NotNull ParameterProvider[] analyze4ParametersFromFormula(String text) {
return ParameterHelper.analyze4ParametersFromFormula(text); return ParameterHelper.analyze4ParametersFromFormula(text);
} }
/** /**
* 分析一组字符串中的参数 * 分析一组字符串中的参数
*
* @param paramTexts 字符串组 * @param paramTexts 字符串组
* @param isFormula 是否是公式类型的字符串数组 * @param isFormula 是否是公式类型的字符串数组
* @return 参数集合 * @return 参数集合
@ -36,14 +60,17 @@ public class ParameterKit{
/** /**
* 创建一个用于计算的参数对名字空间 * 创建一个用于计算的参数对名字空间
*
* @param map 参数键值对 * @param map 参数键值对
* @return 名字空间用于传递给算子做计算 * @return 名字空间用于传递给算子做计算
*/ */
public static @NotNull NameSpace createParameterMapNameSpace(Map<String, Object> map) { public static @NotNull NameSpace createParameterMapNameSpace(Map<String, Object> map) {
return ParameterMapNameSpace.create(map); return ParameterMapNameSpace.create(map);
} }
/** /**
* 创建一个用于计算的参数对名字空间 * 创建一个用于计算的参数对名字空间
*
* @param ps ParameterProvider的数组 * @param ps ParameterProvider的数组
* @return 名字空间用于传递给算子做计算 * @return 名字空间用于传递给算子做计算
*/ */

14
src/main/java/com/fanruan/api/design/ui/component/UIDictionaryComboBox.java

@ -0,0 +1,14 @@
package com.fanruan.api.design.ui.component;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-08-28
* 带字典数据的下拉框显示值和实际值通过字典进行对应
*/
public class UIDictionaryComboBox<T> extends com.fr.design.gui.icombobox.UIDictionaryComboBox<T> {
public UIDictionaryComboBox(T[] keys, String[] values) {
super(keys, values);
}
}

19
src/main/java/com/fanruan/api/design/ui/component/UIPasswordField.java

@ -0,0 +1,19 @@
package com.fanruan.api.design.ui.component;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-08-28
* 密码输入控件
*/
public class UIPasswordField extends com.fr.design.gui.ipasswordfield.UIPassWordField {
public UIPasswordField() {
super();
}
public UIPasswordField(String text) {
super(text);
}
}

27
src/main/java/com/fanruan/api/design/ui/component/UIPlaceholderTextField.java

@ -0,0 +1,27 @@
package com.fanruan.api.design.ui.component;
import com.fr.design.gui.itextfield.PlaceholderTextField;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-08-28
* 带占位文本的文本编辑器当没有输入文本的时候会显示占位符
*/
public class UIPlaceholderTextField extends PlaceholderTextField {
public UIPlaceholderTextField() {
super();
}
public UIPlaceholderTextField(String placeHolder) {
super();
setPlaceholder(placeHolder);
}
public UIPlaceholderTextField(String text, String placeHolder) {
super(text);
setPlaceholder(placeHolder);
}
}

20
src/main/java/com/fanruan/api/design/ui/component/table/UITableEditorPane.java

@ -0,0 +1,20 @@
package com.fanruan.api.design.ui.component.table;
import com.fanruan.api.design.ui.component.table.model.UITableModelAdapter;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-08-28
*/
public class UITableEditorPane<T> extends com.fr.design.gui.itableeditorpane.UITableEditorPane<T> {
public UITableEditorPane(UITableModelAdapter<T> adapter) {
super(adapter);
}
public UITableEditorPane(UITableModelAdapter<T> adapter, String leftLabelName) {
super(adapter, leftLabelName);
}
}

3
src/main/java/com/fanruan/api/design/ui/component/table/action/UITableEditAction.java

@ -2,7 +2,8 @@ package com.fanruan.api.design.ui.component.table.action;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
public class UITableEditAction extends com.fr.design.gui.itableeditorpane.UITableEditAction{ public class UITableEditAction extends com.fr.design.gui.itableeditorpane.UITableEditAction {
@Override @Override
public void checkEnabled() { public void checkEnabled() {
} }

343
src/main/java/com/fanruan/api/design/ui/component/table/model/ParameterTableModel.java

@ -1,28 +1,361 @@
package com.fanruan.api.design.ui.component.table.model; package com.fanruan.api.design.ui.component.table.model;
import com.fanruan.api.cal.ParameterKit;
import com.fanruan.api.design.ui.component.UILabel;
import com.fanruan.api.design.ui.component.UITextField;
import com.fanruan.api.design.ui.component.table.action.UITableEditAction;
import com.fanruan.api.design.ui.editor.ValueEditorPane; import com.fanruan.api.design.ui.editor.ValueEditorPane;
import com.fanruan.api.design.ui.editor.ValueEditors;
import com.fanruan.api.design.util.I18nDesignKit;
import com.fanruan.api.log.LogKit;
import com.fanruan.api.util.IOKit;
import com.fanruan.api.util.StringKit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.stable.ParameterProvider;
import javax.swing.*;
import javax.swing.event.CellEditorListener;
import javax.swing.event.ChangeEvent;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellEditor;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent;
import java.util.Collections;
/** /**
* 表格模型 * 表格模型
*/ */
public class ParameterTableModel extends com.fr.design.gui.itableeditorpane.ParameterTableModel { public class ParameterTableModel extends UITableModelAdapter<ParameterProvider> {
public static final int NO_CHART_USE = 0;
public static final int CHART_NORMAL_USE = 1;
public static final int FORM_NORMAL_USE = -1;
private static final long serialVersionUID = 1L;
protected Component component = null;
public ParameterTableModel() { public ParameterTableModel() {
super(); this(NO_CHART_USE);
} }
public ParameterTableModel(int paraUseType) { public ParameterTableModel(int paraUseType) {
super(paraUseType); super(new String[]{I18nDesignKit.i18nText("Fine-Design_Basic_Parameter"), I18nDesignKit.i18nText("Fine-Design_Basic_Value")});
this.setColumnClass(new Class[]{ParameterEditor.class, ParameterValueEditor.class});
this.setDefaultEditor(ParameterValueEditor.class, new ParameterValueEditor(paraUseType));
this.setDefaultEditor(ParameterEditor.class, new ParameterEditor());
this.setDefaultRenderer(ParameterValueEditor.class, new ParameterValueRenderer(paraUseType));
} }
public ParameterTableModel(int paraUseType, Component component) { public ParameterTableModel(int paraUseType, Component component) {
super(paraUseType, component); super(new String[]{I18nDesignKit.i18nText("Fine-Design_Basic_Parameter"), I18nDesignKit.i18nText("Fine-Design_Basic_Value")});
this.setColumnClass(new Class[]{ParameterEditor.class, ParameterValueEditor.class});
this.setDefaultEditor(ParameterValueEditor.class, new ParameterValueEditor(paraUseType));
this.setDefaultEditor(ParameterEditor.class, new ParameterEditor());
this.setDefaultRenderer(ParameterValueEditor.class, new ParameterValueRenderer(paraUseType));
this.component = component;
} }
public ParameterTableModel(ValueEditorPane valueEditorPane, ValueEditorPane valueRenderPane, Component component) { public ParameterTableModel(ValueEditorPane valueEditorPane, ValueEditorPane valueRenderPane, Component component) {
super(valueEditorPane, valueRenderPane, component); super(new String[]{I18nDesignKit.i18nText("Fine-Design_Basic_Parameter"), I18nDesignKit.i18nText("Fine-Design_Basic_Value")});
this.setColumnClass(new Class[]{ParameterEditor.class, ParameterValueEditor.class});
this.setDefaultEditor(ParameterValueEditor.class, new ParameterValueEditor(valueEditorPane));
this.setDefaultEditor(ParameterEditor.class, new ParameterEditor());
this.setDefaultRenderer(ParameterValueEditor.class, new ParameterValueRenderer(valueRenderPane));
this.component = component;
}
/**
* 单元格是否可编辑
*
* @param row
* @param col
* @return 是否可以编辑
*/
public boolean isCellEditable(int row, int col) {
if (col == 1) {
return this.getList().get(row) != null && StringKit.isNotEmpty(this.getList().get(row).getName());
}
return true;
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
ParameterProvider para = this.getList().get(rowIndex);
switch (columnIndex) {
case 0:
return para.getName();
case 1:
return para.getValue();
}
return null;
}
/**
* 生成工具栏上的一系列动作按钮
*
* @return 返回table上的action数组.
*/
@Override
public UITableEditAction[] createAction() {
return new UITableEditAction[]{new AddParameterAction(), new DeleteAction(), new MoveUpAction(), new MoveDownAction()};
}
/**
* 生成上移下移按钮
*
* @return UItableEdit数组.
*/
public UITableEditAction[] createDBTableAction() {
return new UITableEditAction[]{new MoveUpAction(), new MoveDownAction()};
}
private class AddParameterAction extends AddTableRowAction {
public AddParameterAction() {
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
addParameter();
}
}
private void addParameter() {
ParameterProvider para = ParameterKit.newParameter();
addRow(para);
fireTableDataChanged();
table.getSelectionModel().setSelectionInterval(table.getRowCount() - 1, table.getRowCount() - 1);
}
protected class DeleteAction extends UITableEditAction {
private Component component = null;
public DeleteAction() {
this.setName(I18nDesignKit.i18nText("Fine-Design_Report_Delete"));
this.setSmallIcon(IOKit.readIcon("/com/fr/base/images/cell/control/remove.png"));
}
public DeleteAction(Component component) {
this.setName(I18nDesignKit.i18nText("Fine-Design_Report_Delete"));
this.setSmallIcon(IOKit.readIcon("/com/fr/base/images/cell/control/remove.png"));
this.component = component;
}
@Override
public void actionPerformed(ActionEvent e) {
int[] selectedRow = table.getSelectedRows();
if (isMultiSelected()) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), I18nDesignKit.i18nText("Fine-Design_Basic_Multiple_Select_Warn_Text"));
return;
}
if (table.getCellEditor() != null) {
try {
table.getCellEditor().stopCellEditing();
} catch (Exception ee) {
LogKit.error(ee.getMessage(), ee);
}
}
if (getRowCount() < 1) {
return;
}
if (component == null) {
component = DesignerContext.getDesignerFrame();
}
int val = JOptionPane.showConfirmDialog(component,
I18nDesignKit.i18nText("Fine-Design_Basic_Utils_Are_You_Sure_To_Remove_The_Selected_Item") + "?", I18nDesignKit.i18nText("Fine-Design_Basic_Remove"),
JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE);
if (val != JOptionPane.OK_OPTION) {
return;
}
for (int i = 0; i < selectedRow.length; i++) {
if (selectedRow[i] - i < 0) {
continue;
}
removeRow(selectedRow[i] - i);
}
fireTableDataChanged();
int selection = selectedRow[0] > table.getRowCount() ? table.getRowCount() - 1
: (selectedRow[0] > 1 ? selectedRow[0] - 1 : 0);
table.getSelectionModel().setSelectionInterval(selection, selection);
}
private boolean isMultiSelected() {
int[] selectedRow = table.getSelectedRows();
return (selectedRow.length == 1 && (selectedRow[0] > table.getRowCount() - 1 || selectedRow[0] < 0)) || selectedRow.length == 0;
}
@Override
public void checkEnabled() {
setEnabled(!isMultiSelected());
}
}
protected class MoveUpAction extends UITableEditAction {
public MoveUpAction() {
this.setName(I18nDesignKit.i18nText("Fine-Design_Basic_Utils_Move_Up"));
this.setSmallIcon(IOKit.readIcon("/com/fr/design/images/control/up.png"));
}
@Override
public void actionPerformed(ActionEvent e) {
int selectedRow = table.getSelectedRow();
stopCellEditing();
if (getList().size() < 2 || selectedRow == 0) {
return;
}
Collections.swap(getList(), selectedRow, selectedRow - 1);
fireTableDataChanged();
table.getSelectionModel().setSelectionInterval(selectedRow - 1, selectedRow - 1);
}
@Override
public void checkEnabled() {
} }
}
protected class MoveDownAction extends UITableEditAction {
public MoveDownAction() {
this.setName(I18nDesignKit.i18nText("Fine-Design_Basic_Utils_Move_Down"));
this.setSmallIcon(IOKit.readIcon("/com/fr/design/images/control/down.png"));
}
@Override
public void actionPerformed(ActionEvent e) {
int selectedRow = table.getSelectedRow();
stopCellEditing();
if (getList().size() < 2 || selectedRow == getRowCount() - 1) {
return;
}
Collections.swap(getList(), selectedRow, selectedRow + 1);
fireTableDataChanged();
table.getSelectionModel().setSelectionInterval(selectedRow + 1, selectedRow + 1);
}
@Override
public void checkEnabled() {
}
}
public class ParameterEditor extends AbstractCellEditor implements TableCellEditor {
private UITextField textField;
public ParameterEditor() {
textField = new UITextField();
this.addCellEditorListener(new CellEditorListener() {
@Override
public void editingCanceled(ChangeEvent e) {
}
@Override
public void editingStopped(ChangeEvent e) {
if (table.getSelectedRow() == -1) {
return;
}
ParameterProvider para = getList().get(table.getSelectedRow());
String value = StringKit.trimToNull(textField.getText());
para.setName(value);
fireTableDataChanged();
}
});
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
textField.setText((String) value);
return textField;
}
@Override
public Object getCellEditorValue() {
return textField.getText();
}
}
private class ParameterValueEditor extends AbstractCellEditor implements TableCellEditor {
private static final long serialVersionUID = 1L;
private ValueEditorPane editor;
public ParameterValueEditor(int paraUseType) {
this(ValueEditors.createValueEditorPaneWithUseType(paraUseType));
}
public ParameterValueEditor(ValueEditorPane valueEditorPane) {
editor = valueEditorPane;
this.addCellEditorListener(new CellEditorListener() {
@Override
public void editingCanceled(ChangeEvent e) {
}
@Override
public void editingStopped(ChangeEvent e) {
if (table.getSelectedRow() == -1) {
return;
}
ParameterProvider para = getList().get(table.getSelectedRow());
para.setValue(getCellEditorValue());
fireTableDataChanged();
}
});
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
editor.populate(value == null ? StringKit.EMPTY : value);
return editor;
}
@Override
public Object getCellEditorValue() {
return editor.update();
}
}
private class ParameterValueRenderer extends DefaultTableCellRenderer {
private static final long serialVersionUID = 1L;
private ValueEditorPane editor;
private UILabel disableLabel;
public ParameterValueRenderer(int paraUseType) {
this(ValueEditors.createValueEditorPaneWithUseType(paraUseType));
}
public ParameterValueRenderer(ValueEditorPane valueEditorPane) {
disableLabel = new UILabel(I18nDesignKit.i18nText("Fine-Design_Basic_Set_Paramete_Name"));
disableLabel.setForeground(Color.pink);
disableLabel.setHorizontalAlignment(SwingConstants.CENTER);
editor = valueEditorPane;
}
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (table.isCellEditable(row, column)) {
if (value == null) {
editor.populate(StringKit.EMPTY);
} else {
editor.populate(value);
}
return editor;
} else {
return disableLabel;
}
}
}
} }

61
src/main/java/com/fanruan/api/design/ui/component/table/model/UITableModelAdapter.java

@ -0,0 +1,61 @@
package com.fanruan.api.design.ui.component.table.model;
import com.fanruan.api.design.ui.component.table.action.UITableEditAction;
import com.fanruan.api.design.util.I18nDesignKit;
import com.fanruan.api.util.IOKit;
import com.fr.design.mainframe.DesignerContext;
import javax.swing.*;
import java.awt.event.ActionEvent;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-08-28
*/
public abstract class UITableModelAdapter<T> extends com.fr.design.gui.itableeditorpane.UITableModelAdapter<T> {
protected UITableModelAdapter(String[] strings) {
super(strings);
}
public abstract UITableEditAction[] createAction();
protected abstract class AddTableRowAction extends UITableEditAction {
public AddTableRowAction() {
this.setName(I18nDesignKit.i18nText("Fine-Design_Report_Insert"));
this.setSmallIcon(IOKit.readIcon("/com/fr/base/images/cell/control/add.png"));
}
@Override
public void actionPerformed(ActionEvent e) {
stopCellEditing();
}
public void checkEnabled() {
}
}
protected abstract class EditAction extends UITableEditAction {
public EditAction() {
this.setName(I18nDesignKit.i18nText("Fine-Design_Report_Edit"));
this.setSmallIcon(IOKit.readIcon("/com/fr/design/images/control/edit.png"));
}
@Override
public void actionPerformed(ActionEvent e) {
final int selectedRow = table.getSelectedRow();
if (selectedRow > table.getRowCount() - 1 || selectedRow < 0) {
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), I18nDesignKit.i18nText("Fine-Design_Basic_No-Alternatives"));
return;
}
stopCellEditing();
}
}
}

482
src/main/java/com/fanruan/api/design/ui/editor/ValueEditors.java

@ -0,0 +1,482 @@
package com.fanruan.api.design.ui.editor;
import com.fanruan.api.design.ui.component.table.model.ParameterTableModel;
import com.fanruan.api.design.util.I18nDesignKit;
import com.fanruan.api.util.StringKit;
import com.fr.base.BaseFormula;
import com.fr.design.editor.editor.BooleanEditor;
import com.fr.design.editor.editor.ColumnRowEditor;
import com.fr.design.editor.editor.ColumnRowGroupEditor;
import com.fr.design.editor.editor.ColumnSelectedEditor;
import com.fr.design.editor.editor.ConstantsEditor;
import com.fr.design.editor.editor.CursorEditor;
import com.fr.design.editor.editor.DateEditor;
import com.fr.design.editor.editor.DoubleEditor;
import com.fr.design.editor.editor.Editor;
import com.fr.design.editor.editor.FormulaEditor;
import com.fr.design.editor.editor.IntegerEditor;
import com.fr.design.editor.editor.NoneEditor;
import com.fr.design.editor.editor.ParameterEditor;
import com.fr.design.editor.editor.SpinnerIntegerEditor;
import com.fr.design.editor.editor.TextEditor;
import com.fr.design.editor.editor.WidgetNameEditor;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-08-28
* 工厂类创建多种组合编辑器
*/
public class ValueEditors {
/**
* 创建带编辑器的ValueEditorPane
*
* @param editors 自定义的编辑器
* @return 返回pane
*/
public static ValueEditorPane createValueEditorPane(Editor<?>[] editors) {
return createValueEditorPane(editors, StringKit.EMPTY, StringKit.EMPTY);
}
/**
* 创建编辑器 名称 弹出的ValueEditorPane
*
* @param editors 编辑器
* @param popupName 弹出的名字
* @param textEditorValue
* @return 返回pane
*/
public static ValueEditorPane createValueEditorPane(Editor<?>[] editors, String popupName, String textEditorValue) {
return new ValueEditorPane(editors, popupName, textEditorValue);
}
/**
* 创建编辑器 名称 弹出的ValueEditorPane
*
* @param editors 编辑器
* @param popupName 弹出的名字
* @param textEditorValue
* @param editor_center_width 编辑器主体的宽度
* @return 返回pane
*/
public static ValueEditorPane createValueEditorPane(Editor<?>[] editors, String popupName, String textEditorValue, int editor_center_width) {
return new ValueEditorPane(editors, popupName, textEditorValue, editor_center_width);
}
/**
* 创建基本的值编辑器面板
*
* @return 返回值编辑器面板
*/
public static ValueEditorPane createBasicValueEditorPane() {
return createValueEditorPane(basicEditors(), StringKit.EMPTY, StringKit.EMPTY);
}
/**
* 创建公式编辑器面板
*
* @return 返回公式编辑器面板
*/
public static ValueEditorPane createFormulaValueEditorPane() {
return createValueEditorPane(new Editor[]{new FormulaEditor(I18nDesignKit.i18nText("Fine-Design_Basic_Parameter_Formula"))},
StringKit.EMPTY, StringKit.EMPTY);
}
/**
* 创建基本的值编辑器面板
*
* @param editor_center_width 指定值编辑器的主体宽度
* @return 返回值编辑器面板
*/
public static ValueEditorPane createBasicValueEditorPane(int editor_center_width) {
return createValueEditorPane(basicEditors(), StringKit.EMPTY, StringKit.EMPTY, editor_center_width);
}
/**
* Process用的editorPane
*
* @return 值编辑器面板
*/
public static ValueEditorPane createFormEditorPane() {
return createValueEditorPane(formEditors(), StringKit.EMPTY, StringKit.EMPTY);
}
/**
* StoreProced用的EditorPane
*
* @return 值编辑器面板
*/
public static ValueEditorPane createStoreProcedValueEditorPane() {
return createValueEditorPane(StoreProcedureEditors(), StringKit.EMPTY, StringKit.EMPTY);
}
/**
* 扩展的ValueEditorPane
*
* @return 值编辑器面板
*/
public static ValueEditorPane createExtendedValueEditorPane() {
return createValueEditorPane(extendedEditors(), StringKit.EMPTY, StringKit.EMPTY);
}
/**
* URL使用的ValueEditorPane
*
* @param popupName 弹出的名字
* @param textEditorValue 编辑器值
* @return 值编辑器返回
*/
public static ValueEditorPane createURLValueEditorPane(String popupName, String textEditorValue) {
return createValueEditorPane(URLEditors(popupName, textEditorValue), StringKit.EMPTY, StringKit.EMPTY);
}
/**
* 创建日期的ValueEditorPane
*
* @param popupName 名字
* @param textEditorValue
* @return 值编辑器面板
*/
public static ValueEditorPane createDateValueEditorPane(String popupName, String textEditorValue) {
return createValueEditorPane(dateEditors(popupName, textEditorValue), StringKit.EMPTY, StringKit.EMPTY);
}
/**
* 带有所有编辑器的ValueEditorPane
*
* @return 值编辑器面板
*/
public static ValueEditorPane createAllValueEditorPane() {
return createValueEditorPane(allEditors(), StringKit.EMPTY, StringKit.EMPTY);
}
/**
* 创建不带公式面板的pane
*
* @return 编辑器面板
*/
public static ValueEditorPane createBasicEditorWithoutFormulaPane() {
return createValueEditorPane(basicEditorsWithoutFormula(), StringKit.EMPTY, StringKit.EMPTY);
}
/**
* 创建NoCRNoColumn
*
* @return 值编辑器
*/
public static ValueEditorPane createNoCRNoColumnValueEditorPane() {
return createValueEditorPane(noCRnoColumnEditors(), StringKit.EMPTY, StringKit.EMPTY);
}
/**
* 创建数值编辑器
*
* @return 值编辑器
*/
public static ValueEditorPane createNumberValueEditorPane() {
return createValueEditorPane(numberEditors(), StringKit.EMPTY, StringKit.EMPTY);
}
/**
* 创建日期编辑器
*
* @return 值编辑器
*/
public static ValueEditorPane createDateValueEditorPane() {
return createValueEditorPane(dateEditors(), StringKit.EMPTY, StringKit.EMPTY);
}
/**
* 根据参数paraUseType 创建编辑器类型.
*
* @param paraUseType 参数类型
* @return 值编辑器
*/
public static ValueEditorPane createValueEditorPaneWithUseType(int paraUseType) {
return createValueEditorPaneWithUseType(paraUseType, null);
}
public static ValueEditorPane createValueEditorPaneWithUseType(int paraUseType, HashMap hyperLinkEditorMap) {
if (paraUseType == ParameterTableModel.NO_CHART_USE) {
return createBasicValueEditorPane();
} else if (paraUseType == ParameterTableModel.FORM_NORMAL_USE) {
return createFormEditorPane();
} else {
return createChartHotValueEditorPane(hyperLinkEditorMap);
}
}
/**
* 图表用的参数编辑器的ValueEditorPane
*
* @param hyperLinkEditorMap 超链下拉参数类型
* @return 值编辑器
*/
public static ValueEditorPane createChartHotValueEditorPane(HashMap hyperLinkEditorMap) {
return createValueEditorPane(chartHotEditors(hyperLinkEditorMap), StringKit.EMPTY, StringKit.EMPTY);
}
/**
* 基础的一些ValueEditorPane所用到的Editors
*
* @return 值编辑器
*/
public static Editor<?>[] basicEditors() {
FormulaEditor formulaEditor = new FormulaEditor(I18nDesignKit.i18nText("Fine-Design_Basic_Parameter_Formula"));
return new Editor[]{
new TextEditor(),
new SpinnerIntegerEditor(),
new DoubleEditor(),
new DateEditor(true, I18nDesignKit.i18nText("Fine-Design_Basic_Date")),
new BooleanEditor(),
formulaEditor
};
}
/**
* 表单的一些编辑器.
*
* @return 值编辑器
*/
public static Editor<?>[] formEditors() {
FormulaEditor formulaEditor = new FormulaEditor(I18nDesignKit.i18nText("Fine-Design_Basic_Parameter_Formula"));
return new Editor[]{
new TextEditor(),
new IntegerEditor(),
new DoubleEditor(),
new DateEditor(true, I18nDesignKit.i18nText("Fine-Design_Basic_Date")),
new BooleanEditor(),
formulaEditor,
new WidgetNameEditor(I18nDesignKit.i18nText("Fine-Design_Report_Widget"))
};
}
/**
* 扩展单元格的一些编辑器
*
* @return 值编辑器
*/
public static Editor<?>[] extendedEditors() {
FormulaEditor formulaEditor = new FormulaEditor(I18nDesignKit.i18nText("Fine-Design_Basic_Parameter_Formula"));
return new Editor[]{
new TextEditor(),
new IntegerEditor(),
new DoubleEditor(),
new DateEditor(true, I18nDesignKit.i18nText("Fine-Design_Basic_Date")),
new BooleanEditor(),
formulaEditor,
new ParameterEditor(),
new ColumnRowEditor(I18nDesignKit.i18nText("Fine-Design_Basic_Cell"))
};
}
/**
* 带单元格组的编辑器
*
* @return 值编辑器
*/
public static Editor<?>[] extendedCellGroupEditors() {
FormulaEditor formulaEditor = new FormulaEditor(I18nDesignKit.i18nText("Fine-Design_Basic_Parameter_Formula"));
return new Editor[]{
new TextEditor(),
new IntegerEditor(),
new DoubleEditor(),
new DateEditor(true, I18nDesignKit.i18nText("Fine-Design_Basic_Date")),
new BooleanEditor(),
formulaEditor,
new ParameterEditor(),
new ColumnRowEditor(I18nDesignKit.i18nText("Fine-Design_Basic_Cell")),
new ColumnRowGroupEditor(I18nDesignKit.i18nText("Fine-Design_Basic_Cell_Group"))
};
}
/**
* 只有单元格和单元格组的编辑器
*
* @return 编辑器b
*/
public static Editor<?>[] cellGroupEditor() {
return new Editor[]{
new ColumnRowEditor(I18nDesignKit.i18nText("Fine-Design_Basic_Cell")),
new ColumnRowGroupEditor(I18nDesignKit.i18nText("Fine-Design_Basic_Cell_Group"))
};
}
/**
* URL的一些编辑器.
*
* @param popupName 名字
* @param textEditorValue
* @return 值编辑器
*/
public static Editor<?>[] URLEditors(String popupName, String textEditorValue) {
return new Editor[]{
new NoneEditor(textEditorValue, StringKit.isEmpty(popupName) ? I18nDesignKit.i18nText("Fine-Design_Basic_None") : popupName),
new TextEditor()
};
}
/**
* 日期类型的一些编辑器
*
* @param popupName 名字
* @param textEditorValue
* @return 值编辑器
*/
public static Editor<?>[] dateEditors(String popupName, String textEditorValue) {
return new Editor[]{
new NoneEditor(textEditorValue, StringKit.isEmpty(popupName) ? I18nDesignKit.i18nText("Fine-Design_Basic_None") : popupName),
new DateEditor(true, I18nDesignKit.i18nText("Fine-Design_Basic_Date")),
new FormulaEditor(I18nDesignKit.i18nText("Fine-Design_Basic_Parameter_Formula"))
};
}
/**
* 所有类型的编辑器
*
* @return 值编辑器
*/
public static Editor<?>[] allEditors() {
FormulaEditor formulaEditor = new FormulaEditor(I18nDesignKit.i18nText("Fine-Design_Basic_Parameter_Formula"));
return new Editor[]{
new TextEditor(),
new IntegerEditor(),
new DoubleEditor(),
new DateEditor(true, I18nDesignKit.i18nText("Fine-Design_Basic_Date")),
new BooleanEditor(),
formulaEditor,
new ParameterEditor(),
new ColumnRowEditor(I18nDesignKit.i18nText("Fine-Design_Basic_Cell")),
new ColumnSelectedEditor(),
};
}
/**
* 不带公式编辑器
*
* @return 编辑器不带公式
*/
public static Editor<?>[] basicEditorsWithoutFormula() {
return new Editor[]{
new TextEditor(),
new IntegerEditor(),
new DoubleEditor(),
new DateEditor(true, I18nDesignKit.i18nText("Fine-Design_Basic_Date")),
new BooleanEditor(),
};
}
/**
* noCRnoColumn编辑器
*
* @return 编辑器
*/
public static Editor<?>[] noCRnoColumnEditors() {
FormulaEditor formulaEditor = new FormulaEditor(I18nDesignKit.i18nText("Fine-Design_Basic_Parameter_Formula"));
return new Editor[]{
new TextEditor(),
new IntegerEditor(),
new DoubleEditor(),
new DateEditor(true, I18nDesignKit.i18nText("Fine-Design_Basic_Date")),
new BooleanEditor(),
formulaEditor,
new ParameterEditor(),
};
}
/**
* 数值编辑器
*
* @return 编辑器
*/
public static Editor<?>[] numberEditors() {
FormulaEditor formulaEditor = new FormulaEditor(I18nDesignKit.i18nText("Fine-Design_Basic_Parameter_Formula"));
return new Editor[]{
new IntegerEditor(),
new DoubleEditor(),
formulaEditor,
new ParameterEditor(),
};
}
/**
* 日期编辑器
*
* @return 编辑器
*/
public static Editor<?>[] dateEditors() {
FormulaEditor formulaEditor = new FormulaEditor(I18nDesignKit.i18nText("Fine-Design_Basic_Parameter_Formula"));
return new Editor[]{
new DateEditor(true, I18nDesignKit.i18nText("Fine-Design_Basic_Date")),
formulaEditor,
new ParameterEditor(),
};
}
/**
* 存储的一些编辑器
*
* @return 存储过程的编辑器
*/
public static Editor<?>[] StoreProcedureEditors() {
FormulaEditor formulaEditor = new FormulaEditor(I18nDesignKit.i18nText("Fine-Design_Basic_Parameter_Formula"));
formulaEditor.setEnabled(true);
return new Editor[]{
new CursorEditor(),
new TextEditor(),
new IntegerEditor(),
new DoubleEditor(),
new DateEditor(true, I18nDesignKit.i18nText("Fine-Design_Basic_Date")),
new BooleanEditor(),
formulaEditor
};
}
/**
* 图表热点的一些编辑器
*
* @return 值编辑器
*/
public static Editor[] chartHotEditors(HashMap hyperLinkEditorMap) {
List<Editor> list = createEditors4Chart(hyperLinkEditorMap);
list.add(new TextEditor());
list.add(new IntegerEditor());
list.add(new DoubleEditor());
list.add(new DateEditor(true, I18nDesignKit.i18nText("Fine-Design_Basic_Date")));
list.add(new BooleanEditor());
FormulaEditor formulaEditor = new FormulaEditor(I18nDesignKit.i18nText("Fine-Design_Basic_Parameter_Formula"));
formulaEditor.setEnabled(true);
list.add(formulaEditor);
return list.toArray(new Editor[0]);
}
/**
* 为图表创建编辑器.
*
* @return 值编辑器
*/
private static List<Editor> createEditors4Chart(HashMap hyperLinkEditorMap) {
List<Editor> lists = new ArrayList<>();
if (hyperLinkEditorMap == null) {
return lists;
}
Iterator<Map.Entry<String, BaseFormula>> entries = hyperLinkEditorMap.entrySet().iterator();
while (entries.hasNext()) {
Map.Entry<String, BaseFormula> entry = entries.next();
ConstantsEditor editor = new ConstantsEditor(entry.getKey(), entry.getValue());
editor.setEnabled(false);
lists.add(editor);
}
return lists;
}
}

4
src/main/java/com/fanruan/api/design/util/I18nDesignKit.java

@ -15,7 +15,7 @@ public class I18nDesignKit {
* @param key 国际化键 * @param key 国际化键
* @return 国际化后的值 * @return 国际化后的值
*/ */
public String i18nText(String key) { public static String i18nText(String key) {
return Toolkit.i18nText(key); return Toolkit.i18nText(key);
} }
@ -25,7 +25,7 @@ public class I18nDesignKit {
* @param args 参数 * @param args 参数
* @return 国际化后的值 * @return 国际化后的值
*/ */
public String i18nText(String key, Object... args) { public static String i18nText(String key, Object... args) {
return Toolkit.i18nText(key, args); return Toolkit.i18nText(key, args);
} }
} }

Loading…
Cancel
Save