From ee0c86589c37429a08ed54814b38c55756f8d2de Mon Sep 17 00:00:00 2001 From: hzzz Date: Thu, 24 Aug 2017 13:35:55 +0800 Subject: [PATCH 01/10] 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 02/10] 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 03/10] 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 04/10] 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 ef12593641aae6e9a9ab652ea441c8ec50422d90 Mon Sep 17 00:00:00 2001 From: vito Date: Thu, 24 Aug 2017 14:28:33 +0800 Subject: [PATCH 05/10] =?UTF-8?q?bugfix:=E5=8D=95=E5=85=83=E6=A0=BC?= =?UTF-8?q?=E5=85=83=E7=B4=A0=E6=8F=92=E5=85=A5=E5=86=85=E5=AE=B9=E4=B8=8B?= =?UTF-8?q?=E6=8B=89=E8=8F=9C=E5=8D=95=E5=90=8E=E5=8F=98=E4=B8=BA=E9=80=89?= =?UTF-8?q?=E4=B8=AD=E7=AC=AC=E4=B8=80=E4=B8=AA=E8=80=8C=E4=B8=8D=E6=98=AF?= =?UTF-8?q?=E4=B8=8A=E6=AC=A1=E9=80=89=E4=B8=AD=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/quickeditor/CellQuickEditor.java | 35 +++++-------------- .../fr/design/actions/core/ActionFactory.java | 15 ++++---- 2 files changed, 18 insertions(+), 32 deletions(-) diff --git a/designer/src/com/fr/quickeditor/CellQuickEditor.java b/designer/src/com/fr/quickeditor/CellQuickEditor.java index b2d66fc25..9f8ab61d2 100644 --- a/designer/src/com/fr/quickeditor/CellQuickEditor.java +++ b/designer/src/com/fr/quickeditor/CellQuickEditor.java @@ -2,6 +2,7 @@ package com.fr.quickeditor; import com.fr.design.actions.UpdateAction; import com.fr.design.actions.core.ActionFactory; +import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.iscrollbar.UIScrollBar; @@ -11,6 +12,7 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.CellElementPropertyPane; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.ElementCasePane; +import com.fr.design.mainframe.JTemplate; import com.fr.design.menu.MenuKeySet; import com.fr.design.menu.ShortCut; import com.fr.design.selection.QuickEditor; @@ -20,8 +22,6 @@ import com.fr.report.cell.TemplateCellElement; import com.fr.stable.ColumnRow; import javax.swing.*; -import javax.swing.event.PopupMenuEvent; -import javax.swing.event.PopupMenuListener; import java.awt.*; import java.awt.event.*; import java.util.ArrayList; @@ -119,10 +119,10 @@ public abstract class CellQuickEditor extends QuickEditor { cellLabel.setPreferredSize(new Dimension(60, 20)); UILabel insertContentLabel = new UILabel(Inter.getLocText("HF-Insert_Content")); insertContentLabel.setPreferredSize(new Dimension(60, 20)); - UIComboBox cellElementEditButton = initCellElementEditComboBox(); + UIComboBox cellElementEditComboBox = initCellElementEditComboBox(); Component[][] components = new Component[][]{ new Component[]{cellLabel, columnRowTextField = initColumnRowTextField()}, - new Component[]{insertContentLabel, cellElementEditButton}, + new Component[]{insertContentLabel, cellElementEditComboBox}, }; JPanel topContent = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); topContent.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 0)); @@ -136,6 +136,10 @@ public abstract class CellQuickEditor extends QuickEditor { * @return UIButton */ private UIComboBox initCellElementEditComboBox() { + JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + if (jTemplate == null) { + return comboBox = new UIComboBox(); + } final String[] items = getDefaultComboBoxItems(); comboBox = new UIComboBox(items); final Object comboBoxSelected = getComboBoxSelected(); @@ -144,31 +148,10 @@ public abstract class CellQuickEditor extends QuickEditor { } else { comboBox.setSelectedIndex(1); } - comboBox.addPopupMenuListener(new PopupMenuListener() { - @Override - public void popupMenuWillBecomeVisible(PopupMenuEvent e) { - if (cellInsertActions == null) { - cellInsertActions = ActionFactory.createCellInsertAction(ElementCasePane.class, tc); - } - // 这边重新获取是因为要根据JTemplate做一个过滤 - ArrayList arrayList = new ArrayList(); - for (UpdateAction action : cellInsertActions) { - arrayList.add(action.getMenuKeySet().getMenuKeySetName()); - } - comboBox.setModel(new DefaultComboBoxModel<>(arrayList.toArray(new String[arrayList.size()]))); - } - - @Override - public void popupMenuWillBecomeInvisible(PopupMenuEvent e) { - } - - @Override - public void popupMenuCanceled(PopupMenuEvent e) { - } - }); comboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { + cellInsertActions = ActionFactory.createCellInsertAction(ElementCasePane.class, tc); selectedIndex = comboBox.getSelectedIndex(); cellInsertActions[selectedIndex].actionPerformed(e); } diff --git a/designer_base/src/com/fr/design/actions/core/ActionFactory.java b/designer_base/src/com/fr/design/actions/core/ActionFactory.java index 01c070899..a8d958533 100644 --- a/designer_base/src/com/fr/design/actions/core/ActionFactory.java +++ b/designer_base/src/com/fr/design/actions/core/ActionFactory.java @@ -73,6 +73,7 @@ public class ActionFactory { /** * 注册图表的 地图资源 + * * @param action 地图资源action */ public static void registerChartMapEditorAction(UpdateAction action) { @@ -229,16 +230,18 @@ public class ActionFactory { public static MenuKeySet[] createCellInsertActionName() { List actionNames = new ArrayList<>(); + JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); for (Class clazz : actionClasses) { if (clazz == null) { continue; } - try { - Constructor c = (Constructor) clazz.getConstructor(); - actionNames.add(c.newInstance().getMenuKeySet()); - - } catch (Exception e) { - FRContext.getLogger().error(e.getMessage(), e); + if (jTemplate.acceptToolbarItem(clazz)) { + try { + Constructor c = (Constructor) clazz.getConstructor(); + actionNames.add(c.newInstance().getMenuKeySet()); + } catch (Exception e) { + FRContext.getLogger().error(e.getMessage(), e); + } } } return actionNames.toArray(new MenuKeySet[actionNames.size()]); From 6dd864e1811390f79adb179dc3861ca0765af6d0 Mon Sep 17 00:00:00 2001 From: hzzz Date: Thu, 24 Aug 2017 14:40:16 +0800 Subject: [PATCH 06/10] 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 800fb273b11bb8cd27f6221ea89458fc2b1ee27c Mon Sep 17 00:00:00 2001 From: vito Date: Thu, 24 Aug 2017 15:10:33 +0800 Subject: [PATCH 07/10] =?UTF-8?q?bugfix:=E5=8D=95=E5=85=83=E6=A0=BC?= =?UTF-8?q?=E5=85=83=E7=B4=A0=E6=8F=92=E5=85=A5=E5=86=85=E5=AE=B9=EF=BC=8C?= =?UTF-8?q?=E5=AF=B9=E8=AF=9D=E6=A1=86=E5=8F=96=E6=B6=88=E4=B9=8B=E5=90=8E?= =?UTF-8?q?=E5=9B=9E=E5=88=B0=E5=8E=9F=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- designer/src/com/fr/quickeditor/CellQuickEditor.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/designer/src/com/fr/quickeditor/CellQuickEditor.java b/designer/src/com/fr/quickeditor/CellQuickEditor.java index 9f8ab61d2..6f0530a70 100644 --- a/designer/src/com/fr/quickeditor/CellQuickEditor.java +++ b/designer/src/com/fr/quickeditor/CellQuickEditor.java @@ -51,6 +51,8 @@ public abstract class CellQuickEditor extends QuickEditor { /*占位label*/ protected static UILabel emptyLabel = new UILabel(); + private int currentSelectedIndex; + static { emptyLabel.setPreferredSize(new Dimension(60, 20)); } @@ -148,12 +150,14 @@ public abstract class CellQuickEditor extends QuickEditor { } else { comboBox.setSelectedIndex(1); } + currentSelectedIndex = comboBox.getSelectedIndex(); comboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { cellInsertActions = ActionFactory.createCellInsertAction(ElementCasePane.class, tc); selectedIndex = comboBox.getSelectedIndex(); cellInsertActions[selectedIndex].actionPerformed(e); + comboBox.setSelectedIndex(currentSelectedIndex); } }); return comboBox; From b4e4e6ea5f2453a2cbdc3a1d4e07f5b52632f8f6 Mon Sep 17 00:00:00 2001 From: hzzz Date: Thu, 24 Aug 2017 15:56:26 +0800 Subject: [PATCH 08/10] 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 09/10] 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; } } From bf6bbd019570e50e11eb1aaf603c4d1ebaa2aa22 Mon Sep 17 00:00:00 2001 From: kerry Date: Thu, 24 Aug 2017 16:48:44 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E6=95=B0=E7=BB=84=E5=AD=97=E5=85=B8?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E4=BF=9D=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/widget/ui/designer/btn/ButtonGroupDefinePane.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/designer_form/src/com/fr/design/widget/ui/designer/btn/ButtonGroupDefinePane.java b/designer_form/src/com/fr/design/widget/ui/designer/btn/ButtonGroupDefinePane.java index 2cfd8ce3c..5f60a8095 100644 --- a/designer_form/src/com/fr/design/widget/ui/designer/btn/ButtonGroupDefinePane.java +++ b/designer_form/src/com/fr/design/widget/ui/designer/btn/ButtonGroupDefinePane.java @@ -1,8 +1,8 @@ package com.fr.design.widget.ui.designer.btn; +import com.fr.data.Dictionary; import com.fr.design.designer.creator.*; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.itextfield.UITextField; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; @@ -67,6 +67,7 @@ public abstract class ButtonGroupDefinePane extends Field protected void populateSubFieldEditorBean(T e) { this.buttonGroupDictPane.populate(e); formWidgetValuePane.populate(e); + dictionaryEditor.setValue(e.getDictionary()); populateSubButtonGroupBean(e); } @@ -79,6 +80,7 @@ public abstract class ButtonGroupDefinePane extends Field T e = updateSubButtonGroupBean(); this.buttonGroupDictPane.update(e); formWidgetValuePane.update(e); + e.setDictionary((Dictionary) dictionaryEditor.getValue()); return e; }