|
|
|
@ -1,21 +1,5 @@
|
|
|
|
|
package com.fr.design.write.submit; |
|
|
|
|
|
|
|
|
|
import java.awt.BorderLayout; |
|
|
|
|
import java.awt.Component; |
|
|
|
|
import java.awt.Container; |
|
|
|
|
import java.awt.Dialog; |
|
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
|
|
|
|
|
|
import javax.swing.BorderFactory; |
|
|
|
|
import javax.swing.JDialog; |
|
|
|
|
import javax.swing.JPanel; |
|
|
|
|
import javax.swing.JTable; |
|
|
|
|
import javax.swing.SwingUtilities; |
|
|
|
|
import javax.swing.SwingWorker; |
|
|
|
|
import javax.swing.table.DefaultTableCellRenderer; |
|
|
|
|
import javax.swing.table.TableCellRenderer; |
|
|
|
|
import javax.swing.table.TableColumn; |
|
|
|
|
|
|
|
|
|
import com.fr.cache.list.IntList; |
|
|
|
|
import com.fr.data.ClassSubmitJob; |
|
|
|
|
import com.fr.design.actions.UpdateAction; |
|
|
|
@ -30,13 +14,16 @@ import com.fr.design.gui.controlpane.NameObjectCreator;
|
|
|
|
|
import com.fr.design.gui.controlpane.NameableCreator; |
|
|
|
|
import com.fr.design.gui.ilable.UILabel; |
|
|
|
|
import com.fr.design.gui.ispinner.UIBasicSpinner; |
|
|
|
|
import com.fr.design.i18n.Toolkit; |
|
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
|
import com.fr.design.layout.TableLayout; |
|
|
|
|
import com.fr.design.layout.TableLayoutHelper; |
|
|
|
|
import com.fr.design.mainframe.*; |
|
|
|
|
import com.fr.design.mainframe.DesignerContext; |
|
|
|
|
import com.fr.design.mainframe.ElementCasePane; |
|
|
|
|
import com.fr.design.mainframe.JTemplate; |
|
|
|
|
import com.fr.design.mainframe.JWorkBook; |
|
|
|
|
import com.fr.design.selection.SelectionEvent; |
|
|
|
|
import com.fr.design.selection.SelectionListener; |
|
|
|
|
|
|
|
|
|
import com.fr.grid.selection.CellSelection; |
|
|
|
|
import com.fr.grid.selection.FloatSelection; |
|
|
|
|
import com.fr.grid.selection.Selection; |
|
|
|
@ -45,6 +32,12 @@ import com.fr.stable.ColumnRowGroup;
|
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
import com.fr.write.DMLConfigJob; |
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
|
import javax.swing.table.DefaultTableCellRenderer; |
|
|
|
|
import javax.swing.table.TableColumn; |
|
|
|
|
import java.awt.*; |
|
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
|
|
|
|
|
|
public class SmartInsertDBManipulationPane extends DBManipulationPane { |
|
|
|
|
private static final Selection NO_SELECTION = new CellSelection(-1, -1, -1, -1); |
|
|
|
|
private ElementCasePane ePane; |
|
|
|
@ -88,7 +81,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public NameableCreator[] createNameableCreators() { |
|
|
|
|
return new NameableCreator[] { |
|
|
|
|
return new NameableCreator[]{ |
|
|
|
|
new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nTextArray(new String[]{"Submit", "Event"}), |
|
|
|
|
"/com/fr/web/images/reportlet.png", |
|
|
|
|
DMLConfigJob.class, |
|
|
|
@ -96,13 +89,13 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
|
|
|
|
|
new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nTextArray(new String[]{"Custom", "Event"}), |
|
|
|
|
"/com/fr/web/images/reportlet.png", |
|
|
|
|
ClassSubmitJob.class, |
|
|
|
|
CustomSubmitJobPane.class) }; |
|
|
|
|
CustomSubmitJobPane.class)}; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected UpdateAction[] getActions() { |
|
|
|
|
return new UpdateAction[] { |
|
|
|
|
return new UpdateAction[]{ |
|
|
|
|
new SmartAddFieldsAction(), |
|
|
|
|
new AddFieldAction(), |
|
|
|
|
new SmartAddCellAction(), |
|
|
|
@ -119,6 +112,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 执行事件 |
|
|
|
|
* |
|
|
|
|
* @param evt 事件对象 |
|
|
|
|
*/ |
|
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
@ -132,15 +126,15 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
|
|
|
|
|
bPane.setBorder(BorderFactory.createEmptyBorder(TOP_PADDING, 0, 0, 0)); |
|
|
|
|
final UIBasicSpinner columnSpinner = new UIBasicSpinner(); |
|
|
|
|
final UIBasicSpinner rowSpinner = new UIBasicSpinner(); |
|
|
|
|
Component[][] coms = new Component[][] { { new UILabel(com.fr.design.i18n.Toolkit.i18nText("RWA-Row_Offset")), rowSpinner },{ new UILabel(com.fr.design.i18n.Toolkit.i18nText("RWA-Column_Offset")), columnSpinner } }; |
|
|
|
|
Component[][] coms = new Component[][]{{new UILabel(com.fr.design.i18n.Toolkit.i18nText("RWA-Row_Offset")), rowSpinner}, {new UILabel(com.fr.design.i18n.Toolkit.i18nText("RWA-Column_Offset")), columnSpinner}}; |
|
|
|
|
double p = TableLayout.PREFERRED; |
|
|
|
|
double f = TableLayout.FILL; |
|
|
|
|
bPane.add(TableLayoutHelper.createTableLayoutPane(coms, new double[]{p, p}, new double[]{p, f}), BorderLayout.NORTH); |
|
|
|
|
BasicDialog dlg = bPane.showSmallWindow(SwingUtilities.getWindowAncestor(SmartInsertDBManipulationPane.this), new DialogActionAdapter() { |
|
|
|
|
public void doOk() { |
|
|
|
|
int row_offset = ((Number)rowSpinner.getValue()).intValue(); |
|
|
|
|
int column_offset = ((Number)columnSpinner.getValue()).intValue(); |
|
|
|
|
KeyColumnTableModel model = (KeyColumnTableModel)keyColumnValuesTable.getModel(); |
|
|
|
|
int row_offset = ((Number) rowSpinner.getValue()).intValue(); |
|
|
|
|
int column_offset = ((Number) columnSpinner.getValue()).intValue(); |
|
|
|
|
KeyColumnTableModel model = (KeyColumnTableModel) keyColumnValuesTable.getModel(); |
|
|
|
|
int[] selectedRows = keyColumnValuesTable.getSelectedRows(); |
|
|
|
|
// 如果一行都没选中,取所有的行
|
|
|
|
|
if (selectedRows.length == 0) { |
|
|
|
@ -150,7 +144,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
|
|
|
|
|
int row = selectedRows[i]; |
|
|
|
|
KeyColumnNameValue kcnv = model.getKeyColumnNameValue(row); |
|
|
|
|
if (kcnv.cv.obj instanceof ColumnRow) { |
|
|
|
|
ColumnRow or = (ColumnRow)kcnv.cv.obj; |
|
|
|
|
ColumnRow or = (ColumnRow) kcnv.cv.obj; |
|
|
|
|
int n_column = or.getColumn() + column_offset; |
|
|
|
|
if (n_column < 0) { |
|
|
|
|
n_column = 0; |
|
|
|
@ -180,6 +174,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 执行事件 |
|
|
|
|
* |
|
|
|
|
* @param evt 事件s |
|
|
|
|
*/ |
|
|
|
|
public void actionPerformed(ActionEvent evt) { |
|
|
|
@ -194,6 +189,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 智能添加单元格组 |
|
|
|
|
* |
|
|
|
|
* @param e 事件s |
|
|
|
|
*/ |
|
|
|
|
public void actionPerformed(ActionEvent e) { |
|
|
|
@ -203,10 +199,11 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 切换到单元格窗口,设置属性面板不可编辑 |
|
|
|
|
* |
|
|
|
|
* @param isCellGroup 判断是否单元格组 |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
private void showCellWindow(boolean isCellGroup){ |
|
|
|
|
private void showCellWindow(boolean isCellGroup) { |
|
|
|
|
if (ePane == null) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -232,7 +229,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
|
|
|
|
|
private void showDialogAfterAddCellAction() { |
|
|
|
|
Container dialog = this; |
|
|
|
|
if (parentPane != null && parentPane.getContentDBManiPane() instanceof SmartInsertDBManipulationPane && parentPane.getContentDBManiPane() != this) { |
|
|
|
|
((SmartInsertDBManipulationPane)parentPane.getContentDBManiPane()).showDialogAfterAddCellAction(); |
|
|
|
|
((SmartInsertDBManipulationPane) parentPane.getContentDBManiPane()).showDialogAfterAddCellAction(); |
|
|
|
|
} |
|
|
|
|
while (dialog.getParent() != null) { |
|
|
|
|
dialog = dialog.getParent(); |
|
|
|
@ -254,7 +251,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
|
|
|
|
|
private void hideDialog4AddCellAction() { |
|
|
|
|
Container dialog = this; |
|
|
|
|
if (parentPane != null && parentPane.getContentDBManiPane() instanceof SmartInsertDBManipulationPane && parentPane.getContentDBManiPane() != this) { |
|
|
|
|
((SmartInsertDBManipulationPane)parentPane.getContentDBManiPane()).hideDialog4AddCellAction(); |
|
|
|
|
((SmartInsertDBManipulationPane) parentPane.getContentDBManiPane()).hideDialog4AddCellAction(); |
|
|
|
|
} |
|
|
|
|
while (dialog.getParent() != null) { |
|
|
|
|
dialog = dialog.getParent(); |
|
|
|
@ -268,13 +265,14 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 检测是否合法 |
|
|
|
|
* |
|
|
|
|
* @throws Exception |
|
|
|
|
*/ |
|
|
|
|
public void checkValid() throws Exception { |
|
|
|
|
KeyColumnTableModel model = (KeyColumnTableModel)keyColumnValuesTable.getModel(); |
|
|
|
|
KeyColumnTableModel model = (KeyColumnTableModel) keyColumnValuesTable.getModel(); |
|
|
|
|
int cnt = model.getRowCount(); |
|
|
|
|
int groupLength = -1; |
|
|
|
|
for (int i=0; i<cnt; i++) { |
|
|
|
|
for (int i = 0; i < cnt; i++) { |
|
|
|
|
KeyColumnNameValue kcv = model.getKeyColumnNameValue(i); |
|
|
|
|
Object val = kcv.cv.obj; |
|
|
|
|
if (val instanceof ColumnRowGroup) { |
|
|
|
@ -346,6 +344,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 检查是否合法 |
|
|
|
|
* |
|
|
|
|
* @throws Exception |
|
|
|
|
*/ |
|
|
|
|
public void checkValid() throws Exception { |
|
|
|
@ -356,17 +355,17 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void selectionChanged(SelectionEvent e) { |
|
|
|
|
KeyColumnTableModel model = (KeyColumnTableModel)table.getModel(); |
|
|
|
|
KeyColumnTableModel model = (KeyColumnTableModel) table.getModel(); |
|
|
|
|
if (editingRowIndex < 0 || editingRowIndex >= model.getRowCount()) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
KeyColumnNameValue kcv = model.getKeyColumnNameValue(editingRowIndex); |
|
|
|
|
ElementCasePane currentReportPane = (ElementCasePane)e.getSource(); |
|
|
|
|
ElementCasePane currentReportPane = (ElementCasePane) e.getSource(); |
|
|
|
|
Selection selection = currentReportPane.getSelection(); |
|
|
|
|
if (selection == NO_SELECTION || selection instanceof FloatSelection) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
CellSelection cellselection = (CellSelection)selection; |
|
|
|
|
CellSelection cellselection = (CellSelection) selection; |
|
|
|
|
kcv.cv.obj = ColumnRow.valueOf(cellselection.getColumn(), cellselection.getRow()); |
|
|
|
|
|
|
|
|
|
if (editingRowIndex >= model.getRowCount() - 1) { |
|
|
|
@ -387,17 +386,17 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
|
|
|
|
|
private SelectionListener groupListener = new SelectionListener() { |
|
|
|
|
@Override |
|
|
|
|
public void selectionChanged(SelectionEvent e) { |
|
|
|
|
KeyColumnTableModel model = (KeyColumnTableModel)table.getModel(); |
|
|
|
|
KeyColumnTableModel model = (KeyColumnTableModel) table.getModel(); |
|
|
|
|
if (editingRowIndex < 0 || editingRowIndex >= model.getRowCount()) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
KeyColumnNameValue kcv = model.getKeyColumnNameValue(editingRowIndex); |
|
|
|
|
ElementCasePane currentReportPane = (ElementCasePane)e.getSource(); |
|
|
|
|
ElementCasePane currentReportPane = (ElementCasePane) e.getSource(); |
|
|
|
|
Selection selection = currentReportPane.getSelection(); |
|
|
|
|
if (selection == NO_SELECTION || selection instanceof FloatSelection) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
CellSelection cellselection = (CellSelection)selection; |
|
|
|
|
CellSelection cellselection = (CellSelection) selection; |
|
|
|
|
Object oriValue = kcv.cv.obj; |
|
|
|
|
ColumnRowGroup newValue = getColumnRowGroupValue(oriValue); |
|
|
|
|
|
|
|
|
@ -415,7 +414,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
|
|
|
|
|
if (add.getSize() > 0) { |
|
|
|
|
newValue.addAll(add); |
|
|
|
|
} else if (removeCount > 0) { |
|
|
|
|
newValue.splice(newValue.getSize()-removeCount, removeCount); |
|
|
|
|
newValue.splice(newValue.getSize() - removeCount, removeCount); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
kcv.cv.obj = newValue; |
|
|
|
@ -428,7 +427,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
|
|
|
|
|
private ColumnRowGroup getColumnRowGroupValue(Object oriValue) { |
|
|
|
|
ColumnRowGroup newValue = new ColumnRowGroup(); |
|
|
|
|
if (oriValue instanceof ColumnRowGroup) { |
|
|
|
|
newValue.addAll((ColumnRowGroup)oriValue); |
|
|
|
|
newValue.addAll((ColumnRowGroup) oriValue); |
|
|
|
|
} else if (oriValue instanceof ColumnRow) { |
|
|
|
|
newValue.addColumnRow((ColumnRow) oriValue); |
|
|
|
|
} |
|
|
|
@ -442,14 +441,14 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
|
|
|
|
|
private int dealDragSelection(ColumnRowGroup add, CellSelection cellselection) { |
|
|
|
|
int removeCount = 0; |
|
|
|
|
if (cellselection.getRowSpan() == oriCellSelection.getRowSpan() + 1) { |
|
|
|
|
for (int i=0; i<cellselection.getColumnSpan(); i++) { |
|
|
|
|
for (int i = 0; i < cellselection.getColumnSpan(); i++) { |
|
|
|
|
add.addColumnRow(ColumnRow.valueOf( |
|
|
|
|
cellselection.getColumn() + i, cellselection.getRow() + cellselection.getRowSpan() -1)); |
|
|
|
|
cellselection.getColumn() + i, cellselection.getRow() + cellselection.getRowSpan() - 1)); |
|
|
|
|
} |
|
|
|
|
} else if (cellselection.getRowSpan() == oriCellSelection.getRowSpan() - 1) { |
|
|
|
|
removeCount = cellselection.getColumnSpan(); |
|
|
|
|
} else if (cellselection.getColumnSpan() == oriCellSelection.getColumnSpan() + 1) { |
|
|
|
|
for (int i=0; i<cellselection.getRowSpan(); i++) { |
|
|
|
|
for (int i = 0; i < cellselection.getRowSpan(); i++) { |
|
|
|
|
add.addColumnRow(ColumnRow.valueOf( |
|
|
|
|
cellselection.getColumn() + cellselection.getColumnSpan() - 1, cellselection.getRow() + i)); |
|
|
|
|
} |
|
|
|
@ -462,9 +461,9 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
|
|
|
|
|
private void dealSelectColRow(ColumnRowGroup add, CellSelection se) { |
|
|
|
|
int c = se.getColumn(), cs = se.getColumnSpan(), |
|
|
|
|
r = se.getRow(), rs = se.getRowSpan(); |
|
|
|
|
for (int i=0; i<cs; i++) { |
|
|
|
|
for (int j=0; j<rs; j++) { |
|
|
|
|
add.addColumnRow(ColumnRow.valueOf(c+i, r+j)); |
|
|
|
|
for (int i = 0; i < cs; i++) { |
|
|
|
|
for (int j = 0; j < rs; j++) { |
|
|
|
|
add.addColumnRow(ColumnRow.valueOf(c + i, r + j)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -486,7 +485,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
updateUpdateCheckBoxEnable(); |
|
|
|
|
((SmartInsertDBManipulationPane)dialog).showDialogAfterAddCellAction(); |
|
|
|
|
((SmartInsertDBManipulationPane) dialog).showDialogAfterAddCellAction(); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
@ -499,8 +498,8 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
|
|
|
|
|
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); |
|
|
|
|
|
|
|
|
|
if (value instanceof ColumnValue) { |
|
|
|
|
if (((ColumnValue)value).obj != null) { |
|
|
|
|
this.setText(((ColumnValue)value).obj.toString()); |
|
|
|
|
if (((ColumnValue) value).obj != null) { |
|
|
|
|
this.setText(((ColumnValue) value).obj.toString()); |
|
|
|
|
} else { |
|
|
|
|
this.setText(StringUtils.EMPTY); |
|
|
|
|
} |
|
|
|
@ -525,9 +524,10 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
|
|
|
|
|
|
|
|
|
|
if (value instanceof ColumnValue) { |
|
|
|
|
Object cv = ((ColumnValue) value).obj; |
|
|
|
|
if (cv instanceof ColumnRowGroup && ((ColumnRowGroup)cv).getSize() >= CELL_GROUP_LIMIT) { |
|
|
|
|
this.setText("[" + com.fr.design.i18n.Toolkit.i18nTextArray(new String[]{"Has_Selected", "Classifier-Ge", "Cell"}, |
|
|
|
|
new String[]{((ColumnRowGroup)cv).getSize()+StringUtils.EMPTY, StringUtils.EMPTY}) + "]"); |
|
|
|
|
if (cv instanceof ColumnRowGroup && ((ColumnRowGroup) cv).getSize() >= CELL_GROUP_LIMIT) { |
|
|
|
|
this.setText("[" + |
|
|
|
|
Toolkit.i18nText("Fine-Design_Write_Select_Cell_Count", ((ColumnRowGroup) cv).getSize()) |
|
|
|
|
+ "]"); |
|
|
|
|
tip = cv.toString() + " " + tip; |
|
|
|
|
} else if (cv != null) { |
|
|
|
|
this.setText(cv.toString()); |
|
|
|
|