|
|
@ -36,33 +36,37 @@ 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-Designer_Label"), Inter.getLocText("FR-Designer_Widgetname")}; |
|
|
|
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 static final int GAP = 11; |
|
|
|
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; |
|
|
|
private int GAP = 11; |
|
|
|
|
|
|
|
private boolean draging = false; |
|
|
|
private boolean draging = false; |
|
|
|
|
|
|
|
|
|
|
|
MobileParaWidgetTable(FormDesigner designer) { |
|
|
|
private void init(FormDesigner designer) { |
|
|
|
this.designer = designer; |
|
|
|
this.designer = designer; |
|
|
|
this.cellData = getData(); |
|
|
|
this.cellData = getData(); |
|
|
|
this.setTableProperties(); |
|
|
|
this.setTableProperties(); |
|
|
|
this.setDefaultEditor(Object.class, new MobileCellEditor()); |
|
|
|
this.setDefaultEditor(Object.class, new MobileCellEditor()); |
|
|
|
TableModel defaultModel = new BeanTableModel(); |
|
|
|
this.setModel(new BeanTableModel()); |
|
|
|
this.setModel(defaultModel); |
|
|
|
this.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); |
|
|
|
this.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); |
|
|
|
|
|
|
|
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()); |
|
|
|
refreshData(); |
|
|
|
refreshData(); |
|
|
|
this.addMouseListener(mouseAdapter); |
|
|
|
this.addMouseListener(mouseAdapter); |
|
|
|
this.addMouseMotionListener(mouseAdapter); |
|
|
|
this.addMouseMotionListener(mouseAdapter); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MobileParaWidgetTable(FormDesigner designer) { |
|
|
|
|
|
|
|
init(designer); |
|
|
|
add(moveComponent); |
|
|
|
add(moveComponent); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -140,7 +144,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 +156,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 +229,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()); |
|
|
@ -342,7 +349,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,10 +370,10 @@ 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(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -377,7 +384,7 @@ class MobileParaWidgetTable extends JTable { |
|
|
|
* @return 是否可编辑 |
|
|
|
* @return 是否可编辑 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public boolean isCellEditable(int row, int column) { |
|
|
|
public boolean isCellEditable(int row, int column) { |
|
|
|
return false; |
|
|
|
return column != 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|