|
|
@ -1,12 +1,41 @@ |
|
|
|
package com.fr.design.mainframe; |
|
|
|
package com.fr.design.mainframe; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.fr.design.designer.creator.XCreator; |
|
|
|
import java.awt.BasicStroke; |
|
|
|
import com.fr.design.designer.creator.XLayoutContainer; |
|
|
|
import java.awt.Color; |
|
|
|
import com.fr.design.designer.creator.XWParameterLayout; |
|
|
|
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.ilable.UILabel; |
|
|
|
|
|
|
|
import com.fr.design.gui.itable.GroupRenderer; |
|
|
|
import com.fr.design.gui.itable.HeaderRenderer; |
|
|
|
import com.fr.design.gui.itable.HeaderRenderer; |
|
|
|
import com.fr.design.gui.itextfield.UITextField; |
|
|
|
import com.fr.design.gui.itextfield.UITextField; |
|
|
|
|
|
|
|
import com.fr.design.designer.creator.XCreator; |
|
|
|
|
|
|
|
import com.fr.design.designer.creator.XLayoutContainer; |
|
|
|
|
|
|
|
import com.fr.design.designer.creator.XWParameterLayout; |
|
|
|
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; |
|
|
@ -14,18 +43,6 @@ 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. |
|
|
@ -36,12 +53,11 @@ import java.util.EventObject; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
class MobileParaWidgetTable extends JTable { |
|
|
|
class MobileParaWidgetTable extends JTable { |
|
|
|
|
|
|
|
|
|
|
|
private final int WIDGET_NAME_COLUMN = 1; |
|
|
|
|
|
|
|
private FormDesigner designer; |
|
|
|
private FormDesigner designer; |
|
|
|
private String[][] cellData ; |
|
|
|
private String[][] cellData ; |
|
|
|
private String[] headers = {Inter.getLocText("Form-Widget_Name")}; |
|
|
|
private String[] headers = {Inter.getLocText("FR-Utils_Label"), 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 = 0; |
|
|
|
private UILabel moveComponent = new UILabel(); // 作为拖动时候随鼠标移动的那个半透明控件
|
|
|
|
private UILabel moveComponent = new UILabel(); // 作为拖动时候随鼠标移动的那个半透明控件
|
|
|
|
private int selectedRow = -1; |
|
|
|
private int selectedRow = -1; |
|
|
|
private int selectedColumn = -1; |
|
|
|
private int selectedColumn = -1; |
|
|
@ -55,8 +71,10 @@ class MobileParaWidgetTable extends JTable { |
|
|
|
this.setDefaultEditor(Object.class, new MobileCellEditor()); |
|
|
|
this.setDefaultEditor(Object.class, new MobileCellEditor()); |
|
|
|
TableModel defaultModel = new BeanTableModel(); |
|
|
|
TableModel defaultModel = new BeanTableModel(); |
|
|
|
this.setModel(defaultModel); |
|
|
|
this.setModel(defaultModel); |
|
|
|
this.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); |
|
|
|
this.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); |
|
|
|
TableColumn tc = this.getColumn(this.getColumnName(0)); |
|
|
|
TableColumn tc = this.getColumn(this.getColumnName(0)); |
|
|
|
|
|
|
|
tc.setMinWidth(UITEXTFIELD_WIDTH); |
|
|
|
|
|
|
|
tc.setMaxWidth(UITEXTFIELD_WIDTH); |
|
|
|
tc.setPreferredWidth(UITEXTFIELD_WIDTH); |
|
|
|
tc.setPreferredWidth(UITEXTFIELD_WIDTH); |
|
|
|
this.repaint(); |
|
|
|
this.repaint(); |
|
|
|
this.setDefaultRenderer(Object.class,new MobileWidgetTableCellRenderer()); |
|
|
|
this.setDefaultRenderer(Object.class,new MobileWidgetTableCellRenderer()); |
|
|
@ -140,7 +158,9 @@ class MobileParaWidgetTable extends JTable { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void mouseDragged(MouseEvent e) { |
|
|
|
public void mouseDragged(MouseEvent e) { |
|
|
|
int width = getColumnModel().getColumn(0).getWidth(); |
|
|
|
int width = getColumnModel().getColumn(1).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()); |
|
|
@ -150,14 +170,15 @@ class MobileParaWidgetTable extends JTable { |
|
|
|
moveComponent.setForeground(Color.lightGray); |
|
|
|
moveComponent.setForeground(Color.lightGray); |
|
|
|
moveComponent.setBorder(BorderFactory.createLineBorder(Color.lightGray)); |
|
|
|
moveComponent.setBorder(BorderFactory.createLineBorder(Color.lightGray)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 设置鼠标单击时处理的事件 |
|
|
|
* 设置鼠标单击时处理的事件(单击第二列的控件列表进入控件属性表) |
|
|
|
* @param e |
|
|
|
* @param e |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void mouseClicked(MouseEvent e) { |
|
|
|
public void mouseClicked(MouseEvent e) { |
|
|
|
if (getSelectedRow() != -1 && getSelectedColumn() == 0) { |
|
|
|
if(getSelectedRow() != -1 && getSelectedColumn() == 1){ |
|
|
|
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(); |
|
|
@ -222,7 +243,7 @@ class MobileParaWidgetTable extends JTable { |
|
|
|
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][1]; |
|
|
|
return new String[0][0]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
WParameterLayout para = (WParameterLayout) (paraContainer.toData()); |
|
|
|
WParameterLayout para = (WParameterLayout) (paraContainer.toData()); |
|
|
@ -256,7 +277,6 @@ 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() { |
|
|
@ -342,7 +362,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][WIDGET_NAME_COLUMN]; |
|
|
|
return cellData[row][column]; |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
@ -363,22 +383,24 @@ class MobileParaWidgetTable extends JTable { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
if (aValue == null) { |
|
|
|
if (aValue == null) { |
|
|
|
cellData[row][WIDGET_NAME_COLUMN] = null; |
|
|
|
cellData[row][column] = null; |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
cellData[row][WIDGET_NAME_COLUMN] = aValue.toString(); |
|
|
|
cellData[row][column] = 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){ |
|
|
|
return false; |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|