Browse Source

Merge pull request #1005 in BA/design from ~MOMEAK/design9.0:9.0 to 9.0

* commit '9024ca56b8568fcabc92d54d681c7f26295a39c2':
  代码格式化
  REPORT-2897 9.0设计器修改 聚合报表缩放条快捷键
  REPORT-2897 9.0设计器修改 修改代码质量,加了一下方法备注
  REPORT-2897 9.0设计器修改 缩放条部分-增加键盘快捷键
  REPORT-2897 9.0设计器修改 缩放条部分
  REPORT-2897 9.0设计器修改 缩放条部分
  REPORT-2897 9.0设计器修改 缩放条部分
  REPORT-2897 9.0设计器修改 缩放条部分
  REPORT-3163 合作开发9.0设计器=>列表面板=》完善UI细节
  REPORT-3163 合作开发9.0设计器=>列表面板弹出编辑框
  REPORT-3163 合作开发9.0设计器=>调整自定义列表项
  REPORT-2897 9.0设计器修改 聚合报表缩放条部分
  REPORT-3163 合作开发9.0设计器=>新列表面板雏形
  REPORT-3163 合作开发9.0设计器=>悬浮元素超级链接tab改为可用
  REPORT-3163 合作开发9.0设计器=>将超级链接面板改为单例,插入右侧属性面板框架中
  REPORT-2897 9.0设计器修改 缩放条部分
  REPORT-3163 合作开发9.0设计器=>调整外框架工具条UI
  REPORT-2897 9.0设计器修改 缩放条部分
master
superman 7 years ago
parent
commit
63a8347163
  1. 6
      designer/src/com/fr/design/cell/bar/DynamicScrollBar.java
  2. 14
      designer/src/com/fr/design/mainframe/ElementCasePane.java
  3. 3
      designer/src/com/fr/design/mainframe/ElementCasePaneDelegate.java
  4. 103
      designer/src/com/fr/design/mainframe/JWorkBook.java
  5. 4
      designer/src/com/fr/design/mainframe/ReportComponentCardPane.java
  6. 97
      designer/src/com/fr/design/mainframe/ReportComponentComposite.java
  7. 50
      designer/src/com/fr/design/mainframe/ReportHyperlinkGroupPane.java
  8. 138
      designer/src/com/fr/design/mainframe/form/FormReportComponentComposite.java
  9. 1
      designer/src/com/fr/design/present/BarCodePane.java
  10. 33
      designer/src/com/fr/grid/AbstractGridHeaderMouseHandler.java
  11. 4
      designer/src/com/fr/grid/Grid.java
  12. 20
      designer/src/com/fr/grid/GridColumn.java
  13. 9
      designer/src/com/fr/grid/GridColumnMouseHandler.java
  14. 12
      designer/src/com/fr/grid/GridHeader.java
  15. 14
      designer/src/com/fr/grid/GridRow.java
  16. 18
      designer/src/com/fr/poly/PolyArea.java
  17. 60
      designer/src/com/fr/poly/PolyDesignUI.java
  18. 163
      designer/src/com/fr/poly/PolyDesigner.java
  19. 9
      designer/src/com/fr/poly/creator/BlockCreator.java
  20. 2
      designer/src/com/fr/poly/creator/BlockEditor.java
  21. 23
      designer/src/com/fr/poly/creator/ChartBlockCreator.java
  22. 13
      designer/src/com/fr/poly/creator/ChartBlockEditor.java
  23. 13
      designer/src/com/fr/poly/creator/ECBlockCreator.java
  24. 5
      designer/src/com/fr/poly/creator/ECBlockEditor.java
  25. 286
      designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java
  26. 974
      designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java
  27. 162
      designer_base/src/com/fr/design/gui/controlpane/UINameableListCellRenderer.java
  28. 4
      designer_base/src/com/fr/design/gui/frpane/HyperlinkGroupPane.java
  29. 7
      designer_base/src/com/fr/design/gui/icontainer/UIEastResizableContainer.java
  30. 398
      designer_base/src/com/fr/design/gui/ilist/UINameEdList.java
  31. 12
      designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java
  32. 370
      designer_base/src/com/fr/design/mainframe/JFormSliderPane.java
  33. 353
      designer_base/src/com/fr/design/mainframe/JSliderPane.java
  34. 27
      designer_base/src/com/fr/design/mainframe/JTemplate.java
  35. 11
      designer_chart/src/com/fr/design/chart/gui/ChartComponent.java
  36. 12
      designer_form/src/com/fr/design/gui/xpane/FormHyperlinkGroupPane.java
  37. 83
      designer_form/src/com/fr/design/mainframe/FormArea.java
  38. 11
      designer_form/src/com/fr/design/mainframe/FormDesigner.java
  39. 26
      designer_form/src/com/fr/design/mainframe/FormDesignerUI.java
  40. 22
      designer_form/src/com/fr/design/mainframe/JForm.java

6
designer/src/com/fr/design/cell/bar/DynamicScrollBar.java

