hzzz 7 years ago
parent
commit
04e593d0ed
  1. 1
      designer/src/com/fr/design/parameter/ParameterDefinitePane.java
  2. 8
      designer_base/src/com/fr/design/parameter/ParameterBridge.java
  3. 1
      designer_base/src/com/fr/design/parameter/ParameterDesignerProvider.java
  4. 5
      designer_base/src/com/fr/start/StartServer.java
  5. 36
      designer_form/src/com/fr/design/designer/creator/XLabel.java
  6. 13
      designer_form/src/com/fr/design/designer/creator/XLayoutContainer.java
  7. 17
      designer_form/src/com/fr/design/designer/creator/XWParameterLayout.java
  8. 30
      designer_form/src/com/fr/design/designer/creator/XWidgetCreator.java
  9. 122
      designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java
  10. 2
      designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java

1
designer/src/com/fr/design/parameter/ParameterDefinitePane.java

@ -355,6 +355,7 @@ public class ParameterDefinitePane extends JPanel implements ToolBarMenuDockPlus
reportParameterAttr.setShowWindow(bridge.isDisplay()); reportParameterAttr.setShowWindow(bridge.isDisplay());
reportParameterAttr.setAlign(bridge.getPosition()); reportParameterAttr.setAlign(bridge.getPosition());
reportParameterAttr.setBackground(bridge.getDataBackground()); reportParameterAttr.setBackground(bridge.getDataBackground());
reportParameterAttr.setUseParamsTemplate(bridge.isUseParamsTemplate());
} }
//这里不用 parameterUI 的原因是考虑到没有控件的时候设置宽度有效果但不保存,只有含有控件才保存属性 //这里不用 parameterUI 的原因是考虑到没有控件的时候设置宽度有效果但不保存,只有含有控件才保存属性
paraDesignEditor.getParaTarget().setDesignSize(new Dimension(bridge.getDesignWidth(), paraDesignEditor.getParaTarget().setDesignSize(new Dimension(bridge.getDesignWidth(),

8
designer_base/src/com/fr/design/parameter/ParameterBridge.java

@ -16,6 +16,12 @@ public interface ParameterBridge {
*/ */
public boolean isDelayDisplayContent(); public boolean isDelayDisplayContent();
/**
* 是否启用参数模板
* @return 显示参数模板界面则返回true否则返回false
*/
public boolean isUseParamsTemplate();
/** /**
* 是否显示参数界面 * 是否显示参数界面
* @return 显示参数界面则返回true否则返回false * @return 显示参数界面则返回true否则返回false
@ -48,4 +54,6 @@ public interface ParameterBridge {
public void setDisplay(boolean showWindow); public void setDisplay(boolean showWindow);
public void setBackground(Background background); public void setBackground(Background background);
public void setUseParamsTemplate(boolean isUse);
} }

1
designer_base/src/com/fr/design/parameter/ParameterDesignerProvider.java

@ -68,5 +68,4 @@ public interface ParameterDesignerProvider {
void removeSelection(); void removeSelection();
ParameterBridge getParaComponent(); ParameterBridge getParaComponent();
} }

5
designer_base/src/com/fr/start/StartServer.java

@ -19,6 +19,7 @@ import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.start.job.favoriteparams.FavoriteParamsJob;
import com.fr.start.server.JettyHost; import com.fr.start.server.JettyHost;
import javax.swing.*; import javax.swing.*;
@ -126,7 +127,7 @@ public class StartServer {
} catch (Exception e) { } catch (Exception e) {
FRContext.getLogger().errorWithServerLevel(e.getMessage()); FRContext.getLogger().errorWithServerLevel(e.getMessage());
} finally { } finally {
NEED_LOAD_ENV = false; FavoriteParamsJob.create().start();
browser(url); browser(url);
} }
} }
@ -176,7 +177,7 @@ public class StartServer {
.append(ProductConstants.APP_NAME) .append(ProductConstants.APP_NAME)
.append(Inter.getLocText("FR-Designer_Utils-OpenDemoEnv")) .append(Inter.getLocText("FR-Designer_Utils-OpenDemoEnv"))
.append(message).append(Inter.getLocText("FR-Designer_Utils-switch")).toString(); .append(message).append(Inter.getLocText("FR-Designer_Utils-switch")).toString();
}else{ } else {
text = new StringBuffer(Inter.getLocText("FR-Designer_Open")) text = new StringBuffer(Inter.getLocText("FR-Designer_Open"))
.append(ProductConstants.APP_NAME) .append(ProductConstants.APP_NAME)
.append(Inter.getLocText("FR-Designer_Utils-NewDemoEnv")) .append(Inter.getLocText("FR-Designer_Utils-NewDemoEnv"))

36
designer_form/src/com/fr/design/designer/creator/XLabel.java

@ -3,19 +3,11 @@
*/ */
package com.fr.design.designer.creator; package com.fr.design.designer.creator;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.geom.Rectangle2D;
import java.beans.IntrospectionException;
import javax.swing.JComponent;
import javax.swing.SwingConstants;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.ScreenResolution; import com.fr.base.ScreenResolution;
import com.fr.base.Style; import com.fr.base.Style;
import com.fr.design.border.UIRoundedBorder; import com.fr.design.border.UIRoundedBorder;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.mainframe.widget.editors.FontEditor; import com.fr.design.mainframe.widget.editors.FontEditor;
import com.fr.design.mainframe.widget.editors.ItemCellEditor; import com.fr.design.mainframe.widget.editors.ItemCellEditor;
@ -23,10 +15,16 @@ import com.fr.design.mainframe.widget.editors.WidgetValueEditor;
import com.fr.design.mainframe.widget.renderer.FontCellRenderer; import com.fr.design.mainframe.widget.renderer.FontCellRenderer;
import com.fr.design.mainframe.widget.renderer.LabelHorizontalAlignmentRenderer; import com.fr.design.mainframe.widget.renderer.LabelHorizontalAlignmentRenderer;
import com.fr.form.ui.Label; import com.fr.form.ui.Label;
import com.fr.design.form.util.XCreatorConstants; import com.fr.form.ui.container.WParameterLayout;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.ArrayUtils; import com.fr.stable.ArrayUtils;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.*;
import java.awt.*;
import java.awt.geom.Rectangle2D;
import java.beans.IntrospectionException;
/** /**
* @author richer * @author richer
@ -42,6 +40,7 @@ public class XLabel extends XWidgetCreator {
/** /**
* 生成creator对应的控件widget * 生成creator对应的控件widget
*
* @return 控件widget * @return 控件widget
*/ */
public Label toData() { public Label toData() {
@ -50,16 +49,25 @@ public class XLabel extends XWidgetCreator {
/** /**
* 返回组件属性值 * 返回组件属性值
*
* @return 返回组件属性值 * @return 返回组件属性值
* @throws IntrospectionException 异常 * @throws IntrospectionException 异常
*/ */
@Override @Override
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException {
return (CRPropertyDescriptor[]) ArrayUtils.addAll(super.supportedDescriptor(), return (CRPropertyDescriptor[]) ArrayUtils.addAll(super.supportedDescriptor(),
new CRPropertyDescriptor[] { new CRPropertyDescriptor[]{
new CRPropertyDescriptor("widgetValue", this.data.getClass()).setI18NName( new CRPropertyDescriptor("widgetValue", this.data.getClass()).setI18NName(
Inter.getLocText(new String[]{"FR-Designer_Widget", "Value"})).setEditorClass( Inter.getLocText(new String[]{"FR-Designer_Widget", "Value"})).setEditorClass(
WidgetValueEditor.class).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), WidgetValueEditor.class).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced")
.setPropertyChangeListener(new PropertyChangeAdapter() {
@Override
public void propertyChange() {
XCreator parent = (XCreator) XLabel.this.getParent();
((WParameterLayout) parent.toData()).refreshTagList();
}
}),
new CRPropertyDescriptor("wrap", this.data.getClass()).setI18NName( new CRPropertyDescriptor("wrap", this.data.getClass()).setI18NName(
Inter.getLocText("FR-Designer_StyleAlignment-Wrap_Text")).putKeyValue( Inter.getLocText("FR-Designer_StyleAlignment-Wrap_Text")).putKeyValue(
XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), XCreatorConstants.PROPERTY_CATEGORY, "Advanced"),
@ -72,7 +80,7 @@ public class XLabel extends XWidgetCreator {
XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), XCreatorConstants.PROPERTY_CATEGORY, "Advanced"),
new CRPropertyDescriptor("font", this.data.getClass()).setI18NName(Inter.getLocText("FR-Designer_Font")) new CRPropertyDescriptor("font", this.data.getClass()).setI18NName(Inter.getLocText("FR-Designer_Font"))
.setEditorClass(FontEditor.class).setRendererClass(FontCellRenderer.class).putKeyValue( .setEditorClass(FontEditor.class).setRendererClass(FontCellRenderer.class).putKeyValue(
XCreatorConstants.PROPERTY_CATEGORY, "Advanced") }); XCreatorConstants.PROPERTY_CATEGORY, "Advanced")});
} }
@Override @Override
@ -82,7 +90,7 @@ public class XLabel extends XWidgetCreator {
Dimension size = this.getSize(); Dimension size = this.getSize();
//先画背景,再画标题 //先画背景,再画标题
if (toData().getBackground() != null) { if (toData().getBackground() != null) {
toData().getBackground().paint(g,new Rectangle2D.Double(0, 0, size.getWidth(), size.getHeight())); toData().getBackground().paint(g, new Rectangle2D.Double(0, 0, size.getWidth(), size.getHeight()));
} }
if (label.getWidgetValue() != null) { if (label.getWidgetValue() != null) {
Graphics2D g2d = (Graphics2D) g.create(); Graphics2D g2d = (Graphics2D) g.create();

13
designer_form/src/com/fr/design/designer/creator/XLayoutContainer.java

@ -412,6 +412,15 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
return false; return false;
} }
/**
* 是否启用参数模板
* @return 显示参数模板界面则返回true否则返回false
*/
public boolean isUseParamsTemplate() {
return false;
}
/** /**
* 是否显示参数界面 * 是否显示参数界面
* *
@ -485,6 +494,10 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme
} }
public void setUseParamsTemplate(boolean isUse) {
}
public void setPosition(int align) { public void setPosition(int align) {
} }

17
designer_form/src/com/fr/design/designer/creator/XWParameterLayout.java

@ -46,7 +46,7 @@ public class XWParameterLayout extends XWAbsoluteLayout {
* @return 尺寸 * @return 尺寸
*/ */
public Dimension initEditorSize() { public Dimension initEditorSize() {
return new Dimension(WFitLayout.DEFAULT_WIDTH, WBorderLayout.DEFAULT_SIZE); return new Dimension(WFitLayout.DEFAULT_WIDTH+1000, WBorderLayout.DEFAULT_SIZE+1000);
} }
/** /**
@ -67,6 +67,9 @@ public class XWParameterLayout extends XWAbsoluteLayout {
new CRPropertyDescriptor("position", this.data.getClass()).setEditorClass(WidgetDisplayPosition.class) new CRPropertyDescriptor("position", this.data.getClass()).setEditorClass(WidgetDisplayPosition.class)
.setRendererClass(WidgetDisplayPositionRender.class).setI18NName(Inter.getLocText("FR-Designer_WidgetDisplyPosition")) .setRendererClass(WidgetDisplayPositionRender.class).setI18NName(Inter.getLocText("FR-Designer_WidgetDisplyPosition"))
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"), .putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"),
new CRPropertyDescriptor("useParamsTemplate", this.data.getClass()).setEditorClass(BooleanEditor.class)
.setI18NName("使用常用参数组合")
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Advanced"),
}; };
ParameterWindowEditorProcessor processor = ExtraDesignClassManager.getInstance().getSingle(ParameterWindowEditorProcessor.MARK_STRING); ParameterWindowEditorProcessor processor = ExtraDesignClassManager.getInstance().getSingle(ParameterWindowEditorProcessor.MARK_STRING);
@ -124,6 +127,14 @@ public class XWParameterLayout extends XWAbsoluteLayout {
return toData().isDelayDisplayContent(); return toData().isDelayDisplayContent();
} }
/**
* 是否启用参数模板
* @return 显示参数模板界面则返回true否则返回false
*/
public boolean isUseParamsTemplate() {
return toData().isUseParamsTemplate();
}
/** /**
* 是否显示参数界面 * 是否显示参数界面
* @return 显示参数界面则返回true否则返回false * @return 显示参数界面则返回true否则返回false
@ -152,6 +163,10 @@ public class XWParameterLayout extends XWAbsoluteLayout {
this.toData().setDelayDisplayContent(delayPlaying); this.toData().setDelayDisplayContent(delayPlaying);
} }
public void setUseParamsTemplate(boolean isUse) {
this.toData().setUseParamsTemplate(isUse);
}
public void setPosition(int align){ public void setPosition(int align){
this.toData().setPosition(align); this.toData().setPosition(align);
} }

30
designer_form/src/com/fr/design/designer/creator/XWidgetCreator.java

@ -3,17 +3,17 @@
*/ */
package com.fr.design.designer.creator; package com.fr.design.designer.creator;
import java.awt.*;
import java.beans.IntrospectionException;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.FRContext; import com.fr.base.FRContext;
import com.fr.design.form.util.XCreatorConstants;
import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.FormDesigner;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.core.PropertyChangeAdapter; import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.*; import javax.swing.*;
import java.awt.*;
import java.beans.IntrospectionException;
/** /**
* @author richer * @author richer
@ -31,11 +31,12 @@ public abstract class XWidgetCreator extends XCreator {
/** /**
* 待说明 * 待说明
*
* @return 待说明 * @return 待说明
* @throws IntrospectionException * @throws IntrospectionException
*/ */
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException {
return new CRPropertyDescriptor[] { return new CRPropertyDescriptor[]{
new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName(Inter new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName(Inter
.getLocText("Form-Widget_Name")), .getLocText("Form-Widget_Name")),
new CRPropertyDescriptor("enabled", this.data.getClass()).setI18NName(Inter.getLocText("FR-Designer_Enabled")) new CRPropertyDescriptor("enabled", this.data.getClass()).setI18NName(Inter.getLocText("FR-Designer_Enabled"))
@ -53,12 +54,17 @@ public abstract class XWidgetCreator extends XCreator {
public void propertyChange() { public void propertyChange() {
makeVisible(toData().isVisible()); makeVisible(toData().isVisible());
} }
}) }; }),
new CRPropertyDescriptor("labelName", this.data.getClass(), "getLabelName", "setLabelName")
.setI18NName("标签名称")
.putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "FR-Designer_Advanced")
};
} }
/** /**
* 待说明 * 待说明
*
* @return 待说明 * @return 待说明
*/ */
public Widget toData() { public Widget toData() {
@ -87,6 +93,7 @@ public abstract class XWidgetCreator extends XCreator {
private String name; private String name;
private String imagePath; private String imagePath;
private float opacity = 0.4f; private float opacity = 0.4f;
public LimpidButton(String name, String imagePath, float opacity) { public LimpidButton(String name, String imagePath, float opacity) {
this.name = name; this.name = name;
this.imagePath = imagePath; this.imagePath = imagePath;
@ -96,7 +103,7 @@ public abstract class XWidgetCreator extends XCreator {
public void draw() { public void draw() {
try { try {
ImageIcon imageIcon =(ImageIcon) BaseUtils.readIcon(imagePath); ImageIcon imageIcon = (ImageIcon) BaseUtils.readIcon(imagePath);
Image img = imageIcon.getImage(); Image img = imageIcon.getImage();
MediaTracker mt = new MediaTracker(this); MediaTracker mt = new MediaTracker(this);
int w = 21; int w = 21;
@ -138,6 +145,7 @@ public abstract class XWidgetCreator extends XCreator {
/** /**
* 待说明 * 待说明
*
* @param visible 待说明 * @param visible 待说明
*/ */
public void makeVisible(boolean visible) { public void makeVisible(boolean visible) {
@ -151,21 +159,21 @@ public abstract class XWidgetCreator extends XCreator {
*/ */
public void paint(Graphics g) { public void paint(Graphics g) {
//不可见时,按钮.4f透明 //不可见时,按钮.4f透明
AlphaComposite composite = this.data.isVisible() ? (AlphaComposite)((Graphics2D)g).getComposite() : AlphaComposite.getInstance(AlphaComposite.SRC_OVER,HALF_OPACITY); AlphaComposite composite = this.data.isVisible() ? (AlphaComposite) ((Graphics2D) g).getComposite() : AlphaComposite.getInstance(AlphaComposite.SRC_OVER, HALF_OPACITY);
((Graphics2D)g).setComposite(composite); ((Graphics2D) g).setComposite(composite);
super.paint(g); super.paint(g);
} }
/** /**
* 重命名 * 重命名
* *
* @param designer 表单设计器 * @param designer 表单设计器
* @param creator 当前组件 * @param creator 当前组件
*
*/ */
public void ChangeCreatorName(FormDesigner designer,XCreator creator){ public void ChangeCreatorName(FormDesigner designer, XCreator creator) {
String oldName = creator.toData().getWidgetName(); String oldName = creator.toData().getWidgetName();
String value = JOptionPane.showInputDialog(designer, Inter.getLocText("Form-Change_Widget_Name_Discription"), oldName); String value = JOptionPane.showInputDialog(designer, Inter.getLocText("Form-Change_Widget_Name_Discription"), oldName);
if(value != null) { if (value != null) {
designer.renameCreator(creator, value); designer.renameCreator(creator, value);
} }
} }

122
designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java

@ -1,41 +1,12 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Component;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.geom.RoundRectangle2D;
import java.util.EventObject;
import javax.swing.AbstractCellEditor;
import javax.swing.BorderFactory;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableColumn;
import javax.swing.table.TableModel;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itable.GroupRenderer;
import com.fr.design.gui.itable.HeaderRenderer;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer; import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWParameterLayout; import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itable.HeaderRenderer;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.form.ui.Label; import com.fr.form.ui.Label;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WParameterLayout; import com.fr.form.ui.container.WParameterLayout;
@ -43,6 +14,18 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.Inter; import com.fr.general.Inter;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.table.*;
import java.awt.*;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.geom.RoundRectangle2D;
import java.util.EventObject;
/** /**
* MobileParaWidgetTable主要显示参数面板容器的控件列表与MobileWidgetTable的区别就是该表多了UITextField这一列 * MobileParaWidgetTable主要显示参数面板容器的控件列表与MobileWidgetTable的区别就是该表多了UITextField这一列
* Created with IntelliJ IDEA. * Created with IntelliJ IDEA.
@ -54,8 +37,8 @@ import com.fr.stable.StringUtils;
class MobileParaWidgetTable extends JTable { class MobileParaWidgetTable extends JTable {
private FormDesigner designer; private FormDesigner designer;
private String[][] cellData ; private String[][] cellData;
private String[] headers = {Inter.getLocText("FR-Utils_Label"), Inter.getLocText("Form-Widget_Name")}; private String[] headers = {Inter.getLocText("Form-Widget_Name")};
private static final int WIDGET_TABLE_ROW_HEIGHT = 22; private static final int WIDGET_TABLE_ROW_HEIGHT = 22;
private static final int UITEXTFIELD_WIDTH = 40; private static final int UITEXTFIELD_WIDTH = 40;
private UILabel moveComponent = new UILabel(); // 作为拖动时候随鼠标移动的那个半透明控件 private UILabel moveComponent = new UILabel(); // 作为拖动时候随鼠标移动的那个半透明控件
@ -75,7 +58,7 @@ class MobileParaWidgetTable extends JTable {
TableColumn tc = this.getColumn(this.getColumnName(0)); TableColumn tc = this.getColumn(this.getColumnName(0));
tc.setPreferredWidth(UITEXTFIELD_WIDTH); tc.setPreferredWidth(UITEXTFIELD_WIDTH);
this.repaint(); this.repaint();
this.setDefaultRenderer(Object.class,new MobileWidgetTableCellRenderer()); this.setDefaultRenderer(Object.class, new MobileWidgetTableCellRenderer());
refreshData(); refreshData();
this.addMouseListener(mouseAdapter); this.addMouseListener(mouseAdapter);
this.addMouseMotionListener(mouseAdapter); this.addMouseMotionListener(mouseAdapter);
@ -112,12 +95,12 @@ class MobileParaWidgetTable extends JTable {
*/ */
@Override @Override
public void mouseReleased(MouseEvent e) { public void mouseReleased(MouseEvent e) {
if(!draging){ if (!draging) {
return; return;
} }
draging = false; draging = false;
moveComponent.setVisible(false); moveComponent.setVisible(false);
int toIndex = e.getY() < GAP ? 0 : (int)Math.rint((e.getY() - GAP)/WIDGET_TABLE_ROW_HEIGHT) + 1; int toIndex = e.getY() < GAP ? 0 : (int) Math.rint((e.getY() - GAP) / WIDGET_TABLE_ROW_HEIGHT) + 1;
//当鼠标放开时,将选中的容器调整至新的顺序 //当鼠标放开时,将选中的容器调整至新的顺序
((WParameterLayout) designer.getParaComponent().toData()).adjustOrder(selectedRow, toIndex); ((WParameterLayout) designer.getParaComponent().toData()).adjustOrder(selectedRow, toIndex);
//拿取排序后表格数据,然后重绘表格 //拿取排序后表格数据,然后重绘表格
@ -135,13 +118,13 @@ class MobileParaWidgetTable extends JTable {
public void mouseMoved(MouseEvent e) { public void mouseMoved(MouseEvent e) {
int overColumn = e.getX() < getColumnModel().getColumn(0).getWidth() ? 0 : 1; // 判断当前鼠标在哪一列 int overColumn = e.getX() < getColumnModel().getColumn(0).getWidth() ? 0 : 1; // 判断当前鼠标在哪一列
int overRow = -1; int overRow = -1;
for (int i = 0;i < getRowCount();i++) { for (int i = 0; i < getRowCount(); i++) {
if (e.getY() > i * WIDGET_TABLE_ROW_HEIGHT && e.getY() <= (i + 1) * WIDGET_TABLE_ROW_HEIGHT) { if (e.getY() > i * WIDGET_TABLE_ROW_HEIGHT && e.getY() <= (i + 1) * WIDGET_TABLE_ROW_HEIGHT) {
overRow = i; //判断当前鼠标在哪一行 overRow = i; //判断当前鼠标在哪一行
} }
} }
//如果鼠标移动到当前选中的行列上面的时候,并且不能在第一列 //如果鼠标移动到当前选中的行列上面的时候,并且不能在第一列
if (overRow == selectedRow && overColumn == selectedColumn && overColumn !=0) { if (overRow == selectedRow && overColumn == selectedColumn && overColumn != 0) {
//把当前选中的那一列行的光标改成(除了第一列)移动样式MOVE_CURSOR //把当前选中的那一列行的光标改成(除了第一列)移动样式MOVE_CURSOR
setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
} else { } else {
@ -156,9 +139,7 @@ class MobileParaWidgetTable extends JTable {
*/ */
@Override @Override
public void mouseDragged(MouseEvent e) { public void mouseDragged(MouseEvent e) {
int width = getColumnModel().getColumn(1).getWidth(); int width = getColumnModel().getColumn(0).getWidth();
//如果点击选中的是第二列,就可以拖动
if (selectedColumn == 1){
setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
draging = true; draging = true;
moveComponent.setText(getValueAt(selectedRow, selectedColumn).toString()); moveComponent.setText(getValueAt(selectedRow, selectedColumn).toString());
@ -168,7 +149,6 @@ class MobileParaWidgetTable extends JTable {
moveComponent.setForeground(Color.lightGray); moveComponent.setForeground(Color.lightGray);
moveComponent.setBorder(BorderFactory.createLineBorder(Color.lightGray)); moveComponent.setBorder(BorderFactory.createLineBorder(Color.lightGray));
} }
}
/** /**
* 设置鼠标单击时处理的事件单击第二列的控件列表进入控件属性表 * 设置鼠标单击时处理的事件单击第二列的控件列表进入控件属性表
@ -176,14 +156,14 @@ class MobileParaWidgetTable extends JTable {
*/ */
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
if(getSelectedRow() != -1 && getSelectedColumn() == 1){ if (getSelectedRow() != -1 && getSelectedColumn() == 0) {
String widgetName = cellData[getSelectedRow()][getSelectedColumn()]; String widgetName = cellData[getSelectedRow()][getSelectedColumn()];
if (StringUtils.isNotEmpty(widgetName)){ if (StringUtils.isNotEmpty(widgetName)) {
int count = getEditingDesigner().getParaComponent().getComponentCount(); int count = getEditingDesigner().getParaComponent().getComponentCount();
for (int i = 0; i < count; i++){ for (int i = 0; i < count; i++) {
XCreator xCreator = (XCreator)getEditingDesigner().getParaComponent().getComponent(i); XCreator xCreator = (XCreator) getEditingDesigner().getParaComponent().getComponent(i);
Widget widget = xCreator.toData(); Widget widget = xCreator.toData();
if (!widget.acceptType(Label.class) && ComparatorUtils.equals(widgetName,widget.getWidgetName())) { if (!widget.acceptType(Label.class) && ComparatorUtils.equals(widgetName, widget.getWidgetName())) {
//设置选中的component,这句代码控制点击之后跳转到相应component属性表 //设置选中的component,这句代码控制点击之后跳转到相应component属性表
getEditingDesigner().getSelectionModel().setSelectedCreator(xCreator); getEditingDesigner().getSelectionModel().setSelectedCreator(xCreator);
} }
@ -204,11 +184,11 @@ class MobileParaWidgetTable extends JTable {
} }
}; };
public MobileParaWidgetTable getInstance(){ public MobileParaWidgetTable getInstance() {
return this; return this;
} }
private FormDesigner getEditingDesigner(){ private FormDesigner getEditingDesigner() {
return designer; return designer;
} }
@ -229,7 +209,7 @@ class MobileParaWidgetTable extends JTable {
/** /**
* 重新get排序后的数据 * 重新get排序后的数据
*/ */
public void refreshData(){ public void refreshData() {
cellData = getData(); cellData = getData();
} }
@ -238,10 +218,10 @@ class MobileParaWidgetTable extends JTable {
* *
* @return String[][] 二维数组[0][0]widgetTag, [0][1]widgetName * @return String[][] 二维数组[0][0]widgetTag, [0][1]widgetName
*/ */
private String[][] getData(){ private String[][] getData() {
XLayoutContainer paraContainer = designer.getParaComponent(); XLayoutContainer paraContainer = designer.getParaComponent();
if(paraContainer == null || !paraContainer.acceptType(XWParameterLayout.class)){ if (paraContainer == null || !paraContainer.acceptType(XWParameterLayout.class)) {
return new String[0][0]; return new String[0][1];
} }
WParameterLayout para = (WParameterLayout) (paraContainer.toData()); WParameterLayout para = (WParameterLayout) (paraContainer.toData());
@ -251,14 +231,14 @@ class MobileParaWidgetTable extends JTable {
/** /**
* 自定义的tableRender类 * 自定义的tableRender类
*/ */
private class MobileWidgetTableCellRenderer extends DefaultTableCellRenderer{ private class MobileWidgetTableCellRenderer extends DefaultTableCellRenderer {
@Override @Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
boolean hasFocus, int row, int column) { boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (column == 0){ if (column == 0) {
UITextField uiTableTextField; UITextField uiTableTextField;
if (getSelectedColumn() == column && getSelectedRow() == row){ if (getSelectedColumn() == column && getSelectedRow() == row) {
uiTableTextField = new UITableTextField(value.toString()); uiTableTextField = new UITableTextField(value.toString());
} else { } else {
uiTableTextField = new UITextField(value.toString()); uiTableTextField = new UITextField(value.toString());
@ -275,7 +255,8 @@ class MobileParaWidgetTable extends JTable {
*/ */
private class MobileCellEditor extends AbstractCellEditor implements TableCellEditor { private class MobileCellEditor extends AbstractCellEditor implements TableCellEditor {
UITableTextField uiTableTextField; UITableTextField uiTableTextField;
MobileCellEditor(){
MobileCellEditor() {
uiTableTextField = new UITableTextField(); uiTableTextField = new UITableTextField();
uiTableTextField.addFocusListener(new FocusAdapter() { uiTableTextField.addFocusListener(new FocusAdapter() {
@Override @Override
@ -306,7 +287,7 @@ class MobileParaWidgetTable extends JTable {
* cell改变相应的nametag改变 * cell改变相应的nametag改变
*/ */
private void firePropertyChange(){ private void firePropertyChange() {
((WParameterLayout) designer.getParaComponent().toData()).add2NameTagMap(uiTableTextField.getText(), ((WParameterLayout) designer.getParaComponent().toData()).add2NameTagMap(uiTableTextField.getText(),
cellData[getSelectedRow()][1]); cellData[getSelectedRow()][1]);
((WParameterLayout) designer.getParaComponent().toData()).setNameTagModified(cellData[getSelectedRow()][1], ((WParameterLayout) designer.getParaComponent().toData()).setNameTagModified(cellData[getSelectedRow()][1],
@ -314,7 +295,7 @@ class MobileParaWidgetTable extends JTable {
} }
@Override @Override
public Object getCellEditorValue(){ public Object getCellEditorValue() {
return uiTableTextField.getText(); return uiTableTextField.getText();
} }
@ -327,8 +308,8 @@ class MobileParaWidgetTable extends JTable {
} }
@Override @Override
public Component getTableCellEditorComponent( JTable table,Object value, public Component getTableCellEditorComponent(JTable table, Object value,
boolean isSelected,int row,int column){ boolean isSelected, int row, int column) {
uiTableTextField.setText(value.toString()); uiTableTextField.setText(value.toString());
return uiTableTextField; return uiTableTextField;
} }
@ -360,7 +341,7 @@ class MobileParaWidgetTable extends JTable {
} }
Object[] rowValue = cellData[row]; Object[] rowValue = cellData[row];
if (column > -1 && column < rowValue.length) { if (column > -1 && column < rowValue.length) {
return cellData[row][column]; return cellData[row][1];
} }
return null; return null;
} }
@ -381,23 +362,24 @@ class MobileParaWidgetTable extends JTable {
return; return;
} }
if (aValue == null) { if (aValue == null) {
cellData[row][column] = null; cellData[row][1] = null;
return; return;
} }
cellData[row][column] = aValue.toString(); cellData[row][1] = aValue.toString();
} }
/** /**
* 是否可编辑 控件标签列可以编辑控件名不可编辑 * 是否可编辑 控件标签列可以编辑控件名不可编辑
*
* @param row 行号 * @param row 行号
* @param column 列号 * @param column 列号
* @return 是否可编辑 * @return 是否可编辑
*/ */
public boolean isCellEditable(int row, int column) { public boolean isCellEditable(int row, int column) {
if(column ==1){ // if(column ==1){
return false; return false;
} // }
return true; // return true;
} }
} }
@ -406,11 +388,11 @@ class MobileParaWidgetTable extends JTable {
* 继承自JTextField类重写了编辑框的样式 * 继承自JTextField类重写了编辑框的样式
*/ */
private class UITableTextField extends UITextField { private class UITableTextField extends UITextField {
public UITableTextField(){ public UITableTextField() {
super(); super();
} }
public UITableTextField(String string){ public UITableTextField(String string) {
super(string); super(string);
} }

2
designer_form/src/com/fr/design/mainframe/WidgetPropertyPane.java

@ -354,7 +354,7 @@ public class WidgetPropertyPane extends FormDockView implements BaseWidgetProper
int value = downPanel.getVerticalScrollBar().getValue(); int value = downPanel.getVerticalScrollBar().getValue();
if (hasSelectParaPane(getEditingFormDesigner())) { if (hasSelectParaPane(getEditingFormDesigner())) {
cardLayout.show(centerPane, PARA); cardLayout.show(centerPane, PARA);
mobileParaWidgetTable.refreshData(); // mobileParaWidgetTable.refreshData();
} else { } else {
cardLayout.show(centerPane, BODY); cardLayout.show(centerPane, BODY);
mobileWidgetTable.refreshData(); mobileWidgetTable.refreshData();

Loading…
Cancel
Save