Browse Source

支撑新的消息滚动插件

master
richie 5 years ago
parent
commit
7726f974c3
  1. 18
      src/main/java/com/fanruan/api/design/err/ValidationException.java
  2. 92
      src/main/java/com/fanruan/api/design/work/form/editor/BaseComboEditor.java
  3. 47
      src/main/java/com/fanruan/api/design/work/form/editor/BasePropertyEditor.java
  4. 14
      src/main/java/com/fanruan/api/design/work/form/editor/StringEditor.java
  5. 65
      src/main/java/com/fanruan/api/design/work/form/editor/impl/StringEditor.java
  6. 2
      src/main/java/com/fanruan/api/design/work/form/editor/impl/WidgetValueEditor.java
  7. 7
      src/main/java/com/fanruan/api/err/ValidationException.java
  8. 36
      src/main/java/com/fanruan/api/generic/adapter/BasePropertyChangeAdapter.java
  9. 11
      src/main/java/com/fanruan/api/report/StyleKit.java

18
src/main/java/com/fanruan/api/design/err/ValidationException.java

@ -0,0 +1,18 @@
package com.fanruan.api.design.err;
/**
* @author richie
* @version 10.0
* Created by richie on 2019/9/26
* 用于标识设计器中控件值校验时发生的异常
*/
public class ValidationException extends com.fr.design.Exception.ValidationException {
public ValidationException() {
super();
}
public ValidationException(String message) {
super(message);
}
}

92
src/main/java/com/fanruan/api/design/work/form/editor/BaseComboEditor.java

@ -0,0 +1,92 @@
package com.fanruan.api.design.work.form.editor;
import com.fanruan.api.design.err.ValidationException;
import com.fanruan.api.design.ui.component.UIComboBox;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Vector;
/**
* @author richie
* @version 10.0
* Created by richie on 2019/10/30
* 通过下拉框选择特定值的编辑器
*/
public abstract class BaseComboEditor<T> extends BasePropertyEditor {
private UIComboBox<T> comboBox;
public BaseComboEditor() {
comboBox = new UIComboBox<>();
initComboBoxLookAndFeel();
ComboBoxModel<T> model = model();
if (model != null) {
comboBox.setModel(model);
}
ListCellRenderer cellRenderer = renderer();
if (cellRenderer != null) {
comboBox.setRenderer(cellRenderer);
}
}
public BaseComboEditor(T[] items) {
this(new UIComboBox<>(items));
}
public BaseComboEditor(Vector<T> items) {
this(new UIComboBox<>(items));
}
public BaseComboEditor(ComboBoxModel<T> model) {
this(new UIComboBox<>(model));
}
public BaseComboEditor(UIComboBox combo) {
comboBox = combo;
initComboBoxLookAndFeel();
}
private void initComboBoxLookAndFeel() {
comboBox.setEditable(false);
comboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
firePropertyChanged();
}
});
((JComponent) comboBox.getEditor().getEditorComponent()).setBorder(null);
comboBox.setBorder(null);
}
public ComboBoxModel model() {
return null;
}
public ListCellRenderer renderer() {
return null;
}
@Override
public void setValue(Object value) {
comboBox.setSelectedItem(value);
}
@Override
public Object getValue() {
return comboBox.getSelectedItem();
}
@Override
public Component getCustomEditor() {
return comboBox;
}
@Override
public void validateValue() throws ValidationException {
}
}

47
src/main/java/com/fanruan/api/design/work/form/editor/BasePropertyEditor.java

@ -0,0 +1,47 @@
package com.fanruan.api.design.work.form.editor;
import com.fanruan.api.design.err.ValidationException;
import com.fr.design.mainframe.widget.editors.AbstractPropertyEditor;
import java.awt.*;
/**
* @author richie
* @version 10.0
* Created by richie on 2019/10/30
* 自定义属性编辑器接口
*/
public abstract class BasePropertyEditor extends AbstractPropertyEditor {
/**
* 校验编辑器中输入值的合法性
*
* @throws ValidationException 值不合法则抛出此异常
*/
@Override
public abstract void validateValue() throws ValidationException;
/**
* 从外部给编辑器传入值
*
* @param value 新值
*/
@Override
public abstract void setValue(Object value);
/**
* 获取编辑器的值
*
* @return 编辑器的值
*/
@Override
public abstract Object getValue();
/**
* 编辑器的UI控制器是一个swing组件比如下拉框复选框用于设置做不同类别的属性设置
*
* @return UI控制器
*/
@Override
public abstract Component getCustomEditor();
}