@ -59,6 +59,10 @@ public class DynamicScrollBar extends JScrollBar {
});
}
public void setDpi(int dpi){
this.dpi = dpi;
}
public ElementCasePane getReportPane() {
return reportPane;
}
@ -112,6 +116,8 @@ public class DynamicScrollBar extends JScrollBar {
}
}
private abstract class DynamicScrollBarHelper extends BarHelper {
protected abstract DynamicUnitList getSizeList();

14
designer/src/com/fr/design/mainframe/ElementCasePane.java

@ -12,8 +12,6 @@ import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.event.*;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.lang.reflect.Constructor;
import java.util.Set;
@ -211,7 +209,9 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
this.setLayout(new RGridLayout());
//todo 直接修改分辨率
if (this.resolution == 0){
this.resolution = ScreenResolution.getScreenResolution();
}
this.initGridComponent();
@ -242,6 +242,8 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
initFormatBrush();
}
public int getMenuState() {
return DesignState.WORK_SHEET;
}
@ -346,6 +348,14 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
}
public void setResolution(int resolution){
this.resolution = resolution;
}
public int getResolution(){
return this.resolution;
}
/**
* 所有的操作都必须在可见范围内否则不做任何操作
*

3
designer/src/com/fr/design/mainframe/ElementCasePaneDelegate.java

@ -58,6 +58,8 @@ public class ElementCasePaneDelegate extends ElementCasePane<WorkSheet> {
QuickEditorRegion.getInstance().populate(getCurrentEditor());
JTemplate editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (editingTemplate != null && !editingTemplate.isUpMode()) {
// 模板初始化完成后,才能初始化超级链接面板
ReportHyperlinkGroupPane.getInstance().populate(ElementCasePaneDelegate.this);
if (((ElementCasePaneDelegate)e.getSource()).getSelection() instanceof FloatSelection) {
EastRegionContainerPane.getInstance().switchMode(EastRegionContainerPane.PropertyMode.REPORT_FLOAT);
// EastRegionContainerPane.getInstance().replaceCellAttrPane(CellElementPropertyPane.getInstance());
@ -67,6 +69,7 @@ public class ElementCasePaneDelegate extends ElementCasePane<WorkSheet> {
EastRegionContainerPane.getInstance().replaceCellAttrPane(CellElementPropertyPane.getInstance());
EastRegionContainerPane.getInstance().replaceCellElementPane(QuickEditorRegion.getInstance());
}
EastRegionContainerPane.getInstance().replaceHyperlinkPane(ReportHyperlinkGroupPane.getInstance());
EastRegionContainerPane.getInstance().removeParameterPane();
}
}

103
designer/src/com/fr/design/mainframe/JWorkBook.java

@ -1,9 +1,6 @@
package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.base.DynamicUnitList;
import com.fr.base.FRContext;
import com.fr.base.Parameter;
import com.fr.base.*;
import com.fr.design.DesignModelAdapter;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.actions.AllowAuthorityEditAction;
@ -14,6 +11,7 @@ import com.fr.design.actions.report.ReportExportAttrAction;
import com.fr.design.actions.report.ReportMobileAttrAction;
import com.fr.design.actions.report.ReportParameterAction;
import com.fr.design.actions.report.ReportWebAttrAction;
import com.fr.design.cell.bar.DynamicScrollBar;
import com.fr.design.constants.UIConstants;
import com.fr.design.data.datapane.TableDataTreePane;
import com.fr.design.designer.TargetComponent;
@ -23,6 +21,7 @@ import com.fr.design.event.TargetModifiedListener;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.file.MutilTempalteTabPane;
import com.fr.design.fun.PreviewProvider;
import com.fr.design.gui.frpane.HyperlinkGroupPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icontainer.UIModeControlContainer;
import com.fr.design.gui.imenu.UIMenuItem;
@ -59,6 +58,7 @@ import com.fr.main.TemplateWorkBook;
import com.fr.main.impl.WorkBook;
import com.fr.main.parameter.ReportParameterAttr;
import com.fr.poly.PolyDesigner;
import com.fr.poly.creator.BlockCreator;
import com.fr.privilege.finegrain.WorkSheetPrivilegeControl;
import com.fr.report.ReportHelper;
import com.fr.report.elementcase.ElementCase;
@ -71,6 +71,7 @@ import com.fr.stable.module.Module;
import com.fr.stable.project.ProjectConstants;
import javax.swing.*;
import javax.swing.Icon;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.FileOutputStream;
@ -86,7 +87,7 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
private static final int TOOLBARPANEDIMHEIGHT = 26;
private UIModeControlContainer centerPane;
private ReportComponentComposite reportComposite;
public ReportComponentComposite reportComposite;
private ParameterDefinitePane parameterPane;
private int resolution;
@ -149,6 +150,16 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
return processInfo;
}
@Override
public void setJTemplateResolution(int resolution) {
this.resolution = resolution;
}
@Override
public int getJTemplateResolution() {
return this.resolution;
}
/**
* 判断sheet权限
*
@ -335,20 +346,77 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
public void setScale(int resolution) {
//更新resolution
this.resolution = resolution;
reportComposite.centerCardPane.editingComponet.elementCasePane.getGrid().getGridMouseAdapter().setResolution(resolution);
reportComposite.centerCardPane.editingComponet.elementCasePane.getGrid().setResolution(resolution);
ElementCasePane elementCasePane = reportComposite.centerCardPane.editingComponet.elementCasePane;
PolyDesigner polyDezi = reportComposite.centerCardPane.getPolyDezi();
if (elementCasePane != null){
elementCasePane.setResolution(resolution);
elementCasePane.getGrid().getGridMouseAdapter().setResolution(resolution);
elementCasePane.getGrid().setResolution(resolution);
//更新Grid
Grid grid = reportComposite.centerCardPane.editingComponet.elementCasePane.getGrid();
DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(reportComposite.centerCardPane.editingComponet.elementCasePane.getEditingElementCase());
DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(reportComposite.centerCardPane.editingComponet.elementCasePane.getEditingElementCase());
Grid grid = elementCasePane.getGrid();
DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(elementCasePane.getEditingElementCase());
DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(elementCasePane.getEditingElementCase());
grid.setVerticalExtent(GridUtils.getExtentValue(0, rowHeightList, grid.getHeight(), resolution));
grid.setHorizontalExtent(GridUtils.getExtentValue(0, columnWidthList, grid.getWidth(), resolution));
reportComposite.centerCardPane.editingComponet.elementCasePane.getGrid().updateUI();
elementCasePane.getGrid().updateUI();
//更新Column和Row
reportComposite.centerCardPane.editingComponet.elementCasePane.getGridColumn().setResolution(resolution);
reportComposite.centerCardPane.editingComponet.elementCasePane.getGridColumn().updateUI();
reportComposite.centerCardPane.editingComponet.elementCasePane.getGridRow().setResolution(resolution);
reportComposite.centerCardPane.editingComponet.elementCasePane.getGridRow().updateUI();
((DynamicScrollBar)elementCasePane.getVerticalScrollBar()).setDpi(resolution);
((DynamicScrollBar)elementCasePane.getHorizontalScrollBar()).setDpi(resolution);
elementCasePane.getGridColumn().setResolution(resolution);
elementCasePane.getGridColumn().updateUI();
elementCasePane.getGridRow().setResolution(resolution);
elementCasePane.getGridRow().updateUI();
}
if (polyDezi != null){
polyDezi.setResolution(resolution);
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setJTemplateResolution(resolution);
polyDezi.updateUI();
}
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().fireTargetModified();
}
@Override
public int selfAdaptUpdate(){
PolyDesigner polyDezi = reportComposite.centerCardPane.getPolyDezi();
ElementCasePane elementCasePane = reportComposite.centerCardPane.editingComponet.elementCasePane;
if (resolution == 0){
resolution = ScreenResolution.getScreenResolution();
}
if (polyDezi != null && polyDezi.getSelection() != null){
BlockCreator blockCreator =polyDezi.getSelection();
double x = blockCreator.getEditorBounds().getX();
double y = blockCreator.getEditorBounds().getY();
polyDezi.setHorizontalValue((int) x);
polyDezi.setVerticalValue((int) y);
double creatorHeight = blockCreator.getEditorBounds().height;
double creatorWidth = blockCreator.getEditorBounds().width;
double areaHeight = polyDezi.polyArea.getHeight();
double areaWidth = polyDezi.polyArea.getWidth();
if (creatorWidth == 0||creatorHeight == 0){
return resolution;
}
double time =(areaHeight/creatorHeight)<(areaWidth/creatorWidth) ? (areaHeight/creatorHeight) : (areaWidth/creatorWidth);
return (int) (time * ScreenResolution.getScreenResolution());
}else if (elementCasePane != null) {
ElementCasePane reportPane = elementCasePane.getGrid().getElementCasePane();
int column = reportPane.getSelection().getSelectedColumns()[0];
double columnLength = reportPane.getSelection().getSelectedColumns().length;
double columnExtent = reportPane.getGrid().getHorizontalExtent();
int row = reportPane.getSelection().getSelectedRows()[0];
double rowLength = reportPane.getSelection().getSelectedRows().length;
double rowExtent = reportPane.getGrid().getVerticalExtent();
if (columnLength == 0||rowLength == 0){
return resolution;
}
double time = (columnExtent/columnLength) < (rowExtent/rowLength) ? (columnExtent/columnLength) : (rowExtent/rowLength);
if (reportPane.isHorizontalScrollBarVisible()) {
reportPane.getVerticalScrollBar().setValue(row);
reportPane.getHorizontalScrollBar().setValue(column);
}
return (int) (time * elementCasePane.getGrid().getResolution());
}else {
return resolution;
}
}
@Override
@ -756,6 +824,11 @@ public class JWorkBook extends JTemplate<WorkBook, WorkBookUndoState> {
return true;
}
@Override
public HyperlinkGroupPane getHyperLinkPane() {
return ReportHyperlinkGroupPane.getInstance();
}
public void setAuthorityMode(boolean isUpMode) {
centerPane.setAuthorityMode(isUpMode);
}

4
designer/src/com/fr/design/mainframe/ReportComponentCardPane.java

@ -37,6 +37,10 @@ public class ReportComponentCardPane extends JComponent implements TargetModifie
}
}
public PolyDesigner getPolyDezi(){
return this.polyDezi;
}
protected void stopEditing() {
if (editingComponet != null) {
editingComponet.stopEditing();

97
designer/src/com/fr/design/mainframe/ReportComponentComposite.java

@ -1,26 +1,25 @@
package com.fr.design.mainframe;
import java.awt.BorderLayout;
import java.util.ArrayList;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import com.fr.base.FRContext;
import com.fr.base.ScreenResolution;
import com.fr.design.designer.EditingState;
import com.fr.design.event.TargetModifiedListener;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.icontainer.UIModeControlContainer;
import com.fr.design.gui.ispinner.UIBasicSpinner;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.Inter;
import com.fr.grid.Grid;
import com.fr.main.impl.WorkBook;
import com.fr.report.report.TemplateReport;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.*;
import java.util.ArrayList;
/**
* 整个报表编辑区域 包括滚动条中间的grid或者聚合块下面的sheetTab
*
@ -46,12 +45,15 @@ public class ReportComponentComposite extends JComponent {
private JSliderPane jSliderContainer;
private boolean isCtrl = false;
/**
* Constructor with workbook..
*
*/
public ReportComponentComposite(JWorkBook jwb) {
setFocusable(true);
setFocusTraversalKeysEnabled(false);
this.parent = jwb;
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.add(centerCardPane = new ReportComponentCardPane(), BorderLayout.CENTER);
@ -60,25 +62,60 @@ public class ReportComponentComposite extends JComponent {
CellElementRegion = FRGUIPaneFactory.createBorderLayout_S_Pane();
this.add(CellElementRegion, BorderLayout.NORTH);
this.add(createSouthControlPane(), BorderLayout.SOUTH);
jSliderContainer.getShowVal().getDocument().addDocumentListener(jSliderContainerListener);
jSliderContainer.getShowVal().addChangeListener(showValSpinnerChangeListener);
jSliderContainer.getSelfAdaptButton().addItemListener(selfAdaptButtonItemListener);
this.centerCardPane.editingComponet.elementCasePane.getGrid().addMouseWheelListener(showValSpinnerMouseWheelListener);
this.centerCardPane.editingComponet.elementCasePane.getGrid().addKeyListener(showValSpinnerKeyListener);
}
DocumentListener jSliderContainerListener = new DocumentListener() {
KeyListener showValSpinnerKeyListener = new KeyListener() {
@Override
public void insertUpdate(DocumentEvent e) {
double value = Integer.parseInt(jSliderContainer.getShowVal().getText().substring(0, jSliderContainer.getShowVal().getText().indexOf("%")));
value = value>MAX ? MAX : value;
value = value<MIN ? MIN : value;
int resolution = (int) (ScreenResolution.getScreenResolution()*value/HUND);
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setScale(resolution);
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
if (e.isControlDown()) {
isCtrl = true;
}
}
@Override
public void keyReleased(KeyEvent e) {
isCtrl = false;
}
};
MouseWheelListener showValSpinnerMouseWheelListener = new MouseWheelListener() {
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
if (isCtrl) {
int dir = e.getWheelRotation();
int old_resolution = (int) jSliderContainer.getShowVal().getValue();
jSliderContainer.getShowVal().setValue(old_resolution - (dir * MIN));
}
}
};
ChangeListener showValSpinnerChangeListener = new ChangeListener() {
@Override
public void removeUpdate(DocumentEvent e) {
public void stateChanged(ChangeEvent e) {
double value = (int) ((UIBasicSpinner) e.getSource()).getValue();
value = value > MAX ? MAX : value;
value = value < MIN ? MIN : value;
int resolution = (int) (ScreenResolution.getScreenResolution() * value / HUND);
HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setScale(resolution);
}
};
ItemListener selfAdaptButtonItemListener = new ItemListener() {
@Override
public void changedUpdate(DocumentEvent e) {
public void itemStateChanged(ItemEvent e) {
if (jSliderContainer.getSelfAdaptButton().isSelected()) {
int resolution = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().selfAdaptUpdate();
jSliderContainer.getShowVal().setValue(resolution * HUND / ScreenResolution.getScreenResolution());
}
}
};
@ -96,6 +133,7 @@ public class ReportComponentComposite extends JComponent {
return;
}
centerCardPane.populate(workbook.getTemplateReport(newIndex));
if (parentContainer != null) {
parentContainer.setDownPane(ReportComponentComposite.this);
}
@ -126,7 +164,6 @@ public class ReportComponentComposite extends JComponent {
* 移除选中状态
*
* @date 2015-2-5-上午11:41:44
*
*/
public void removeSelection() {
if (centerCardPane.editingComponet instanceof WorkSheetDesigner) {
@ -145,6 +182,10 @@ public class ReportComponentComposite extends JComponent {
return sheetNameTab.getSelectedIndex();
}
public JSliderPane getjSliderContainer() {
return this.jSliderContainer;
}
public void setParentContainer(UIModeControlContainer parentContainer) {
this.parentContainer = parentContainer;
@ -193,21 +234,11 @@ public class ReportComponentComposite extends JComponent {
splitpane.setBorder(null);
splitpane.setDividerSize(3);
splitpane.setResizeWeight(1);
southPane.add(hbarContainer,BorderLayout.NORTH);
southPane.add(splitpane,BorderLayout.CENTER);
southPane.add(hbarContainer, BorderLayout.NORTH);
southPane.add(splitpane, BorderLayout.CENTER);
return southPane;
}
private JComponent createSouthControlPaneWithJSliderPane() {
hbarContainer = FRGUIPaneFactory.createBorderLayout_S_Pane();
hbarContainer.add(centerCardPane.editingComponet.getHorizontalScrollBar());
JSplitPane splitWithJSliderPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, hbarContainer, JSliderPane.getInstance());
splitWithJSliderPane.setBorder(null);
splitWithJSliderPane.setDividerLocation(0.9);
splitWithJSliderPane.setDividerSize(3);
splitWithJSliderPane.setResizeWeight(1);
return splitWithJSliderPane;
}
public void setSelectedIndex(int selectedIndex) {
sheetNameTab.setSelectedIndex(selectedIndex);

50
designer/src/com/fr/design/mainframe/ReportHyperlinkGroupPane.java

@ -0,0 +1,50 @@
package com.fr.design.mainframe;
import com.fr.design.gui.frpane.HyperlinkGroupPane;
import com.fr.grid.selection.CellSelection;
import com.fr.grid.selection.FloatSelection;
import com.fr.grid.selection.Selection;
import com.fr.js.NameJavaScriptGroup;
import com.fr.report.cell.CellElement;
import com.fr.report.cell.FloatElement;
import com.fr.report.elementcase.TemplateElementCase;
/**
* Created by plough on 2017/7/21.
*/
public class ReportHyperlinkGroupPane extends HyperlinkGroupPane {
private static ReportHyperlinkGroupPane singleton;
private ReportHyperlinkGroupPane() {
super();
}
public synchronized static ReportHyperlinkGroupPane getInstance() {
if (singleton == null) {
singleton = new ReportHyperlinkGroupPane();
}
return singleton;
}
public void populate(ElementCasePane reportPane) {
final TemplateElementCase report = reportPane.getEditingElementCase();
NameJavaScriptGroup nameHyperlinks = getNameJSGroup(reportPane, report);
populate(nameHyperlinks);
}
private NameJavaScriptGroup getNameJSGroup(ElementCasePane reportPane, final TemplateElementCase report) {
NameJavaScriptGroup nameHyperlinks = null;
final Selection sel = reportPane.getSelection();
if (sel instanceof FloatSelection) {
FloatElement selectedFloatElement = report.getFloatElement(((FloatSelection)sel).getSelectedFloatName());
nameHyperlinks = selectedFloatElement.getNameHyperlinkGroup();
} else {
CellElement editCellElement = report.getCellElement(((CellSelection)sel).getColumn(), ((CellSelection)sel).getRow());
if (editCellElement != null) {
nameHyperlinks = editCellElement.getNameHyperlinkGroup();
}
}
return nameHyperlinks;
}
}

138
designer/src/com/fr/design/mainframe/form/FormReportComponentComposite.java

@ -1,30 +1,43 @@
package com.fr.design.mainframe.form;
import com.fr.base.DynamicUnitList;
import com.fr.base.ScreenResolution;
import com.fr.design.cell.bar.DynamicScrollBar;
import com.fr.design.event.TargetModifiedEvent;
import com.fr.design.event.TargetModifiedListener;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.ispinner.UIBasicSpinner;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.BaseJForm;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.*;
import com.fr.design.mainframe.toolbar.ToolBarMenuDockPlus;
import com.fr.form.FormElementCaseContainerProvider;
import com.fr.form.FormElementCaseProvider;
import com.fr.grid.Grid;
import com.fr.grid.GridUtils;
import com.fr.report.ReportHelper;
import com.fr.report.worksheet.FormElementCase;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.*;
/**
* 整个FormElementCase编辑区域 包括滚动条中间的grid或者聚合块下面的sheetTab
*/
public class FormReportComponentComposite extends JComponent implements TargetModifiedListener, FormECCompositeProvider{
private FormElementCaseDesigner elementCaseDesigner;
private static final int MAX = 400;
private static final int HUND = 100;
private static final int MIN = 10;
public FormElementCaseDesigner elementCaseDesigner;
private BaseJForm jForm;
private FormTabPane sheetNameTab;
private JPanel hbarContainer;
private JSliderPane jSliderContainer;
private boolean isCtrl = false;
public FormReportComponentComposite(BaseJForm jform, FormElementCaseDesigner elementCaseDesign, FormElementCaseContainerProvider ecContainer) {
this.jForm = jform;
@ -33,12 +46,114 @@ public class FormReportComponentComposite extends JComponent implements TargetMo
this.add(elementCaseDesigner, BorderLayout.CENTER);
sheetNameTab = new FormTabPane(ecContainer, jform);
this.add(createSouthControlPane(), BorderLayout.SOUTH);
jSliderContainer.getShowVal().addChangeListener(showValSpinnerChangeListener);
jSliderContainer.getSelfAdaptButton().addItemListener(selfAdaptButtonItemListener);
((JForm)this.jForm).getFormDesign().getArea().addMouseWheelListener(showValSpinnerMouseWheelListener);
((JForm)this.jForm).getFormDesign().getArea().addKeyListener(showValSpinnerKeyListener);
this.elementCaseDesigner.elementCasePane.getGrid().addMouseWheelListener(showValSpinnerMouseWheelListener);
this.elementCaseDesigner.elementCasePane.getGrid().addKeyListener(showValSpinnerKeyListener);
elementCaseDesigner.addTargetModifiedListener(this);
}
KeyListener showValSpinnerKeyListener = new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
if( e.isControlDown()){
isCtrl = true ;
}
}
@Override
public void keyReleased(KeyEvent e) {
isCtrl = false ;
}
};
MouseWheelListener showValSpinnerMouseWheelListener = new MouseWheelListener() {
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
if (isCtrl){
int dir = e.getWheelRotation();
int old_resolution = (int) jSliderContainer.getShowVal().getValue();
jSliderContainer.getShowVal().setValue(old_resolution - (dir * MIN));
}
}
};
ChangeListener showValSpinnerChangeListener = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
double value = (int) ((UIBasicSpinner)e.getSource()).getValue();
value = value > MAX ? MAX : value;
value = value < MIN ? MIN : value;
int resolution = (int) (ScreenResolution.getScreenResolution()*value/HUND);
setScale(resolution);
// HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().setScale(resolution);
}
};
ItemListener selfAdaptButtonItemListener = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (jSliderContainer.getSelfAdaptButton().isSelected()){
int resolution = selfAdaptUpdate();
jSliderContainer.getShowVal().setValue(resolution*HUND/ScreenResolution.getScreenResolution());
}
}
};
private java.util.List<TargetModifiedListener> targetModifiedList = new java.util.ArrayList<TargetModifiedListener>();
private void setScale(int resolution){
JForm jForm = (JForm) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
ElementCasePane elementCasePane = ((FormReportComponentComposite)jForm.getReportComposite()).elementCaseDesigner.getEditingElementCasePane();
elementCasePane.setResolution(resolution);
elementCasePane.getGrid().getGridMouseAdapter().setResolution(resolution);
elementCasePane.getGrid().setResolution(resolution);
//更新Grid
Grid grid = elementCasePane.getGrid();
DynamicUnitList rowHeightList = ReportHelper.getRowHeightList(elementCasePane.getEditingElementCase());
DynamicUnitList columnWidthList = ReportHelper.getColumnWidthList(elementCasePane.getEditingElementCase());
grid.setVerticalExtent(GridUtils.getExtentValue(0, rowHeightList, grid.getHeight(), resolution));
grid.setHorizontalExtent(GridUtils.getExtentValue(0, columnWidthList, grid.getWidth(), resolution));
elementCasePane.getGrid().updateUI();
//更新Column和Row
((DynamicScrollBar)elementCasePane.getVerticalScrollBar()).setDpi(resolution);
((DynamicScrollBar)elementCasePane.getHorizontalScrollBar()).setDpi(resolution);
elementCasePane.getGridColumn().setResolution(resolution);
elementCasePane.getGridColumn().updateUI();
elementCasePane.getGridRow().setResolution(resolution);
elementCasePane.getGridRow().updateUI();
}
private int selfAdaptUpdate(){
JForm jForm = (JForm) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (jForm.resolution == 0){
jForm.resolution = ScreenResolution.getScreenResolution();
}
ElementCasePane elementCasePane = ((FormReportComponentComposite)jForm.getReportComposite()).elementCaseDesigner.getEditingElementCasePane();
ElementCasePane reportPane = elementCasePane.getGrid().getElementCasePane();
int column = reportPane.getSelection().getSelectedColumns()[0];
double columnLength = reportPane.getSelection().getSelectedColumns().length;
double columnExtent = reportPane.getGrid().getHorizontalExtent();
int row = reportPane.getSelection().getSelectedRows()[0];
double rowLength = reportPane.getSelection().getSelectedRows().length;
double rowExtent = reportPane.getGrid().getVerticalExtent();
if (columnLength == 0||rowLength == 0){
return jForm.resolution;
}
double time =(columnExtent/columnLength)<(rowExtent/rowLength) ? (columnExtent/columnLength) : (rowExtent/rowLength);
if (reportPane.isHorizontalScrollBarVisible()) {
reportPane.getVerticalScrollBar().setValue(row);
reportPane.getHorizontalScrollBar().setValue(column);
}
return (int) (time * elementCasePane.getGrid().getResolution());
}
/**
* 添加目标改变的监听
* @param targetModifiedListener 目标改变事件
@ -62,13 +177,18 @@ public class FormReportComponentComposite extends JComponent implements TargetMo
}
private JComponent createSouthControlPane() {
JPanel southPane = new JPanel(new BorderLayout());
hbarContainer = FRGUIPaneFactory.createBorderLayout_S_Pane();
hbarContainer.add(elementCaseDesigner.getHorizontalScrollBar());
JSplitPane splitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sheetNameTab, hbarContainer);
jSliderContainer = JSliderPane.getInstance();
JSplitPane splitpane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, sheetNameTab, jSliderContainer);
southPane.add(hbarContainer,BorderLayout.NORTH);
southPane.add(splitpane,BorderLayout.CENTER);
splitpane.setBorder(null);
splitpane.setDividerSize(3);
splitpane.setResizeWeight(0.6);
return splitpane;
splitpane.setResizeWeight(1);
return southPane;
}
/**

1
designer/src/com/fr/design/present/BarCodePane.java

@ -69,6 +69,7 @@ public class BarCodePane extends FurtherBasicBeanPane<BarcodePresent> {
addlistener();
}
private void initComponents() {
barCodePreviewPane = new BarCodePreviewPane();
this.barWidthSpinner = new UIBasicSpinner(new SpinnerNumberModel(1, 1, 100, 0.1));

33
designer/src/com/fr/grid/AbstractGridHeaderMouseHandler.java

@ -41,7 +41,6 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter {
protected static final int SEPARATOR_GAP = 5;
private GridHeader gHeader;
private int dragType = GridUtils.DRAG_NONE;
//james 是否为选定多行的drag
private boolean isMultiSelectDragPermited = false;
@ -53,9 +52,15 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter {
private int dragIndex = 0;
private JToolTip tip = null;
private JWindow tipWindow = null;
protected int resolution = ScreenResolution.getScreenResolution();
public AbstractGridHeaderMouseHandler(GridHeader gHeader) {
this.gHeader = gHeader;
if (gHeader instanceof GridColumn){
this.resolution = ((GridColumn)gHeader).getResolution();
}else {
this.resolution = ((GridRow)gHeader).getResolution();
}
}
public void setStartMultiSelectIndex(int index) {
@ -98,7 +103,7 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter {
@Override
public boolean run(MouseEvent evt, int index, double tmpSize1, double tmpSize2, int tmpIncreaseSize, int oldEndValueSize, ElementCase report, DynamicUnitList sizeList) {
int resolution = ScreenResolution.getScreenResolution();
// int resolution = ScreenResolution.getScreenResolution();
// richer:这边这么做的原因是调整了行高列宽后需要通知聚合块改变边界
Method method = null;
try {
@ -142,7 +147,7 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter {
private ScrollAction PRESS_ACTION = new ScrollAction() {
@Override
public boolean run(MouseEvent evt, int index, double tmpSize1, double tmpSize2, int tmpIncreaseSize, int oldEndValueSize, ElementCase report, DynamicUnitList sizeList) {
int resolution = ScreenResolution.getScreenResolution();
// int resolution = ScreenResolution.getScreenResolution();
if (isOnSeparatorLineIncludeZero(evt, tmpSize2, tmpIncreaseSize) || isOnNormalSeparatorLine(evt, tmpSize2)) {
dragType = GridUtils.DRAG_CELL_SIZE;
@ -177,7 +182,7 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter {
double tmpIncreaseSize = 0;
double oldEndValueSize = 0;
int resolution = ScreenResolution.getScreenResolution();
// int resolution = ScreenResolution.getScreenResolution();
for (int index = beginValue; index < endValue; index++) { // denny:
// beginValue
@ -215,7 +220,7 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter {
ePane.getGrid().stopEditing();// james 停止当前的所有编辑
// peter:选中格子位置.
ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow(ePane, evt.getX(), evt.getY());
ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow_withresolution(ePane, evt.getX(), evt.getY(),resolution);
iterateScrollBar(ePane, evt, PRESS_ACTION);
@ -255,7 +260,7 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter {
* @param evtY
*/
private void doShiftSelectHeader(ElementCasePane ePane, double evtX, double evtY) {
ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow(ePane, evtX, evtY);
ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow_withresolution(ePane, evtX, evtY, resolution);
int selectedCellPointX = selectedCellPoint.getColumn();// column.
int selectedCellPointY = selectedCellPoint.getRow();// row.
CellSelection cs = ((CellSelection) ePane.getSelection()).clone();
@ -294,7 +299,7 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter {
private String createToolTipString(double doubleValue, double totalDoubleValue) {
int unitType = DesignerEnvManager.getEnvManager().getReportLengthUnit();
int resolution = ScreenResolution.getScreenResolution();
// int resolution = ScreenResolution.getScreenResolution();
FU ulen = FU.valueOfPix((int) doubleValue, resolution);
FU tulen = FU.valueOfPix((int) totalDoubleValue, resolution);
String unit;
@ -317,11 +322,11 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter {
unit = Inter.getLocText("Unit_MM");
}
StringBuilder sb = new StringBuilder();
sb.append(Utils.convertNumberStringToString(new Float(len)))
.append('/').append(Utils.convertNumberStringToString(new Float(tlen)))
sb.append(String.format("%.2f", new Double(len)))
.append('/').append(String.format("%.2f", new Double(tlen)))
.append(unit).append('(')
.append(Utils.doubleToString(doubleValue)).append('/')
.append(Utils.doubleToString(totalDoubleValue))
.append((int)(doubleValue)).append('/')
.append((int)(totalDoubleValue))
.append(Inter.getLocText("px"))
.append(')');
return sb.toString();
@ -401,7 +406,7 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter {
if (!this.isMultiSelectDragPermited) {
return;
}
ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow(ePane, evt.getX(), evt.getY());
ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow_withresolution(ePane, evt.getX(), evt.getY(), resolution);
endMultiSelectIndex = getColumnOrRowByGridHeader(selectedCellPoint);
resetGridSelectionByDrag(cs, ePane, startMultiSelectIndex, endMultiSelectIndex);
cs.setSelectedType(doChooseFrom());
@ -421,7 +426,7 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter {
iterateScrollBar(ePane, evt, DRAG_ACTION);
DynamicUnitList sizeList = getSizeList(report);
int resolution = ScreenResolution.getScreenResolution();
// int resolution = ScreenResolution.getScreenResolution();
this.setToolTipText2(this.createToolTipString(sizeList.get(dragIndex).toPixD(resolution), sizeList.getRangeValue(0, dragIndex + 1).toPixD(resolution)));
}
@ -472,7 +477,7 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter {
double tmpSize1 = 0;
double tmpSize2;
double tmpIncreaseSize = 0;
int resolution = ScreenResolution.getScreenResolution();
// int resolution = ScreenResolution.getScreenResolution();
for (int i = beginValue; i < endValue; i++) {
if (i == 0) {

4
designer/src/com/fr/grid/Grid.java

@ -141,6 +141,10 @@ public class Grid extends BaseGridComponent {
this.resolution = resolution;
}
public int getResolution() {
return this.resolution;
}
/**
* 应用界面设置
*

20
designer/src/com/fr/grid/GridColumn.java

@ -10,6 +10,7 @@ import com.fr.base.ScreenResolution;
import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fun.GridUIProcessor;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.JSliderPane;
import com.fr.stable.StableUtils;
import javax.swing.plaf.ComponentUI;
@ -22,11 +23,15 @@ import javax.swing.plaf.ComponentUI;
*/
public class GridColumn extends GridHeader<String> {
private int resolution = ScreenResolution.getScreenResolution();
public int resolution = ScreenResolution.getScreenResolution();
private GridColumnMouseHandler gridColumnMouseHandler;
@Override
protected void initByConstructor() {
GridColumnMouseHandler gridColumnMouseHandler = new GridColumnMouseHandler(this);
resolution = ScreenResolution.getScreenResolution();
this.setResolution(resolution);
gridColumnMouseHandler = new GridColumnMouseHandler(this);
this.addMouseListener(gridColumnMouseHandler);
this.addMouseMotionListener(gridColumnMouseHandler);
this.updateUI();
@ -39,6 +44,12 @@ public class GridColumn extends GridHeader<String> {
@Override
public void updateUI() {
this.removeMouseListener(gridColumnMouseHandler);
this.removeMouseMotionListener(gridColumnMouseHandler);
gridColumnMouseHandler = new GridColumnMouseHandler(this);
this.addMouseListener(gridColumnMouseHandler);
this.addMouseMotionListener(gridColumnMouseHandler);
// gridColumnMouseHandler.setResolution(resolution);
this.setUI(new GridColumnUI(resolution));
}
@ -46,6 +57,11 @@ public class GridColumn extends GridHeader<String> {
this.resolution = resolution;
}
@Override
public int getResolution() {
return this.resolution;
}
/**
* Gets the preferred size.
*/

9
designer/src/com/fr/grid/GridColumnMouseHandler.java

@ -9,6 +9,7 @@ import java.awt.event.MouseEvent;
import javax.swing.SwingUtilities;
import com.fr.base.DynamicUnitList;
import com.fr.base.ScreenResolution;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.grid.selection.CellSelection;
@ -22,8 +23,15 @@ import com.fr.stable.ColumnRow;
*/
public class GridColumnMouseHandler extends AbstractGridHeaderMouseHandler {
private int resolution;
public GridColumnMouseHandler(GridColumn gridColumn) {
super(gridColumn);
this.resolution = gridColumn.resolution;
}
public void setResolution(int resolution){
this.resolution = resolution;
}
@Override
@ -86,7 +94,6 @@ public class GridColumnMouseHandler extends AbstractGridHeaderMouseHandler {
/**
* Checks whether is on zero separator line.
*
* @param evtX event x
*/
@Override
protected boolean isOnSeparatorLineIncludeZero(MouseEvent evt, double tmpWidth2, double tmpIncreaseWidth) {

12
designer/src/com/fr/grid/GridHeader.java

@ -1,5 +1,7 @@
package com.fr.grid;
import com.fr.base.ScreenResolution;
import java.awt.Color;
@ -12,6 +14,8 @@ public abstract class GridHeader<T> extends BaseGridComponent {
private Color selectedForeground = Color.black;
private Color selectedBackground = new Color(253, 216, 153);
protected int resolution;
public GridHeader() {
//清除所有的Key Action.
this.getInputMap().clear();
@ -23,6 +27,14 @@ public abstract class GridHeader<T> extends BaseGridComponent {
initByConstructor();
}
public void setResolution(int resolution){
this.resolution = resolution;
}
public int getResolution(){
return this.resolution;
}
protected abstract void initByConstructor();
protected abstract T getDisplay(int index) ;

14
designer/src/com/fr/grid/GridRow.java

@ -23,10 +23,13 @@ public class GridRow extends GridHeader<Integer> {
private static final int MAX = 5;
private int resolution = ScreenResolution.getScreenResolution();
private GridRowMouseHandler gridRowMouseHandler;
@Override
protected void initByConstructor() {
GridRowMouseHandler gridRowMouseHandler = new GridRowMouseHandler(this);
resolution = ScreenResolution.getScreenResolution();
this.setResolution(resolution);
gridRowMouseHandler = new GridRowMouseHandler(this);
this.addMouseListener(gridRowMouseHandler);
this.addMouseMotionListener(gridRowMouseHandler);
this.updateUI();
@ -39,6 +42,11 @@ public class GridRow extends GridHeader<Integer> {
@Override
public void updateUI() {
this.removeMouseListener(gridRowMouseHandler);
this.removeMouseMotionListener(gridRowMouseHandler);
gridRowMouseHandler = new GridRowMouseHandler(this);
this.addMouseListener(gridRowMouseHandler);
this.addMouseMotionListener(gridRowMouseHandler);
this.setUI(new GridRowUI(resolution));
}
@ -46,6 +54,10 @@ public class GridRow extends GridHeader<Integer> {
this.resolution = resolution;
}
public int getResolution() {
return this.resolution;
}
/**
* Gets the preferred size.

18
designer/src/com/fr/poly/PolyArea.java

@ -1,15 +1,29 @@
package com.fr.poly;
import javax.swing.JComponent;
public class PolyArea extends JComponent {
private PolyDesigner polyDesigner;
private int resolution;
public PolyArea(PolyDesigner polyDesigner) {
public PolyArea(PolyDesigner polyDesigner, int resolution) {
this.polyDesigner = polyDesigner;
setUI(new PolyDesignUI());
this.resolution = resolution;
this.setUI(new PolyDesignUI(resolution));
// setUI(new PolyDesignUI());
}
public void setResolution(int resolution) {
this.resolution = resolution;
}
public int getResolution() {
return this.resolution;
}
public PolyDesigner getPolyDesigner() {
return polyDesigner;
}

60
designer/src/com/fr/poly/PolyDesignUI.java

@ -10,6 +10,7 @@ import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.text.DecimalFormat;
import java.util.ArrayList;
@ -27,12 +28,14 @@ import com.fr.general.Inter;
import com.fr.page.PaperSettingProvider;
import com.fr.page.ReportSettingsProvider;
import com.fr.poly.creator.BlockCreator;
import com.fr.poly.creator.ECBlockCreator;
import com.fr.poly.model.AddedData;
import com.fr.poly.model.AddingData;
import com.fr.report.report.Report;
import com.fr.report.report.TemplateReport;
import com.fr.report.stable.ReportConstants;
import com.fr.stable.Constants;
import com.fr.stable.CoreGraphHelper;
import com.fr.stable.unit.UNIT;
/**
@ -44,13 +47,17 @@ public class PolyDesignUI extends ComponentUI {
private static final double SCROLL_POINT = 50;
private static final int SCROLL_DISTANCE = 15;
private static final int TEN = 10;
private static final int HHUNDRED = 100;
private PolyDesigner designer;
private int resolution = ScreenResolution.getScreenResolution();
private int ten = 10;
private int hundred = 100;
private int resolution;
private float time;
public PolyDesignUI() {
public PolyDesignUI(int resolution) {
if (resolution == 0){
resolution = ScreenResolution.getScreenResolution();
}
this.resolution = resolution;
}
/**
@ -83,6 +90,8 @@ public class PolyDesignUI extends ComponentUI {
@Override
public void paint(Graphics g, JComponent c) {
this.resolution = ((PolyArea)c).getResolution();
this.time = (float)resolution/ScreenResolution.getScreenResolution();
paintBackground(g, c);
Graphics2D g2d = (Graphics2D) g;
paintAddedData(g2d);
@ -100,8 +109,8 @@ public class PolyDesignUI extends ComponentUI {
BlockCreator creator = addedData.getAddedAt(i);
// richer:如果当前这个组件正在编辑,那么他是完全被他的编辑器所遮挡的,不需要画出来
if (creator == designer.getSelection()) {
paintPositionLine(g, creator.getX(), creator.getY(), designer.getHorizontalValue(), designer
.getVerticalValue());
paintPositionLine(g, creator.getX(time), creator.getY(time),
(int) (designer.getHorizontalValue()*time), (int) (designer.getVerticalValue()*time));
if (creator.getEditor().isDragging()) {
creator.getEditor().paintAbsorptionline(g);
//如果与其他块重合了, 需要画出提示禁止重叠
@ -112,8 +121,8 @@ public class PolyDesignUI extends ComponentUI {
creator.getEditor().hideForbiddenWindow();
}
} else {
paintCreator(g, creator, creator.getX() - designer.getHorizontalValue(), creator.getY() - designer.getVerticalValue(),
creator.getWidth(), creator.getHeight());
paintCreator(g, creator, (int) (creator.getX()*time - designer.getHorizontalValue()*time), (int) (creator.getY()*time - designer.getVerticalValue()*time),
(int) (creator.getWidth()*time), (int) (creator.getHeight()*time));
}
}
}
@ -126,8 +135,8 @@ public class PolyDesignUI extends ComponentUI {
return;
}
int x = (int) (designer.getAreaLocationX() + pixRec.getCenterX() - designer.getHorizontalValue());
int y = (int) (designer.getAreaLocationY() + pixRec.getCenterY() - designer.getVerticalValue());
int x = (int) (designer.getAreaLocationX() + pixRec.getCenterX()*time - designer.getHorizontalValue());
int y = (int) (designer.getAreaLocationY() + pixRec.getCenterY()*time - designer.getVerticalValue());
creator.getEditor().showForbiddenWindow(x, y);
}
@ -183,16 +192,16 @@ public class PolyDesignUI extends ComponentUI {
private String convertUnit(int i) {
short unit = designer.getRulerLengthUnit();
int resolution = ScreenResolution.getScreenResolution();
// int resolution = ScreenResolution.getScreenResolution();
if (unit == Constants.UNIT_MM) {
Double j = (i + 2) * 1.0 * Constants.HUNDRED_FU_PER_INCH / Constants.HUNDRED_FU_PER_MM / resolution;
return j.intValue() + Inter.getLocText("Unit_MM");
} else if (unit == Constants.UNIT_CM) {
Double j = (i + 2) * 1.0 * Constants.HUNDRED_FU_PER_INCH / Constants.HUNDRED_FU_PER_MM / resolution;
return new DecimalFormat("0.0").format(j.intValue() * 1.0 / ten) + Inter.getLocText("Unit_CM");
return new DecimalFormat("0.0").format(j.intValue() * 1.0 / TEN) + Inter.getLocText("Unit_CM");
} else if (unit == Constants.UNIT_INCH) {
Double j = i == 0 ? 0 : (i + 2) * 1.0 / resolution * hundred;
return new DecimalFormat("0.00").format(j.intValue() * 1.0 / hundred) + Inter.getLocText("Unit_INCH");
Double j = i == 0 ? 0 : (i + 2) * 1.0 / resolution * HHUNDRED;
return new DecimalFormat("0.00").format(j.intValue() * 1.0 / HHUNDRED) + Inter.getLocText("Unit_INCH");
} else if (unit == Constants.UNIT_PT) {
int j = i == 0 ? 0 : (i + 2) * UNIT.PT_PER_INCH / resolution;
return j + Inter.getLocText("Unit_PT");
@ -203,10 +212,10 @@ public class PolyDesignUI extends ComponentUI {
private void paintAddingData(Graphics g, AddingData addingData) {
BlockCreator comp = addingData.getCreator();
int x = addingData.getCurrentX();
int y = addingData.getCurrentY();
int width = comp.getWidth();
int height = comp.getHeight();
int x = (int) (addingData.getCurrentX()*time);
int y = (int) (addingData.getCurrentY()*time);
int width = (int) (comp.getWidth()*time);
int height = (int) (comp.getHeight()*time);
paintCreator(g, comp, x, y, width, height);
}
@ -214,9 +223,16 @@ public class PolyDesignUI extends ComponentUI {
ArrayList<JComponent> dbcomponents = new ArrayList<JComponent>();
// richer:禁止双缓冲行为,否则会出现两个图像
ComponentUtils.disableBuffer(comp, dbcomponents);
Graphics clipg = g.create(x, y, width, height);
comp.paint(clipg);
clipg.dispose();
// Graphics clipg = g.create(x, y, width*resolution/ScreenResolution.getScreenResolution(), height*resolution/ScreenResolution.getScreenResolution());
//
BufferedImage img = CoreGraphHelper.createBufferedImage(comp.getWidth(), comp.getHeight(), BufferedImage.TYPE_INT_RGB);
Graphics2D g2d = img.createGraphics();
comp.printAll(g2d);
g2d.dispose();
g.drawImage(img,x,y,width,height,null);
// comp.paint(clipg);
// clipg.dispose();
ComponentUtils.resetBuffer(dbcomponents);
}

163
designer/src/com/fr/poly/PolyDesigner.java

@ -3,25 +3,6 @@
*/
package com.fr.poly;
import java.awt.AWTEvent;
import java.awt.Adjustable;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
import javax.swing.AbstractAction;
import javax.swing.ActionMap;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.JScrollBar;
import javax.swing.KeyStroke;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.base.GraphHelper;
@ -36,16 +17,7 @@ import com.fr.design.designer.EditingState;
import com.fr.design.designer.TargetComponent;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.AuthorityEditPane;
import com.fr.design.mainframe.CellElementPropertyPane;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.EastRegionContainerPane;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.ElementCasePaneAuthorityEditPane;
import com.fr.design.mainframe.FormScrollBar;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.NoSupportAuthorityEdit;
import com.fr.design.mainframe.ReportComponent;
import com.fr.design.mainframe.*;
import com.fr.design.mainframe.cell.QuickEditorRegion;
import com.fr.design.menu.MenuDef;
import com.fr.design.menu.ShortCut;
@ -61,11 +33,7 @@ import com.fr.design.utils.gui.LayoutUtils;
import com.fr.general.ComparatorUtils;
import com.fr.grid.selection.Selection;
import com.fr.poly.actions.DeleteBlockAction;
import com.fr.poly.creator.BlockCreator;
import com.fr.poly.creator.BlockEditor;
import com.fr.poly.creator.ECBlockCreator;
import com.fr.poly.creator.ECBlockEditor;
import com.fr.poly.creator.PolyElementCasePane;
import com.fr.poly.creator.*;
import com.fr.poly.hanlder.DataEditingListener;
import com.fr.poly.hanlder.PolyDesignerDropTarget;
import com.fr.poly.model.AddedData;
@ -81,6 +49,15 @@ import com.fr.stable.unit.OLDPIX;
import com.fr.stable.unit.UNIT;
import com.fr.stable.unit.UnitRectangle;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
/**
* @author richer
* @since 6.5.3 聚合报表的设计块不包括底部和右边的滚动条以及左边和上边的像素标识条
@ -99,6 +76,7 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
NONE, INNER, BLOCK
}
public JComponent polyArea;
private SelectionType selectedtype = SelectionType.NONE;
private AddingData addingData;
private AddedData addedData;
@ -108,20 +86,24 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
private int horizontalValue = 0;
private int verticalValue = 0;
private transient ArrayList<TemplateBlock> clip_board = new ArrayList<TemplateBlock>();
// richer:鼠标滚轮每滚动一下,PolyDesignPane的尺寸就改变ROTATIONS这么多
private static final int ROTATIONS = 50;
private static final int MIN = 10;
private JScrollBar verScrollBar;
private JScrollBar horScrollBar;
private JComponent polyArea;
private PolyComponetsBar polyComponetsBar = new PolyComponetsBar();
private JComponent[] toolBarComponent = null;
private int resolution = ScreenResolution.getScreenResolution();
private JPanel ployareaPane;
private JSliderPane jSliderContainer;
private int resolution = (int) (ScreenResolution.getScreenResolution() * JSliderPane.getInstance().resolutionTimes);
private float time;
private boolean isCtrl = false;
public PolyDesigner(PolyWorkSheet report) {
super(report);
setDoubleBuffered(true);
// 为了处理键盘事件,需要FormDesigner能够获取焦点
setFocusable(true);
setFocusTraversalKeysEnabled(false);
@ -131,11 +113,13 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
enableEvents(AWTEvent.KEY_EVENT_MASK | AWTEvent.MOUSE_EVENT_MASK | AWTEvent.MOUSE_MOTION_EVENT_MASK | AWTEvent.MOUSE_WHEEL_EVENT_MASK);
setOpaque(true);
initComponents();
this.initDataListeners();
this.initPolyBlocks();
this.setFocusTraversalKeysEnabled(false);
new PolyDesignerDropTarget(this);
toolBarComponent = new JComponent[]{new CutAction(this).createToolBarComponent(), new CopyAction(this).createToolBarComponent(), new PasteAction(this).createToolBarComponent(), new DeleteBlockAction(this).createToolBarComponent()};
@ -155,9 +139,10 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
}
private void initComponents() {
jSliderContainer = ((JWorkBook) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()).reportComposite.getjSliderContainer();
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel ployareaPane = new JPanel(new PolyDesignerLayout());
polyArea = new PolyArea(this);
ployareaPane = new JPanel(new PolyDesignerLayout());
polyArea = new PolyArea(this, resolution);
ployareaPane.add(PolyDesignerLayout.Center, polyArea);
horScrollBar = new FormScrollBar(Adjustable.HORIZONTAL, this);
@ -169,7 +154,27 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
ployareaPane.add(PolyDesignerLayout.HRuler, new HorizontalRuler(this));
this.add(ployareaPane, BorderLayout.CENTER);
this.add(polyComponetsBar, BorderLayout.WEST);
this.addKeyListener(showValSpinnerKeyListener);
}
KeyListener showValSpinnerKeyListener = new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
if (e.isControlDown()) {
isCtrl = true;
}
}
@Override
public void keyReleased(KeyEvent e) {
isCtrl = false;
}
};
private void initPolyBlocks() {
for (int i = 0, count = this.getTarget().getBlockCount(); i < count; i++) {
@ -181,8 +186,23 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
repaint();
}
public void setResolution(int resolution) {
this.resolution = resolution;
}
public int getResolution() {
return this.resolution;
}
public void updateUI() {
((PolyArea) this.polyArea).setResolution(resolution);
polyArea.repaint();
// this.polyArea = (JComponent) new PolyArea(this, resolution);
}
/**
* 是否含有聚和报表块
*
* @param targetComponent 目标组件
* @return 是则返回true
*/
@ -217,8 +237,13 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
}
public JPanel getPloyAreaPane() {
return this.ployareaPane;
}
/**
* 增加组件
*
* @param currentEditor 组件
*/
public void addEditor(BlockEditor currentEditor) {
@ -227,6 +252,7 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
/**
* 移除组件
*
* @param currentEditor 组件
*/
public void removeEditor(BlockEditor currentEditor) {
@ -235,6 +261,7 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
/**
* 权限编辑状态
*
* @return 权限编辑面板
*/
public AuthorityEditPane createAuthorityEditPane() {
@ -250,15 +277,27 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
@Override
public void paintComponent(Graphics g) {
this.time = (float) resolution / ScreenResolution.getScreenResolution();
resetEditorComponentBounds();
LayoutUtils.layoutRootContainer(this);
g.setColor(Color.black);
GraphHelper.drawLine(g, 0, 0, this.getWidth(), 0);
GraphHelper.drawLine(g, 0, 0, 0, this.getHeight());
super.paintComponent(g);
}
private void resetEditorComponentBounds() {
if (selection != null) {
selection.setResolution(this.resolution);
selection.getEditor().setBounds((int) (selection.getEditorBounds().x * time), (int) (selection.getEditorBounds().y * time),
(int) (selection.getEditorBounds().width * time), (int) (selection.getEditorBounds().height * time));
LayoutUtils.layoutRootContainer(this);
}
}
/**
* 增加组件
*
* @param creator 组件
*/
public void addBlockCreator(BlockCreator creator) {
@ -345,6 +384,7 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
/**
* 选中的是否是报表块
*
* @return 是则返回true
*/
public boolean isSelectedECBolck() {
@ -368,12 +408,6 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
repaint();
}
private void resetEditorComponentBounds() {
if (selection != null) {
selection.getEditor().setBounds(selection.getEditorBounds());
LayoutUtils.layoutRootContainer(this);
}
}
/**
* @return
@ -425,6 +459,7 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
/**
* 黏贴
*
* @return 黏贴成功返回true
*/
public boolean paste() {
@ -484,6 +519,7 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
/**
* 删除
*
* @return 删除成功返回true
*/
public boolean delete() {
@ -523,6 +559,7 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
/**
* 剪切
*
* @return 剪切成功返回true
*/
public boolean cut() {
@ -533,6 +570,7 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
/**
* 移动
*
* @param x 横坐标
* @param y 纵坐标
*/
@ -636,8 +674,14 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
int id = evt.getID();
switch (id) {
case MouseEvent.MOUSE_WHEEL: {
if (isCtrl) {
int dir = evt.getWheelRotation();
int old_resolution = (int) jSliderContainer.getShowVal().getValue();
jSliderContainer.getShowVal().setValue(old_resolution - (dir * MIN));
} else {
int rotations = evt.getWheelRotation();
this.getVerticalScrollBar().setValue(this.getVerticalScrollBar().getValue() + rotations * ROTATIONS);
}
break;
}
}
@ -645,6 +689,7 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
/**
* 开始编辑
*
* @param blockName 聚合块名称
*/
public void startEditing(String blockName) {
@ -835,7 +880,7 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
if (!ComparatorUtils.equals(selectedtype, type) || type == SelectionType.NONE) {
selectedtype = type;
JTemplate<?, ?> jt = DesignerContext.getDesignerFrame().getSelectedJTemplate();
if(jt != null){
if (jt != null) {
jt.setComposite();
}
DesignerContext.getDesignerFrame().resetToolkitByPlus(DesignerContext.getDesignerFrame().getSelectedJTemplate());
@ -877,6 +922,7 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
/**
* 是否选中聚合块本身
*
* @return 是则返回true
*/
public boolean isChooseBlock() {
@ -925,6 +971,7 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
/**
* 计算滚动条的值和max
*
* @param oldmax 之前最大值
* @param max 当前最大值
* @param newValue 当前value
@ -941,9 +988,8 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
* 获取当前聚合报表区域左上角x坐标
*
* @return 当前聚合报表区域左上角x坐标
*
*/
public double getAreaLocationX(){
public double getAreaLocationX() {
return polyArea.getLocationOnScreen().getX();
}
@ -951,9 +997,8 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
* 获取当前聚合报表区域左上角y坐标
*
* @return 当前聚合报表区域左上角y坐标
*
*/
public double getAreaLocationY(){
public double getAreaLocationY() {
return polyArea.getLocationOnScreen().getY();
}
@ -961,11 +1006,9 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
* 检测指定块是否与其他的块有重叠区域
*
* @param creator 指定的块编辑器
*
* @return 是否与其他的块有重叠区域
*
*/
public boolean intersectsAllBlock(BlockCreator creator){
public boolean intersectsAllBlock(BlockCreator creator) {
return intersectsAllBlock(creator.getValue());
}
@ -973,11 +1016,9 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
* 检测指定块是否与其他的块有重叠区域
*
* @param block 指定的块
*
* @return 是否与其他的块有重叠区域
*
*/
public boolean intersectsAllBlock(TemplateBlock block){
public boolean intersectsAllBlock(TemplateBlock block) {
UnitRectangle rec = block.getBounds();
String blockName = block.getBlockName();
return intersectsAllBlock(rec, blockName);
@ -988,22 +1029,20 @@ public class PolyDesigner extends ReportComponent<PolyWorkSheet, PolyElementCase
*
* @param rec 指定的块区域
* @param blockName 指定的块名称
*
* @return 是否与其他的块有重叠区域
*
*/
public boolean intersectsAllBlock(UnitRectangle rec, String blockName){
public boolean intersectsAllBlock(UnitRectangle rec, String blockName) {
PolyWorkSheet worksheet = this.getTarget();
int count = worksheet.getBlockCount();
for (int i = 0; i < count; i++) {
Block temp_block = worksheet.getBlock(i);
UnitRectangle temp_rect = temp_block.getBounds();
if(ComparatorUtils.equals(blockName, temp_block.getBlockName())){
if (ComparatorUtils.equals(blockName, temp_block.getBlockName())) {
continue;
}
if(temp_rect.intersects(rec)){
if (temp_rect.intersects(rec)) {
return true;
}
}

9
designer/src/com/fr/poly/creator/BlockCreator.java

@ -75,6 +75,10 @@ public abstract class BlockCreator<T extends TemplateBlock> extends JComponent i
LayoutUtils.layoutContainer(this);
}
public void setResolution(int resolution){
this.resolution = resolution;
}
//默认大小, 报表块默认3列6行, 图表块默认330*240
public abstract UnitRectangle getDefaultBlockBounds();
@ -85,6 +89,11 @@ public abstract class BlockCreator<T extends TemplateBlock> extends JComponent i
public abstract BlockEditor getEditor();
public abstract int getX(float time);
public abstract int getY(float time);
/**
* 检测按钮状态

2
designer/src/com/fr/poly/creator/BlockEditor.java

@ -50,7 +50,7 @@ public abstract class BlockEditor<T extends JComponent,U extends TemplateBlock>
public BlockEditor(PolyDesigner designer, BlockCreator<U> creator) {
this.designer = designer;
this.creator = creator;
this.resolution = creator.resolution;
this.initComponets();
this.addColumnRowListeners();

23
designer/src/com/fr/poly/creator/ChartBlockCreator.java

@ -3,13 +3,15 @@
*/
package com.fr.poly.creator;
import java.awt.Color;
import java.awt.*;
import java.awt.image.BufferedImage;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.*;
import com.fr.base.ScreenResolution;
import com.fr.design.DesignState;
import com.fr.design.designer.TargetComponent;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.chart.MiddleChartComponent;
import com.fr.design.menu.MenuDef;
import com.fr.design.menu.ShortCut;
@ -34,6 +36,7 @@ public class ChartBlockCreator extends BlockCreator<PolyChartBlock> {
private static final UNIT DEFAULT_WIDTH = FU.getInstance(12573000);
private static final UNIT DEFAULT_HEIGHT = FU.getInstance(9144000);
public ChartBlockCreator() {
}
@ -42,6 +45,10 @@ public class ChartBlockCreator extends BlockCreator<PolyChartBlock> {
super(block);
}
public void setResolution(int resolution){
this.resolution = resolution;
}
/**
* 初始化
* @return 初始化的控件.
@ -64,6 +71,16 @@ public class ChartBlockCreator extends BlockCreator<PolyChartBlock> {
return editor;
}
@Override
public int getX(float time) {
return (int) (this.getX() * time);
}
@Override
public int getY(float time) {
return (int) (this.getY() * time);
}
/**
* 检测按钮状态

13
designer/src/com/fr/poly/creator/ChartBlockEditor.java

@ -5,6 +5,7 @@ package com.fr.poly.creator;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.base.ScreenResolution;
import com.fr.base.chart.BaseChart;
import com.fr.base.chart.BaseChartCollection;
import com.fr.base.chart.BaseChartGetter;
@ -13,6 +14,7 @@ import com.fr.design.border.UIRoundedBorder;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.chart.MiddleChartComponent;
import com.fr.design.mainframe.EastRegionContainerPane;
import com.fr.design.mainframe.JSliderPane;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.NoSupportAuthorityEdit;
import com.fr.design.mainframe.cell.QuickEditorRegion;
@ -25,6 +27,7 @@ import com.fr.poly.PolyDesigner.SelectionType;
import com.fr.poly.hanlder.ColumnOperationMouseHandler;
import com.fr.poly.hanlder.RowOperationMouseHandler;
import com.fr.report.poly.PolyChartBlock;
import com.fr.stable.CoreGraphHelper;
import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.*;
@ -32,6 +35,7 @@ import javax.swing.border.Border;
import java.awt.*;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.image.BufferedImage;
/**
* @author richer
@ -43,6 +47,7 @@ public class ChartBlockEditor extends BlockEditor<MiddleChartComponent, PolyChar
private static Border buttonBorder;
private static String[][] chartsNames;
private static BaseChartNameID[] typeName = BaseChartGetter.getStaticAllChartBaseNames();
private int resolution = (int) (ScreenResolution.getScreenResolution()* JSliderPane.getInstance().resolutionTimes);
static {
buttonBorder = new UIRoundedBorder(new Color(149, 149, 149), 1, 5);
@ -60,8 +65,14 @@ public class ChartBlockEditor extends BlockEditor<MiddleChartComponent, PolyChar
public ChartBlockEditor(PolyDesigner designer, ChartBlockCreator creator) {
super(designer, creator);
this.resolution = creator.resolution;
//shine:和产品商量后决定把最上面一排切换按钮去掉
//this.initNorthBarComponent();
// this.initNorthBarComponent();
}
private void setResolution(int resolution){
this.resolution = resolution;
}
private void initNorthBarComponent() {

13
designer/src/com/fr/poly/creator/ECBlockCreator.java

@ -23,6 +23,9 @@ import com.fr.stable.unit.UnitRectangle;
*/
public class ECBlockCreator extends BlockCreator<PolyECBlock> {
private ECBlockEditor editor;
private static final int CREATOR_WIDTH = 30;
private static final int CREATOR_HEIGHT = 19;
public ECBlockCreator() {
@ -64,6 +67,16 @@ public class ECBlockCreator extends BlockCreator<PolyECBlock> {
return editor;
}
@Override
public int getX(float time) {
return (int) ((this.getX() - CREATOR_WIDTH) * time) + CREATOR_WIDTH;
}
@Override
public int getY(float time) {
return (int) ((this.getY() - CREATOR_HEIGHT) * time) + CREATOR_HEIGHT;
}
/**
* 检测按钮状态
*

5
designer/src/com/fr/poly/creator/ECBlockEditor.java

@ -6,6 +6,7 @@ package com.fr.poly.creator;
import java.awt.Dimension;
import com.fr.base.BaseUtils;
import com.fr.base.ScreenResolution;
import com.fr.design.constants.UIConstants;
import com.fr.design.event.TargetModifiedEvent;
import com.fr.design.event.TargetModifiedListener;
@ -70,6 +71,10 @@ public class ECBlockEditor extends BlockEditor<ECBlockPane, PolyECBlock> {
@Override
protected void initSize() {
resolution = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getJTemplateResolution();
if (resolution == 0){
resolution = ScreenResolution.getScreenResolution();
}
Dimension cornerSize = getCornerSize();
PolyECBlock block = getValue();
UnitRectangle ub = block.getBounds();

286
designer_base/src/com/fr/design/gui/controlpane/UIControlPane.java

@ -0,0 +1,286 @@
package com.fr.design.gui.controlpane;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.EastRegionContainerPane;
import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.Inter;
import com.fr.stable.ArrayUtils;
import com.fr.stable.Nameable;
import javax.swing.*;
import java.awt.*;
/**
* Created by plough on 2017/7/21.
*/
public abstract class UIControlPane extends BasicPane implements UnrepeatedNameHelper {
protected static final int SHORT_WIDTH = 30; //每加一个short Divider位置加30
protected JPanel controlUpdatePane;
private ShortCut4JControlPane[] shorts;
private NameableCreator[] creators;
private ToolBarDef toolbarDef;
private UIToolbar toolBar;
protected PopupEditPane popupEditPane;
// peter:这是整体的一个cardLayout Pane
protected CardLayout cardLayout;
protected JPanel cardPane;
public UIControlPane() {
this.initComponentPane();
}
/**
* 生成添加按钮的NameableCreator
*
* @return 按钮的NameableCreator
*/
public abstract NameableCreator[] createNameableCreators();
public ShortCut4JControlPane[] getShorts() {
return shorts;
}
public void setShorts(ShortCut4JControlPane[] shorts) {
this.shorts = shorts;
}
public void setCreators(NameableCreator[] creators) {
this.creators = creators;
}
public ToolBarDef getToolbarDef() {
return toolbarDef;
}
public void setToolbarDef(ToolBarDef toolbarDef) {
this.toolbarDef = toolbarDef;
}
public UIToolbar getToolBar() {
return toolBar;
}
public void setToolBar(UIToolbar toolBar) {
this.toolBar = toolBar;
}
public CardLayout getCardLayout() {
return cardLayout;
}
public void setCardLayout(CardLayout cardLayout) {
this.cardLayout = cardLayout;
}
public JPanel getCardPane() {
return cardPane;
}
public void setCardPane(JPanel cardPane) {
this.cardPane = cardPane;
}
protected void initComponentPane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.creators = this.createNameableCreators();
this.controlUpdatePane = createControlUpdatePane();
// p: edit card layout
this.cardLayout = new CardLayout();
cardPane = FRGUIPaneFactory.createCardLayout_S_Pane();
cardPane.setLayout(this.cardLayout);
// p:选择的Label
UILabel selectLabel = new UILabel();
cardPane.add(selectLabel, "SELECT");
cardPane.add(controlUpdatePane, "EDIT");
popupEditPane = new PopupEditPane(cardPane);
// SplitPane
// JSplitPane mainSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, getLeftPane(), cardPane);
// mainSplitPane.setBorder(BorderFactory.createLineBorder(GUICoreUtils.getTitleLineBorderColor()));
// mainSplitPane.setOneTouchExpandable(true);
this.add(getLeftPane(), BorderLayout.CENTER);
this.setBorder(BorderFactory.createEmptyBorder(0, 10, 12, 10));
// mainSplitPane.setDividerLocation(getLeftPreferredSize());
this.checkButtonEnabled();
}
protected abstract JPanel createControlUpdatePane();
protected JPanel getLeftPane() {
// LeftPane
JPanel leftPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
JPanel leftContentPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
initLeftPane(leftContentPane);
leftPane.add(leftContentPane, BorderLayout.CENTER);
shorts = this.createShortcuts();
if (ArrayUtils.isEmpty(shorts)) {
return leftPane;
}
toolbarDef = new ToolBarDef();
for (ShortCut4JControlPane sj : shorts) {
toolbarDef.addShortCut(sj.getShortCut());
}
toolBar = ToolBarDef.createJToolBar();
// toolBar.setLayout(new FlowLayout(FlowLayout.LEFT));
toolbarDef.updateToolBar(toolBar);
// 封装一层,加边框
JPanel toolBarPane = new JPanel(new BorderLayout());
toolBarPane.add(toolBar, BorderLayout.CENTER);
toolBarPane.setBorder(BorderFactory.createMatteBorder(1, 1, 0, 1, new Color(201, 198, 184)));
leftContentPane.add(toolBarPane, BorderLayout.NORTH);
// leftContentPane.setBorder(BorderFactory.createLineBorder(new Color(201, 198, 184)));
// 顶部标签及add按钮
UIToolbar topToolBar = new UIToolbar();
topToolBar.setLayout(new BorderLayout());
ShortCut addItem = addItemShortCut().getShortCut();
addItem.intoJToolBar(topToolBar);
topToolBar.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = { p, f };
double[] rowSize = { p};
Component[][] components = new Component[][]{
new Component[]{new UILabel("add hyperlink "), topToolBar},
};
JPanel leftTopPane = TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize);
leftTopPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 6, 0));
leftPane.add(leftTopPane, BorderLayout.NORTH);
return leftPane;
}
/**
* 初始化左边面板
*/
protected void initLeftPane(JPanel leftPane) {
}
protected int getLeftPreferredSize() {
return shorts.length * SHORT_WIDTH;
}
protected ShortCut4JControlPane[] createShortcuts() {
return new ShortCut4JControlPane[]{
// addItemShortCut(),
copyItemShortCut(),
moveUpItemShortCut(),
moveDownItemShortCut(),
sortItemShortCut(),
removeItemShortCut()
};
}
protected abstract ShortCut4JControlPane addItemShortCut();
protected abstract ShortCut4JControlPane removeItemShortCut();
protected abstract ShortCut4JControlPane copyItemShortCut();
protected abstract ShortCut4JControlPane moveUpItemShortCut();
protected abstract ShortCut4JControlPane moveDownItemShortCut();
protected abstract ShortCut4JControlPane sortItemShortCut();
public abstract Nameable[] update();
public void populate(Nameable[] nameableArray) {
}
/**
* 检查按钮可用状态 Check button enabled.
*/
public void checkButtonEnabled() {
}
protected void doBeforeRemove() {
}
protected void doAfterRemove() {
}
public NameableCreator[] creators() {
return creators == null ? new NameableCreator[0] : creators;
}
protected abstract boolean hasInvalid(boolean isAdd);
/**
* 刷新 NameableCreator
*
* @param creators 生成器
*/
public void refreshNameableCreator(NameableCreator[] creators) {
this.creators = creators;
shorts = this.createShortcuts();
toolbarDef.clearShortCuts();
for (ShortCut4JControlPane sj : shorts) {
toolbarDef.addShortCut(sj.getShortCut());
}
toolbarDef.updateToolBar(toolBar);
toolBar.validate();
toolBar.repaint();
this.repaint();
}
// 点击"编辑"按钮,弹出面板
protected class PopupEditPane extends JPopupMenu {
private JComponent contentPane;
private static final int WIDTH = 460;
private static final int HEIGHT = 500;
// private PopupToolPane popupToolPane;
// private int fixedHeight;
PopupEditPane(JComponent pane) {
contentPane = pane;
this.setLayout(new BorderLayout());
this.add(contentPane, BorderLayout.CENTER);
this.setOpaque(false);
contentPane.setPreferredSize(new Dimension(WIDTH, HEIGHT));
// fixedHeight = getPreferredSize().height - contentPane.getPreferredSize().height;
// updateSize();
}
// private void updateSize() {
// int newHeight = fixedHeight + contentPane.getPreferredSize().height;
// this.setPreferredSize(new Dimension(CONTAINER_WIDTH - TAB_WIDTH, newHeight));
// }
public JComponent getContentPane() {
return contentPane;
}
public void replaceContentPane(JComponent pane) {
// remove(pane);
this.remove(this.contentPane);
this.add(this.contentPane = pane);
// updateSize();
refreshContainer();
}
private void refreshContainer() {
validate();
repaint();
revalidate();
}
}
}

974
designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java

@ -0,0 +1,974 @@
package com.fr.design.gui.controlpane;
import com.fr.base.BaseUtils;
import com.fr.base.FRContext;
import com.fr.design.actions.UpdateAction;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.data.tabledata.tabledatapane.GlobalMultiTDTableDataPane;
import com.fr.design.data.tabledata.tabledatapane.GlobalTreeTableDataPane;
import com.fr.design.data.tabledata.tabledatapane.MultiTDTableDataPane;
import com.fr.design.data.tabledata.tabledatapane.TreeTableDataPane;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilist.UINameEdList;
import com.fr.design.gui.ilist.ListModelElement;
import com.fr.design.gui.ilist.ModNameActionListener;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.menu.LineSeparator;
import com.fr.design.menu.MenuDef;
import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.ComparatorUtils;
import com.fr.general.Inter;
import com.fr.stable.ArrayUtils;
import com.fr.stable.Nameable;
import com.fr.stable.core.PropertyChangeAdapter;
import sun.swing.DefaultLookup;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.Comparator;
/**
* Created by plough on 2017/7/19.
*/
public abstract class UIListControlPane extends UIControlPane {
public static final String LIST_NAME = "UIControl_List";
private static final int EDIT_RANGE = 25; // 编辑按钮的x坐标范围
protected UINameEdList nameableList;
protected int editingIndex;
protected String selectedName;
private boolean isNameRepeated = false;
public UIListControlPane() {
this.initComponentPane();
}
@Override
protected JPanel createControlUpdatePane() {
return new JControlUpdatePane();
}
/**
* 生成添加按钮的NameableCreator
*
* @return 按钮的NameableCreator
*/
@Override
public abstract NameableCreator[] createNameableCreators();
@Override
protected void initLeftPane(JPanel leftPane) {
nameableList = createJNameList();
nameableList.setName(LIST_NAME);
leftPane.add(new UIScrollPane(nameableList), BorderLayout.CENTER);
nameableList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
nameableList.addMouseListener(listMouseListener);
nameableList.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent evt) {
// richie:避免多次update和populate大大降低效率
if (!evt.getValueIsAdjusting()) {
// shoc 切换的时候加检验
if (hasInvalid(false)) {
return;
}
((JControlUpdatePane) UIListControlPane.this.controlUpdatePane).update();
((JControlUpdatePane) UIListControlPane.this.controlUpdatePane).populate();
UIListControlPane.this.checkButtonEnabled();
}
}
});
}
public UINameEdList createJNameList() {
UINameEdList nameEdList = new UINameEdList(new DefaultListModel()) {
@Override
protected void doAfterLostFocus() {
UIListControlPane.this.updateControlUpdatePane();
}
};
nameEdList.setCellRenderer(new UINameableListCellRenderer(this));
return nameEdList;
}
public void updateControlUpdatePane() {
((JControlUpdatePane) controlUpdatePane).update();
}
protected void doWhenPopulate(BasicBeanPane beanPane) {
}
protected void doBeforePopulate(ListModelElement el, Object obj) {
}
@Override
protected ShortCut4JControlPane addItemShortCut() {
ShortCut addItemShortCut;
NameableCreator[] creators = creators();
if (creators.length == 1) {
addItemShortCut = new AddItemUpdateAction(creators);
} else {
addItemShortCut = new AddItemMenuDef(creators);
}
return new AbsoluteEnableShortCut(addItemShortCut);
}
@Override
protected ShortCut4JControlPane removeItemShortCut() {
return new NormalEnableShortCut(new RemoveItemAction());
}
@Override
protected ShortCut4JControlPane copyItemShortCut() {
return new NormalEnableShortCut(new CopyItemAction());
}
@Override
protected ShortCut4JControlPane moveUpItemShortCut() {
return new NormalEnableShortCut(new MoveUpItemAction());
}
@Override
protected ShortCut4JControlPane moveDownItemShortCut() {
return new NormalEnableShortCut(new MoveDownItemAction());
}
@Override
protected ShortCut4JControlPane sortItemShortCut() {
return new NormalEnableShortCut(new SortItemAction());
}
public void setNameListEditable(boolean editable) {
this.nameableList.setEditable(editable);
}
@Override
public Nameable[] update() {
java.util.List<Nameable> res = new java.util.ArrayList<Nameable>();
((JControlUpdatePane) this.controlUpdatePane).update();
DefaultListModel listModel = (DefaultListModel) this.nameableList.getModel();
for (int i = 0, len = listModel.getSize(); i < len; i++) {
res.add(((ListModelElement) listModel.getElementAt(i)).wrapper);
}
return res.toArray(new Nameable[res.size()]);
}
@Override
public void populate(Nameable[] nameableArray) {
DefaultListModel listModel = (DefaultListModel) this.nameableList.getModel();
listModel.removeAllElements();
if (ArrayUtils.isEmpty(nameableArray)) {
return;
}
for (Nameable aNameableArray : nameableArray) {
listModel.addElement(new ListModelElement(aNameableArray));
}
if (listModel.size() > 0) {
this.nameableList.setSelectedIndex(0);
}
this.checkButtonEnabled();
}
/**
* 添加名字改变时的listener
*
* @param l 名字改变时的监听
*/
public void addModNameActionListener(ModNameActionListener l) {
this.nameableList.addModNameActionListener(l);
}
/**
* 添加Editinglistener
*
* @param l 监听
*/
public void addEditingListner(PropertyChangeAdapter l) {
this.nameableList.addEditingListner(l);
}
/*
* 刷新当前的选中的UpdatePane
*/
protected void populateSelectedValue() {
((JControlUpdatePane) UIListControlPane.this.controlUpdatePane).populate();
}
/**
* 根据name,选中UINameEdList中的item
*/
public void setSelectedName(String name) {
DefaultListModel listModel = (DefaultListModel) this.nameableList.getModel();
for (int i = 0, len = listModel.getSize(); i < len; i++) {
Nameable item = ((ListModelElement) listModel.getElementAt(i)).wrapper;
if (ComparatorUtils.equals(name, item.getName())) {
this.nameableList.setSelectedIndex(i);
break;
}
}
}
public String getEditingName() {
return this.nameableList.getEditingName();
}
public Object getEditingType() {
return this.nameableList.getAllTypes()[editingIndex];
}
public void setWarnigText(int index) {
this.nameableList.setWarnigText(index);
}
/**
* 获取选中的名字
*/
public String getSelectedName() {
ListModelElement el = (ListModelElement) this.nameableList.getSelectedValue();
return el == null ? null : el.wrapper.getName();
}
protected boolean isNameRepeted(java.util.List[] list, String name) {
for (int i = 0; i < list.length; i++) {
if (list[i].contains(name)) {
isNameRepeated = true;
return true;
}
}
isNameRepeated = false;
return false;
}
/**
* 名字是否重复
*
* @return 重复则返回true
*/
public boolean isNameRepeated() {
return isNameRepeated;
}
/**
* 添加 Nameable
*
* @param nameable 添加的Nameable
* @param index 序号
*/
public void addNameable(Nameable nameable, int index) {
UINameEdList nameEdList = UIListControlPane.this.nameableList;
DefaultListModel model = (DefaultListModel) nameEdList.getModel();
ListModelElement el = new ListModelElement(nameable);
model.add(index, el);
nameableList.setSelectedIndex(index);
nameableList.ensureIndexIsVisible(index);
nameEdList.repaint();
}
/**
* 是否重命名
*
* @return 是则true
*/
public boolean isContainsRename() {
String rename = Inter.getLocText("FR-Please_Rename") + "!";
String[] names = this.nameableList.getAllNames();
for (int i = names.length - 1; i >= 0; i--) {
if (ComparatorUtils.equals(names[i], rename)) {
return true;
}
}
return false;
}
protected DefaultListModel getModel() {
return (DefaultListModel) UIListControlPane.this.nameableList.getModel();
}
private String createUnrepeatedCopyName(String suffix) {
DefaultListModel model = this.getModel();
String[] names = new String[model.getSize()];
for (int i = 0; i < model.size(); i++) {
names[i] = ((ListModelElement) model.get(i)).wrapper.getName();
}
String lastName = "CopyOf" + suffix;
while (ArrayUtils.contains(names, lastName)) {
lastName = "CopyOf" + lastName;
}
return lastName;
}
/**
* 生成不重复的名字
*
* @param prefix 名字前缀
* @return 名字
*/
@Override
public String createUnrepeatedName(String prefix) {
DefaultListModel model = this.getModel();
Nameable[] all = new Nameable[model.getSize()];
for (int i = 0; i < model.size(); i++) {
all[i] = ((ListModelElement) model.get(i)).wrapper;
}
// richer:生成的名字从1开始. kunsnat: 添加属性从0开始.
int count = all.length + 1;
while (true) {
String name_test = prefix + count;
boolean repeated = false;
for (int i = 0, len = model.size(); i < len; i++) {
Nameable nameable = all[i];
if (ComparatorUtils.equals(nameable.getName(), name_test)) {
repeated = true;
break;
}
}
if (!repeated) {
return name_test;
}
count++;
}
}
private void popupEditPane() {
if (editingIndex < 0) {
return;
}
GUICoreUtils.showPopupMenu(popupEditPane, this,
- popupEditPane.getPreferredSize().width, editingIndex * EDIT_RANGE);
}
/**
* 增加项的UpdateAction
*/
protected class AddItemUpdateAction extends UpdateAction {
final NameableCreator creator;
public AddItemUpdateAction(NameableCreator[] creators) {
this.creator = creators[0];
this.setName(Inter.getLocText("FR-Action_Add"));
this.setMnemonic('A');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/add.png"));
}
@Override
public void actionPerformed(ActionEvent e) {
Nameable nameable = creator.createNameable(UIListControlPane.this);
UIListControlPane.this.addNameable(nameable, getModel().getSize());
}
}
/*
* 增加项的MenuDef
*/
protected class AddItemMenuDef extends MenuDef {
public AddItemMenuDef(NameableCreator[] creators) {
this.setName(Inter.getLocText("FR-Action_Add"));
this.setMnemonic('A');
this.setIconPath("/com/fr/design/images/control/addPopup.png");
wrapActionListener(creators);
}
/**
* 生成UIButton
* @return 菜单按钮
*/
public UIButton createUIButton() {
createdButton = super.createUIButton();
// 此按钮单独抽出,不应使用工具栏外观
if (!createdButton.isOpaque()) {
createdButton.setOpaque(true);
createdButton.setNormalPainted(true);
createdButton.setBorderPaintedOnlyWhenPressed(false);
}
return createdButton;
}
private void wrapActionListener(NameableCreator[] creators) {
for (final NameableCreator creator : creators) {
if (!whetherAdd(creator.menuName())) {
continue;
}
boolean isTrue = ComparatorUtils.equals(creator.menuName(), Inter.getLocText("Datasource-Stored_Procedure")) ||
ComparatorUtils.equals(creator.menuName(), Inter.getLocText("DS-Relation_TableData")) || ComparatorUtils.equals(creator.menuName(), Inter.getLocText("DS-Multi_Dimensional_Database"));
if (isTrue) {
this.addShortCut(new LineSeparator());
}
this.addShortCut(new UpdateAction() {
{
this.setName(creator.menuName());
Icon icon = creator.menuIcon();
if (icon != null) {
this.setSmallIcon(icon);
}
}
@Override
public void actionPerformed(ActionEvent e) {
if (hasInvalid(true)) {
return;
}
Nameable nameable = creator.createNameable(UIListControlPane.this);
UIListControlPane.this.addNameable(nameable, getModel().getSize());
}
});
}
}
private boolean whetherAdd(String itemName) {
JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if (jTemplate == null) {
return false;
}
//先屏蔽掉这个,之后还有别的
String[] names = {Inter.getLocText("FR-Hyperlink_Chart_Float")};
for (String name : names) {
if (!jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName, name)) {
return false;
}
}
String formName = Inter.getLocText("Hyperlink-Form_link");
return !(jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName, formName));
}
}
/*
* 移除item
*/
private class RemoveItemAction extends UpdateAction {
public RemoveItemAction() {
this.setName(Inter.getLocText("FR-Action_Remove"));
this.setMnemonic('R');
this.setSmallIcon(BaseUtils
.readIcon("/com/fr/base/images/cell/control/remove.png"));
}
@Override
public void actionPerformed(ActionEvent evt) {
try {
UIListControlPane.this.nameableList.getCellEditor()
.stopCellEditing();
} catch (Exception ignored) {
}
// bug:在选中一个NameObject并删除,会遗留下Name.
doBeforeRemove();
if (GUICoreUtils.removeJListSelectedNodes(SwingUtilities
.getWindowAncestor(UIListControlPane.this), nameableList)) {
checkButtonEnabled();
doAfterRemove();
}
}
}
/*
* CopyItem
*/
private class CopyItemAction extends UpdateAction {
public CopyItemAction() {
this.setName(Inter.getLocText("FR-Action_Copy"));
this.setMnemonic('C');
this.setSmallIcon(BaseUtils
.readIcon("/com/fr/base/images/cell/control/copy.png"));
}
@Override
public void actionPerformed(ActionEvent evt) {
// p:选中的值.
ListModelElement selectedValue = (ListModelElement) nameableList.getSelectedValue();
if (selectedValue == null) {
return;
}
((JControlUpdatePane) controlUpdatePane).update();
Nameable selectedNameable = selectedValue.wrapper;
// p: 用反射机制实现
try {
Nameable newNameable = (Nameable) BaseUtils.cloneObject(selectedNameable);
newNameable.setName(createUnrepeatedCopyName(selectedNameable.getName()));
UIListControlPane.this.addNameable(newNameable, nameableList.getSelectedIndex() + 1);
} catch (Exception e) {
FRContext.getLogger().error(e.getMessage(), e);
}
}
}
/*
* 上移Item
*/
private class MoveUpItemAction extends UpdateAction {
public MoveUpItemAction() {
this.setName(Inter.getLocText("Utils-Move_Up"));
this.setMnemonic('U');
this.setSmallIcon(BaseUtils
.readIcon("/com/fr/design/images/control/up.png"));
}
@Override
public void actionPerformed(ActionEvent evt) {
int selectedIndex = nameableList.getSelectedIndex();
if (selectedIndex == -1) {
return;
}
// 上移
if (selectedIndex > 0) {
DefaultListModel listModel = (DefaultListModel) nameableList
.getModel();
Object selecteObj1 = listModel.get(selectedIndex - 1);
listModel.set(selectedIndex - 1, listModel.get(selectedIndex));
listModel.set(selectedIndex, selecteObj1);
nameableList.setSelectedIndex(selectedIndex - 1);
nameableList.ensureIndexIsVisible(selectedIndex - 1);
}
}
}
/*
* 下移Item
*/
private class MoveDownItemAction extends UpdateAction {
public MoveDownItemAction() {
this.setName(Inter.getLocText("Utils-Move_Down"));
this.setMnemonic('D');
this.setSmallIcon(BaseUtils
.readIcon("/com/fr/design/images/control/down.png"));
}
@Override
public void actionPerformed(ActionEvent evt) {
int selectedIndex = nameableList.getSelectedIndex();
if (selectedIndex == -1) {
return;
}
if (selectedIndex < nameableList.getModel().getSize() - 1) {
DefaultListModel listModel = (DefaultListModel) nameableList
.getModel();
Object selecteObj1 = listModel.get(selectedIndex + 1);
listModel.set(selectedIndex + 1, listModel.get(selectedIndex));
listModel.set(selectedIndex, selecteObj1);
nameableList.setSelectedIndex(selectedIndex + 1);
nameableList.ensureIndexIsVisible(selectedIndex + 1);
}
}
}
private class SortItemAction extends UpdateAction {
private boolean isAtoZ = false;
public SortItemAction() {
this.setName(Inter.getLocText("FR-Action_Sort"));
this.setMnemonic('S');
this.setSmallIcon(BaseUtils
.readIcon("/com/fr/design/images/control/sortAsc.png"));
}
@Override
public void actionPerformed(ActionEvent evt) {
// p:选中的值.
Object selectedValue = nameableList.getSelectedValue();
DefaultListModel listModel = (DefaultListModel) nameableList
.getModel();
Nameable[] nameableArray = new Nameable[listModel.getSize()];
if (nameableArray.length <= 0) {
return;
}
for (int i = 0; i < listModel.getSize(); i++) {
nameableArray[i] = ((ListModelElement) listModel.getElementAt(i)).wrapper;
}
// p:排序.
if (isAtoZ) {
Comparator<Nameable> nameableComparator = new Comparator<Nameable>() {
@Override
public int compare(Nameable o1, Nameable o2) {
return -ComparatorUtils.compare(o1.getName(), o2
.getName());
}
};
isAtoZ = !isAtoZ;
Arrays.sort(nameableArray, nameableComparator);
} else {
Comparator<Nameable> nameableComparator = new Comparator<Nameable>() {
@Override
public int compare(Nameable o1, Nameable o2) {
return ComparatorUtils.compare(o1.getName(), o2
.getName());
}
};
isAtoZ = !isAtoZ;
Arrays.sort(nameableArray, nameableComparator);
}
for (int i = 0; i < nameableArray.length; i++) {
listModel.set(i, new ListModelElement(nameableArray[i]));
}
// p:需要选中以前的那个值.
if (selectedValue != null) {
nameableList.setSelectedValue(selectedValue, true);
}
checkButtonEnabled();
// p:需要repaint.
nameableList.repaint();
}
}
/*
* UINameEdList的鼠标事件
*/
private MouseListener listMouseListener = new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent evt) {
nameableList.stopEditing();
if (evt.getClickCount() >= 2
&& SwingUtilities.isLeftMouseButton(evt) && evt.getX() > EDIT_RANGE) {
editingIndex = nameableList.getSelectedIndex();
selectedName = nameableList.getNameAt(editingIndex);
nameableList.editItemAt(nameableList.getSelectedIndex());
} else if (SwingUtilities.isLeftMouseButton(evt) && evt.getX() <= EDIT_RANGE) {
editingIndex = nameableList.getSelectedIndex();
popupEditPane();
}
// peter:处理右键的弹出菜单
if (!SwingUtilities.isRightMouseButton(evt)) {
return;
}
// peter: 注意,在checkButtonEnabled()方法里面,设置了所有的Action的Enabled.
checkButtonEnabled();
// p:右键菜单.
JPopupMenu popupMenu = new JPopupMenu();
for (ShortCut4JControlPane sj : getShorts()) {
sj.getShortCut().intoJPopupMenu(popupMenu);
}
// peter: 只有弹出菜单有子菜单的时候,才需要弹出来.
GUICoreUtils.showPopupMenu(popupMenu, nameableList, evt.getX() - 1,
evt.getY() - 1);
}
@Override
public void mouseMoved(MouseEvent e) {
}
};
/**
* 检查按钮可用状态 Check button enabled.
*/
@Override
public void checkButtonEnabled() {
int selectedIndex = nameableList.getSelectedIndex();
if (selectedIndex == -1) {
this.cardLayout.show(cardPane, "SELECT");
} else {
this.cardLayout.show(cardPane, "EDIT");
}
for (ShortCut4JControlPane sj : getShorts()) {
sj.checkEnable();
}
}
public class AbsoluteEnableShortCut extends ShortCut4JControlPane {
public AbsoluteEnableShortCut(ShortCut shortCut) {
this.shortCut = shortCut;
}
/**
* 检查是否可用
*/
@Override
public void checkEnable() {
this.shortCut.setEnabled(true);
}
}
public class NormalEnableShortCut extends ShortCut4JControlPane {
public NormalEnableShortCut(ShortCut shortCut) {
this.shortCut = shortCut;
}
/**
* 检查是否可用
*/
@Override
public void checkEnable() {
this.shortCut.setEnabled(getModel()
.getSize() > 0
&& UIListControlPane.this.nameableList.getSelectedIndex() != -1);
}
}
public class SortEnableShortCut extends ShortCut4JControlPane {
public SortEnableShortCut(ShortCut shortCut) {
this.shortCut = shortCut;
}
/**
* 检查是否可用
*/
@Override
public void checkEnable() {
this.shortCut.setEnabled(getModel().getSize() > 1);
}
}
public class MoveUpEnableShortCut extends ShortCut4JControlPane {
public MoveUpEnableShortCut(ShortCut shortCut) {
this.shortCut = shortCut;
}
/**
* 检查是否可用
*/
@Override
public void checkEnable() {
this.shortCut.setEnabled(getModel().getSize() > 1
&& UIListControlPane.this.nameableList.getSelectedIndex() > 0);
}
}
public class MoveDownEnableShortCut extends ShortCut4JControlPane {
public MoveDownEnableShortCut(ShortCut shortCut) {
this.shortCut = shortCut;
}
/**
* 检查是否可用
*/
@Override
public void checkEnable() {
this.shortCut.setEnabled(getModel().getSize() > 1
&& UIListControlPane.this.nameableList.getSelectedIndex() < UIListControlPane.this.nameableList.getModel().getSize() - 1);
}
}
private class JControlUpdatePane extends JPanel {
private CardLayout card;
private JPanel cardPane;
private BasicBeanPane[] updatePanes;
private ListModelElement elEditing;
public JControlUpdatePane() {
initUpdatePane();
}
private void initUpdatePane() {
NameableCreator[] creators = creators();
if (creators == null) {
return;
}
card = new CardLayout();
cardPane = FRGUIPaneFactory.createCardLayout_S_Pane();
cardPane.setLayout(card);
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.add(cardPane);
int len = creators.length;
updatePanes = new BasicBeanPane[len];
}
public void populate() {
ListModelElement el = (ListModelElement) UIListControlPane.this.nameableList.getSelectedValue();
if (el == null) {
return;
}
elEditing = el;
NameableCreator[] creators = creators();
for (int i = 0, len = updatePanes.length; i < len; i++) {
Object ob2Populate = creators[i].acceptObject2Populate(el.wrapper);
if (ob2Populate != null) {
if (updatePanes[i] == null) {
if (isMulti(creators[i].getUpdatePane()) || isTree(creators[i].getUpdatePane())) {
updatePanes[i] = createPaneByCreators(creators[i], el.wrapper.getName());
} else {
updatePanes[i] = createPaneByCreators(creators[i]);
}
cardPane.add(updatePanes[i], String.valueOf(i));
}
card.show(cardPane, String.valueOf(i));
doBeforePopulate(el, ob2Populate);
updatePanes[i].populateBean(ob2Populate);
doWhenPopulate(updatePanes[i]);
break;
}
}
}
public boolean isMulti(Class _class) {
return ComparatorUtils.equals(_class, GlobalMultiTDTableDataPane.class) || ComparatorUtils.equals(_class, MultiTDTableDataPane.class);
}
public boolean isTree(Class _class) {
return ComparatorUtils.equals(_class, GlobalTreeTableDataPane.class) || ComparatorUtils.equals(_class, TreeTableDataPane.class);
}
public void update() {
NameableCreator[] creators = creators();
for (int i = 0; i < updatePanes.length; i++) {
BasicBeanPane pane = updatePanes[i];
if (pane != null && pane.isVisible()) {
Object bean = pane.updateBean();
if (i < creators.length) {
creators[i].saveUpdatedBean(elEditing, bean);
}
}
}
}
public void checkValid() throws Exception {
if (updatePanes != null) {
for (int i = 0; i < updatePanes.length; i++) {
if (updatePanes[i] != null) {
updatePanes[i].checkValid();
}
}
}
}
}
protected BasicBeanPane createPaneByCreators(NameableCreator creator) {
try {
return creator.getUpdatePane().newInstance();
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
protected BasicBeanPane createPaneByCreators(NameableCreator creator, String string) {
Constructor constructor = null;
try {
constructor = creator.getUpdatePane().getDeclaredConstructor(new Class[]{String.class});
constructor.setAccessible(true);
return (BasicBeanPane) constructor.newInstance(string);
} catch (NoSuchMethodException e) {
throw new RuntimeException(e);
} catch (InstantiationException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
} catch (InvocationTargetException e) {
throw new RuntimeException(e);
}
}
// 选项添加个数有限制等情况下 要求能控制快捷按钮的状态
protected void setToolbarDefEnable(int shortCutIndex, int itemIndex, boolean enabled) {
ToolBarDef toolbarDef = getToolbarDef();
if (toolbarDef.getShortCutCount() > shortCutIndex) {
ShortCut sc = toolbarDef.getShortCut(shortCutIndex);
if (sc instanceof AddItemMenuDef) {
AddItemMenuDef am = (AddItemMenuDef) sc;
if (am.getShortCutCount() > itemIndex) {
am.getShortCut(itemIndex).setEnabled(enabled);
}
}
}
}
/**
* 检查是否符合规范
*
* @throws Exception
*/
@Override
public void checkValid() throws Exception {
((JControlUpdatePane) this.controlUpdatePane).checkValid();
}
private int getInValidIndex() {
BasicBeanPane[] p = ((JControlUpdatePane) controlUpdatePane).updatePanes;
if (p != null) {
for (int i = 0; i < p.length; i++) {
if (p[i] != null) {
try {
p[i].checkValid();
} catch (Exception e) {
return i;
}
}
}
}
return -1;
}
@Override
protected boolean hasInvalid(boolean isAdd) {
int idx = UIListControlPane.this.getInValidIndex();
if (isAdd || nameableList.getSelectedIndex() != idx) {
try {
checkValid();
} catch (Exception exp) {
JOptionPane.showMessageDialog(UIListControlPane.this, exp.getMessage());
nameableList.setSelectedIndex(idx);
return true;
}
}
return false;
}
/**
* 设置选中项
*
* @param index 选中项的序列号
*/
public void setSelectedIndex(int index) {
nameableList.setSelectedIndex(index);
}
}

162
designer_base/src/com/fr/design/gui/controlpane/UINameableListCellRenderer.java

@ -0,0 +1,162 @@
package com.fr.design.gui.controlpane;
import com.fr.base.BaseUtils;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ilist.ListModelElement;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.Nameable;
import sun.swing.DefaultLookup;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* Nameable的ListCellRenerer
* Created by plough on 2017/7/21.
*/
public class UINameableListCellRenderer extends
JPanel implements ListCellRenderer {
private static final Border SAFE_NO_FOCUS_BORDER = new EmptyBorder(1, 1, 1, 1);
private static final Border DEFAULT_NO_FOCUS_BORDER = new EmptyBorder(1, 1, 1, 1);
private static final Color BORDER_COLOR = new Color(201, 198, 184);
protected static Border noFocusBorder = DEFAULT_NO_FOCUS_BORDER;
private static final int BUTTON_WIDTH = 25;
private UILabel editButton; // "编辑按钮",实际上是一个 UILabel,由列表项(UIListControlPane)统一处理点击事件
private UILabel label;
private UIListControlPane listControlPane;
public UINameableListCellRenderer(UIListControlPane listControlPane) {
super();
this.listControlPane = listControlPane;
initComponents();
setOpaque(true);
setBorder(getNoFocusBorder());
setName("List.cellRenderer");
}
private void initComponents() {
editButton = new UILabel() {
public Dimension getPreferredSize() {
return new Dimension(BUTTON_WIDTH, BUTTON_WIDTH);
}
};
// editButton.set4LargeToolbarButton();
editButton.setIcon(BaseUtils.readIcon("/com/fr/base/images/cell/control/add.png"));
editButton.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, BORDER_COLOR));
editButton.setHorizontalAlignment(SwingConstants.CENTER);
// editButton.addActionListener(new ActionListener() {
// @Override
// public void actionPerformed(ActionEvent e) {
// popupEditPane();
// }
// });
label = new UILabel();
label.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
// label.setEditable(false);
this.setLayout(new BorderLayout());
this.add(editButton, BorderLayout.WEST);
this.add(label, BorderLayout.CENTER);
}
private Border getNoFocusBorder() {
// return BorderFactory.createLineBorder(new Color(201, 198, 184));
return BorderFactory.createMatteBorder(0, 0, 1, 0, BORDER_COLOR);
// Border border = DefaultLookup.getBorder(this, ui, "List.cellNoFocusBorder");
// if (System.getSecurityManager() != null) {
// if (border != null) return border;
// return SAFE_NO_FOCUS_BORDER;
// } else {
// if (border != null &&
// (noFocusBorder == null ||
// noFocusBorder == DEFAULT_NO_FOCUS_BORDER)) {
// return border;
// }
// return noFocusBorder;
// }
}
private void setText(String t) {
label.setText(t);
}
@Override
public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected, boolean cellHasFocus) {
setComponentOrientation(list.getComponentOrientation());
Color bg = null;
Color fg = null;
JList.DropLocation dropLocation = list.getDropLocation();
if (dropLocation != null
&& !dropLocation.isInsert()
&& dropLocation.getIndex() == index) {
bg = DefaultLookup.getColor(this, ui, "List.dropCellBackground");
fg = DefaultLookup.getColor(this, ui, "List.dropCellForeground");
isSelected = true;
}
if (isSelected) {
setBackground(bg == null ? list.getSelectionBackground() : bg);
setForeground(fg == null ? list.getSelectionForeground() : fg);
}
else {
setBackground(list.getBackground());
setForeground(list.getForeground());
}
// if (value instanceof Icon) {
// setIcon((Icon)value);
// setText("");
// }
// else {
// setIcon(null);
setText((value == null) ? "" : value.toString());
// }
setEnabled(list.isEnabled());
setFont(list.getFont());
Border border = null;
if (cellHasFocus) {
if (isSelected) {
border = DefaultLookup.getBorder(this, ui, "List.focusSelectedCellHighlightBorder");
}
if (border == null) {
border = DefaultLookup.getBorder(this, ui, "List.focusCellHighlightBorder");
}
} else {
border = getNoFocusBorder();
}
setBorder(border);
if (value instanceof ListModelElement) {
Nameable wrappee = ((ListModelElement) value).wrapper;
this.setText(((ListModelElement) value).wrapper.getName());
boolean iconSet = false;
for (NameableCreator creator : listControlPane.creators()) {
if (creator.menuIcon() != null && creator.acceptObject2Populate(wrappee) != null) {
// this.setIcon(creator.menuIcon());
this.setToolTipText(creator.createTooltip());
iconSet = true;
break;
}
}
// if (!iconSet) {
// this.setIcon(BaseUtils.readIcon("/com/fr/base/images/oem/cpt.png"));
// }
}
return this;
}
}

4
designer_base/src/com/fr/design/gui/frpane/HyperlinkGroupPane.java

@ -4,6 +4,7 @@ import com.fr.design.ExtraDesignClassManager;
import com.fr.design.fun.HyperlinkProvider;
import com.fr.design.gui.controlpane.JListControlPane;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.gui.controlpane.UIListControlPane;
import com.fr.design.module.DesignModuleFactory;
import com.fr.general.Inter;
import com.fr.general.NameObject;
@ -23,8 +24,7 @@ import java.util.Set;
* @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2013-6-25 上午11:17:57
*/
public class HyperlinkGroupPane extends JListControlPane {
public abstract class HyperlinkGroupPane extends UIListControlPane {
/**
* 生成添加按钮的NameableCreator
*

7
designer_base/src/com/fr/design/gui/icontainer/UIEastResizableContainer.java

@ -159,11 +159,12 @@ public class UIEastResizableContainer extends JPanel {
return;
}
topToolPane.setBounds(0, 0, containerWidth, topToolPaneHeight);//0,0,10,462
// topToolPane.setBounds(0, 0, containerWidth, topToolPaneHeight);//0,0,10,462
topToolPane.setBounds(0, 0, leftPaneWidth, topToolPaneHeight);//0,0,10,462
leftPane.setBounds(0, topToolPaneHeight, leftPaneWidth, getHeight() - topToolPaneHeight);
// parameterPane.setBounds(20, 0, 230, getParameterPaneHeight());//10,0,230,462
rightPane.setBounds(leftPaneWidth, topToolPaneHeight, containerWidth-leftPaneWidth, getHeight() - topToolPaneHeight);//20,0,230,0
rightPane.setBounds(leftPaneWidth, 0, containerWidth-leftPaneWidth, getHeight());//20,0,230,0
}
@Override
@ -303,7 +304,7 @@ public class UIEastResizableContainer extends JPanel {
}
}
// g.drawImage(button, 2, ARROW_MARGIN_VERTICAL, 5, toolPaneHeight, null);
g.drawImage(button, 20, 7, 5, 5, null);
g.drawImage(button, 18, 7, 5, 5, null);
}
}

398
designer_base/src/com/fr/design/gui/ilist/UINameEdList.java

@ -0,0 +1,398 @@
package com.fr.design.gui.ilist;
import com.fr.base.Utils;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.general.Inter;
import com.fr.general.NameObject;
import com.fr.stable.Nameable;
import com.fr.stable.StringUtils;
import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.*;
import javax.swing.event.CellEditorListener;
import javax.swing.event.ChangeEvent;
import java.awt.*;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Vector;
/**
* Created by plough on 2017/7/23.
*/
public class UINameEdList extends UIList implements CellEditorListener {
private static final int TEST_LIST_LENTH = 20;
private static final int BUTTON_WIDTH = 25;
private boolean editable = true;
// kunsnat: 是否强制ListName是数字 (int型)
private boolean isNameShouldNumber = false;
transient protected ListCellEditor cellEditor;
transient protected Component editorComp;
transient protected int editingIndex;
private PropertyChangeAdapter editingListner;
private java.util.List<ModNameActionListener> ll = new ArrayList<ModNameActionListener>();
public UINameEdList(ListModel dataModel) {
super(dataModel);
}
public UINameEdList(final Object[] listData) {
super(listData);
}
public UINameEdList(final Vector<?> listData) {
super(listData);
}
public UINameEdList() {
super();
}
/*
* Sets是否可编辑
*/
public void setEditable(boolean editable) {
this.editable = editable;
}
/**
* 是否可编辑
*
* @return 是则返回true
*/
public boolean isEditable() {
return this.editable;
}
public void setNameShouldNumber(boolean isNameShouldNumber) {
this.isNameShouldNumber = isNameShouldNumber;
}
/**
* 是否强制ListName是数字 (int型)
*
* @return 是则返回true
*/
public boolean isNameShouldNumber() {
return isNameShouldNumber;
}
/**
* 添加名字改变时的listener
*
* @param l 监听器
*/
public void addModNameActionListener(ModNameActionListener l) {
ll.add(l);
}
/**
* 编辑时的监听器
*
* @param l 监听器
*/
public void addEditingListner(PropertyChangeAdapter l) {
this.editingListner = l;
}
/**
* 移除某名字改变时的listener
*
* @param l 监听器
*/
public void removeModNameActionListener(ModNameActionListener l) {
ll.remove(l);
}
public ListCellEditor getCellEditor() {
if (cellEditor == null) {
UITextField editField = new UITextField();
if (editingListner != null) {
editField.addFocusListener(new FocusListener() {
@Override
public void focusLost(FocusEvent e) {
editingListner.propertyChange();
}
@Override
public void focusGained(FocusEvent e) {
// TODO Auto-generated method stub
}
});
}
cellEditor = new DefaultListCellEditor(editField) {
public boolean stopCellEditing() {
boolean isTrue = super.stopCellEditing();
stopEditing();
return isTrue;
}
};
cellEditor.addCellEditorListener(this);
}
return cellEditor;
}
protected void doAfterLostFocus() {
}
public void setCellEditor(ListCellEditor editor) {
this.cellEditor = editor;
}
/*
* 取得index节点的名字
*/
public String getNameAt(int index) {
Nameable nameable = ((ListModelElement) getModel().getElementAt(index)).wrapper;
if (nameable != null) {
return nameable.getName();
}
return null;
}
public Object getType(int index) {
Nameable nameable = ((ListModelElement) getModel().getElementAt(index)).wrapper;
if (nameable != null && nameable instanceof NameObject) {
return ((NameObject) nameable).getObject();
}
return null;
}
public void setWarnigText() {
setWarnigText(this.getSelectedIndex());
}
public void setWarnigText(int index) {
setNameAt(Inter.getLocText("Please_Rename") + "!", index);
this.repaint();
}
/*
* 设置index节点的名字
*/
// b:edit改变name的时候怎么办?
public void setNameAt(String name, int index) {
Nameable nameable = ((ListModelElement) getModel().getElementAt(index)).wrapper;
if (nameable != null) {
String oldName = nameable.getName();
if (isNameShouldNumber()) {
// kunsnat: 限制只能是数字(int型)
Number number = Utils.string2Number(name);
if (number == null) {
nameable.setName(oldName);
} else {
int newName = number.intValue();
nameable.setName(String.valueOf(newName));
}
} else {
nameable.setName(name);
}
for (int i = 0, len = ll.size(); i < len; i++) {
ll.get(i).nameModed(index, oldName, name);
}
}
}
/*
* 编辑第index个item
*/
private String oldName;
/**
* 编辑第index项
*
* @param index 序号
* @return 成功返回true
*/
public boolean editItemAt(int index) {
// 如果不可编辑,返回
if (!this.editable) {
return false;
}
if (cellEditor != null && !cellEditor.stopCellEditing()) {
return false;
}
if (index < 0 || index >= this.getModel().getSize()) {
return false;
}
ListCellEditor editor = getCellEditor();
Object value = editor.getCellEditorValue();
if (!StringUtils.isBlank(value.toString())) {
oldName = value.toString();
}
editorComp = prepareEditor(editor, index);
if (editorComp == null) {
return false;
}
Rectangle rect = this.getCellBounds(index, index);
// alex:所有的UINameEdList都有Icon,空出前面20 * 20的位置就是放的Icon
rect.setRect(createRect(rect, BUTTON_WIDTH));
editorComp.setBounds(rect);
add(editorComp);
editorComp.validate();
editorComp.requestFocus();
if (editorComp instanceof UITextField) {
((UITextField) editorComp).selectAll();
}
setEditingIndex(index);
return true;
}
public Rectangle createRect(Rectangle rect, int iconWidth) {
return new Rectangle(rect.x + iconWidth, rect.y, rect.width - iconWidth, rect.height);
}
public String getEditingName() {
return (String) getCellEditor().getCellEditorValue();
}
/*
* 根据ListCellEditor取得编辑器的Component
*/
private Component prepareEditor(ListCellEditor cellEditor, int index) {
String name = getNameAt(index);
boolean isSelected = this.isSelectedIndex(index);
Component comp = cellEditor.getListCellEditorComponent(this, name, isSelected, index);
return comp;
}
/*
* 记录正在编辑的index
*/
private void setEditingIndex(int idx) {
editingIndex = idx;
}
/**
* 编辑取消
*
* @param e 事件
*/
public void editingCanceled(ChangeEvent e) {
removeComp();
}
/**
* 编辑结束
*
* @param e 事件
*/
public void editingStopped(ChangeEvent e) {
doAfterLostFocus();
stopEditing();
}
/**
* 停止编辑事件
*/
public void stopEditing() {
ListCellEditor editor = getCellEditor();
if (editor != null && editorComp != null) {
Object value = editor.getCellEditorValue();
String name = StringUtils.isBlank(value.toString()) ? oldName : value.toString();
setNameAt(name, editingIndex);
removeComp();
}
}
public String[] getAllNames() {
int length = this.getModel().getSize();
String[] names = new String[length];
for (int i = 0; i < length; i++) {
names[i] = getNameAt(i);
}
return names;
}
public Object[] getAllTypes() {
int length = this.getModel().getSize();
Object[] types = new Object[length];
for (int i = 0; i < length; i++) {
types[i] = getType(i);
}
return types;
}
/*
* 移除编辑器的Component
*/
private void removeComp() {
if (editorComp != null) {
remove(editorComp);
}
Rectangle cellRect = this.getCellBounds(editingIndex, editingIndex);
setEditingIndex(-1);
editorComp = null;
repaint(cellRect);
}
/**
* 主函数
*
* @param args 参数
*/
public static void main(String... args) {
JFrame f = new JFrame();
JPanel c = (JPanel) f.getContentPane();
c.setLayout(new BorderLayout());
ListModelElement[] data = new ListModelElement[TEST_LIST_LENTH];
for (int i = 0; i < TEST_LIST_LENTH; i++) {
data[i] = new ListModelElement(new NameObject(i + 1 + "", i));
}
final UINameEdList list = new UINameEdList(data);
list.setEditable(true);
list.addMouseListener(new MouseAdapter() {
public void mouseReleased(MouseEvent evt) {
list.stopEditing();
if (evt.getClickCount() >= 2
&& SwingUtilities.isLeftMouseButton(evt)) {
list.editItemAt(list.getSelectedIndex());
}
}
})
;
list.setCellEditor(new DefaultListCellEditor(new UITextField()));
list.setCellRenderer(new NameableListCellRenderer());
c.add(list, BorderLayout.CENTER);
f.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
f.setSize(400, 600);
f.setVisible(true);
}
private static class NameableListCellRenderer extends DefaultListCellRenderer {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected,
boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof Nameable) {
Nameable wrappee = (Nameable) value;
this.setText(wrappee.getName());
}
return this;
}
}
}

12
designer_base/src/com/fr/design/mainframe/EastRegionContainerPane.java

@ -106,7 +106,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
// 超级链接
PropertyItem hyperlink = new PropertyItem(KEY_HYPERLINK, Inter.getLocText("FR-Designer_Hyperlink"),
"/com/fr/design/images/buttonicon/add.png", new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_PARA, PropertyMode.REPORT_FLOAT, PropertyMode.POLY, PropertyMode.POLY_CHART},
new PropertyMode[]{PropertyMode.REPORT, PropertyMode.FORM_REPORT, PropertyMode.POLY_REPORT});
new PropertyMode[]{PropertyMode.REPORT, PropertyMode.REPORT_FLOAT, PropertyMode.FORM_REPORT, PropertyMode.POLY_REPORT});
// 组件库
PropertyItem widgetLib = new PropertyItem(KEY_WIDGET_LIB, Inter.getLocText("FR-Designer_Widget_Library"),
"/com/fr/design/images/buttonicon/add.png", new PropertyMode[]{PropertyMode.FORM},
@ -175,7 +175,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
}
// leftPane.setLayout(new BoxLayout(leftPane, BoxLayout.Y_AXIS));
leftPane.setBackground(Color.yellow);
leftPane.setBackground(new Color(210, 210, 210));
replaceLeftPane(leftPane);
}
@ -267,6 +267,14 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
return propertyItemMap.get(KEY_WIDGET_SETTINGS).getContentPane();
}
public void replaceHyperlinkPane(JComponent pane) {
propertyItemMap.get(KEY_HYPERLINK).replaceContentPane(pane);
}
public JComponent getHyperlinkPane() {
return propertyItemMap.get(KEY_HYPERLINK).getContentPane();
}
public void replaceWidgetLibPane(JComponent pane) {
propertyItemMap.get(KEY_WIDGET_LIB).replaceContentPane(pane);
}

370
designer_base/src/com/fr/design/mainframe/JFormSliderPane.java

@ -0,0 +1,370 @@
package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.islider.UISlider;
import com.fr.design.gui.ispinner.UIBasicSpinner;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.Inter;
import javax.swing.*;
import javax.swing.border.MatteBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.math.BigDecimal;
/**
* Created by MoMeak on 2017/7/13.
*/
public class JFormSliderPane extends JPanel {
private static final double ONEPOINTEIGHT = 1.8;
private static final int SIX = 6;
private static final int TEN = 10;
private static final int ONE_EIGHT = 18;
private static final int FONT_SIZE = 14;
private static final int SPINNER_WIDTH = 45;
private static final int SPINNER_HEIGHT = 20;
private static final int HALF_HUNDRED = 50;
private static final int HUNDRED = 100;
private static final int TWO_HUNDRED = 200;
private static final int THREE_HUNDRED = 300;
private static final int FOUR_HUNDRED = 400;
private static final int DIALOG_WIDTH = 150;
private static final int DIALOG_HEIGHT = 240;
private static final int SHOWVALBUTTON_WIDTH = 70;
private static final int SHOWVALBUTTON_HEIGHTH = 25;
public int showValue = 100;
public double resolutionTimes = 1.0;
private static JFormSliderPane THIS;
private UITextField showVal;
private JSpinner showValSpinner;
private UISlider slider;
private int times;
private int sliderValue;
private UIButton downButton;
private UIButton upButton;
private UIButton showValButton;
private UIRadioButton twoHundredButton;
private UIRadioButton oneHundredButton;
private UIRadioButton SevenFiveButton;
private UIRadioButton fiveTenButton;
private UIRadioButton twoFiveButton;
private UIRadioButton selfAdaptButton;
private UIRadioButton customButton;
//拖动条处理和button、直接输入不一样
private boolean isButtonOrIsTxt = true;
private FormPopupPane dialog;
private int upButtonX;
private JPanel dialogContentPanel;
public JFormSliderPane() {
this.setLayout(new BorderLayout());
slider = new UISlider(0, HUNDRED, HALF_HUNDRED);
slider.setUI(new JSliderPaneUI(slider));
slider.addChangeListener(listener);
showValSpinner = new UIBasicSpinner(new SpinnerNumberModel(HUNDRED, TEN, FOUR_HUNDRED, 1));
showValSpinner.setEnabled(true);
showValSpinner.addChangeListener(showValSpinnerChangeListener);
showValSpinner.setPreferredSize(new Dimension(SPINNER_WIDTH, SPINNER_HEIGHT));
//MoMeak:控制只能输入10-400,但是用起来感觉不舒服,先注释掉吧
// JSpinner.NumberEditor editor = new JSpinner.NumberEditor(showValSpinner, "0");
// showValSpinner.setEditor(editor);
// JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField();
// textField.setEditable(true);
// DefaultFormatterFactory factory = (DefaultFormatterFactory) textField .getFormatterFactory();
// NumberFormatter formatter = (NumberFormatter) factory.getDefaultFormatter();
// formatter.setAllowsInvalid(false);
downButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/source/moveDown.png"));
upButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/source/moveUp.png"));
downButton.setActionCommand("less");
upButton.setActionCommand("more");
downButton.addActionListener(buttonActionListener);
upButton.addActionListener(buttonActionListener);
showValButton = new UIButton(showValSpinner.getValue() + "%");
showValButton.setBorderPainted(false);
showValButton.setPreferredSize(new Dimension(SHOWVALBUTTON_WIDTH, SHOWVALBUTTON_HEIGHTH));
showValButton.addActionListener(showValButtonActionListener);
initUIRadioButton();
initPane();
JPanel panel = new JPanel(new FlowLayout(1, 1, 0));
panel.add(downButton);
panel.add(slider);
panel.add(upButton);
panel.add(showValButton);
this.add(panel, BorderLayout.NORTH);
this.setBounds(0, 0, THREE_HUNDRED, ONE_EIGHT);
}
public static final JFormSliderPane getInstance() {
// if (THIS == null) {
// THIS = new JFormSliderPane();
// }
THIS = new JFormSliderPane();
return THIS;
}
private void initUIRadioButton() {
twoHundredButton = new UIRadioButton("200%");
oneHundredButton = new UIRadioButton("100%");
SevenFiveButton = new UIRadioButton("75%");
fiveTenButton = new UIRadioButton("50%");
twoFiveButton = new UIRadioButton("25%");
// selfAdaptButton = new UIRadioButton(Inter.getLocText("FR-Designer_Scale_selfAdaptButton"));
customButton = new UIRadioButton(Inter.getLocText("FR-Designer_Scale_customButton"));
twoHundredButton.addItemListener(radioButtonItemListener);
oneHundredButton.addItemListener(radioButtonItemListener);
SevenFiveButton.addItemListener(radioButtonItemListener);
fiveTenButton.addItemListener(radioButtonItemListener);
twoFiveButton.addItemListener(radioButtonItemListener);
//TODO
// selfAdaptButton.addItemListener();
ButtonGroup bg = new ButtonGroup();// 初始化按钮组
bg.add(twoHundredButton);// 加入按钮组
bg.add(oneHundredButton);
bg.add(SevenFiveButton);
bg.add(fiveTenButton);
bg.add(twoFiveButton);
// bg.add(selfAdaptButton);
bg.add(customButton);
customButton.setSelected(true);
}
private void initPane() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {p, f};
double[] rowSize = {p, p, p, p, p, p, p};
Component[][] components = new Component[][]{
new Component[]{twoHundredButton, null},
new Component[]{oneHundredButton, null},
new Component[]{SevenFiveButton, null},
new Component[]{fiveTenButton, null},
new Component[]{twoFiveButton, null},
// new Component[]{selfAdaptButton,null},
new Component[]{customButton, createSpinnerPanel()}
};
dialogContentPanel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
}
private JPanel createSpinnerPanel() {
JPanel spinnerPanel = new JPanel(new FlowLayout());
spinnerPanel.add(showValSpinner);
UILabel percent = new UILabel("%");
percent.setFont(new Font("Dialog", Font.PLAIN, FONT_SIZE));
spinnerPanel.add(percent);
return spinnerPanel;
}
ActionListener showValButtonActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
popupDialog();
}
};
ChangeListener showValSpinnerChangeListener = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
int val = (int) ((UIBasicSpinner) e.getSource()).getValue();
isButtonOrIsTxt = true;
resolutionTimes = divide(showValue, 100, 2);
if (val > FOUR_HUNDRED) {
showValSpinner.setValue(FOUR_HUNDRED);
val = FOUR_HUNDRED;
}
if (val < TEN) {
showValSpinner.setValue(TEN);
val = TEN;
}
refreshSlider(val);
refreshBottun(val);
}
};
//定义一个监听器,用于监听所有滑动条
ChangeListener listener = new ChangeListener() {
public void stateChanged(ChangeEvent event) {
//取出滑动条的值,并在文本中显示出来
if (!isButtonOrIsTxt) {
customButton.setSelected(true);
EventQueue.invokeLater(new Runnable() {
public void run() {
sliderValue = slider.getValue();
getTimes(sliderValue);
showValue = times;
showValSpinner.setValue(times);
}
});
} else {
isButtonOrIsTxt = false;
}
}
};
ItemListener radioButtonItemListener = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
JRadioButton temp = (JRadioButton) e.getSource();
if (temp.isSelected()) {
showValSpinner.setValue(Integer.valueOf(temp.getText().substring(0, temp.getText().indexOf("%"))));
}
}
};
private void refreshSlider(int val) {
showValue = val;
if (showValue > HUNDRED) {
slider.setValue((int) (showValue + TWO_HUNDRED) / SIX);
} else if (showValue < HUNDRED) {
slider.setValue((int) ((showValue - TEN) / ONEPOINTEIGHT));
} else if (showValue == HUNDRED) {
slider.setValue(HALF_HUNDRED);
}
}
private void refreshBottun(int val) {
showValButton.setText(val + "%");
}
public double getResolutionTimes() {
return this.resolutionTimes;
}
public int getshowValue() {
return this.showValue;
}
public static double divide(double v1, double v2, int scale) {
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.divide(b2, scale).doubleValue();
}
ActionListener buttonActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
showValue = (int) showValSpinner.getValue();
isButtonOrIsTxt = true;
if (e.getActionCommand().equals("less")) {
int newDownVal = showValue - TEN;
if (newDownVal >= TEN) {
showValue = newDownVal;
showValSpinner.setValue(newDownVal);
} else {
showValue = newDownVal;
showValSpinner.setValue(TEN);
}
}
if (e.getActionCommand().equals("more")) {
int newUpVal = showValue + TEN;
if (newUpVal <= FOUR_HUNDRED) {
showValue = newUpVal;
showValSpinner.setValue(newUpVal);
} else {
showValue = newUpVal;
showValSpinner.setValue(FOUR_HUNDRED);
}
}
isButtonOrIsTxt = true;
customButton.setSelected(true);
}
};
private void getTimes(int value) {
if (value == HALF_HUNDRED) {
times = HUNDRED;
} else if (value < HALF_HUNDRED) {
times = (int) Math.round(ONEPOINTEIGHT * value + TEN);
} else {
times = (int) (SIX * value - TWO_HUNDRED);
}
}
public JSpinner getShowVal() {
return this.showValSpinner;
}
public UIRadioButton getSelfAdaptButton() {
return this.selfAdaptButton;
}
private void popupDialog() {
Point btnCoords = upButton.getLocationOnScreen();
if (dialog == null) {
dialog = new FormPopupPane(upButton, dialogContentPanel);
if (upButtonX == 0) {
upButtonX = btnCoords.x;
GUICoreUtils.showPopupMenu(dialog, upButton, -DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT);
}
} else {
if (upButtonX == 0) {
upButtonX = btnCoords.x;
GUICoreUtils.showPopupMenu(dialog, upButton, -DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT);
} else {
GUICoreUtils.showPopupMenu(dialog, upButton, -DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT);
}
}
}
public static void main(String[] args) {
JFrame jf = new JFrame("test");
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel content = (JPanel) jf.getContentPane();
content.setLayout(new BorderLayout());
content.add(JFormSliderPane.getInstance(), BorderLayout.CENTER);
GUICoreUtils.centerWindow(jf);
jf.setSize(400, 80);
jf.setVisible(true);
}
}
class FormPopupPane extends JPopupMenu {
private JComponent contentPane;
private static final int UPLABEL_HEIGHT = 25;
private static final int DIALOG_WIDTH = 150;
private static final int DIALOG_HEIGHT = 220;
private static final int UPLABEL_WIDTH = 300;
private JComponent centerPane;
private UILabel upLabel;
FormPopupPane(UIButton b, JPanel dialogContentPanel) {
contentPane = new JPanel(new BorderLayout());
centerPane = new JPanel(new BorderLayout());
upLabel = new UILabel(" " + Inter.getLocText("FR-Designer_Scale_EnlargeOrReduce"));
upLabel.setOpaque(true);
upLabel.setPreferredSize(new Dimension(UPLABEL_WIDTH, UPLABEL_HEIGHT));
upLabel.setBackground(Color.LIGHT_GRAY);
upLabel.setBorder(new MatteBorder(0, 0, 1, 0, Color.gray));
centerPane.add(dialogContentPanel, BorderLayout.NORTH);
contentPane.add(upLabel, BorderLayout.NORTH);
contentPane.add(centerPane, BorderLayout.CENTER);
// contentPane.setBorder(new MatteBorder(1,1,1,1,Color.darkGray));
this.add(contentPane, BorderLayout.CENTER);
this.setPreferredSize(new Dimension(DIALOG_WIDTH, DIALOG_HEIGHT));
this.setOpaque(false);
}
}

353
designer_base/src/com/fr/design/mainframe/JSliderPane.java

@ -5,7 +5,10 @@ import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.islider.UISlider;
import com.fr.design.gui.ispinner.UIBasicSpinner;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.Inter;
@ -13,11 +16,12 @@ import javax.swing.*;
import javax.swing.border.MatteBorder;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.plaf.basic.BasicSliderUI;
import java.awt.*;
import java.awt.event.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.math.BigDecimal;
/**
@ -28,19 +32,24 @@ public class JSliderPane extends JPanel {
private static final double ONEPOINTEIGHT = 1.8;
private static final int SIX = 6;
private static final int TEN = 10;
private static final int ONEEIGHT = 18;
private static final int FOURTEN = 40;
private static final int HALFHUNDRED = 50;
private static final int ONE_EIGHT = 18;
private static final int FONT_SIZE = 14;
private static final int SPINNER_WIDTH = 45;
private static final int SPINNER_HEIGHT = 20;
private static final int HALF_HUNDRED = 50;
private static final int HUNDRED = 100;
private static final int TWOHUNDRED = 200;
private static final int THREEHUNDRED = 300;
private static final int FOURHUNDRED = 400;
private static final int DIALOGWIDTH = 150;
private static final int DIALOGHEIGHT = 200;
private static final int TWO_HUNDRED = 200;
private static final int THREE_HUNDRED = 300;
private static final int FOUR_HUNDRED = 400;
private static final int DIALOG_WIDTH = 150;
private static final int DIALOG_HEIGHT = 240;
private static final int SHOWVALBUTTON_WIDTH = 70;
private static final int SHOWVALBUTTON_HEIGHTH = 25;
public int showValue = 100;
public double resolutionTimes = 1.0;
private static JSliderPane THIS;
private UITextField showVal;
private JSpinner showValSpinner;
private UISlider slider;
private int times;
private int sliderValue;
@ -58,19 +67,27 @@ public class JSliderPane extends JPanel {
private boolean isButtonOrIsTxt = true;
private PopupPane dialog;
private int upButtonX;
private JPanel dialogContentPanel;
public JSliderPane() {
this.setLayout(new BorderLayout());
slider = new UISlider(0,HUNDRED,HALFHUNDRED);
slider = new UISlider(0, HUNDRED, HALF_HUNDRED);
slider.setUI(new JSliderPaneUI(slider));
slider.addChangeListener(listener);
showVal = new UITextField();
showVal.setText("100%");
showVal.setPreferredSize(new Dimension(FOURTEN,ONEEIGHT));
showVal.getDocument().addDocumentListener(showValDocumentListener);
showValSpinner = new UIBasicSpinner(new SpinnerNumberModel(HUNDRED, TEN, FOUR_HUNDRED, 1));
showValSpinner.setEnabled(true);
showValSpinner.addChangeListener(showValSpinnerChangeListener);
showValSpinner.setPreferredSize(new Dimension(SPINNER_WIDTH, SPINNER_HEIGHT));
//MoMeak:控制只能输入10-400,但是用起来感觉不舒服,先注释掉吧
// JSpinner.NumberEditor editor = new JSpinner.NumberEditor(showValSpinner, "0");
// showValSpinner.setEditor(editor);
// JFormattedTextField textField = ((JSpinner.NumberEditor) showValSpinner.getEditor()).getTextField();
// textField.setEditable(true);
// DefaultFormatterFactory factory = (DefaultFormatterFactory) textField .getFormatterFactory();
// NumberFormatter formatter = (NumberFormatter) factory.getDefaultFormatter();
// formatter.setAllowsInvalid(false);
downButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/source/moveDown.png"));
upButton = new UIButton(BaseUtils.readIcon("com/fr/design/images/data/source/moveUp.png"));
downButton.setActionCommand("less");
@ -78,25 +95,19 @@ public class JSliderPane extends JPanel {
downButton.addActionListener(buttonActionListener);
upButton.addActionListener(buttonActionListener);
JPanel panel = new JPanel(new FlowLayout(1,1,0));
showValButton = new UIButton(showVal.getText());
showValButton = new UIButton(showValSpinner.getValue() + "%");
showValButton.setBorderPainted(false);
showValButton.setPreferredSize(new Dimension(HALFHUNDRED,ONEEIGHT));
showValButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
popupDialog();
}
});
showValButton.setPreferredSize(new Dimension(SHOWVALBUTTON_WIDTH, SHOWVALBUTTON_HEIGHTH));
showValButton.addActionListener(showValButtonActionListener);
initUIRadioButton();
initPane();
JPanel panel = new JPanel(new FlowLayout(1, 1, 0));
panel.add(downButton);
panel.add(slider);
panel.add(upButton);
panel.add(showValButton);
this.add(panel,BorderLayout.NORTH);
this.setBounds(0,0,THREEHUNDRED,ONEEIGHT);
this.add(panel, BorderLayout.NORTH);
this.setBounds(0, 0, THREE_HUNDRED, ONE_EIGHT);
}
public static final JSliderPane getInstance() {
@ -107,7 +118,7 @@ public class JSliderPane extends JPanel {
return THIS;
}
private void initUIRadioButton(){
private void initUIRadioButton() {
twoHundredButton = new UIRadioButton("200%");
oneHundredButton = new UIRadioButton("100%");
SevenFiveButton = new UIRadioButton("75%");
@ -115,8 +126,15 @@ public class JSliderPane extends JPanel {
twoFiveButton = new UIRadioButton("25%");
selfAdaptButton = new UIRadioButton(Inter.getLocText("FR-Designer_Scale_selfAdaptButton"));
customButton = new UIRadioButton(Inter.getLocText("FR-Designer_Scale_customButton"));
ButtonGroup bg=new ButtonGroup();// 初始化按钮组
twoHundredButton.addItemListener(radioButtonItemListener);
oneHundredButton.addItemListener(radioButtonItemListener);
SevenFiveButton.addItemListener(radioButtonItemListener);
fiveTenButton.addItemListener(radioButtonItemListener);
twoFiveButton.addItemListener(radioButtonItemListener);
//TODO
// selfAdaptButton.addItemListener();
ButtonGroup bg = new ButtonGroup();// 初始化按钮组
bg.add(twoHundredButton);// 加入按钮组
bg.add(oneHundredButton);
bg.add(SevenFiveButton);
@ -124,151 +142,196 @@ public class JSliderPane extends JPanel {
bg.add(twoFiveButton);
bg.add(selfAdaptButton);
bg.add(customButton);
customButton.setSelected(true);
}
private void initPane() {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {p, f};
double[] rowSize = {p, p, p, p, p, p, p};
Component[][] components = new Component[][]{
new Component[]{twoHundredButton, null},
new Component[]{oneHundredButton, null},
new Component[]{SevenFiveButton, null},
new Component[]{fiveTenButton, null},
new Component[]{twoFiveButton, null},
new Component[]{selfAdaptButton, null},
new Component[]{customButton, createSpinnerPanel()}
};
dialogContentPanel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
}
private JPanel createSpinnerPanel() {
JPanel spinnerPanel = new JPanel(new FlowLayout());
spinnerPanel.add(showValSpinner);
UILabel percent = new UILabel("%");
percent.setFont(new Font("Dialog", Font.PLAIN, FONT_SIZE));
spinnerPanel.add(percent);
return spinnerPanel;
}
ActionListener showValButtonActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
popupDialog();
}
};
ChangeListener showValSpinnerChangeListener = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
int val = (int) ((UIBasicSpinner) e.getSource()).getValue();
isButtonOrIsTxt = true;
resolutionTimes = divide(showValue, 100, 2);
if (val > FOUR_HUNDRED) {
showValSpinner.setValue(FOUR_HUNDRED);
val = FOUR_HUNDRED;
}
if (val < TEN) {
showValSpinner.setValue(TEN);
val = TEN;
}
refreshSlider(val);
refreshBottun(val);
}
};
//定义一个监听器,用于监听所有滑动条
ChangeListener listener = new ChangeListener()
{
public void stateChanged( ChangeEvent event) {
ChangeListener listener = new ChangeListener() {
public void stateChanged(ChangeEvent event) {
//取出滑动条的值,并在文本中显示出来
if (!isButtonOrIsTxt){
JSlider source = (JSlider) event.getSource();
if (!isButtonOrIsTxt) {
customButton.setSelected(true);
EventQueue.invokeLater(new Runnable() {
public void run() {
sliderValue = slider.getValue();
getTimes(sliderValue);
showValue = times;
showVal.setText(times + "%");
showValSpinner.setValue(times);
}
});
}else {
} else {
isButtonOrIsTxt = false;
}
}
};
DocumentListener showValDocumentListener = new DocumentListener() {
ItemListener radioButtonItemListener = new ItemListener() {
@Override
public void insertUpdate(DocumentEvent e) {
isButtonOrIsTxt = true;
resolutionTimes = divide(showValue,100,2);
refreshSlider();
refreshBottun();
public void itemStateChanged(ItemEvent e) {
JRadioButton temp = (JRadioButton) e.getSource();
if (temp.isSelected()) {
showValSpinner.setValue(Integer.valueOf(temp.getText().substring(0, temp.getText().indexOf("%"))));
}
@Override
public void removeUpdate(DocumentEvent e) {
// refreshSlider();
}
@Override
public void changedUpdate(DocumentEvent e) {
// refreshSlider();
}
};
private void refreshSlider(){
showValue = Integer.parseInt(showVal.getText().substring(0, showVal.getText().indexOf("%")));
if (showValue >HUNDRED){
slider.setValue((int)(showValue+TWOHUNDRED)/SIX);
}else if (showValue <HUNDRED){
slider.setValue((int)((showValue-TEN)/ONEPOINTEIGHT));
}else if (showValue == HUNDRED){
slider.setValue(HALFHUNDRED);
private void refreshSlider(int val) {
showValue = val;
if (showValue > HUNDRED) {
slider.setValue((int) (showValue + TWO_HUNDRED) / SIX);
} else if (showValue < HUNDRED) {
slider.setValue((int) ((showValue - TEN) / ONEPOINTEIGHT));
} else if (showValue == HUNDRED) {
slider.setValue(HALF_HUNDRED);
}
}
private void refreshBottun(){
showValButton.setText(showVal.getText());
private void refreshBottun(int val) {
showValButton.setText(val + "%");
}
public double getResolutionTimes(){
public double getResolutionTimes() {
return this.resolutionTimes;
}
public int getshowValue(){
public int getshowValue() {
return this.showValue;
}
public static double divide(double v1, double v2,int scale) {
public static double divide(double v1, double v2, int scale) {
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.divide(b2,scale).doubleValue();
return b1.divide(b2, scale).doubleValue();
}
ActionListener buttonActionListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
showValue = Integer.parseInt(showVal.getText().substring(0, showVal.getText().indexOf("%")));
showValue = (int) showValSpinner.getValue();
isButtonOrIsTxt = true;
if(e.getActionCommand().equals("less")){
if (e.getActionCommand().equals("less")) {
int newDownVal = showValue - TEN;
if (newDownVal >= TEN ){
if (newDownVal >= TEN) {
showValue = newDownVal;
showVal.setText(newDownVal + "%");
}else {
showValSpinner.setValue(newDownVal);
} else {
showValue = newDownVal;
showVal.setText(TEN + "%");
showValSpinner.setValue(TEN);
}
}
if(e.getActionCommand().equals("more")){
if (e.getActionCommand().equals("more")) {
int newUpVal = showValue + TEN;
if (newUpVal <= FOURHUNDRED ){
if (newUpVal <= FOUR_HUNDRED) {
showValue = newUpVal;
showVal.setText(newUpVal + "%");
}else {
showValSpinner.setValue(newUpVal);
} else {
showValue = newUpVal;
showVal.setText(FOURHUNDRED + "%");
showValSpinner.setValue(FOUR_HUNDRED);
}
}
isButtonOrIsTxt = true;
customButton.setSelected(true);
}
};
private void getTimes(int value){
if (value == HALFHUNDRED){
times=HUNDRED;
}else if (value < HALFHUNDRED){
times = (int) Math.round(ONEPOINTEIGHT*value + TEN);
}else {
times = (int) (SIX*value - TWOHUNDRED);
private void getTimes(int value) {
if (value == HALF_HUNDRED) {
times = HUNDRED;
} else if (value < HALF_HUNDRED) {
times = (int) Math.round(ONEPOINTEIGHT * value + TEN);
} else {
times = (int) (SIX * value - TWO_HUNDRED);
}
}
public UITextField getShowVal(){
return this.showVal;
public JSpinner getShowVal() {
return this.showValSpinner;
}
private void popupDialog(){
public UIRadioButton getSelfAdaptButton() {
return this.selfAdaptButton;
}
private void popupDialog() {
Point btnCoords = upButton.getLocationOnScreen();
if (dialog == null){
dialog = new PopupPane(upButton,showVal);
if (dialog == null) {
dialog = new PopupPane(upButton, dialogContentPanel);
if (upButtonX == 0) {
upButtonX = btnCoords.x;
GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOGWIDTH + upButton.getWidth() +HALFHUNDRED, -DIALOGHEIGHT);
GUICoreUtils.showPopupMenu(dialog, upButton, -DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT);
}
}else {
} else {
if (upButtonX == 0) {
upButtonX = btnCoords.x;
GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOGWIDTH + upButton.getWidth() +HALFHUNDRED, -DIALOGHEIGHT);
GUICoreUtils.showPopupMenu(dialog, upButton, -DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT);
} else {
GUICoreUtils.showPopupMenu(dialog, upButton, - DIALOGWIDTH + upButton.getWidth() +HALFHUNDRED, -DIALOGHEIGHT);
GUICoreUtils.showPopupMenu(dialog, upButton, -DIALOG_WIDTH + upButton.getWidth() + SHOWVALBUTTON_WIDTH, -DIALOG_HEIGHT);
}
}
}
public static void main(String[] args)
{
public static void main(String[] args) {
JFrame jf = new JFrame("test");
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel content = (JPanel)jf.getContentPane();
JPanel content = (JPanel) jf.getContentPane();
content.setLayout(new BorderLayout());
content.add(JSliderPane.getInstance(),BorderLayout.CENTER);
content.add(JSliderPane.getInstance(), BorderLayout.CENTER);
GUICoreUtils.centerWindow(jf);
jf.setSize(400, 80);
jf.setVisible(true);
@ -296,11 +359,10 @@ class JSliderPaneUI extends BasicSliderUI {
public Dimension getThumbSize() {
Dimension size = new Dimension();
if ( slider.getOrientation() == JSlider.VERTICAL ) {
if (slider.getOrientation() == JSlider.VERTICAL) {
size.width = VERTICAL_WIDTH;
size.height = VERTICAL_HEIGHT;
}
else {
} else {
size.width = VERTICAL_WIDTH;
size.height = VERTICAL_HEIGHT;
}
@ -314,14 +376,13 @@ class JSliderPaneUI extends BasicSliderUI {
int h = knobBounds.height;
g.translate(knobBounds.x, knobBounds.y);
if ( slider.isEnabled() ) {
if (slider.isEnabled()) {
g.setColor(slider.getBackground());
}
else {
} else {
g.setColor(slider.getBackground().darker());
}
g.setColor(Color.darkGray);
g.fillRect(0, 1, w-SIX, h+1);
g.fillRect(0, 1, w - SIX, h + 1);
}
/** */
@ -336,82 +397,40 @@ class JSliderPaneUI extends BasicSliderUI {
cy = (trackBounds.height / 2);
cw = trackBounds.width;
g.setColor(Color.lightGray);
g.drawLine(0, cy, cw+FIVE, cy);
g.drawLine(FIVE+cw/2, cy-FOUR, FIVE+cw/2, cy+FOUR);
g.drawLine(0, cy, cw + FIVE, cy);
g.drawLine(FIVE + cw / 2, cy - FOUR, FIVE + cw / 2, cy + FOUR);
} else {
super.paintTrack(g);
}
}
}
class Dialog extends JDialog {
// private Container container;
// private static final int UPLABELHEIGHT = 25;
// private static final int HALFHUNDRED = 50;
// private static final int DIALOGWIDTH = 150;
// private static final int DIALOGHEIGHT = 200;
// private static final int UPLABELWIDTH = 300;
// private int minHeight; // 对话框最小高度
// private JComponent contentPane;
// private JComponent centerPane;
// private UILabel upLabel;
// public Dialog(UIButton b,UITextField j) {
// super(DesignerContext.getDesignerFrame());
// container = getContentPane();
// setUndecorated(true);
// contentPane = new JPanel(new BorderLayout());
// centerPane = new JPanel(new BorderLayout());
// upLabel = new UILabel(Inter.getLocText("FR-Designer_Scale_EnlargeOrReduce"));
// upLabel.setOpaque(true);
// upLabel.setPreferredSize(new Dimension(UPLABELWIDTH,UPLABELHEIGHT));
// upLabel.setBackground(Color.LIGHT_GRAY);
// upLabel.setBorder(BorderFactory.createLineBorder(Color.gray,1));
// upLabel.setBorder(new MatteBorder(0,0,1,0,Color.gray));
// centerPane.add(j,BorderLayout.NORTH);
// contentPane.add(upLabel,BorderLayout.NORTH);
// contentPane.add(centerPane,BorderLayout.CENTER);
//// contentPane.setBorder(BorderFactory.createLineBorder(Color.gray,1));
// contentPane.setBorder(new MatteBorder(1,1,1,1,Color.darkGray));
//// contentPane.add(new JPanel())
// container.add(contentPane, BorderLayout.CENTER);
// minHeight = container.getPreferredSize().height;
// setSize(DIALOGWIDTH, DIALOGHEIGHT);
//// validate();
// Point btnCoords = b.getLocationOnScreen();
//
// this.setLocation(btnCoords.x - DIALOGWIDTH + b.getWidth() +HALFHUNDRED, btnCoords.y -DIALOGHEIGHT);
//// initListener();
//
// this.setVisible(true);
// }
}
class PopupPane extends JPopupMenu {
private JComponent contentPane;
private static final int UPLABELHEIGHT = 25;
private static final int HALFHUNDRED = 50;
private static final int DIALOGWIDTH = 150;
private static final int DIALOGHEIGHT = 200;
private static final int UPLABELWIDTH = 300;
private static final int UPLABEL_HEIGHT = 25;
private static final int DIALOG_WIDTH = 150;
private static final int DIALOG_HEIGHT = 240;
private static final int UPLABEL_WIDTH = 300;
private JComponent centerPane;
private UILabel upLabel;
PopupPane(UIButton b,UITextField j) {
PopupPane(UIButton b, JPanel dialogContentPanel) {
contentPane = new JPanel(new BorderLayout());
centerPane = new JPanel(new BorderLayout());
upLabel = new UILabel(Inter.getLocText("FR-Designer_Scale_EnlargeOrReduce"));
upLabel = new UILabel(" " + Inter.getLocText("FR-Designer_Scale_EnlargeOrReduce"));
upLabel.setOpaque(true);
upLabel.setPreferredSize(new Dimension(UPLABELWIDTH,UPLABELHEIGHT));
upLabel.setPreferredSize(new Dimension(UPLABEL_WIDTH, UPLABEL_HEIGHT));
upLabel.setBackground(Color.LIGHT_GRAY);
upLabel.setBorder(new MatteBorder(0,0,1,0,Color.gray));
centerPane.add(j,BorderLayout.NORTH);
contentPane.add(upLabel,BorderLayout.NORTH);
contentPane.add(centerPane,BorderLayout.CENTER);
upLabel.setBorder(new MatteBorder(0, 0, 1, 0, Color.gray));
centerPane.add(dialogContentPanel, BorderLayout.NORTH);
contentPane.add(upLabel, BorderLayout.NORTH);
contentPane.add(centerPane, BorderLayout.CENTER);
// contentPane.setBorder(new MatteBorder(1,1,1,1,Color.darkGray));
this.add(contentPane, BorderLayout.CENTER);
this.setPreferredSize(new Dimension(DIALOGWIDTH, DIALOGHEIGHT));
this.setPreferredSize(new Dimension(DIALOG_WIDTH, DIALOG_HEIGHT));
this.setOpaque(false);
}
}

27
designer_base/src/com/fr/design/mainframe/JTemplate.java

@ -1,9 +1,6 @@
package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.base.ConfigManager;
import com.fr.base.FRContext;
import com.fr.base.Parameter;
import com.fr.base.*;
import com.fr.base.io.IOFile;
import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignState;
@ -51,6 +48,7 @@ import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants;
import javax.swing.*;
import javax.swing.Icon;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.undo.UndoManager;
import java.awt.*;
@ -82,6 +80,7 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
private long openTime = 0L; // 打开模板的时间点(包括新建模板)
private TemplateInfoCollector tic = TemplateInfoCollector.getInstance();
private StringBuilder process = new StringBuilder(""); // 制作模板的过程
public int resolution = ScreenResolution.getScreenResolution();
public JTemplate(T t, String defaultFileName) {
this(t, new MemFILE(newTemplateNameByIndex(defaultFileName)), true);
@ -144,6 +143,14 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
return undoState;
}
/**
* set/get 模板屏幕分辨率
*/
public abstract void setJTemplateResolution(int resolution);
public abstract int getJTemplateResolution();
/**
* 初始化权限细粒度撤销状态
*/
@ -213,10 +220,18 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
*/
public abstract void removeParameterPaneSelection();
/**
* 缩放参数
*/
public abstract void setScale(int resolution);
public abstract int getScale();
/**
* 缩放参数自适应
*/
public abstract int selfAdaptUpdate();
protected abstract DesignModelAdapter<T, ?> createDesignModel();
/**
@ -867,9 +882,7 @@ public abstract class JTemplate<T extends IOFile, U extends BaseUndoState<?>> ex
* 返回当前支持的超链界面pane
* @return 超链连接界面
*/
public HyperlinkGroupPane getHyperLinkPane() {
return new HyperlinkGroupPane();
}
public abstract HyperlinkGroupPane getHyperLinkPane();
/**
* 是否是图表

11
designer_chart/src/com/fr/design/chart/gui/ChartComponent.java

@ -13,6 +13,7 @@ import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartglyph.AxisGlyph;
import com.fr.design.chart.gui.active.ActiveGlyph;
import com.fr.design.chart.gui.active.ChartActiveGlyph;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.chart.MiddleChartComponent;
import com.fr.stable.ArrayUtils;
import com.fr.stable.core.PropertyChangeListener;
@ -41,7 +42,7 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
private int chartWidth = -1;
private int chartHeight = -1;
private Point point;
private int resolution = ScreenResolution.getScreenResolution();
private ActiveGlyph activeGlyph;
private boolean supportEdit = true;
@ -315,7 +316,13 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
//不直接画chartGlyph而画image的原因是表单的柱形图会溢出表单
//其他图都ok,其实感觉应该是柱形图画的不对,应该也可以改那边
//处理画图事件
Image chartImage = chartGlyph.toImage(chartWidth,chartHeight,ScreenResolution.getScreenResolution(), this, null);
resolution = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getJTemplateResolution();
if (resolution == 0){
resolution = ScreenResolution.getScreenResolution();
}
Image chartImage = chartGlyph.toImage(chartWidth,chartHeight,resolution, this, null);
g2d.drawImage(chartImage, 0, 0, null);
}
}

12
designer_form/src/com/fr/design/gui/xpane/FormHyperlinkGroupPane.java

@ -9,6 +9,18 @@ import com.fr.general.Inter;
import com.fr.js.EmailJavaScript;
public class FormHyperlinkGroupPane extends HyperlinkGroupPane{
private static FormHyperlinkGroupPane singleton;
private FormHyperlinkGroupPane() {
super();
}
public synchronized static FormHyperlinkGroupPane getInstance() {
if (singleton == null) {
singleton = new FormHyperlinkGroupPane();
}
return singleton;
}
/**
* 生成添加按钮的NameableCreator

83
designer_form/src/com/fr/design/mainframe/FormArea.java

@ -9,11 +9,7 @@ import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.MouseEvent;
import java.awt.event.*;
import javax.swing.JComponent;
import javax.swing.JPanel;
@ -23,6 +19,7 @@ import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import com.fr.base.ScreenResolution;
import com.fr.design.designer.beans.events.DesignerEvent;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer;
@ -31,6 +28,7 @@ import com.fr.design.designer.creator.XWFitLayout;
import com.fr.design.file.HistoryTemplateListPane;
import com.fr.design.gui.frpane.UINumberSlidePane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UIBasicSpinner;
import com.fr.design.gui.itextfield.UINumberField;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
@ -63,12 +61,13 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
//显示和设置表单界面大小的控件
private UINumberField widthPane;
private UINumberField heightPane;
private JSliderPane slidePane;
private JFormSliderPane slidePane;
private boolean isValid = true;
// 初始时滑块值为100,托动后的值设为START_VALUE;
private double START_VALUE = DEFAULT_SLIDER;
private int resolution = ScreenResolution.getScreenResolution();
private double screenValue;
private JSliderPane sliderPane;
private boolean isCtrl = false;
public FormScrollBar getHorScrollBar() {
return horScrollBar;
@ -103,8 +102,39 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
addFormRuler();
}
this.setFocusTraversalKeysEnabled(false);
this.designer.addMouseWheelListener(showValSpinnerMouseWheelListener);
this.designer.addKeyListener(showValSpinnerKeyListener);
}
KeyListener showValSpinnerKeyListener = new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyPressed(KeyEvent e) {
if( e.isControlDown()){
isCtrl = true ;
}
}
@Override
public void keyReleased(KeyEvent e) {
isCtrl = false ;
}
};
MouseWheelListener showValSpinnerMouseWheelListener = new MouseWheelListener() {
@Override
public void mouseWheelMoved(MouseWheelEvent e) {
if (isCtrl){
int dir = e.getWheelRotation();
int old_resolution = (int) slidePane.getShowVal().getValue();
slidePane.getShowVal().setValue(old_resolution - (dir * SHOWVALMIN));
}
}
};
/**
* 增加表单的页面大小控制界面包括手动修改和滑块拖动
*/
@ -122,8 +152,8 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
// slidePane = new UINumberSlidePane(SLIDER_MIN, SLIDER_FLOAT);
// slidePane.setPreferredSize(new Dimension(260,20));
slidePane = JSliderPane.getInstance();
slidePane.setPreferredSize(new Dimension(300,20));
slidePane = JFormSliderPane.getInstance();
slidePane.setPreferredSize(new Dimension(350,20));
JPanel resizePane =TableLayoutHelper.createCommonTableLayoutPane(new JComponent[][]{
@ -153,39 +183,26 @@ public class FormArea extends JComponent implements ScrollRulerComponent {
private void initTransparent() {
initCalculateSize();
slidePane.getShowVal().getDocument().addDocumentListener(new DocumentListener() {
slidePane.getShowVal().addChangeListener(showValSpinnerChangeListener);
}
ChangeListener showValSpinnerChangeListener = new ChangeListener() {
@Override
public void insertUpdate(DocumentEvent e) {
// slidePane.getShowVal().getDocument()
double value = Integer.parseInt(slidePane.getShowVal().getText().substring(0, slidePane.getShowVal().getText().indexOf("%")));
public void stateChanged(ChangeEvent e) {
double value = (int) ((UIBasicSpinner)e.getSource()).getValue();
value = value>SHOWVALMAX ? SHOWVALMAX : value;
value = value<SHOWVALMIN ? SHOWVALMIN : value;
JForm jf = (JForm) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
jf.resolution = (int) value;
jf.getFormDesign().setResolution((int) value);
jf.getFormDesign().getArea().resolution = (int) value;
reCalculateRoot(value, true);
JTemplate form = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
if(form != null){
form.fireTargetModified();
}
}
@Override
public void removeUpdate(DocumentEvent e) {
}
@Override
public void changedUpdate(DocumentEvent e) {
}
});
// slidePane.addChangeListener(new ChangeListener() {
// public void stateChanged(ChangeEvent e) {
// double value = ((UINumberSlidePane) e.getSource()).getValue();
// reCalculateRoot(value, true);
// JTemplate form = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
// if(form != null){
// form.fireTargetModified();
// }
// }
// });
}
};
/**
* 返回当前的屏幕分辨率对应的百分比值

11
designer_form/src/com/fr/design/mainframe/FormDesigner.java

@ -2,6 +2,7 @@ package com.fr.design.mainframe;
import com.fr.base.BaseUtils;
import com.fr.base.Parameter;
import com.fr.base.ScreenResolution;
import com.fr.design.DesignState;
import com.fr.design.designer.TargetComponent;
import com.fr.design.designer.beans.AdapterBus;
@ -47,6 +48,7 @@ import com.fr.general.ComparatorUtils;
import com.fr.general.FRLogger;
import com.fr.general.Inter;
import com.fr.stable.ArrayUtils;
import com.fr.stable.CoreGraphHelper;
import com.fr.stable.bridge.StableFactory;
import javax.swing.*;
@ -103,6 +105,7 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
// 存储被选择组件和剪切板的model
private transient SelectionModel selectionModel;
private int resolution = ScreenResolution.getScreenResolution();
// 编辑状态的事件表
private CreatorEventListenerTable edit;
protected Action[] designerActions;
@ -1416,4 +1419,12 @@ public class FormDesigner extends TargetComponent<Form> implements TreeSelection
}
}
public void setResolution(int resolution){
this.resolution = resolution;
}
public int getResolution(){
return this.resolution;
}
}

26
designer_form/src/com/fr/design/mainframe/FormDesignerUI.java

@ -7,6 +7,7 @@ import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.geom.Area;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import javax.swing.JComponent;
@ -15,6 +16,7 @@ import javax.swing.plaf.ComponentUI;
import com.fr.base.BaseUtils;
import com.fr.base.GraphHelper;
import com.fr.base.ScreenResolution;
import com.fr.base.Utils;
import com.fr.design.constants.UIConstants;
import com.fr.design.designer.beans.AdapterBus;
@ -31,6 +33,7 @@ import com.fr.design.utils.ComponentUtils;
import com.fr.general.Inter;
import com.fr.stable.ArrayUtils;
import com.fr.stable.Constants;
import com.fr.stable.CoreGraphHelper;
/**
* FormDesigner的UI类是一个有状态的UI类它根据FormDesigner的当前状态画出
@ -42,6 +45,7 @@ public class FormDesignerUI extends ComponentUI {
private FormDesigner designer;
private SelectionModel selectionModel;
private Rectangle2D.Double back_or_selection_rect = new Rectangle2D.Double(0, 0, 0, 0);
private float time;
public FormDesignerUI() {
}
@ -63,6 +67,7 @@ public class FormDesignerUI extends ComponentUI {
@Override
public void paint(Graphics g, JComponent c) {
XCreator rootComponent = designer.getRootComponent();
this.time = (float)designer.getResolution()/ScreenResolution.getScreenResolution();
if (rootComponent != null) {
// 设计自适应界面
repaintFit(g, rootComponent, c);
@ -373,9 +378,17 @@ public class FormDesignerUI extends ComponentUI {
// 禁止双缓冲
ComponentUtils.disableBuffer(component, dbcomponents);
Graphics clipg;
clipg = g.create(-designer.getArea().getHorizontalValue(), -designer.getArea().getVerticalValue() + designer.getParaHeight(), parent
.getSize().width + designer.getArea().getHorizontalValue(), parent.getSize().height
+ designer.getArea().getVerticalValue());
clipg = g.create(
-designer.getArea().getHorizontalValue(),
-designer.getArea().getVerticalValue() + designer.getParaHeight(),
parent.getSize().width + designer.getArea().getHorizontalValue(),
parent.getSize().height + designer.getArea().getVerticalValue());
// BufferedImage img = CoreGraphHelper.createBufferedImage(parent.getSize().width + designer.getArea().getHorizontalValue(), parent.getSize().height + designer.getArea().getVerticalValue(), BufferedImage.TYPE_INT_RGB);
// Graphics2D g2d = img.createGraphics();
// component.printAll(g2d);
// g2d.dispose();
// g.drawImage(img,-designer.getArea().getHorizontalValue(),-designer.getArea().getVerticalValue() + designer.getParaHeight(), (int) (parent.getSize().width*time + designer.getArea().getHorizontalValue()), (int) (parent.getSize().height*time + designer.getArea().getVerticalValue()),null);
designer.paintContent(clipg);
clipg.dispose();
@ -397,9 +410,10 @@ public class FormDesignerUI extends ComponentUI {
// 禁止双缓冲
ComponentUtils.disableBuffer(component, dbcomponents);
Graphics clipg1;
clipg1 = g.create(-designer.getArea().getHorizontalValue(), -designer.getArea().getVerticalValue() , parent
.getSize().width + designer.getArea().getHorizontalValue(), designer.getParaHeight()
+ designer.getArea().getVerticalValue());
clipg1 = g.create(-designer.getArea().getHorizontalValue(),
-designer.getArea().getVerticalValue() ,
parent.getSize().width + designer.getArea().getHorizontalValue(),
designer.getParaHeight() + designer.getArea().getVerticalValue());
designer.paintPara(clipg1);
clipg1.dispose();

22
designer_form/src/com/fr/design/mainframe/JForm.java

@ -104,6 +104,20 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
return processInfo;
}
public FormECCompositeProvider getReportComposite(){
return this.reportComposite;
}
@Override
public void setJTemplateResolution(int resolution) {
}
@Override
public int getJTemplateResolution() {
return 0;
}
@Override
protected boolean accept(Object o) {
return !(o instanceof FloatElementsProvider);
@ -124,7 +138,7 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
* @return 超链连接界面
*/
public HyperlinkGroupPane getHyperLinkPane() {
return new FormHyperlinkGroupPane();
return FormHyperlinkGroupPane.getInstance();
}
//表单返回 FORM_TAB or ELEMENTCASE_TAB
@ -246,7 +260,6 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
@Override
public void setScale(int resolution) {
}
@Override
@ -254,6 +267,11 @@ public class JForm extends JTemplate<Form, FormUndoState> implements BaseJForm {
return 0;
}
@Override
public int selfAdaptUpdate() {
return 0;
}
/**
* 创建权限细粒度编辑面板
*

Loading…
Cancel
Save