From ee0c86589c37429a08ed54814b38c55756f8d2de Mon Sep 17 00:00:00 2001 From: hzzz Date: Thu, 24 Aug 2017 13:35:55 +0800 Subject: [PATCH 1/7] fix --- .../mainframe/MobileParaWidgetTable.java | 154 ++++++++++-------- 1 file changed, 88 insertions(+), 66 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java b/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java index e32ba8cc5..57402df94 100644 --- a/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java +++ b/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java @@ -1,12 +1,41 @@ package com.fr.design.mainframe; -import com.fr.design.designer.creator.XCreator; -import com.fr.design.designer.creator.XLayoutContainer; -import com.fr.design.designer.creator.XWParameterLayout; +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.XLayoutContainer; +import com.fr.design.designer.creator.XWParameterLayout; import com.fr.form.ui.Label; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WParameterLayout; @@ -14,18 +43,6 @@ import com.fr.general.ComparatorUtils; import com.fr.general.Inter; 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这一列 * Created with IntelliJ IDEA. @@ -36,12 +53,11 @@ import java.util.EventObject; */ class MobileParaWidgetTable extends JTable { - private final int WIDGET_NAME_COLUMN = 1; private FormDesigner designer; - private String[][] cellData; - private String[] headers = {Inter.getLocText("Form-Widget_Name")}; + private String[][] cellData ; + 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 UITEXTFIELD_WIDTH = 40; + private static final int UITEXTFIELD_WIDTH = 0; private UILabel moveComponent = new UILabel(); // 作为拖动时候随鼠标移动的那个半透明控件 private int selectedRow = -1; private int selectedColumn = -1; @@ -55,11 +71,13 @@ class MobileParaWidgetTable extends JTable { this.setDefaultEditor(Object.class, new MobileCellEditor()); TableModel defaultModel = new BeanTableModel(); this.setModel(defaultModel); - this.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); + this.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); TableColumn tc = this.getColumn(this.getColumnName(0)); + tc.setMinWidth(UITEXTFIELD_WIDTH); + tc.setMaxWidth(UITEXTFIELD_WIDTH); tc.setPreferredWidth(UITEXTFIELD_WIDTH); this.repaint(); - this.setDefaultRenderer(Object.class, new MobileWidgetTableCellRenderer()); + this.setDefaultRenderer(Object.class,new MobileWidgetTableCellRenderer()); refreshData(); this.addMouseListener(mouseAdapter); this.addMouseMotionListener(mouseAdapter); @@ -96,12 +114,12 @@ class MobileParaWidgetTable extends JTable { */ @Override public void mouseReleased(MouseEvent e) { - if (!draging) { + if(!draging){ return; } draging = 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); //拿取排序后表格数据,然后重绘表格 @@ -119,13 +137,13 @@ class MobileParaWidgetTable extends JTable { public void mouseMoved(MouseEvent e) { int overColumn = e.getX() < getColumnModel().getColumn(0).getWidth() ? 0 : 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) { overRow = i; //判断当前鼠标在哪一行 } } //如果鼠标移动到当前选中的行列上面的时候,并且不能在第一列 - if (overRow == selectedRow && overColumn == selectedColumn && overColumn != 0) { + if (overRow == selectedRow && overColumn == selectedColumn && overColumn !=0) { //把当前选中的那一列行的光标改成(除了第一列)移动样式MOVE_CURSOR setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); } else { @@ -140,31 +158,34 @@ class MobileParaWidgetTable extends JTable { */ @Override public void mouseDragged(MouseEvent e) { - int width = getColumnModel().getColumn(0).getWidth(); - setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); - draging = true; - moveComponent.setText(getValueAt(selectedRow, selectedColumn).toString()); - moveComponent.setLocation(getColumnModel().getColumn(0).getWidth(), e.getY() - GAP); - moveComponent.setSize(new Dimension(width, WIDGET_TABLE_ROW_HEIGHT)); - moveComponent.setVisible(true); - moveComponent.setForeground(Color.lightGray); - moveComponent.setBorder(BorderFactory.createLineBorder(Color.lightGray)); + int width = getColumnModel().getColumn(1).getWidth(); + //如果点击选中的是第二列,就可以拖动 + if (selectedColumn == 1){ + setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); + draging = true; + moveComponent.setText(getValueAt(selectedRow, selectedColumn).toString()); + moveComponent.setLocation(getColumnModel().getColumn(0).getWidth(), e.getY() - GAP); + moveComponent.setSize(new Dimension(width, WIDGET_TABLE_ROW_HEIGHT)); + moveComponent.setVisible(true); + moveComponent.setForeground(Color.lightGray); + moveComponent.setBorder(BorderFactory.createLineBorder(Color.lightGray)); + } } /** - * 设置鼠标单击时处理的事件 + * 设置鼠标单击时处理的事件(单击第二列的控件列表进入控件属性表) * @param e */ @Override public void mouseClicked(MouseEvent e) { - if (getSelectedRow() != -1 && getSelectedColumn() == 0) { + if(getSelectedRow() != -1 && getSelectedColumn() == 1){ String widgetName = cellData[getSelectedRow()][getSelectedColumn()]; - if (StringUtils.isNotEmpty(widgetName)) { + if (StringUtils.isNotEmpty(widgetName)){ int count = getEditingDesigner().getParaComponent().getComponentCount(); - for (int i = 0; i < count; i++) { - XCreator xCreator = (XCreator) getEditingDesigner().getParaComponent().getComponent(i); + for (int i = 0; i < count; i++){ + XCreator xCreator = (XCreator)getEditingDesigner().getParaComponent().getComponent(i); 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属性表 getEditingDesigner().getSelectionModel().setSelectedCreator(xCreator); } @@ -185,12 +206,12 @@ class MobileParaWidgetTable extends JTable { } }; - public MobileParaWidgetTable getInstance() { + public MobileParaWidgetTable getInstance(){ return this; } - private FormDesigner getEditingDesigner() { - return designer; + private FormDesigner getEditingDesigner(){ + return designer; } /** @@ -210,7 +231,7 @@ class MobileParaWidgetTable extends JTable { /** * 重新get排序后的数据 */ - public void refreshData() { + public void refreshData(){ cellData = getData(); } @@ -219,10 +240,10 @@ class MobileParaWidgetTable extends JTable { * * @return String[][] 二维数组,[0][0]widgetTag, [0][1]widgetName */ - private String[][] getData() { + private String[][] getData(){ XLayoutContainer paraContainer = designer.getParaComponent(); - if (paraContainer == null || !paraContainer.acceptType(XWParameterLayout.class)) { - return new String[0][1]; + if(paraContainer == null || !paraContainer.acceptType(XWParameterLayout.class)){ + return new String[0][0]; } WParameterLayout para = (WParameterLayout) (paraContainer.toData()); @@ -232,14 +253,14 @@ class MobileParaWidgetTable extends JTable { /** * 自定义的tableRender类 */ - private class MobileWidgetTableCellRenderer extends DefaultTableCellRenderer { + private class MobileWidgetTableCellRenderer extends DefaultTableCellRenderer{ @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - if (column == 0) { + if (column == 0){ UITextField uiTableTextField; - if (getSelectedColumn() == column && getSelectedRow() == row) { + if (getSelectedColumn() == column && getSelectedRow() == row){ uiTableTextField = new UITableTextField(value.toString()); } else { uiTableTextField = new UITextField(value.toString()); @@ -256,8 +277,7 @@ class MobileParaWidgetTable extends JTable { */ private class MobileCellEditor extends AbstractCellEditor implements TableCellEditor { UITableTextField uiTableTextField; - - MobileCellEditor() { + MobileCellEditor(){ uiTableTextField = new UITableTextField(); uiTableTextField.addFocusListener(new FocusAdapter() { @Override @@ -288,7 +308,7 @@ class MobileParaWidgetTable extends JTable { * cell改变,相应的nametag改变 */ - private void firePropertyChange() { + private void firePropertyChange(){ ((WParameterLayout) designer.getParaComponent().toData()).add2NameTagMap(uiTableTextField.getText(), cellData[getSelectedRow()][1]); ((WParameterLayout) designer.getParaComponent().toData()).setNameTagModified(cellData[getSelectedRow()][1], @@ -296,7 +316,7 @@ class MobileParaWidgetTable extends JTable { } @Override - public Object getCellEditorValue() { + public Object getCellEditorValue(){ return uiTableTextField.getText(); } @@ -309,8 +329,8 @@ class MobileParaWidgetTable extends JTable { } @Override - public Component getTableCellEditorComponent(JTable table, Object value, - boolean isSelected, int row, int column) { + public Component getTableCellEditorComponent( JTable table,Object value, + boolean isSelected,int row,int column){ uiTableTextField.setText(value.toString()); return uiTableTextField; } @@ -342,7 +362,7 @@ class MobileParaWidgetTable extends JTable { } Object[] rowValue = cellData[row]; if (column > -1 && column < rowValue.length) { - return cellData[row][WIDGET_NAME_COLUMN]; + return cellData[row][column]; } return null; } @@ -363,21 +383,23 @@ class MobileParaWidgetTable extends JTable { return; } if (aValue == null) { - cellData[row][WIDGET_NAME_COLUMN] = null; + cellData[row][column] = null; return; } - cellData[row][WIDGET_NAME_COLUMN] = aValue.toString(); + cellData[row][column] = aValue.toString(); } /** - * 是否可编辑 控件标签列可以编辑,控件名不可编辑 - * - * @param row 行号 - * @param column 列号 + * 是否可编辑 控件标签列可以编辑,控件名不可编辑 + * @param row 行号 + * @param column 列号 * @return 是否可编辑 */ public boolean isCellEditable(int row, int column) { - return false; + if(column ==1){ + return false; + } + return true; } } @@ -386,11 +408,11 @@ class MobileParaWidgetTable extends JTable { * 继承自JTextField类,重写了编辑框的样式 */ private class UITableTextField extends UITextField { - public UITableTextField() { + public UITableTextField(){ super(); } - public UITableTextField(String string) { + public UITableTextField(String string){ super(string); } From 25ab70797fe974a52d8d02c86e45c0f4ba7df8fd Mon Sep 17 00:00:00 2001 From: hzzz Date: Thu, 24 Aug 2017 13:36:54 +0800 Subject: [PATCH 2/7] tmp --- .../mainframe/MobileParaWidgetTable.java | 47 ++++++------------- 1 file changed, 15 insertions(+), 32 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java b/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java index 57402df94..5c3f3630d 100644 --- a/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java +++ b/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java @@ -1,41 +1,12 @@ 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.XLayoutContainer; 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.Widget; import com.fr.form.ui.container.WParameterLayout; @@ -43,6 +14,18 @@ import com.fr.general.ComparatorUtils; import com.fr.general.Inter; 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这一列 * Created with IntelliJ IDEA. From 2c297d511b42b4463548b009078a28176c79e7ae Mon Sep 17 00:00:00 2001 From: hzzz Date: Thu, 24 Aug 2017 13:50:10 +0800 Subject: [PATCH 3/7] format --- .../mainframe/MobileParaWidgetTable.java | 66 ++++++++++--------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java b/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java index 5c3f3630d..37555dd60 100644 --- a/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java +++ b/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java @@ -37,7 +37,7 @@ import java.util.EventObject; class MobileParaWidgetTable extends JTable { private FormDesigner designer; - private String[][] cellData ; + private String[][] cellData; 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 UITEXTFIELD_WIDTH = 0; @@ -60,7 +60,7 @@ class MobileParaWidgetTable extends JTable { tc.setMaxWidth(UITEXTFIELD_WIDTH); tc.setPreferredWidth(UITEXTFIELD_WIDTH); this.repaint(); - this.setDefaultRenderer(Object.class,new MobileWidgetTableCellRenderer()); + this.setDefaultRenderer(Object.class, new MobileWidgetTableCellRenderer()); refreshData(); this.addMouseListener(mouseAdapter); this.addMouseMotionListener(mouseAdapter); @@ -97,12 +97,12 @@ class MobileParaWidgetTable extends JTable { */ @Override public void mouseReleased(MouseEvent e) { - if(!draging){ + if (!draging) { return; } draging = 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); //拿取排序后表格数据,然后重绘表格 @@ -120,13 +120,13 @@ class MobileParaWidgetTable extends JTable { public void mouseMoved(MouseEvent e) { int overColumn = e.getX() < getColumnModel().getColumn(0).getWidth() ? 0 : 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) { overRow = i; //判断当前鼠标在哪一行 } } //如果鼠标移动到当前选中的行列上面的时候,并且不能在第一列 - if (overRow == selectedRow && overColumn == selectedColumn && overColumn !=0) { + if (overRow == selectedRow && overColumn == selectedColumn && overColumn != 0) { //把当前选中的那一列行的光标改成(除了第一列)移动样式MOVE_CURSOR setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); } else { @@ -143,7 +143,7 @@ class MobileParaWidgetTable extends JTable { public void mouseDragged(MouseEvent e) { int width = getColumnModel().getColumn(1).getWidth(); //如果点击选中的是第二列,就可以拖动 - if (selectedColumn == 1){ + if (selectedColumn == 1) { setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); draging = true; moveComponent.setText(getValueAt(selectedRow, selectedColumn).toString()); @@ -161,14 +161,14 @@ class MobileParaWidgetTable extends JTable { */ @Override public void mouseClicked(MouseEvent e) { - if(getSelectedRow() != -1 && getSelectedColumn() == 1){ + if (getSelectedRow() != -1 && getSelectedColumn() == 1) { String widgetName = cellData[getSelectedRow()][getSelectedColumn()]; - if (StringUtils.isNotEmpty(widgetName)){ + if (StringUtils.isNotEmpty(widgetName)) { int count = getEditingDesigner().getParaComponent().getComponentCount(); - for (int i = 0; i < count; i++){ - XCreator xCreator = (XCreator)getEditingDesigner().getParaComponent().getComponent(i); + for (int i = 0; i < count; i++) { + XCreator xCreator = (XCreator) getEditingDesigner().getParaComponent().getComponent(i); 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属性表 getEditingDesigner().getSelectionModel().setSelectedCreator(xCreator); } @@ -189,12 +189,12 @@ class MobileParaWidgetTable extends JTable { } }; - public MobileParaWidgetTable getInstance(){ + public MobileParaWidgetTable getInstance() { return this; } - private FormDesigner getEditingDesigner(){ - return designer; + private FormDesigner getEditingDesigner() { + return designer; } /** @@ -214,7 +214,7 @@ class MobileParaWidgetTable extends JTable { /** * 重新get排序后的数据 */ - public void refreshData(){ + public void refreshData() { cellData = getData(); } @@ -223,9 +223,9 @@ class MobileParaWidgetTable extends JTable { * * @return String[][] 二维数组,[0][0]widgetTag, [0][1]widgetName */ - private String[][] getData(){ + private String[][] getData() { XLayoutContainer paraContainer = designer.getParaComponent(); - if(paraContainer == null || !paraContainer.acceptType(XWParameterLayout.class)){ + if (paraContainer == null || !paraContainer.acceptType(XWParameterLayout.class)) { return new String[0][0]; } @@ -236,14 +236,14 @@ class MobileParaWidgetTable extends JTable { /** * 自定义的tableRender类 */ - private class MobileWidgetTableCellRenderer extends DefaultTableCellRenderer{ + private class MobileWidgetTableCellRenderer extends DefaultTableCellRenderer { @Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); - if (column == 0){ + if (column == 0) { UITextField uiTableTextField; - if (getSelectedColumn() == column && getSelectedRow() == row){ + if (getSelectedColumn() == column && getSelectedRow() == row) { uiTableTextField = new UITableTextField(value.toString()); } else { uiTableTextField = new UITextField(value.toString()); @@ -260,7 +260,8 @@ class MobileParaWidgetTable extends JTable { */ private class MobileCellEditor extends AbstractCellEditor implements TableCellEditor { UITableTextField uiTableTextField; - MobileCellEditor(){ + + MobileCellEditor() { uiTableTextField = new UITableTextField(); uiTableTextField.addFocusListener(new FocusAdapter() { @Override @@ -291,7 +292,7 @@ class MobileParaWidgetTable extends JTable { * cell改变,相应的nametag改变 */ - private void firePropertyChange(){ + private void firePropertyChange() { ((WParameterLayout) designer.getParaComponent().toData()).add2NameTagMap(uiTableTextField.getText(), cellData[getSelectedRow()][1]); ((WParameterLayout) designer.getParaComponent().toData()).setNameTagModified(cellData[getSelectedRow()][1], @@ -299,7 +300,7 @@ class MobileParaWidgetTable extends JTable { } @Override - public Object getCellEditorValue(){ + public Object getCellEditorValue() { return uiTableTextField.getText(); } @@ -312,8 +313,8 @@ class MobileParaWidgetTable extends JTable { } @Override - public Component getTableCellEditorComponent( JTable table,Object value, - boolean isSelected,int row,int column){ + public Component getTableCellEditorComponent(JTable table, Object value, + boolean isSelected, int row, int column) { uiTableTextField.setText(value.toString()); return uiTableTextField; } @@ -373,13 +374,14 @@ class MobileParaWidgetTable extends JTable { } /** - * 是否可编辑 控件标签列可以编辑,控件名不可编辑 - * @param row 行号 - * @param column 列号 + * 是否可编辑 控件标签列可以编辑,控件名不可编辑 + * + * @param row 行号 + * @param column 列号 * @return 是否可编辑 */ public boolean isCellEditable(int row, int column) { - if(column ==1){ + if (column == 1) { return false; } return true; @@ -391,11 +393,11 @@ class MobileParaWidgetTable extends JTable { * 继承自JTextField类,重写了编辑框的样式 */ private class UITableTextField extends UITextField { - public UITableTextField(){ + public UITableTextField() { super(); } - public UITableTextField(String string){ + public UITableTextField(String string) { super(string); } From 5f50ab43081338f9cb303f94cee068251494b5f8 Mon Sep 17 00:00:00 2001 From: hzzz Date: Thu, 24 Aug 2017 13:54:42 +0800 Subject: [PATCH 4/7] SonarQube --- .../com/fr/design/mainframe/MobileParaWidgetTable.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java b/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java index 37555dd60..2c6c06372 100644 --- a/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java +++ b/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java @@ -41,15 +41,19 @@ class MobileParaWidgetTable extends JTable { 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 UITEXTFIELD_WIDTH = 0; + private static final int GAP = 11; private UILabel moveComponent = new UILabel(); // 作为拖动时候随鼠标移动的那个半透明控件 private int selectedRow = -1; private int selectedColumn = -1; - private int GAP = 11; private boolean draging = false; - MobileParaWidgetTable(FormDesigner designer) { + private void init(FormDesigner designer) { this.designer = designer; this.cellData = getData(); + } + + MobileParaWidgetTable(FormDesigner designer) { + init(designer); this.setTableProperties(); this.setDefaultEditor(Object.class, new MobileCellEditor()); TableModel defaultModel = new BeanTableModel(); From 6dd864e1811390f79adb179dc3861ca0765af6d0 Mon Sep 17 00:00:00 2001 From: hzzz Date: Thu, 24 Aug 2017 14:40:16 +0800 Subject: [PATCH 5/7] SonarQube --- .../fr/design/mainframe/MobileParaWidgetTable.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java b/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java index 2c6c06372..940c2df58 100644 --- a/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java +++ b/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java @@ -50,14 +50,9 @@ class MobileParaWidgetTable extends JTable { private void init(FormDesigner designer) { this.designer = designer; this.cellData = getData(); - } - - MobileParaWidgetTable(FormDesigner designer) { - init(designer); this.setTableProperties(); this.setDefaultEditor(Object.class, new MobileCellEditor()); - TableModel defaultModel = new BeanTableModel(); - this.setModel(defaultModel); + this.setModel(new BeanTableModel()); this.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); TableColumn tc = this.getColumn(this.getColumnName(0)); tc.setMinWidth(UITEXTFIELD_WIDTH); @@ -68,6 +63,10 @@ class MobileParaWidgetTable extends JTable { refreshData(); this.addMouseListener(mouseAdapter); this.addMouseMotionListener(mouseAdapter); + } + + MobileParaWidgetTable(FormDesigner designer) { + init(designer); add(moveComponent); } From b4e4e6ea5f2453a2cbdc3a1d4e07f5b52632f8f6 Mon Sep 17 00:00:00 2001 From: hzzz Date: Thu, 24 Aug 2017 15:56:26 +0800 Subject: [PATCH 6/7] fix --- designer_base/src/com/fr/design/locale/designer.properties | 4 +++- .../src/com/fr/design/locale/designer_en_US.properties | 4 +++- .../src/com/fr/design/locale/designer_ja_JP.properties | 2 ++ .../src/com/fr/design/locale/designer_ko_KR.properties | 4 +++- .../src/com/fr/design/locale/designer_zh_CN.properties | 4 +++- .../src/com/fr/design/locale/designer_zh_TW.properties | 2 ++ .../src/com/fr/design/mainframe/MobileParaWidgetTable.java | 2 +- 7 files changed, 17 insertions(+), 5 deletions(-) diff --git a/designer_base/src/com/fr/design/locale/designer.properties b/designer_base/src/com/fr/design/locale/designer.properties index 9423c23a7..c048d29c5 100644 --- a/designer_base/src/com/fr/design/locale/designer.properties +++ b/designer_base/src/com/fr/design/locale/designer.properties @@ -2129,4 +2129,6 @@ FR-Designer_Mobile-Height-Limit=Height Limit FR-Designer-AlphaFine_NO_Result=no search result FR-Designer-Download_Online_Sources= FR-Designer_Select_Color=Select Color -FR-Designer-Basic_Dynamic_Parameter_Injection=Injection \ No newline at end of file +FR-Designer-Basic_Dynamic_Parameter_Injection=Injection +FR-Designer_Label= +FR-Designer_Widgetname=Widget Name \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_en_US.properties b/designer_base/src/com/fr/design/locale/designer_en_US.properties index bb48b927d..4a87f1620 100644 --- a/designer_base/src/com/fr/design/locale/designer_en_US.properties +++ b/designer_base/src/com/fr/design/locale/designer_en_US.properties @@ -2125,4 +2125,6 @@ FS-Designer_DS_Filter_Specify_Tip=Specify_Tip FR-Designer-AlphaFine_NO_Result=no search result FR-Designer-Download_Online_Sources= FR-Designer_Select_Color=Select Color -FR-Designer-Basic_Dynamic_Parameter_Injection=Injection \ No newline at end of file +FR-Designer-Basic_Dynamic_Parameter_Injection=Injection +FR-Designer_Label=Label +FR-Designer_Widgetname=Widget Name \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties index 94768d087..05783bc7b 100644 --- a/designer_base/src/com/fr/design/locale/designer_ja_JP.properties +++ b/designer_base/src/com/fr/design/locale/designer_ja_JP.properties @@ -2124,3 +2124,5 @@ FR-Designer_Mobile-Height-Limit= FR-Designer-Download_Online_Sources= FR-Designer_Select_Color= FR-Designer-Basic_Dynamic_Parameter_Injection=\ +FR-Designer_Label=\u30E9\u30D9\u30EBa +FR-Designer_Widgetname=\u30B3\u30F3\u30C8\u30ED\u30FC\u30EB\u540D diff --git a/designer_base/src/com/fr/design/locale/designer_ko_KR.properties b/designer_base/src/com/fr/design/locale/designer_ko_KR.properties index c9cacdb7e..6a660743d 100644 --- a/designer_base/src/com/fr/design/locale/designer_ko_KR.properties +++ b/designer_base/src/com/fr/design/locale/designer_ko_KR.properties @@ -2124,4 +2124,6 @@ FR-Designer_Mobile-Height-Percent= FR-Designer_Mobile-Height-Limit= FR-Designer-Download_Online_Sources= FR-Designer_Select_Color= -FR-Designer-Basic_Dynamic_Parameter_Injection= \ No newline at end of file +FR-Designer-Basic_Dynamic_Parameter_Injection= +FR-Designer_Label=\uB808\uC774\uBE14 +FR-Designer_Widgetname=\uC18C\uD504\uD2B8\uC6E8\uC5B4\uC81C\uC5B4\uC774\uB984 \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties index d4cfbba9c..e9b593318 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_CN.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_CN.properties @@ -2136,4 +2136,6 @@ FS-Designer_DS_Filter_Specify_Tip=\u63D0\u793A\uFF1A\u683C\u5F0F\u4E3A1,2-3,5,8\ FR-Designer-AlphaFine_NO_Result=\u65E0\u641C\u7D22\u7ED3\u679C FR-Designer-Download_Online_Sources=\u56FE\u8868\u9700\u8981\u4E0B\u8F7D\u6700\u65B0\u7684\u8D44\u6E90\u6587\u4EF6\uFF0C\u662F\u5426\u5B89\u88C5\uFF1F FR-Designer_Select_Color=\u9009\u62E9\u989C\u8272 -FR-Designer-Basic_Dynamic_Parameter_Injection=\u6CE8\u5165 \ No newline at end of file +FR-Designer-Basic_Dynamic_Parameter_Injection=\u6CE8\u5165 +FR-Designer_Label=\u6807\u7B7E +FR-Designer_Widgetname=\u63A7\u4EF6\u540D \ No newline at end of file diff --git a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties index fe2839aee..95c67c32a 100644 --- a/designer_base/src/com/fr/design/locale/designer_zh_TW.properties +++ b/designer_base/src/com/fr/design/locale/designer_zh_TW.properties @@ -2129,3 +2129,5 @@ FR-Designer-AlphaFine_NO_Result=\u7121\u641C\u7D22\u7D50\u679C FR-Designer-Download_Online_Sources= FR-Designer_Select_Color= FR-Designer-Basic_Dynamic_Parameter_Injection=\u6CE8\u5165 +FR-Designer_Label=\u6A19\u7C3D +FR-Designer_Widgetname=\u63A7\u5236\u9805\u540D diff --git a/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java b/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java index 940c2df58..5788f22f4 100644 --- a/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java +++ b/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java @@ -38,7 +38,7 @@ class MobileParaWidgetTable extends JTable { private FormDesigner designer; private String[][] cellData; - private String[] headers = {Inter.getLocText("FR-Utils_Label"), 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 UITEXTFIELD_WIDTH = 0; private static final int GAP = 11; From 1cc5c6903eb3758e4aa86afece73ebfd2989e6a7 Mon Sep 17 00:00:00 2001 From: hzzz Date: Thu, 24 Aug 2017 15:57:11 +0800 Subject: [PATCH 7/7] fix --- .../src/com/fr/design/mainframe/MobileParaWidgetTable.java | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java b/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java index 5788f22f4..e7e5089b5 100644 --- a/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java +++ b/designer_form/src/com/fr/design/mainframe/MobileParaWidgetTable.java @@ -384,10 +384,7 @@ class MobileParaWidgetTable extends JTable { * @return 是否可编辑 */ public boolean isCellEditable(int row, int column) { - if (column == 1) { - return false; - } - return true; + return column != 1; } }