14
src/main/java/com/fanruan/api/design/work/form/editor/StringEditor.java

@ -1,14 +0,0 @@
package com.fanruan.api.design.work.form.editor;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-09-05
* 字符串编辑器
*/
public class StringEditor extends com.fr.design.mainframe.widget.editors.StringEditor {
public StringEditor() {
super();
}
}

65
src/main/java/com/fanruan/api/design/work/form/editor/impl/StringEditor.java

@ -0,0 +1,65 @@
package com.fanruan.api.design.work.form.editor.impl;
import com.fanruan.api.design.err.ValidationException;
import com.fanruan.api.design.ui.component.UITextField;
import com.fanruan.api.design.work.form.editor.BasePropertyEditor;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.*;
/**
* @author richie
* @version 10.0
* Created by richie on 2019-09-05
* 字符串编辑器
*/
public class StringEditor extends BasePropertyEditor {
private JPanel panel;
private UITextField textField;
public StringEditor() {
panel = new JPanel(new BorderLayout());
textField = new UITextField();
panel.add(textField, BorderLayout.CENTER);
textField.setBorder(null);
textField.getDocument().addDocumentListener(new DocumentListener() {
@Override
public void removeUpdate(DocumentEvent e) {
firePropertyChanged();
}
@Override
public void insertUpdate(DocumentEvent e) {
firePropertyChanged();
}
@Override
public void changedUpdate(DocumentEvent e) {
firePropertyChanged();
}
});
}
@Override
public void setValue(Object value) {
textField.setText((String) value);
}
@Override
public Object getValue() {
return textField.getText();
}
@Override
public Component getCustomEditor() {
return textField;
}
@Override
public void validateValue() throws ValidationException {
}
}

2
src/main/java/com/fanruan/api/design/work/form/editor/WidgetValueEditor.java → src/main/java/com/fanruan/api/design/work/form/editor/impl/WidgetValueEditor.java

@ -1,4 +1,4 @@
package com.fanruan.api.design.work.form.editor; package com.fanruan.api.design.work.form.editor.impl;
/** /**
* @author Kalven * @author Kalven

7
src/main/java/com/fanruan/api/err/ValidationException.java

@ -1,7 +0,0 @@
package com.fanruan.api.err;
/**
* 验证异常
*/
public class ValidationException extends com.fr.design.Exception.ValidationException {
}

36
src/main/java/com/fanruan/api/generic/adapter/BasePropertyChangeAdapter.java

@ -0,0 +1,36 @@
package com.fanruan.api.generic.adapter;
import com.fr.stable.core.PropertyChangeAdapter;
/**
* @author richie
* @version 10.0
* Created by richie on 2019/10/30
* 事件适配器
*/
public class BasePropertyChangeAdapter<T> extends PropertyChangeAdapter<T> {
/**
* 属性改变是执行的方法根据不同的需求做不同的实现不带参数
*/
public void propertyChange() {
}
/**
* 属性改变是执行的方法根据不同的需求做不同的实现带一个参数
*
* @param mark 执行具体操作时所携带的参数
*/
public void propertyChange(T mark) {
}
/***
* 属性改变是执行的方法根据不同的需求做不同的实现带可变个参数
* @param marks 参数
*/
public void propertyChange(T... marks) {
}
}

11
src/main/java/com/fanruan/api/report/StyleKit.java

@ -2,6 +2,7 @@ package com.fanruan.api.report;
import com.fr.base.Style; import com.fr.base.Style;
import com.fr.stable.xml.XMLPrintWriter; import com.fr.stable.xml.XMLPrintWriter;
import com.fr.stable.xml.XMLableReader;
import com.fr.xml.SynchronizedStyleList; import com.fr.xml.SynchronizedStyleList;
/** /**
@ -21,6 +22,16 @@ public class StyleKit {
SynchronizedStyleList.getSynchronizedStyleList().xmlizeStyleList(writer); SynchronizedStyleList.getSynchronizedStyleList().xmlizeStyleList(writer);
} }
/**
* 反序列化样式列表
*
* @param reader xml读取器
*/
public static void deXmlizeStyleList(XMLableReader reader) {
SynchronizedStyleList.getSynchronizedStyleList().deXmlizeStyleList(reader);
}
/** /**
* 获取指定样式的序列 * 获取指定样式的序列
* *

Loading…
Cancel
Save