richie
7 years ago
22 changed files with 562 additions and 558 deletions
@ -1,136 +1,128 @@ |
|||||||
/* |
/* |
||||||
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved. |
* Copyright(c) 2001-2010, FineReport Inc, All Rights Reserved. |
||||||
*/ |
*/ |
||||||
package com.fr.design.actions.insert.flot; |
package com.fr.design.actions.insert.flot; |
||||||
|
|
||||||
import com.fr.base.BaseFormula; |
import com.fr.base.BaseFormula; |
||||||
import com.fr.base.BaseUtils; |
import com.fr.base.BaseUtils; |
||||||
import com.fr.base.DynamicUnitList; |
import com.fr.base.DynamicUnitList; |
||||||
import com.fr.base.Formula; |
import com.fr.design.actions.ElementCaseAction; |
||||||
import com.fr.design.actions.ElementCaseAction; |
import com.fr.design.dialog.BasicDialog; |
||||||
import com.fr.design.dialog.BasicDialog; |
import com.fr.design.dialog.DialogActionAdapter; |
||||||
import com.fr.design.dialog.DialogActionAdapter; |
import com.fr.design.file.HistoryTemplateListPane; |
||||||
import com.fr.design.file.HistoryTemplateListPane; |
import com.fr.design.formula.FormulaFactory; |
||||||
import com.fr.design.formula.FormulaFactory; |
import com.fr.design.formula.UIFormula; |
||||||
import com.fr.design.formula.UIFormula; |
import com.fr.design.mainframe.DesignerContext; |
||||||
import com.fr.design.mainframe.DesignerContext; |
import com.fr.design.mainframe.ElementCasePane; |
||||||
import com.fr.design.mainframe.ElementCasePane; |
import com.fr.design.menu.MenuKeySet; |
||||||
import com.fr.design.menu.MenuKeySet; |
import com.fr.general.Inter; |
||||||
import com.fr.design.report.SelectImagePane; |
import com.fr.grid.Grid; |
||||||
import com.fr.general.Inter; |
import com.fr.grid.selection.FloatSelection; |
||||||
import com.fr.grid.Grid; |
import com.fr.report.ReportHelper; |
||||||
import com.fr.grid.selection.FloatSelection; |
import com.fr.report.cell.FloatElement; |
||||||
import com.fr.report.ReportHelper; |
import com.fr.report.elementcase.TemplateElementCase; |
||||||
import com.fr.report.cell.FloatElement; |
import com.fr.stable.unit.FU; |
||||||
import com.fr.report.cell.cellattr.CellImage; |
|
||||||
import com.fr.report.elementcase.TemplateElementCase; |
import javax.swing.*; |
||||||
import com.fr.stable.CoreGraphHelper; |
|
||||||
import com.fr.stable.StringUtils; |
/** |
||||||
import com.fr.stable.unit.FU; |
* Insert formula. |
||||||
|
*/ |
||||||
import javax.swing.*; |
public class FormulaFloatAction extends ElementCaseAction { |
||||||
import java.awt.*; |
|
||||||
import java.awt.event.ActionEvent; |
private boolean returnValue = false; |
||||||
import java.io.File; |
|
||||||
|
public FormulaFloatAction(ElementCasePane t) { |
||||||
/** |
super(t); |
||||||
* Insert formula. |
this.setMenuKeySet(FLOAT_INSERT_FORMULA); |
||||||
*/ |
this.setName(getMenuKeySet().getMenuKeySetName()); |
||||||
public class FormulaFloatAction extends ElementCaseAction { |
this.setMnemonic(getMenuKeySet().getMnemonic()); |
||||||
|
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/formula.png")); |
||||||
private boolean returnValue = false; |
} |
||||||
|
|
||||||
public FormulaFloatAction(ElementCasePane t) { |
public static final MenuKeySet FLOAT_INSERT_FORMULA = new MenuKeySet() { |
||||||
super(t); |
@Override |
||||||
this.setMenuKeySet(FLOAT_INSERT_FORMULA); |
public char getMnemonic() { |
||||||
this.setName(getMenuKeySet().getMenuKeySetName()); |
return 'F'; |
||||||
this.setMnemonic(getMenuKeySet().getMnemonic()); |
} |
||||||
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/formula.png")); |
|
||||||
} |
@Override |
||||||
|
public String getMenuName() { |
||||||
public static final MenuKeySet FLOAT_INSERT_FORMULA = new MenuKeySet() { |
return Inter.getLocText("FR-Designer_Insert_Formula"); |
||||||
@Override |
} |
||||||
public char getMnemonic() { |
|
||||||
return 'F'; |
@Override |
||||||
} |
public KeyStroke getKeyStroke() { |
||||||
|
return null; |
||||||
@Override |
} |
||||||
public String getMenuName() { |
}; |
||||||
return Inter.getLocText("FR-Designer_Insert_Formula"); |
|
||||||
} |
private void doWithDrawingFloatElement() { |
||||||
|
ElementCasePane jws = (ElementCasePane) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane(); |
||||||
@Override |
Grid grid = jws.getGrid(); |
||||||
public KeyStroke getKeyStroke() { |
|
||||||
return null; |
ElementCasePane reportPane = grid.getElementCasePane(); |
||||||
} |
TemplateElementCase report = reportPane.getEditingElementCase(); |
||||||
}; |
DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(report); |
||||||
|
DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(report); |
||||||
private void doWithDrawingFloatElement() { |
|
||||||
ElementCasePane jws = (ElementCasePane) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane(); |
int horizentalScrollValue = grid.getHorizontalValue(); |
||||||
Grid grid = jws.getGrid(); |
int verticalScrollValue = grid.getVerticalValue(); |
||||||
|
|
||||||
ElementCasePane reportPane = grid.getElementCasePane(); |
int resolution = grid.getResolution(); |
||||||
TemplateElementCase report = reportPane.getEditingElementCase(); |
int floatWdith = grid.getDrawingFloatElement().getWidth().toPixI(resolution); |
||||||
DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(report); |
int floatHeight = grid.getDrawingFloatElement().getWidth().toPixI(resolution); |
||||||
DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(report); |
|
||||||
|
FU evtX_fu = FU.valueOfPix((grid.getWidth() - floatWdith) / 2, resolution); |
||||||
int horizentalScrollValue = grid.getHorizontalValue(); |
FU evtY_fu = FU.valueOfPix((grid.getHeight() - floatHeight) / 2, resolution); |
||||||
int verticalScrollValue = grid.getVerticalValue(); |
|
||||||
|
FU leftDistance = FU.getInstance(evtX_fu.toFU() + columnWidthList.getRangeValue(0, horizentalScrollValue).toFU()); |
||||||
int resolution = grid.getResolution(); |
FU topDistance = FU.getInstance(evtY_fu.toFU() + rowHeightList.getRangeValue(0, verticalScrollValue).toFU()); |
||||||
int floatWdith = grid.getDrawingFloatElement().getWidth().toPixI(resolution); |
|
||||||
int floatHeight = grid.getDrawingFloatElement().getWidth().toPixI(resolution); |
grid.getDrawingFloatElement().setLeftDistance(leftDistance); |
||||||
|
grid.getDrawingFloatElement().setTopDistance(topDistance); |
||||||
FU evtX_fu = FU.valueOfPix((grid.getWidth() - floatWdith) / 2, resolution); |
|
||||||
FU evtY_fu = FU.valueOfPix((grid.getHeight() - floatHeight) / 2, resolution); |
report.addFloatElement(grid.getDrawingFloatElement()); |
||||||
|
reportPane.setSelection(new FloatSelection(grid.getDrawingFloatElement().getName())); |
||||||
FU leftDistance = FU.getInstance(evtX_fu.toFU() + columnWidthList.getRangeValue(0, horizentalScrollValue).toFU()); |
} |
||||||
FU topDistance = FU.getInstance(evtY_fu.toFU() + rowHeightList.getRangeValue(0, verticalScrollValue).toFU()); |
|
||||||
|
/** |
||||||
grid.getDrawingFloatElement().setLeftDistance(leftDistance); |
* 执行动作 |
||||||
grid.getDrawingFloatElement().setTopDistance(topDistance); |
* |
||||||
|
* @return 成功返回true |
||||||
report.addFloatElement(grid.getDrawingFloatElement()); |
*/ |
||||||
reportPane.setSelection(new FloatSelection(grid.getDrawingFloatElement().getName())); |
@Override |
||||||
} |
public boolean executeActionReturnUndoRecordNeeded() { |
||||||
|
final ElementCasePane reportPane = (ElementCasePane) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane(); |
||||||
/** |
if (reportPane == null) { |
||||||
* 执行动作 |
return false; |
||||||
* |
} |
||||||
* @return 成功返回true |
|
||||||
*/ |
reportPane.stopEditing(); |
||||||
@Override |
final FloatElement floatElement = new FloatElement(); |
||||||
public boolean executeActionReturnUndoRecordNeeded() { |
final UIFormula formulaPane = FormulaFactory.createFormulaPane(); |
||||||
final ElementCasePane reportPane = (ElementCasePane) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getCurrentElementCasePane(); |
formulaPane.populate(BaseFormula.createFormulaBuilder().build()); |
||||||
if (reportPane == null) { |
|
||||||
return false; |
BasicDialog dialog = formulaPane.showLargeWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { |
||||||
} |
|
||||||
|
@Override |
||||||
reportPane.stopEditing(); |
public void doOk() { |
||||||
final FloatElement floatElement = new FloatElement(); |
floatElement.setValue(formulaPane.update()); |
||||||
final UIFormula formulaPane = FormulaFactory.createFormulaPane(); |
if (reportPane == null) { |
||||||
formulaPane.populate(BaseFormula.createFormulaBuilder().build()); |
return; |
||||||
|
} |
||||||
BasicDialog dialog = formulaPane.showLargeWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { |
reportPane.getGrid().setDrawingFloatElement(floatElement); |
||||||
|
doWithDrawingFloatElement(); |
||||||
@Override |
returnValue = true; |
||||||
public void doOk() { |
} |
||||||
floatElement.setValue(formulaPane.update()); |
|
||||||
if (reportPane == null) { |
@Override |
||||||
return; |
public void doCancel() { |
||||||
} |
returnValue = false; |
||||||
reportPane.getGrid().setDrawingFloatElement(floatElement); |
} |
||||||
doWithDrawingFloatElement(); |
}); |
||||||
returnValue = true; |
dialog.setVisible(true); |
||||||
} |
return returnValue; |
||||||
|
} |
||||||
@Override |
|
||||||
public void doCancel() { |
|
||||||
returnValue = false; |
|
||||||
} |
|
||||||
}); |
|
||||||
dialog.setVisible(true); |
|
||||||
return returnValue; |
|
||||||
} |
|
||||||
|
|
||||||
} |
} |
@ -1,371 +1,371 @@ |
|||||||
package com.fr.design.present.dict; |
package com.fr.design.present.dict; |
||||||
|
|
||||||
import com.fr.base.Formula; |
import com.fr.base.BaseFormula; |
||||||
import com.fr.base.TableData; |
import com.fr.base.TableData; |
||||||
import com.fr.data.TableDataSource; |
import com.fr.data.TableDataSource; |
||||||
import com.fr.data.impl.DBTableData; |
import com.fr.data.impl.DBTableData; |
||||||
import com.fr.data.impl.DynamicSQLDict; |
import com.fr.data.impl.DynamicSQLDict; |
||||||
import com.fr.data.impl.NameTableData; |
import com.fr.data.impl.NameTableData; |
||||||
import com.fr.data.impl.TableDataDictionary; |
import com.fr.data.impl.TableDataDictionary; |
||||||
import com.fr.design.DesignModelAdapter; |
import com.fr.design.DesignModelAdapter; |
||||||
import com.fr.design.beans.FurtherBasicBeanPane; |
import com.fr.design.beans.FurtherBasicBeanPane; |
||||||
import com.fr.design.constants.LayoutConstants; |
import com.fr.design.constants.LayoutConstants; |
||||||
import com.fr.design.constants.UIConstants; |
import com.fr.design.constants.UIConstants; |
||||||
import com.fr.design.data.DesignTableDataManager; |
import com.fr.design.data.DesignTableDataManager; |
||||||
import com.fr.design.data.datapane.TableDataComboBox; |
import com.fr.design.data.datapane.TableDataComboBox; |
||||||
import com.fr.design.data.datapane.TableDataTreePane; |
import com.fr.design.data.datapane.TableDataTreePane; |
||||||
import com.fr.design.data.datapane.preview.PreviewLabel; |
import com.fr.design.data.datapane.preview.PreviewLabel; |
||||||
import com.fr.design.data.datapane.preview.PreviewLabel.Previewable; |
import com.fr.design.data.datapane.preview.PreviewLabel.Previewable; |
||||||
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; |
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; |
||||||
import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper; |
import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper; |
||||||
import com.fr.design.editor.DoubleDeckValueEditorPane; |
import com.fr.design.editor.DoubleDeckValueEditorPane; |
||||||
import com.fr.design.editor.editor.ColumnIndexEditor; |
import com.fr.design.editor.editor.ColumnIndexEditor; |
||||||
import com.fr.design.editor.editor.ColumnNameEditor; |
import com.fr.design.editor.editor.ColumnNameEditor; |
||||||
import com.fr.design.editor.editor.Editor; |
import com.fr.design.editor.editor.Editor; |
||||||
import com.fr.design.editor.editor.FormulaEditor; |
import com.fr.design.editor.editor.FormulaEditor; |
||||||
import com.fr.design.event.UIObserver; |
import com.fr.design.event.UIObserver; |
||||||
import com.fr.design.event.UIObserverListener; |
import com.fr.design.event.UIObserverListener; |
||||||
import com.fr.design.gui.ilable.UILabel; |
import com.fr.design.gui.ilable.UILabel; |
||||||
import com.fr.design.layout.TableLayout; |
import com.fr.design.layout.TableLayout; |
||||||
import com.fr.design.layout.TableLayoutHelper; |
import com.fr.design.layout.TableLayoutHelper; |
||||||
import com.fr.design.utils.gui.GUICoreUtils; |
import com.fr.design.utils.gui.GUICoreUtils; |
||||||
import com.fr.general.ComparatorUtils; |
import com.fr.general.ComparatorUtils; |
||||||
import com.fr.general.Inter; |
import com.fr.general.Inter; |
||||||
import com.fr.stable.ArrayUtils; |
import com.fr.stable.ArrayUtils; |
||||||
import com.fr.stable.StringUtils; |
import com.fr.stable.StringUtils; |
||||||
|
|
||||||
import javax.swing.*; |
import javax.swing.*; |
||||||
import javax.swing.event.ChangeEvent; |
import javax.swing.event.ChangeEvent; |
||||||
import javax.swing.event.ChangeListener; |
import javax.swing.event.ChangeListener; |
||||||
import java.awt.*; |
import java.awt.*; |
||||||
import java.awt.event.ItemEvent; |
import java.awt.event.ItemEvent; |
||||||
import java.awt.event.ItemListener; |
import java.awt.event.ItemListener; |
||||||
import java.util.List; |
import java.util.List; |
||||||
|
|
||||||
/** |
/** |
||||||
* 数据字典的数据查询面板 |
* 数据字典的数据查询面板 |
||||||
* |
* |
||||||
* @editor zhou |
* @editor zhou |
||||||
* @since 2012-3-29下午1:49:24 |
* @since 2012-3-29下午1:49:24 |
||||||
*/ |
*/ |
||||||
public class TableDataDictPane extends FurtherBasicBeanPane<TableDataDictionary> implements Previewable, UIObserver { |
public class TableDataDictPane extends FurtherBasicBeanPane<TableDataDictionary> implements Previewable, UIObserver { |
||||||
private static final int BEGIN = 1; |
private static final int BEGIN = 1; |
||||||
private static final int END = 10; |
private static final int END = 10; |
||||||
private static final int VGAP = 24; |
private static final int VGAP = 24; |
||||||
private static final long serialVersionUID = -5469742115988153206L; |
private static final long serialVersionUID = -5469742115988153206L; |
||||||
private static final int SELECTED_NO_TABLEDATA = -2; |
private static final int SELECTED_NO_TABLEDATA = -2; |
||||||
public TableDataComboBox tableDataNameComboBox; |
public TableDataComboBox tableDataNameComboBox; |
||||||
private DoubleDeckValueEditorPane keyColumnPane; |
private DoubleDeckValueEditorPane keyColumnPane; |
||||||
private DoubleDeckValueEditorPane valueDictPane; |
private DoubleDeckValueEditorPane valueDictPane; |
||||||
private ItemListener itemListener; |
private ItemListener itemListener; |
||||||
private UIObserverListener uiObserverListener; |
private UIObserverListener uiObserverListener; |
||||||
|
|
||||||
public TableDataDictPane() { |
public TableDataDictPane() { |
||||||
initBasicComponets(); |
initBasicComponets(); |
||||||
initComponents(); |
initComponents(); |
||||||
iniListener(); |
iniListener(); |
||||||
} |
} |
||||||
|
|
||||||
public static void main(String[] args) { |
public static void main(String[] args) { |
||||||
JFrame jf = new JFrame("test"); |
JFrame jf = new JFrame("test"); |
||||||
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
||||||
JPanel content = (JPanel) jf.getContentPane(); |
JPanel content = (JPanel) jf.getContentPane(); |
||||||
content.setLayout(new BorderLayout()); |
content.setLayout(new BorderLayout()); |
||||||
content.add(new TableDataDictPane(), BorderLayout.NORTH); |
content.add(new TableDataDictPane(), BorderLayout.NORTH); |
||||||
GUICoreUtils.centerWindow(jf); |
GUICoreUtils.centerWindow(jf); |
||||||
jf.setSize(290, 400); |
jf.setSize(290, 400); |
||||||
jf.setVisible(true); |
jf.setVisible(true); |
||||||
} |
} |
||||||
|
|
||||||
private void initBasicComponets() { |
private void initBasicComponets() { |
||||||
tableDataNameComboBox = new TableDataComboBox(DesignTableDataManager.getEditingTableDataSource()); |
tableDataNameComboBox = new TableDataComboBox(DesignTableDataManager.getEditingTableDataSource()); |
||||||
tableDataNameComboBox.addItemListener(new ItemListener() { |
tableDataNameComboBox.addItemListener(new ItemListener() { |
||||||
public void itemStateChanged(ItemEvent e) { |
public void itemStateChanged(ItemEvent e) { |
||||||
if (e.getStateChange() == ItemEvent.SELECTED) { |
if (e.getStateChange() == ItemEvent.SELECTED) { |
||||||
tdChange(e); |
tdChange(e); |
||||||
} |
} |
||||||
} |
} |
||||||
}); |
}); |
||||||
// keyColumnPane = ValueEditorPaneFactory.createValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor()});
|
// keyColumnPane = ValueEditorPaneFactory.createValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor()});
|
||||||
keyColumnPane = new DoubleDeckValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor()}); |
keyColumnPane = new DoubleDeckValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor()}); |
||||||
FormulaEditor formulaEditor = new FormulaEditor(Inter.getLocText("FR-Designer_Parameter-Formula")); |
FormulaEditor formulaEditor = new FormulaEditor(Inter.getLocText("FR-Designer_Parameter-Formula")); |
||||||
formulaEditor.setEnabled(true); |
formulaEditor.setEnabled(true); |
||||||
// valueDictPane = ValueEditorPaneFactory.createValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor(), formulaEditor});
|
// valueDictPane = ValueEditorPaneFactory.createValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor(), formulaEditor});
|
||||||
valueDictPane = new DoubleDeckValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor(), formulaEditor}); |
valueDictPane = new DoubleDeckValueEditorPane(new Editor[]{new ColumnNameEditor(), new ColumnIndexEditor(), formulaEditor}); |
||||||
} |
} |
||||||
|
|
||||||
private void initComponents() { |
private void initComponents() { |
||||||
|
|
||||||
double p = TableLayout.PREFERRED; |
double p = TableLayout.PREFERRED; |
||||||
double f = TableLayout.FILL; |
double f = TableLayout.FILL; |
||||||
double[] columnSize = {p, f}; |
double[] columnSize = {p, f}; |
||||||
double[] rowSize = {p, p, p, p, p}; |
double[] rowSize = {p, p, p, p, p}; |
||||||
int[][] rowCount = {{1, 1}, {1, 3}, {1, 3}}; |
int[][] rowCount = {{1, 1}, {1, 3}, {1, 3}}; |
||||||
|
|
||||||
JPanel firstLine = new JPanel(new BorderLayout(4, 0)); |
JPanel firstLine = new JPanel(new BorderLayout(4, 0)); |
||||||
firstLine.add(tableDataNameComboBox, BorderLayout.CENTER); |
firstLine.add(tableDataNameComboBox, BorderLayout.CENTER); |
||||||
firstLine.add(new PreviewLabel(this), BorderLayout.EAST); |
firstLine.add(new PreviewLabel(this), BorderLayout.EAST); |
||||||
|
|
||||||
Component[][] components = new Component[][]{ |
Component[][] components = new Component[][]{ |
||||||
new Component[]{new UILabel(Inter.getLocText("FR-Designer_DS_TableData") + " ", UILabel.LEFT), firstLine}, |
new Component[]{new UILabel(Inter.getLocText("FR-Designer_DS_TableData") + " ", UILabel.LEFT), firstLine}, |
||||||
new Component[]{new UILabel(Inter.getLocText("FR-Designer_Actual_Value") + " ", UILabel.LEFT), keyColumnPane}, |
new Component[]{new UILabel(Inter.getLocText("FR-Designer_Actual_Value") + " ", UILabel.LEFT), keyColumnPane}, |
||||||
new Component[]{new UILabel(Inter.getLocText("FR-Designer_Display_Value") + " ", UILabel.LEFT), valueDictPane}, |
new Component[]{new UILabel(Inter.getLocText("FR-Designer_Display_Value") + " ", UILabel.LEFT), valueDictPane}, |
||||||
}; |
}; |
||||||
|
|
||||||
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, VGAP, LayoutConstants.VGAP_MEDIUM); |
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, VGAP, LayoutConstants.VGAP_MEDIUM); |
||||||
this.setLayout(new BorderLayout()); |
this.setLayout(new BorderLayout()); |
||||||
this.add(panel, BorderLayout.CENTER); |
this.add(panel, BorderLayout.CENTER); |
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
private void iniListener() { |
private void iniListener() { |
||||||
if (shouldResponseChangeListener()) { |
if (shouldResponseChangeListener()) { |
||||||
this.addItemListener(new ItemListener() { |
this.addItemListener(new ItemListener() { |
||||||
@Override |
@Override |
||||||
public void itemStateChanged(ItemEvent e) { |
public void itemStateChanged(ItemEvent e) { |
||||||
if (uiObserverListener == null) { |
if (uiObserverListener == null) { |
||||||
return; |
return; |
||||||
} |
} |
||||||
if (e.getStateChange() == ItemEvent.SELECTED) { |
if (e.getStateChange() == ItemEvent.SELECTED) { |
||||||
uiObserverListener.doChange(); |
uiObserverListener.doChange(); |
||||||
} |
} |
||||||
} |
} |
||||||
}); |
}); |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 增加Listener |
* 增加Listener |
||||||
* |
* |
||||||
* @param aListener 将本对象的Listener指向该listener |
* @param aListener 将本对象的Listener指向该listener |
||||||
*/ |
*/ |
||||||
public void addItemListener(ItemListener aListener) { |
public void addItemListener(ItemListener aListener) { |
||||||
this.itemListener = aListener; |
this.itemListener = aListener; |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 该面板标题 |
* 该面板标题 |
||||||
* |
* |
||||||
* @return 返回是窗口显示的标题 |
* @return 返回是窗口显示的标题 |
||||||
*/ |
*/ |
||||||
public String title4PopupWindow() { |
public String title4PopupWindow() { |
||||||
return Inter.getLocText("FR-Designer_Dic_Data_Query"); |
return Inter.getLocText("FR-Designer_Dic_Data_Query"); |
||||||
} |
} |
||||||
|
|
||||||
private void tdChange(final ItemEvent e) { |
private void tdChange(final ItemEvent e) { |
||||||
TableDataWrapper tableDataWrappe = this.tableDataNameComboBox.getSelectedItem(); |
TableDataWrapper tableDataWrappe = this.tableDataNameComboBox.getSelectedItem(); |
||||||
if (tableDataWrappe == null) { |
if (tableDataWrappe == null) { |
||||||
return; |
return; |
||||||
} |
} |
||||||
|
|
||||||
List<String> namelist = tableDataWrappe.calculateColumnNameList(); |
List<String> namelist = tableDataWrappe.calculateColumnNameList(); |
||||||
String[] columnNames = null; |
String[] columnNames = null; |
||||||
if (!namelist.isEmpty()) { |
if (!namelist.isEmpty()) { |
||||||
columnNames = namelist.toArray(ArrayUtils.EMPTY_STRING_ARRAY); |
columnNames = namelist.toArray(ArrayUtils.EMPTY_STRING_ARRAY); |
||||||
} else { |
} else { |
||||||
columnNames = new String[]{""}; |
columnNames = new String[]{""}; |
||||||
} |
} |
||||||
ColumnNameEditor columnNameEditor1 = new ColumnNameEditor(columnNames); |
ColumnNameEditor columnNameEditor1 = new ColumnNameEditor(columnNames); |
||||||
columnNameEditor1.addItemListener(itemListener); |
columnNameEditor1.addItemListener(itemListener); |
||||||
ColumnIndexEditor columnIndexEditor1 = new ColumnIndexEditor(columnNames.length); |
ColumnIndexEditor columnIndexEditor1 = new ColumnIndexEditor(columnNames.length); |
||||||
columnIndexEditor1.addItemListener(itemListener); |
columnIndexEditor1.addItemListener(itemListener); |
||||||
keyColumnPane.setEditors(new Editor[]{columnNameEditor1, columnIndexEditor1}, columnNames[0]); |
keyColumnPane.setEditors(new Editor[]{columnNameEditor1, columnIndexEditor1}, columnNames[0]); |
||||||
|
|
||||||
FormulaEditor formulaEditor = new FormulaEditor(Inter.getLocText("FR-Designer_Parameter-Formula")); |
FormulaEditor formulaEditor = new FormulaEditor(Inter.getLocText("FR-Designer_Parameter-Formula")); |
||||||
formulaEditor.setEnabled(true); |
formulaEditor.setEnabled(true); |
||||||
formulaEditor.addChangeListener(new ChangeListener() { |
formulaEditor.addChangeListener(new ChangeListener() { |
||||||
|
|
||||||
@Override |
@Override |
||||||
public void stateChanged(ChangeEvent ee) { |
public void stateChanged(ChangeEvent ee) { |
||||||
if (itemListener != null) { |
if (itemListener != null) { |
||||||
itemListener.itemStateChanged(e); |
itemListener.itemStateChanged(e); |
||||||
} |
} |
||||||
} |
} |
||||||
}); |
}); |
||||||
ColumnNameEditor columnNameEditor2 = new ColumnNameEditor(columnNames); |
ColumnNameEditor columnNameEditor2 = new ColumnNameEditor(columnNames); |
||||||
columnNameEditor2.addItemListener(itemListener); |
columnNameEditor2.addItemListener(itemListener); |
||||||
ColumnIndexEditor columnIndexEditor2 = new ColumnIndexEditor(columnNames.length); |
ColumnIndexEditor columnIndexEditor2 = new ColumnIndexEditor(columnNames.length); |
||||||
columnIndexEditor2.addItemListener(itemListener); |
columnIndexEditor2.addItemListener(itemListener); |
||||||
valueDictPane.setEditors(new Editor[]{columnNameEditor2, columnIndexEditor2, formulaEditor}, columnNames[0]); |
valueDictPane.setEditors(new Editor[]{columnNameEditor2, columnIndexEditor2, formulaEditor}, columnNames[0]); |
||||||
if (itemListener != null) { |
if (itemListener != null) { |
||||||
itemListener.itemStateChanged(e); |
itemListener.itemStateChanged(e); |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
/** |
/** |
||||||
* |
* |
||||||
*/ |
*/ |
||||||
public void populateBean(TableDataDictionary tableDataDict) { |
public void populateBean(TableDataDictionary tableDataDict) { |
||||||
populate(tableDataDict, ""); |
populate(tableDataDict, ""); |
||||||
} |
} |
||||||
|
|
||||||
private void populate(TableDataDictionary tableDataDict, String name) { |
private void populate(TableDataDictionary tableDataDict, String name) { |
||||||
if (tableDataDict == null || tableDataDict.getTableData() == TableData.EMPTY_TABLEDATA) { |
if (tableDataDict == null || tableDataDict.getTableData() == TableData.EMPTY_TABLEDATA) { |
||||||
this.tableDataNameComboBox.setSelectedIndex(-1); |
this.tableDataNameComboBox.setSelectedIndex(-1); |
||||||
this.keyColumnPane.populate(StringUtils.EMPTY); |
this.keyColumnPane.populate(StringUtils.EMPTY); |
||||||
this.valueDictPane.populate(StringUtils.EMPTY); |
this.valueDictPane.populate(StringUtils.EMPTY); |
||||||
return; |
return; |
||||||
} |
} |
||||||
if (tableDataDict.getTableData() instanceof DBTableData && !"".equals(name)) { |
if (tableDataDict.getTableData() instanceof DBTableData && !"".equals(name)) { |
||||||
this.tableDataNameComboBox.putTableDataIntoMap(name, new TemplateTableDataWrapper( |
this.tableDataNameComboBox.putTableDataIntoMap(name, new TemplateTableDataWrapper( |
||||||
(DBTableData) tableDataDict.getTableData(), name)); |
(DBTableData) tableDataDict.getTableData(), name)); |
||||||
this.tableDataNameComboBox.setSelectedTableDataByName(name); |
this.tableDataNameComboBox.setSelectedTableDataByName(name); |
||||||
} else if (tableDataDict.getTableData() instanceof NameTableData) { |
} else if (tableDataDict.getTableData() instanceof NameTableData) { |
||||||
this.tableDataNameComboBox.setSelectedTableDataByName(((NameTableData) tableDataDict.getTableData()) |
this.tableDataNameComboBox.setSelectedTableDataByName(((NameTableData) tableDataDict.getTableData()) |
||||||
.getName()); |
.getName()); |
||||||
} |
} |
||||||
// alex:因为显示到界面上的index是以1为始的,所以要加1
|
// alex:因为显示到界面上的index是以1为始的,所以要加1
|
||||||
|
|
||||||
TableDataWrapper tableDataWrappe = this.tableDataNameComboBox.getSelectedItem(); |
TableDataWrapper tableDataWrappe = this.tableDataNameComboBox.getSelectedItem(); |
||||||
if (tableDataWrappe == null) { |
if (tableDataWrappe == null) { |
||||||
keyColumnPane.resetComponets(); |
keyColumnPane.resetComponets(); |
||||||
valueDictPane.resetComponets(); |
valueDictPane.resetComponets(); |
||||||
} else { |
} else { |
||||||
if (StringUtils.isNotEmpty(tableDataDict.getKeyColumnName())) { |
if (StringUtils.isNotEmpty(tableDataDict.getKeyColumnName())) { |
||||||
this.keyColumnPane.populate(tableDataDict.getKeyColumnName()); |
this.keyColumnPane.populate(tableDataDict.getKeyColumnName()); |
||||||
} else { |
} else { |
||||||
this.keyColumnPane.populate(tableDataDict.getKeyColumnIndex() + 1); |
this.keyColumnPane.populate(tableDataDict.getKeyColumnIndex() + 1); |
||||||
} |
} |
||||||
|
|
||||||
Object value = null; |
Object value = null; |
||||||
if (tableDataDict.getFormula() != null) { |
if (tableDataDict.getFormula() != null) { |
||||||
value = tableDataDict.getFormula(); |
value = tableDataDict.getFormula(); |
||||||
} else { |
} else { |
||||||
if (StringUtils.isNotEmpty(tableDataDict.getValueColumnName())) { |
if (StringUtils.isNotEmpty(tableDataDict.getValueColumnName())) { |
||||||
value = tableDataDict.getValueColumnName(); |
value = tableDataDict.getValueColumnName(); |
||||||
} else { |
} else { |
||||||
value = tableDataDict.getValueColumnIndex() + 1; |
value = tableDataDict.getValueColumnIndex() + 1; |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
this.valueDictPane.populate(value); |
this.valueDictPane.populate(value); |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* @param dsql |
* @param dsql |
||||||
*/ |
*/ |
||||||
public void populateBean(DynamicSQLDict dsql) { |
public void populateBean(DynamicSQLDict dsql) { |
||||||
DBTableData db = new DBTableData(dsql.getDatabaseConnection(), dsql.getSqlFormula()); |
DBTableData db = new DBTableData(dsql.getDatabaseConnection(), dsql.getSqlFormula()); |
||||||
String name = ""; |
String name = ""; |
||||||
TableDataSource dataSource = DesignTableDataManager.getEditingTableDataSource(); |
TableDataSource dataSource = DesignTableDataManager.getEditingTableDataSource(); |
||||||
if (dataSource != null) { |
if (dataSource != null) { |
||||||
for (int i = BEGIN; i < END; i++) { |
for (int i = BEGIN; i < END; i++) { |
||||||
TableData td = dataSource.getTableData(Inter.getLocText("FR-Designer_Dictionary_Dynamic_SQL") + i); |
TableData td = dataSource.getTableData(Inter.getLocText("FR-Designer_Dictionary_Dynamic_SQL") + i); |
||||||
if (td == null) { |
if (td == null) { |
||||||
name = Inter.getLocText("FR-Designer_Dictionary_Dynamic_SQL") + i; |
name = Inter.getLocText("FR-Designer_Dictionary_Dynamic_SQL") + i; |
||||||
dataSource.putTableData(Inter.getLocText("FR-Designer_Dictionary_Dynamic_SQL") + i, db); |
dataSource.putTableData(Inter.getLocText("FR-Designer_Dictionary_Dynamic_SQL") + i, db); |
||||||
break; |
break; |
||||||
} else { |
} else { |
||||||
if (ComparatorUtils.equals(td, db)) { |
if (ComparatorUtils.equals(td, db)) { |
||||||
name = Inter.getLocText("FR-Designer_Dictionary_Dynamic_SQL") + i; |
name = Inter.getLocText("FR-Designer_Dictionary_Dynamic_SQL") + i; |
||||||
break; |
break; |
||||||
} else { |
} else { |
||||||
continue; |
continue; |
||||||
} |
} |
||||||
} |
} |
||||||
} |
} |
||||||
} |
} |
||||||
|
|
||||||
TableDataDictionary tdd = new TableDataDictionary(db, dsql.getKeyColumnIndex(), dsql.getValueColumnIndex()); |
TableDataDictionary tdd = new TableDataDictionary(db, dsql.getKeyColumnIndex(), dsql.getValueColumnIndex()); |
||||||
if (dsql.getFormula() != null) { |
if (dsql.getFormula() != null) { |
||||||
tdd.setFormula(dsql.getFormula()); |
tdd.setFormula(dsql.getFormula()); |
||||||
} |
} |
||||||
this.populate(tdd, name); |
this.populate(tdd, name); |
||||||
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); |
TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()); |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* @return |
* @return |
||||||
*/ |
*/ |
||||||
public TableDataDictionary updateBean() { |
public TableDataDictionary updateBean() { |
||||||
TableDataDictionary tableDataDict = new TableDataDictionary(); |
TableDataDictionary tableDataDict = new TableDataDictionary(); |
||||||
Object object = this.valueDictPane.update(); |
Object object = this.valueDictPane.update(); |
||||||
// alex:因为显示到界面上的index是以1为始的,所以要减1
|
// alex:因为显示到界面上的index是以1为始的,所以要减1
|
||||||
// carl:假如这里的序号要变,请考虑6.2的兼容
|
// carl:假如这里的序号要变,请考虑6.2的兼容
|
||||||
if (object instanceof Integer) { |
if (object instanceof Integer) { |
||||||
int valuleColumnIndex = (Integer) object - 1; |
int valuleColumnIndex = (Integer) object - 1; |
||||||
String valueColumnName = StringUtils.EMPTY; |
String valueColumnName = StringUtils.EMPTY; |
||||||
|
|
||||||
if (this.valueDictPane.getCurrentEditor() instanceof ColumnNameEditor) { |
if (this.valueDictPane.getCurrentEditor() instanceof ColumnNameEditor) { |
||||||
valueColumnName = ((ColumnNameEditor) this.valueDictPane.getCurrentEditor()).getColumnName(); |
valueColumnName = ((ColumnNameEditor) this.valueDictPane.getCurrentEditor()).getColumnName(); |
||||||
valuleColumnIndex = -1; |
valuleColumnIndex = -1; |
||||||
} |
} |
||||||
tableDataDict.setValueColumnIndex(valuleColumnIndex); |
tableDataDict.setValueColumnIndex(valuleColumnIndex); |
||||||
tableDataDict.setValueColumnName(valueColumnName); |
tableDataDict.setValueColumnName(valueColumnName); |
||||||
} else { |
} else { |
||||||
tableDataDict.setFormula(((Formula) object)); |
tableDataDict.setFormula(((BaseFormula) object)); |
||||||
} |
} |
||||||
TableDataWrapper tableDataWrappe = this.tableDataNameComboBox.getSelectedItem(); |
TableDataWrapper tableDataWrappe = this.tableDataNameComboBox.getSelectedItem(); |
||||||
if (tableDataWrappe != null) { |
if (tableDataWrappe != null) { |
||||||
tableDataDict.setTableData(new NameTableData(tableDataWrappe.getTableDataName())); |
tableDataDict.setTableData(new NameTableData(tableDataWrappe.getTableDataName())); |
||||||
int keyColumnIndex = (Integer) this.keyColumnPane.update() - 1; |
int keyColumnIndex = (Integer) this.keyColumnPane.update() - 1; |
||||||
String keyColumnName = StringUtils.EMPTY; |
String keyColumnName = StringUtils.EMPTY; |
||||||
|
|
||||||
if (keyColumnPane.getCurrentEditor() instanceof ColumnNameEditor) { |
if (keyColumnPane.getCurrentEditor() instanceof ColumnNameEditor) { |
||||||
keyColumnName = ((ColumnNameEditor) this.keyColumnPane.getCurrentEditor()).getColumnName(); |
keyColumnName = ((ColumnNameEditor) this.keyColumnPane.getCurrentEditor()).getColumnName(); |
||||||
keyColumnIndex = -1; |
keyColumnIndex = -1; |
||||||
} |
} |
||||||
|
|
||||||
tableDataDict.setKeyColumnIndex(keyColumnIndex); |
tableDataDict.setKeyColumnIndex(keyColumnIndex); |
||||||
tableDataDict.setKeyColumnName(keyColumnName); |
tableDataDict.setKeyColumnName(keyColumnName); |
||||||
} |
} |
||||||
|
|
||||||
return tableDataDict; |
return tableDataDict; |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 预览 |
* 预览 |
||||||
*/ |
*/ |
||||||
public void preview() { |
public void preview() { |
||||||
TableDataWrapper tableDataWrappe = tableDataNameComboBox.getSelectedItem(); |
TableDataWrapper tableDataWrappe = tableDataNameComboBox.getSelectedItem(); |
||||||
if (tableDataWrappe == null) { |
if (tableDataWrappe == null) { |
||||||
return; |
return; |
||||||
} |
} |
||||||
Object object = this.valueDictPane.update(); |
Object object = this.valueDictPane.update(); |
||||||
if (object instanceof Integer) { |
if (object instanceof Integer) { |
||||||
tableDataWrappe.previewData((Integer) this.keyColumnPane.update() - 1, (Integer) object - 1); |
tableDataWrappe.previewData((Integer) this.keyColumnPane.update() - 1, (Integer) object - 1); |
||||||
} |
} |
||||||
|
|
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 判断ob是否是TableDataDictionary类型 |
* 判断ob是否是TableDataDictionary类型 |
||||||
* |
* |
||||||
* @param ob 用于判断的Object |
* @param ob 用于判断的Object |
||||||
* @return 如果是TableDataDictionary类型,则返回true |
* @return 如果是TableDataDictionary类型,则返回true |
||||||
*/ |
*/ |
||||||
public boolean accept(Object ob) { |
public boolean accept(Object ob) { |
||||||
return ob instanceof TableDataDictionary; |
return ob instanceof TableDataDictionary; |
||||||
} |
} |
||||||
|
|
||||||
@Override |
@Override |
||||||
/** |
/** |
||||||
*重置 |
*重置 |
||||||
*/ |
*/ |
||||||
public void reset() { |
public void reset() { |
||||||
GUICoreUtils.setSelectedItemQuietly(tableDataNameComboBox, UIConstants.PENDING); |
GUICoreUtils.setSelectedItemQuietly(tableDataNameComboBox, UIConstants.PENDING); |
||||||
keyColumnPane.clearComponentsData(); |
keyColumnPane.clearComponentsData(); |
||||||
valueDictPane.clearComponentsData(); |
valueDictPane.clearComponentsData(); |
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
/** |
/** |
||||||
* 给组件登记一个观察者监听事件 |
* 给组件登记一个观察者监听事件 |
||||||
* |
* |
||||||
* @param listener 观察者监听事件 |
* @param listener 观察者监听事件 |
||||||
*/ |
*/ |
||||||
public void registerChangeListener(UIObserverListener listener) { |
public void registerChangeListener(UIObserverListener listener) { |
||||||
uiObserverListener = listener; |
uiObserverListener = listener; |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 是否应该相应listener事件 |
* 是否应该相应listener事件 |
||||||
* |
* |
||||||
* @return 要是响应listener事件,则返回true |
* @return 要是响应listener事件,则返回true |
||||||
*/ |
*/ |
||||||
public boolean shouldResponseChangeListener() { |
public boolean shouldResponseChangeListener() { |
||||||
return true; |
return true; |
||||||
} |
} |
||||||
} |
} |
Loading…
Reference in new issue