Browse Source

无JIRA任务 为了能提供SDK做的控件结构修改(续)

research/11.0
richie 5 years ago
parent
commit
c45dca28b5
  1. 15
      designer-form/src/main/java/com/fr/design/designer/creator/XCheckBox.java
  2. 9
      designer-form/src/main/java/com/fr/design/designer/creator/XDateEditor.java
  3. 4
      designer-form/src/main/java/com/fr/design/gui/xpane/ToolTipEditor.java
  4. 20
      designer-form/src/main/java/com/fr/design/mainframe/FormDesignerDropTarget.java
  5. 10
      designer-form/src/main/java/com/fr/design/widget/ui/designer/component/FormWidgetValuePane.java

15
designer-form/src/main/java/com/fr/design/designer/creator/XCheckBox.java

@ -7,13 +7,12 @@ import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.mainframe.widget.editors.WidgetValueEditor; import com.fr.design.mainframe.widget.editors.WidgetValueEditor;
import com.fr.form.ui.CheckBox; import com.fr.form.ui.CheckBox;
import com.fr.form.ui.WidgetValue; import com.fr.form.ui.concept.data.ValueInitializer;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.BorderFactory; import javax.swing.*;
import javax.swing.JComponent; import java.awt.*;
import java.awt.Dimension;
import java.beans.IntrospectionException; import java.beans.IntrospectionException;
/** /**
@ -28,7 +27,7 @@ public class XCheckBox extends XWidgetCreator {
@Override @Override
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException {
return (CRPropertyDescriptor[]) ArrayUtils.addAll(super.supportedDescriptor(), new CRPropertyDescriptor[] { return (CRPropertyDescriptor[]) ArrayUtils.addAll(super.supportedDescriptor(), new CRPropertyDescriptor[]{
new CRPropertyDescriptor("text", this.data.getClass()).setI18NName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Text")) new CRPropertyDescriptor("text", this.data.getClass()).setI18NName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Text"))
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced") .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced")
.setPropertyChangeListener(new PropertyChangeAdapter() { .setPropertyChangeListener(new PropertyChangeAdapter() {
@ -45,7 +44,7 @@ public class XCheckBox extends XWidgetCreator {
@Override @Override
public void propertyChange() { public void propertyChange() {
WidgetValue value = ((CheckBox) data).getWidgetValue(); ValueInitializer value = ((CheckBox) data).getWidgetValue();
if (value != null && value.getValue() instanceof Boolean) { if (value != null && value.getValue() instanceof Boolean) {
((UICheckBox) editor).setSelected((Boolean) value.getValue()); ((UICheckBox) editor).setSelected((Boolean) value.getValue());
} }
@ -82,9 +81,9 @@ public class XCheckBox extends XWidgetCreator {
return "check_box_16.png"; return "check_box_16.png";
} }
public void firePropertyChange(){ public void firePropertyChange() {
((UICheckBox) editor).setText(((CheckBox) data).getText()); ((UICheckBox) editor).setText(((CheckBox) data).getText());
WidgetValue value = ((CheckBox) data).getWidgetValue(); ValueInitializer value = ((CheckBox) data).getWidgetValue();
if (value != null && value.getValue() instanceof Boolean) { if (value != null && value.getValue() instanceof Boolean) {
((UICheckBox) editor).setSelected((Boolean) value.getValue()); ((UICheckBox) editor).setSelected((Boolean) value.getValue());
} }

9
designer-form/src/main/java/com/fr/design/designer/creator/XDateEditor.java

@ -12,15 +12,14 @@ import com.fr.design.mainframe.widget.editors.WidgetValueEditor;
import com.fr.design.mainframe.widget.renderer.DateCellRenderer; import com.fr.design.mainframe.widget.renderer.DateCellRenderer;
import com.fr.form.ui.DateEditor; import com.fr.form.ui.DateEditor;
import com.fr.form.ui.WidgetValue; import com.fr.form.ui.WidgetValue;
import com.fr.form.ui.concept.data.ValueInitializer;
import com.fr.general.DateUtils; import com.fr.general.DateUtils;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.JComponent; import javax.swing.*;
import java.awt.BorderLayout; import java.awt.*;
import java.awt.Color;
import java.awt.Dimension;
import java.beans.IntrospectionException; import java.beans.IntrospectionException;
import java.util.Date; import java.util.Date;
@ -84,7 +83,7 @@ public class XDateEditor extends XDirectWriteEditor {
private void initFieldText() { private void initFieldText() {
DateEditor dateEditor = (DateEditor) data; DateEditor dateEditor = (DateEditor) data;
if (dateEditor.getWidgetValue() != null) { if (dateEditor.getWidgetValue() != null) {
WidgetValue widgetValue = dateEditor.getWidgetValue(); ValueInitializer widgetValue = dateEditor.getWidgetValue();
//控件值.toString //控件值.toString
String valueStr = widgetValue.toString(); String valueStr = widgetValue.toString();
//控件值 //控件值

4
designer-form/src/main/java/com/fr/design/gui/xpane/ToolTipEditor.java

@ -15,7 +15,7 @@ import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.form.ui.DataControl; import com.fr.form.ui.DataControl;
import com.fr.form.ui.EditorHolder; import com.fr.form.ui.EditorHolder;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.WidgetValue; import com.fr.form.ui.WidgetValueUtils;
import com.fr.general.Background; import com.fr.general.Background;
import com.fr.general.GeneralContext; import com.fr.general.GeneralContext;
import com.fr.plugin.context.PluginContext; import com.fr.plugin.context.PluginContext;
@ -77,7 +77,7 @@ public class ToolTipEditor extends JWindow {
createWidget.setWidgetName(widget.getWidgetName()); createWidget.setWidgetName(widget.getWidgetName());
createWidget.setEnabled(widget.isEnabled()); createWidget.setEnabled(widget.isEnabled());
createWidget.setVisible(widget.isVisible()); createWidget.setVisible(widget.isVisible());
WidgetValue.convertWidgetValue((DataControl) createWidget, widget.getWidgetValue().getValue()); WidgetValueUtils.convertWidgetValue((DataControl) createWidget, widget.getWidgetValue().getValue());
XCreator creator = null; XCreator creator = null;
creator = parent.replace(createWidget, holder); creator = parent.replace(createWidget, holder);
Component designer = holder.getDesignerEditor().getEditorTarget().getParent(); Component designer = holder.getDesignerEditor().getEditorTarget().getParent();

20
designer-form/src/main/java/com/fr/design/mainframe/FormDesignerDropTarget.java

@ -6,10 +6,11 @@ import com.fr.form.ui.DataControl;
import com.fr.form.ui.IframeEditor; import com.fr.form.ui.IframeEditor;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.WidgetValue; import com.fr.form.ui.WidgetValue;
import com.fr.form.ui.concept.data.ValueInitializer;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import java.awt.Point; import java.awt.*;
import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable; import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.datatransfer.UnsupportedFlavorException;
@ -31,6 +32,7 @@ public class FormDesignerDropTarget extends DropTargetAdapter {
/** /**
* 响应拖拽进入事件 * 响应拖拽进入事件
*
* @param dtde 需要被处理的拖拽事件 * @param dtde 需要被处理的拖拽事件
*/ */
public void dragEnter(DropTargetDragEvent dtde) { public void dragEnter(DropTargetDragEvent dtde) {
@ -39,6 +41,7 @@ public class FormDesignerDropTarget extends DropTargetAdapter {
/** /**
* 处理拖拽经过事件 * 处理拖拽经过事件
*
* @param dtde 需要被处理的拖拽事件 * @param dtde 需要被处理的拖拽事件
*/ */
public void dragOver(DropTargetDragEvent dtde) { public void dragOver(DropTargetDragEvent dtde) {
@ -52,6 +55,7 @@ public class FormDesignerDropTarget extends DropTargetAdapter {
/** /**
* 处理拖拽释放事件 * 处理拖拽释放事件
*
* @param dtde 需要被处理的拖拽事件 * @param dtde 需要被处理的拖拽事件
*/ */
public void drop(DropTargetDropEvent dtde) { public void drop(DropTargetDropEvent dtde) {
@ -75,22 +79,16 @@ public class FormDesignerDropTarget extends DropTargetAdapter {
if (!(widget instanceof DataControl)) { if (!(widget instanceof DataControl)) {
return; return;
} }
WidgetValue oldvalue = ((DataControl) widget).getWidgetValue(); ValueInitializer oldValue = ((DataControl) widget).getWidgetValue();
WidgetValue newValue = new WidgetValue(new DataBinding((String[][]) o)); ValueInitializer newValue = new WidgetValue(new DataBinding((String[][]) o));
if (!ComparatorUtils.equals(oldvalue, newValue)) { if (!ComparatorUtils.equals(oldValue, newValue)) {
((DataControl) widget).setWidgetValue(newValue); ((DataControl) widget).setWidgetValue(newValue);
designer.fireTargetModified(); designer.fireTargetModified();
} }
creator.rebuid(); creator.rebuid();
designer.getSelectionModel().setSelectedCreator(creator); designer.getSelectionModel().setSelectedCreator(creator);
} catch (UnsupportedFlavorException e) { } catch (UnsupportedFlavorException | IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
} catch (IOException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
} }
private void setSrcForIframeEditor() {
} }
} }

10
designer-form/src/main/java/com/fr/design/widget/ui/designer/component/FormWidgetValuePane.java

@ -1,7 +1,11 @@
package com.fr.design.widget.ui.designer.component; package com.fr.design.widget.ui.designer.component;
import com.fr.design.constants.LayoutConstants; import com.fr.design.constants.LayoutConstants;
import com.fr.design.editor.editor.*; import com.fr.design.editor.editor.BooleanEditor;
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.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.mainframe.widget.editors.DataBindingEditor; import com.fr.design.mainframe.widget.editors.DataBindingEditor;
import com.fr.design.mainframe.widget.editors.DataTableEditor; import com.fr.design.mainframe.widget.editors.DataTableEditor;
@ -9,9 +13,9 @@ import com.fr.design.mainframe.widget.editors.ServerDataBindingEditor;
import com.fr.design.mainframe.widget.editors.ServerDataTableEditor; import com.fr.design.mainframe.widget.editors.ServerDataTableEditor;
import com.fr.form.ui.DataControl; import com.fr.form.ui.DataControl;
import com.fr.form.ui.WidgetValue; import com.fr.form.ui.WidgetValue;
import com.fr.form.ui.concept.data.ValueInitializer;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -112,7 +116,7 @@ public class FormWidgetValuePane extends JPanel {
} }
public void populate(DataControl ob) { public void populate(DataControl ob) {
WidgetValue widgetValue = ob.getWidgetValue(); ValueInitializer widgetValue = ob.getWidgetValue();
if (widgetValue != null) { if (widgetValue != null) {
for (int i = 0; i < editor.length; i++) { for (int i = 0; i < editor.length; i++) {
if (editor[i].accept(widgetValue.getValue())) { if (editor[i].accept(widgetValue.getValue())) {

Loading…
Cancel
Save